Пример #1
0
        /// <summary>
        /// Get all batch process status
        /// </summary>
        /// <returns></returns>
        public ActionResult CMS050_SearchResponse()
        {
            List <dtBatchProcess>      list = new List <dtBatchProcess>();
            List <View_dtBatchProcess> nlst = new List <View_dtBatchProcess>();
            ObjectResultData           res  = new ObjectResultData();

            try
            {
                ILogHandler handler = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                list = handler.GetBatchProcessDataList(ConfigName.C_CONFIG_SUSPEND_FLAG,
                                                       MiscType.C_BATCH_STATUS,
                                                       MiscType.C_BATCH_LAST_RESULT,
                                                       BatchStatus.C_BATCH_STATUS_PROCESSING,
                                                       FlagType.C_FLAG_ON,
                                                       FlagType.C_FLAG_OFF);



                // Select by language
                nlst = CommonUtil.ConvertObjectbyLanguage <dtBatchProcess, View_dtBatchProcess>(list, "BatchStatusName", "BatchLastResultName");

                // tt
                if (BatchProcessUtil.CheckJobRunning("SECOM_AJIS_BatchAll") == true)
                {
                    foreach (var item in nlst)
                    {
                        item.EnableRun = false;
                    }
                }
            }
            catch (Exception ex)
            {
                nlst = new List <View_dtBatchProcess>();
                res.AddErrorMessage(ex);
                return(Json(res));
            }

            res.ResultData = CommonUtil.ConvertToXml <View_dtBatchProcess>(nlst, "Common\\CMS050", CommonUtil.GRID_EMPTY_TYPE.SEARCH);
            return(Json(res));
        }
Пример #2
0
        public void Execute(JobExecutionContext context)
        {
            JobDataMap dataMap = context.JobDetail.JobDataMap;

            tbs_BatchQueue    batchQueue          = dataMap.Get("BatchQueue") as tbs_BatchQueue;
            QueueStatusUpdate queueUpdateCallBack = dataMap.Get("QueueStatusUpdateCallBack") as QueueStatusUpdate;

            if (batchQueue == null)
            {
                return;
            }

            ICommonHandler       commonHandler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            ILogHandler          logHandler    = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
            IBatchProcessHandler batchhandler  = ServiceContainer.GetService <IBatchProcessHandler>() as IBatchProcessHandler;
            List <string>        message       = new List <string>();

            batchQueue.Status     = "R";
            batchQueue.StartTime  = DateTime.Now;
            batchQueue.LastUpdate = DateTime.Now;
            batchQueue.Remark     = null;

            commonHandler.UpdateTbs_BatchQueue(CommonUtil.ConvertToXml_Store <tbs_BatchQueue>(new List <tbs_BatchQueue>()
            {
                batchQueue
            }));
            if (queueUpdateCallBack != null)
            {
                queueUpdateCallBack(batchQueue);
            }

            var callback = new BatchCallBackDel(batchhandler.BatchUpdateStatus);

            try
            {
                foreach (string tmpBatchCode in batchQueue.BatchCode.Split(','))
                {
                    var batchCode = tmpBatchCode.Trim();

                    var lstAllBatches = logHandler.GetBatchProcessDataList(
                        ConfigName.C_CONFIG_SUSPEND_FLAG,
                        MiscType.C_BATCH_STATUS,
                        MiscType.C_BATCH_LAST_RESULT,
                        BatchStatus.C_BATCH_STATUS_PROCESSING,
                        FlagType.C_FLAG_ON,
                        FlagType.C_FLAG_OFF
                        );

                    var batchInfo = lstAllBatches.Where(b => b.BatchCode == batchCode).FirstOrDefault();

                    if (batchInfo == null)
                    {
                        message.Add(string.Format("BatchCode: {0} | Action: Skipped | Remark: Missing from sp_CM_GetBatchProcessDataList", batchCode));
                        continue;
                    }

                    if (!(batchInfo.EnableRun ?? false))
                    {
                        message.Add(string.Format("BatchCode: {0} | Action: Skipped | Remark: EnableRun = False", batchCode));
                        continue;
                    }

                    batchQueue.LastUpdate = DateTime.Now;
                    batchQueue.Remark     = "Running BatchCode : " + batchCode;

                    commonHandler.UpdateTbs_BatchQueue(CommonUtil.ConvertToXml_Store <tbs_BatchQueue>(new List <tbs_BatchQueue>()
                    {
                        batchQueue
                    }));
                    if (queueUpdateCallBack != null)
                    {
                        queueUpdateCallBack(batchQueue);
                    }

                    message.Add(string.Format("BatchCode: {0} | Action: Start | Remark: " + DateTime.Now.ToString(), batchCode));

                    this.RunProcess(batchInfo, "INITIAL", DateTime.Now, callback);

                    message.Add(string.Format("BatchCode: {0} | Action: Finished | Remark: " + DateTime.Now.ToString(), batchCode));
                }

                batchQueue.Status     = "C";
                batchQueue.EndTime    = DateTime.Now;
                batchQueue.LastUpdate = DateTime.Now;
                batchQueue.Remark     = string.Join("\r\n", message);

                commonHandler.UpdateTbs_BatchQueue(CommonUtil.ConvertToXml_Store <tbs_BatchQueue>(new List <tbs_BatchQueue>()
                {
                    batchQueue
                }));
                if (queueUpdateCallBack != null)
                {
                    queueUpdateCallBack(batchQueue);
                }
            }
            catch (Exception ex)
            {
                message.Add("ERROR: " + ex.ToString());

                batchQueue.Status  = "E";
                batchQueue.EndTime = DateTime.Now;
                batchQueue.Remark  = string.Join("\n", message);

                commonHandler.UpdateTbs_BatchQueue(CommonUtil.ConvertToXml_Store <tbs_BatchQueue>(new List <tbs_BatchQueue>()
                {
                    batchQueue
                }));
                if (queueUpdateCallBack != null)
                {
                    queueUpdateCallBack(batchQueue);
                }
            }
        }