Creating MOM Product Connectors


The MOM Connector Framework (MCF) is really just a NET Framework class library. The MCF consists of the Microsoft.EnterpriseManagement.MomConnector as well as the Microsoft.EnterpriseManagement MomConnector.V2 namespaces. Microsoft.EnterpriseManagment.MomConnector is provided for backward compatibility with product connectors that were built with MOM 2000 SP1. The MCF comes in two "flavors" — a regular class library and a Web Service. With the MCF, you can develop connectors between MOM and various other management products. See the following code for an example.

The advantages of using the MCF to build a MOM connector include:

  • Support for connector applications running on non-Windows platforms through the MCF Web Service

  • A consistent, reusable framework for developing connector applications

  • Increased performance compared to other methods of querying alert data

  • Access to an alert's Product Knowledge content

     namespace Microsoft.Samples.MomSdk.MomSdkConnector     {         using Microsoft.EnterpriseManagement.Mom.Connector;         using System;         using System.Diagnostics;         using System.Resources;         using System.Data;         /// <summary>         /// Class to handle the conversion of MOM Alert objects to         /// a trouble ticket data structure which is compatible with         /// trouble tickets in another system.         /// </summary>         public class TroubleTicketMapper         {             private ResourceManager resources;             private const int MinTicketID = 0001;             private const int MaxTicketID = 9999;             /// <summary>             /// Constructor for the TroubleTicketMapper class.             /// </summary>             public TroubleTicketMapper()             {                 this.resources = new     ResourceManager("Microsoft.Samples.MomSdk.MomSdkConnector.Messages", this.GetType().Assembly);             }             /// <summary>             /// Converts an MCF Alert object to a row of trouble ticket values.             /// </summary>             /// <param name="mcfAlert">The MCF Alert</param>             /// <param name="newTicketRow">Row to store the ticket data</param>             public void MakeNewTicketFromAlert(Alert mcfAlert, DataRow newTicketRow)             {                 newTicketRow["ID"] = this.MakeTicketID();                 newTicketRow["SourceAlert"] = mcfAlert.AlertId;                 if (null == mcfAlert.Name)                 {                     newTicketRow["Name"] = "";                 }                 else                 {                      newTicketRow["Name"] = mcfAlert.Name;                 }                 if (null == mcfAlert.Description)                 {                     newTicketRow["Description"] = "";                 }                 else                 {                     newTicketRow["Description"] = mcfAlert.Description;                 }                 if (null == mcfAlert.ComputerDomain)                 {                     newTicketRow["Computer"] = "";                     if (null == mcfAlert.ComputerName)                     {                         newTicketRow["Computer"] = "";                     }                     newTicketRow["Computer"] = mcfAlert.ComputerDomain + @"\" + mcfAlert.ComputerName;                 }                 if (null == mcfAlert.OwnerName)                 {                     newTicketRow["AssignedTo"] = "";                 }                 else                 {                     newTicketRow["AssignedTo"] = mcfAlert.OwnerName;                 }                 newTicketRow["Opened"] = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();                 string statusName = "";                 statusName = GetStatusNameFromID(mcfAlert.ResolutionState);                 newTicketRow["Status"] = statusName;                 newTicketRow["Closed"] = "";             }             /// <summary>             /// Converts an MCF Alert object to a trouble dicket data row.             /// </summary>             /// <param name="mcfAlert">The MCF alert</param>             /// <param name="ticketRow">Row containing the ticket data</param>             public void MakeTicketFromAlert(Alert mcfAlert, DataRow ticketRow)             {                 if (null == mcfAlert.Name)                 {                     ticketRow["Name"] = "";                 }                 else                 {                     ticketRow["Name"] = mcfAlert.Name;                 }                 if (null == mcfAlert.Description)                 {                     ticketRow["Description"] = "";                 }                 else                 {                     ticketRow["Description"] = mcfAlert.Description;                 }                 if (null == mcfAlert.OwnerName)                 {                     ticketRow["AssignedTo"] = "";                 }                 else                 {                     ticketRow["AssignedTo"] = mcfAlert.OwnerName;                 }                 string statusName = "";                 statusName = GetStatusNameFromID(mcfAlert.ResolutionState);                 ticketRow["Status"] = statusName;             }             /// <summary>             /// Converts a trouble ticket data row to a MOM alert update.             /// </summary>             /// <param name="ticketRow">Row containing the ticket data</param>             /// <returns>New MCF AlertUpdate object</returns>             public AlertUpdate MakeAlertUpdateFromTicket(DataRow ticketRow)             {                 AlertUpdate mcfAlertUpdate = new AlertUpdate();                 mcfAlertUpdate.AlertId = new Guid(ticketRow["SourceAlert"].ToString());                 mcfAlertUpdate.CustomField1UseExisting = true;                 mcfAlertUpdate.CustomField2UseExisting = true;                 mcfAlertUpdate.CustomField3UseExisting = true;                 mcfAlertUpdate.CustomField4UseExisting = true;                 mcfAlertUpdate.CustomField5UseExisting = true;                 mcfAlertUpdate.RepeatCountUseExisting = true;             if (null == ticketRow["AssignedTo"])                 {                     mcfAlertUpdate.OwnerNameExisting = false;                     mcfAlertUpdate.OwnerName = "";                 }                 else                 {                     mcfAlertUpdate.OwnerNameExisting = false;                     mcfAlertUpdate.OwnerName = ticketRow["AssignedTo"].ToString();                 }                 mcfAlertUpdate.ResolutionState = GetIDFromStatusName(ticketRow["Status"].ToString());                 mcfAlertUpdate.ResolutionStateUseExisting = false;                 return mcfAlertUpdate;             }             /// <summary>             /// Maps the MOM resolution state to trouble ticket status.             /// </summary>             /// <param name="id">MOM Alert's resolution state</param>             /// <returns>Trouble ticket status text</returns>             private static string GetStatusNameFromID(byte id)         {             string name = "New"; switch (id)             {                 case 0:                     name = "New";                     break;                 case 85:                     name = "Acknowledged";                     break;                 case 170:                     name = "Level 1: Assigned to a help desk or local support";                     break;                 case 180:                     name = "Level 2: Assigned to a subject matter expert";                     break;                 case 190:                 name = "Level 3: Requires scheduled maintenance";                 break;             case 200:                 name = "Level 4: Assigned to an external group or vendor";                 break;             case 255:                 name = "Resolved";                 break;             }             return name;             /// <summary>             /// Gets a numerical resolution state ID from the state name.             /// </summary>             /// <param name="name">Resolution state name</param>             /// <returns>State ID</returns>             private static byte GetIDFromStatusName(string name)             {                 byte stateId = byte.Parse("0");                 switch (name)                 {                     case "New":                         stateId = 0;                         break;                     case "Acknowledged":                         stateId = 85;                         break;                     case "Level 1: Assigned to a help desk or local support":                         stateId = 170;                         break;                     case "Level 2: Assigned to a subject matter expert":                         stateId = 180;                         break;                     case "Level 3: Requires scheduled maintenance":                         stateId = 190;                         break;                     case "Level 4: Assigned to an external group or vendor":                         stateId = 200;                         break;                     case "Resolved":                         stateId = 255;                         break;                 }                 return stateId;             }             /// <summary>             /// Generates an ID for the trouble ticket.             /// </summary>             /// <returns>New ticket ID</returns>             private Guid MakeTicketID()             {                 return Guid.NewGuid();             }         }     } 



Professional MOM 2005, SMS 2003, and WSUS
Professional MOM 2005, SMS 2003, and WSUS
ISBN: 0764589636
EAN: 2147483647
Year: 2006
Pages: 132

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net