public static AcmaCSEntryChange ImportFromXml(XElement element, bool throwOnMissingAttribute)
        {
            AcmaCSEntryChange csentry = new AcmaCSEntryChange();

            CSEntryChangeXmlImport.ImportFromXml(element, csentry, throwOnMissingAttribute);
            return(csentry);
        }
Example #2
0
        public static AcmaCSEntryChange FromCSEntryChange(CSEntryChange csentry)
        {
            AcmaCSEntryChange obj = new AcmaCSEntryChange();

            AcmaCSEntryChange.CloneCSEntryChange(csentry, obj);

            return(obj);
        }
        /// <summary>
        /// Creates a CSEntryChange of the specified modification type for the supplied MAObjectHologram
        /// </summary>
        /// <param name="maObject">The MAObjectHologram to create the CSEntryChange from</param>
        /// <param name="objectModificationType">The object modification type to apply</param>
        /// <returns>A new CSEntryChange object representing the current state of the specified MAObjectHologram </returns>
        public static AcmaCSEntryChange CreateCSEntryChangeFromMAObjectHologram(this MAObjectHologram maObject, ObjectModificationType objectModificationType)
        {
            AcmaCSEntryChange csentry = new AcmaCSEntryChange();

            csentry.ObjectModificationType = objectModificationType;
            csentry.DN         = maObject.ObjectID.ToString();
            csentry.ObjectType = maObject.ObjectClass.Name;

            if (objectModificationType != ObjectModificationType.Delete)
            {
                AttributeModificationType attributeModificationType = objectModificationType == ObjectModificationType.Update ? AttributeModificationType.Replace : AttributeModificationType.Add;

                foreach (AcmaSchemaAttribute attribute in maObject.ObjectClass.Attributes.Where(t => t.Name != "objectId" && t.Name != "objectClass"))
                {
                    AttributeValues values = maObject.GetAttributeValues(attribute);

                    if (values.IsEmptyOrNull)
                    {
                        continue;
                    }

                    if (attributeModificationType == AttributeModificationType.Add)
                    {
                        AttributeChange change = AttributeChange.CreateAttributeAdd(attribute.Name, values.ToObjectList());
                        csentry.AttributeChanges.Add(AttributeChange.CreateAttributeAdd(attribute.Name, values.ToObjectList()));
                    }
                    else
                    {
                        csentry.AttributeChanges.Add(AttributeChange.CreateAttributeReplace(attribute.Name, values.ToObjectList()));
                    }
                }
            }

            if (csentry.ErrorCodeImport == MAImportError.Success)
            {
                MAStatistics.AddImportOperation();
            }
            else
            {
                MAStatistics.AddImportError();
            }

            return(csentry);
        }
Example #4
0
        private static void CloneCSEntryChange(CSEntryChange csentry, AcmaCSEntryChange acmaCSEntry)
        {
            acmaCSEntry.DN = csentry.DN;
            acmaCSEntry.ErrorCodeImport        = csentry.ErrorCodeImport;
            acmaCSEntry.ErrorDetail            = csentry.ErrorDetail;
            acmaCSEntry.ErrorName              = csentry.ErrorName;
            acmaCSEntry.ObjectModificationType = csentry.ObjectModificationType;
            acmaCSEntry.ObjectType             = csentry.ObjectType;

            foreach (var item in csentry.AnchorAttributes)
            {
                acmaCSEntry.AnchorAttributes.Add(item);
            }

            foreach (var item in csentry.AttributeChanges)
            {
                acmaCSEntry.AttributeChanges.Add(item);
            }
        }
Example #5
0
 public AcmaCSEntryChange(CSEntryChange csentry)
     : this()
 {
     AcmaCSEntryChange.CloneCSEntryChange(csentry, this);
 }