Welcome to EMC Consulting Blogs Sign in | Join | Help

Ira Lustman's Blog

  • 70-583 Windows Azure Exam

    I passed the Azure Exam this week and thought I would share my preparation steps.  Overall I thought it was a fair exam that emphasized product knowledge and analysis skills.    There was no combing thru code or config files looking for minor syntax variation type questions. There were 55 questions and 700 was the passing score.

    My preparation consisted of:

    • set up a VM and download Windows Azure Training Kit.  This will walk you thru the install of the sdk and its pre-reqs.  The training kits has a good series of guided Labs and Demos that walk thru common azure development tasks.    I did all of the labs in the training kit.
    • read Programming Windows Azure: Programming the Microsoft Cloud from cover to cover.   The book may be a bit dated but I thought it clear and liked the authors reading style.
    • I read every link in this buck woody blog post
    • This site had a free set of practice questions.   The questions on the test where really not like the questions in this practice test but did get me into “test taking mode” (my last cert was over 2 years ago) and highlighted some areas that I hadn’t come across yet.

    There is lots of debate about whether certification exams are worthwhile or prove anything.  In this case, the exam itself provided a goal to help get up to speed on Azure and provided an outline to help me go “wide” in learning different aspects of the product.   Looking forward to doing a real azure project!

  • Azure Trial Account options

     

    I’m going thru the Azure Training kit and need to obtain a windows azure account and I am reaching out to see what is the best way to go.

    As I understand it, options are:

    · I’m aware of free 30 day (no credit card required) trial accounts (for example http://windowsazurepass.com/?campid=878F2064-1944-E011-98E3-001F29C8E9A8) .  I have signed up for this 2 weeks ago and got an email stating “You have been added to the waiting list for a Windows Azure platform 30 day pass.You will be notified if a pass becomes available.”

    · http://www.microsoft.com/windowsazure/free-trial/  this page requires a credit card and gives you 90 days free with allocation limits.  Overages hit the credit card.    Since, I’m just playing, I’m obviously concerned with writing some dumb-ass code that results in surprise charges.

    · MSDN subscribers have azure benefits included with their subscription (http://www.microsoft.com/windowsazure/msdn-benefits/)  I’m sure we have a ton of MSDN subscriptions but I’m unsure if I can provision azure storage in association with what we have.

    Are there other options that I’m not aware of?  Can you guys point me in the right direction? 

  • Things I am glad that we did when we started this project.

     

    We onboarded 2 new members to our team last month.   As we were “showing them the ropes”,  I thought about some of the things we did that made the process of onboarding new team members easier while increasing developer productivity.

    1. I suspect that this is a no brainer at this point, but doing all development in a Virtual Machine makes getting the new guy(or gal) up and running a simple copy operation.
    2. Solution Organization.   Using Visual Studio folders we separated client and server side components. 

    CropperCapture[13]

    This project is a silverlight project and we used Prism.    We created a silverlight module project template to ensure that all modules had the same structure and plumbing:

    CropperCapture[15]

    We also added a new item template for a prism View / View Model so that all the views and view models started their life in a uniform manner.

    CropperCapture[17]

     

    3.  We established some code snippets for common operations.   Explaining how and where to use these snippets to new team members really help them recognize and come up to speed on the key patterns.

    propn (sets up a INotifyPropertyChanged Property)

    CropperCapture[18]

    service_property_changed (boilerplate code to capture property change notifications from a silverlight service

    CropperCapture[19]

    dcmd (delegate command implementation)

    CropperCapture[20]

     

    4.  Keeping developer databases in sync.   We used a tool we downloaded from codeplex named database build tool.  This allows developers the ability to run CreateDatabase.bat to recreate their local databases uses .sql scripts checked into source control.  UpgradeDatabase.bat runs scripts checked in that have not been executed against the local database while preserving the local DB’s test data.

  • Linq to Sql. How to Profile the generated sql statements

    Its often handy see the sql that is generated by L2S statements in your project.    Last week I needed to capture the generated SQL, and paste it into SQL Management Studio to analyze the performance of the query.  L2S makes this easy to do via the DataContext Log Property.   

    myDataContext.Log = new DebugTextWriter()

    The DebugTextWriter Class is as follows":
    class DebugTextWriter : System.IO.TextWriter 
    {
       public override void Write(char[] buffer, int index, int count) {
           System.Diagnostics.Debug.Write(new String(buffer, index, count));
       }

       public override void Write(string value) {
           System.Diagnostics.Debug.Write(value);
       }

       public override Encoding Encoding {
           get { return System.Text.Encoding.Default; }
       }
    }
    I like to use Debugview to view system.diagnostics output 
    (free download at http://technet.microsoft.com/en-us/sysinternals/bb896647) 
     
     
  • Minimum Value for a SQL DateTime variable

     

    We had a silverlight page which had text boxes for a report start date and end date and then passed those values to a SQL Server to extract data for the date range.   The view model set the initial values for the 2 fields to DateTime.MinValue and DateTime.MaxValue.  If the user did not enter anything in the start date field we got a SqlDateTime overflow when trying to execute the query.

    This is because the minimum value for a SQL DateTime is 1/1/1753 and the .NET DateTime.MinValue is 1/1/0001

    To fix this we had to initialize the Report Start Date as follows:

    DateTime minValue = SqlDateTime.MinValue.Value;

  • Editing Documents in a Silverlight Application

    We have developed a digital asset management (DAM) application.  The base architecture is as follows:

    • The user interface is written with Silverlight 4
    • Assets are stored in SQL Server using the FileStream data type.
    • Communication between Silverlight and the mid tier is over WCF

    Users want to be able to select a document inside our Silverlight application, choose edit, have the document fire up in the native application, and have any changes made reflected inside DAM.  Documents are not limited to any specific types and are predominantly adobe PSD and AI files and Office documents.   Users love the user interface and other system features, but they miss the feel of native editing that sharepoint provides. 

    We are considering the following approach and seek opinions from the community on its feasibility.

    1. A WebDAV enabled folder would set up in IIS.
    2. The user selects a document in dam and chooses Edit.  This would invoke a wcf call.
    3. The wcf service would:
    • Create a subfolder in the WebDAV Main folder and secure it.
    • Extract the document from the dam database and stores it in the newly created WebDav folder
    • Send a response back to the client with the location of the extracted document

    The Silverlight client  would then pop up a new browser window pointing at the document in WebDAV.

    When the user saves the document it will be saved in the WebDAV folder.   A windows service will listen for file change notification events on the WebDAV folder tree.  When an event is raised, the service will cause the updated documents contents to replace the prior contents in the dam database.  The windows service will also clean any documents in the WebDAV tree that are older than x days.

    Benefits:

    1. We don't have to link to SharePoint.

    2. All types of files are supported.

    3. Security can be handled by dynamically creating user folders with appropriate permissions.

    Potential Issues:

    1. Microsoft Office 2003 and 2007, and potentially other versions of Office open documents from WebDAV sites as Read-Only by default. This can be overridden with a registry setting, which could be pushed out by Group Policy.

    2. WebDAV gives some people the "heeby jeebies". I have not had enough experience with it to know why.

    Alternatives:

    Instead of using WebDAV, host an instance of SharePoint Foundation or SharePoint server and use the appropriate API's to store and secure the document.  Our initial inclination toward WebDAV is to keep the footprint small.

  • SQL Server XML Query

    Every 6 months or so, I have to query a SQL Server database with criteria that is buried in an XML data type.  I say to myself, self, you know you have done this before.  But i can never remember the syntax and for some reason, it takes me more time than it should to search and get it working.  So, i’m putting it here so it will be easy for me (and anyone else) to find.

     

    select whatever from tableWithXMLcolumn where tableWithXMLcolumn.XMLcolumn.value('(/AssetAttributes/Tags/SecurityClassification)[1]' ,'varchar(25)') = 'Secure Restricted'

     

    AssetAttributes/Tags/SecurityClassification  is my xpath and Secure Restricted what the search criteria.

     

    I’m pretty sure I’ll come back here in about 6 months the next time i have to do this.

  • Running Office in a windows service

    In my last post Rendering Office Documents in Silverlight I described a situation in which a windows service needed to create XPS files from office documents.    We were using the PDFNET SDK from PDFTRON to accomplish this and they claimed this would work.  In fact it did work for excel, powerpoint and pdf files in my development and test environments.  It even worked in our QA environment for .doc and .docx files.   In our production environment i would see a winword.exe process in the task manager fire up and never go away whenever a word document was processed. The exact same code worked when run out of a console application instead of a service. 

    Microsofts official word on the subject in Considerations for server-side Automation of Office was not encouraging. 

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    This problem plagued the project for several weeks.  We needed to implement a stop gap process in which a desktop was logged into and had the console application running.  Whenever the desktop got rebooted, someone needed to rdp into it and restart the console application.  This definitely was not going to cut it long term.

    Fortunately the fix was as simple as creating a folder!  The trick that finally made this work was (major props to http://emalvass.blogspot.com/2010/01/how-to-use-office-2007-automation-in.html  for posting this.

    • for x64 system is necessary to create the following folder:
      C:\Windows\SysWOW64\config\systemprofile\Desktop
    • for x86 system:
      C:\Windows\System32\config\systemprofile\Desktop

    After creating this folder in the production environment things started working.  I went back to the QA environment where things were working all along and sure enough that folder was present.

  • Rendering Office Documents in Silverlight

    Our current project had a requirement for users to be able to view office (and PDF) documents in our Silverlight client without the ability to save or print the documents locally. The documents needed to be watermarked with the users login ID and the date when viewed.

    The final solution worked as follows: (the magic is in steps 3 and 4)

    1. Document Owners upload source documents in the Silverlight client.

    2. Uploaded Documents are stored in SQL Server Filestream stores.

    3. A windows service processes uploaded files creating XPS files.

    4. A Silverlight view hosts a control which renders xps files within the Silverlight client.

    In order to facilitate the production of XPS files in the windows service we utilized the pdfnet sdk from pdftron (http://www.pdftron.com/pdfnet/index.html). This sdk allowed us to convert our uploaded files to xps.

    The second part of the solution was the document toolkit (http://firstfloorsoftware.com/documenttoolkit). This provided an easy to implement reader control that had all of the viewing and watermarking options built in. I’d also like to note here that the support from Koen at first floor software was outstanding. First Floor also makes the highly recommended Silverlight spy product.

    An example of an office document in the document toolkit is shown below:

    CropperCapture[5]

  • Dealing with IIS 7 metabase changes

    We have recently released version 1.0 of our project and started to work on version 1.1.   We followed the TFS Rangers Branching Guidance and branched so that the development track is IIS virtual Directory was at ..\Dev\Main\MyFolder and the production track was at ..\Main\Myfolder.

    When opening up my Visual Studio Solution in the Production folder, i was presented with the following dialog:

    image

     

    There are several web projects that would require altering IIS to point to the new location each time i would switch back and forth to different code branches.

    IIS 7 has an appcmd utility that really solved this problem for me.  It is described at How to Back Up an IIS 7 Configuration.   

     

    I set up my IIS to point to my main track and used appcmd to backup the configuration:

    Appcmd add backup Main

    Then I modified IIS to point to the dev track and backed that up:

     

    Appcmd add backup Dev

    I then created 2 BAT files (one named RestoreIISMain.bat and the other Named RestoreIISDev.bat:

    %windir%\system32\inetsrv\appcmd.exe restore backup "Main"
    pause

     

    %windir%\system32\inetsrv\appcmd.exe restore backup "Dev"
    pause

    Switching back and forth is now a single click operation.

Powered by Community Server (Personal Edition), by Telligent Systems