public static DBInfoModel GetBDList() { DBInfoModel model = new DBInfoModel(); XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(Path.Combine(Environment.CurrentDirectory, "AppData", "DBLinkInfo.xml")); XmlNodeList xnList = xmlDoc.SelectNodes("DBInfoList/DBInfo"); if (xnList != null && xnList.Count > 0) { foreach (XmlNode node in xnList) { DBInfo info = new DBInfo() { DBName = node["DBName"].InnerText, Port = node["Port"].InnerText, Pwd = node["Pwd"].InnerText, Server = node["Server"].InnerText, Type = (DBEnum)Enum.Parse(typeof(DBEnum), node["Type"].InnerText), Uid = node["Uid"].InnerText }; GetTableList(info); model.DBInfoList.Add(info); } } return(model); }
/// <summary> /// IF Exist Update Else Add /// </summary> /// <param name="model"></param> public DBInfoModel Add(DBInfoModel model) { if (ExistDBInfo(model.ServerName, model.DBName)) { DBInfoModel existModel = DBInfoList.Find(new Predicate <DBInfoModel>((m) => { return(m.UniqueID() == model.UniqueID()); })); if (existModel != null) { existModel.ServerName = model.ServerName; existModel.UserID = model.UserID; existModel.Password = model.Password; existModel.DBName = model.DBName; return(existModel); } else { DBInfoList.Add(model); return(model); } } else { DBInfoList.Add(model); return(model); } }
public ABMainForm(AutoBuildEntityContent abContent) { InitializeComponent(); ABContent = abContent; DBInfo = GetDBLink.GetBDList(); BindData(DBInfo); OutputWindowHelper.OutPutMessage("数据已加载完成"); }
public BEMainForm(BuildEverythingContent beContent) { InitializeComponent(); BEContent = beContent; InitFiles(); DBInfo = new GetDBLink().GetBDList(BEContent.SelectedProject.ABEPath); BindData(); OutPutMsg($"资源配置地址:{BEContent.SelectedProject.RootPath}"); OutPutMsg("数据已加载完成..."); }
private void cbxServerNames_SelectedIndexChanged(object sender, EventArgs e) { DBInfoModel dbInfo = cbxServerNames.SelectedItem as DBInfoModel; if (dbInfo == null) { return; } tbxUserID.Text = dbInfo.UserID; tbxPassword.Text = dbInfo.Password; tbxDBName.Text = dbInfo.DBName; }
/// <summary> /// 数据绑定 /// </summary> /// <param name="model"></param> /// <param name="tview"></param> private void BindData(DBInfoModel model) { foreach (DBInfo info in model.DBInfoList) { TreeNode node = new TreeNode(); node.ImageKey = "database.png"; node.SelectedImageKey = "database.png"; node.Name = info.DBName; node.Text = info.DBName; foreach (var table in info.TableStruList.Select(s => s.TableName).Distinct()) { TreeNode subNode = new TreeNode() { Name = table, Text = table, ImageKey = "table.png", SelectedImageKey = "table.png" }; node.Nodes.Add(subNode); } tv_DBList.Nodes.Add(node); } cbx_Folder.DataSource = ABContent.SelectedProject.FolderNames; }