Ejemplo n.º 1
0
        /// <summary>
        /// 将上传的原模型预处理为对应的主机名
        /// </summary>
        /// <param name="xmlpath"></param>
        public static void PreMachineName(string xmlpath)
        {
            XmlDocument xmlcmp = ReadXml(xmlpath);

            {
                LearnSite.BLL.Computers pbll = new BLL.Computers();
                DataTable   dtcomputer       = pbll.GetPipPmachine();
                XmlNode     root             = xmlcmp.SelectSingleNode("classmodel");
                XmlNodeList nodeList         = root.ChildNodes;
                if (nodeList[0].Name != "student")
                {
                    XmlNode newroot = root.SelectSingleNode("students");
                    nodeList = newroot.ChildNodes;
                }
                foreach (XmlNode xn in nodeList)
                {
                    XmlNode addressNode = xn.SelectSingleNode("address");
                    string  ip          = addressNode.Attributes["IP"].Value;
                    string  Sname       = GetMachineByIp(dtcomputer, ip);  //根据IP,获取主机名
                    if (!string.IsNullOrEmpty(Sname) && !WordProcess.IsZh(Sname))
                    {
                        XmlNode nameNode = xn.SelectSingleNode("name");
                        nameNode.InnerText = Sname;//如果有则修改
                    }
                }
                xmlcmp.Save(xmlpath);//保存生成的主机名模型
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据班级模型读取IP的x坐标和y坐标
        /// </summary>
        /// <param name="xdoc"></param>
        /// <param name="classname"></param>
        public static int SetIpxy(string xmlfile, string Pm)
        {
            XmlDocument xmlsave = new XmlDocument();

            xmlsave = ReadXml(xmlfile);

            XmlNode     root     = xmlsave.SelectSingleNode("classmodel");
            XmlNodeList nodeList = root.ChildNodes;

            if (nodeList[0].Name != "student")
            {
                XmlNode newroot = root.SelectSingleNode("students");
                nodeList = newroot.ChildNodes;
            }

            LearnSite.BLL.Computers cbll = new BLL.Computers();
            foreach (XmlNode xn in nodeList)
            {
                XmlNode addressNode = xn.SelectSingleNode("address");
                string  ip          = addressNode.Attributes["IP"].Value;
                XmlNode posNode     = xn.SelectSingleNode("posThumb");
                string  px          = posNode.Attributes["x"].Value;
                string  py          = posNode.Attributes["y"].Value;
                string  machine     = xn.SelectSingleNode("name").InnerText;//主机名
                if (WordProcess.IsZh(machine))
                {
                    machine = "";                           //如果班级模型的主机名是中文,则留空
                }
                if (!cbll.UpdateIpPxPy(ip, Int32.Parse(px), Int32.Parse(py), Pm))
                {
                    //如果没更新,则插入一条
                    LearnSite.Model.Computers cmodel = new Model.Computers();
                    cmodel.Pdate    = DateTime.Now;
                    cmodel.Pip      = ip;
                    cmodel.Plock    = true;
                    cmodel.Pm       = Pm;
                    cmodel.Pmachine = machine;
                    cmodel.Px       = Int32.Parse(px);
                    cmodel.Py       = Int32.Parse(py);
                    cbll.AddModel(cmodel);
                }
            }
            return(nodeList.Count);
        }