示例#1
0
        private void CheckNUpdateMetadataCategory(string metadataXml)
        {
            string CategoryName = string.Empty;
            string CategoryValue = string.Empty;
            XmlDocument XmlDoc = new XmlDocument();
            MetadataCategoryBuilder MDCatBuilder;
            MetadataCategoryInfo MDCatInfo;
            XmlDoc.LoadXml(metadataXml);

            try
            {

                MDCatBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                XmlNodeList XmlList = XmlDoc.SelectNodes(METADATA_CATEGORYTAG);

                for (int i = 0; i < XmlList.Count; i++)
                {
                    CategoryName = XmlList[i].Attributes["name"].Value;

                    MDCatInfo = MDCatBuilder.GetMetadataCategoryInfo(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(CategoryName) + "'");

                    MDCatBuilder.CheckNCreateMetadataCategory(MDCatInfo);

                }

            }
            catch (Exception)
            {
            }
        }
示例#2
0
        private string GetElementMetadata(MetaDataType elementType, string elementGId, int elementNId, DIExcel diExcel, int startRowIndex)
        {
            string RetVal = string.Empty;
            MetadataCategoryBuilder MDCatBuilder;
            MetadataCategoryInfo MDCatInfo;
            XmlDocument MetadataXmlDoc = new XmlDocument();
            XmlElement CategoryNode;
            XmlElement ParaNode;
            XmlText CategoryText;
            string Category = string.Empty;
            string CategoryValue = string.Empty;
            string ElementMetadataXml = string.Empty;
            int CategoryNId = 0;

            //-- Get Metadata Info for Element
            ElementMetadataXml = this.GetElementInfo(elementType, elementGId);

            if (string.IsNullOrEmpty(ElementMetadataXml))
            {
                MetadataConverter.InsertRootNode(MetadataXmlDoc);
            }
            else
            {
                MetadataXmlDoc.LoadXml(ElementMetadataXml);
            }

            MDCatBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);

            //foreach (IRange Row in DiExcel.GetUsedRange(0).Rows )
            for (int Index = startRowIndex; Index < diExcel.GetUsedRange(0).Rows.RowCount; Index++)
            {
                Category = Convert.ToString(diExcel.GetUsedRange(0).Rows[Index, 0].Value);
                CategoryValue = Convert.ToString(diExcel.GetUsedRange(0).Rows[Index, 1].Value);

                if (!string.IsNullOrEmpty(Category))
                {
                    //-- Get Metadata CategoryInfo
                    MDCatInfo = MDCatBuilder.GetMetadataCategoryInfo(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(Category) + "'");
                    //-- If Metadata not category exists
                    if (MDCatInfo != null && string.IsNullOrEmpty(MDCatInfo.CategoryName))
                    {
                        MDCatInfo.CategoryName = Category;
                        MDCatInfo.CategoryType = this.GetCategoryTypeText(elementType);

                        //Create new xmlelement as Category
                        CategoryNode = MetadataXmlDoc.CreateElement(MetaDataConstants.CategoryTagName);

                        //Set attribute values of category element.
                        CategoryNode.SetAttribute(MetaDataConstants.NameAttribute, Category);
                        // create para element
                        ParaNode = MetadataXmlDoc.CreateElement(MetaDataConstants.ParaTagName);
                        //Append as para node under category node
                        CategoryNode.AppendChild(ParaNode);
                        // create text node
                        CategoryText = MetadataXmlDoc.CreateTextNode(this.ReplaceInvalidString(CategoryValue));
                        //Append category text in paraNode
                        ParaNode.AppendChild(CategoryText);
                        //Append it under metadata node
                        MetadataXmlDoc.DocumentElement.AppendChild(CategoryNode);
                    }
                    //-- Get CategoryNId
                    CategoryNId = MDCatBuilder.CheckNCreateMetadataCategory(MDCatInfo);
                    this.UpdateMetadataCategory(MetadataXmlDoc, Category, CategoryValue);
                }
                else
                {
                    //-- Exit for Next Metadata
                    break;
                }

            }

            RetVal = MetadataXmlDoc.InnerXml;

            return RetVal;
        }
示例#3
0
        private bool ISMetadataXmlForCategory(string metadataXml, MetaDataType elementType)
        {
            bool RetVal = false;
            string CategoryName = string.Empty;
            string CategoryValue = string.Empty;
            XmlDocument XmlDoc = new XmlDocument();
            MetadataCategoryBuilder MDCatBuilder;
            MetadataCategoryInfo MDCatInfo;
            XmlDoc.LoadXml(metadataXml);

            try
            {

                MDCatBuilder = new MetadataCategoryBuilder(this.DBConnection, this.DBQueries);
                XmlNodeList XmlList = XmlDoc.SelectNodes(METADATA_CATEGORYTAG);

                for (int i = 0; i < XmlList.Count; i++)
                {
                    CategoryName = XmlList[i].Attributes["name"].Value;

                    MDCatInfo = MDCatBuilder.GetMetadataCategoryInfo(FilterFieldType.Name, "'" + DICommon.RemoveQuotes(CategoryName) + "'");

                    if (MDCatInfo.CategoryType == this.GetCategoryTypeText(elementType))
                    {
                        MDCatBuilder.CheckNCreateMetadataCategory(MDCatInfo);
                        RetVal = true;
                    }

                }

            }
            catch (Exception)
            {
            }

            return RetVal;
        }