コード例 #1
0
        public ActionResult CMS000_RedirectScreen()
        {
            ObjectResultData res = new ObjectResultData();

            try
            {
                if (CommonUtil.dsTransData != null)
                {
                    res.ResultData = "/Common/CMS020";

                    doDirectScreen dos = CommonUtil.GetSession <doDirectScreen>("DIRECT_SCREEN");
                    if (dos != null)
                    {
                        res.ResultData = dos;
                        CommonUtil.SetSession("DIRECT_SCREEN", null);
                    }
                }
                else
                {
                    res.ResultData = "/Common/CMS010";
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }
コード例 #2
0
        /// <summary>
        /// Event on action executing for check session is expired?
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            try
            {
                bool   checkScreenSession = true;
                string action             = filterContext.RouteData.Values["action"].ToString();
                if (action == "CMS000" ||
                    action == "CMS010" ||
                    action == "Login" ||
                    action == "CMS010_CHECK" ||
                    action == "CMS020_Retrive" ||
                    action == "GetMessage" ||
                    action == "changeLanguageDsTransData" ||
                    action == "Logout" ||
                    action == "GetLanguageMessage" ||
                    action == "ClearCurrentScreenSession" ||
                    action == "CMS000_RedirectScreen" ||
                    action.ToUpper().Contains("UPLOAD") ||
                    action.ToUpper().Contains("ATTACH"))
                {
                    checkScreenSession = false;
                }

                dsTransDataModel dsTrans = CommonUtil.dsTransData;
                if (dsTrans == null)
                {
                    //if (checkScreenSession)
                    //{
                    //Check Action from ajax caller or load view
                    string ajax = filterContext.HttpContext.Request["ajax"];
                    if ((ajax == "1") &&
                        action != "CMS010" &&
                        action != "CMS010_CHECK" &&
                        action != "Login")
                    {
                        RedirectObject o = new RedirectObject();
                        o.URL = CommonUtil.GenerateURL("Common", "CMS010") + "?timeout=1";

                        JsonResult jRes = new JsonResult();
                        jRes.Data            = o;
                        filterContext.Result = jRes;
                    }
                    else if (checkScreenSession == true)
                    {
                        bool           skip = false;
                        doDirectScreen dos  = null;

                        /* *** This method will only in case url has send parameter (expect "k" parameter). *** */
                        #region Initial redirect method

                        if (action != "CMS020")
                        {
                            dos            = new doDirectScreen();
                            dos.Controller = filterContext.RouteData.Values["controller"].ToString();
                            dos.ScreenID   = action;

                            foreach (string key in filterContext.HttpContext.Request.QueryString.AllKeys)
                            {
                                if (key == "k")
                                {
                                    skip = true;
                                    break;
                                }
                                string val = filterContext.HttpContext.Request[key];
                                if (dos.Parameters == null)
                                {
                                    dos.Parameters = new List <string>();
                                    dos.Values     = new List <string>();
                                }

                                dos.Parameters.Add(key);
                                dos.Values.Add(val);
                            }
                        }

                        #endregion

                        if (skip == false && dos != null)
                        {
                            CommonUtil.SetSession("DIRECT_SCREEN", dos);

                            filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                            {
                                controller = "Common",
                                action     = "CMS000"
                            }));
                        }
                        else
                        {
                            if (action == "CMS020")
                            {
                                BaseController bController = filterContext.Controller as BaseController;
                                if (bController != null)
                                {
                                    filterContext.Result = bController.RedirectToLogin();
                                }
                            }
                            else
                            {
                                filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                                {
                                    controller = "Common",
                                    action     = "CMS010"
                                }));
                            }
                        }
                    }

                    return;
                    //}
                }
                else
                {
                    BaseController bController = filterContext.Controller as BaseController;
                    if (bController != null)
                    {
                        ScreenParameter param = bController.GetScreenObject <object>() as ScreenParameter;
                        if (param != null)
                        {
                            dsTrans.dtTransHeader.ScreenID = param.ScreenID;
                        }
                        else if (checkScreenSession)
                        {
                            bool       isInitial = false;
                            MethodInfo method    = bController.GetType().GetMethod(action);
                            if (method != null)
                            {
                                if (method.GetCustomAttributes(typeof(InitializeAttribute), true).Length > 0)
                                {
                                    isInitial = true;
                                }
                            }

                            if (action.EndsWith("_Authority") ||
                                isInitial == true)
                            {
                                dsTrans.dtTransHeader.ScreenID = action.Replace("_Authority", "");

                                /* *** This method will only in case url has send parameter (expect "k" parameter). *** */
                                #region Initial redirect method

                                if (action != "CMS020" && isInitial == true)
                                {
                                    doDirectScreen dos = new doDirectScreen();
                                    dos.Controller = filterContext.RouteData.Values["controller"].ToString();
                                    dos.ScreenID   = action;

                                    bool skip = false;
                                    foreach (string key in filterContext.HttpContext.Request.QueryString.AllKeys)
                                    {
                                        if (key == "k")
                                        {
                                            skip = true;
                                            break;
                                        }
                                        string val = filterContext.HttpContext.Request[key];
                                        if (dos.Parameters == null)
                                        {
                                            dos.Parameters = new List <string>();
                                            dos.Values     = new List <string>();
                                        }

                                        dos.Parameters.Add(key);
                                        dos.Values.Add(val);
                                    }

                                    if (skip == false)
                                    {
                                        CommonUtil.SetSession("DIRECT_SCREEN", dos);
                                        filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary(new
                                        {
                                            controller = "Common",
                                            action     = "CMS000"
                                        }));
                                    }
                                }

                                #endregion
                            }
                            else
                            {
                                if (CommonUtil.dsTransData != null)
                                {
                                    RedirectObject o = new RedirectObject();
                                    o.URL = CommonUtil.GenerateURL("Common", "CMS020");

                                    JsonResult jRes = new JsonResult();
                                    jRes.Data            = o;
                                    filterContext.Result = jRes;
                                }
                                else
                                {
                                    RedirectObject o = new RedirectObject();
                                    o.URL = CommonUtil.GenerateURL("Common", "CMS010") + "?timeout=1";

                                    JsonResult jRes = new JsonResult();
                                    jRes.Data            = o;
                                    filterContext.Result = jRes;
                                    return;
                                }
                            }
                        }
                    }

                    DateTime dateTime = DateTime.Now;
                    dateTime = dateTime.AddTicks(-(dateTime.Ticks % TimeSpan.TicksPerSecond));
                    dsTrans.dtOperationData.ProcessDateTime = dateTime;
                    dsTrans.dtOperationData.GUID            = Guid.NewGuid().ToString().ToUpper();
                    CommonUtil.dsTransData = dsTrans;
                }
                string actionUpper = action.ToUpper();
                if (actionUpper.Contains("EDIT") ||
                    actionUpper.Contains("SAVE") ||
                    actionUpper.Contains("UPDATE") ||
                    actionUpper.Contains("DELETE"))
                {
                    string[] aItem    = actionUpper.Split('_');
                    string   screenID = aItem[0];
                }
                base.OnActionExecuting(filterContext);
            }
            catch
            {
            }
        }
