I saw the question of how to provision a new object into a SQL MA using MIIS, so I thought I’d just post a simple method I use often.

It’s called ProvDB and can be added to the Metaverse Extension to be called based upon business logic.

I have a standard Correlation ID (CID) that ties data objects together, so this is what is used to provision the object into the DataSource.  Once the Object is provisioned with this CID, the MA join logic will handle all other data flows.  This makes its simplistic since the CID is the anchor for the MA as well.

Here is the standard method of ProvDB:

 void ProvDB(MVEntry mventry, string DBMA)
        {
            ConnectedMA ManagementAgent;    // Management agent object
            int Connectors;                 // Management agent connectors
            CSEntry csentry;                // Connector space entry objectt agent connectors
            
            // Get the management agent connectors

            ManagementAgent = mventry.ConnectedMAs[DBMA];

            // Get the management agent connectors.
            Connectors = ManagementAgent.Connectors.Count;

            // determine if this object may have a connector with this MA already.
            if (Connectors == 0)
            {


                try
                {

                   
                    csentry = ManagementAgent.Connectors.StartNewConnector("Person");
                    csentry["CID"].Value = mventry["CID"].Value;
                    
                    csentry.CommitNewConnector();

                }
                catch (ObjectAlreadyExistsException exAlreadyExists)
                {
                    string ExceptionMessage = null;
                    
		// throw exception if you want to alert on duplicates, or just catch to let join rules resolve
		ExceptionMessage = "Duplicate User - in " + DBMA;
                  throw new UnexpectedDataException(ExceptionMessage);


                }

                catch (NullReferenceException exNull)
                {
                    string ExceptionMessage = null;
                    ExceptionMessage = "Null Reference Exception in " + DBMA;
                    throw new UnexpectedDataException(ExceptionMessage);

                }

            }
            else
            {
                // Do nothing.  Object may already have a connection.
            }
        }

So you could use a simple routine to determine if the object should be provisioned into the correct MA-CS.

If (mventry["employeeType").IsPresent && mventry["employeeType"].Value == "CONTRACTOR") 
{ 
	// Provision into Contractor system
	ProvDB(mventry, "ContractorDB")
}

So you can reuse this to provision objects based on the CID into different DBs since the provision ADD is handled by the MA interface.

 

[Edit: I had left in code referencing DN concatination for a DB.   I removed this, since it is confusing.  It was from an assumption I had that later turned out to be wrong. ]

 tags: , ,

Advertisements