We're moving to a new blog location!

We upgraded to the newest version of BlogEngine. 

The new blog will be at http://www.Global-webnet.com/Blog

This Blog will remain intact - I just won't be posting new blogs to it.


Tags:
Categories:


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

TreeMap control primer with WPF MVP-VM

Source: Treemap.zip (2.68 mb)

Note: the sample application uses a Portable Class Library (a library that can be used by WPF, Silverlight, Phone and XBox projects).  Resharper has not been updated to support these libraries so it will underline code in red indicating that it cannot find the applicable module - disregard these visual indications as they are false.

I learned how to use the TreeMap control from Diptimaya Patra's blog "Tree Map Control In Silverlight 3".   You may recognize the results as I used his data structures to complete the application I created to learn how to interact with the TreeMap.

My objective was to generate the TreeMap data from a reusable data structure (so the infrastructure could be easily used by other Presenters/processes).   Since REST services are the popular data sources these days I provide mock data from my data access layer using the following structure:

With the Model-View-Presenter, View-Model (MVP-VM) pattern the Presenter is responsible for instantiating the View (line 22 below), configuring the data context, and wiring up events.   In this case the App.xaml instantiates our Presenter and will Show() the shell that it is returned by Initialize().

With MVP-VM no business logic is in our View, the only code it will have is to raise events so that the Presenter can subscribe to them (line 25 above); this permits the View to remain reusable in other modules.   The DriveView (MainWindow class) is shown below:

If a TreeMap block is clicked on (right or left mouse buttons) or hovered over with the mouse the HandleConcreteTreeMapEvent (instantiated on line 46 of the Presenter above) will handle the request.  This method on the Presenter is called by the baseclass ViewEvent process which uses a factory to determine what ConcreteEvent to pass in to HandleConcreteTreeMapEvent.

The DriveTreeMapEventHandler (on line 49 of the Presenter above) contains the logic that will update the ViewModel - it follows:

We'll want to extend the TreeMapViewModel (baseclass) at some point so we'll derive DriveViewModel from it, however for now its existing functionality is all we need to get our TreeMap bootstrapped so it is currently empty.

The important thing to note in this application is that the View and ViewModel are loosely coupled, they could easily be reused in other application.   


Tags: ,
Categories: MVPVM


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

Getting Solr installed and running under windows

If you are here it is assumed that you know what Solr is and want to setup your Windows environment so that you can take advantage of its power.   The steps are pretty straight foreward and I was able to get a development environment up and running within a few minutes.   If you don't know what Solr is, it is worth the time investigating click here. Just keep in the top of your mind that it doesn't replace your DBMS system; it supplements it by providing a very powerful indexing service that can be easily queried.  Where your DBMS will hold normalized table structures Solr is intended to take data, that you might put in denormalized views/tables (to speed up queries), and places it in lighting fast indexes.  The data it returns, i.e., primary keys, can be used to query more detailed results from your DBMS.

  1. Ensure Java is installed and up to date click here

  2. Ensure the Java SE Runtime Environment is installed click here

  3. Install the latest version of TomCat click here  (I installed the 32bit/64bit Windows Service Installer)
    • Tip: use port 8983 during install if you want to be compatible with Solr examples/port
    • Click on Start | Programs | Appache Tomcat <version> | run "Configure Tomcat" as administrator and on the General tab click [Stop] button (so we can configure Tomcat)
    • Tip: leave window open because we will [Start] it again in step 5.
  4. Install Solr by downloading the Solr application from the  "Get Started" section (I installed 3.1.0)  click here
    • After you unzip the appache-solr-(version) file, copy the the .war file (there will be only one) to
      c:\Program Files\Apache Software Foundation\Tomcat<version>\webapps\solr.war
    • From the unzipped contents, copy the \example contents (it will have a start.jar file) to a location on your harddrive, e.g., d:\Tomcat\Solr.   This will be your Solr Home folder in Tomcat.
  5. Configure the Java Options: so that it knows where the Solr home folder is, e.g.,
    -Dsolr.solr.home=d:\tomcat\solr.  


  6. Click [Start] button (step 3) - you should be able to access the Solr site by typing in the following: http://localhost.:8983/solr - you will be greeted with a "Welcome to Solr!" page which will have a link that takes you to the Solr Admin page.
    • Tip: note that I have a period between localhost and the :8983.  This little trick will allow Fiddler to capture events so that you can analyze GET and POST syntax.
  7. Up to this point all went rather smoothly - the problem I encountered was there was no data to play with and the instructions assumed I was on a Unix or Mac OS system.   If you want to play with the sample data and run the tutorials you'll need to download Cygwin click here
    • IMPORTANT: when you get to the "Select Packages" page you will need to search for "curl", click [View] and check the checkbox for the Net | curl: Multi-protocol file transfer command-line tool.   Without this the post.sh will complain that it cannot find "curl"
    • The folder you run cygwin.exe from will become the location for the Unix environment.  You will want to go to the <installed path>\cygwin\home\YourLoginName folder and copy the example folder from step 4 to this folder
    • Double-click the newly installed cygwin icon and you will see the following prompt:


    • Type cd example/exampledocs to change directory the example documentation section
    • Type ls -al  (comparable to dir command) to see a directory - you should see .xml files
    • type in ./post.sh *.xml  to import the sample data

    Now if you run the tutorials http://lucene.apache.org/solr/tutorial.html you will be able to click on tutorial links and see actual results from your local Solr web application!


