/// <summary> /// 读取json文件。z /// </summary> public void readServerInfo() { List <Server_Info> jsonSqls = jsonServer_Info.ReadListJson(); if (jsonSqls != null && jsonSqls.Count > 0) { Server_Info server_Info = jsonSqls[0]; this.mtb_server_name.Text = server_Info.serverName; //0-Windows身份验证 1-SQL Server身份验证 this.mcb_authentication.SelectedIndex = server_Info.authentication; this.mtb_login_name.Text = server_Info.login_name; this.mtb_login_pwd.Text = server_Info.login_pwd; } }
public static bool LoadServerListFromText(string Path) { m_ServerList.Clear(); StreamReader sr; try{ sr = File.OpenText(Path); } catch (Exception e) { //路径与名称未找到文件则直接返回空 return(false); } string line; Server_Info Info = new Server_Info(); while ((line = sr.ReadLine()) != null) { if (line.StartsWith("ServerName")) { Info.ServerName = line.Replace("ServerName = ", ""); } if (line.StartsWith("ServerId")) { Info.ServerID = int.Parse(line.Replace("ServerId = ", "")); } if (line.StartsWith("ServerIp")) { Info.iP = line.Replace("ServerIp = ", ""); } if (line.StartsWith("ServerPort")) { Info.Port = int.Parse(line.Replace("ServerPort = ", "")); ServerInfo v = new ServerInfo(); v.iP = Info.iP; v.Port = Info.Port; v.ServerID = Info.ServerID; v.ServerName = Info.ServerName; m_ServerList.Add(v); } } //关闭流 sr.Close(); //销毁流 sr.Dispose(); return(true); }
public bool SaveLogingInfo() { string serverName = this.mtb_server_name.Text.Trim(); //0-Windows身份验证 1-SQL Server身份验证 int auth = this.mcb_authentication.SelectedIndex; string loginName = this.mtb_login_name.Text.Trim(); string pwd = this.mtb_login_pwd.Text.Trim(); Server_Info server_Info = new Server_Info(); server_Info.authentication = auth; server_Info.serverName = serverName; server_Info.login_name = loginName; server_Info.login_pwd = pwd; jsonServer_Info.WriteJsonUnAppend(server_Info); return(default(bool)); }