Partition Wizard - Free Disk Partition Software Review

by Viper 1. December 2009 06:14

For quite some time I have been thinking of creating a new partition on my laptop to dual boot Windows 7 on it. Well I wanted to only have Windows 7 on it but I kept Windows XP on it because Aventail VPN client software will not work on Windows 7. Well, that's a whole different story for some other time.

So this morning I decided to use one of the partition manager softwares to create a new partition from unused 150GB disk space I have on my 250GB disk on may Dell LATITUDE E6500 laptop. After searching around using Bing and Google I came across Partition Wizard and to my surprise they offer free edition for home and well as business use. I was kind of surprised but thrilled that there is some free utility available to repartition my disk. There is difference between spending $49 or $0.

I had to make judgement call. I reviewed files on my laptop and found that most of my critical data including emails are all backed up so I could take a leap of faith. So I went ahead and downloaded the home edition. It was nice that I only had to download 6.7MB file and not 130MB+ file like some other softwares have. Installation was quick and easy. And I did not have to reboot the system as well. So far so good.

I started the GUI for Partition Wizard. It looked well organized and intuitive. I choose my one and only partition and set to resize to create a new partition of 60GB. And then I hit Apply. As expected it asked for system restart. As a good user I said YES to restart.

When system restarted it gave the option that Partition Wizard is going to apply the changes and I have 5 seconds to opt out of it. Partition Wizard started its magic. It went through file system check. Now started resizing phase. It reached 77% of operation and then hit error and could not move forward. So it asked me to hit any key to continue. Machine restarted again and partition wizard launched again to resize the partition. Again it went up to resize phase and then stopped at 77%.

At this point, I did not want to try it again. I gave it two tries. I just could not risk Partition Wizard playing with my file system anymore. So on next reboot I skipped the process of partition resize and let machine boot with Windows XP. Immediately uninstalled Partition Wizard and rebooted the machine. One thing I was happy about Partition Wizard was that after removing the software it did not interfere with reboot process and things like that and my machine was clean again.

I will strongly recommend that you get opinion from users who have actually used Partition Wizard successfully before you try this free disk partition software on your machine. It did not work on two of my laptops. May be you will have better luck with it. But I would not risk it on machine that have mission critical data on it.

Views: 705

Tags: ,

Storage

How to debug DNN module

by Viper 17. November 2009 11:45

In last two posts, Setting up development environment and Implenting custom DNN module, I have described you will do custom DNN module development. Now comes the fun part. How are you going to debug your module. Since your module gets loaded inside DotnetNuke site, the debugging requires change in your project settings.

Need Debug Build

When you used NANT build tool to create package for deployment, it uses release build options. So the assembly for your module does not have DEBUG option turned on in your site. What you can do is that do a DEBUG build of your project and replace module assemblies in BIN folder of your DNN site with the DEBUG version. Or you can make some change in NANT build file for your project to create a DEBUG package and then deploy that. If you are not comfortable with NANT build file, then go with the first option I mentioned.

Change Project Setting

One option you have it to change target start URL that gets invoked when hit F5 or choose Debug > Start Debugging menu option. To do that, bring up Properties of module project. Goto Web tab on the dialog box. You can select Use local web server or Use custom web server radio button and then specify the URL for your DNN installation. Now you will be able to break into your module.

Attach to Process

Other option you have is to choose Debug > Attach to process menu option and then attach to ASP.Net process. And then put break points in your module to debug the problems.

If you are looking into debugging your DNN modules on live site then I will be discussing that in one of my later posts about how you can incorporate logging and diagnostics into your module.

Views: 1122

Tags: , ,

DotNetNuke

How to develop DotnetNuke Module - Implementation of module

by Viper 17. November 2009 06:27

Download Module Project

In previous post Develop DotnetNuke Module - Setting up environment, I described how you will go about setting up your development environment. Now I will start discussion on developing a DNN custom module as stand alone assembly using C#. I have named this module as ByteBlocks: AmazonProducts. The module displays products from Amazon.com store based on product category and search keywords. For this to use in your web site, you will need to have an associate account with Amazon.com. This is totally free and you can get started by clicking here.

Click here to see this module in action


New Project

Select File > New > Project menu option to create new project. In my case, I named it AmazonProducts. This will create a new C# project for you. The project template adds lot of boiler plate code for you to get started. In this post I will explain the files that are absolutely basic to get started with module development. Before you start doing anything, run NANT build tool to make sure that your project compiles. And check that there is a folder named package under the project folder. And this folder should contain four ZIP files in it. If this step goes smoothly, that means you have your development set up correctly and you are ready to rock with module development.

Lets look at some of the files that got added to your project.

.dnn file

This is the file that defines metadata for your module. What this means is that this where you specify how your module is structured, files it contains and other settings. Open this file. This is a XML file. All the node names are very intuitive and very quickly you will figure out what these means. If you are building a single view and single assembly module then you will not have to make any changes under Controls and Files node. For more complex modules that require more files to be included and other things then you will be made to define those settings in these sections. For now, leave it the way it is. Make sure that you have name of the module specified that is relevant to functionality of your module.

View{projectname}.ascx

This is the file where you will implement VIEW of your module. What this means is that this is the control that gets loaded in DNN framework when users come to your site. If you open {projectname}.dnn file you will find a node under controls that looks as below.

<control>
 <src>DesktopModules/AmazonProducts/ViewAmazonProducts.ascx</src>
 <type>View</type>
 <helpurl></helpurl>
</control>

This is the node where you indicate to DNN framework what all controls are going to be used a view for the data. If you have multiple views for your module then you will need to add entries for those views in {projectname}.dnn file. I will explain in another post how you will deal with multiple views and how you will load them at run time based on their IDs and things like that. In this sample module I only have one view.

Settings{projectname}.ascx

This is the control that gets loaded when you invoke settings of a module. DNN framework loads your implementation combined with the base implementation provided by the framework to show settings for the module. If you do not have any custom settings for your module then you do not have to add any content to it. Also open {projectname}.dnn and notice that you have a node like below in there.

<control>
 <key>Settings</key>
 <title>AmazonProducts Settings</title>
 <src>DesktopModules/AmazonProducts/Settings.ascx</src>
 <type>Edit</type>
 <helpurl></helpurl>
</control>

Edit{projectname}.ascx

This is a very important control implementation in your module. If your control requires some input to configure it to run it, then you can use this control to implement gathering of those settings. For example in the sample module, you need to gather 2 very important pieces of information to get data from Amazon.com web service. The images below shows you how a new link Amazon Account Set up appears when you are logged in as an admin and clicking on it brings up a view where you can specify the settings for the module.

Open {projectname}.dnn file you will find a node as shown below.

<control>
 <key<Edit</key<
 <title<Edit Content</title<
 <src<DesktopModules/AmazonProducts/EditAmazonProducts.ascx</src<
 <type<Edit</type<
 <helpurl<</helpurl<
</control<

There are some very important points about how you indicate to DNN framework that this is the control that is going to be used for EDIT. One you have noticed in the DNN file that type has been set to Edit. Second is in your implementation. You have to implement IActionable interface in View{projectname}.ascx control. In that implement you indicate to DNN framework what all other actions can be performed by this module. The project template does not add boiler plate code for this interface in your module. You will have to add it yourself. For example, in the sample project the implementation of the class looks as below.

public partial class ViewAmazonProducts : 
   AmazonProductsModuleBase, IActionable
{....}

Add implementation

Now that you have set up the boiler plate code for your module, it is time to fill it with implementation. You will just go about the implementation as you are doing regular ASP.Net user control implementation. The sample project contains complete implementation of rendering product lists from amazon.com. This code was implemented during .Net1.1 days so lot of code may be obsolete and not optimized according to recent changes. But it will give you get started with your DNN module development.

