예제 #1
0
        /// <summary>
        /// Gets the current selections.
        /// </summary>
        /// <param name="cookeiCollection">The cookei collection.</param>
        /// <returns>CurrentSelections.</returns>
        public static CurrentSelections GetCurrentSelections(HttpCookieCollection cookeiCollection)
        {
            var retVal = new CurrentSelections();

            try
            {
                var psCookies  = cookeiCollection;
                var httpCookie = psCookies[@"currentSelections"];
                if (httpCookie != null)
                {
                    var cookieValue = HttpUtility.UrlDecode(httpCookie.Value);
                    PsLogger.Trace("CurrentSelectionsCookie = {0}", cookieValue);
                    if (!String.IsNullOrEmpty(cookieValue))
                    {
                        var cookieArray = cookieValue.Split(new[] { ',' });

                        retVal.ItemId          = cookieArray[0].ToInt();
                        retVal.SubItemId       = cookieArray[1].ToInt();
                        retVal.ExtendedInfo    = cookieArray[2];
                        retVal.MapId           = cookieArray[3].ToInt();
                        retVal.VpfId           = cookieArray[4].ToInt();
                        retVal.ScId            = cookieArray[5].ToInt();
                        retVal.FormId          = cookieArray[6].ToInt();
                        retVal.FormTabId       = cookieArray[7].ToInt();
                        retVal.Module          = cookieArray[8].ToInt();
                        retVal.CurrentItem     = cookieArray[9].ToInt();
                        retVal.User            = cookieArray[10];
                        retVal.Locale          = cookieArray[11];
                        retVal.DashboardId     = cookieArray[12].ToInt();
                        retVal.DashboardTabId  = cookieArray[13].ToInt();
                        retVal.AsOfId          = cookieArray[14].ToInt();
                        retVal.AsOfDate        = cookieArray[15];
                        retVal.DisplayLanguage = cookieArray[16];
                    }
                }
            }
            catch (Exception ex)
            {
                PsLogger.Error(ex.Message);
                PsLogger.Error(ex.InnerException);
                retVal = new CurrentSelections();
            }

            PsLogger.Trace("CurrentSelections\n{0}", retVal.ToString());
            return(retVal);
        }
예제 #2
0
        /// <summary>
        /// Gets the current user view.
        /// </summary>
        /// <param name="httpRequest">The HTTP request.</param>
        /// <param name="userId">The user id.</param>
        /// <returns>CurrentUserView.</returns>
        public CurrentUserView GetCurrentUserView(HttpRequest httpRequest, Int32 userId)
        {
            PsLogger.Trace("GetCurrentUserView userId = {0}", userId.ToString(CultureInfo.InvariantCulture));
            var retVal = new CurrentUserView {
                UserSelections = CurrentSelections.GetCurrentSelections(httpRequest.Cookies)
            };

            try
            {
                if (retVal.UserSelections.CurrentItem.HasValue)
                {
                    retVal.ItemId      = retVal.UserSelections.CurrentItem.Value;
                    retVal.VersionId   = retVal.UserSelections.AsOfId;
                    retVal.VersionDate = retVal.UserSelections.AsOfDate.ToDate();

                    if (retVal.UserSelections.Module.HasValue)
                    {
                        retVal.ModuleType   = retVal.UserSelections.Module.Value;
                        retVal.ModuleWindow = String.Empty;
                        if (retVal.UserSelections.Module == 1)
                        {
                            retVal.ModuleWindow = "todo";
                        }
                        if (retVal.UserSelections.Module == 2)
                        {
                            retVal.ModuleWindow = "map";
                            retVal.ModuleId     = retVal.UserSelections.MapId;
                        }
                        if (retVal.UserSelections.Module == 3)
                        {
                            retVal.ModuleWindow = "sc";
                            retVal.ModuleId     = retVal.UserSelections.ScId;
                        }
                        if (retVal.UserSelections.Module == 4)
                        {
                            retVal.ModuleWindow = "dash";
                            retVal.ModuleId     = retVal.UserSelections.DashboardId;
                        }
                        if (retVal.UserSelections.Module == 5)
                        {
                            retVal.ModuleWindow = "wb";
                            retVal.ModuleId     = retVal.ModuleId = retVal.UserSelections.ScId;
                        }
                        if (retVal.UserSelections.Module == 7)
                        {
                            retVal.ModuleWindow = "form";
                            retVal.ModuleId     = retVal.UserSelections.FormId;
                        }
                    }

                    if (retVal.ModuleId.HasValue && retVal.ModuleType.HasValue)
                    {
                        //var itemInfo = String.Empty; GetItemInfo(retVal.UserSelections.CurrentItem.Value);
                        retVal.ItemName   = String.Empty; //itemInfo.Name;
                        retVal.ModuleName = String.Empty; //psDal.GetModuleName(retVal.ModuleType.Value, retVal.ModuleId.Value);
                    }
                }
            }
            catch (Exception ex)
            {
                PsLogger.Error(ex.ToString()); // Warn -- log it for some who cares.
                retVal = new CurrentUserView {
                    UserSelections = CurrentSelections.GetCurrentSelections(httpRequest.Cookies)
                };
            }

            PsLogger.Trace("GetCurrentUserView retVal = {0}", retVal.ToString());
            return(retVal);
        }