Beispiel #1
0
        /// <summary>
        /// Back to Previous Screen
        /// </summary>
        /// <returns></returns>
        public ActionResult BackPreviousScreen()
        {
            string currentScreenID = UriUtility.GetScreenIDFromURL(Request.Url.AbsoluteUri);
            string returnURL       = string.Empty;

            if (!string.IsNullOrEmpty(currentScreenID))
            {
                returnURL = this.GetCache <string>(currentScreenID + ".BackURL");

                if (!string.IsNullOrEmpty(returnURL))
                {
                    string referrerTabID = UriUtility.GetParamValueFromURL(returnURL, "tabId");

                    if (string.IsNullOrEmpty(referrerTabID) && !string.IsNullOrEmpty(this.tabId))
                    {
                        returnURL += returnURL.Contains("?") ? "&tabId=" + this.tabId : "?tabId=" + this.tabId;
                    }
                    else
                    {
                        returnURL = !string.IsNullOrEmpty(this.tabId) && referrerTabID != this.tabId ? returnURL.Replace(referrerTabID, this.tabId) : returnURL;
                    }

                    returnURL = returnURL.Contains("?") ? returnURL : returnURL + "?IsBack=1";
                    returnURL = returnURL.Contains("IsBack") ? returnURL : returnURL + "&IsBack=1";

                    this.SaveCache(currentScreenID + ".BackURL", null);
                    return(base.Redirect(returnURL));
                }
            }

            this.SaveCache(currentScreenID + ".BackURL", null);
            return(base.Redirect(string.IsNullOrEmpty(returnURL) ? Url.Action("DCW002Menu", "DCW002", new { Area = "DCW" }) : returnURL));
        }
Beispiel #2
0
        /// <summary>
        /// Called before the action method is invoked.
        /// </summary>
        /// <param name="filterContext">Information about the current request and action.</param>
        /// <exception cref="System.Exception">
        /// </exception>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            // get SessionId from queryString
            string sessionId = filterContext.RequestContext.HttpContext.Request["SessionId"];

            if (!string.IsNullOrWhiteSpace(sessionId))
            {
                var  manager = new SessionIDManager();
                bool redirected, isAdded;
                manager.SaveSessionID(System.Web.HttpContext.Current, sessionId, out redirected, out isAdded);
            }

            string currentScreenId = (string)ViewBag.CoreCenter_ScreenID;
            string screenType      = string.Empty;

            this.CmnEntityModel.CurrentScreenID = currentScreenId;

            if (string.IsNullOrEmpty(this.cmnEntityModel.UserName) && (currentScreenId != "DCW001" && currentScreenId != "DCW002"))
            {
                throw new Exception("GLV_SYS_LoginException");
            }

            this._ShowModelStateError();

            // Reset error
            this.CmnEntityModel.ErrorMsgCd            = string.Empty;
            this.CmnEntityModel.ErrorMsgReplaceString = string.Empty;

            // Get TabId POST/GET
            if (filterContext.HttpContext.Request.HttpMethod == HttpMethod.Post.Method)
            {
                this.tabId = filterContext.HttpContext.Request.Form["hfldUniqueTabSession"];
            }
            else
            {
                this.tabId = filterContext.HttpContext.Request.QueryString["tabId"];
            }

            // Get TabId in AJAX Request
            if ((filterContext.HttpContext.Request.ContentType ?? string.Empty).Contains("application/json"))
            {
                string jsonPost = string.Empty;
                filterContext.HttpContext.Request.InputStream.Position = 0;
                using (var reader = new StreamReader(filterContext.HttpContext.Request.InputStream))
                {
                    jsonPost = reader.ReadToEnd();
                }

                if (!string.IsNullOrEmpty(jsonPost))
                {
                    var jsonPostData = Newtonsoft.Json.JsonConvert.DeserializeObject <IDictionary <string, object> >(jsonPost);
                    this.tabId = (jsonPostData != null && jsonPostData.ContainsKey("hfldUniqueTabSession") && jsonPostData["hfldUniqueTabSession"] != null)
                                                                         ? Convert.ToString(jsonPostData["hfldUniqueTabSession"])
                                                                         : "";
                }
            }

            //if (string.IsNullOrEmpty( this.tabId ))
            //{
            //	return;
            //}

            // Save TabId and Screen Route
            this.cmnTabEntityModel                 = this.GetCmnTabEntityModel(this.tabId);
            this.cmnTabEntityModel.TabID           = this.tabId;
            this.cmnTabEntityModel.CurrentScreenID = currentScreenId;

            if (this.cmnTabEntityModel.CurrentScreenID.Equals("DCW001"))
            {
                this.cmnTabEntityModel.ScreenRoute = string.Empty;
            }
            else if (this.cmnTabEntityModel.CurrentScreenID.Equals("DCW002"))
            {
                this.cmnTabEntityModel.ScreenRoute = "DCW002";
            }
            else if (!this.cmnTabEntityModel.ScreenRoute.Contains(currentScreenId))
            {
                if (string.IsNullOrEmpty(this.cmnTabEntityModel.ScreenRoute))
                {
                    this.cmnTabEntityModel.ScreenRoute = currentScreenId;
                }
                else
                {
                    this.cmnTabEntityModel.ScreenRoute += "," + currentScreenId;
                }
            }

            string[] screenList = this.cmnTabEntityModel.ScreenRoute.Split(',');
            if (screenList.Length > 1)
            {
                this.cmnTabEntityModel.ParrentScreenID = screenList[screenList.Length - 2];
            }

            this.SaveCache("CmnTabEntityModel", this.cmnTabEntityModel);

            #region "Back"
            if (Request.UrlReferrer != null)
            {
                string currentScreenID  = UriUtility.GetScreenIDFromURL(Request.Url.AbsoluteUri);
                string referrerScreenID = UriUtility.GetScreenIDFromURL(Request.UrlReferrer.AbsoluteUri);

                if (currentScreenID != referrerScreenID && !Request.Url.AbsoluteUri.Contains("IsBack"))
                {
                    this.SaveCache(currentScreenID + ".BackURL", Request.UrlReferrer.AbsoluteUri);
                }
            }
            #endregion

            #region Detecting Refresh
            var cookie = this.GetCache <string>("UrlCheckRefresh");
            this.cmnTabEntityModel.IsRefreshed = filterContext.HttpContext.Request.Url != null && (cookie != null && cookie == filterContext.HttpContext.Request.Url.ToString());
            #endregion

            #region Current screen Id for common
            CacheUtil.SaveCache("_CommonCurrentScreenId", currentScreenId);

            #endregion

            CacheUtil.SaveCache(CacheKeys.CmnEntityModel, cmnEntityModel);
        }