예제 #1
0
 private void checkLogDB()
 {
     try
     {
         bool bok = DBTools4Mysql.checkLogTable();
     }
     catch (Exception ex) {
         logger.Error(ex, "创建日志表失败");
         MessageBox.Show(ex.Message);
     }
 }
예제 #2
0
        private bool checkConfDB()
        {
            bool bok = false;

            try
            {
                bok = DBTools4Mysql.checkConfigTable();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "创建配置表失败");
                MessageBox.Show(ex.Message);
            }
            return(bok);
        }
예제 #3
0
 private void TestDBLink(object sender, EventArgs e)
 {
     if (configM != null && !string.IsNullOrEmpty(CURR_DBConf))
     {
         if (string.IsNullOrEmpty(DBTools4Mysql.DBLink))
         {
             DBTools4Mysql.DBLink = CURR_DBConf;
         }
         string bgtime = DBTools4Mysql.GetSearchBgTime(configM.Sid);
         MessageBox.Show(string.Format("获取到任务开始查询时间{0}", bgtime));
     }
     else
     {
         MessageBox.Show("没有数据库配置信息!");
     }
 }
예제 #4
0
        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;
                        DBTools4Mysql.DBLink = CURR_DBConf;
                        bool bok = checkConfDB();
                        if (bok)
                        {
                            DBTools4Mysql.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);
            }
        }