Service Bus MQ Manager v3.00 Released

by Daniel Halan 25. March 2013 00:25

Just released v3.00 of Service Bus MQ Manager, it contains a complete source code overhaul, with a simpler Service Bus Adapter API and including following features,

  • Show Processed Messages, Load messages from the Journal queues. For use cases such as, show messages that got processed before Service Bus MQ Manager was started, or messages that where added and processed before the Service Bus monitor process discovered them.
  • Queue Colors, Set specific color per Queue, for easier overview of different categories of messages that span over queue types.
  • Resend Command, Easy access to resend a command, opens up the send command dialog so changes can be made before sent again.
  • JSON Messages, Now support for JSON serialized messages.
  • Error Stack Trace, View Stack Trace of Error messages
  • Perfomance improvments, Quicker loading times and less resource consuming when processing large amounts of messages.
  • Quick filter, Start typing and only messages with names containing the text will be shown

 Go to Download page

 

Deserializing objects with non-default constructors in JSON.NET

by Daniel Halan 5. January 2013 12:06

Recently I've come across the need to be able to serialize and deserialize objects with non-default constructors using JSON.NET. One way of doing this is to add JsonConstructor attribute to one (1) constructor and make sure that all parameter names does match the public properties names. But the problem arise when you don’t have control over the classes that should be serialized/deserialize, or just don't want to add JSON specific constructors mudding your objects.

So the other solution would be to have a fallback method whenever JSON.NET cannot find an appropriate constructor, giving an opportunity to analyze the class and call the appropriate constructor returning an instance of the newly created object.

Here follows example code of how it works,

public static T ReadJsonFile(string fileName) {

  if( File.Exists(fileName) ) {
    var s = new JsonSerializerSettings {
      ConstructorHandlingFallback = CtorFallback
    };


    return (T)JsonConvert.DeserializeObject(File.ReadAllText(fileName), typeof(T), s);
  }

  return default(T);
}

// Create new object instance using default values for constructor parameters
private static void CtorFallback(object sender, ConstructorHandlingFallbackEventArgs e) {
  
  List<object> args = new List<object>();
  foreach( var p in e.ObjectContract.Properties ) {
	args.Add(p.PropertyType.IsValueType ? Activator.CreateInstance(p.PropertyType) : null);
  }

  e.Object = Activator.CreateInstance(e.ObjectContract.UnderlyingType, args.ToArray());

  e.Handled = true;
}

The modified JSON.NET library is a part of the Service Bus MQ Manager project at GitHub, the compiled version can be downloaded below, until this gets implemented in future versions of JSON.NET.

 

 Newtonsoft.Json.zip v4.5 r11 (479.28 kb)

This also solves the exception "Unable to find a constructor to use for type 'xxx'. A class should either have a default constructor, one constructor with arguments or a constructor marked with the JsonConstructor attribute" that JSON.NET throws where there are more then one parameterized public constructors and none public default constructor.

 

Service Bus MQ Manager v2.0 Released

by Daniel Halan 14. December 2012 16:25

Just released version 2.0 of Service Bus MQ Manager, the release includes Sending Commands, Viewing Subscriptions, in-application configuration and improvments in fetching messages before they gets processed. It has been tested with NServiceBus and MSMQ.

 Go to Download page

A MSMQ Viewer for NServiceBus

by Daniel Halan 5. October 2012 07:25

I've lately been working with a scalable cloud solution, and then it's good to use a Service Bus for sending commands, events and messages around the network. Now I tried few MSMQ message viewers that are available, but they all lacked the real-time feedback that would be nice when debugging or just want to know what is happening behind the scenes. So from that a new small application grew, called "ServiceBus MQ Manager". It's a small application that will monitor queues with a set interval, and present the Events, Commands and Messages that are there, but also keeping messages that has been retrieved (deleted) from the Queue.

One feature worth mentioning is that you can easily move messages that are in the Error queue to their original queue, just by selecting them and using the context menu.

Currently it has only been design and tested for NServiceBus using MSMQ, but it could easily be extended to use with any other Service Bus such as MassTransit and Azure Service Bus.

 Go to Download page

The source code is available at GitHub

 

    

Replaying events using Event Store with RavenDB

by Daniel Halan 27. February 2012 06:44

Been working latly with Event Sourcing and the CQRS pattern. One of the great features of Event Sourcing is to be able to change the view model schemas and simply replay all the events and let the event handlers rebuild all your view models. No more deltas to think about. Been using the Jonathan Oliver EventStore library together with RavenDB

Here is an example of a generic way of replaying all events, where all View Models stored in RavenDB implements an IViewModel interface. If you would have your IViewModel implementations in a different assembly from where the interface is, you will need to change the GetAssembly()-call to the correct one.

