public static int createJobConfig(string outcode, out AbstractJobConfig config) { int num; string str4; XmlDocument document2; config = null; string code = outcode.Substring(0, 6); if (!int.TryParse(outcode.Substring(6), out num)) { return -10; } string dir = TemplatePath + @"recv\" + code + @"\"; int num2 = dirCheck(dir, code, out str4); if (num2 != 0) { code = code.Substring(0, 4); dir = TemplatePath + @"recv\" + code + @"\"; int num3 = dirCheck(dir, code, out str4); switch (num3) { case 0: goto Label_015D; case -1: return num2; } return num3; } XmlDocument document = new XmlDocument(); try { document.Load(str4); XmlAttribute attribute = document.DocumentElement.Attributes["erase"]; if ((attribute != null) && (attribute.Value.ToUpper() == "TRUE")) { code = code.Substring(0, 4); dir = TemplatePath + @"recv\" + code + @"\"; int num4 = dirCheck(dir, code, out str4); switch (num4) { case 0: goto Label_015D; case -1: return -8; } return num4; } } catch (XmlException exception) { lastError = exception.Message + "\t" + exception.StackTrace; return -4; } catch (Exception exception2) { lastError = exception2.Message + "\t" + exception2.StackTrace; return -99; } Label_015D: document2 = new XmlDocument(); try { XmlNode node; document2.Load(str4); XmlAttribute attribute2 = document2.DocumentElement.Attributes["style"]; if ((attribute2 == null) || (attribute2.Value == "normal")) { NormalConfig config2 = new NormalConfig(); num2 = config2.setDocument(document2); if (num2 == 0) { config2.setDirectories(dir, GymErrPath, GuidePath); num2 = config2.selectRecord(num, out node); } config = config2; return num2; } if ((attribute2.Value == "combi") || (attribute2.Value == "combination")) { CombiConfig config3 = new CombiConfig(); num2 = config3.setDocument(document2); if (num2 == 0) { config3.setDirectories(dir, GymErrPath, GuidePath); } config = config3; return num2; } if (attribute2.Value == "divide") { DivideConfig config4 = new DivideConfig(); num2 = config4.setDocument(document2); if (num2 == 0) { config4.setDirectories(dir, GymErrPath, GuidePath); num2 = config4.selectRecord(num, out node); } config = config4; return num2; } return -6; } catch (XmlException exception3) { lastError = exception3.Message + "\t" + exception3.StackTrace; return -4; } catch (Exception exception4) { lastError = exception4.Message + "\t" + exception4.StackTrace; return -99; } return num2; }
private static int loadJob(string dir, string code, DateTime dateTime, out AbstractJobConfig config) { string str; config = null; int num = dirCheck(dir, code, out str); if (num == 0) { XmlDocument doc = new XmlDocument(); try { XmlNode node; doc.Load(str); XmlAttribute attribute = doc.DocumentElement.Attributes["style"]; if (((attribute == null) || (attribute.Value == "")) || (attribute.Value == "normal")) { NormalConfig config2 = new NormalConfig(); num = config2.setDocument(doc); if (num == 0) { config2.setDirectories(dir, GymErrPath, GuidePath); num = config2.selectRecord(dateTime, out node); } config = config2; return num; } if (attribute.Value == "combi") { CombiConfig config3 = new CombiConfig(); num = config3.setDocument(doc); if (num == 0) { config3.setDirectories(dir, GymErrPath, GuidePath); for (int i = 0; i < config3.count; i++) { AbstractJobConfig config4; num = createJobConfig(config3.configs[i].code, dateTime, out config4); config3.configs[i].config = config4 as NormalConfig; } } config = config3; return num; } if (attribute.Value == "divide") { DivideConfig config5 = new DivideConfig(); num = config5.setDocument(doc); if (num == 0) { config5.setDirectories(dir, GymErrPath, GuidePath); num = config5.selectRecord(dateTime, out node); } config = config5; return num; } return -6; } catch (XmlException exception) { lastError = exception.Message + "\t" + exception.StackTrace; return -4; } catch (Exception exception2) { lastError = exception2.Message + "\t" + exception2.StackTrace; return -99; } } return num; }
public jobForm(string JobCode) { InitializeComponent(); #region Xử lý nghiệp vụ //Xác định jobcode để load config this.jobCode = JobCode; //Template path strTemplatePath = Path.Combine(Application.StartupPath, @"App_LocalResources\Template"); if (Directory.Exists(strTemplatePath) == false) Directory.CreateDirectory(strTemplatePath); strGuidePath = Path.Combine(Application.StartupPath, @"App_LocalResources\Help\guide\"); if (Directory.Exists(strGuidePath) == false) Directory.CreateDirectory(strGuidePath); strHelpPath = Path.Combine(Application.StartupPath, @"App_LocalResources\Help\gym_err\"); if (Directory.Exists(strHelpPath) == false) Directory.CreateDirectory(strHelpPath); //Đường dẫn file config cho job này string strJobConfigPath = Path.Combine(Application.StartupPath, string.Format(strJobConfigPathInit, jobCode)); if (Directory.Exists(strJobConfigPath) == false) Directory.CreateDirectory(strJobConfigPath); string strJobConfigFileName=string.Format("{0}.conf",jobCode); string strJobConfigFilePath = Path.Combine(strJobConfigPath, strJobConfigFileName); clsAll.ExtractJobFile(strJobConfigPath, strJobConfigFileName); //Load file config AbstractJobConfig c1 = new NormalConfig(); JobConfigFactory.TemplatePath = strTemplatePath; JobConfigFactory.GuidePath = strGuidePath; JobConfigFactory.GymErrPath = strHelpPath; JobConfigFactory.createJobConfig(jobCode, new DateTime(), out c1); NormalConfig jobConfig = (c1 as NormalConfig); jobTitle = jobConfig.record.titile1; this.KySo = jobConfig.record.signflg.Equals(1); //Title jobCodeTitle = string.Format("{0} - {1}", jobCode, jobTitle); this.Text = jobCodeTitle; this.TITLE.Text = jobCodeTitle; //Diplay file strDisplayFile = jobConfig.Display; clsAll.ExtractJobFile(strJobConfigPath, Path.GetFileName(strDisplayFile)); strGuideFile = jobConfig.Guide; clsAll.ExtractJobFile(strGuidePath, Path.GetFileName(strGuideFile)); strHelpFile = jobConfig.Help; clsAll.ExtractJobFile(strHelpPath, Path.GetFileName(strHelpFile)); #region Load guide file hướng dẫn XmlDocument docGuide = new XmlDocument(); docGuide.Load(strGuideFile); DataColumn cID = new DataColumn("ID"); dtGuide.Columns.Add(cID); DataColumn cGuideText = new DataColumn("GuideText"); dtGuide.Columns.Add(cGuideText); foreach (XmlNode n in docGuide.SelectNodes("guide/item")) { DataRow r = dtGuide.NewRow(); r[0] = n.Attributes["id"].Value; r[1] = n.InnerText; dtGuide.Rows.Add(r); } #endregion #endregion }