Code Camp NYC 2016 Presentation
MongoDB For Developers And Accessing MongoDB data
This is where .NET, MongoDB, and SSIS meet. We'll begin with an overview of what MongoDB and NoSQL are and how it is often used in the world. Then, we'll go over some of terminology of MongoDB and how these terms map to the SQL world. Lastly, we'll demonstrate how we can work with MongoDB from SSIS using .NET code to make all of the connections.
CodeCampNYC_2016_MongoDB_Intro.pptx (1.05 mb)
This past Saturday, Microsoft hosted a Windows 8 Camp at Harrisburg Area Community College (HACC) on the Harrisburg campus. If you get the opportunity, take advantage of one of these free events offered by Microsoft. They provide for a good way to keep abreast of newer technologies and connect with fellow developers. Listed down below are links for you to keep tabs of some of the local development events.
The Windows 8 Camps are a great learning experience. Right now, if you haven't noticed, there's quite a change in how people stay connected and work with computer technologies. Tablet sales are projected to surpass PC sales this year so how users interact with the software which developers build is changing considerably. In some ways, end users of current technologies sometimes seem to be more in tune with these changes than even seasoned developers.
The focus of this camp was right in line to help existing .NET developers get in sync with the new Windows paradigm shift. Also, Microsoft kindly supplied breakfast munchies and a lunch. Chris Gomez @SpaceShot and Microsoft MVP John Baird @jbaird_pa gave tag-team presentations and were both understanding of what it takes for an existing .NET developer to advance the new mindset and make the jump to Windows 8 app development.
Sessions
Building Windows Store Apps Using HTML5/JavaScript
The first session overviewed Building Windows Store apps using HTML5, CSS3, and JavaScript. Chris opened up by keying in on some of main features of Windows 8 user interaction and what is essential in making good applications interoperable within a Windows 8 environment. Basically this was to jump-start experienced developers with one of the more significant changes to the Microsoft development portfolio.
In order to understand what is to be accomplished, Chris presented a cursory review of the Windows 8 user experience and then did a code walkthrough of navigation, searching, controls, sharing, and async operations. If there's one thing you can take away from this, it's Microsoft's recommendation that interacting with WinJS will simplify developing Windows 8 apps when using HTML5, CSS3, and JavaScript . WinJS is simply a JavaScript, CSS, and HTML library that helps build Windows 8 controls that are not necessarily implemented in HTML5. However, you can still develop apps with HTML5/JavaScript without the use of WinJS.
Building Windows store Apps with XAML/C#
Next John jumped into Building Windows Store apps with XAML and C#. A good portion of the participants had already been developing in this realm, so this session was an easier jump to constructing Windows 8 apps. If you've been building .NET applications in XAML for sometime, whether it's Silverlight or WPF, your learning curve to getting a Windows 8 app running is actually going to be fairly quick.
Process Lifetime of Windows 8 Apps
The third session, Process lifetime of Windows 8 apps, was led by Chris. Certainly, anyone who's been running Windows over the years knows that being mindful of your available resources is important in ensuring that things run smoothly, and actively keeping tabs of what's running and killing any unnecessary processes is a part of daily computing. However, the intention with Windows 8 is a bit different. To get you in the right frame of mind, think how you've been computing these days with your smart phone or tablet. The perspective is that provisions for an always-on and available mentality is in place when interacting with Windows 8 apps. Chris went on to describe throughout his walkthrough how apps go through the suspend and resume process and how to maintain consistent application state for a user friendly experience.
Introducing the Windows Store
Lastly, John went into an overview of the Windows Store. If you've used Google Play or the Mac App Store, you understand this concept. The Windows Store is basically a distribution system which allows for developers to deliver their certified apps to consumers. John went over a list of details in using the Windows Store and performed a walkthrough of signing up and registering your app on the Store.
During this, he discussed details on:
• Selling, price points, and getting paid
• Advertising options
• Beta options
• Limited functionality and timed trials
• Registration
• Application Certification Kit (ACK)
• Localization
• Deploying apps for use in other countries
• Updates and versioning
Wrapping Up
As with any other nice event there was a little bit of SWAG and closing with a bunch a nice prizes. Again, keep tabs on your local events. The most important thing you can do is to meet other developers and possibly form ongoing relationships in your field. Right now, there's a dramatic change taking place in personal computing, and now's a great time to be part of that change.
Resources
Downloads, SDK’s, & Tools
Windows Store Apps Developer Downloads
includes the Windows 8 SDK, Blend for Visual Studio, Windows Application Certification Kit (ACK), practice labs, sample apps, and much more.
The Microsoft Windows Store
Windows 8 Camp in a Box - Official Microsoft Download Center
Lesson slides, the hands-on-labs, samples, and related resources.
Windows 8 Hands-on Labs Online (HOLO)
Scheduled live online presentations and labs. Experts are available in for real-time assistance through your lab work.
Windows Store App Labs
Event Calendars
Windows Camps Events Channel 9
Community Megaphone
Microsoft World Wide Events
Recently a team member brought up a problem in regards to obtaining a fairly sizeable 2008 R2 SSRS report which needed some modifications and to be deployed to a 2008 SSRS system; essentially requiring that the report RDL be down-converted to 2008 SSRS. Unfortunately, installing BIDS for 2008 R2 on this team member's development environment is not an option so there needs to be another way to provide for a 2008 version of this particular RDL for which to be modified. Could BIDS 2008 R2 on another developer workstation or a conversion utility provide the solution? Possibly. However, taking a look at the XML of the RDL, it's clear that the solution might be a bit simpler.
This solution should be able to be applied when converting from 2012 back to 2008 as well. Additionally, this may not be the most optimum method to update the RDL, however it was easy and quickly got a report out to production. One other detail to note is that this report allows for the ability to provide names to be assigned to each worksheet when it is exported to an Excel worksheet.
There are only two main steps to provide for this down-conversion:
- Apply proper schema
- Remove unsupported elements
Step 1 - Apply Proper Schema
To apply the older definition information, simply replace the newer RDL schema definition with the older version RDL schema. Find the SSRS 2008 R2 <Report> element:
<Report
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition"
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition"
>
Replace this <Report> element namespace information with the 2008 namespace information:
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition"
xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner"
>
Step 2 - Remove Unsupported Elements
Remove incompatible start and end XML element tags. Look for and remove the following start and end elements if they exist; being sure to leave the data within the elements:
<ReportSections>
</ReportSections>
<ReportSection>
</ReportSection>
Look for and remove, if they exist, the following start and end elements as well as the data within the elements:
<PageName>...</PageName>
<Authentication>integrated...</Authentication>
<rd:SecurityType>Integrated</rd:SecurityType>
Finally, test within BIDS for SSRS 2008. That's pretty much all there is to it. One additional note, it's possible that there may be other properties within an SSRS 2008 R2 RDL that will balk in BIDS for SSRS 2008. Please feel free to share comments on any additional pieces of the RDL that may need to be removed or modified for a proper down-conversion.
There are multiple ways in which the tab header of a tab control can be hidden. One way is to set the DrawMode of the control to "OwnerDrawFixed," the SizeMode to "Fixed, " and then set the ItemSize to "0, 1" What's left is somewhat of an abandoned tab header. A little bit of fussing with the layout is then required to clean up the tab control.
Another method is to extend the WinForm tab control and override the WndProc method to trap the TCM_ADJUSTRECT message, which is sent when it needs to adjust the size of the tabs, while the control is in DesignMode. This allows for a nice way of completely eliminating the tab header from the control without any need to clean up the layout. Once you trap the TCM_ADJUSTRECT message, return the value 1 to specify that the message was handled.
if (_message.Msg == TCM_ADJUSTRECT && !DesignMode)
_message.Result = (IntPtr)1;
While you're at it, put the class inside your custom library and add it the Visual Studio Toolbox so it can dragged onto a form whenever it is needed.
using System;
using System.Windows.Forms;
namespace StoreLib
{
public class NoHeaderTabControl : TabControl
{
private const int TCM_ADJUSTRECT = 0x1328;
protected override void WndProc(ref Message _message)
{
if (_message.Msg == TCM_ADJUSTRECT && !DesignMode)
_message.Result = (IntPtr)1;
else
base.WndProc(ref _message);
}
}
}
References
Control.WndProc Method
TCM_ADJUSTRECT message (Windows)
Due to the push for the adoption of XML configuration files, INI file handling was not built into the .NET Framework. However, INI files do still exist in legacy applications and can sometimes be found in newer software as well. So there needs to be a way to work with them from code. There are some available libraries, such as Nini and CommonLibrary.NET, which can perform this type of work, however, since this is part of the Quick-and-Dirty Series, here's a very simple example that will work for a lot of scenarios.
Interop Services to the rescue
Two kernel32.dll functions can be exposed to handle these INI files; WritePrivateProfileString and GetPrivateProfileString. The class IniFile listed below shows how to utilize these functions from Kernel32 via interop.
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace StoreLib.Configuration.Ini
{
public class IniFile
{
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string _section, string _key, string _val, string _filePath);
[DllImport("kernel32")]
private static extern int GetPrivateProfileString(string _section, string _key, string _def, StringBuilder _retVal, int _size, string _filePath);
public IniFile(string _path)
{
Path = _path;
}
//Write to INI File
public void WriteValue(string _section, string _key, string _value)
{
WritePrivateProfileString(_section, _key, _value, Path);
}
//Read from INI File
public string ReadValue(string _section, string _key)
{
StringBuilder sb = new StringBuilder(255);
int i = GetPrivateProfileString(_section, _key, "", sb, 255, Path);
return sb.ToString();
}
public string Path { get; set; }
}
}
Once the IniFile class is ready, reading a value is easy:
IniFile iniFile;
iniFile = newIniFile(@"C:\LegacyApplication\la.ini");
string dataSourceKey = "source1";
string dataSourceName = iniFile.ReadValue("DataSources", dataSourceKey);
Similarly, writing a value to the file is just as easy:
IniFile iniFile;
iniFile = newIniFile(@"C:\LegacyApplication\la.ini");
string appLoadKey= "splash";
string appLoadValue = "logo";
iniFile.WriteValue("AppLoad", appLoadKey, appLoadValue);
That's all there is to it. This is just one option for accessing an INI file and should be able to handle most instances of a section's simple key-value pair. Feel free to give it a try.
___________
Quick-and-Dirty Series - Hopefully still a sound solution, these may not be the best, fastest, or most appropriate methods of accomplishing a development task, however, they work and are fast to put in place.
By all means, this is far from a complete list of my .NET development toolbelt. It is just a select few of effective lightweight utilities that I commonly use. Often said, although there is often a better tool for the job, sometimes the best tool for the job is the one you know. Please feel free to share some of your own favorites.
Productivity & Desktop
dnGREP
Developing and working within Unix (I often date myself by typing UNIX) and Linux environments, I've learned to really appreciate some of the great shells and commandline utilities. One of my favorite utilities was grep, which is a text searching utility. dnGrep is a Windows implementation of this utility.
http://code.google.com/p/dngrep/
Cygwin Bash Shell
Tee'ing off of the previously stated usefulness of the Unix command shells, Cygwin is a port of many of the more popular Unix tools and provides commandline interaction of these utilities.
http://www.cygwin.com/
Focus Booster
This is just one of a dozen-dozen utilities assisting with the Pomodoro Technique. This is just one that I like because it's simple, clean, and small. That's kind of a theme of mine when it comes to maintaining my development toolbelt.
http://www.focusboosterapp.com/
If you want to learn more about the Pomodoro Technique have a look here: http://www.pomodorotechnique.com/ Obviously, this isn't the end-all be-all of productivity methods. There may another one that's a better fit for you.
Input Director
Multiple computers, multiple monitors, one keyboard, one mouse. There's nothing that keeps my desk cleaned up and my hands in one place better than this productivity tool.
http://www.inputdirector.com/
notepad
Maybe overstating the obvious, but notepad is one of my more useful tools as well. Often I'm on a system without a good toolset and need to remove any textual formatting from any text that's block copied. While my development machines have various utilities for pasting cleaned up text, that system on the other end of the network probably will not.
ImgBurn
As often, simple is always better. I've created so many less coasters over the years with this CD/DVD burning/copying utility than with any other tool.
http://www.imgburn.com/
FormatFactory
This is a just a great media converter. It's been very effective for me and is one of the few that doesn't bog down my workstation.
http://www.pcfreetime.com/
Graphics & Images
Paint.NET
This is probably my alltime favorite graphic editor. It is such a capable image editor and has a large following with which to collaborate.
http://www.getpaint.net/
Greenshot
Greenshot is a speedy lightweight screenshot tool. I'm hesitant to keep anything running in my windows taskbar that I don't need at all times and is going to use up a lot of memory. These kind of utilities are notorious for sapping away more memory than they need while waiting for you to use them. Greenshot is not one of them and has a home in my taskbar.
http://getgreenshot.org/
Wordpad
Did I hear a laugh? Yes, as funny as it sounds. Often I need to get full or partial screen shots on systems that don't have much of anything in terms of productivity tools installed on them. I sometimes need to gather a few simple screen shots and to move on. I've found that it's quicker, and tidy, to just drop a bunch of images in a Wordpad document and then wrap things up elsewhere.
Reporting
RSScripter
Although, it can be done from a manual sense, I often need to grab a load of SSRS reports from a server to either be moved or worked on. This little utility is great for short work of these operations.
http://www.sqldbatips.com/showarticle.asp?ID=62
Report Builder
I often say that developers are lazy. They only want to type something once, automate things, and build things that, in turn, build things for them. Every once in awhile a dynamically generated report doesn't fit the bill and a one-up report is needed. I don't want to take up time with a project, I just want to get the information out there into a report format as quickly as possible. Better yet, if all of the work is done in a stored procedure and available to the report definition, I only need to worry about the layout, groupings, etc. of the report.
http://www.microsoft.com/en-us/download/details.aspx?id=6116
Internals
Dependency Walker
This great utility by Steve Walker examines Windows assemblies and provides realtime interactive diagrams of any activity, errors, and interactions between the different modules running on your system. While it provides extremely detailed useful information, it is surprisingly intuitive for the uninitiated.
http://www.dependencywalker.com/
Sysinternals
Ever since I first purchased the Winternals suite of admin tools years ago, I've been a satisfied customer. This suite of small and effective utilities are use for monitoring and managing Windows systems. Microsoft later obtained Winternals and still has the majority of the tools available for free. I often create scripts or shell commands to the various utilities. Process Explorer, TCPView, PsService, PsList, PsKill, PsInfo, PsExec are the utilities I make use of on a regular basis.
http://technet.microsoft.com/en-us/sysinternals/bb842062
Development/Debug
Firebug
This is a Firefox plugin that provides a more detailed view of HTML, CSS, and JavaScript from the client.
http://getfirebug.com/
Glimpse
This is an ASP.NET diagnostics tool that captures performance characteristics for further debugging or troubleshooting. It has the ability to gather an amazing amount of detail fairly easly.
http://getglimpse.com/
JustDecompile
Reflector used to be my go-to tool for .NET code decompilation. This has been an incredible useful tool. Not long after Reflector became a premium product, JustDecompile from Telerik came on the scene.
http://www.telerik.com/products/decompiler.aspx
FXCop
FXCop is tool that helps maintain that certain rules pertaining to security, naming conventions, proper memory usage, and design are met within .NET code.
http://msdn.microsoft.com/en-us/library/bb429476(v=vs.80).aspx
If you’ve tried to run a Windows Service project in debug mode, you’ve probably seen the message shown below. To debug our code by default, we would have to install the service and then attach the debugger to a Process (Ctrl+Alt+P). Obviously, this can get tedious. There is a more appropriate and efficient way to debug the Windows Service project in which we’re developing.
Let’s start out by constructing a simple Windows Service… Add a Windows Service class item to the project; in our case, the class is named AgentService.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;
namespace ProvingGrounds.Agent
{
partial class AgentService : ServiceBase
{
private Timer timer = null;
public AgentService()
{
InitializeComponent();
timer = new Timer(6000);
timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
timer.Enabled = true;
timer.AutoReset = true;
}
protected override void OnStart(string[] args)
{
Start();
}
protected override void OnStop()
{
Stop();
}
public void Start()
{
timer.Start();
}
public void Stop()
{
timer.Stop();
}
void timer_Elapsed(object sender, ElapsedEventArgs e)
{
//TODO:Do Something
}
}
}
Next, update Main() found in Program.cs to execute AgentService.
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new AgentService()
};
ServiceBase.Run(ServicesToRun);
}
We should now have our Windows Service constructed. Feel free to compile it and then go ahead try running it in debug mode. You should be receiving our "Start Failure" error message.
Next, let's get this thing running in debug mode from Visual Studio. We can do this by adding the #if DEBUG preprocessor directive to our Main() function. We simply wrap the existing call to our AgentService with the conditional preprocessor directives.
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Threading;
namespace ProvingGrounds.Agent
{
static class Program
{
static void Main()
{
#if DEBUG
AgentService agentService = new AgentService();
agentService.Start();
Thread.Sleep(Timeout.Infinite);
agentService.Stop();
#else
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new AgentService()
};
ServiceBase.Run(ServicesToRun);
#endif
}
}
}
That's all there is to. Go ahead and hit F5 from Visual Studio and your Windows Project should be running in Debug Mode.