Tags:
Categories:


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

Setup MVC 3 with Dependency Injection and Mobile support (IPhone, IPad, Windows Phone) in a few minutes!

Not that it took me only five minutes....   I was able to gleen bits and pieces from different sites, however most of the information available (as of this date) applies to beta code that doesn't work with the latest MVC 3 release.  As a result this task started yesterday (Saturday) at approximatey noon and I am just now wrapping it up (Sunday evening 9:00pm)....   Lots of dead-ends and misinformation.... Fortunately I ran into Brad Wilson's site which started to streamline the process by filling in the blanks.

Why did I have to bleed?   I am writing my wife a new website for her business that will automate all of her mundane tasks.   This week she is at home (Amarillo, TX) taking care of her business while I am on location for an out-of-state contract; I proudly tell her "check out the site!".  She calls me back and my pride quickly turned to an unexpected jaw drop - she said "I just accessed the site with my sister's IPad and I can't see the movies - I get a Silverlight button that won't install - it isn't supported".  Naturally she turned to her IPhone next with similiar results - except the screen was real tiny.   

We don't want to limit her client base to desktops (particularly in this day and age of IPhone/IPad) so I am starting to see an early return on investment for my new Mac Pro plus (I'll also be writing her IPad/IPhone apps).  Sure enough, when I accessed the site with both the IPhone and IPad emulators I quickly saw that the site was not where it needed to be.  Early in the research process I learned I can use MP4's for both of these devices so the top priority was providing mobile support for her MVC 3 site.  As of this writing only the IPhone/Windows Phone pages have an MP4 sample - IPad is a work in progress).

Cool Hopefully this will save you some time

Source code: Gwn.Library.TestHarness.zip (4.04 mb)

Setting up a brand new MVC 3 project with Unity (DI) and Mobile support

  1. Create the new MVC 3 project and add a reference to the Gwn.Library.Desktop project
  2. Copy the Mobile folder to the "Views/Home" folder
  3. Copy the _LayoutMobile.cshtml file to the "Shared" folder 
  4. Update the _ViewStart.cshtml as shown in the top right pane (image below)
  5. Update the Global.asax.cs file with lines 43-54 below

Your done!

You'll want to use the IE 9 developer tools to easily switch "user agents" between IPhone, IPad, Windows Phone, and Desktop modes.   Once I launch the application in debug mode I simply hit F12 to open the developer tool view, select Tools, Change User Agent string, and select the platform I am developing/testing for.   Note that the non-desktop devices do not have tabs - this is configurable from the applicable extension.

Below are the custom settings I used for the three platforms - I prefix with a forward slash because the code will do a IndexOf > 0 so I need to ensure my mock agent string does not start at zero.   The current settings used for development worked for the IPhone, IPad and Windows Phone hardware devices.

Once you select a new user agent you simply have to go back to the browser and hit refresh - it will use the specified user agent!


Tags: , ,
Categories: ASP.NET MVC


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

Deploying ASP.NET MVC 3 with Razor to a Windows Server without MVC installed on host

The fun on this issue started when I tried to deploy a basic MVC 3 framework (stock-out-of-the-box) to my ISP server and received the following error:

"Could not load file or assembly 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified."

My assumption was that this namespace resided under System.Web.WebPages namespace since my project had no reference to a System.Web.WebPages.Razor assembly.   In this experience I learned that it is best to start debugging issues at  Scott Hanselmins blog; this is the second time in a week that he has helped me through a "bleeding edge" issue that was causing me to hemorrage....

I appreciated that he started this blog with the following quote - it clarified the meaning of "Bin Deploy"

If someone says "just bin Deploy it" they mean "deploy the application with the dependencies copied into the application's /bin folder, rather than running an MSI that installs the dependencies into the Global Assembly Cache (GAC)."

Even though this blog BIN Deploying ASP.NET MVC 3 with Razor to a Windows Server without MVC installed didn't resolve my issue completely (I ran into more issues) the comments within his blog helped fill in the blanks.  

In summary - follow his instructions for "The Manual Way to BIN Deploy ASP.NET MVC 3 with Razor" which will have you manually copy the following five files to the bin folder (I manually FTP them to the server's bin since I was debugging/troubleshooting):

  1. System.Web.Mvc  (I selected this dll from the references list and changed its "Copy local" property setting to True to resolve this requirement
  2. System.Web.Infrastructure.dll
  3. System.Web.Helpers.dll
  4. System.Web.Razor.dll
  5. System.Web.WebPages.dll
  6. System.WebPages.Razor.dll

From the Program Files(x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/Assemblies folder, which quickly dispelled my belief that the razor namespace was in System.Web.WebPages; I see now that the dependencies were solved externally.

You'll quickly find that you will require a 7th file

     7.  System.Web.WebPages.Deployment.dll (from the same folder as the above)

2011.03.27 UPDATE

 It is actually easier than noted above!!!

I understand this came with VS 2010 SP1

Right click on your MVC 3 web applicaiton and select "Add Deployable Dependencies" 

Select ASP.NET MVC (it will provide everything you need for the RazorViewEngine)

When done you will have the required assemblies in a _bin_deployableAssemblies folder! 


Tags:
Categories: ASP.NET MVC


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

Mac X - Virtual Desktop, or "Spaces"

I configured my Mac's Remote Desktop connection to my Windows 7 box to use full screen on my second monitor.   This works great because I can have both my Apple and Microsoft environments accessible at the same time; particularly useful since I have a heavy investment in software, such as image editors, that I would like to continue to use.

The issue comes when I want to use my second monitor for my Xcode screens, I can overlay them on my remote desktop screen but if I inadvertantly click on it my Xcode screens will be hidden.   Fortunately Mac OS X has spaces (virtual desktop) capabilities built in!

If you click on System Preferences and "Expose & Spaces" you will find you can quickly setup this very powerful feature!

I enabled both checkboxes which gave me a space indicator on the top bar - I can either use this or the Command-1, Command-2, etc., etc., to switch between spaces.   I'll load remote desktop in space 1 and then click Command-2 to go to my second space (note I switched from the default control keys to command keys - see bottom arrow) When I need the remote desktop I simply hit Command-1.


Tags:
Categories: Mac X


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

MAC OS X - remote desktop into Microsoft Windows 7 machine

If you told me a year ago I'd be programming on an Apple I would have laughed at you, even though I started with an Apple][C (programming 65C02 assembly), I have been a loyal Microsoft developer/crony for over 20 years.  BUT, I have to keep up with the times and programming for the IPhone and IPad is something that will be beneficial to clients - so it was time to go to "the dark side".  

It is not as painful as I thought it would be and I'm actually starting to enjoy the Mac environment and am looking forward to learning the infrastructure, Xcode development environment and Objective-C.   After a $1,500.00 dollar investment for a MacPro laptop (13 inch), a Magic Mouse and Keyboard I have a modest start.   I was extremely pleased to find that my USB DisplayLink had a driver for Mac so I get to continue to enjoy my dual screen development environment on my Mac laptop as easily as my HP laptop using my 22 inch flat screen as the second monitor.

Coming from the HP world the Magic Mouse was an excellent investment, I have my scrolling, left, and right click capabilities (I was lost without a right click).  The keyboard was another excellent investment because it gave me my numeric keypad - I'd recommend both if, like myself, you are coming from the HP world.

With my sleeves rolled up and my Mac now connected to my server more, all I needed was access to the tools that I'm use to having - such as my image editors.

Enter stage left - Remote desktop connection for the Mac, provided by Microsoft!   Where my MSDN professional subscription did not provide it I was excited to see that my Technet subscription did!  I downloaded the "Office for Mac Home and Business 2011" and happy to find that I now have Word, Xcel, PowerPoint, Microsoft Document Connection, and of course Remote Desktop! 

Once installed you can execute the Remote Desktop Connection and while the window is open setup the preferences from the RDC menu.   I have use my second monitor (full screen) for my Microsoft platform, this is convenient because I can still use it for the Mac side.

In addition to the following settings I also selected the "Drives" menu option and have it share all drives - this way I can save directly to the Mac from my Microsoft environment.


Tags: ,
Categories: Mac X


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

MAC OS X - Connecting to Windows Shares

I have a heavy investment in my Microsoft development environment, to include image editors, that I don't want to have to duplicate in my Apple development environment.  Fortunately with a few steps I was able to easily share resources.

Open up the Finder window and hold the Command key and press K

You will see the following window where you can browse or specify the server you want to connect to.  The MAC syntax is to preceed the server with "smb://" as shown below.   I hit the + button and added it to my server volume list.

In case your curious this is accessible from the Finder's GO Menu

Once you connect to a share you will be able to access it via a new icon (BDrive below) or from the /Volumes folder.   Below I do a directory listing (ls -l) to view the contents of the /volumes/bdrive/apple folder structure that I created on my GWNServer for apple files.

To make image editing easy for I make an alias of the Images folder, drag it to the desktop, rename it to simply show "Images", and then I delete the alias (Images alias) below.

For blogging all I have to do is hit Command-Shift-4, which provides me a cross-hatch cursor, that I can drag until I captured the screen area I am interested in and when I let go of the mouse button my image appears on the desktop.   I simply drag it to my Images icon on the desktop (above) and delete the desktop version. 

 


Tags:
Categories: Mac X


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

MAC OS X - Showing hidden files in Finder

If we do a directory list "ls -l" we'll find that it displays the same contents as the Finder.

If we do a directly listing using "ls -al" then we get different results - it also shows hidden files (prefixed with a period - see above).

 Under your home directory you will have a library/preferences folder, from the terminal you can type in "cd library/preferences" to get to it.  This folder holds the configuration options for the various applications.   We are interested in the com.apple.finder.plist configuration file.

You can use the "defaults write" command to programmatically set values in this file; in my case the file didn't exist so I found by executing the following - it created it:

defaults write com.apple.finder AppleShowAllFiles -bool true

Likewise you can disable it by setting -bool false.   Once the file exist you can easily update the AppleShowAllFiles configuration, as well as others, using the open command, e.g.,

open library/preferences/com.apple.finder.plist  (as shown below)

In order for this change to take affect the Finder must be restarted.  To do this simply hit the Command-Option-ESC key, select the Finder, and click the relaunch button.  You'll find that when you click on Finder that you will be able to see all files to include hidden ones.


Tags:
Categories: Mac X


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know

MAC OS X - creating an executable file

After clicking on the Terminal icon you will be greated with a "Terminal - bash" prompt.   As a minimum there a few commands that you should be familiar with:

  • ls -l ....... directory listing of files
  • ls-al ...... directory listing of files including hidden files (prefixed with .)
  • rm ........ remove a file
  • rm -R .... remove a directory
  • mkdir .... make a directory
  • cd ......... change directory
  • cp ......... copy file
  • mv ........ move file
  • set ........ show environment variables
  • ~ home path (/Users/loginName)
  • .  current directory (single dot)
  • .. prior directory  (double dot)

Let's create a HelloWorld script. 

Start by typing "pico HelloWorld" and hit enter (as shown in image below)

Type in "echo hello world!" as shown above.

Hold Ctrl key and press X (to Exit).  When prompted to save modified buffer answer "Y" for yes.   Hit enter to accept the name "HelloWorld".

Type in "ls -l" and hit enter, you should find your file in the list with -rw-r--r-- (read write) priviledges.

Execute the "chmod 755 HelloWorld" command which assigns E"x"ecute permission for the newly created script.

If you attempt to run this command by typing "HelloWorld" and hitting enter you will most likely (default configuration) be greeted with a "command not found".   Oddly, the operating system doesn't look in the current directly for commands unless you specifically specify "this location" by using the dot command, e.g., "./HelloWorld" will work.

Obviously this is not practical so I made some easy configuration changes that make my life simpler. 

Execute "pico .bash_profile" and add ".:~/bin:$PATH" to the export Path command (ensure there is no space between PATH and the equal sign) as shown in the image below.

The colon is a delimiter between paths (to search for commands in) and the dot tells it to search the current path, preventing you from having to use ./mycommand.   The ~/bin assumes you created a bin command (md bin) which you can easily use to place your scripts in.  For example:

cp HelloWorld bin 

would copy the HelloWorld executable script to the bin folder, now you can execute it from anywhere in the system.  

The $PATH statement indicates that you want the existing path to be appended to the newly assigned path.

Notice below that in the PATH statement that the "~/bin" was transformed into the actual location "/Users/Bill/bin".


Tags: ,
Categories: Mac X


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know