public void InitSetting(CheckedListBox listbox, List <ExcelData> sheets) { dataList = listbox; dataExcels = sheets; XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\JavaDataConfig.xml"); XmlElement root = ConfigControl.GetXmlRootAsElement(doc, "JavaDataGenerateConfig"); XmlElement config = root.SelectSingleNode("configs") as XmlElement; if (config != null) { XmlNodeList configList = config.SelectNodes("JavaDataGenerateInfo"); if (configList.Count > 0) { for (int i = 0; i < configList.Count; i++) { CJavaDataConfig dataConfig = new CJavaDataConfig(); dataConfig.LoadConfig((XmlElement)configList[i]); dataConfigs.Add(dataConfig); } } } int index = Convert.ToInt32(ConfigControl.GetXmlElementInnerText(root, "lastIndex")); currentConfig = index; //comboBoxConfigList.Items.Clear(); //for (int i = 0; i < dataConfigs.Count; i++) //{ // comboBoxConfigList.Items.Add(dataConfigs[i].caption); //} comBonRefreshFlag = true; RefreshData(); comboBoxConfigList.SelectedIndex = index; }
public void Init(LinkLabel linkLabel) { linkLabel1 = linkLabel; doc = ConfigControl.GetXmlDocument(@".\Config\BasicConfig.xml"); XmlElement rootElement = ConfigControl.GetXmlRootAsElement(doc, "BasicConfig"); folderElement = ConfigControl.GetXmlElement(rootElement, "folder"); path = folderElement.InnerText; textBoxPath.Text = path; }
public void Init(string[] xmlPath) { filepaths = xmlPath; doc = ConfigControl.GetXmlDocument(@".\Config\MessageConfig.xml"); XmlElement rootElement = ConfigControl.GetXmlRootAsElement(doc, "MessageConfig"); XmlElement csElement = ConfigControl.GetXmlElement(rootElement, "CS"); outPathElement = ConfigControl.GetXmlElement(csElement, "OutPath"); outPath = outPathElement.InnerText; textBoxPath.Text = outPath; }
public static void SaveMessageSetting() { XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\MessageConfig.xml"); XmlElement rootElement = ConfigControl.GetXmlRootAsElement(doc, "MessageConfig"); XmlElement csElement = ConfigControl.GetXmlElement(rootElement, "CS"); ConfigControl.SetXmlelementInnerText(csElement, "CsMessageFile", CsMessageFilePath, doc); ConfigControl.SetXmlelementInnerText(csElement, "CsBeanTemplate", CsBeanTemplatePath, doc); ConfigControl.SetXmlelementInnerText(csElement, "CsMessageTemplate", CsMessageTemplatePath, doc); ConfigControl.SetXmlelementInnerText(csElement, "CsMessageTypeTemplate", CsMessageTypeTemplatePath, doc); ConfigControl.SetXmlelementInnerText(csElement, "CsFunMap", CsFunMapFilePath, doc); doc.Save(@".\Config\MessageConfig.xml"); }
private void BtnSave_Click(object sender, EventArgs e) { SetCurrentData(); for (int i = 0; i < dataConfigs.Count; i++) { if (string.IsNullOrEmpty(dataConfigs[i].folder)) { if (MessageBox.Show(dataConfigs[i].caption + "配置路径为空,请设置", "空路径", MessageBoxButtons.OKCancel, MessageBoxIcon.Error) == DialogResult.OK) { currentConfig = i; return; } else { return; } } } XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\JavaDataConfig.xml"); XmlElement root = ConfigControl.GetXmlRootAsElement(doc, "JavaDataGenerateConfig"); XmlElement configelElement = root.SelectSingleNode("configs") as XmlElement; if (configelElement != null) { configelElement.RemoveAll(); if (dataConfigs.Count > 0) { foreach (var config in dataConfigs) { XmlElement infoElement = doc.CreateElement("JavaDataGenerateInfo"); config.WriteConfig(doc, infoElement); configelElement.AppendChild(infoElement); } } } XmlElement lastIndex = root.SelectSingleNode("lastIndex") as XmlElement; if (lastIndex != null) { lastIndex.InnerText = comboBoxConfigList.SelectedIndex.ToString(); } doc.Save(@".\Config\JavaDataConfig.xml"); }
private void OKButton_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(CsTempFilePath)) { Global.CsTemplate = CsTempFilePath; } if (!string.IsNullOrEmpty(typeFilePath)) { Global.TypeBankFile = typeFilePath; } XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\BasicConfig.xml"); XmlElement rootElement = ConfigControl.GetXmlRootAsElement(doc, "BasicConfig"); ConfigControl.SetXmlelementInnerText(rootElement, "csTemplate", CsTempFilePath, doc); ConfigControl.SetXmlelementInnerText(rootElement, "typeBankFile", typeFilePath, doc); doc.Save(@".\Config\BasicConfig.xml"); this.Close(); }
public static void InitMessageSetting() { XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\MessageConfig.xml"); XmlElement rootElement = ConfigControl.GetXmlRootAsElement(doc, "MessageConfig"); ///C#配置读取 XmlElement csElement = ConfigControl.GetXmlElement(rootElement, "CS"); XmlElement csMessageFileElement = ConfigControl.GetXmlElement(csElement, "CsMessageFile"); if (csMessageFileElement != null) { CsMessageFilePath = csMessageFileElement.InnerText.Trim(); } XmlElement csBeanTemplateElement = ConfigControl.GetXmlElement(csElement, "CsBeanTemplate"); if (csBeanTemplateElement != null) { CsBeanTemplatePath = csBeanTemplateElement.InnerText.Trim(); } XmlElement csMessageTemplateElement = ConfigControl.GetXmlElement(csElement, "CsMessageTemplate"); if (csMessageTemplateElement != null) { CsMessageTemplatePath = csMessageTemplateElement.InnerText.Trim(); } CsMessageTypeTemplatePath = ConfigControl.GetXmlElementInnerText(csElement, "CsMessageTypeTemplate"); XmlElement csFunMapElement = ConfigControl.GetXmlElement(csElement, "CsFunMap"); if (csFunMapElement != null) { CsFunMapFilePath = csFunMapElement.InnerText.Trim(); } ///AS配置读取 XmlElement asElement = ConfigControl.GetXmlElement(rootElement, "AS"); AsMessageFilePath = ConfigControl.GetXmlElementInnerText(asElement, "AsMessageFile"); AsBeanTemplatePath = ConfigControl.GetXmlElementInnerText(asElement, "AsBeanTemplate"); AsMessageTemplatePath = ConfigControl.GetXmlElementInnerText(asElement, "AsMessageTemplate"); AsHandleTemplatePath = ConfigControl.GetXmlElementInnerText(asElement, "AsHandleTemplate"); AsFunMapFilePath = ConfigControl.GetXmlElementInnerText(asElement, "AsFunMap"); }
public void CreateJavaResDataConfig(ExcelData excelSheetData, CJavaDataConfig javaDataConfig) { string dataConfigPath = javaDataConfig.folder + @"\src\data-config.xml"; if (File.Exists(dataConfigPath)) { XmlDocument doc = ConfigControl.GetXmlDocument(dataConfigPath); XmlElement rootElement = ConfigControl.GetXmlRootAsElement(doc, "configuration"); XmlElement mappersElement = rootElement.SelectSingleNode("mappers") as XmlElement; if (mappersElement.ChildNodes.Count > 0) { XmlNodeList list = mappersElement.ChildNodes; MapperNode[] nodes = new MapperNode[list.Count / 2]; for (int i = 0; i < nodes.Length; i++) { nodes[i] = new MapperNode(); //nodes[i].nodeValue = list[i*2].Value; XmlElement element = (XmlElement)list[i * 2 + 1]; string fullNmae = element.GetAttribute("resource"); int beginIndex = fullNmae.LastIndexOf(@"/"); int endIndex = fullNmae.LastIndexOf("."); nodes[i].name = fullNmae.Substring(beginIndex + 1, endIndex - beginIndex - 1).Trim(); string nodeValue = list[i * 2].Value; int startIndex = nodeValue.IndexOf(":"); nodes[i].time = nodeValue.Substring(startIndex + 1).Trim(); } WriteToDataConfig(excelSheetData, dataConfigPath, javaDataConfig, nodes); } else { WriteToDataConfig(excelSheetData, dataConfigPath, javaDataConfig, null); } Debug.Log(" data-config" + ".xml文件更新完毕"); } else { WriteToDataConfig(excelSheetData, dataConfigPath, javaDataConfig, null); Debug.Log(" data-config" + ".xml文件生成完毕"); } }
public void InitSetting(CheckedListBox listbox, List <ExcelData> sheets, bool asFlag = true) { isAs = asFlag; dataList = listbox; dataExcels = sheets; XmlElement root; if (isAs) { XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\AsDataConfig.xml"); root = ConfigControl.GetXmlRootAsElement(doc, "AsDataGenerateConfig"); XmlElement config = root.SelectSingleNode("configs") as XmlElement; if (config != null) { XmlNodeList configList = config.SelectNodes("AsDataGenerateInfo"); if (configList.Count > 0) { for (int i = 0; i < configList.Count; i++) { CAsDataConfig dataConfig = new CAsDataConfig(); dataConfig.LoadConfig((XmlElement)configList[i]); dataConfigs.Add(dataConfig); } } } } else { label1.Text = "Cs Src目录:"; label2.Text = "Cs包:"; label3.Text = "bean using List:"; label4.Text = "Container using list:"; XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\CsDataConfig.xml"); root = ConfigControl.GetXmlRootAsElement(doc, "CsDataGenerateConfig"); XmlElement config = root.SelectSingleNode("configs") as XmlElement; if (config != null) { XmlNodeList configList = config.SelectNodes("CsDataGenerateInfo"); if (configList.Count > 0) { for (int i = 0; i < configList.Count; i++) { CAsDataConfig dataConfig = new CAsDataConfig(); dataConfig.LoadConfig((XmlElement)configList[i]); dataConfigs.Add(dataConfig); } } } checkBoxLoad.Checked = false; } int index = Convert.ToInt32(ConfigControl.GetXmlElementInnerText(root, "lastIndex")); currentConfig = index; //comboBoxCapterList.Items.Clear(); //for (int i = 0; i < dataConfigs.Count; i++) //{ // comboBoxCapterList.Items.Add(dataConfigs[i].caption); //} comBoxRefreshFlag = true; RefreshData(); //comboBoxCapterList.SelectedIndex = index; }
private void Save_Click(object sender, EventArgs e) { Global.FilterSheets = FilterSheetText.Text; Global.StartLoadFolder = StartLoadFoldercheckBox.Checked; Global.LoadData = LoadDataCheckBox.Checked; Global.ResFolder = ResFolderText.Text; Global.IsDataBase = IsDataBaseCheckBox.Checked; Global.IsDisorder = IsDisorderCheckBox.Checked; Global.IsResEnc = IsResEncCheckBox.Checked; if (VersionCheckBox.Checked) { Global.DisEncType = SeedType.Version; } else if (CRC32CheckBox.Checked) { Global.DisEncType = SeedType.CRC32; } else if (MD5CheckBox.Checked) { Global.DisEncType = SeedType.MD5; } else if (SHA1CheckBox.Checked) { Global.DisEncType = SeedType.SHA1; } XmlDocument doc = ConfigControl.GetXmlDocument(@".\Config\BasicConfig.xml"); XmlElement rootElement = ConfigControl.GetXmlRootAsElement(doc, "BasicConfig"); XmlElement filterElement = ConfigControl.GetXmlElement(rootElement, "filterSheets"); XmlNodeList list = filterElement.SelectNodes("string"); foreach (XmlNode node in list) { filterElement.RemoveChild(node); } if (Global.FilterSheets != "") { string[] splites = Global.FilterSheets.Split(','); foreach (var sp in splites) { if (sp != "") { XmlElement element = doc.CreateElement("string"); element.InnerText = sp; filterElement.AppendChild(element); } } } ConfigControl.SetXmlelementInnerText(rootElement, "startLoadFolder", Global.StartLoadFolder, doc); ConfigControl.SetXmlelementInnerText(rootElement, "loadData", Global.LoadData, doc); ConfigControl.SetXmlelementInnerText(rootElement, "resFolder", Global.ResFolder, doc); ConfigControl.SetXmlelementInnerText(rootElement, "isDatabase", Global.IsDataBase, doc); ConfigControl.SetXmlelementInnerText(rootElement, "isDisorder", Global.IsDisorder, doc); ConfigControl.SetXmlelementInnerText(rootElement, "isResEnc", Global.IsResEnc, doc); ConfigControl.SetXmlelementInnerText(rootElement, "resFolder", Global.ResFolder, doc); switch (Global.DisEncType) { case SeedType.Version: ConfigControl.SetXmlelementInnerText(rootElement, "disEncType", "Version", doc); break; case SeedType.CRC32: ConfigControl.SetXmlelementInnerText(rootElement, "disEncType", "CRC32", doc); break; case SeedType.MD5: ConfigControl.SetXmlelementInnerText(rootElement, "disEncType", "MD5", doc); break; case SeedType.SHA1: ConfigControl.SetXmlelementInnerText(rootElement, "disEncType", "SHA1", doc); break; default: break; } doc.Save(@".\Config\BasicConfig.xml"); this.Close(); }