Esempio n. 1
0
        public void SetAttributeValue()
        {
            InstanceHandle keyClass         = oms.GetInstance(KnownInstanceGuids.Classes.Class);
            InstanceHandle keyAttributeName = oms.GetInstance(KnownAttributeGuids.Text.Name);

            oms.BeginTransaction();

            oms.SetAttributeValue(keyClass, keyAttributeName, SAV_TEST_VALUE);

            oms.CommitTransaction();

            string value = oms.GetAttributeValue <string>(keyClass, keyAttributeName);

            Assert.AreEqual(SAV_TEST_VALUE, value);
        }
Esempio n. 2
0
        private static void Initialize(this Oms oms, MochaClassLibraryObjectModel mcl)
        {
            oms.BeginTransaction();

            for (int i = 0; i < mcl.Libraries.Count; i++)
            {
                for (int j = 0; j < mcl.Libraries[i].Instances.Count; j++)
                {
                    oms.CreateInstance(mcl.Libraries[i].Instances[j].ID, Guid.Empty);
                }
            }

            oms.CommitTransaction();

            oms.BeginTransaction();
            for (int i = 0; i < mcl.Libraries.Count; i++)
            {
                for (int j = 0; j < mcl.Libraries[i].Instances.Count; j++)
                {
                    for (int k = 0; k < mcl.Libraries[i].Instances[j].AttributeValues.Count; k++)
                    {
                        oms.SetAttributeValue(oms.GetInstance(mcl.Libraries[i].Instances[j].ID), oms.GetInstance(mcl.Libraries[i].Instances[j].AttributeValues[k].AttributeInstanceID), mcl.Libraries[i].Instances[j].AttributeValues[k].Value);
                    }
                }
                for (int j = 0; j < mcl.Libraries[i].Relationships.Count; j++)
                {
                    Guid[] ids = new Guid[mcl.Libraries[i].Relationships[j].DestinationInstanceIDs.Count];
                    for (int k = 0; k < mcl.Libraries[i].Relationships[j].DestinationInstanceIDs.Count; k++)
                    {
                        ids[k] = mcl.Libraries[i].Relationships[j].DestinationInstanceIDs[k];
                    }
                    oms.CreateRelationship(oms.GetInstance(mcl.Libraries[i].Relationships[j].SourceInstanceID), oms.GetInstance(mcl.Libraries[i].Relationships[j].RelationshipInstanceID), GuidsToInstances(oms, ids));
                }
            }
            oms.CommitTransaction();

            oms.BeginTransaction();


            // create the Class::Instance.has parent Class relationship
            oms.CreateRelationship(oms.GetInstance(KnownInstanceGuids.Classes.Class), oms.GetInstance(KnownRelationshipGuids.Class__has__Instance), oms.GetInstance(KnownInstanceGuids.Classes.Class));
            oms.CreateRelationship(oms.GetInstance(KnownInstanceGuids.Classes.Class), oms.GetInstance(KnownRelationshipGuids.Instance__for__Class), oms.GetInstance(KnownInstanceGuids.Classes.Class));

            oms.CommitTransaction();
        }
Esempio n. 3
0
 private static void LoadMCXOperation(this Oms oms, MochaSnapshotTransactionOperation op)
 {
     if (op is MochaSnapshotAssignAttributeTransactionOperation aa)
     {
         oms.SetAttributeValue(oms.GetInstance(aa.SourceInstanceID), oms.GetInstance(aa.AttributeInstanceID), aa.EffectiveDate, aa.Value);
     }
     else if (op is MochaSnapshotAssociateRelationshipTransactionOperation ar)
     {
         List <InstanceHandle> targetInstances = new List <InstanceHandle>();
         foreach (Guid id in ar.TargetInstanceIDs)
         {
             targetInstances.Add(oms.GetInstance(id));
         }
         oms.CreateRelationship(oms.GetInstance(ar.SourceInstanceID), oms.GetInstance(ar.RelationshipInstanceID), targetInstances.ToArray(), ar.EffectiveDate);
     }
     else if (op is MochaSnapshotCreateInstanceTransactionOperation ci)
     {
         oms.CreateInstance(ci.GlobalIdentifier, ci.ClassGlobalIdentifier);
     }
 }