public IXmlSetting InitFromXmlFile(string xmlType, string xmlFilePath, string userId)
        {
            CXmlSettingImp neoXmlSetting = new CXmlSettingImp();

            neoXmlSetting.file_type   = xmlType;
            neoXmlSetting.update_time = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
            neoXmlSetting.updated_by  = userId;
            //neoXmlSetting.GetChildRelation(xmlFilePath);
            //neoXmlSetting.GetParentRelation(xmlFilePath);

            XmlDocument NodeSettingDoc = new XmlDocument();

            try
            {
                NodeSettingDoc.Load(xmlFilePath);
                XmlNode     root     = NodeSettingDoc.DocumentElement;
                XmlNodeList listNode = root.SelectNodes("//*");

                List <string> lstDisctinctNodeNames = (from XmlNode tempNode in listNode select tempNode.Name).Distinct().ToList();
                foreach (string strNodeName in lstDisctinctNodeNames)
                {
                    CXmlSettingNodeImp neoNode = new CXmlSettingNodeImp();
                    neoNode.name         = strNodeName;
                    neoNode.compare_flag = true;

                    List <string> lstDisctinctAttributeNames = new List <string>();
                    List <XmlAttributeCollection> lstAttrSet = (from XmlNode tmpXmlNode in listNode
                                                                where tmpXmlNode.Name == strNodeName
                                                                select tmpXmlNode.Attributes).ToList();
                    foreach (XmlAttributeCollection tempAttrSet in lstAttrSet)
                    {
                        foreach (XmlNode tempAttr in tempAttrSet)
                        {
                            lstDisctinctAttributeNames.Add(tempAttr.Name);
                        }
                    }
                    lstDisctinctAttributeNames = lstDisctinctAttributeNames.Distinct().ToList();


                    foreach (string strAttrName in lstDisctinctAttributeNames)
                    {
                        CXmlSettingAttrImp neoAttr = new CXmlSettingAttrImp();
                        neoAttr.name            = strAttrName;
                        neoAttr.identifier_flag = false;
                        neoAttr.compare_flag    = true;
                        neoNode.AppendAttribute(neoAttr);
                    }
                    neoXmlSetting.AppendNode(neoNode);
                }
                neoXmlSetting.GetParentRelation(xmlFilePath);
                neoXmlSetting.GetChildRelation(xmlFilePath);
                return(neoXmlSetting);
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Example #2
0
        public void AppendSetting(IXmlSetting setting)
        {
            CXmlSettingImp value = (CXmlSettingImp)setting;

            if (m_NodeSettingCollection.Exists(m => m.file_type == value.file_type))
            {
                //throw new Exception("diplicate file type[" + value.file_type + "] exist in setting collcetion.append failed");
                MessageBox.Show("Type already exists!");
            }
            else
            {
                m_NodeSettingCollection.Add(value);
            }
        }
Example #3
0
        public void RemoveSetting(IXmlSetting setting)
        {
            CXmlSettingImp value = (CXmlSettingImp)setting;

            m_NodeSettingCollection.Remove(value);
        }