Gary Davidson, the Chief Software Architect at Interclick, has created a new SCSM CodePlex project called SCSM Façade.  The intention of the SCSM Façade project is to make programming against the SCSM SDK a little less abstract.  Because SCSM is a configuration driven platform all of the APIs are abstract.  For example – we don’t have a GetIncidents() method.  We only have a GetObjectReader() method which gets you objects that match the criteria you specify.  The criteria is what tells SCSM to return incidents instead of change requests.  So – in pseudocode you do something like this Incidents = GetObjectReader(Incident) instead of Incidents = GetIncidents().

The SCSM Façade CodePlex project tries to obscure some of the complexity of dealing with abstract APIs by exposing more concrete APIs.  This is a great example from Gary’s blog.

This is an example of how to write the code using the SCSM SDK APIs to get an incident by ID:

EnterpriseManagementGroup emg = new EnterpriseManagementGroup(Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\System Center\2010\Service Manager\Console\User Settings",

"SDKServiceMachine", "localhost").ToString());

// what guid is it?

ManagementPackTypeProjection typeProjection = emg.EntityTypes.GetTypeProjection(new Guid("285CB0A2-F276-BCCB-563E-BB721DF7CDEC"));

// try remembering all this

var criteriaXml = "<Criteria xmlns=\"http://Microsoft.EnterpriseManagement.Core.Criteria/\"> <Reference Id=\"System.WorkItem.Incident.Library\" Version=\"7.0.6555.0\" PublicKeyToken=\"31bf3856ad364e35\" Alias=\"IncidentMP\" /><Expression><SimpleExpression><ValueExpressionLeft><Property>$Target/Property[Type='IncidentMP!System.WorkItem.Incident']/Id/Property></ValueExpressionLeft><Operator>Equal</Operator><ValueExpressionRight><Value>IR201</Value></ValueExpressionRight></SimpleExpression></Expression></Criteria>";

ObjectProjectionCriteria criteria = new ObjectProjectionCriteria(criteriaXml, typeProjection, emg);

var incidentProjection = emg.EntityObjects.GetObjectProjectionReader<EnterpriseManagementObject>(criteria, ObjectQueryOptions.Default);

With SCSM Façade you just need to do this:

var incidentProjection = SCSMIncident.GetIncident("IR201");

Nice!

Thanks for starting up this project Gary!  Anyone who would like to contribute to the project can contact me or Gary via the CodePlex site.

http://scsmfacade.codeplex.com/