Feb
6
2013

My First Win8app, WCF, Entity, SQL, and Azure

First off, I am no closer to being a pro at the 5 areas above then an average ice skater is a pro at hockey.   Please don’t come here looking for guidance or best practice, but make use of the direction and ideas.  One more disclaimer, my writing style below is personalized and is pretty much how my brain runs in the tech world.  I tend to use a lot of parentheses when I type as a way to jump thoughts or give a little more detail. My company was kind enough to provide me with an MSDN subscription, which I took advantage of last Friday evening.  Granted it is to be used for work, but I am the kind of woman who is curious, full of ideas, and who likes to learn things on my own, and so I used it for “training”.   In my head I have a killer idea for a Windows 8 Store App, but before this idea could ever become more I had to understand how things work.   I had already setup Virtual Box VM of Windows 8 and installed Visual Studio 2012 on it to learn the tool (I wanted to be prepared when we finally upgrade in the office).  I followed this site to set it up,  http://betanews.com/2012/03/01/install-windows-8-on-oracle-virtual-box/. I started with the solution.  I know I wanted a Windows 8 Store App, so I surfed the web to find a walkthrough tutorial to kick start me.  Of course I only got through the first page and started to lose my focus (due to surging creativity, this happens all the time).  Part 1: Create a “Hello, world” app. What I ended up with was a solution with a running app that asked for a name and spit back some greeting text.  My next challenge was to wire this up to a database. I didn’t have a database, nor SQL Express installed.  This is where Azure came in to play (go Cloud).  I know this guy (Hi David), who LOVES Azure, and I wanted to see why he loves it.  This led me to creating an Azure account (go free trial).  This was simple enough to setup.   I took a few moments in the Azure management tool seeing all the options available.  This had change since last time I watched David demo it at a Code Camp, but I easily found the option to setup a new SQL database.  I then used the databases Management Portal to create a table and add data.  I created the table with a key, Name, and FavoriteColor columns.  I put in the names from my family, husband, daughter, son, and myself with our favorite colors.    Database done!  Now how do I tie them together?  I’ve almost always developed in a multi-tier architect.  The data layer (database), middle tier/business layer (WCF), and interface (ASP.NET/WPF).  My first thought was to use WCF and Entity Framework.  I’ve done this plenty of times in the past, so it’s easy for me to setup.  I started with Entity first by adding a Class Library project to my Windows 8 app solution.  I added the ADO Model with the connection string to the Azure database I had setup (which kindly prompted me to ensure Azure allowed my local IP address, yeah firewall).  I brought in my one table into the model. Next I added a WCF project to my solution and created a simple method that would take a name and return a color.  I tested the method with VS’s WCF Test Client and retrieved the correct response. public string GetFavoriteColor(string name) {     var entity = new GMappEntities();     var row = entity.TestTables.Where(q => q.Name.Contains(name)).FirstOrDefault();     if (row == null) {         return string.Empty;     }     return row.FavoriteColor; } Accessing the Azure database programmatically, check! Now for the tricky part.  I knew that the Windows 8 App would most likely run more like Silverlight, where it would make Async calls (remember I haven’t worked in this area before), but I had no idea on the syntax.   I tried on my own to add the new WCF Service to the Store App, but was unprepare to have only “GetFavoriteColorAsync” methods and no “GetFavoriteColorCompleted” events to tie it too.   With lacking knowledge I took the next logical step and surfed the web.   It took me a few sites to point me in the a path, but no real flat out “here’s how you do it, lady.” (or my search patterns sucked).   My search results lead me into using WCF Data Services Tools for Windows Store Apps.  I began experimenting by creating a Data Service request in an ASP.NET project (I didn’t really like this idea, but that’s because mostly I don’t understand it that well).   I  pretty much messed up on the calls and just gave up on it.  I switched back to trying to get my WCF site to work.  After more web surfing I found references to “async and await”.   Await isn’t something I’ve used before (or I don’t remember using it).  I dug deeper on what ‘await’ was used for, how, and why.   The code began to come together and I successfully entered Traven (my boy's name) and got back Green.  private void Button_Click(object sender, RoutedEventArgs e) {     GetFavoriteColor(nameInput.Text); } private async void GetFavoriteColor(string text) {     var client = new WcfTestService2.ServiceTestClient();     Task<string> getStringTask = client.GetFavoriteColorAsync(nameInput.Text);     greetingOutput.Text = await getStringTask;     var colorBrush = new SolidColorBrush( );     colorBrush.Color = TranslateColor(greetingOutput.Text);     greetingOutput.Foreground = colorBrush;     greetingLabel.Text = "Your favorite color is: "; } The first call to Azure took about 7-10 seconds, but the subsequent calls were about 0-1.  Access Azure through WCF into the Windows 8 App, done! This is when my six-year-old son pulled my sleeve and said “Mom, when are you going to stop working, I want to play Minecraft with you.”  (Yes, it is obvious that he is my boy).  I decided to introduce Traven to my little program.  I demonstrated the functionality of my little app that allows you to enter a name and get back a favorite color.  I showed him how I could add more names, so we put in his friends name and set orange as his favorite color.  Traven thought this was pretty cool and I still had his attention, which I thought was extremely cool.  Then he said “Mom, shouldn’t the words be the color.”  He stayed with me for the next fifteen minutes while we worked out setting the foreground color based on the text color from the database. When dad finally came home from work, Traven bounced out of our office to tell him all about the color program we made.   Learning all of this was awesome, but sharing it with my six-year-old was absolutely awesome (aka priceless, but with more excitement). Feed the brain people and share! I also found these sites helpful: http://bhrnjica.net/2011/09/26/consuming-wcf-in-windows-8-metro-style-app/ http://www.c-sharpcorner.com/uploadfile/UrmimalaPal/creating-a-windows-phone-7-application-consuming-data-using-a-wcf-service/ http://www.techrepublic.com/blog/programming-and-development/my-first-windows-8-application/5273
Aug
5
2011

