public int AddTerm(TermStore termStore)
 {
     if (_terms == null)
         _terms = new List<TermStore>();
     if (termStore != null)
         _terms.Add(termStore);
     return _terms.Count;
 }
示例#2
0
 public static TermStore CreateStore(string termName, Guid managedItemID)
 {
     TermStore termStore = new TermStore(termName, TermType.PlaceHolderAttachments);
     DataTable dtDocuments = Business.ManagedItem.GetManagedItemDocuments(managedItemID);
     if (dtDocuments.Rows.Count > 0)
     {
         foreach (DataRow drDocument in dtDocuments.Rows)
         {
             if (!(bool)drDocument[Data.DataNames._C_Deleted])
                 termStore.AddMultiValue(drDocument[Data.DataNames._C_DocumentName].ToString());
         }
     }
     return termStore;
 }
        public static TermStore CreateStore(string termName, XmlReader reader)
        {
            using (reader)
            {
                reader.Read();

                TermStore termStore = new TermStore(termName, TermType.Renewal);
                DisplayedDate displayedDateType = (DisplayedDate)Enum.Parse(typeof(DisplayedDate), reader.GetAttribute(XMLNames._A_DisplayedDate));

                bool effectiveDateProcessed = false;
                bool expirationDateProcessed = false;

                string value = string.Empty;

                reader.Read();

                ReadPastSubTree(reader, XMLNames._E_validateOn);

                int loopCount = 0;
                while (!(effectiveDateProcessed && expirationDateProcessed))
                {
                    if (loopCount++ > TermStore.maxLoopCount)
                    {
                        throw new Exception(string.Format("CreateStore stopped at loopCount {0:D} for Renewal term '{1}'", loopCount, termName));
                    }
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            switch (reader.Name)
                            {
                                case XMLNames._E_EffectiveDate:
                                    value = Utility.XMLHelper.SafeReadElementString(reader);
                                    if (displayedDateType == DisplayedDate.EffectiveDate)
                                    {
                                        termStore.AddMultiValue(value);
                                        expirationDateProcessed = true;
                                    }
                                    effectiveDateProcessed = true;
                                    break;

                                case XMLNames._E_ExpirationDate:
                                    value = Utility.XMLHelper.SafeReadElementString(reader);
                                    if (displayedDateType == DisplayedDate.ExpirationDate)
                                    {
                                        termStore.AddMultiValue(value);
                                        effectiveDateProcessed = true;
                                    }
                                    expirationDateProcessed = true;
                                    break;

                                default:
                                    reader.Read();
                                    break;
                            }
                            break;

                        default:
                            reader.Read();
                            break;
                    }
                }
                return termStore;
            }
        }
