コード例 #1
0
        /// <summary>
        /// Perform purge log
        /// </summary>
        /// <returns></returns>
        public ActionResult CMS240_PurgeLog()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                CMS240_Status cms240_status_param = GetScreenObject <CMS240_Status>();

                //Write log for start purging log
                ILogHandler hand = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                hand.WriteWindowLog(EventType.C_EVENT_TYPE_INFORMATION, "Purge log process is started", EventID.C_EVENT_ID_REPORT_PURGE_LOG);

                //Call CMP030: Purge log process
                DateTime            dtime = cms240_status_param.MonthYear.HasValue ? cms240_status_param.MonthYear.Value : DateTime.Now;
                List <tbt_PurgeLog> pl    = hand.DeleteLog(cms240_status_param.MonthYear.Value);


                if (pl.Count > 0)
                {
                    if (pl[0].PurgeStatus == BatchStatus.C_BATCH_STATUS_SUCCEEDED)
                    {
                        cms240_status_param.IsPurgeSucceeded = true;
                        hand.WriteWindowLog(EventType.C_EVENT_TYPE_INFORMATION, "Purge log is finish", EventID.C_EVENT_ID_REPORT_PURGE_LOG);
                    }
                    else
                    {
                        cms240_status_param.IsPurgeSucceeded = false;
                        hand.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, "There are some error at purge log", EventID.C_EVENT_ID_REPORT_PURGE_LOG);
                    }


                    // update status
                    cms240_status_param.PurgeStatus     = pl[0].PurgeStatus;
                    cms240_status_param.PurgeStatusName = "";


                    // Misc Mapping (#2)
                    ICommonHandler        handlerComm  = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                    List <doMiscTypeCode> MiscTypeCode = new List <doMiscTypeCode>();
                    List <string>         lsFieldNames = new List <string>();
                    lsFieldNames.Add(MiscType.C_BATCH_STATUS);
                    List <doMiscTypeCode> MiscTypeList = handlerComm.GetMiscTypeCodeListByFieldName(lsFieldNames);

                    cms240_status_param.PurgeStatusName = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_BATCH_STATUS, cms240_status_param.PurgeStatus);
                }

                res.ResultData = cms240_status_param;
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }