示例#1
0
 private void UpLoadProData()
 {
     try
     {
         string sql = "";
         if (bids)
         {
             string   s1  = makeSql1();
             string[] s11 = ids.Split(',');
             s1 += " where (docketno=" + s11[0];
             for (int i = 1; i < s11.Length; i++)
             {
                 s1 += " or docketno=" + s11[i];
             }
             s1 += ")";
             sql = s1;
         }
         else
         {
             string s1  = string.Format(rsql, bgtime, edtime);
             string log = "{0}-->开始执行任务,查询区间{1}===={2}";
             log = string.Format(log, Tools.Now(), bgtime, edtime);
             logger.Info("任务开始执行:" + s1);//执行sql查询
             jd.ExecUpload(log);
             sql = s1;
         }
         jd.ExecUpload(sql);
         List <JObject> list = null;
         try
         {
             list = DBTools.Query(sql);
             int size = 0;
             if (list != null && list.Count > 0)
             {
                 List <JObject> listup = new List <JObject>();
                 foreach (JObject obj in list)
                 {
                     JToken jto = obj.GetValue("prodno");
                     if (!DBTools.checkRecordUped(jto.ToString()))
                     {
                         size++;
                         obj.Add("scm", cURR_SCM);
                         obj.Add("mconfigid", configM.Sid);
                         listup.Add(obj);
                     }
                     if (listup.Count >= 10)
                     {
                         string sup = JsonConvert.SerializeObject(listup);
                         logger.Info("开始执行上传:" + sup);
                         jd.ExecUpload(Tools.Now() + "小组开始执行上传:" + listup.Count);
                         sup = Tools.EncodeBase64("UTF-8", sup);
                         sup = Tools.EscapeExprSpecialWord(sup);
                         Tools.HttpPostInfo(url + ICL.API_KEY, UP_KEY + sup);
                         jd.ExecUpload(Tools.Now() + "==>小组完成上传:" + listup.Count);
                         logger.Info("小组执行完成:" + sup);
                         logger.Info("开始写小组日志:");
                         DBTools.WriteSysUpLog(listup);
                         jd.ExecUpload(Tools.Now() + " 写日志表");
                         listup.Clear();
                     }
                 }
                 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 + ICL.API_KEY, UP_KEY + sup);
                     logger.Info("尾数执行完成:" + sup);
                     logger.Info("开始写尾数日志:");
                     DBTools.WriteSysUpLog(listup);
                     listup.Clear();
                 }
                 logger.Info(string.Format(Tools.Now() + "本次执行完成,上传总条数【{0}】", size));
             }
             else
             {
                 logger.Info("没有查询到数据;");
             }
             jd.ExecUpload(string.Format(Tools.Now() + "-->任务执行完成【{0}】", size));
         }
         catch (Exception ex)
         {
             logger.Error("错误SQL:" + sql);
             logger.Error(ex, "执行查询出错");
             jd.ExecUpload(Tools.Now() + "-->任务执行报错:" + ex.Message);
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "上传出错!");
         jd.ExecUpload(ex.Message);
     }
 }
示例#2
0
 private void QueryData(string sql)
 {
     try
     {
         logger.Info("开始执行查询:" + sql);
         UpdateTxtMsgContent("开始执行查询:" + sql);
         List <JObject> list = DBTools.Query(sql);
         int            size = 0;
         if (list != null && list.Count > 0)
         {
             List <JObject> listup = new List <JObject>();
             foreach (JObject obj in list)
             {
                 JToken jto = obj.GetValue("prodno");
                 if (!DBTools.checkRecordUped(jto.ToString()))
                 {
                     size++;
                     obj.Add("scm", CURR_SCM);
                     obj.Add("mconfigid", configM.Sid);
                     listup.Add(obj);
                 }
                 if (listup.Count >= 10)
                 {
                     string sup = JsonConvert.SerializeObject(listup);
                     logger.Info("开始执行上传:" + sup);
                     sup = Tools.EncodeBase64("UTF-8", sup);
                     sup = Tools.EscapeExprSpecialWord(sup);
                     Tools.HttpPostInfo(CURR_URI + ICL.API_KEY, UP_KEY + sup);
                     logger.Info("小组执行完成:" + sup);
                     logger.Info("开始写小组日志:");
                     DBTools.WriteSysUpLog(listup);
                     listup.Clear();
                 }
             }
             if (listup.Count > 0)
             {
                 string sup = JsonConvert.SerializeObject(listup);
                 logger.Info("开始执行尾数上传:" + sup);
                 sup = Tools.EncodeBase64("UTF-8", sup);
                 sup = Tools.EscapeExprSpecialWord(sup);
                 Tools.HttpPostInfo(CURR_URI + ICL.API_KEY, UP_KEY + sup);
                 logger.Info("尾数执行完成:" + sup);
                 logger.Info("开始写尾数日志:");
                 DBTools.WriteSysUpLog(listup);
                 listup.Clear();
             }
             string s1 = string.Format("本次执行完成,上传总条数【{0}】", size);
             logger.Info(s1);
             UpdateTxtMsgContent(s1);
         }
         else
         {
             logger.Info("没有查询到数据;");
             UpdateTxtMsgContent("没有查询到数据;");
         }
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
         logger.Error(ex);
     }
 }