Compile It

Now that you have finished adding implementation of your module, it is time to see it in action. You can use your Visual Studio to a build of the project and resolve any compile errors. Once all errors have been taken care of, fire up NANT build to create package for your module. You will notice four ZIP files created in package folder.

Install It

Once you have created package for your module, you are ready to install it in your DNN framework. Fire up DNN site and login with HOST account. Yes, you will need to log in as HOST. Once logged in, under HOST menu option, select Module Definitions option. This will bring up list of all modules installed in your installation. On that page at the top you will see a dropdown icon next to Module Definitions. Hover mouse on it and it will bring up menu options. Select Install module option as show below.

In the first step you will be asked to select location of your module package. Point to package folder under your project or wherever you copied the ZIP files created for your module. After that follow the instructions and you will have your module loaded and ready to use on any page in your site.

Use It

Once you are done with installation of module package, it shall be visible in list of modules available for your site. Just follow your usual steps of adding a module on any page on your site and you are good to go.

Debugging

In the next post, I will explain how you can go about debugging a DNN module.

Views: 1102

Tags: ,

DotNetNuke

How to develop DotnetNuke Module - Setup Development Environment

by Viper 16. November 2009 14:20

This is multi-part series on how to write a custom DotnetNuke module as an independent assembly. This series is not about how to add content and configure containers, pages etc. in DNN framework. There are lot of resources available that explain those things in a very details manner. This series of posts are focusing strictly on module development. This post will get you started with getting your development environment set up.

Setting up development environment for DNN module development

I am going to focus mainly on developing DNN module using C#. It does not mean that these concepts do not apply to VB.Net or any other .Net languages. And also I do not have anything against VB.Net. It is just that my main development platform is C#.

Install DNN

First thing you will need is to have DNN site running on your local machine which you will be using to test your modules with. You can download the package from DotNetNuke web site. I will strongly recommend that you download source package instead of just the installation package. This will help you in debugging underlying DNN framework code as well or to step into the implementation to see whats going on. Once you have downloaded the package, follow the installation instructions to get your DNN site up and running on your local machine.

Install DNN Module Project Template

There are few templates available out there that you can download and install in your development environment to use with Visual Studio. I am using Visual Studio 2008 currently so all references I will mention are going to be be targeted to VS2008 environment. I have been using project template published by Engage. They have provided instructions to install it as well. I will put list the set up instructions here as well.

  • Close all instance of Visual Studio on your machine.
  • Save the downloaded project template ZIP file in C:\Documents and Settings\{user name}\My Documents\Visual Studio 2008\Templates\ProjectTemplates\Visual Web Developer. Note that this location is for VS2008 templates. Depending on how you have configured your Visual Studio installation, this location may be different on your machine. Very important that you do not unzip the template compressed file. It needs to be copied as a ZIP file. Otherwise your visual studio will not pick it up.
  • Start Visual Studio instance and select File >New > Project menu option. You should see the new project template installed under My Templates section as shown in picture below. dnn compiled project template

If you can not locate the project template files on Engage web site, let me know. I can try to provide you the template that I use. You will just have to deal with the modifications I have done to it to show my company name and things like that.

Install NANT Build Tool

The project template that you installed from step creates a NANT build file along with other files for module. This NANT build file helps in building and packaging your module correctly. You can compile the project without NANT build tool. But then you will have to make sure that you have packaged the required files. The NANT file generated by this template just takes care of all the steps. If there are some custom requirements, you can always open the NANT file to edit it. You can download latest NANT build tool from Sourceforge.

Now that you have basic infrastructure set up for module development, let's get started with creating our module project. I have created a module that is used to display products from amazon.com based on the product category and search keywords. You will be able to download the whole source for that module in the next post. So lets get started with it.

Developing Amazon.com Products Store Module

Views: 1272

Tags: ,

DotNetNuke

Work from home to make money Scam

by Viper 6. November 2009 16:53

Usually I do not write about these kind of topics. But today of my co-workers asked me about opinion on an advertisement she saw that advetised that you could make $300+/week by working for google from home. In tough economic times a lot of people tend to fall for these kind of statements. This person is well educated and works for an internet company. I asked her to forward me the link she saw. For a change I read throught the whole page. I will have to say that it was very eye catching and written to attract right kind of people.

At this point we all very well know about this infamous Google Money Making Kit which is being adevertised to be sold for $1.97. Here are some of the facts that I will list about this whole scam. Thanks to one of these sites, I found all the information in fine print.

  • $1.97is one time shipping fee or subscription fee you are paying to get started.
  • You have 7 days to cancel the subscription or you will be charged close to $300/month in subscriptions. I bet you did not know that part.
  • To cancel your subscription there is a phone number of mailing address. You can forget about getting to that number
  • Here is worst news. If you accidently do give your credit card number to these sites, your credit card company is not going to be of any help. They will ask you to cancel your credit card account to stop any further payments to them.

Following is fine print that I found hidden in source of the page. I will make it bigger so you could read at leas this part.

This publication provides the Author's opinions and neither the Publisher nor the author intends to render legal, accounting, financial, business or other professional advice with this publication. With regards to licensing of a business enterprise, any legal accounting or tax matters. Author and publisher is an Affiliate of the company offering the business opportunity and are remunerated by advertiser. Author and publisher strongly suggest that the reader seek the services of appropriate licensed business, financial and or legal professionals before proceeding with any actions and comply with the local, state and federal licensing and guideline requirements which the reader resides or conducts business.

Google is in no way associated with this website. The Publisher and Author disclaim any personal liability, loss or risk incurred as a consequence of the use and application of the offer, either directly or indirectly, of any advice, information, or methods presented in this publication. Individual comments are unedited and not the opinion of Author or Publisher and not liable for their comments and opinions.

*INCOME CLAIM WARNING: Testimonials do not result typical result. Photographs or images are depiction of individuals and payment methods. These income examples are representative of some of the most successful participants in the program. Some individuals purchasing the program Sept. make little or NO MONEY AT ALL. These claims are not a guarantee of your income, nor are they typical of average participants. Individual results will vary greatly and in accordance to your input, determination, hard work, and ability to follow directions. No person or company can guarantee profits or freedom from loss. Any and all use of this website certifies you are agreeing to our Earnings and Income Disclaimers.



Here is some more information from another site. Read the costs very carefully

THE STORY DEPICTED ON THIS SITE AND THE PERSON DEPICTED IN THE STORY ARE NOT REAL. RATHER, THIS STORY IS BASED ON THE RESULTS THAT SOME PEOPLE WHO HAVE USED THESE PRODUCTS HAVE ACHIEVED. THE RESULTS PORTRAYED IN THE STORY AND IN THE COMMENTS ARE ILLUSTRATIVE, AND MAY NOT BE THE RESULTS THAT YOU ACHIEVE WITH THESE PRODUCTS. THIS PAGE RECEIVES COMPENSATION FOR CLICKS ON OR PURCHASE OF PRODUCTS FEATURED ON THIS SITE.

