private bool checkConfDB()
        {
            bool bok = false;

            try
            {
                bok = DBTools.checkConfigTable();
            }
            catch (Exception ex)
            {
                logger.Error(ex, "创建配置表失败");
                MessageBox.Show(ex.Message);
            }
            return(bok);
        }
 private void TestDBLink(object sender, EventArgs e)
 {
     if (configM != null && !string.IsNullOrEmpty(CURR_DBConf))
     {
         if (string.IsNullOrEmpty(DBTools.DBLink))
         {
             DBTools.DBLink = CURR_DBConf;
         }
         try
         {
             string bgtime = DBTools.GetSearchBgTime(configM.Sid);
             MessageBox.Show(string.Format("获取到任务开始查询时间{0}", bgtime));
         }
         catch (Exception ex) {
             MessageBox.Show(ex.Message);
         }
     }
     else
     {
         MessageBox.Show("没有数据库配置信息!");
     }
 }
 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);
     }
 }
Esempio n. 4
0
        private void UpLoadProData()
        {
            try
            {
                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);
                List <JObject> list = null;
                try
                {
                    list = DBTools.Query(s1);
                    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);
                                string url1 = @"http://8.129.40.31:8081/bip-erp/";
                                Tools.HttpPostInfo(url1 + 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);
                            string url1 = @"http://8.129.40.31:8081/bip-erp/";
                            Tools.HttpPostInfo(url1 + 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:" + s1);
                    logger.Error(ex, "执行查询出错");
                    jd.ExecUpload(Tools.Now() + "-->任务执行报错:" + ex.Message);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "上传出错!");
                jd.ExecUpload(ex.Message);
            }
        }