private void TestDBLink(object sender, EventArgs e)
 {
     if (configM != null && !string.IsNullOrEmpty(CURR_DBConf))
     {
         if (string.IsNullOrEmpty(DBTools.DBLink))
         {
             DBTools.DBLink = CURR_DBConf;
         }
         string bgtime = DBTools.GetSearchBgTime(configM.Sid);
         MessageBox.Show(string.Format("获取到任务开始查询时间{0}", bgtime));
     }
     else
     {
         MessageBox.Show("没有数据库配置信息!");
     }
 }
Example #2
0
 private void UpLoadWeightData(object sender, ElapsedEventArgs e)
 {
     if (canRun)
     {
         canRun = false;
         try
         {
             string   bgtime = DBTools.GetSearchBgTime(configM.Sid);
             DateTime d1     = DateTime.Now;
             int      jgmin  = -configM.Inter;
             d1 = d1.AddMinutes(jgmin);
             if (string.IsNullOrEmpty(bgtime))
             {
                 bgtime = configM.Bgtime;
             }
             string edtime = d1.ToString(ICL.DATE_FMT_L);
             //开始同步数据
             SyncDataToBakTable(edtime);
             //同步数据结束
             string s1  = string.Format(rsql, bgtime, edtime);
             string log = "{0}-->开始执行任务,查询区间{1}===={2}";
             log = string.Format(log, Tools.Now(), bgtime, edtime);
             updateTabsLogs(log);
             logger.Info("任务开始执行:" + s1);//执行sql查询
             List <JObject> list = null;
             try
             {
                 list = DBTools.Query(s1);
                 int size = 0;
                 if (list != null && list.Count > 0)
                 {
                     List <DBParams> listup = new List <DBParams>();
                     foreach (JObject obj in list)
                     {
                         DBParams param = JsonConvert.DeserializeObject <DBParams>(obj.ToString());
                         if (!DBTools.checkRecordUped(param.Bdid))
                         {
                             size++;
                             if (string.IsNullOrEmpty(param.Sbid))
                             {
                                 param.Sbid = cURR_DBID;
                             }
                             if (string.IsNullOrEmpty(param.Scm))
                             {
                                 param.Scm = cURR_SCM;
                             }
                             if (string.IsNullOrEmpty(param.Sopr))
                             {
                                 param.Sopr = cURR_OPR;
                             }
                             listup.Add(param);
                         }
                         if (listup.Count >= 10)
                         {
                             string sup = JsonConvert.SerializeObject(listup);
                             logger.Info("开始执行上传:" + sup);
                             sup = Tools.EncodeBase64("UTF-8", sup);
                             sup = Tools.EscapeExprSpecialWord(sup);
                             Tools.HttpPostInfo(url + "wmdatas2", "type=210&json=" + sup);
                             logger.Info("小组执行完成:" + sup);
                             logger.Info("开始写小组日志:");
                             DBTools.WriteSysUpLog(listup);
                             listup.Clear();
                             Thread.Sleep(5);
                         }
                     }
                     if (listup.Count > 0)
                     {
                         string sup = JsonConvert.SerializeObject(listup);
                         logger.Info("开始执行尾数上传:" + sup);
                         sup = Tools.EncodeBase64("UTF-8", sup);
                         sup = Tools.EscapeExprSpecialWord(sup);
                         Tools.HttpPostInfo(url + "wmdatas2", "type=210&json=" + sup);
                         logger.Info("尾数执行完成:" + sup);
                         logger.Info("开始写尾数日志:");
                         DBTools.WriteSysUpLog(listup);
                         listup.Clear();
                     }
                     logger.Info(string.Format("本次执行完成,上传总条数【{0}】", size));
                 }
                 else
                 {
                     logger.Info("没有查询到数据;");
                 }
                 DBTools.insertOrUpDate(configM.Sid, edtime);
                 updateTabsLogs(string.Format(Tools.Now() + "-->任务执行完成【{0}】", size));
             }
             catch (Exception ex)
             {
                 logger.Error("错误SQL:" + s1);
                 logger.Error(ex, "执行查询出错");
                 updateTabsLogs(Tools.Now() + "-->任务执行报错:" + ex.Message);
             }
         }
         catch (Exception ex)
         {
             logger.Error(ex, "上传出错!");
         }
         finally {
             canRun = true;
         }
     }
 }