示例#4
0
        public static TermStore CreateStore(string termName, XmlReader reader)
        {
            using (reader)
            {
                reader.Read();
                TermStore termStore = new TermStore(reader.GetAttribute(XMLNames._A_Name), TermType.MSO);
                Dictionary<string, string> item = new Dictionary<string, string>();

                item.Add(_MSO_FieldName, reader.GetAttribute(XMLNames._A_MSOValue));
                item.Add(_MSO_Address1FieldName, reader.GetAttribute(XMLNames._A_Address1Value));
                item.Add(_MSO_Address2FieldName, reader.GetAttribute(XMLNames._A_Address2Value));
                item.Add(_MSO_CityFieldName, reader.GetAttribute(XMLNames._A_CityValue));
                item.Add(_MSO_StateFieldName, reader.GetAttribute(XMLNames._A_StateValue));
                item.Add(_MSO_ZipFieldName, reader.GetAttribute(XMLNames._A_ZipValue));
                item.Add(_MSO_PhoneFieldName, reader.GetAttribute(XMLNames._A_PhoneValue));
                termStore.AddFieldValue(item);

                return termStore;
            }
        }
        public static TermStore CreateStore(string termName, XmlReader reader)
        {
            using (reader)
            {
                TermStore termStore = new TermStore(termName, TermType.Facility);
                bool termProcessed = false;
                bool abort = false;
                reader.Read();
                reader.Read();

                int loopCount = 0;

                ReadPastSubTree(reader, XMLNames._E_validateOn);

                while (!abort && !termProcessed)
                {
                    if (loopCount++ > TermStore.maxLoopCount)
                    {
                        throw new Exception(string.Format("CreateStore stopped at loopCount {0:D} for Facility term '{1}'", loopCount, termName));
                    }
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.EndElement:
                            abort = true;
                            break;

                        case XmlNodeType.Element:
                            switch (reader.Name)
                            {
                                case XMLNames._E_FacilityTypes:
                                case XMLNames._E_OwningFacilityIDs:
                                    reader.Skip();
                                    break;

                                case XMLNames._E_SelectedFacilityIDs:
                                    using (XmlReader facilityReader = reader.ReadSubtree())
                                    {
                                        while (facilityReader.Read())
                                        {
                                            switch (facilityReader.NodeType)
                                            {
                                                case XmlNodeType.Element:
                                                    switch (facilityReader.Name)
                                                    {
                                                        case XMLNames._E_FacilityID:
                                                            termStore.AddMultiValue(facilityReader.GetAttribute(XMLNames._A_ID));
                                                            break;

                                                        default:
                                                            break;
                                                    }
                                                    break;

                                                default:
                                                    break;
                                            }
                                        }
                                    }
                                    termProcessed = true;
                                    break;

                                default:
                                    //reader.Read();
                                    break;
                            }
                            break;

                        default:
                            break;
                    }
                }
                return termStore;
            }
        }
        public static TermStore CreateStore(string termName, XmlReader reader)
        {
            using (reader)
            {
                TermStore termStore = new TermStore(termName, TermType.PickList);
                bool abort = false;
                reader.Read();
                reader.Read();

                ReadPastSubTree(reader, XMLNames._E_validateOn);

                int loopCount = 0;
                while (!abort)
                {
                    if (loopCount++ > TermStore.maxLoopCount)
                    {
                        throw new Exception(string.Format("CreateStore stopped at loopCount {0:D} for PickList term '{1}'", loopCount, termName));
                    }
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.EndElement:
                            abort = true;
                            break;

                        case XmlNodeType.Element:
                            switch (reader.Name)
                            {
                                case XMLNames._E_ListItem:
                                    string selected = reader.GetAttribute(XMLNames._A_Selected);
                                    string value = Utility.XMLHelper.SafeReadElementString(reader);
                                    if (selected.Equals("True", StringComparison.OrdinalIgnoreCase))
                                    {
                                        termStore.AddMultiValue(value);
                                    }
                                    break;

                                default:
                                    reader.Read();
                                    break;
                            }
                            break;

                        default:
                            reader.Read();
                            break;
                    }
                }
                return termStore;
            }
        }