TFS Folder Structure

Looking at TFS folder structures for better organization and separation of releases. [More]
May
13
2011

My Software Must Have List (games not included)

I thought I’d share the applications that I must have on my computer and devices.  They are the ones you first install after rebuilding your device and they are the most used applications.  I am going to separate them between work and home.  This list does not include my favorite games, maybe I will post them at another time.  The reason I’m sharing this list is because I was inspired by another blogger whose list I refer to whenever I’m looking for a utility.   Scott Hanselman’s 2009 Ultimate Developer and Power Users Tool List for Windows.  I emailed him today asking for a recent list because he has twittered and inadvertently videoed some new utilities.  I’ll mention in my list below if I heard about it from him. Both Stardock Fences – I heard about this from Scott Hanselman post on Herding Cats: Organize your Desktop Icons with Stardock Fences for Windows.  I’ve just recently started using this application and like how I appear organized and uncluttered.  Just like walking into a clean room except it’s in a virtual space.  It does remind me a little of Windows for Workgroups 3.11, where you had windows of organized folders.  KeyPass – (Stored in the Cloud with Asus WebStorage) I run the none installed version from off of the cloud.  This isn’t something I install but I thought it was note worthy since I use it to store all my passwords and I can access it from anywhere. Microsoft OneNote 2010 – My note taker and idea tracker.  I’ve also used this at work when first starting a project I through all my thoughts in a OneNote.  I track the previous project, new requirements, discussions, emails, boardroom drawings, and more.  I can store the OneNote on my Microsoft Live space so that I can access it from any computer with OneNote and I link it to my Windows Phone 7 device.  I use the phones pinning feature to pin the OneNote page that I’m currently obsessing over.  At the this time I have a character from a book I’d like to write in my pinned list. Adobe Photoshop - I am always doodling and designing. Making logos or editing pictures. Since Photoshop runs at a high price I've also used Paint.Net and Inkscape.  These last two applications I heard about from Scott Hanselman by his blog and following him on Twitter. DisplayFusion – I don’t use this tool to its potential.  I just use it because I am addicted to multiple screens and like to have different backgrounds on them. Zune – I used to use iTunes but then I feel in love with the WP7 and haven’t gone back.  iTunes was very painful for me.  Maybe it’s because it wasn’t meant for the PC, but it would always lock up on me during launch, download and playback of video.  I swear now that I will never spend money on iTunes again.  Zune is very simple, in fact if you use it you’ll agree that it’s drag n’ drop simple. Asus WebStorage – I got this with my ASUS Eee Slate and have become a fan.  To the cloud! I use this as I mentioned above for my KeyPass, but also I use it to backup data and sync files between my devices.  I haven’t yet but I can also use it to share with friends and family. Internet Explorer 9 – Be honest, if you didn’t have an Internet Browser on your computer wouldn’t that be the first thing you installed.  For that reason alone I had to add this to my list.  IE9 is my preferred browser, but as a web developer you need to have the primary three flavors.  This means I also have Chrome and Firefox installed.  FYI, I use Bing as my search engine. Livescribe Smartpen –  I bought it for taking meeting and seminar notes. I also thought it could help me work on writing my ideas and book notes.  Honestly, I don’t use it as much is I’d hope. Social Media Application – I currently just use the websites for Twitter, Facebook, MSN, LinkedIn, and the such.  I’ve tried TweetDeck, Seesmic, blu, bDule, and others.  I haven’t found my perfect fit just yet, but the closest so far has been Sobees bDule. Home AVG - My virus protection software of choice. Scrivener – Writing tool used to help write books, papers, poems, and playwrights.  At the time of this post they were in beta trials for their Windows version.  It’s purchase price is listed at around $45.00. Kindle for PC & Kindle for WP7 – I love reading from any device like my PC, Kindle, and my WP7.  The books I have on there now are Patrick Rothfuss The Wise Man's Fear: The Kingkiller Chronicle: Day Two,  Orson Scott Card Pathfinder, Nancy Drew Nancy Drew 01: The Secret of the Old Clock, and Megan McDonald Judy Moody.  Of course the Judy Moody and Nancy Drew are for my 7 year old daughter.  Even if you don’t have the device this is really a great way to read and purchase more books.  The one thing I wish they had was a library membership. Mozilla Thunderbird – I’d really like to use Outlook, but I don’t want to spend that much money on an email application.  I have too many email addresses and am not a big fan of email through a web browser.  I have never conformed to that webmail, maybe it’s because I grew up with the AOL client.  I feel so set in my ways. Cyberlink PowerDVD - A good program for playing DVD's and blu-rays. Picasa - I use Picas to store, manage, and organize my photos and images. Work Visual Studio 2010 – After all I am currently a .Net Developer. Microsoft Expression Studio – I mainly use Blend and Web from the tools.  As a student you can get the software free through DreamSpark.com Gadwin Systems PrintScreen – I am using the freeware version.  The reason I’m using this is because it allows you to include the mouse pointer or menu popups with the screenshot.  It can be customized so that you don’t feel the difference between it and a regular prtscn keystroke. ZoomIt – A kick butt screen magnifier.  This utility is perfect for overhead display or if someone is looking over your shoulder and you want to focus them to specific area.  I’ve been to a lot of local events out here in Virginia and ZoomIt is very popular among the speakers. SQL Server Management Studio – Yep, I use this because of my current interaction with SQL Servers. Free Regular Expression Designer - A good application for deciphering and helping you build regular expressions. Applications Used at Previous Employment Synergy – I had multiple computers including a Linux box running different flavors (mostly RHEL), a Windows XP laptop, and a Windows Server 2003 desktop.  I used Synergy to switch between all three computers using the same keyboard and mouse.  I loved this application. Tortoise SVN – We had a subversion server used to backup our work and I preferred Tortoise SVN to work with the files. Putty - Love this application, used it for tunnels and to communicate with linux hosts. What are your “Must Have” applications?
May
11
2011

Creating a Bookmark (anchor) link in SharePoint 2010

My co-worker was asking for advice on a help documentation site. I noticed she had about 5 sub areas and each one opened a new page where the content was thin. I recommended that she keep the content in the same page and use bookmarks (also called anchors) to jump to the areas below. She then asked me how she would make these. My brain went straight to modifying HTML, but that is an area she is uncomfortable working in. After several manipulations of the Hyperlink feature from an Edit Page mode I figured out how to empower her to create bookmarks. Here are the instructions I sent to her. [More]

About the author

Hi, I am Jamie McCoard (also known as Tevyn). This blog is about my thoughts and dreams towards becoming a writer. Over time it will grow into a writer's journal.  I suggest you follow it now, so that you can say 'I was with her from the beginning.'  

If you would like to read more about me please visit About The Author.

Month List

Disclaimer:

The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.