We are not affiliated in any way with CNN, WebTV, News Channel 7, ABC, NBC, CBS, U.S. News or FOX. CNN, WebTV, News Channel 7, ABC, NBC, CBS, U.S. News and FOX are all registered trademarks of their respective owners. All trademarks on this web site whether registered or not, are the property of their respective owners. The authors of this web site are not sponsored by or affiliated with any of the third-party trade mark or third-party registered trade mark owners, and make no representations about them, their owners, their products or services.
"THE STORY DEPICTED ON THIS SITE AND THE PERSON DEPICTED IN THE STORY ARE NOT REAL. RATHER, THIS STORY IS BASED ON THE RESULTS THAT SOME PEOPLE WHO HAVE USED THESE PRODUCTS HAVE ACHIEVED. THE RESULTS PORTRAYED IN THE STORY AND IN THE COMMENTS ARE ILLUSTRATIVE, ANDMAY NOT BE THE RESULTS THAT YOU ACHIEVE WITH THESE PRODUCTS. THIS PAGE RECEIVES COMPENSATION FOR CLICKS ON OR PURCHASE OF PRODUCTS FEATURED ON THIS SITE."
INCOME CLAIM WARNING: Testimonials do not result typical result. Photographs or images are depiction of individuals and payment methods. These income examples are representative of some of the most successful participants in the program. Some individuals purchasing the program may make little or NO MONEY AT ALL. These claims are not a guarantee of your income, nor are they typical of average participants. Individual results will vary greatly and in accordance to your input, determination, hard work, and ability to follow directions. No person or company can guarantee profits or freedom from loss. Any and all use of this website certifies you are agreeing to our Terms and Conditions.


* S&H charges do apply. Results will vary by person, and the special offers may only be available for a limited time. Some of the products described on this site have terms regarding continued billing after the trial period ends. This is referred to as negative option, or continuity billing. Therefore, it is important to ensure that you are fully aware of the terms associated with each product before you order. To make this easier for you, we have included links to the billing terms for each of the products below. Please keep in mind that these are separate companies and we are not the best source for information about orders or specific policies. Because these companies control their own policies, shipping and other fees may change periodically. We have linked away from our website directly to their terms and conditions pages.

For the convenience of our readers, we have also included the billing information and cancellation contact info here:

*For Google Profits At Home: By submitting an order, You automatically receive a 7-day trial to the Start Up Kit Using Google. Your 7-day trial begins immediately upon placing your order. You will be billed $1.97 at the time of order submission. Once Your trial is active you have 7-days to decide whether to accept Your Subscription. Prior to the expiration of the 7-day trial period, You may cancel Your subscription by calling toll-free at 877-484-8016 or International customers please call 00-1-646-205-0216. Should You fail to cancel Your Subscription within the 7-day trial You will be billed $79.90 at the completion of the 7-day trial and every month thereafter for continued services and hosting of your Visual Webtools software unless canceled by You.

*For Online Cash Success Kit: Subscriber agrees to pay today the free trial shipping and handling fee of $1.97 to begin subscriber's trial membership. Subscriber has thirty days from the date of enrollment to cancel Trial membership by calling our customer care department at 1-866-995-9812 to cancel their trial subscription and to be issued an authorization number for return of the Online Cash Success Kit disc. Subscriber must clearly write the authorization number on the outside of the package and return the CD to the address given by the customer care department within thirty days from the date of enrollment or does not promptly return the disc with authorization number according to the terms above, Subscriber agrees to pay a one time fee of $99.00, which will be billed on Day thirty one from the date of enrollment. Once the free trial shipping and handling fee has been paid and once Subscriber does not cancel within the thirty day Trial period, the one time fee will be NON REFUNDABLE.
In addition, the subscriber will be provided access to an online Resource Center which will bill at $47.50 on the fifteenth Day from the date of enrollment and we will re-bill every thirty one days at $47.50 per month until cancelled by calling 1-866-995-9812. If for any reason, Subscribers credit card company refuses to pay the amount billed for the service, Subscriber agrees that we may, at our option, suspend or terminate the subscription to the service and require the Subscriber to pay the overdue amount by other means acceptable to us. We may charge a fee for reinstatement of suspended or terminated accounts. You have also been enrolled into a seven (7) day trial to the eBay Money Resource Center. Should you choose not to cancel your eBay Money Resource Center, you will be billed seven dollars and seventy one cents ($7.71) each month for the eBay Money Resource Center. If you wish to cancel your eBay Money Resource Center subscription, please call 1-800-215-1752 to cancel.

Views: 673

Tags:

General

How to programatically set meta tags on ASP.Net page

by Viper 5. November 2009 06:19

When we are creating a web site, one of the main goal we all have is that out site should be listed on first page of search engines like Google, Bing, Yahoo, Baidu etc. As we all know that in SEO world, one of the first thing we all look for in the page is meta tags in header of the page. In the past there was no direct way to set the meta tags on a page programatically when developing ASP.Net web site. We all used the work around of adding metaelements in header element of the page. You can read my previous post Adding meta tags to asp.net page dynamically about that technique. With ASP.Net 4.0 microsoft has introduced following two properties on that allow you to set the meta tags on a page.

  • MetaDescription
  • MetaKeywords

Following code snippet shows how it is used in your code.


public partial class _Default : System.Web.UI.Page
{
 protected void Page_Load(object sender, EventArgs e)
 {
  SetMetaTags();
 }
 private void SetMetaTags()
 {
  Title = "Hello Meta";
  MetaDescription = "This is description of my ASP.Net 4.0 page.";
  MetaKeywords = "ASP.Net,.Net4.0,Meta";
 }
}

And it works. You can see from the source of the page as shown below.

<head>
<title>Hello Meta</title>
<meta name="description" content="This is description of my ASP.Net 4.0 page." />
<meta name="keywords" content="ASP.Net,.Net4.0,Meta" />
</head>

Views: 506

Tags:

.Net | ASP.Net

Tricky - Implementing Halloween Google Wave Robot and Gadget Sample Using .Net

by Viper 3. November 2009 16:58

Download Sample Project

After doing some plain text Google wave robots implementations, it is time for some fun robot that has some graphical implementation to it. This post is about port of tricky python sample published by Google in their Google wave development resources. This robot uses Google wave gadget as well to display some images. So implementation of this robot will help you understand how Google wave gadgets get included in the wave and how you can add them from robot itself. I am not going to discuss implementation of gadget here. I will do it in my future post.

In one of my earlier posts Developing Google Wave Robots Using .Net i discussed fundamental steps in creating and deploying your Google wave robot. So I will refer you to reading that post if you have not done it already. So following those steps i created my new robot named byteblocks-tricky.

How to use and try it

  • Add byteblocks-tricky@appsot.com as participant in your contacts
  • Start a new wave and add byteblocks-tricky@appspot.com as one of the participants in the wave. As soon as you add it as participant, you will notice that title of your wave has changed and a graphical widget gets added to the document.
  • Start a new message and type trick or treat. It will randomly give your trick or treat and display an image for the item.

Implementation

This robot handles WAVELET_SELF_ADDED and BLIP_SUBMITTED. In WAVELET_SELF_ADDED handler, robot inserts a gadget into the wave. In BLIP_SUBMITTED the robot looks for text trick or treat in document. If it finds it, it randomly decided if you are going to get tricked or get a treat. Then it searches Google images for appropriate image for that item and then inserts that image into the document.

Have fun with trick or treat.

Views: 541

Tags:

Google Wave

How to debug Google Wave Robot and extensions

by Viper 3. November 2009 09:32

I have been writing posts on how to develop Google Wave robots. During the process of development of some prototype robots I ran into lot of issues, bugs and what not. Since this is a new framework and still in beta state, so you will be running into more issues than expected. Having the robot hosted on Google app engine cloud adds some challenge itself if you want to debug your robot. And I get questions everybody about debugging of these robots as well. So here is my attempt on putting together some notes and thoughts on debugging a Google wave robot.

Deployment Check

First and foremost, you need to check if your robot has been correctly or not. Here are some steps I follow when I deploy a new robot.

1.Check capabilities.xml

