Esempio n. 1
0
        /// <summary>
        /// 读取PLC异常的XML文档
        /// </summary>
        internal void ReadPLCErrXML()
        {
            try
            {
                string xml_path = string.Format("{0}\\{1}", GlobalVar.Folder_Config, GlobalVar.File_PLCErr);
                if (!File.Exists(xml_path))
                {
                    throw new Exception("PLC异常文件不存在");
                }

                OpXML          xml      = new OpXML(xml_path);
                string         Value    = "PLCErr";
                List <XmlNode> NodeList = OpXML.GetChildNodes(xml_path, Value);

                foreach (XmlNode item in NodeList)
                {
                    int    Index  = Convert.ToInt32(((XmlElement)item).GetAttribute("Index"));
                    string ErrStr = ((XmlElement)item).GetAttribute("ErrStr");
                    GlobalVar.PLCErrDir.Add(Index, new PLCErr(ErrStr));
                }
            }
            catch (Exception ex)
            {
                log.AddERRORLOG("读取PLC异常:" + ex.Message);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 检查版本是否为最新版本
        /// </summary>
        /// <param name="DownloadPath_Name">下载文件路径 文件名</param>
        /// <returns></returns>
        public bool CheckVersion(out Dictionary <string, string> DownloadPath_Name)
        {
            bool NewVersion = false;

            DownloadPath_Name = new Dictionary <string, string>();
            try
            {
                OpXML xml = new OpXML();
                list_XN = OpXML.GetChildNodes(IIS_Url, _Version);
                foreach (XmlNode node in list_XN)
                {
                    this.Server_Ver = GetVerInt(node.Value);
                    //Console.WriteLine(string.Format("{0}\t服务器版本:{1}\t已经下载版本:{2}\t当前版本:{3}",
                    //    DateTime.Now.ToString("HH:mm:ss:fff"),
                    //    this.Server_Ver,
                    //    this.Download_Ver,
                    //    this.Current_Ver));
                }
                list_XN = OpXML.GetChildNodes(IIS_Url, _Update);
                foreach (XmlNode node in list_XN)
                {
                    if (node.Name != _File)
                    {
                        continue;
                    }
                    string webpath, filename;
                    if (GetUpdateInf(node, out webpath, out filename))
                    {
                        DownloadPath_Name.Add(webpath, filename);
                    }
                }
            }
            catch (Exception ex)
            {
#if DEBUG
                MessageBox.Show(string.Format("检查版本:{0}", ex.Message), MsgTitle);
#endif
                Console.WriteLine(string.Format("{1} 检查版本:{0}", ex.Message, MsgTitle));
            }
            //以网络的版本比对当前运行的版本,及下载的版本
            if (this.Server_Ver != this.Current_Ver && this.Server_Ver != this.Download_Ver)
            {
                NewVersion = true;
            }
            return(NewVersion);
        }