Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MFunctionProfile mFunctionProfile = FunctionUtility.CurrentProfile();
            String           mScript          = "<script type='text/javascript' language='javascript'>GW.FileManager.currentDirectory = '/'; GW.FileManager.currentFunctionSeqID=" + mFunctionProfile.Id.ToString() + "</script>";

            Page.ClientScript.RegisterStartupScript(this.GetType(), "", mScript);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Page_s the init.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 protected void Page_Init(Object sender, EventArgs e)
 {
     m_SecurityInfo   = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
     m_ShowDeleteLink = m_SecurityInfo.MayDelete;
     if (!m_SecurityInfo.MayView)
     {
         this.searchResults.Columns.RemoveAt(0);
     }
 }
Ejemplo n.º 3
0
        protected void Page_Init(object sender, EventArgs e)
        {
            string mAction = GWWebHelper.GetQueryValue(Request, "action");

            if (!String.IsNullOrEmpty(mAction))
            {
                m_SecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Handles the PreInit event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void Page_PreInit(object sender, EventArgs e)
        {
            base.OnInit(e);
            MFunctionProfile mFunction = FunctionUtility.CurrentProfile();

            if (mFunction != null)
            {
                this.EnableViewState = mFunction.EnableViewState;
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MRoleProfile  myProfile           = new MRoleProfile();
            MSecurityInfo accountSecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());

            txtEditID.Text = Request.QueryString[GWWebHelper.RoleDataKeyField].ToString();
            //HttpContext.Current.Session.Remove(AppConstants.ROLE_DATA_KEY_FIELD);
            myProfile.Id = int.Parse(txtEditID.Text);
            HttpContext.Current.Session.Add("EditId", myProfile.Id);
            myProfile    = RoleUtility.GetProfile(myProfile.Id);
            litRole.Text = myProfile.Name;
            myProfile.SecurityEntityId = int.Parse(ClientChoicesState[MClientChoices.SecurityEntityId].ToString());
            ctlMembers.DataSource      = RoleUtility.GetAccountsNotInRole(myProfile).ToArray(Type.GetType("System.String"));
            ctlMembers.SelectedItems   = (string[])RoleUtility.GetAccountsInRole(myProfile).ToArray(Type.GetType("System.String"));
            ctlMembers.DataBind();
        }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SearchControl.ShowAddLink = false;
            MDirectoryProfile mDirectoryProfile = DirectoryUtility.GetProfile(FunctionUtility.CurrentProfile().Id);
            String            mLinks            = FileUtility.GetDirectoryLinks("/", mDirectoryProfile.FunctionSeqId);

            directorySelector.InnerHtml = mLinks;
            MFunctionProfile mFunctionProfile = FunctionUtility.CurrentProfile();
            MAccountProfile  mAccountProfile  = AccountUtility.CurrentProfile();
            MSecurityInfo    mSI = new MSecurityInfo(mFunctionProfile, mAccountProfile);

            UploadControl.Visible       = mSI.MayAdd;
            tdNewDirectory.Visible      = mSI.MayAdd;
            SearchControl.ShowDeleteAll = mSI.MayDelete;
            SearchControl.ShowSelect    = mSI.MayDelete;
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            m_SecurityInfo    = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
            noResults.Visible = false;
            searchResults.HeaderStyle.ForeColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeaderForeColor]);
            searchResults.HeaderStyle.BackColor         = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.HeadColor]);
            searchResults.AlternatingRowStyle.BackColor = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.AlternatingRowBackColor]);
            searchResults.RowStyle.BackColor            = ColorTranslator.FromHtml(ClientChoicesState[MClientChoices.RowBackColor]);
            if (!String.IsNullOrEmpty(GWWebHelper.GetQueryValue(Request, "Columns")))
            {
                MSearchCriteria mSearchCriteria = new MSearchCriteria();
                mSearchCriteria.Columns          = GWWebHelper.GetQueryValue(Request, "Columns");
                mSearchCriteria.OrderByColumn    = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "OrderByColumn"));
                mSearchCriteria.OrderByDirection = GWWebHelper.GetQueryValue(Request, "OrderByDirection");
                int mTryParse = 0;
                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "PageSize"), out mTryParse))
                {
                    mSearchCriteria.PageSize = int.Parse(GWWebHelper.GetQueryValue(Request, "PageSize"));
                }
                else
                {
                    mSearchCriteria.PageSize = 10;
                }

                if (int.TryParse(GWWebHelper.GetQueryValue(Request, "SelectedPage"), out mTryParse))
                {
                    mSearchCriteria.SelectedPage = int.Parse(GWWebHelper.GetQueryValue(Request, "SelectedPage"));
                }
                else
                {
                    mSearchCriteria.SelectedPage = 1;
                }
                mSearchCriteria.WhereClause = Server.UrlDecode(GWWebHelper.GetQueryValue(Request, "WhereClause"));
                mSearchCriteria.WhereClause = mSearchCriteria.WhereClause.Replace("\"", String.Empty);
                bindData(mSearchCriteria);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Page_s the init.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
 protected void Page_Init(Object sender, EventArgs e)
 {
     m_SecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
 }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
