Wednesday 29 June 2016

.NET on Multiple Platforms

Finally the dream and promise of having .NET run on multiple platform has been made possible with the release of .NET Core 1.0 RTM yesterday.


.NET Core enables .NET code to be run on OS/X, Linux (including Red Hat) apart from Windows. This release and announcement is monumental since that was the basic premise of .NET which was released almost 15 years back.


Along with .NET Core 1.0, ASP.NET Core 1.0 and Visual Studio 2015 Update 3 are also released yesterday. Visual Studio 2015 Update 3 enables you to develop .NET/ASP.NET Core 1.0 applications using the familiar Visual Studio IDE.

Monday 20 August 2012

Windows 8 - First Impressions

I have been wanting to check out Windows 8 for a long time... I have heard so many good things about it... However, yesterday I finally managed to install Windows 8 RTM on my laptop.

These are my first impressions
  1. User Interface is really cool... Very similar to the Windows Phone 7 interface. If you have used WP7, then you will get a hang of it fairly quickly.
  2. Application Store is really cool. Something new for Windows users.
  3. Moving between normal desktop and Windows 8 Style UI is very smooth
  4. It takes time to get hang of the UI gestures using mouse when using Windows 8 in your laptop or PC
I guess overall Microsoft has done a good job with the OS which is the similar for Desktop/Laptop, Tablet and WP8.

However, i think given that the UI takes time to get used to mainly because of the gestures, users using Windows 8 in Desktop/Laptop might not instantly like it and it may delay the migration from the current OS (Windows XP/Vista/7) to Windows 8.

It is indeed one of the biggest gamble Microsoft is doing with Windows 8!!!

Friday 13 July 2012

Moving Controllers to a Seperate Assembly in ASP.NET MVC

I saw a really great tip very recently about moving the controllers which is part of the ASP.NET MVC project to a seperate assembly from Keith Burnell.

This helps in to make the ASP.NET MVC project more testable and also helps to achieve seperation of concerns...

Thanks Keith for this great tip...

Saturday 27 March 2010

Mystery behind Failed on Start (Retrying)

Few days back i wanted to check the behavior of a out of the box (OOTB) document approval when there are multiple approvers in MOSS 2007. I thought the task is simple enough and was all geared up. I started one of my MOSS 2007 VPC’s and opened up a site which i had created earlier. I configured the OOTB approval workflow for a document library which was already available there. The approval workflow was configured to start on creation/updation of any item.
I wanted to test out the workflow. I uploaded a document into the library and hoping for the workflow to kick start. Little that i knew, i was in for a shock!!!
The workflow failed with the status Failed to Start (Retrying). (Refer the below picture)
mossworkflowfailedtostartstatus
This got me wondering what has gone wrong. I am using a OOTB workflow without any modifications, why does it give this error. The workflow log doesn’t help much to understand the problem. (Refer the below picture)
mossworkflowfailedtostartworkflowhistory
The next obvious place to check for diagnosing the issue was the SharePoint logs in 12 hive folder. On checking the logs, i found there where a few entries for Workflow Infrastructure category in the log. The error read like this…
Load Workflow Class: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: The requested Performance Counter is not a custom counter, it has to be initialized as ReadOnly.     at System.Diagnostics.PerformanceCounter.Initialize()     at System.Diagnostics.PerformanceCounter..ctor(String categoryName, String counterName, String instanceName, Boolean readOnly)     at System.Workflow.Runtime.PerformanceCounterManager.CreateCounters(String name)     at System.Workflow.Runtime.Hosting.DefaultWorkflowSchedulerService.OnStarted()     at System.Workflow.Runtime.Hosting.WorkflowRuntimeService.HandleStarted(Object source, WorkflowRuntimeEventArgs e)     at System.EventHandler`1.Invoke(Object sender, TEventArgs e) at System.Workflow.Runtime.WorkflowRuntime.StartRuntime()     at Microsoft.SharePoint.Workflow.SPWinOeHostServices..ctor(SPSite site, SPWeb web, SPWorkflowManager manager, SPWorkflowEngine engine)     --- End of inner exception stack trace …..
This error was quite interesting to me. It looks like the OOTB workflow is creating some performance counters when the workflow starts and it is having some problems to create one thus giving an error Failed on Start.
When i was wondering why it was not able to find the performance counters, thanks to the blog post by Kiran really helped to figure out what’s going wrong. As pointed out in the blog post, there was some issue with the environment and for some reason Windows Workflow Foundation related performance counters were missing. This was basically creating the problem.
As directed in the blog post, I reinstalled .NET Framework 3.0 and associating performance counters with WF instances… Now the workflow was working properly… Wow!!!
However, I have absolutely no idea why those Performance counters went missing!!!
Technorati Tags: ,

Wednesday 24 March 2010

Assigning a task to multiple users in MOSS Workflow

I have been thinking of writing about this for quite a while now!!! Finally managed to sit down to write about the peculiar issue which we faced few weeks back in a Project.

Scenario

Business documents are created and shared using a document library in MOSS. The documents go through the approval process on creation/updating. A list of approvers is assigned. Document can be approved by any one of the approver.

Problem

The out of the box (OOTB) Approval workflow available in MOSS has the capability to add multiple approvers to an item added to document library or list. However it changes only the routing process of the approval workflow i.e. the approval task is to be sent to all the approvers (parallel) or task sent to one approver at a time (serial). (Refer the below picture)

MOSSworkflowApprovers

If we configure our workflow as parallel, then when a document or list item is created/updated, a separate task will be created for all the approvers. (Refer the below picture)

mossworkflowtasksootb

All the approvers have to approve the task for the document/list item to be approved.

However, in our scenario there should be only one task created irrespective of the number of approvers. Any one of the approvers can approve the task. This warranted a custom workflow solution to be built.

In a custom workflow we need to create a task which is assigned to multiple approvers. WF has the CreateTask activity which helps to create the task.

mosscustomworkflowpic1

MethodInvoking event of CreateTask activity is used to assign properties like assignedTo to the task which is created. (Refer the MethodInvoking event of CreateTask activity)

   1: private void createTaskAct_MethodInvoking(object sender, EventArgs e)
   2: {
   3:     try
   4:     {
   5:         using (SPSite site = new SPSite("http://madhu-win2k3:5000/Docs"))
   6:         {
   7:             using (SPWeb web = site.OpenWeb())
   8:             {
   9:                 TaskID = Guid.NewGuid();
  10:                 TaskProps = new SPWorkflowTaskProperties();
  11:                 TaskProps.Title = "Demo Task";
  12:                 TaskProps.AssignedTo = @"1;#MADHU-WIN2K3\Administrator;#15;#MADHU-WIN2K3\sharepointuser";
  13:                 //TaskProps.AssignedTo = web.SiteUsers[0].ID.ToString();
  14:                 TaskProps.Description = "test";
  15:                 TaskProps.ExtendedProperties["comments"] = comments;
  16:                 TaskProps.ExtendedProperties["instructions"] = instructions;
  17:             }
  18:         }
  19:  
  20:     }
  21:     catch (Exception ex)
  22:     {
  23:         Debug.WriteLine(ex);
  24:     }
  25: }

However, the CreateTask activity doesn’t support assigning the task to multiple users even though AssignedTo field of the Workflow Tasks list is changed to allow multiple selection (Refer the below Pic).

mossworkflowtasksassignedTo

Solution

One of the solution to the above problem was to have some other way to assign the task to multiple users since the CreateTask activity was not doing the job.

OnTaskCreated Activity to the rescue. OnTaskCreated activity provides a great way to tap into the task which has been been created and assign properties. The invoked event of the OnTaskCreated activity is used to assign the above said properties. (Refer the sample code for invoked event)

   1: private void onTaskCreated1_Invoked(object sender, ExternalDataEventArgs e)
   2: {
   3:     try
   4:     {
   5:         using (SPSite site = new SPSite("http://madhu-win2k3:5000/Docs"))
   6:         {
   7:             using (SPWeb web = site.OpenWeb())
   8:             {
   9:                 web.AllowUnsafeUpdates = true;
  10:                 SPList list = web.GetList("http://madhu-win2k3:5000/Docs/Lists/Tasks/AllItems.aspx");
  11:                 SPListItem item = list.Items.GetItemById(onTaskCreated1.AfterProperties.TaskItemId);
  12:                 item["Assigned To"] = @"1;#MADHU-WIN2K3\Administrator;#15;#MADHU-WIN2K3\sharepointuser";
  13:                 item.Update();
  14:             }
  15:         }
  16:     }
  17:     catch (Exception ex)
  18:     {
  19:         Debug.WriteLine(ex);
  20:     }
  21: }

With the above code it is now possible to assign the same task to multiple approvers. Thus any one of the approver can approve the task to make the corresponding document/list item approved.

However, for the above code to work it is necessary that the version settings for workflow tasks be disabled. Otherwise, we will get the following error “This task is currently locked by a running workflow and cannot be edited” when the task is approved or rejected.

Caveat

Caveat of the above approach is the version of the Workflow Tasks list has be disabled. This might not be possible in all scenarios.

Other Solutions

One of the other possible solution will be to create another column in the Workflow Tasks list which can allow multiple select to store “assigned to” users.

Another solution might be to create a field control to assign multiple users and use the field control to create a custom column in the Workflow Tasks list.

Technorati Tags: ,

Monday 16 November 2009

NFR

The past few weeks have been quite busy making it difficult to rant... I am going to break this hiatus with a lighter post...

Recently i stumbled across a post by Marcus on the various Non Functional requirements to be captured in any project. Marcus captures all the aspects of non-functional requirements and its a great ready reckoner for anyone interested in them...

Saturday 12 September 2009

Modeling using Visual Studio 2010

Its been a while since i wanted to write about the modeling capability which comes along with Visual Studio 2010.. Yeah!!! you heard it right modeling capability in Visual Studio!!!

Last couple of editions of Visual Studio had fragments of tools like Application Designer, System Designer, Logical Datacenter Designer, and Class Designer. However, apart from class designer i don’t think anyone has used the other designers in live projects. The lack of adoption was primarily because the designers not based on UML standards (Class designer was to some extent). The lack of standards meant one has to rely on Visio or tools like Rational Rose to do the designs… Apart from the lack of standards, couple of things which i didn’t like are lack of support for capturing requirements and interconnectivity between the designers (of course application designer and system designer was interconnected but that didn’t pass on to class designer). So the story of complete Life cycle management using Visual Studio Team Suite/Visual Studio Team foundation was incomplete in my mind.

With Visual Studio Team Suite 2010, Microsoft is trying to change that with new modeling tools and support for UML. It has done away with the designers mentioned above except Class designer. Lets look at what the new tools and what they offer…

To begin with we have the new type of project template in Visual Studio name “Modeling Project”

image

This project is used to create different UML diagrams like use case, activity diagram, component diagram, sequence diagram and logical class diagram.

Use Case Diagram

Use cases provides a way to document the functional requirements of the system. With the use of use case diagram, now users can document functional requirements and also create work items out of it. The use case diagram provides most of the features. One thing which i was searching and didn’t find is constraints, which helps to put restrictions on which the use case will operate. See below a sample use case diagram created using Visual Studio. One cool thing which i liked is, for each of the use cases you can associate work items and track it. This gives a very good traceability.

image

Activity Diagram

Activity diagram is used to model state machines like workflows. The activity diagram in Visual Studio covers most of the stuff available in UML 2. Below sample shows the activity diagram created using Visual Studio. As with use cases, you can create work items for each action item. One thing which i was looking in activity diagram which was missing is swim lanes which helps in separating the actions performed by various users/departments.

image

Component Diagram

Component diagram helps to describe the components which make the application. The below picture shows the component diagram created using Visual Studio 2010. Again as in the previous diagrams, you can create work items based on the components. One cool thing with component diagrams is that you can create sequence diagram from this. Selecting “Create Lifeline” from the context menu of the action item creates the sequence diagram. In component diagram something which was missing was the assembly connector which is used to bridge the required and provided interface.

image

Sequence Diagram

Sequence diagram helps to describe the interaction between the various components. Visual Studio 2010 provides some re-engineering capability and creates sequence diagrams from a method, this helps to understand the code better. However there seems to be a bug and it works only for the Generation scope of Current Project.

image

The below picture shows the sequence diagram created using Visual studio.

image

Logical Class Diagram

Logical class diagram let the user to model the classes, interfaces and enumerations used in the particular application. Logical class diagram has almost all the features available in UML 2 class diagram. The one key thing which i noticed was the attribute types.. Only 4 types are listed… not sure what happened to the other types… One important thing which is missing is the ability to re-engineer the existing code and create class diagram from the same.

image

The list of UML diagrams provided is a good improvement from earlier versions of Visual Studio, however there are still quite a lot of diagrams to be covered like Deployment diagrams, State machine diagrams etc and not to forget the full UML 2 support in all the diagrams.

Apart from the UML diagrams, there is one other diagram which can be created using the Modeling Project. This diagram is called layer diagram. This is the diagram which will be used by the Architects to define the architecture of the application. The cool thing about this diagram is that it comes with in-built types of architecture like 3-Tier, 4-Tier and MVC. The architect can use this as boiler plate and then start customizing the diagram. The below diagram shows the 4-tier layer diagram created using the template provided.

image

One cool thing about the layer diagram is it provides the ability to validate whether the components developed confirms to the architecture. The validation can be done from the designer, command line and also the build process.

Dependency Graph

Using Visual Studio 2010 its very easy to create the dependency graph which will come handy during re-engineering of existing code. The dependency graph can be created based on assembly, namespace or class.

image

The above picture shows an example of dependency graph which is generated using Visual Studio 2010. With the help of the dependency graph it is very easy to find out the assembly/namespace/class which are dependent on a particular assembly/namespace/class.

Visual studio allows you to view the dependency information as a matrix as well as shown below.

image

One bad thing about dependency graph (at least the beta 1) is it just hogs memory… It eats so much memory that not even 3 GB of RAM is enough of it… :-(. Hopefully this will be rectified in the RTM.

Conclusion

With Visual Studio 2010, UML is back as the modeling language within Microsoft’s IDE. Though it doesn’t have the full breadth of UML 2 capabilities still its a good start by having some of the important diagrams in place. Once the full support of UML 2 is added into the IDE it will be a force to reckon with thus giving a complete Life Cycle management.