This is a very quick and robot test that will reveal following two things very quickly. In your browser type the URL http://{robotname}.appspot.com/_wave/capabilities.xml. If everything is deployed correctly and working as designed then you should verify following outputs.

  • You do no get 404 status code. If you get 404 (Page not found) then you have deployment issues going on. To resolve this issue, check following things:

    • Your URL is correct.

    • Your robot name is correct.

    • Check in your App Engine dashboard to see if this application has been deployed.

    • Check your code if you are handling requests for this request.

  • You should get a valid capabilities.xml document in response. And this response should contain all the capabilities or events your robot is handling. Here are some common issues that you may run into:

    • You get a blank xml document. Check if you have configured your entry point to robot correctly. One of the common problems I have seen with python implementation is that correct entry point is not provided in app.yaml file. Other problem I run into is that your entry point robot implementation is not correct and is some blank implementation. I have seen this happen when you use Google app engine sdk to create new application.

2. Check profile

If you have provided custom profile or for that matter even if there is some default profile associated with your robot, you can check it. Type this url in your browser, http://{robotname}.appspot.com/_wave/robot/profile. You should get a json response object back that could look something as shown below.


{
  "profileUrl": "http://www.byteblocks.com",
  "imageUrl": "http://wave.byteblocks.com/byteblocksavatar.gif",
  "name": "StockBlocks",
  "javaClass": "com.google.wave.api.ParticipantProfile"
}

If you are handling requests for this URL in your robot and not returning 404 status code, then you should get a response even if its blank document. If you get 404 status code, that would mean that your robot is not configured and implemented correctly.

App Engine Dashboard As Debug Tool

Before I discuss any further, i think this will be good spot to talk about Google App Engine dashboard. This is the place where you will see all your deployed applications, their status etc. If you are seeing errors or problems in your robot, this dashboard is your best friend to get a quick answer to lot of common issues.

  • When you log into your Google app engine application dashboard, you will see Logs link in left pane. Click on it and it will bring a view like below. You can filter your log messages from the filter drop down as shown in the image.


    Another place in dashboard from where you can get details about various requests in your robot is from the summary view. In the CPU load section you can see all the requests that are being sent your robot. You can click on individual URL in that view to get details log about that URL. You can see a sample view of the summary and details log about profile URL in images below.


    A lot of time you will be able to diagnose your problems from this log itself. Following is an example of one of the issues I ran into. I implemented a custom profile for my robot for it to display my avatar and site URL in the profile. But it was not working for me. So I looked at the logs in app engine dash. You can see from the log message below that my robot is throwing 404 error code to the wave client.


    
    11-02 04:31AM 52.458 /_wave/robot/profile 404 82ms 6cpu_ms 0kb gzip(gfe)
    64.233.172.1 - - [02/Nov/2009:04:31:52 -0800] "GET /_wave/robot/profile HTTP/1.1" 404 124
         - "gzip(gfe)" "byteblocks-stocks.appspot.com"
    I 11-02 04:31AM 52.462
    path: <http://wave.byteblocks.com/Stocky.ashx?/_wave/robot/profile>
    I 11-02 04:31AM 52.537
    remote response: 404
    
    

    Just by looking at this message I was able to quickly diagnose the problem. I never implemented a handler for /_wave/robobt/profile. You can read about the details on this in my earlier post Specifying Google wave robot profile data

Implementation problems

This is where some robust error and event logging mechanism will help you greatly. There are couple of tricks I have come up with for my robot implementation. Some of these may or may not apply to your implementation depending on your deployment.

  • Always use structured exception handling around error prone implementation. For that matter since wave api is still in beta state, whole implementation is subject to throw error if underlying data format changes. In your exception handling routines, append detailed stack trace or error messages in the wave itself. But make sure that you this dump configurable so you can turn it on or off from wave itself. In my previous post Google Wave Robot Development Sample I showed how complete .Net stack trace is dumped as new blip in the wave when exceptions occur.
  • Use some instrumentation and logging framework like log4net etc. in your implementation. Log all the errors and warnings in log database(file, or database or event log etc.).
  • Some time unhandled exceptions will occur that may bypass all your safety net. Look in the event logs of your server to see what went wrong.

Get latest code

Yes that is true, the wave api is still in beta state. So always keep your api code updated with latest changes from google code site. I have run into this issue a few times. Just getting latest updates and recompile and redeployment may solve some of the issues that you may be seeing.

More tricks

These are some of the basic diagnostics and debugging steps you can perform to track issues in your robot. There is always some new trick that everybody has. I will keep adding more information to this post as I do some more experiments with this api.

Views: 1279

Tags:

Google Wave

How to specify profile information for google wave robot

by Viper 2. November 2009 11:49

In my earlier post, How to publish google wave robot capabilities, I talked about capabilities.xml file that each robot publishes to declare what event(s) it can handle. And one of the nodes in the XML file was profile. The original specification was that robots could provide their profile information in that node. It looks like that this specification was changed. Now this profile node is ignored in capabilities.xml. Wave client sends a separate request to /wave/robot/profile url to your robot. And it expects a JSON response for that request. That JSON response has the following format and structure.

{
  "profileUrl": "http://www.byteblocks.com",
  "imageUrl": "http://wave.byteblocks.com/byteblocksavatar.gif",
  "name": "StockBlocks",
  "javaClass": "com.google.wave.api.ParticipantProfile"
}

Specifying google wave robot profile information

In your .Net implementation of the robot, it is very easy to provide the profile information. You can add ParticipantProfile attribute to your ASHX handler class. And you are all set to go. You can see from the following code snippet how easy it is do so.


[WebService(Namespace = "http://byteblocks.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ParticipantProfile(Name = "StockBlocks", 
   ImageUrl = "https://wave.google.com/a/wavesandbox.com/static/images/profiles/rusty.png", 
   ProfileUrl = "http://www.byteblocks.com")]
public class Stocky : EventDrivenRobotBase
{.....}

The API will take care of sending the appropriate response to wave client.

Update version

If you want to update existing profile of your robot, then you will need to change version of it as well. The client caches the profiles of robots. Unless it sees that there is a newer version available, it will keep using older profile.

Views: 1123

Tags:

Google Wave

Developing Google Wave Robot To Monitor Latest Stock Price

by Viper 28. October 2009 05:20

Download Sample Robot Project

In my last post Goole Wave Robot Sample, I walked through basic building blocks of development of a Google Wave robot using .Net. I think its time now that we see how this cool framework can be put to some useful lifting for us. In this post I will discuss conversion of Google provided java sample Stocky. This robot parses stock ticker provided in your wave or blip and then it contacts another third party app engine application to get latest stock price corresponding to that ticker. Following image shows how the output of Stocky will look like. This is from .Net port of the sample. I called my sample byteblocks-stocks. So in case you want to give it a spin, add byteblocks-stocks@appspot.com to your contacts.

stocky google wave robot

Events handled by byteblocks-stocks

I discussed some important events and life cycle of wave in my post Life cycle and events in Google Wave Robots. This prototype robot handles two events only (for now). As you develop more and more Google wave robots, you will realize that 80% of the tasks can be accomplished by handling the events I discussed in my earlier posts. Following is the list of events handled by byteblocks-stocks.

  • self_added - As i explained in my earlier post that this event is fired when a robot gets added to a wave. Our stocks robot takes this opportunity to tell the participants how to use its features. For now it announces Get stock price by prefixing your stock symbol with $. You can use this event to do any initialization that needs to be done in the robot as well.
  • blip_submitted - This event is fired when participant has submitted a blip. In layman's terms when participant has clicked on Done button in a blip. The robot parses the contents of the blip document to extract all ticker symbols. Then it contacts a third party service to get latest stock price for that ticker and then modifies the content of the blip with stock price for that ticker.

Sample Project

This is mostly port of java sample to .Net. For now I have repalced java PersistenceManager with ASP.Net cache to save previous tickers mentioned in blips. Other than this changes, the code is very straight forward. You can download the project and play with it to figure out insides of Google wave robot development.

How it works

