Example #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!this.IsPostBack)
     {
         Login1.DestinationPageUrl = ResourceProvider.GetActiveOrganizationUrl();
     }
 }
Example #2
0
        /// <summary>
        /// Occurs when the page is being loaded.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains no event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Micajah.Common.Pages.MasterPage.CreatePageHeader(this.Page, false, false);

            if (!IsPostBack)
            {
                UserContext user = UserContext.Current;

                if (user.OrganizationId == null)
                {
                    Response.Redirect(ResourceProvider.GetActiveOrganizationUrl(Request.Url.PathAndQuery));
                }

                Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.LogOffGlobalNavigationLinkActionId));

                OrganizationArea.Visible = false;
                InstanceArea.Visible     = false;

                InstanceCollection     instances = LoginProvider.Current.GetLoginInstances(user.UserId, user.OrganizationId);
                OrganizationCollection orgs      = LoginProvider.Current.GetOrganizationsByLoginId(user.UserId);
                int instCount = instances.Count;
                int orgsCount = 0;
                if (orgs != null)
                {
                    orgsCount = orgs.Count;
                    if (orgsCount > 1)
                    {
                        orgs      = orgs.FindAllVisible();
                        orgsCount = orgs.Count;
                        if (orgsCount == 1)
                        {
                            if (orgs[0].OrganizationId != user.OrganizationId)
                            {
                                orgsCount = 2;
                            }
                        }
                    }
                }

                if (user.InstanceId == Guid.Empty)
                {
                    instCount = 0;
                }
                else
                {
                    if (instCount > 1)
                    {
                        InstanceDescriptionLabel.Text = Resources.LogOffControl_InstanceDescriptionLabel_Text;

                        InstanceList.DataSource = instances;
                        InstanceList.DataBind();

                        InstanceArea.Visible = true;
                    }
                }

                if (orgsCount > 1)
                {
                    OrganizationLabel.Text = Resources.LogOffControl_OrganizationLabel_Text;

                    orgs.SortByExpiration();

                    OrganizationList.DataSource = orgs;
                    OrganizationList.DataBind();

                    OrganizationArea.Visible = true;
                }
                else if (!InstanceArea.Visible)
                {
                    LoginProvider.Current.SignOut();

                    return;
                }

                TitleLabel.Text = Resources.LogOffControl_TitleLabel_Text;
                LogOffLink.Text = Resources.LogoffControl_LogoffLink_Text;
            }

            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnModernStyleSheet, true)));
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
Example #3
0
        /// <summary>
        /// Occurs when the page is being loaded.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains no event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            Micajah.Common.Pages.MasterPage.CreatePageHeader(this.Page, false, false);

            if (!IsPostBack)
            {
                UserContext user = UserContext.Current;

                if (user.OrganizationId == Guid.Empty)
                {
                    Response.Redirect(ResourceProvider.GetActiveOrganizationUrl(Request.Url.PathAndQuery));
                }

                Micajah.Common.Bll.Action action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, action);

                if (string.Compare(Request.QueryString["ai"], "1", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    ShowError(Resources.ActiveInstanceControl_YouAreLoggedIntoAnotherInstance, ErrorPanel);
                }

                LogOffLink.Text = Resources.ActiveInstanceControl_LogoffLink_Text;

                action = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.LogOffGlobalNavigationLinkActionId);
                LogOffLink.NavigateUrl = ((action == null) ? ResourceProvider.LogOffPageVirtualPath : action.AbsoluteNavigateUrl);

                InstanceCollection coll = LoginProvider.Current.GetLoginInstances(user.UserId, user.OrganizationId);
                int count = 0;

                if (coll != null)
                {
                    count = coll.Count;
                }

                if (count == 0)
                {
                    string url = string.Empty;
                    action = ActionProvider.PagesAndControls.FindByActionId(ActionProvider.ConfigurationPageActionId);
                    if (action != null)
                    {
                        url = action.CustomAbsoluteNavigateUrl;
                    }

                    ShowError(
                        (user.IsOrganizationAdministrator
                            ? Resources.UserContext_ErrorMessage_YouAreNotAssociatedWithInstances + "<br />"
                         + string.Format(CultureInfo.InvariantCulture, Resources.ActiveInstanceControl_ConfigureOrganization, url)
                            : Resources.UserContext_ErrorMessage_YouAreNotAssociatedWithInstances)
                        , ErrorPanel);
                }
                else if (count == 1)
                {
                    InstanceArea.Visible           = false;
                    LogOffDescriptionLabel.Visible = false;
                    SelectInstance(coll[0].InstanceId, Request.QueryString["returnurl"], true, ErrorPanel);
                }
                else
                {
                    DescriptionLabel.Text       = Resources.ActiveInstanceControl_DescriptionLabel_Text;
                    LogOffDescriptionLabel.Text = Resources.ActiveInstanceControl_LogoffDescriptionLabel_Text;

                    InstanceList.DataSource = coll;
                    InstanceList.DataBind();
                }
            }

            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnModernStyleSheet, true)));
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }