コード例 #1
0
        /// <summary>
        /// Get purge log status
        /// </summary>
        /// <param name="cond"></param>
        /// <returns></returns>
        public ActionResult CMS240_GetStatus(CMS240_ScreenParameter cond)
        {
            ObjectResultData res = new ObjectResultData();

            res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;

            List <CMS240_PurgeLogDataDetail> listPurgeLogFailDetail = new List <CMS240_PurgeLogDataDetail>();

            CMS240_Status status = new CMS240_Status();

            try
            {
                if (ModelState.IsValid == false)
                {
                    ValidatorUtil.BuildErrorMessage(res, this);
                    if (res.IsError)
                    {
                        return(Json(res));
                    }
                }

                ICommonHandler hand = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                List <DataEntity.Common.doSystemStatus> lstSystemStatus = hand.GetSystemStatus();
                bool bSuspendFlag = false;
                if (lstSystemStatus.Count > 0)
                {
                    bSuspendFlag = (lstSystemStatus[0].SuspendFlag == FlagType.C_FLAG_ON);
                }

                status.SuspendFlag = bSuspendFlag;
                status.MonthYear   = cond.MonthYear;


                ILogHandler  logHandler   = ServiceContainer.GetService <ILogHandler>() as ILogHandler;
                List <dtTPL> lstLogHeader = logHandler.GetTbt_Purgelog(cond.MonthYear);


                List <dtMonthYear> lstLogMonthYear = logHandler.GetLogMonthYear();
                status.IsExistInTransLog = true;
                if (lstLogMonthYear.Count > 0)
                {
                    List <dtMonthYear> t = (from p in lstLogMonthYear where p.MonthYear.Value.CompareTo(cond.MonthYear.Value) == 0
                                            select p).ToList <dtMonthYear>();

                    if (t.Count == 0) // 0 mean not exist
                    {
                        status.IsExistInTransLog = false;
                    }
                }


                if (lstLogHeader.Count > 0)
                {
                    //// Misc Mapping (#1)
                    //MiscTypeMappingList miscList = new MiscTypeMappingList();
                    //miscList.AddMiscType(lstLogHeader.ToArray());
                    //ICommonHandler comHandler = ServiceContainer.GetService<ICommonHandler>() as ICommonHandler;
                    //comHandler.MiscTypeMappingList(miscList);

                    // 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);

                    lstLogHeader[0].PurgeStatusName = handlerComm.GetMiscDisplayValue(MiscTypeList, MiscType.C_BATCH_STATUS, lstLogHeader[0].PurgeStatus);

                    // 1. Keep purge status , fail****
                    // 2. Create data list (PurgeLogDataDetail) from xml (column ErrorDescription)

                    bool isShowPurgeLogDataDetail = (lstLogHeader[0].PurgeStatus == BatchStatus.C_BATCH_STATUS_FAILED);

                    status.isShowPurgeLogDataDetail = isShowPurgeLogDataDetail;
                    status.PurgeStatusName          = lstLogHeader[0].PurgeStatusName;
                    status.PurgeStatus = lstLogHeader[0].PurgeStatus;
                    status.xml         = lstLogHeader[0].ErrorDescription;
                }

                UpdateScreenObject(status);
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            res.ResultData = status;

            return(Json(res));
        }