Here are steps you will follow to see how this robot works

  • Add byteblocks-stocks@appspot.com into your google wave contact list.
  • As soon as you add this robot as participant, it will add a blip with instructions on how to use it.
  • Create a new blip in your wave and type name of any stock ticker. For example to check price of Google stock, you will enter $goog. Depending on how fast event responds and wave synchronizes the information, you will see that blip's content has been replaced with something like goog (550.34).
  • If you want to track price of multiple tickers in same blip, simple enter multiple ticker symbols prefixed with "$". For example $goog$msft$boa

If you have any questions, feel free to drop me a line.

Views: 1686

Tags:

Google Wave

Google Wave Robot Development Sample

by Viper 28. October 2009 05:20

Download Sample Robot Project

In this post I will discuss development of a Google Wave robot using .Net API. This sample is a port of java sample Debuggy provided by google. I have leveraged that sample to build a simple robot that performs following things:

  • Provides debugging messages to understand life cycle of a wave
  • Dumps details about the whole wave

Some of the key concepts demonstrated in this sample are:

  • How to handle various events in a wave?
  • How to extract contents of a wave/blip?
  • How to add new blip to a wave?
  • How to modify content of an existing blip?
  • How to format content of blip?

Steps to develop a google wave robot

In my previous post, I talked about how to go about developing a wave robot using .Net. I will list those points quickly here.

  • Create a google app engine account. If you already have one then you do not need one. Create an application for your robot in app engine dashboard.
  • Modify proxy.py file to point to URL where you will be hosting your .Net ASHX handler to listen on wave events
  • Upload this python application to app engine
  • Create an ASP.Net Web Application project and add an ASHX handler that will provide implementation for all the robot events that you want to handle.

I will pick OnBlipSubmitted implementation from the sample project and discuss it line by line. And following image shows how this robot is interacting in wave client.

google wave robot

protected override void OnBlipSubmitted(IEvent e)
{
 base.OnBlipSubmitted(e);
 IBlip blip = e.Wavelet.AppendBlip();
 TextView textView = blip.Document;
 textView.Append(string.Format("WaBo - Blip submitted [{0}][{1}]", 
  e.Blip.BlipId, e.Blip.Document.Text));
 if (e.Blip.Document.Text.IndexOf("_dumpit_") != -1)
 {
  try
  {
   var cacheKey = string.Format("DumpTrack_{0}", e.Wavelet.WaveId);
   if (HttpContext.Current.Cache[cacheKey] == null)
   {
     e.Wavelet.AppendBlip().Document.Append("Dumping Wave - " + e.Blip.Document.Text);
     ViewUtil.DumpWave(e);
   }
  }
  catch (Exception ex)
  {
   ViewUtil.DumpException(e, ex);
  }
 }
}

All the steps in this method are very intuitive and self explanatory.

  • Each event handler is provided with parsed request data in IEvent parameter. Different properties and methods provide you with access each component of a wave.
  • Method calls base class implementation of the event handler, just in case there is some. Currently base class implementation is empty.
  • To add a new blip, you will call AppendBlip method on Wavelet. If you do not want to add a new blip and want to act on existing blip itself then you can access the blip via e.Blip property.
  • Each blip has an associated document which is view to content of that blip. To access that document of blip, you will access Document property of the blip.
  • To access content of the blip that triggered the event, you can look at Text property of Document object. For example in my sample, I want to check if the content contains the word _dumpit_. I access it via e.Blip.Document.Tex and then look for presence of that text string in there.
  • To add content to your blip, you can utilize following methods on Document object.
    • Append
    • AppendElement
    • AppendInlineBlip
    • AppendMarkup
    • AppendStyledText

    All these methods are very self explanatory. Simplest of all these methods is Append. If you want to insert some simple text you can use this method. For more formatted and styled text you can utilize other methods. Following example shows implementation from method where I am displaying wave creator's name in red color and other participant names are displayed in blue.

    
    foreach (var participant in e.Wavelet.Participants)
    {
     var color = (string.Compare(participant, creator, true) == 0) ? "red" : "blue";
     var txt = string.Format("<span style=\"color:{0};font-weight:bold;\">{1}</span>", 
      color, participant);
     textView.AppendMarkup(txt);
     textView.Append(ViewUtil.CreateNewLine());
    }
    
    

Following image shows how this debug helper robot helps in dumping exception details when somethings goes wrong in robot event handlers.

wave debug

I hope this sample will provide you enough information and details to get started with Google Wave robot development using .Net. I will post some more samples to demonstrate more advanced features of this framework.

Views: 4864

Tags:

Google Wave

Life cycle and events in Google Wave Robots

by Viper 28. October 2009 03:47

In my previous two posts I discussed some basics of getting started with development of Google Wave robots using .Net and then talked about publishing of capabilities.

Let's now see what all events get fired by google wave client and how do you handle them in your robot. First let's see what all events (or capabilities) are available. Here is some information from Google wave api site itself.

Robot Events

The following events which a robot may subscribe to are particularly important:

  • wavelet_blip_created fires when a new wave blip has been created.
  • wavelet_participants_changed fires whenever a participant (including another robot) is added or removed from the wave.
  • wavelet_title_changed fires whenever the wavelet title changes.
  • blip_contributors_changed fires whenever the editors of a blip change.
  • blip_deleted fires whenever a blip is deleted from the wavelet.
  • blip_submitted fires whenever a blip is submitted. Note that this event only fires once the user clicks Done or moves to another blip.
  • document_changed fires whenever content is added to a blip, at various intervals.

I will discuss these events in little bit more details and try to tell you when they get fired

self-added

This event is fired as soon as you add the robot as one of the participant in your wave. It is not manadatory that a robot has to be added when a wave is started. As I mentioned few times, a robot is like a real participant in wave that can be added or removed at any given time. So this event is fired when robot gets added to wave. To handle this event, you will need to override OnWaveletSelfAdded method in your ASHX handler.

wavelet_participants_changed

As soon as robot gets added to a wave, framework sends this event to robot with list of participants who are already part of the wave. Your robot will be included as one of the participants in that list.

wavelet_blip_create

This event is fired when a new blip is created in the wave. An example of creating a new blip could be when you reply to another message. Moment you hit reply link or button, this event is fired. This will be good place to any state initialization in your robot for all new blips that are created. For example if you want to cache ID of the blip for later tracking or things like that, you can do that in this event handler.

document_changed

This event is fired when there is any change in the document. This includes character by character change notification being sent to the robot or participants. You will notice that as you are typing in your wave, your robot is getting these notifications continuously. Since this event is fired very often, it is going to create a lot of network traffic for your robot as well as web server handling the requests. There are couple of things you may want to keep in mind when subscribing to this event:

  • If you are not going to take any action on the document or content while it is being acted on, do not subscribe to this event. This will affect performance of your client application as well web application.
  • Keep the actions as atomic as possible for this event. Especially if your robot is adding new blips or modiying content of the existing blip(s), then long operations in this event handler may give some unwanted UI behavior to your participants.

blip_submitted

This event is fired when a blip is submitted. What this means is that when you hit Done button for your blip, it is no longer in draft mode and it gets submitted. This is one of the most used events because at this point the content of the blip is final (till somebody edits it again). If you are taking action based on final content of the blip, this will be the place where you will do it.

blip_deleted

As name suggests, this is fired when a blip is deleted from wave. If you are keeping some state for a blip in your robot, this will be a good place to perform any clean up or any final actions that need to be taken on that blip.

Other events

There are lot more events that your subscribe to. But the ones that discussed are very basic building blocks of a simple robots. I will discuss other events in my later posts. In next post I will walk through development of a simple debugging robot.

Views: 643

Tags:

Google Wave

How to publish google wave robot capabilities

by Viper 27. October 2009 13:58