0
        public IHttpActionResult Save(UIAccountProfile uiProfile)
        {
            if (uiProfile == null)
            {
                throw new ArgumentNullException("uiProfile", "uiProfile cannot be a null reference (Nothing in Visual Basic)!");
            }
            string          mRetVal                = "false";
            bool            mSaveGroups            = false;
            bool            mSaveRoles             = false;
            MAccountProfile mCurrentAccountProfile = AccountUtility.CurrentProfile();
            MAccountProfile mAccountProfileToSave  = new MAccountProfile();
            Logger          mLog = Logger.Instance();

            if (HttpContext.Current.Request.QueryString["Action"].ToString().ToUpper(CultureInfo.InvariantCulture).IndexOf("REGISTER") > -1)
            {
                MAccountProfile mExistingAccount = AccountUtility.GetProfile(uiProfile.Account);
                if (mExistingAccount == null)
                {
                    mAccountProfileToSave    = populateAccountProfile(uiProfile, mAccountProfileToSave);
                    mAccountProfileToSave.Id = uiProfile.Id;
                    string mGroups = ConfigSettings.RegistrationGroups;
                    string mRoles  = ConfigSettings.RegistrationRoles;
                    if (!string.IsNullOrEmpty(mGroups))
                    {
                        mSaveGroups = true;
                    }
                    if (!string.IsNullOrEmpty(mRoles))
                    {
                        mSaveRoles = true;
                    }
                    mAccountProfileToSave.AddedBy   = mCurrentAccountProfile.Id;
                    mAccountProfileToSave.AddedDate = DateTime.Now;
                    mAccountProfileToSave.SetGroups(mGroups);
                    mAccountProfileToSave.SetRoles(mRoles);
                    mAccountProfileToSave.PasswordLastSet = DateTime.Now;
                    mAccountProfileToSave.LastLogOn       = DateTime.Now;
                    mAccountProfileToSave.Password        = CryptoUtility.Encrypt(ConfigSettings.RegistrationPassword, ConfigSettings.EncryptionType);
                    mAccountProfileToSave.Status          = int.Parse(ConfigSettings.RegistrationStatusId);
                    if (HttpContext.Current.Request.QueryString["Action"].ToString().ToUpper(CultureInfo.InvariantCulture).IndexOf("REGISTER") > -1)
                    {
                        mAccountProfileToSave.Status = (int)SystemStatus.Active;
                    }
                    MClientChoicesState    mClientChoiceState     = ClientChoicesUtility.GetClientChoicesState(ConfigSettings.RegistrationAccountChoicesAccount, true);
                    MSecurityEntityProfile mSecurityEntityProfile = SecurityEntityUtility.GetProfile(ConfigSettings.RegistrationSecurityEntityId);
                    string mCurrentSecurityEntityId = mClientChoiceState[MClientChoices.SecurityEntityId];

                    mClientChoiceState.IsDirty = false;
                    mClientChoiceState[MClientChoices.AccountName]        = mAccountProfileToSave.Account;
                    mClientChoiceState[MClientChoices.SecurityEntityId]   = mSecurityEntityProfile.Id.ToString(CultureInfo.InvariantCulture);
                    mClientChoiceState[MClientChoices.SecurityEntityName] = mSecurityEntityProfile.Name;
                    try
                    {
                        AccountUtility.Save(mAccountProfileToSave, mSaveRoles, mSaveGroups, mSecurityEntityProfile);
                        ClientChoicesUtility.Save(mClientChoiceState, false);
                        AccountUtility.SetPrincipal(mAccountProfileToSave);
                        mRetVal = "Your account has been created";
                    }
                    catch (Exception ex)
                    {
                        mLog.Error(ex);
                    }
                }
                else
                {
                    mRetVal = "The account '" + uiProfile.Account + "' already exists please choose a different account/email";
                }
            }
            else
            {
                if ((HttpContext.Current.Items["EditId"] != null) | mCurrentAccountProfile.Status == (int)SystemStatus.SetAccountDetails)
                {
                    int mEditId = 0;
                    if ((HttpContext.Current.Items["EditId"] != null))
                    {
                        mEditId = int.Parse(HttpContext.Current.Items["EditId"].ToString());
                    }
                    else
                    {
                        mEditId = mCurrentAccountProfile.Id;
                    }
                    if (mEditId == uiProfile.Id)
                    {
                        MSecurityInfo mSecurityInfo = new MSecurityInfo(FunctionUtility.CurrentProfile(), AccountUtility.CurrentProfile());
                        if ((mSecurityInfo != null))
                        {
                            if (mEditId != -1)
                            {
                                if (mCurrentAccountProfile.Id != uiProfile.Id)
                                {
                                    mSecurityInfo = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_EditOtherAccount", true)), mCurrentAccountProfile);
                                }
                                if (mSecurityInfo.MayEdit | mCurrentAccountProfile.Status == (int)SystemStatus.SetAccountDetails)
                                {
                                    MSecurityInfo mGroupTabSecurity = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_View_Account_Group_Tab", true)), mCurrentAccountProfile);
                                    MSecurityInfo mRoleTabSecurity  = new MSecurityInfo(FunctionUtility.GetProfile(ConfigSettings.GetAppSettingValue("Actions_View_Account_Role_Tab", true)), mCurrentAccountProfile);
                                    mAccountProfileToSave    = AccountUtility.GetProfile(mEditId);
                                    mAccountProfileToSave    = populateAccountProfile(uiProfile, mAccountProfileToSave);
                                    mAccountProfileToSave.Id = uiProfile.Id;
                                    string mGroups = string.Join(",", uiProfile.AccountGroups.Groups);
                                    string mRoles  = string.Join(",", uiProfile.AccountRoles.Roles);
                                    if (mGroupTabSecurity.MayView & FunctionUtility.CurrentProfile().Action.ToLowerInvariant() == ConfigSettings.GetAppSettingValue("Actions_EditOtherAccount", true).ToLower(CultureInfo.InvariantCulture))
                                    {
                                        if (mAccountProfileToSave.GetCommaSeparatedAssignedGroups != mGroups)
                                        {
                                            mSaveGroups = true;
                                            mAccountProfileToSave.SetGroups(mGroups);
                                        }
                                    }
                                    if (mRoleTabSecurity.MayView & FunctionUtility.CurrentProfile().Action.ToLowerInvariant() == ConfigSettings.GetAppSettingValue("Actions_EditOtherAccount", true).ToLower(CultureInfo.InvariantCulture))
                                    {
                                        if (mAccountProfileToSave.GetCommaSeparatedAssignedRoles != mRoles)
                                        {
                                            mSaveRoles = true;
                                            mAccountProfileToSave.SetRoles(mRoles);
                                        }
                                    }
                                    mAccountProfileToSave.AddedBy   = mCurrentAccountProfile.Id;
                                    mAccountProfileToSave.AddedDate = DateTime.Now;
                                    AccountUtility.Save(mAccountProfileToSave, mSaveRoles, mSaveGroups);
                                    mLog.Debug("Saved account " + mAccountProfileToSave.Account + " by " + mCurrentAccountProfile.Account);
                                    mRetVal = "true";
                                }
                                else
                                {
                                    Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to edit");
                                    mLog.Error(mError);
                                    return(this.InternalServerError(mError));
                                }
                            }
                            else
                            {
                                if (mSecurityInfo.MayAdd)
                                {
                                    mSaveGroups                     = true;
                                    mSaveRoles                      = true;
                                    mAccountProfileToSave           = populateAccountProfile(uiProfile, mAccountProfileToSave);
                                    mAccountProfileToSave.Id        = -1;
                                    mAccountProfileToSave.AddedBy   = mCurrentAccountProfile.Id;
                                    mAccountProfileToSave.AddedDate = DateTime.Now;

                                    mAccountProfileToSave.AddedBy         = mCurrentAccountProfile.Id;
                                    mAccountProfileToSave.AddedDate       = DateTime.Now;
                                    mAccountProfileToSave.PasswordLastSet = DateTime.Now;
                                    mAccountProfileToSave.LastLogOn       = DateTime.Now;
                                    mAccountProfileToSave.Password        = CryptoUtility.Encrypt(ConfigSettings.RegistrationPassword, ConfigSettings.EncryptionType);
                                    mAccountProfileToSave.Status          = ConfigSettings.AutoCreateAccountStatusId;
                                    string mGroups = string.Join(",", uiProfile.AccountGroups.Groups);
                                    string mRoles  = string.Join(",", uiProfile.AccountRoles.Roles);
                                    mAccountProfileToSave.SetGroups(mGroups);
                                    mAccountProfileToSave.SetRoles(mRoles);
                                    try
                                    {
                                        AccountUtility.Save(mAccountProfileToSave, mSaveRoles, mSaveGroups);
                                    }
                                    catch (Exception ex)
                                    {
                                        mLog.Error(ex);
                                    }
                                    mLog.Debug("Added account " + mAccountProfileToSave.Account + " by " + mCurrentAccountProfile.Account);
                                    mRetVal = "true";
                                }
                                else
                                {
                                    Exception mError = new Exception("The account (" + AccountUtility.CurrentProfile().Account + ") being used does not have the correct permissions to add");
                                    mLog.Error(mError);
                                    return(this.InternalServerError(mError));
                                }
                            }
                        }
                        else
                        {
                            Exception mError = new Exception("Security Info is not in context nothing has been saved!!!!");
                            mLog.Error(mError);
                            return(this.InternalServerError(mError));
                        }
                    }
                    else
                    {
                        Exception mError = new Exception("Identifier you have last looked at does not match the one passed in nothing has been saved!!!!");
                        mLog.Error(mError);
                        return(this.InternalServerError(mError));
                    }
                }
            }

            return(Ok(mRetVal));
        }