Example #1
0
    public List <DeptSupplyModel> GetSpecialDeptName()
    {
        List <DeptSupplyModel> lsDept = new List <DeptSupplyModel>();
        DeptSupplyModel        dept;
        string path = Server.MapPath("/") + @"RmsOA\DeptSupply.xml";
        //string path = @"D:\RmsPM20\RmsPM20\RmsOA\DeptSupply.xml";
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.Load(path);
        XmlNodeList xmlList = xmlDoc.DocumentElement.ChildNodes;

        if (xmlList.Count > 0)
        {
            foreach (XmlElement xmlEle in xmlList)
            {
                if (xmlEle.Name.Equals("Dept"))
                {
                    dept = new DeptSupplyModel();
                    XmlNodeList nodeList = xmlEle.ChildNodes;
                    foreach (XmlElement xmlEleIN in nodeList)
                    {
                        if (xmlEleIN.Name.Equals("DeptName"))
                        {
                            if (!String.IsNullOrEmpty(xmlEleIN.InnerText))
                            {
                                dept.DeptName = xmlEleIN.InnerText;
                            }
                        }
                        if (xmlEleIN.Name.Equals("DeptCode"))
                        {
                            if (!string.IsNullOrEmpty(xmlEleIN.InnerText))
                            {
                                dept.DeptCode = xmlEleIN.InnerText;
                            }
                        }
                        if (xmlEleIN.Name.Equals("Supply"))
                        {
                            XmlNodeList   nameList = xmlEleIN.ChildNodes;
                            List <string> names    = new List <string>();
                            foreach (XmlElement xe in nameList)
                            {
                                names.Add(xe.InnerText);
                            }
                            dept.SupplyName = names;
                        }
                    }
                    lsDept.Add(dept);
                }
            }
        }
        return(lsDept);
    }
Example #2
0
        public static List <DeptSupplyModel> GetModel()
        {
            List <DeptSupplyModel> list = new List <DeptSupplyModel>();
            DeptSupplyModel        item = new DeptSupplyModel();
            string text = ConfigurationManager.AppSettings["ScoreDepts"];

            if (string.IsNullOrEmpty(text))
            {
                throw new Exception("违法操作,请在配置文件里面配置好扩展部门");
            }
            string[] textArray = text.Split(new char[] { '|' });
            foreach (string text2 in textArray)
            {
                string[] textArray2 = text2.Split(new char[] { ';', ',' });
                item          = new DeptSupplyModel();
                item.DeptName = textArray2[0];
                item.DeptCode = textArray2[1];
                List <string> list2 = new List <string>();
                list2.Add(textArray2[2]);
                list2.Add(textArray2[3]);
                list.Add(item);
            }
            return(list);
        }