private void DBDataUpForm_Load(object sender, EventArgs e) { MakeCircle(); if (iniFile.ExistINIFile()) { string uri = iniFile.IniReadValue(ICL.SERV_LAB, ICL.SERV_URI); tb_uri.Text = uri + ""; CURR_URI = uri; string sid = iniFile.IniReadValue(ICL.SERV_LAB, ICL.SERV_SID); tb_conf_id.Text = sid; string conf = iniFile.IniReadValue(ICL.SERV_LAB, ICL.SERV_SCONF); if (!string.IsNullOrEmpty(conf)) { try { conf = Tools.DecodeBase64("UTF-8", conf); configM = JsonConvert.DeserializeObject <DBConfigM>(conf); } catch (Exception ex) { logger.Error(ex, "加载ini文件读取conf错误!!"); MessageBox.Show("非法串改配置文件数据"); } } string dblink = iniFile.IniReadValue(ICL.DB_LAB, ICL.DB_DBLINK); if (!string.IsNullOrEmpty(dblink)) { DBToolsAccess.DBLink = dblink; CURR_DBConf = dblink; } string opr = iniFile.IniReadValue(ICL.LOCL_LAB, ICL.LOCL_OPR); if (!string.IsNullOrEmpty(opr)) { tb_opr.Text = opr; CURR_OPR = opr; } string scm = iniFile.IniReadValue(ICL.LOCL_LAB, ICL.LOCL_SCM); if (!string.IsNullOrEmpty(scm)) { tb_scm.Text = scm; CURR_SCM = scm; } string dbid = iniFile.IniReadValue(ICL.LOCL_LAB, ICL.LOCL_DBID); if (!string.IsNullOrEmpty(dbid)) { tb_dbid.Text = dbid; CURR_DBID = dbid; } string loc = iniFile.IniReadValue(ICL.LOCL_LAB, ICL.LOCL_DIR); CURR_DIR = loc; tb_loc.Text = loc; string rm = iniFile.IniReadValue(ICL.LOCL_LAB, ICL.LOCL_RM); CURR_DIR = rm; tb_rm.Text = rm; WindowState = FormWindowState.Minimized; this.Hide(); notifyIcon1.Visible = true; ExcuteTask(); } }
private void GetServerConfigInfo(object sender, EventArgs e) { string url = tb_uri.Text; if (string.IsNullOrEmpty(url) && string.IsNullOrWhiteSpace(url)) { MessageBox.Show("请输入【服务器地址】"); return; } string configId = tb_conf_id.Text; if (string.IsNullOrEmpty(configId) && string.IsNullOrWhiteSpace(configId)) { MessageBox.Show("请输入【配置Id】"); return; } string queryparam = "type=400&sid=" + configId; try { string res = Tools.HttpPostInfo(url + ICL.API_KEY, queryparam); if (!string.IsNullOrWhiteSpace(res)) { ResultInfo rInfo = JsonConvert.DeserializeObject <ResultInfo>(res); if (rInfo.Data != null) { string conf = rInfo.Data["conf"]; configM = JsonConvert.DeserializeObject <DBConfigM>(conf); string dbconf = configM.Dbconf; if (string.IsNullOrWhiteSpace(dbconf)) { MessageBox.Show("服务端没有数据库配置信息!"); return; } iniFile.IniWriteValue(ICL.DB_LAB, ICL.DB_DBLINK, configM.Dbconf); iniFile.IniWriteValue(ICL.SERV_LAB, ICL.SERV_SCONF, Tools.EncodeBase64("UTF-8", JsonConvert.SerializeObject(configM))); iniFile.IniWriteValue(ICL.SERV_LAB, ICL.SERV_URI, url); iniFile.IniWriteValue(ICL.SERV_LAB, ICL.SERV_SID, configId); CURR_URI = url; CURR_DBConf = configM.Dbconf; DBToolsAccess.DBLink = CURR_DBConf; bool bok = checkConfDB(); if (bok) { DBToolsAccess.insertOrUpDate(configM.Sid, configM.Bgtime); } checkLogDB(); tb_conf_id.Enabled = false; tb_uri.Enabled = false; } else { MessageBox.Show("没有获取到配置信息"); } } else { MessageBox.Show("没有获取到配置信息"); } } catch (Exception ex) { logger.Error(ex, "访问服务器失败"); MessageBox.Show(ex.Message); } }