In last post Developing Google Wave Extension Using .Net, I gave a quick overview of how to get started with wave robot development. In this post I will try to discuss how communicaton between your robot and wave client works.

What events get notified to client?

Communication between wave client and robot is based on event subscription model. What this means is that a robot has to specify what all events it wants to listen on. There are a lot of events that you can subscribe to. For this post's discussion I will limit it to some basic and important events. So first question you have is how do a robot subscribes for the events? In wave framework this happens by pubslishing of capabilities by robot. When your robot gets added to a wave, the client looks for Capabilities.xml file at your app engine's location. My sample robot is named wavebog. So I see a post request coming to the server for url http://wavebog.appspot.com/_wave/capabilities.xml. Here is example of Capabilities.xml from google wave api.

<w:robot xmlns:w="http://wave.google.com/extensions/robots/1.0">
<w:version>0.1</w:version>
<w:capabilities>
 <w:capability name="BLIP_SUBMITTED"/>
 <w:capability name="DOCUMENT_CHANGED"/>
</w:capabilities>
<w:profile name="Cartoony" 
  imageurl="http://cartoonybot.appspot.com/public/avatar.png" 
  profileurl="http://cartoonybot.appspot.com"/>
</w:robot>

There are two important parts of this file. Under the capbilities node, you specify what all capabilities (or events) the robots can handle. In this example, robot has published that it can handle two events, BLIP_SUBMITTED and DOCUMENT_CHANGED. I will talk about various events little later in the post. Second important piece of the data is Version. If you add more capabilities to your robot and do not change the version number, then your robot may not get notifications for newly added capabilities. So it is important that you handle the robot versioning very carefully. There is some other information in the capabilities file which I will discuss later.

Generating Capbilities.xml file for .Net robot

When you are using .Net API for creating your google wave robot, you do not have to explicitly create this file. The core framework takes care of this for you. I am going to jump ahead a little and give quick over view of how this file gets generated.

When wave client sends request for Capbilities.xml to your robot myrobot@appspot.com, the proxy (as I mentioned in first post), forwards the requests to your ASP.Net handler. The handler parses the request to check if the request is for ?/_wave/capabilities.xml path. If it is then it generates the XML file at run time and sends the response back to client. You will find following implementation in RobotHttpHandlerBase class.

internal XDocument CreateCapabilitiesDocument()
{
 ParticipantProfile profile = Profile;
 return new XDocument(new XDeclaration ("1.0", "UTF-8", null),
    new XElement(RobotNamespace + "robot",
    new XAttribute(XNamespace.Xmlns + "w", RobotNamespace),
    new XElement(RobotNamespace + "capabilities",
     MonitoredEvents.Select(type => type.ToXElement())),
     profile == null ? null : profile.ToXElement(),
     new XElement(RobotNamespace + "version", Version)
 ));
}

At run time it determines what all events your ASHX handler has implemented and then adds those to the xml response accordingly. It also generates unique version number ID based on the names of the events you are handling. So if in future you add implementation for more events, then version number will get changed automatically.

Handling events in your robot

As described in Hello World example, your create an ASHX ASP.Net handler in your web application. And then you change its base class to EventDrivenRobotBase. If you look inside this class you will find that there are lot of virtual methods corresponding to each event that you can possibly handle in your handler. So depending on functionality of your robot, you will override those methods in your handler. For example, based on the capabilities.xml file generated above, I added following methods in my robot.

public class WoBoCop : EventDrivenRobotBase {
protected override void OnWaveletSelfAdded(IEvent e)
{
 IBlip blip = e.Wavelet.AppendBlip();
 ITextView textView = blip.Document;
 textView.Append(string.Format("WaBo - Added to wave {0}", e.Wavelet.Title));
}

protected override void OnDocumentChanged(IEvent e)
{
 base.OnDocumentChanged(e);
 IBlip blip = e.Wavelet.AppendBlip();
 ITextView textView = blip.Document;
 textView.Append(string.Format("WaBo - Blip document changed [{0}]", 
   e.Blip.Document.Text));
}
}

There is some dummy implementation in these methods and mention of some wave concepts like blip, document, wavelet, etc. I will talk about them in next post. For this discussion I just want to concentrate on how you will publish capabilities of your robot.

Test It

To make sure that your robot is working correctly and is publishing correct capabilities, type following URL in your browser.

http://{myrobot}.appspot.com/_wave_capabilities.xml

If everything is working correctly then you should see valid XML document rendered in browser. If you are using Google Chrome then only thing you may see is version number. Do not panic. This does not mean that your robot is not working. There is only one text node in the file with version number. Chrome is rendering only that part. But if you look at the source of the page, you will find your correct XML document. Yeah, this kind of threw me into a loop for few minutes.

In next post I will discuss, what all events you can subscribe to and what is life cycle of a wave events.

Views: 1379

Tags:

Google Wave

How to develop Google Wave Extensions and Gadgets Using .Net

by Viper 27. October 2009 08:47

Google Wave has been out of sandbox for some time now. Google started its open beta pre-view with about 100,000 accounts. There has been lot of buzz in development community about Google Wave framework and writing extensions and widget to build some really useful and cool applications. And recently a lot of interesting extensions have been published.

One of the restrictions on development of extensions at this time is that these can only be hosted in Google App Engine environment. Google only supports two languages (and its derivatives) on Google App Engine, Java and Python. Google has mentioned that in future they will support more languages on their cloud computing environment, but there is no definite time line for that. That leaves .Net development community in a fix as far as Google Wave extension development goes. But as we all know, where there is a will there is a way.

If you look at communication mechanism of Google Wave, there is a way to do extension development in .Net framework and host your robot on ASP.Net web server. Google wave client communicates to robots by sending request to a URL with all the data and then wait for response and act on it. Currently this URL has to correspond to an application hosted on Google App Engine environment. If we can find a mechanism to redirect these calls from Google App Engine application to a URL hosted as ASP.Net application and send the response back to Google Wave client, our job is done. As you may have guessed it that we are talking about writing a light weight proxy to do this job. Soon you will find out that Google has already provided that proxy.

Wave Extension API

Google has provided with Java and Python API to develop wave extensions. There is a .Net port available on Google code at following location.

Google Wave Extension API For .Net

Getting started

There is nice description available at following link about how to get started with your first Hello World application. I will not go into details about that. But I will point out some of the issues that you will run into when you are writing your first wave extension. These are some of the issues I ran into personally. If you have questions, feel free to send me message and I will try to answer them.

Google App Engine Account

This is your first and foremost step in development. You need to create a Google App Engine account. It is free. You can get started by clicking on this link.

Google App Engine

After you are done creating your account, create an application in app engine dashboard. Make sure that you pick some name that is relevant to your extension. This is the name by which your extension will be known to world. Do not worry about uploading any code or anything at this point.

App Engine SDK

On the page from where you started with app engine account, there is a link on right side to down load Google App Engine SDK. Download python SDK and install it. When you install Python based app engine SDK, it will require that you have Python framework installed on your machine. Install will provide with links and everything if you do not have it installed it already.

Uploading Proxy Application

Follow the instructions from WIKI page about modifying the files to point to your ASP.Net server. Launch Google App Engine launcher application. Choose File > Add Existing Application menu option and not File > Create New Application option. If you choose the latter option, the application will add main.py file in your application folder. That file contains a plain hello world application. And the launcher application also overrides app.yaml file and make it to point to main.py instead of proxy.py file. When you will upload the application, you will notice that when you access your robot it always displays Hello World message. So remember to delete main.py file from your folder if it is there and make sure that app.yaml is pointing to correct file for its entry point.

Creating ASP.Net handler for robot

Follow the instructions from WIKI page to create your Hello World message robot. And test it out.

Adding your robot in Wave

