private void property_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { Xml2 xml = new Xml2(xmlFile); var info = config.OPList[listBox.SelectedIndex]; xml.SetAttr("root//Table[@Name='" + info.Table + "']", "Entity|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|UpdateAndInsert", "{8}|{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{9}".FormatWith( info.Insert.ToString().ToLower(), info.Update.ToString().ToLower(), info.DeleteByID.ToString().ToLower(), info.IsExistByID.ToString().ToLower(), info.SelectByID.ToString().ToLower(), info.SelectPageList.ToString().ToLower(), info.SelectListByFK.ToString().ToLower(), info.SelectListByAll.ToString().ToLower(), info.Entity.ToString().ToLower(), info.UpdateAndInsert.ToString().ToLower() )); xml.Save(); xml.Close(); }
private void CreateXML(string fileName) { Xml2.Create(fileName, "", "", "utf-8", "<root></root>"); Xml2 xml = new Xml2(fileName); foreach (var info in OPList) { xml.AddNode("root", "Table", "Name|Entity|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|UpdateAndInsert", "{0}|{9}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{10}".FormatWith( info.Table, info.Insert.ToString().ToLower(), info.Update.ToString().ToLower(), info.DeleteByID.ToString().ToLower(), info.IsExistByID.ToString().ToLower(), info.SelectByID.ToString().ToLower(), info.SelectPageList.ToString().ToLower(), info.SelectListByFK.ToString().ToLower(), info.SelectListByAll.ToString().ToLower(), info.Entity.ToString().ToLower(), info.UpdateAndInsert.ToString().ToLower() )); } xml.Save(); xml.Close(); }
private void frmEntity_Load(object sender, EventArgs e) { //Data.ConnString = WebConfig.GetConn("ConnString"); textBox1.Text = string.IsNullOrEmpty(WebConfig.GetApp("Project")) ? "Test" : WebConfig.GetApp("Project"); xmlFile = "".GetMapPath() + textBox1.Text + ".xml"; bool xmlExist = FileDirectory.FileExists(xmlFile); IList <TableEntity> list = TableFactory.GetTable(); foreach (TableEntity entity in list) { listBox.Items.Add((entity.isView ? "* " : "") + entity.Name, entity.isView ? false : true); if (!xmlExist) { OPList.Add(new TableOperator() { Table = entity.Name }); } else { Xml2 xml = new Xml2(xmlFile); string[] attrs = xml.GetAttr("root//Table[@Name='" + entity.Name + "']", "Name|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|Entity|UpdateAndInsert").Split('|'); if (attrs[0].IsNullEmpty()) { OPList.Add(new TableOperator() { Table = entity.Name }); var info = OPList[OPList.Count - 1]; xml.AddNode("root", "Table", "Name|Entity|Insert|Update|Delete|IsExistByID|SelectByID|SelectPageList|SelectListByFK|SelectListByAll|UpdateAndInsert", "{0}|{9}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}|{10}".FormatWith( info.Table, info.Insert.ToString().ToLower(), info.Update.ToString().ToLower(), info.DeleteByID.ToString().ToLower(), info.IsExistByID.ToString().ToLower(), info.SelectByID.ToString().ToLower(), info.SelectPageList.ToString().ToLower(), info.SelectListByFK.ToString().ToLower(), info.SelectListByAll.ToString().ToLower(), info.Entity.ToString().ToLower(), info.UpdateAndInsert.ToString().ToLower() )); xml.Save(); } else { OPList.Add(new TableOperator() { Table = entity.Name, Insert = attrs[1] == "true" ? true : false, Update = attrs[2] == "true" ? true : false, DeleteByID = attrs[3] == "true" ? true : false, IsExistByID = attrs[4] == "true" ? true : false, SelectByID = attrs[5] == "true" ? true : false, SelectPageList = attrs[6] == "true" ? true : false, SelectListByFK = attrs[7] == "true" ? true : false, SelectListByAll = attrs[8] == "true" ? true : false, Entity = attrs[9] == "true" ? true : false, UpdateAndInsert = attrs[10] == "true" ? true : false, }); } xml.Close(); } } if (!xmlExist) { CreateXML(xmlFile); } if (listBox.Items.Count > 0) { listBox.SelectedIndex = 0; } this.Text = "Entity Tool [{2}] - {1}连接共有{0}个表".FormatWith(listBox.Items.Count, Data.DBType, TemplateName); }