示例#1
0
        public void UpdateTuDien(string fileName, MathRule mathRule)
        {
            System.Xml.Linq.XDocument document = System.Xml.Linq.XDocument.Load(fileName);
            var node = (from t in document.Descendants("Column")
                        where t.Element("DataBase").Value == mathRule.ColumnInDB
                        select t).FirstOrDefault();

            node.Element("Excel").Value = mathRule.ColumnInExcel;
            document.Save(fileName);
        }
示例#2
0
        public void Update(string fileName, MathRule mathRule)
        {
            System.Xml.Linq.XDocument document = System.Xml.Linq.XDocument.Load(fileName);
            var node = (from t in document.Descendants("Column")
                        where t.Element("DataBase").Value == mathRule.ColumnInDB
                        select t).FirstOrDefault();

            // check exist element excel
            string[]      arr  = node.Element("Excel").Value.Split(';');
            List <string> list = new List <string>();

            for (int i = 0; i < arr.Length; i++)
            {
                list.Add(arr[i].Trim());
            }

            if (!list.Contains(mathRule.ColumnInExcel.Trim()))
            {
                node.Element("Excel").Value += ";" + mathRule.ColumnInExcel;
            }

            document.Save(fileName);
        }