To test your robot use the following steps

  1. From “Manage Contacts” section, add your robot extension account to the list. Your robot account is identified like myappengineappname@appspot.com. It is that simple. That’s why I mentioned earlier that make sure that you pick appropriate name for your application. It is also important that this account exists in your contact list before you add it to your waves. Yes a robot is like a real participant in a wave.
  2. From Google Wave client, click on “New Wave” button to start a new wave.
  3. Add your robot as one of the participants in the wave.
  4. You are done. Now your robot is getting event notifications from wave client like a real participant.

It could not be simpler than this. Did I mention that only hard part in this whole process is to get Google Wave account.

This was just to get you started. In next post I will discuss some details about life of a wave and event notifications.

Views: 1858

Tags:

Google Wave

Using DotNetNuke for first time

by Viper 23. October 2009 05:20

I just finished putting together a quick web site for a client using DotNetNuke framework. This was my first time creating a site from scratch using DNN. I have done plenty of custom ASP.Net web sites from scratch in the past. I heard a lot, in the past, about DNN as a quick way to put together some decent sites. But when I came to know that it is developed in VB.Net, I held my self back. It is not that VB.Net is inferior language. But having strong background in C/C++/C# and not very extensive experience in VB always kind of not like any VB.Net development. I have done plenty of VB.Net development but not by choice. I kind of digressed from main topic, sorry about that.

My overall experience was pretty good about new version of DotNetNuke. In the past I did maintenance work on a DNN site that was built with V1.0 of the framework. And it was not a pretty experience for me. But I am pleased with how quickly I was able to put together the site for the client. There are some quirks but like any other good software, it is not going to be perfect and make everybody happy. I think law of 80-20 works very well. If it works 100% for 80% of the people then it did its job. And for rest 20%, it provides hooks to customize the things around.

Views: 418

Tags:

DotNetNuke

How to insert HTML content in email body in Outlook

by Viper 15. October 2009 05:34

If you are creating news letter with nicely formatted HTML content and images etc. and using Outlook to send those emails to your subscribers and user, then here are simple steps that you can follow to do it on Outlook 2007.

  • Create HTML file with all the content that you want to send as email content. Here are few things that you will have to mind
    • Use inline styles.
    • Post your images on an external web site and then add links to that URL in your content
  • Start outlook client application
  • Click on File >New > Mail Message menu option or simple click on New button.

  • Click on Attach File tool bar button as shown below

  • From Insert File dialog box, browse to location where you saved your HTML file. When you click on that file, notice that Insert button in lower right corner is active now. Most important thing to note is that there is a Down Arrow next to the button that most of us do not pay attention to. Click on it and it brings up a menu with 2 options. Click on Inset as text option.

  • You will notice that your HTML file's content has been inserted as content of your email now.
  • If everything looks good, click on Send button and you are done.

Views: 856

Tags:

Microsoft Outlook

Silverlight compile error - The tag 'Label' does not exist in XML namespace

by Viper 8. October 2009 05:55

I was working on a silverlight form in an application. I was trying to add some validations and other related controls on the page. So I had added Label control on the page. I declared the xml namespace and associated tags at the top of the control file as well. When I tried to compile the application, I got the following error. I looked at the declarations, my SDK folder to make sure that I have the required SDK assemblies, I looked in GAC etc. Everything looked good and I still could not figure out what the problem is.

The tag 'Label' does not exist in XML namespace 'clr-namespace:System.Windows.Controls;assembly= System.Windows.Controls.Data.Input'
Could not load type 'Microsoft.Windows.Design.DataContextValueSourceAttribute' from assembly 'Microsoft.Windows.Design.Interaction, Version=3.7.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

What is the problem?

After spending good bit of time, I decided to look at one of the sample in SDK. I still could not figure out the issue. Then I decided to copy and paste the xml namespace and tags from the sample to my XAML file. Now everything worked fine. When I closely looked at the declaration, I saw the issue. See below, the one in red is wrong and one in green is good.

xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly= System.Windows.Controls.Data.Input"

xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"

You can see I had an extra white space after assembly=. It seems that compiler is literally parsing the string and trying to look for assembly file with name as is in the statement. Instead of giving error message that some namespace or control does not exist in the assembly, the correct error message should have been that assembly with name or path could not be found. I could not complain much either because I am using Visual Studio 2010 Beta and beta version has lot of room for improvement.

Views: 1409

Tags:

Silverlight | Visual Studio

How to implement OWA style new message notifier poup using Silverlight and javascript

by Viper 6. October 2009 14:06
OWA style new message notification popup

Download Demo Projects

This is one of the projects I have been planning to work on for some time. I was looking into building an event notifier in one of my ASP.Net application. I wanted it to be more like Outlook Web Access (OWA) new email notifier pop-up. It is the one that slides up from bottom right corner of your browser when there is a new email in your inbox. I had built it in the past using all javascript solution. Yes, this Microsoft is one of the earliest implementation of so called AJAX applications. I did not want to deal with all the javascript code related to setting up HTTP calls and then dealing with response and rendering the results.

I wanted to leverage Silverlight to do all the heavy lifting. And use light weight javascript implementation on client to do animated sliding and positioning of the popup notifier box. At the end it turned out be quite an elegant solution that worked on major browsers like Internet Explorer, FireFox and Chrome. This article is an attempt to describe How to implement OWA style new email notifier popup using Silverlight and Javascript.

The implementation involved the following technologies and I will describe how each component was implemented

  • ASP.Net web application
  • ASP.Net web service
  • Silverlight application

ASP.Net Web Service

Let's start with discussion of the component that is responsible for communication of data between client and server application. The client requests data from server at certain frequency to check if there are any new messages. So I implemented as simple ASP.Net web service application with few web methods. For this demo I had a simple method with following signature.


[WebMethod]
public string GetGlobalMessages()
{
 List msgs = MockData.GetGlobalMessages();
 return msgs.ToJson();
}

For demo application, I implemented a MockData class that creates a random list of messages and then serializes that collection as JSON and sends it in response. I implemented ToJson as an extension method on List<StatusMessage> object. You will find it in Extension.cs file in ActivityData project.


public static string ToJson(this List<StatusMessage> msgs)
{
 var ser = new DataContractJsonSerializer(msgs.GetType());
 var ms = new MemoryStream();
 ser.WriteObject(ms, msgs);
 var serializedData = System.Text.UTF8Encoding.UTF8.GetString(ms.ToArray());
 return serializedData;
}

You can see there is nothing fancy about this whole implementation to make it work with a Silverlight client. A very simple ASP.Net web service.

Silverlight Application

This is where all the action happens. There are few components of this application, rendering and data access. Lets us first discuss data access. The client application is to talk to server at certain frequency. That means I need some kind of timer going in the application. When this timer ticks at specified interval of time, it send asynchronous request to server to get new messages. I have implemented this whole mechanism in MessageMonitor application. When this class is constructed, it creates an instance of DispatchTimer. You may be asking why DispatchTimer and why not simple Timer application. The problem is that when you are dealing with user interface application, you can only update the controls on the thread on which they were dispatched. Regular timer does not executes on that dispatcher thread. So if you will try to update your user interface on that thread you will get exception complaining about cross threaded access. Here is the code that created DispatcherTimer for my application.


private void CreateMessagePollTimer()
{
 _messagePollTimer = new DispatcherTimer();
 _messagePollTimer.Tick += new EventHandler(MessagePollTimer_Tick);
 _messagePollTimer.Interval = new TimeSpan(0, 0, MessagePollInterval);
}

When the timer ticks it calls MessagePollTimer_Tick method. And that method makes async request to server to get new messages.


void MessagePollTimer_Tick(object sender, EventArgs e)
{
 if (Stopping || MessagePollInProgress) return;
 GetMessages();
}

