Ejemplo n.º 1
0
        // Resume/Suspend Now

        /// <summary>
        /// Method for Resume/Suspend system immediately
        /// </summary>
        /// <param name="UpdateType"></param>
        /// <returns></returns>
        public ActionResult CMS040_UpdateSystemStatus(string UpdateType)
        {
            bool bResult = false;

            try
            {
                ICommonHandler handler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                if (UpdateType == "SUSPEND")
                {
                    bResult = handler.UpdateSystemStatus(true, true, CommonUtil.dsTransData.dtUserData.EmpNo);
                }
                else if (UpdateType == "RESUME")
                {
                    bResult = handler.UpdateSystemStatus(false, true, CommonUtil.dsTransData.dtUserData.EmpNo);
                }


                List <doSystemStatus> l    = new List <doSystemStatus>();
                doSystemStatus        item = new doSystemStatus();

                var list = handler.GetSystemStatus();

                if (list.Count > 0)
                {
                    string strOnline  = CommonUtil.GetLabelFromResource("Common", "CMS040", "lblOnline");;
                    string strOffline = CommonUtil.GetLabelFromResource("Common", "CMS040", "lblOffline");


                    item.CompleteFlag               = bResult;
                    item.UpdateType                 = UpdateType;
                    item.SystemStatus               = (list[0].SuspendFlag == true) ? "Offline" : "Online";
                    item.SystemStatusDisplayName    = (list[0].SuspendFlag == true) ? strOffline : strOnline;
                    item.NextResumeServiceDateTime  = ((DateTime)list[0].ResumeServiceDateTime).ToString("dd-MMM-yyyy HH:mm:ss");
                    item.NextSuspendServiceDateTime = ((DateTime)list[0].SuspendServiceDateTime).ToString("dd-MMM-yyyy HH:mm:ss");
                    l.Add(item);
                }

                return(Json(l));
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Ejemplo n.º 2
0
        public ActionResult CMS040()
        {
            try
            {
                ICommonHandler handler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
                var            list    = handler.GetSystemStatus();

                //list[0].SuspendFlag
                //list[0].ResumeServiceDateTime
                //list[0].SuspendServiceDateTime



                string strOnline  = CommonUtil.GetLabelFromResource("Common", "CMS040", "lblOnline");;
                string strOffline = CommonUtil.GetLabelFromResource("Common", "CMS040", "lblOffline");

                ViewBag.SystemStatus               = (list[0].SuspendFlag == true) ? strOffline : strOnline;
                ViewBag.SystemStatusName           = (list[0].SuspendFlag == true) ? "OFFLINE" : "ONLINE";
                ViewBag.NextResumeServiceDateTime  = ((DateTime)list[0].ResumeServiceDateTime).ToString("dd-MMM-yyyy HH:mm:ss");
                ViewBag.NextSuspendServiceDateTime = ((DateTime)list[0].SuspendServiceDateTime).ToString("dd-MMM-yyyy HH:mm:ss");

                // for set default at combobox NextResumeServiceTime , NextSuspendServiceTime
                DateTime t        = DateTime.Now;
                DateTime datNSPST = ((DateTime)list[0].SuspendServiceDateTime);
                DateTime datNRST  = ((DateTime)list[0].ResumeServiceDateTime);

                DateTime datNextSuspendServiceTime = new DateTime(t.Year, t.Month, t.Day, datNSPST.Hour, datNSPST.Minute, 0);
                DateTime datNextResumeServiceTime  = new DateTime(t.Year, t.Month, t.Day, datNRST.Hour, datNRST.Minute, 0);

                ViewBag.NextSuspendServiceTime = datNextSuspendServiceTime.ToString();
                ViewBag.NextResumeServiceTime  = datNextResumeServiceTime.ToString();

                return(View());
            }
            catch (Exception ex)
            {
                ObjectResultData res = new ObjectResultData();
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Ejemplo n.º 3
0
        ///<summary>
        ///Purpose:
        ///     Get system status  - Resume system
        ///
        ///Pre-Condition
        ///     Current date: 04/08/2011
        ///     Current time: 15:00
        ///
        ///Expected:
        ///     SuspendFlag : 0
        ///     ResumeServiceDateTime: 04/08/2011  18:00:00
        ///     SuspendServiceDateTime: 05/08/2011  9:00:00
        ///
        ///</summary>
        public string Case2()
        {
            ICommonHandler        target   = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;
            List <doSystemStatus> expected = new List <doSystemStatus>();
            doSystemStatus        status   = new doSystemStatus();

            status.SuspendFlag            = false;
            status.ResumeServiceDateTime  = new DateTime(2011, 8, 4, 18, 0, 0);
            status.SuspendServiceDateTime = new DateTime(2011, 8, 5, 9, 0, 0);

            List <doSystemStatus> actual = null;

            try {
                actual = target.GetSystemStatus();
            } catch (ApplicationErrorException ex) {
                actual = null;
            } catch (Exception ex) {
                actual = null;
            }

            return(string.Format(RESULT_FORMAT, 2, expected, actual, CompareResult_Object(expected, actual)));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Method for update Resume/Suspend system schedule
        /// </summary>
        /// <param name="UpdateType"></param>
        /// <param name="ServiceUpdateTime"></param>
        /// <returns></returns>
        public ActionResult CMS040_UpdateSystemConfig(string UpdateType, DateTime ServiceUpdateTime)
        {
            string strServiceUpdateTime = ServiceUpdateTime.ToString("HH:mm"); // What's type of format ?? --> "HH:mm"
            bool   bResult = false;

            ObjectResultData res = new ObjectResultData();

            try
            {
                ICommonHandler handler = ServiceContainer.GetService <ICommonHandler>() as ICommonHandler;

                var    currentStatus      = handler.GetSystemStatus();
                string strNextResumeTime  = ((DateTime)currentStatus[0].ResumeServiceDateTime).ToString("HH:mm");
                string strNextSuspendTime = ((DateTime)currentStatus[0].SuspendServiceDateTime).ToString("HH:mm");

                if (UpdateType == "SUSPEND")
                {
                    if (strServiceUpdateTime == strNextResumeTime)
                    {
                        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0029);
                        return(Json(res));
                    }

                    bResult = handler.UpdateSystemConfig(ConfigName.C_CONFIG_SUSPEND_SERVICE_TIME, strServiceUpdateTime);
                }
                else if (UpdateType == "RESUME")
                {
                    if (strServiceUpdateTime == strNextSuspendTime)
                    {
                        res.MessageType = MessageModel.MESSAGE_TYPE.WARNING;
                        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0030);
                        return(Json(res));
                    }

                    bResult = handler.UpdateSystemConfig(ConfigName.C_CONFIG_RESUME_SERVICE_TIME, strServiceUpdateTime);
                }

                List <doSystemStatus> l    = new List <doSystemStatus>();
                doSystemStatus        item = new doSystemStatus();

                var list = handler.GetSystemStatus();

                if (list.Count > 0)
                {
                    string strOnline  = CommonUtil.GetLabelFromResource("Common", "CMS040", "lblOnline");;
                    string strOffline = CommonUtil.GetLabelFromResource("Common", "CMS040", "lblOffline");

                    item.CompleteFlag               = bResult;
                    item.UpdateType                 = UpdateType;
                    item.SystemStatus               = (list[0].SuspendFlag == true) ? "Offline" : "Online";
                    item.SystemStatusDisplayName    = (list[0].SuspendFlag == true) ? strOffline : strOnline;
                    item.NextResumeServiceDateTime  = ((DateTime)list[0].ResumeServiceDateTime).ToString("dd-MMM-yyyy HH:mm:ss");
                    item.NextSuspendServiceDateTime = ((DateTime)list[0].SuspendServiceDateTime).ToString("dd-MMM-yyyy HH:mm:ss");


                    l.Add(item);
                }

                return(Json(l));
            }
            catch (Exception ex)
            {
                res.MessageType = MessageModel.MESSAGE_TYPE.INFORMATION;
                res.AddErrorMessage(ex);
                return(Json(res));
            }
        }
Ejemplo n.º 5
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));
        }