public void ReplayAllEvents() {
    Type viewModelInterface = typeof(IViewModel);
    Assembly viewModelAsm = Assembly.GetAssembly(viewModelInterface);

    // Delete all View Models
    using( var session = _readRep.OpenSession() ) {
        MethodInfo miQ = session.GetType().GetMethods().Where( mi => mi.Name == "Query" && mi.GetParameters().Length == 0 && mi.GetGenericArguments().Length == 1 ).Single();
        MethodInfo miDel = session.GetType().GetMethod("Delete");

        foreach( Type type in viewModelAsm.GetTypes().Where(t => viewModelInterface.IsAssignableFrom(t)) ) {

          foreach( var m in (IQueryable)miQ.MakeGenericMethod(new Type[] { type }).Invoke(session, null) ) {
            miDel.MakeGenericMethod(new Type[] { type }).Invoke(session, new []{ m });
          }
        }

        session.SaveChanges();
    }

    // Make sure the read model doesn't return stale results
    _readRep.RegisterListener(new NoStaleQueriesListener());

    // Dispatch all events again
    foreach( var commit in _eventStore.Advanced.GetFrom(DateTime.MinValue) ) {
        ServiceLocator.Bus.Dispatch(commit);
    }

}

 

Implicit Dynamics CRM data-type conversion

by Daniel Halan 24. June 2010 00:29

When working with Microsoft CRM data-types using web services there is no constructor parameters due to limitations of the WSDL code generation. This leads to few lines of code each time one want to create a variable of any CRM type.

This can be optimized using a Factory class where you encapsle the creation of the desired class. But one even cleaner way is to create a partial class and define "implicit" operators between CRM data-type and .NET data-type.

Here is an example on how it works.

Standard way of assigning a .NET DateTime to CRM DateTime,

CrmDateTime cdt = new CrmDateTime();
cdt.Value = DateTime.Today.ToString("s");

Using implicit declaration,

CrmDateTime cdt = DateTime.Now;

and back,

DateTime dt = cdt;

The code behind this,

public partial class CrmDateTime {

  public CrmDateTime(DateTime dt) {
    this.Value = dt.ToString("s");
  }
  public static implicit operator CrmDateTime(DateTime dt) {
     return new CrmDateTime (dt);
  }
  public static implicit operator DateTime(CrmDateTime dt) {
     return DateTime.Parse(dt.Value);
  }
}

Tags: ,

.NET | CRM

Microsoft Word Add-in for CRM Configuration Manager

by Daniel Halan 19. May 2010 05:43
Here comes a requested add-in for ouputting all your Microsoft CRM Customizations to a Word document.

This add-in can be used for various scenarios,

Documentation

  • Document your work after it's finished, removing any possible mismatch from the specifications.
  • Understand the work of others when taking ownership of a CRM instance without any documentations provided (Using the filters to export only Custom Entities, Attributes and Relationships)
  • Presents all your ISV Configuration changes in one place, that usually are hard to get a good overview of.

Daily work routines

  • Development Aid, use a complete export document as a reference.
    By searching in the document for a specific entity you can quickly see available picklist values, implemented javascript, published attributes on form and attributes schema name including data type restrictions.
  • Architect Aid, Cut & Paste attribute, forms or relationships Tables to your specifications, and extend them with new values or describe changes.

The Add-in supports multi-language CRM installations, you select the prefered output language, and the base language will be used as fallback. You can also define to only export custom entities, attributes and relationsships making the document easier to read.

The document can contain following chapters,

  • Organisation Settings
    Configurations set for the selected organisation (tenant) i e Schema Name Prefix..
  • ISV Configuration
    All custom Menues, Navigation Items, Toolbar Buttons and Renamed titles
  • Workflows
  • Security Roles
  • Entities


Checkout sample document,
CCM Word Sample.docx (41,74 kb)

Only $99

Buy Now

Free version upgrades

Requirements
Docx File Format Viewer
Microsoft .NET Framework 3.5 or newer

CRM Configuration Manager v1.50

by Daniel Halan 19. May 2010 04:16

First of all, I would like to thank for all the positive response regarding CRM Configuration Manager, always a joy to hear that the product works :)

Here comes a new release of CRM Configuration Manager that contains some improvements and a new Extension Framework for creating Add-ins. The first extension interface available is for output handling. You can now implement a new document type handler for exporting. Could be used for various documentation formats, for example an Visio document handler, that would create a data model of the exported entities and their relationships.

A SDK will be released in the near future, but until then you can contact me for guidance.

Improvements and bugfixes included in version 1.50,

  • Improved 'Export only Modifications' function, now also checking modifications at Entity Forms and Relationships
  • Not all system entities was listed in the Entity view.
    Thanks to Daniel Jansen for reporting the issue.
  • Implemented Add-in framework for output document formats. 
  • Revised user interface to improve usability
  • Minor bug fixes

Complete list of features

CcmSetup1.55.exe (966,81 kb)

Also released an output Add-in for Microsoft Word document format,
read more about it here.

Happy Customization!

 

Blog3ngine dot NET 1.6.1.2
Theme by Daniel Halan

About the author

Daniel Halan Daniel Halan, M.Sc. systems architect from Sweden, currently in Bangkok.

Working primary with Microsoft .NET, Azure, DDD, CQRS and some Dynamics CRM  Read more...

The content of this site are my own personal opinions and do not represent my employer's view in anyway.


Follow Me
@UdiDahan Can agree with that from own experience, two years now and it just gets better :) 01 Feb 2013