示例#7
0
        public override string IsValid(TermStore termStore)
        {
            string error = base.IsValid(termStore);

            if (!string.IsNullOrEmpty(error))
                return error;

            if (Max.HasValue)
                (termStore as TextTermStore).Length = Max.Value;

            return string.Empty;
        }
        public static TermStore CreateStore(string termName, XmlReader reader, List<string> templateFieldNames)
        {
            TermStore termStore = new TermStore(termName, TermType.ComplexList);
            bool abort = false;

            int outerLoopCount1 = 0;

            //First need to parse out the Fields collection for this ManagedItem Complex List.
            Dictionary<Guid, string> allFieldNames = new Dictionary<Guid, string>();

            using (reader)
            {
                while (!abort)
                {
                    if (outerLoopCount1++ > TermStore.maxLoopCount)
                    {
                        throw new Exception(string.Format("Complex List CreateStore stopped at outerLoopCount1 {0:D} for termName '{1}'", outerLoopCount1, termName));
                    }
                    if (reader.NodeType == XmlNodeType.Element && reader.Name == XMLNames._E_Fields)
                    {
                        int innerLoopCount1 = 0;
                        while (reader.Read() && !abort)
                        {
                            if (innerLoopCount1++ > TermStore.maxLoopCount)
                            {
                                throw new Exception(string.Format("Complex List CreateStore stopped at innerLoopCount1 {0:D} for termName '{1}'", innerLoopCount1, termName));
                            }
                            if (reader.NodeType == XmlNodeType.Element && reader.Name == XMLNames._E_Field)
                            {
                                //NOTE - Allow for some ComplexLists that do not have FieldID's assigned...
                                try
                                {
                                    allFieldNames.Add(new Guid(reader.GetAttribute(XMLNames._A_ID)), reader.GetAttribute(XMLNames._A_Name));
                                }
                                catch
                                {
                                    abort = true;
                                }
                            }
                            if (reader.NodeType == XmlNodeType.EndElement && reader.Name == XMLNames._E_Fields)
                            {
                                abort = true;
                            }
                        }
                    }
                    else
                    {
                        abort = !reader.Read();
                    }
                }

                if (allFieldNames.Count > 0)
                {
                    //Create a new collection of the Complex List fields that are in common with the ones found in the Template.
                    Dictionary<Guid, string> matchedFieldNames = new Dictionary<Guid, string>();
                    foreach (string templateFieldName in templateFieldNames)
                    {
                        if (allFieldNames.ContainsValue(templateFieldName))
                        {
                            foreach (KeyValuePair<Guid, string> kvp in allFieldNames)
                            {
                                if (kvp.Value == templateFieldName)
                                {
                                    matchedFieldNames.Add(kvp.Key, kvp.Value);
                                    break;
                                }
                            }
                        }
                    }

                    abort = false;
                    //Now we need to parse out the Items collection.
                    int outerLoopCount2 = 0;
                    while (!abort)
                    {
                        if (outerLoopCount2++ > TermStore.maxLoopCount)
                        {
                            throw new Exception(string.Format("Complex List CreateStore stopped at outerLoopCount2 {0:D} for termName '{1}'", outerLoopCount2, termName));
                        }
                        if (reader.NodeType == XmlNodeType.Element && reader.Name == XMLNames._E_Items)
                        {
                            int innerLoopCount2 = 0;
                            while (reader.Read() && !abort)
                            {
                                if (innerLoopCount2++ > TermStore.maxLoopCount)
                                {
                                    throw new Exception(string.Format("Complex List CreateStore stopped at innerLoopCount2 {0:D} for termName '{1}'", innerLoopCount2, termName));
                                }
                                if (reader.NodeType == XmlNodeType.Element && reader.Name == XMLNames._E_Item)
                                {
                                    Dictionary<string, string> item = ComplexListItem.CreateComplexListItemStore(reader.ReadSubtree(), matchedFieldNames);
                                    if (item != null)
                                        termStore.AddFieldValue(item);
                                }
                                if (reader.NodeType == XmlNodeType.EndElement && reader.Name == XMLNames._E_Items)
                                {
                                    abort = true;
                                }
                            }
                        }
                        else
                        {
                            abort = !reader.Read();
                        }
                    }
                }
            }
            return termStore;
        }
        public static TermStore CreateStore(string termName, ExternalTerm externalTerm, Guid managedItemID)
        {
            if (externalTerm == null)
                throw new Exception(string.Format("External Term named '{0}' not found within the template", termName));

            TermStore termStore = new TermStore(termName, TermType.External);
            DataTable dt = Data.ExternalTerm.GetValues(managedItemID, externalTerm._interfaceConfig.Name);
            string previousKeyValue = string.Empty;
            Dictionary<string, string> item = new Dictionary<string, string>();

            for (int index = 0; index < dt.Rows.Count; index++)
            {
                DataRow dr = dt.Rows[index];
                string keyValue = (string)dr[Data.DataNames._C_KeyValue];
                if (index == 0)
                    previousKeyValue = keyValue;
                if (!item.ContainsKey((string)dr[1]))
                    item.Add((string)dr[1], (string)dr[2]);
                if (index == dt.Rows.Count - 1)
                    termStore.AddFieldValue(item);
                else
                {
                    if (keyValue != previousKeyValue)
                    {
                        termStore.AddFieldValue(item);
                        previousKeyValue = keyValue;
                        item = new Dictionary<string, string>();
                        item.Add((string)dr[1], (string)dr[2]);
                    }
                }
            }

            return termStore;
        }