When async request to server completes, the following method gets called. You can see that now it uses the same JsonSerializer class to de-serialize the response into list of StatusMessage objects. And then it raises event for objects that have subscribed to the event.


void GetGlobalMessagesCompleted(object sender, 
  SiteMessagePanel.ActivityDataServices.GetGlobalMessagesCompletedEventArgs e)
{
if (e.Error != null)
{
 return;
}
 var msgsData = e.Result as String;
 var msgs = msgsData.FromJson();
 System.Diagnostics.Debug.WriteLine(msgs);
 StatusMessageEventArgs args = new StatusMessageEventArgs(msgs);
 OnStatusMessageReceieved(args);
}

Page class that implements user interface for popup, handles this event and renders all the messages.


void Monitor_StatusMessageReceieved(object sender, 
 ByteBlocks.ActivityData.StatusMessageEventArgs arg)
{
 if (arg.Messages.Count == 0)
 {
 msgTextBlock.Text = "No messages received";
 ShowClientPanel(false);
 return;
 }

 msgTextBlock.Text = string.Empty;
 messagesPanel.Children.Clear();
 foreach (var msg in arg.Messages)
 {
  StackPanel sp = new StackPanel();
  TextBlock tb = new TextBlock();
  tb.Text = msg.Title;
  tb.TextWrapping = TextWrapping.Wrap;
  sp.Children.Add(tb);
  messagesPanel.Children.Add(sp);
 }
 ShowClientPanel(true);
}

ASP.Net application and javascript

ASP.Net application acts as a host for the silverlight control that I created to render messages. I have implemented a simple Server Control that hosts it. Then I added that control inside a simple div on the master page. And I have very simple vanilla implementation of the server control. It does not have very complicated implementation. I simply copied the code generated by silverlight wizard for test page into that control


<div id="statusslideup">
<ByteBlocks:StatusPanel runat="server" id="statusPanel" />
</div>

Calling Javascript Method From Silverlight

So far we have implemented two pieces of the application that drive the data and render it. Now comes the fun part. How are we going to trigger the client to show the popup and animate it to come up from bottom. First, it is Silverlight application that is running the timer. So it is the one that has to trigger the client. I implemented some java script code that shows the DIV that hosts silverlight client component. And then small piece of code that implements animation. Silverlight framework provides a very simple mechanism to invoke any Javascript method that is implemented on client side. I implemented a very simple method in silvelight application to call my JS method whenever there are new messages for the user.


private void ShowClientPanel(bool show)
{
 HtmlPage.Window.Invoke("_showStatusPanel", show);
}

It could not be any simpler. And the following Javascript function implements small piece of code that calculates position of popup notifier window based on browser height and height of element containing silverlight control.


setStatusPanelPosition = function() {
 if (_statusdiv) {
 _maxPanelPos = document.body.scrollTop + ($(document).height() - _statusdiv.clientHeight);
 _curPanelPos = $(document).height();
 if (!_isStatusVisible) {
  _sliderInterval = setInterval("_slidePanel()", 5);
 }
 else {
  _statusdiv.style.top = _maxPanelPos + "px";
 }
 _isStatusVisible = true;
 }
}

Demo Project

Attached demo project is a collection of Visual Studio 2010 projects and solution. If you do not have VS2010, you can simply create a new solution and projects in VS2008 and copy the source files in there. You are also going to need to download Silverlight 3 Toolkit because I use theming controls from that toolkit to give some zing to the UI.

I hope this demo project helps you in building cooler implementations of OWA like message and event notifier windows.

Views: 2398

Tags: , ,

ASP.Net | Javascript | JQuery | Silverlight

Unable to start debugging on the web server - Error when starting ASP.Net debugging

by Viper 1. October 2009 13:59

Recently I installed Visual Studio 2010 and was working on a prototype User Activity Monitoring administration application. When I tried to launch the application in Visual Studio IDE, I got the following error message box.

---------------------------
Microsoft Visual Studio
---------------------------
Unable to start debugging on the web server. Debugging failed because integrated 
Windows authentication is not enabled. Please see Help for assistance.
---------------------------
OK   Help   
---------------------------

As the error suggests that I need to enable windows authentication. And that is a pre-requisites for running ASP.Net application under debugger. But thing that was different is that till Visual Studio 2008 when you made the IDE to create Virtual Directory, it used to enable windows authentication in IIS for that virtual directory. It seems that Visual Studio 2010 does things differently. It only enables anonymous access. You will have to explicitly enable windows authentication. It is simple procedure.

  • Launch IIS manager
  • Right click on virtual directory and select Properties menu option
  • Select Directory Security tab on the dialog box.
  • On this view click on Edit button in Anonymous access and authentication control section at top
  • On this dialog box, check the check box at the bottom in front of Integrated Windows Authentication option.
  • Click OK and apply your changes.

Views: 1066

Tags: ,

ASP.Net | IIS | Visual Studio

There is no device supporting CUDA

by Viper 29. September 2009 11:37

Recently I got assigned to looking into CUDA architecture to speed some of heavy computations in our application. So this was my first attempt on CUDA stuff. I have a Dell XPS 630 Windows XP machine with NVidia GeForce GTX285 video card. So I followed the steps mentioned on NVidia CUDA site for installing drivers etc. So the sequence of install is CUDA Driver, CUDA Toolkit and CUDA SDK. Just to test that everything is installed correctly and working fine, I compiled clock sample and tried to run it. I got error message saying no CUDA devices found. I looked around on different forums and sites and lot of people had run into similar issues. A lot of got the issue resolved by installing newer driver. I have a relatively newer machine with latest drivers. And I also made sure that I install CUDA 2.3 drivers and toolkits. So I reinstalled the drivers and everything and still it will not work. I ran deviceQuery sample as well. And it gave me the same error message. The out of that sample looked as below.

CUDA Device Query (Runtime API) version (CUDART static linking)
There is no device supporting CUDA.

Device 0: "Device Emulation (CPU)"
  CUDA Driver Version:                           2.30
  CUDA Runtime Version:                          2.30
  CUDA Capability Major revision number:         9999
  CUDA Capability Minor revision number:         9999
  Total amount of global memory:                 4294967295 bytes
  Number of multiprocessors:                     16
  Number of cores:                               128
  Total amount of constant memory:               65536 bytes
  Total amount of shared memory per block:       16384 bytes
  Total number of registers available per block: 8192
  Warp size:                                     1
  Maximum number of threads per block:           512
  Maximum sizes of each dimension of a block:    512 x 512 x 64
  Maximum sizes of each dimension of a grid:     65535 x 65535 x 1
  Maximum memory pitch:                          262144 bytes
  Texture alignment:                             256 bytes
  Clock rate:                                    1.35 GHz
  Concurrent copy and execution:                 No
  Run time limit on kernels:                     No
  Integrated:                                    Yes
  Support host page-locked memory mapping:       Yes
  Compute mode:                                  Unknown

Test PASSED

Press ENTER to exit...

That was not a good sign. Then I started thinking and then it struck my mind that I am not directly logged into my desktop. I was using remote desktop to use the machine. In the past when I have tried to run some video games over RDP, I always used to get error telling me that I could not do so over RDP. So I immediately switched the connections and directly logged into the machine. And there it was, everything worked like a charm. And I felt like a dumb noob :-) Bottom line is that when you are seeing similar issue, check the following things:

  • Make sure you have latest video card driver installed
  • Make sure that you are using latest CUDA driver, toolkit and SDK
  • Make sure that you install three component in order suggested by NVidia
  • and .... you are directly logged into the machine and not using RDP or using any means that puts its own graphics pipe line on top

Views: 918

Tags: ,

Video Driver | CUDA

Powered by BlogEngine.NET 1.4.6.1
Theme by Naveen Kohli

Recent

By Categories