예제 #1
0
        /// <summary>
        /// Ons the state of the acquire request.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        private void onAcquireRequestState(object sender, EventArgs e)
        {
            Logger mLog         = Logger.Instance();
            string mAccountName = AccountUtility.HttpContextUserName();

            mLog.Debug("Started");
            mLog.Debug("CurrentExecutionFilePath " + HttpContext.Current.Request.CurrentExecutionFilePath);
            mLog.Debug("HttpContextUserName: "******"ANONYMOUS")
            {
                string mMessage = "Could not find account '" + mAccountName + "'";
                mLog.Info(mMessage);
                if (ConfigSettings.AutoCreateAccount)
                {
                    mMessage = "Creating new account for '" + mAccountName + "'";
                    mLog.Info(mMessage);
                    AccountUtility.AutoCreateAccount();
                }
            }
            if (mAccountName.ToUpper(CultureInfo.InvariantCulture) != "ANONYMOUS" & (mAccountProfile.LastLogOn.ToShortDateString() != DateTime.Now.ToShortDateString()))
            {
                mAccountProfile.LastLogOn = DateTime.Now;
                AccountUtility.Save(mAccountProfile, false, false);
            }
            if (HttpContext.Current.Session == null)
            {
                mLog.Debug("No Session!");
                mLog.Debug("Ended");
                return;
            }
            if (!processRequest())
            {
                mLog.Debug("Request not for processing!");
                mLog.Debug("Ended");
                return;
            }
            if ((HttpContext.Current.Session["EditId"] != null))
            {
                HttpContext.Current.Items["EditId"] = HttpContext.Current.Session["EditId"];
            }
            MClientChoicesState mClientChoicesState = ClientChoicesUtility.GetClientChoicesState(mAccountName);

            HttpContext.Current.Items[MClientChoices.SessionName] = mClientChoicesState;
            string mAction = GWWebHelper.GetQueryValue(HttpContext.Current.Request, "Action");

            if (string.IsNullOrEmpty(mAction))
            {
                mLog.Debug("No Action!");
                mLog.Debug("Ended");
                return;
            }
            MFunctionProfile mFunctionProfile = FunctionUtility.CurrentProfile();

            if (mFunctionProfile == null)
            {
                mFunctionProfile = FunctionUtility.GetProfile(mAction);
            }
            if (!mFunctionProfile.Source.ToUpper(CultureInfo.InvariantCulture).Contains("MENUS") && !(mAction.ToUpper(CultureInfo.InvariantCulture) == "LOGOFF" | mAction.ToUpper(CultureInfo.InvariantCulture) == "LOGON" | mAction.ToUpper(CultureInfo.InvariantCulture) == "CHANGEPASSWORD"))
            {
                FunctionUtility.SetCurrentProfile(mFunctionProfile);
                dynamic mSecurityInfo = new MSecurityInfo(mFunctionProfile, mAccountProfile);
                HttpContext.Current.Items["SecurityInfo"] = mSecurityInfo;
                switch (mAccountProfile.Status)
                {
                case (int)SystemStatus.ChangePassword:
                    mException = new WebSupportException("Your password needs to be changed before any other action can be performed.");
                    GWWebHelper.ExceptionError = mException;
                    mFunctionProfile           = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_ChangePassword", true));
                    string mChangePasswordPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                    HttpContext.Current.Response.Redirect(mChangePasswordPage + "?Action=" + mFunctionProfile.Action);
                    break;

                case (int)SystemStatus.SetAccountDetails:
                    if (HttpContext.Current.Request.Path.ToUpper(CultureInfo.InvariantCulture).IndexOf("/API/", StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        mFunctionProfile = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditAccount", true));
                        if (mAction.ToUpper(CultureInfo.InvariantCulture) != mFunctionProfile.Action.ToUpper(CultureInfo.InvariantCulture))
                        {
                            mException = new WebSupportException("Your account details need to be set.");
                            GWWebHelper.ExceptionError = mException;
                            string mEditAccountPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                            HttpContext.Current.Response.Redirect(mEditAccountPage + "?Action=" + mFunctionProfile.Action);
                        }
                    }
                    break;

                default:
                    string mPage = string.Empty;
                    if (!mSecurityInfo.MayView)
                    {
                        if (mAccountProfile.Account.ToUpper(CultureInfo.InvariantCulture) == "ANONYMOUS")
                        {
                            mException = new WebSupportException("Your session has timed out.<br/>Please sign in.");
                            GWWebHelper.ExceptionError = mException;
                            mFunctionProfile           = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_Logon", true));
                            mPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                            HttpContext.Current.Response.Redirect(mPage + "?Action=" + mFunctionProfile.Action);
                        }
                        mFunctionProfile = FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_AccessDenied", true));
                        mLog.Warn("Access was denied to Account: " + mAccountProfile.Account + " for Action: " + mFunctionProfile.Action);
                        mPage = GWWebHelper.RootSite + ConfigSettings.AppName + mFunctionProfile.Source;
                        HttpContext.Current.Response.Redirect(mPage + "?Action=" + mFunctionProfile.Action);
                    }
                    break;
                }
            }
            else
            {
                mLog.Debug("Menu data or Logoff/Logon or ChangePassword requested");
            }
            //processOverridePage(mFunctionProfile);
        }