void LoadConfig(string name) { if (!string.IsNullOrEmpty(name)) { using (ProjectConfig config = new ProjectConfig()) { if (config.Fill("Name='" + name + "'")) { config.UI.SetToAll(this); } } } }
internal static void Create(object nameObj) { int count = 0; try { string name = Convert.ToString(nameObj); using (ProjectConfig config = new ProjectConfig()) { try { if (config.Fill("Name='" + name + "'")) { string dbName = string.Empty; Dictionary <string, string> tables = Tool.DBTool.GetTables(config.Conn, out dbName); if (tables != null && tables.Count > 0) { dbName = dbName[0].ToString().ToUpper() + dbName.Substring(1, dbName.Length - 1); count = tables.Count; if (config.BuildMode.Contains("枚举") || config.BuildMode.Contains("Enum"))//枚举型。 { BuildTableEnumText(tables, config, dbName); } else { BuildTableEntityText(tables, config, dbName); } } } } catch (Exception err) { Log.WriteLogToTxt(err); } } } finally { if (OnCreateEnd != null) { OnCreateEnd(count); } } //MessageBox.Show(string.Format("执行完成!共计{0}个表", count)); }
string SaveConfig() { string name = ddlName.Text.Trim(); if (string.IsNullOrEmpty(name)) { name = "DefaultConn"; } ResetMainState(); bool result = false; using (ProjectConfig config = new ProjectConfig()) { config.UI.SetAutoParentControl(gbConn, gbBuild); if (config.Fill("Name='" + name + "'")) { config.IsMain = true; result = config.Update(null, true); bool ccc = config.MutilDatabase; bool bb = ccc; } else { config.IsMain = true; if (config.Insert(true)) { ddlName.Items.Add(name); result = true; } } } if (!result) { MessageBox.Show("Save fail", "Tip"); } return(name); }
/// <summary> /// 创建 /// </summary> /// <param name="KeyConnName_ValueTableNames">KeyConnName_ValueTableNames (key 配置名称),(表名,如果为 all 则所有表,否则为:tablename1,tablename2,tablename3,)</param> internal static void Create(object KeyConnName_ValueTableNames) { int count = 0; try { KeyValuePair <string, string> keyValuePair = (KeyValuePair <string, string>)KeyConnName_ValueTableNames; string str = Convert.ToString(keyValuePair.Key); string tablenames = keyValuePair.Value; using (ProjectConfig config = new ProjectConfig()) { try { if (config.Fill("Name='" + str + "'")) { string dbName = string.Empty; string errInfo = string.Empty; Dictionary <string, string> tables = DBTool.GetTables(config.Conn, out dbName, out errInfo); Dictionary <string, string> selectTables = new Dictionary <string, string>(); if (tablenames == "all") // 只留下已选择的表 { selectTables = tables; } else { string[] selectTableNames = tablenames.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (var tablename in selectTableNames) { selectTables.Add(tablename, tables[tablename]); } } if ((selectTables != null) && (selectTables.Count > 0)) { char ch = dbName[0]; dbName = ch.ToString().ToUpper() + dbName.Substring(1, dbName.Length - 1); count = selectTables.Count; if (config.BuildMode.Contains("枚举")) { BuildTableEnumText(selectTables, config, dbName); } else { BuildTableEntityText(selectTables, config, dbName); } } } } catch (Exception exception) { CYQ.Data.Log.WriteLogToTxt(exception); } } } finally { if (OnCreateEnd != null) { OnCreateEnd(count); } } }