コード例 #1
0
        /// <summary>
        /// 添加Job执行日志
        /// </summary>
        /// <param name="jobLog"></param>
        private static void OnLogCreate(BackgroundJobLog jobLog)
        {
            var bsonDoc = new BsonDocument
            {
                { "jobId", jobLog.jobId },
                { "jobType", jobLog.jobType },
                { "name", jobLog.name },
                { "runLog", jobLog.runLog },
                { "executionTime", jobLog.executionTime },
                { "executionDuration", jobLog.executionDuration },
                { "customerCode", jobLog.customerCode },
                { "createDate", DateTime.Now.ToString("yyy-MM-dd HH:mm:ss") },
                { "clientInfo", jobLog.clientInfo }
            };

            try
            {
                var result = jobLogBll.CreateLogQuick(bsonDoc);
                var msg    = result.Status == Status.Successful ? "成功" : "失败";
                if (result.Status != Status.Successful)
                {
                    CallBack.OnExecFail(idMap["2"], 1, result.Message, jobLog.ToJson());
                }
                else
                {
                    queueMap["2"].SuccessTime = DateTime.Now;
                }
                var message = ($"{bsonDoc.Text("name")}_{bsonDoc.Text("jobId")}处理结果:{msg}\n");
                ShowMessageInfo("OnLogCreate", message);
            }
            catch (Exception e)
            {
                CallBack.OnExecFail(idMap["2"], 0, e.ToString(), jobLog.ToJson());
            }
        }
コード例 #2
0
 /// <summary>
 /// 业务数据分析
 /// </summary>
 /// <param name="jobLog"></param>
 private static void OnDataAnalyse(BackgroundJobLog jobLog)
 {
     try
     {
         var content     = jobLog.runLog;
         var bsonContent = new BsonDocument();
         if (!string.IsNullOrEmpty(content))
         {
             bsonContent = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(content);
             var json = ReceiveSaveData.SaveData(bsonContent.String("execData"), jobLog.customerCode);
             content = json.Message;
             if (json.Success == false)
             {
                 CallBack.OnExecFail(idMap["1"], 1, json.Message, jobLog.ToJson());
             }
             else
             {
                 queueMap["1"].SuccessTime = DateTime.Now;
             }
         }
         var message = ($"处理结果:{jobLog.jobId}_{jobLog.customerCode}:{content}\n");
         ShowMessageInfo("OnDataAnalyse", message);
     }
     catch (Exception e)
     {
         CallBack.OnExecFail(idMap["1"], 0, e.ToString(), jobLog.ToJson());
     }
 }
コード例 #3
0
 /// <summary>
 /// 处理系统健康状态
 /// </summary>
 /// <param name="jobLog"></param>
 private static void OnSystemHealth(BackgroundJobLog jobLog)
 {
     if (jobLog != null)
     {
         try
         {
             var bsonDoc = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <BsonDocument>(jobLog.runLog);
             if (bsonDoc != null)
             {
                 if (!string.IsNullOrEmpty(bsonDoc.Text("execData")))
                 {
                     var messageInfo = MongoDB.Bson.Serialization.BsonSerializer.Deserialize <PushMessageInfo>(bsonDoc.Text("execData"));
                     jobLogBll.ProcessPushMessageInfo(messageInfo);
                 }
             }
             var message = ($"{jobLog.jobId}{jobLog.name}{jobLog.customerCode}{jobLog.runLog}\n");
             ShowMessageInfo("OnSystemHealth", message);
         }
         catch (Exception e)
         {
             CallBack.OnExecFail(idMap["4"], 0, e.ToString(), jobLog.ToJson());
         }
     }
 }