SharePoint Holiday Loader
March 19, 2012: This tool has had a major make over since the original release!
I’m sure, as a SharePoint power user, you’ve had the fun of your boss walking up to you and asking why the public holidays aren’t in your SharePoint calendar? (guess what happened to me last week)
You would think this would be easy, in fact Outlook supports adding holidays to calendars easily. So why isn’t SharePoint easy like that too?
I’ve had this asked a few times and never had a good answer to do it, so I decided that a simple tool needed to be built to solve this once and for all – Let me introduce SharePoint Holiday Loader (SHL).
SHL takes a standard holiday file (.hol) and allows you to publish that to a SharePoint list!
This tool is very easy to use (just need the file, the server and the calendar name) and it is free and open source. You can get the download the tool, source code, leave comments (or complaints) at: https://bitbucket.org/rmaclean/sharepoint-holiday-loader/
How to get the mouse to stop waking up Windows?
My old Logitech V450 mouse had an odd issue, if Windows was put to sleep and pulled the dongle out, Windows woke up. This never bothered me much since I got into a habit of doing that before I put Windows to bed.
However with my new Performance MX Mouse (aka the mouse Batman would use) it does something similar which a change of habit just can’t fix.
The new mouse has a TINY dongle which is designed to be left in all the time and I do that, however any mouse movement or button pressing will turn a sleeping Windows on. So if when I forget to turn the mouse off and toss it in my laptop bag, it will turn the laptop on and the start the process of converting my laptop bag into an oven.
The solution to both these issues is to disable this wake up feature.
Step 1) Right click on the Computer start menu item (or My Computer icon on your desktop) and select Manage
Step 2) Click on the Device Manager node (under System Tools).
Step 3) Expand Mice and other point devices, right click on the mice and click Properties
Step 4) Head to the Power Management tab, and untick Allow this device to wake the computer and finally click OK
This will prevent both the issue of dongle changes or mouse action from waking up your computer.
Foot note: how porn does that last line sound…
Source Code Management for the Individual SharePoint Developer
With SharePoint 2010 and Visual Studio 2010 the ability to be a productive developer was key and there is tight out-of-the-box integration and this means that it is easy for SharePoint developers to put code into source control easily. Hilton Giesnow covers this brilliantly in a video he has: http://bit.ly/g71Gnb
Imagine a number of dedicated SharePoint developers, they may have an enterprise ALM solution like TFS and on their own machines have SharePoint 2010 Developer and VS2010 installed and life is good – but what about the individual, or ad-hoc, developer?
The problem for him is that installing SharePoint 2010 is a resource hog and you may not want it running all the time (what Hilton nicely calls the 9 to 12 development) and what about if you switching between projects, how do you switch SharePoint? The solution I found, is to have a virtual machine (VM) for SharePoint with the dev tools installed and do all work on the VM. This is great because the overhead is only there when you need it and you can easily switch between different virtual environments. The downside: source code management.
Sure you can hook up the VM to the network and manage code using the source control as you are used too, but this isn’t always easy or possible, so what else you can do? I had this problem recently where the source control is on one domain and my development was another domain. I choose to use the Mercurial Distributed Version Control System (DVCS) and I thought I would share this experience with you.
DVCS differs from “traditional” source control like TFS or SubVersion which has a client/server model where each developer is a client talking to a central server, however in DVCS every developer is their own server and does pushes/pulls (think like a sync) between other developers.
What this enables is a very lightweight set of tools installed along side SharePoint and the developer tools on the VM. At the end of each day I could run Mercurial on my machine and pull the source control down to my own machine. This meant the VM had the code and my “real” machine had the code. Then this code could easily be checked into the corporate source control system creating another backup and ensuring compliance with source management policies!
This has been a very exciting project and this configuration really made the management of the source code very smooth.
Enabling Flip 3d with Logitech Performance MX Mouse
I purchased a Logitech Performance MX Mouse (to replace my other Logitech V450 mouse) which has a number of fantastic features:
- Darkfield optical sensor which works on everything, including glass
- The awesome and tiny wireless pickup that can remain plugged in all the time.
- Ability to charge off of USB and still work!
- 7 Buttons
One of those 7 buttons defaults to a feature called Application Switcher. For Mac users this is exactly like Expose and for Windows users it is like a full screen task switcher.
In fact on Mac runs Expose but on Windows this is a custom application and really doesn’t have the feel or the polish that the Flip 3d (the Windows+Tab thing) which ships with Windows Vista and Windows 7.
So how do you change this? There is many posts about using macro’s, assigning specific applications or even hacked drivers but from my own experience this is no longer needed and it appears most people do not know about it because it is so well hidden.
The first step is to download the latest version of SetPoint, the mouse software, from Logitech which at time of writing is 6.2. However the mouse actually ships with 4.7, a version over 3 years old! This is really odd since the mouse was only launched less than 1 year ago!
Once upgrade go to the Button Settings section, select the button and set the task to Other this will bring up a dialog with a massive drop down full of options. If you look in here for Flip 3d or maybe some alternative on application switcher you will not find it. However there is an option called Document Flip, which you guessed correctly is Flip 3d.
Set your mouse to this and viola!
Pull: January 2011 release
2011 has started off well with the new release of Pull! This release is a major update release where the focus was on improving the experience on the front end.
Ribbon
You either love it or you hate the ribbon, but there is no doubt that using it makes you more productive and we have moved to that with this release.
There has been discussion moving the Episodes ribbon around, so this may change. Please join that or post issues if you have any other items you want to change please see the Issue Tracker.
Cover Flow
We now show podcasts using cover flow, which also means we now try to pull down the podcast art! This makes it much nicer to expose and move around podcasts!
However maybe you do not like this, check out the toolbar options:
- Show one podcast as a time
- Rather than the cool carousal flow, stack the podcasts next to each other.
- Same as 2, but vertical stacking.
- Stack across first and then stack vertically.
- Stack vertically and then stack horizontally.
- Carousal mode (default)
And you can use the wrench to customize the cards and change what is shown. Doing that I removed the image and status icon and shrunk the size:
And when you want to go back – you can use the reset views button in the settings.
Powerful Grids
Both the episode and download queue grid are greatly enhanced.
- Changes made now persist!
- You can re-order and resize columns.
- There is full filtering support on them!
- At the bottom is a total bar which you can turn on/off or change what is shown (try right click!).
Twitter support got a major overhaul so the issues discussed previously are gone! Something you may want to check out though is the little arrow below the button which lets you specify your http://bit.ly username and password!
Export
You can now export to .xlsx (Excel 2007/2010) and .html in addition to .csv!
Coming up next?
Being a fairly major release there is some spit and polish we want to focus on for the next release and adding some smaller features!
Dev4Devs - it's coming!
Update: Event moved to the 5th March 2011 - details: http://blogs.msdn.com/b/southafrica/archive/2011/01/18/devs4devs-returns.aspx
Dev4Dev’s, my favourite event, is coming up soon! It is a free event which happens at Microsoft offices on a Saturday morning where you get to see a variety of topics! The key points that make this awesome:
- Each presentation is 20min long – so all meat in the topics with no fluff!
- Even though it is as Microsoft, it is not Microsoft – some fantastic non-Microsoft technologies has been shown before.
- It’s developers presenting to developers – so no marketing nonsense.
- You can apply to present in one of the slots – so if you want to present at bigger events (TechEd, DevDays etc…) this is a great way to get on the radar of those who make those decisions!
All the details at: Devs4Devs Returns
For me this is the first one I will miss as I will be in Seattle for MVP Summit
What's in Microsoft.VisualBasic for C# Developers: Part 7 - File System
[This blog is part of a larger series, to find more parts in the series please see the Series Index]
The FileSystem class is what originally brought me to explorer this assembly because there is some very interesting options in the class which aren’t available elsewhere. To add to confusion there is two FileSystem’s in the Microsoft.VisualBasic namespace :
- Microsoft.VisualBasic.FileSystem
- Microsoft.VisualBasic.FileIO.FileSystem
The one I am interested in, and this post covers, is the second one which has some fantastic options: unfortunately there is way more functions in there than a single blog post can cover (27 methods not counting overloads), so I am going to focus on just two of them which bring new features, i.e. not just wrapping some other .NET API.
DeleteDirectory
The first I want to look at is the DeleteDirectory method which allows you to easily delete a directory. What makes this fantastic is that it can empty the directory of files first (i.e. it handles non-empty directories). Second it supports deleting to the recycle bin and finally it supports a nice pretty UI for the deletion action, including confirm dialog and progress bar dialog.
string testFolder = FileSystem.CombinePath(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"Demo"); FileSystem.CreateDirectory(testFolder); FileSystem.DeleteDirectory(testFolder, UIOption.AllDialogs, RecycleOption.SendToRecycleBin, UICancelOption.ThrowException);
In the code above uses a few options from FileSystem.
- CombinePath – this is provides a error checked and normalised concatted path using System.IO.Path.CombinePath.
- CreateDirectory – this does some error checking and wraps System.IO.Directory.CreateDirectory.
- DeleteDirectory – This is what we are talking about with the display of UI and send to recycle bin enabled.
There is similar methods to DeleteDirectory, such as MoveDirectory & CopyDirectory and similar items for files: CopyFile, MoveFile etc…
FindInFiles
This is a very useful function which allows you to search files on your machine for specific content (i.e. search in the file, not just the filename). This is not wrapping any functionality behind the scenes (for a change):
string myDocs =Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); var result = FileSystem.FindInFiles(myDocs, "MVP", true, SearchOption.SearchTopLevelOnly); MessageBox.Show(result.Aggregate((c, n) => { return c + Environment.NewLine + n; }));
The above code shows me searching the My Documents folder for any file with the letters MVP (in any case – controlled by the third parameter). It can be filtered using standard wildcards and and search sub-directories too
What's in Microsoft.VisualBasic for C# Developers: Part 6 - Networks
[This blog is part of a larger series, to find more parts in the series please see the Series Index]
The Network class is an interesting set of wrappers around other classes in .NET which is useful for simplification of certain actions:
- DownloadFile & UploadFile
- Ping
- IsAvailable
DownloadFile & UploadFile
These two methods are interesting in that the wrap the WebClient class which make it much easier to use while still giving a lot of flexibility. This isn’t the most robust way to work with the HTTP (download) & FTP (upload) but it is very useful. For example the easiest way to download a file:
Network network = new Network(); network.DownloadFile("http://www.bing.com", @"c:\bing-index.html");
It includes 10 overloads which the most complex is:
One of the interesting parameters I wanted to highlight is the showUI parameters which when set to true gives you a dialog ox with a progress bar and cancel support. It’s not pretty but, like a lot of this Network class it is functional:
Ping
Just like DownloadFile & UploadFile, Ping wraps other functions in the framework, namely the Ping class from System.Net.NetworkInformation. It really just takes two lines of code if you used the Ping class and makes it two lines using the Network class – not really that helpful:
Network network = new Network(); string message = network.Ping("www.bing.com") ? "Bing is up" : "Bing is down";
IsAvailable
The last in the Network Trilogy is the IsAvailable property which tells you if you are connected to a network. All it does is call: NetworkInterface.GetIsNetworkAvailable.
Why you want to write two lines for this when you could use the one line it uses is confusing, but it’s there:
Network network = new Network(); string message = network.IsAvailable ? "Network up" : "Network down"; // I prefer this: string message2 = NetworkInterface.GetIsNetworkAvailable() ? "Network up" : "Network down";
What's in Microsoft.VisualBasic for C# Developers: Part 5 - Hardware
[This blog is part of a larger series, to find more parts in the series please see the Series Index]
Hardware isn’t just related to the computer information, like OS version and memory, but it also includes a variety of other types of devices such as audio, clocks, keyboards and many more. The VisualBasic library provides us with access to a lot of these pieces of hardware:
Audio
Microsoft.VisualBasic.Devices.Audio is a interesting class which allows us to play various sounds it has three functions that are key:
- Play – This allows us to play a wave file, either by passing in the file name, a stream or byte array. There are a few overloads to allow you to control how the audio is played.
- Stop – Stop the playing audio.
- PlaySystemSound – This plays the sound associated with a specified system event.
string waveFile = @"C:\Windows\winsxs\amd64_microsoft-windows-speech-userexperience_31bf3856ad364e35_6.1.7600.16385_none_77fee1b2657da663\Speech Sleep.wav"; Audio audio = new Audio(); // play full file to wnd audio.Play(waveFile, Microsoft.VisualBasic.AudioPlayMode.WaitToComplete); // play first 300ms and stop audio.Play(waveFile); Thread.Sleep(300); audio.Stop(); // play sound associated with a question audio.PlaySystemSound(System.Media.SystemSounds.Question); Console.ReadKey();
Clock
Microsoft.VisualBasic.Devices.Clock is rather pointless it has three properties which match to existing properties we know and love.
- GmtTime equals DateTime.UtcNow
- LocalTime equals DateTime.Now
- TickCount equals Environment.TickCount
Keyboard
This provides us with an interesting mixed bag first we have 3 Boolean properties, one for each modifier key (Ctrl, Alt & Shift) which tell us if it is being pressed. Next we have 3 Boolean properties, one for each of the toggle keys (Caps lock, scroll lock & num lock) which tells you if they are enabled.
Keyboard keyboard = new Keyboard(); Console.WriteLine("Alt pressed: {0}", keyboard.AltKeyDown); Console.WriteLine("Ctrl pressed: {0}", keyboard.CtrlKeyDown); Console.WriteLine("Shift pressed: {0}", keyboard.ShiftKeyDown); Console.WriteLine("Caps on: {0}", keyboard.CapsLock); Console.WriteLine("Numlock on: {0}", keyboard.NumLock); Console.WriteLine("Scroll lock on: {0}", keyboard.ScrollLock);
However the interesting piece of code is the SendKeys method which actually allows you to send key strokes to the active window, basically to simulate a user typing.
There is one thing to be aware of and that is if you are using something which does not handle window messages for example a console application. In this case you must use the overload which takes a boolean as a second parameter and set this to true.
// winforms keyboard.SendKeys("Hello world!"); // console keyboard.SendKeys("Hello world!", true);
Mouse
Microsoft.VisualBasic.Devices.Mouse does not let you control Mouse from the Matrix, it merely provides status information to you on the hardware mouse you are using via three properties:
- ButtonsSwapped – Are the left and right mouse buttons swapped?
- WheelExists – Does the mouse have a mouse wheel?
- WheelScrollLines – How many lines does a single notch of the mouse wheel to scroll?
Ports
Need to work with serial (COM) ports? The Microsoft.VisualBasic.Devices.Ports provides you with a simple way to do that, however nothing it provides you do not already get from System.IO.Ports.SerialPort except saving a few lines of code.
The OpenSerialPort method does the following:
- Creates a new System.IO.Ports.SerialPort – OpenSerialPort does contain overloads which match to the constructors for SerialPort.
- It then calls Open on the port.
- It returns the port.
That three lines of code wrapped into one for you.
The other item provided on Ports is the SerialPortNames property which returns a ReadOnlyCollection<String> of the names of the port. It does this by calling the GetPortNames method from SerialPort, which returns an array and then converts that result to the collection. The only time you should use this is if you really need a ReadOnlyCollection<String> as calling the GetPortNames method directly and working with the array is much faster.
What's in Microsoft.VisualBasic for C# Developers: Part 4 - Computer Info
[This blog is part of a larger series, to find more parts in the series please see the Series Index]
For today we will be looking at a very useful class ComputerInfo, which provides a small set of information on the computer. It doesn’t provide a lot of info but the information it provides are key:
- OSFullName: The “nice” name for the OS – like Windows 7 Ultimate
- OSVersion: The OS version number
- OSPlatform: The OS platform
- TotalPhysicalMemory, AvailablePhysicalMemory, TotalVirtualMemory, AvailableVirtualMemory: Memory usage information
- InstalledUICulture: The culture that was used during the install, this is the exact same as System.Globalization.CultureInfo.InstalledUICulture
ComputerInfo info = new ComputerInfo(); Console.WriteLine("You are running {0} ({1})", info.OSFullName, info.OSVersion); Console.WriteLine("\t this is built on the {0} platform.", info.OSPlatform); UInt64 usedPhysical = info.TotalPhysicalMemory - info.AvailablePhysicalMemory; UInt64 usedVirtual = info.TotalVirtualMemory - info.AvailableVirtualMemory; Console.WriteLine("Memory Information in Mb (Available | Used | Total)"); Console.WriteLine("\t Virtual: {0} | {1} | {2}", info.AvailableVirtualMemory / 1048576, usedVirtual / 1048576, info.TotalVirtualMemory / 1048576); Console.WriteLine("\t Physical: {0} | {1} | {2}", info.AvailablePhysicalMemory / 1048576, usedPhysical / 1048576, info.TotalPhysicalMemory / 1048576); Console.WriteLine("You are running the following culture {0}", CultureInfo.CurrentCulture.EnglishName); if (CultureInfo.CurrentCulture != info.InstalledUICulture) { Console.WriteLine("BUT you installed with {0}", info.InstalledUICulture.EnglishName); } else { Console.WriteLine("and you installed with that culture too"); }
This gives us:
This is isn’t the only way to get computer information, there is plenty in other locations in the framework – for example the System.Environment class from the mscorlib assembly has things like:
- Environment.Is64BitOperatingSystem
- Environment.Is64BitProcess
- Environment.MachineName
- Environment.OSVersion
- Environment.ProcessorCount
- Environment.Version