Beispiel #1
0
 public static bool SaveCfg(ref string reStr)
 {
     try
     {
         string xmlCfgFile = System.AppDomain.CurrentDomain.BaseDirectory + @"data/DevConfigFTzj.xml";
         if (!File.Exists(xmlCfgFile))
         {
             reStr = "系统配置文件:" + xmlCfgFile + " 不存在!";
             return(false);
         }
         XElement root      = XElement.Load(xmlCfgFile);
         XElement printerXE = root.Element("sysSet").Element("Printer");
         if (PrienterEnable)
         {
             printerXE.Attribute("Enable").Value = "True";
         }
         else
         {
             printerXE.Attribute("Enable").Value = "False";
         }
         XElement mesXE = root.Element("sysSet").Element("Mes");
         if (MesCheckEnable)
         {
             mesXE.Attribute("Enable").Value = "True";
         }
         else
         {
             mesXE.Attribute("Enable").Value = "False";
         }
         if (MesOfflineMode)
         {
             mesXE.Attribute("OfflineMode").Value = "True";
         }
         else
         {
             mesXE.Attribute("OfflineMode").Value = "False";
         }
         XElement mesTimeOutXE = root.Element("sysSet").Element("MesDownTimeout");
         mesTimeOutXE.Value = MesTimeout.ToString();
         XElement rfidTimeOutXE = root.Element("sysSet").Element("RfidTimeout");
         rfidTimeOutXE.Value = RfidDelayTimeout.ToString();
         root.Save(xmlCfgFile);
         return(true);
     }
     catch (Exception ex)
     {
         reStr = ex.ToString();
         return(false);
     }
 }
Beispiel #2
0
        public static bool SaveCfg(string xmlCfgFile, ref string reStr)
        {
            try
            {
                //string xmlCfgFile = System.AppDomain.CurrentDomain.BaseDirectory + @"data/DevConfigFTzj.xml";
                if (!File.Exists(xmlCfgFile))
                {
                    reStr = "系统配置文件:" + xmlCfgFile + " 不存在!";
                    return(false);
                }
                XElement root      = XElement.Load(xmlCfgFile);
                XElement printerXE = root.Element("sysSet").Element("Printer");
                if (PrienterEnable)
                {
                    printerXE.Attribute("Enable").Value = "True";
                }
                else
                {
                    printerXE.Attribute("Enable").Value = "False";
                }

                XElement sysSetXE   = root.Element("sysSet");
                XElement sysParamXE = sysSetXE.Element("SysParam");
                List <ParamCfgBase.ParamModel> paramList = new List <ParamCfgBase.ParamModel>();
                foreach (string strKey in SysParamDic.Keys)
                {
                    paramList.Add(SysParamDic[strKey]);
                }
                string strJsonParam = JsonConvert.SerializeObject(paramList);
                sysParamXE.Value = strJsonParam;

                XElement runModeXE = root.Element("sysSet").Element("RunMode");
                //if(runModeXE.Attribute("debugMode") != null)
                //{
                //    if(DebugMode)
                //    {
                //        runModeXE.Attribute("debugMode").Value = "True";
                //    }
                //    else
                //    {
                //        runModeXE.Attribute("debugMode").Value = "False";
                //    }
                //}
                if (runModeXE.Attribute("manualMode1") != null)
                {
                    if (ManualMode1)
                    {
                        runModeXE.Attribute("manualMode1").Value = "True";
                    }
                    else
                    {
                        runModeXE.Attribute("manualMode1").Value = "False";
                    }
                }
                if (runModeXE.Attribute("manualMode3") != null)
                {
                    if (ManualMode1)
                    {
                        runModeXE.Attribute("manualMode3").Value = "True";
                    }
                    else
                    {
                        runModeXE.Attribute("manualMode3").Value = "False";
                    }
                }
                XElement mesXE = root.Element("sysSet").Element("Mes");
                if (MesCheckEnable)
                {
                    mesXE.Attribute("Enable").Value = "True";
                }
                else
                {
                    mesXE.Attribute("Enable").Value = "False";
                }
                if (MesOfflineMode)
                {
                    mesXE.Attribute("OfflineMode").Value = "True";
                }
                else
                {
                    mesXE.Attribute("OfflineMode").Value = "False";
                }
                if (MesAutodownEnabled)
                {
                    mesXE.Attribute("MesAutodown").Value = "True";
                }
                else
                {
                    mesXE.Attribute("MesAutodown").Value = "False";
                }
                XElement mesTimeOutXE = root.Element("sysSet").Element("MesDownTimeout");
                mesTimeOutXE.Value = MesTimeout.ToString();
                XElement rfidTimeOutXE = root.Element("sysSet").Element("RfidTimeout");
                rfidTimeOutXE.Value = RfidDelayTimeout.ToString();


                root.Save(xmlCfgFile);
                return(true);
            }
            catch (Exception ex)
            {
                reStr = ex.ToString();
                return(false);
            }
        }