コード例 #3
0
        /// <summary>
        /// Check username and password.<br />
        /// Check is Employee No. active.<br />
        /// Get user default language.<br/>
        /// Refresh user data.
        /// </summary>
        /// <param name="Cond"></param>
        /// <returns></returns>
        public ActionResult Login(doLogin Cond)
        {
            ObjectResultData res = new ObjectResultData();

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

                //1.2
                ILoginHandler handLogin  = ServiceContainer.GetService <ILoginHandler>() as ILoginHandler;
                bool          bLogDomain = handLogin.LoginDomain(Cond);
                //if (!bLogDomain)
                //{
                //    if (handLogin.IsLockedEmployee(Cond.EmployeeNo))
                //    {
                //        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0PWL);
                //    }
                //    else
                //    {
                //        //Comment for Test Only : Nattapong N.
                //        res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0099);
                //    }
                //    ILogHandler handLog = ServiceContainer.GetService<ILogHandler>() as ILogHandler;
                //    handLog.WriteWindowLog(EventType.C_EVENT_TYPE_ERROR, LogMessage.C_LOG_INVALID_USER, EventID.C_EVENT_ID_LOGIN_FAIL);

                //    return Json(res);
                //}

                // Clear Temporary pdf file where crate date < today
                bool isClear = ReportUtil.ClearTemporaryFile();

                //1.3
                IEmployeeMasterHandler handEmp = ServiceContainer.GetService <IEmployeeMasterHandler>() as IEmployeeMasterHandler;
                bool blnExistEmployee          = handEmp.CheckExistActiveEmployee(Cond.EmployeeNo);
                //if (!blnExistEmployee)
                //{
                //    res.AddErrorMessage(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0099);
                //    return Json(res);
                //}


                dsTransDataModel  dsTrans   = new dsTransDataModel();
                ITransDataHandler handTrans = ServiceContainer.GetService <ITransDataHandler>() as ITransDataHandler;

                #region Language

                dsTrans.dtTransHeader          = new TransHeaderDo();
                dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN;

                if (this.RouteData.Values["lang"] != null &&
                    !string.IsNullOrWhiteSpace(this.RouteData.Values["lang"].ToString()))
                {
                    // set the culture from the route data (url)
                    string lang = this.RouteData.Values["lang"].ToString();

                    if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_EN)
                    {
                        dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_EN;
                    }
                    else if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_JP)
                    {
                        dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_JP;
                    }
                    else if (lang.ToLower() == CommonValue.DEFAULT_SHORT_LANGUAGE_LC)
                    {
                        dsTrans.dtTransHeader.Language = CommonValue.DEFAULT_LANGUAGE_LC;
                    }
                }
                CommonUtil.dsTransData = dsTrans;

                #endregion
                #region Refesh Data

                handTrans.RefreshUserData(dsTrans, Cond.EmployeeNo);
                handTrans.RefreshOfficeData(dsTrans);
                handTrans.RefreshPermissionData(dsTrans);

                #endregion

                handLogin.KeepHistory(Cond.EmployeeNo, LogType.C_LOG_IN);

                dsTrans.dtOperationData = new OperationDataDo();
                dsTrans.dtOperationData.ProcessDateTime = DateTime.Now;

                dsTrans.dtCommonSearch = new CommonSearchDo();

                CommonUtil.dsTransData = dsTrans;


                //-----------Add by Narupon W.-------(Menu list)-----------------//

                IMasterHandler    handMAS  = ServiceContainer.GetService <IMasterHandler>() as IMasterHandler;
                List <tbm_Object> menuList = handMAS.GetTbm_Object();
                dsTrans.dtMenuNameList = CommonUtil.ClonsObjectList <tbm_Object, MenuName>(menuList);
                CommonUtil.MappingObjectLanguage <MenuName>(dsTrans.dtMenuNameList);

                //-----------END Add by Narupon W.-------(Menu list)-------------//



                res.ResultData = "/Common/CMS020";

                doDirectScreen dos = CommonUtil.GetSession <doDirectScreen>("DIRECT_SCREEN");
                if (dos != null)
                {
                    res.ResultData = dos;
                    CommonUtil.SetSession("DIRECT_SCREEN", null);
                }
            }
            catch (Exception ex)
            {
                res.AddErrorMessage(ex);
            }

            return(Json(res));
        }