Ejemplo n.º 1
0
        private void VerifyVanityUrl(Guid organizationId, Guid instanceId)
        {
            if (organizationId != Guid.Empty)
            {
                string vanityUrl = CustomUrlProvider.GetVanityUrl(organizationId, instanceId);

                if (!string.IsNullOrEmpty(vanityUrl) && (string.Compare(Request.Url.Host, vanityUrl, StringComparison.OrdinalIgnoreCase) != 0))
                {
                    string redirectUrl = this.ReturnUrl;

                    if (string.IsNullOrEmpty(redirectUrl))
                    {
                        redirectUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery);
                    }
                    else
                    {
                        redirectUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery)
                                      + ((Request.QueryString["returnurl"] == null)
                                ? ((Request.Url.PathAndQuery.IndexOf("&", StringComparison.OrdinalIgnoreCase) > -1) ? "&" : "?") + "returnurl=" + HttpUtility.UrlEncode(redirectUrl)
                                : string.Empty);
                    }

                    Response.Redirect(string.Format(CultureInfo.InvariantCulture, "{0}{1}{2}{3}", Request.Url.Scheme, Uri.SchemeDelimiter, vanityUrl, redirectUrl));
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Renders the application logo and the logo of the copyright holder company.
        /// </summary>
        /// <param name="writer">The System.Web.UI.HtmlTextWriter to render content to.</param>
        public static void RenderHeader(HtmlTextWriter writer)
        {
            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                return;
            }

            if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl))
            {
                using (Image img = new Image())
                {
                    img.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                    img.ToolTip  = FrameworkConfiguration.Current.WebApplication.Copyright.CompanyName;

                    RenderHeader(writer, img);
                }
            }
            else
            {
                using (LiteralControl literal = new LiteralControl(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyName))
                {
                    RenderHeader(writer, literal);
                }
            }
        }
Ejemplo n.º 3
0
        private static Image CreateItemIcon(Micajah.Common.Bll.Action item, IconSize iconSize)
        {
            Image img = null;

            try
            {
                img            = new Image();
                img.ImageAlign = ImageAlign.AbsMiddle;
                img.ImageUrl   = CustomUrlProvider.CreateApplicationAbsoluteUrl(item.IconUrl);
                if (iconSize != IconSize.NotSet)
                {
                    img.Height = img.Width = Unit.Pixel((int)iconSize);
                }
                string descr = item.CustomDescription;
                if (!string.IsNullOrEmpty(descr))
                {
                    img.ToolTip = descr;
                }

                return(img);
            }
            finally
            {
                if (img != null)
                {
                    img.Dispose();
                }
            }
        }
Ejemplo n.º 4
0
        private void Tree_DataBind()
        {
            Type   typeOfThis     = typeof(EntitiesControl);
            string entityImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GetImageUrl(typeOfThis, "Entity.gif"));
            string fieldImageUrl  = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GetImageUrl(typeOfThis, "Field.gif"));
            string eventImageUrl  = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GetImageUrl(typeOfThis, "Event.gif"));

            foreach (Entity entity in EntityFieldProvider.Entities)
            {
                RadTreeNode entityNode = new RadTreeNode(entity.Name);
                entityNode.ImageUrl = entityImageUrl;
                Tree.Nodes.Add(entityNode);

                if (entity.EnableHierarchy)
                {
                    RadTreeNode parentNode = entityNode;
                    foreach (EntityNodeType nodeType in entity.NodeTypes)
                    {
                        RadTreeNode nodeTypeNode = new RadTreeNode(nodeType.Name);
                        nodeTypeNode.ImageUrl = entityImageUrl;
                        parentNode.Nodes.Add(nodeTypeNode);

                        foreach (EntityEvent entityEvent in nodeType.Events)
                        {
                            RadTreeNode eventNode = new RadTreeNode(entityEvent.Name);
                            eventNode.ImageUrl = eventImageUrl;
                            nodeTypeNode.Nodes.Add(eventNode);
                        }

                        parentNode = nodeTypeNode;
                    }

                    foreach (EntityEvent entityEvent in entity.CustomEvents)
                    {
                        RadTreeNode eventNode = new RadTreeNode(entityEvent.Name);
                        eventNode.ImageUrl = eventImageUrl;
                        entityNode.Nodes.Add(eventNode);
                    }
                }
                else
                {
                    foreach (EntityField field in entity.Fields)
                    {
                        RadTreeNode fieldNode = new RadTreeNode(field.Name);
                        fieldNode.ImageUrl = fieldImageUrl;
                        entityNode.Nodes.Add(fieldNode);
                    }

                    foreach (EntityEvent entityEvent in entity.Events)
                    {
                        RadTreeNode eventNode = new RadTreeNode(entityEvent.Name);
                        eventNode.ImageUrl = eventImageUrl;
                        entityNode.Nodes.Add(eventNode);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        protected void InviteUsersLink_Init(object sender, EventArgs e)
        {
            HyperLink lnk = sender as HyperLink;

            if (lnk != null)
            {
                lnk.Text        = Resources.UsersControl_InviteUsersLink_Text;
                lnk.NavigateUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.InviteUsersPageVirtualPath);
            }
        }
Ejemplo n.º 6
0
        protected override void LoadResources()
        {
            base.LoadResources();
            HyperLinkField field = (List.Columns[1] as HyperLinkField);

            if (field != null)
            {
                field.Text = Resources.GroupsControl_List_RolesLinkColumns_Text;
                field.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl(string.Concat(ResourceProvider.GroupsInstancesRolesPageVirtualPath, "?GroupId={0:N}"));
            }
        }
Ejemplo n.º 7
0
        protected override void LoadResources()
        {
            base.LoadResources();
            HyperLinkField field = (List.Columns[0] as HyperLinkField);

            if (field != null)
            {
                field.Text = Resources.RulesControl_List_Caption;
                field.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.VirtualRootShortPath + "admin/rules.aspx?RuleEngineId={0:N}");
            }
        }
Ejemplo n.º 8
0
        protected override void LoadResources()
        {
            base.LoadResources();

            TemplateField tempField = (List.Columns[0] as TemplateField);

            if (tempField != null)
            {
                tempField.HeaderText = Resources.RulesControl_List_OrderNumberColumn_HeaderText;
            }

            HyperLinkField linkField = (List.Columns[1] as HyperLinkField);

            if (linkField != null)
            {
                linkField.HeaderText = Resources.RulesControl_List_InputParametersLinkColumns_HeaderText;
                linkField.Text       = Resources.RulesControl_List_InputParametersLinkColumns_Text;
                linkField.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.VirtualRootShortPath + "admin/ruleparameters.aspx?RuleId={0:N}");
                linkField.HeaderGroup = Resources.RulesControl_List_ParametersLinkColumns_HeaderGroup;
            }

            linkField = (List.Columns[2] as HyperLinkField);
            if (linkField != null)
            {
                linkField.HeaderText = Resources.RulesControl_List_OutputParametersLinkColumns_HeaderText;
                linkField.Text       = Resources.RulesControl_List_OutputParametersLinkColumns_Text;
                linkField.DataNavigateUrlFormatString = CustomUrlProvider.CreateApplicationAbsoluteUrl((string)FormRuleEngine.DataKey["OutputEditPage"]);
                linkField.HeaderGroup = Resources.RulesControl_List_ParametersLinkColumns_HeaderGroup;
            }

            tempField = (List.Columns[6] as TemplateField);
            if (tempField != null)
            {
                tempField.HeaderText = Resources.RulesControl_List_LastUsedUserColumn_HeaderText;
            }

            List.Columns[7].HeaderText = Resources.RulesControl_List_LastUsedDateColumn_HeaderText;

            tempField = (List.Columns[8] as TemplateField);
            if (tempField != null)
            {
                tempField.HeaderText = Resources.RulesControl_List_CreatedByColumn_HeaderText;
            }

            List.Columns[9].HeaderText = Resources.RulesControl_List_CreatedDateColumn_HeaderText;

            Initialize(FormRuleEngine);
            FormRuleEngine.Visible = true;
            FormRuleEngine.AutoGenerateEditButton = FormRuleEngine.AutoGenerateInsertButton = false;

            LoadResources(FormRuleEngine, this.GetType().BaseType.Name);
        }
Ejemplo n.º 9
0
        protected override void OnLoad(EventArgs e)
        {
            Micajah.Common.Pages.MasterPage.InitializeSetupPage(this.Page);

            if (DatabaseServerProvider.GetDatabaseServers().Count == 0)
            {
                List.EmptyDataText = string.Format(CultureInfo.CurrentCulture
                                                   , Resources.DatabasesControl_ErrorMessage_NoDatabaseServer
                                                   , CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.DatabaseServersPageVirtualPath));
                List.ShowAddLink = EditForm.Visible = false;
            }

            base.OnLoad(e);
        }
Ejemplo n.º 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            MagicForm.ApplyStyle(FormTable, ColorScheme.White, false, true);
            AutoGeneratedButtonsField.InsertButtonSeparator(ButtonsSeparator);

            if (!this.IsPostBack)
            {
                this.LoadResources();
                CancelLink.NavigateUrl      = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.UsersPageVirtualPath);
                EmailValidator.ErrorMessage = Resources.TextBox_RegularExpressionValidator_ErrorMessage;

                EmailValidator.Attributes["controltovalidate2"] = EmailTextBox.ClientID;
            }
        }
Ejemplo n.º 11
0
        internal static void OrganizationListItemDataBound(DataListItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.Item:
            case ListItemType.AlternatingItem:
                Organization org = e.Item.DataItem as Organization;
                if (org != null)
                {
                    if (org.Expired)
                    {
                        int days = org.GraceDaysRemaining;
                        if (days > 0)
                        {
                            HyperLink expirationLink = e.Item.FindControl("ExpirationLink") as HyperLink;
                            if (expirationLink != null)
                            {
                                expirationLink.Text        = string.Format(CultureInfo.InvariantCulture, Resources.ActiveOrganizationControl_OrganizationList_ExpirationLink_Text, days);
                                expirationLink.NavigateUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.SupportPageVirtualPath) + "?o=" + org.OrganizationId.ToString("N");
                                expirationLink.Visible     = true;
                            }
                        }
                        else
                        {
                            Label expiredLabel = e.Item.FindControl("ExpiredLabel") as Label;
                            if (expiredLabel != null)
                            {
                                expiredLabel.Text    = Resources.ActiveOrganizationControl_OrganizationList_ExpiredLabel_Text;
                                expiredLabel.Visible = true;
                            }

                            LinkButton orgButton = e.Item.FindControl("OrgButton") as LinkButton;
                            if (orgButton != null)
                            {
                                orgButton.Visible = false;
                            }

                            HyperLink orgLink = e.Item.FindControl("OrgLink") as HyperLink;
                            if (orgLink != null)
                            {
                                orgLink.NavigateUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.SupportPageVirtualPath) + "?o=" + org.OrganizationId.ToString("N");
                                orgLink.Visible     = true;
                            }
                        }
                    }
                }
                break;
            }
        }
Ejemplo n.º 12
0
        private int ValidateLoginName(string loginName)
        {
            int returnValue = 0;

            ConfirmPasswordRow.Visible = true;
            if (LoginProvider.Current.LoginNameExists(loginName))
            {
                if (LoginProvider.Current.LoginInOrganization(loginName, this.OrganizationId))
                {
                    this.ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, Resources.SignupUserControl_ErrorMessage_LoginInOrganizationExists, m_Organization.Name));
                    return(1);
                }

                ClientDataSet.UserRow userRow = UserProvider.GetUserRow(loginName);
                if (userRow != null)
                {
                    FirstNameTextBox.Text = userRow.FirstName;
                    LastNameTextBox.Text  = userRow.LastName;
                }

                ConfirmPasswordRow.Visible = false;

                this.ShowDescription(string.Format(CultureInfo.CurrentCulture
                                                   , Resources.SignupUserControl_DescriptionLabel_Text_UserExists
                                                   , string.Concat(CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.PasswordRecoveryPageVirtualPath), "?l=", HttpUtility.UrlEncode(loginName))));

                returnValue = 2;
            }

            LoginTextLabel.Text = loginName;
            FirstNameTextBox.Focus();
            Step1Table.Visible = false;
            Step2Table.Visible = true;

            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                MainContainer.Style[HtmlTextWriterStyle.Height]    = "500px";
                MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-250px";
            }
            else
            {
                MainContainer.Style[HtmlTextWriterStyle.Height]    = "360px";
                MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-180px";
            }

            return(returnValue);
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Adds the Home page action.
        /// </summary>
        private void AddHomePageAction()
        {
            if (this.Count == 0)
            {
                return;
            }

            Action      homeItem  = null;
            Action      firstItem = this[0];
            UserContext user      = UserContext.Current;

            if (user != null)
            {
                homeItem = ActionProvider.FindAction(user.StartPageUrl);
            }
            else
            {
                homeItem = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl("~/default.aspx"));
                if (homeItem != null)
                {
                    if (homeItem.AuthenticationRequired)
                    {
                        homeItem = null;
                    }
                }
            }

            if (Micajah.Common.Configuration.FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern)
            {
                if (homeItem != null)
                {
                    if ((homeItem != null) && (firstItem.ActionId == homeItem.ActionId))
                    {
                        base.Remove(firstItem);
                    }
                }
            }
            else
            {
                if ((homeItem != null) && (firstItem.ActionId != homeItem.ActionId))
                {
                    base.Insert(0, homeItem.Clone());
                }
            }
        }
Ejemplo n.º 14
0
        private static void Tree_SetNodeAttributes(RadTreeNode node)
        {
            if (node == null)
            {
                return;
            }

            ActionType type       = (ActionType)Enum.Parse(typeof(ActionType), node.Category);
            string     imageUrl   = null;
            Type       typeOfThis = typeof(ActionsControl);

            if (node.ParentNode == null)
            {
                imageUrl      = ResourceProvider.GetImageUrl(typeOfThis, "Folder.gif");
                node.Expanded = true;
            }

            switch (type)
            {
            case ActionType.GlobalNavigationLink:
                if (node.ParentNode != null)
                {
                    if (imageUrl == null)
                    {
                        imageUrl = ResourceProvider.GetImageUrl(typeOfThis, "HyperLink.gif");
                    }
                }
                break;

            case ActionType.Page:
                if (imageUrl == null)
                {
                    imageUrl = ResourceProvider.GetImageUrl(typeOfThis, "Page.gif");
                }
                break;

            case ActionType.Control:
                imageUrl = ResourceProvider.GetImageUrl(typeOfThis, "Control.gif");
                break;
            }

            node.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(imageUrl);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Raises when a security module has established the identity of the user.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected virtual void Application_AuthenticateRequest(object sender, EventArgs e)
        {
            string pageUrl = Request.AppRelativeCurrentExecutionFilePath;

            if (ResourceProvider.IsResourceUrl(pageUrl))
            {
                Context.SkipAuthorization = true;
            }
            else if (ActionProvider.IsPublicPage(pageUrl))
            {
                if ((!FrameworkConfiguration.Current.WebApplication.Password.EnablePasswordRetrieval) &&
                    (string.Compare(pageUrl, ResourceProvider.PasswordRecoveryPageVirtualPath, StringComparison.OrdinalIgnoreCase) == 0))
                {
                    throw new HttpException(404, Resources.Error_404);
                }
                else
                {
                    Micajah.Common.Bll.Action action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                    if (action != null)
                    {
                        Context.SkipAuthorization = (!action.AuthenticationRequired);
                    }
                    else
                    {
                        Context.SkipAuthorization = true;
                    }

                    switch (FrameworkConfiguration.Current.WebApplication.AuthenticationMode)
                    {
                    case AuthenticationMode.Forms:
                        HttpCookie authCookie = Context.Request.Cookies[FormsAuthentication.FormsCookieName];
                        if (authCookie == null)
                        {
                            FormsIdentity    id        = new FormsIdentity(new FormsAuthenticationTicket(string.Empty, false, FrameworkConfiguration.Current.WebApplication.Login.Timeout));
                            GenericPrincipal principal = new GenericPrincipal(id, null);
                            Context.User = principal;
                        }
                        break;
                    }
                }
            }
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Renders the control and the logo of the copyright holder company.
        /// </summary>
        /// <param name="writer">The System.Web.UI.HtmlTextWriter to render content to.</param>
        /// <param name="control">The System.Web.UI.Control to render.</param>
        private static void RenderHeader(HtmlTextWriter writer, Control control)
        {
            if (writer == null)
            {
                return;
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "Mp_Hdr");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "A");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            if (control != null)
            {
                control.RenderControl(writer);
            }
            writer.RenderEndTag();

            writer.AddStyleAttribute("line-height", "normal !important");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "G");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            using (HyperLink link = new HyperLink())
            {
                if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.LogoImageUrl))
                {
                    link.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(FrameworkConfiguration.Current.WebApplication.LogoImageUrl);
                    link.ToolTip  = FrameworkConfiguration.Current.WebApplication.Name;
                }
                else
                {
                    link.Text = FrameworkConfiguration.Current.WebApplication.Name;
                }
                link.RenderControl(writer);
            }
            writer.RenderEndTag();

            writer.RenderEndTag();
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Returns the URL of the action to navigate.
        /// </summary>
        /// <param name="action">The action to get URL of.</param>
        /// <returns>The System.String that represents the URL of the action to navigate.</returns>
        public virtual string GetNavigateUrl(Action action)
        {
            if (action == null)
            {
                return(null);
            }

            if ((action.ActionId == ActionProvider.ConfigurationPageActionId) || (action.ActionId == ActionProvider.ConfigurationGlobalNavigationLinkActionId))
            {
                if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == MasterPageTheme.Modern)
                {
                    return(CustomUrlProvider.CreateApplicationRelativeUrl(ResourceProvider.AccountSettingsVirtualPath));
                }
            }
            else if (action.ActionId == ActionProvider.LoginGlobalNavigationLinkActionId)
            {
                UserContext user = UserContext.Current;
                if ((user != null) && (user.OrganizationId == Guid.Empty))
                {
                    return(CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.ActiveOrganizationPageVirtualPath));
                }
            }
            else if (action.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
            {
                if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == MasterPageTheme.Modern)
                {
                    return(string.Empty);
                }
            }
            else if (action.ActionId == ActionProvider.StartGlobalNavigationLinkActionId)
            {
                Action page = ActionProvider.FindAction(ActionProvider.StartPageActionId);

                return(page.AbsoluteNavigateUrl);
            }

            return(action.NavigateUrl);
        }
Ejemplo n.º 18
0
        protected override void OnLoad(EventArgs e)
        {
            if (!IsPostBack)
            {
                if (InstanceProvider.GetInstances(UserContext.Current.OrganizationId, true).Count == 0)
                {
                    MasterPage.Message            = Resources.GroupsControl_NoInstanceError_Message;
                    MasterPage.MessageDescription = string.Format(CultureInfo.CurrentCulture, Resources.GroupsControl_NoInstanceError_Description, CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.InstancePageVirtualPath));
                    List.Visible = false;
                }
            }

            base.OnLoad(e);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Creates a new hyperlink with specifies css class from specified action.
        /// </summary>
        /// <param name="action">The action to create link from.</param>
        /// <param name="cssClass">The css class of the link.</param>
        /// <param name="showIcon">Whether the icon of the link is shown.</param>
        /// <param name="modernTheme">Whether the theme is modern.</param>
        /// <returns>The Link that represents hyperlink with specifies css class from specified action.</returns>
        internal static Control CreateLink(Action action, string cssClass, bool showIcon, bool modernTheme)
        {
            if (action == null)
            {
                return(null);
            }
            if (cssClass == null)
            {
                cssClass = string.Empty;
            }

            HtmlInputButton button = null;
            HyperLink       link   = null;

            try
            {
                if ((action.SubmenuItemType == SubmenuItemType.Button) && (!modernTheme))
                {
                    button = new HtmlInputButton("button");
                    button.Attributes["value"]   = action.CustomName;
                    button.Attributes["class"]   = cssClass;
                    button.Attributes["onclick"] = string.Format(CultureInfo.InvariantCulture, "location.href=\"{0}\";return false;", action.CustomAbsoluteNavigateUrl);

                    string descr = action.CustomDescription;
                    if (!string.IsNullOrEmpty(descr))
                    {
                        button.Attributes["title"] = descr;
                    }

                    if (action.SubmenuItemWidth > 0)
                    {
                        button.Style[HtmlTextWriterStyle.Width] = action.SubmenuItemWidth.ToString(CultureInfo.InvariantCulture) + "px";
                    }

                    return(button);
                }
                else
                {
                    link             = new HyperLink();
                    link.CssClass    = cssClass;
                    link.NavigateUrl = action.CustomAbsoluteNavigateUrl;
                    link.ToolTip     = action.CustomDescription;

                    if (showIcon && (action.SubmenuItemType == SubmenuItemType.ImageButton))
                    {
                        using (Image image = new Image())
                        {
                            image.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(action.SubmenuItemImageUrl);
                            image.ToolTip  = action.CustomDescription;
                            link.Controls.Add(image);
                        }

                        using (LiteralControl literal = new LiteralControl(action.CustomName))
                        {
                            link.Controls.Add(literal);
                        }
                    }
                    else
                    {
                        link.Text = action.CustomName;
                    }

                    return(link);
                }
            }
            finally
            {
                if (button != null)
                {
                    button.Dispose();
                }
                if (link != null)
                {
                    link.Dispose();
                }
            }
        }
Ejemplo n.º 20
0
 protected static string GetSettingsLink(object groupId, object instanceId)
 {
     return(string.Format(CultureInfo.InvariantCulture, "{0}?GroupId={1:N}&InstanceId={2:N}", CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GroupSettingsInInstancePageVirtualPath), groupId, instanceId));
 }
Ejemplo n.º 21
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, true);

            AutoGeneratedButtonsField.InsertButtonSeparator(ButtonsSeparator);

            if (!IsPostBack)
            {
                Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery)));

                LoadResources();

                string loginName = Request.QueryString["l"];
                if (!string.IsNullOrEmpty(loginName))
                {
                    LoginTextBox.Text = loginName;
                }

                LoginTextBox.Focus();

                ResultTable.Visible = false;
            }

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

                MagicForm.ApplyStyle(FormTable);
                MagicForm.ApplyStyle(ResultTable);
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
Ejemplo n.º 22
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, true);

            AutoGeneratedButtonsField.InsertButtonSeparator(ButtonsSeparator);

            if (!this.IsPostBack)
            {
                Micajah.Common.Pages.MasterPage.SetPageTitle(this.Page, ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery)));

                this.LoadResources();
                this.ValidateResetPasswordRequest();
            }

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

                MagicForm.ApplyStyle(FormTable);

                PasswordCompareValidator.Attributes["controltovalidate2"] = ConfirmPasswordTextBox.ClientID;

                MainContainer.Style[HtmlTextWriterStyle.Height]    = "320px";
                MainContainer.Style[HtmlTextWriterStyle.MarginTop] = "-160px";
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
Ejemplo n.º 23
0
        private void LoadResources()
        {
            OrganizationName.ErrorMessage = Resources.SignupOrganizationControl_OrganizationName_ErrorMessage;
            OrganizationNameLabel.Text    = Resources.SignupOrganizationControl_OrganizationNameLabel_Text;
            OrganizationNameHelpText.Text = Resources.SignupOrganizationControl_OrganizationNameHelpText_Text;
            OrganizationNameTick.ImageUrl = EmailTick.ImageUrl = OrganizationUrlTick.ImageUrl
                                                                     = ResourceProvider.GetImageUrl(typeof(SignupOrganizationControl), "Tick.png", true);
            Email.ErrorMessage        = Resources.SignupOrganizationControl_Email_ErrorMessage;
            EmailLabel.Text           = Resources.SignupOrganizationControl_EmailLabel_Text;
            OrganizationUrlLabel.Text = Resources.SignupOrganizationControl_OrganizationUrlLabel_Text;
            Schema.Text = Uri.UriSchemeHttps + Uri.SchemeDelimiter;
            PartialCustomUrlRootAddress.Text      = "." + FrameworkConfiguration.Current.WebApplication.CustomUrl.PartialCustomUrlRootAddressesFirst;
            OrganizationUrl.ErrorMessage          = Resources.CustomUrlProvider_CustomUrlAlreadyExists;
            OrganizationUrlValidator.ErrorMessage = Resources.CustomUrlProvider_CustomUrlAlreadyExists;
            CreateMyAccountButton.Text            = Resources.SignupOrganizationControl_CreateMyAccountButton_Text;

            ModalTitleLiteral.Text                 = Resources.SignupOrganizationControl_ModalTitleLiteral_Text;
            ModalMessageLiteral.Text               = Resources.SignupOrganizationControl_ModalMessageLiteral_Text;
            ModalSelectActionLiteral.Text          = Resources.SignupOrganizationControl_ModalSelectActionLiteral_Text;
            ModalLoginLink.Text                    = Resources.SignupOrganizationControl_ModalLoginLink_Text;
            ModalSelectActionSeparatorLiteral.Text = Resources.SignupOrganizationControl_ModalSelectActionSeparatorLiteral_Text;
            CreateMyAccountModalButton.Text        = Resources.SignupOrganizationControl_CreateMyAccountModalButton_Text;

            if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.SmallLogoImageUrl))
            {
                ModalWindowHeader.Attributes["class"] += " bg";
                ModalWindowHeader.Style[HtmlTextWriterStyle.BackgroundImage] = "url(" + CustomUrlProvider.CreateApplicationAbsoluteUrl(FrameworkConfiguration.Current.WebApplication.SmallLogoImageUrl) + ")";
            }

            CaptchaLabel.Text = Resources.SignupOrganizationControl_CaptchaLabel_Text;
            AgreeLabel.Text   = string.Format(CultureInfo.InvariantCulture, Resources.SignupOrganizationControl_AgreeLabel_Text
                                              , BaseControl.GetHyperlink(FrameworkConfiguration.Current.WebApplication.Support.TermsUrl, Resources.SignupOrganizationControl_TermsLink_Text)
                                              , BaseControl.GetHyperlink(FrameworkConfiguration.Current.WebApplication.Support.PrivacyPolicyUrl, Resources.SignupOrganizationControl_PrivacyPolicyLink_Text));

            ErrorContinueLabel.Text = Resources.SignupOrganizationControl_ErrorContinueLabel_Text;
            ErrorContinueLink.Text  = Resources.SignupOrganizationControl_ErrorContinueLink_Text;

            if (string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.MobileLogoImageUrl))
            {
                LogoImage.Visible = LogoImage3.Visible = false;
            }
            else
            {
                LogoImage.ImageUrl = LogoImage3.ImageUrl = FrameworkConfiguration.Current.WebApplication.MobileLogoImageUrl;
            }
        }
Ejemplo n.º 24
0
        private void LoadLogos()
        {
            if (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme != Pages.MasterPageTheme.Modern)
            {
                if (HeaderLeftLogoLink != null)
                {
                    if (m_Organization == null)
                    {
                        if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl))
                        {
                            HeaderLeftLogoLink.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(FrameworkConfiguration.Current.WebApplication.Copyright.CompanyLogoImageUrl);
                            HeaderLeftLogoLink.ToolTip  = FrameworkConfiguration.Current.WebApplication.Copyright.CompanyName;
                            HeaderLeftLogoLink.Visible  = true;
                        }
                        else
                        {
                            HeaderLeftLogoLink.Text    = FrameworkConfiguration.Current.WebApplication.Copyright.CompanyName;
                            HeaderLeftLogoLink.Visible = true;
                        }
                    }
                    else
                    {
                        CreateLogo(m_Organization, m_Instance, ref HeaderLeftLogoLink);
                    }
                }

                if (HeaderRightLogoLink != null)
                {
                    if (!string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.LogoImageUrl))
                    {
                        HeaderRightLogoLink.ImageUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(FrameworkConfiguration.Current.WebApplication.LogoImageUrl);
                        HeaderRightLogoLink.ToolTip  = FrameworkConfiguration.Current.WebApplication.Name;
                    }
                    else
                    {
                        HeaderRightLogoLink.Text = FrameworkConfiguration.Current.WebApplication.Name;
                    }
                    HeaderRightLogoLink.Visible = true;
                }
            }

            if ((FrameworkConfiguration.Current.WebApplication.MasterPage.Theme != Pages.MasterPageTheme.Modern) || string.IsNullOrEmpty(FrameworkConfiguration.Current.WebApplication.MobileLogoImageUrl))
            {
                if (LogoImagePanel != null)
                {
                    LogoImagePanel.Visible = false;
                }
            }
            else
            {
                if (LogoImagePanel != null)
                {
                    LogoImagePanel.Visible = true;
                    if (LogoImage != null)
                    {
                        LogoImage.ImageUrl = FrameworkConfiguration.Current.WebApplication.MobileLogoImageUrl;
                        if (FrameworkConfiguration.Current.WebApplication.BigLogoImageHeight > 0)
                        {
                            m_MainContainerHeight += FrameworkConfiguration.Current.WebApplication.MobileLogoImageHeight;
                        }
                    }
                }
            }
        }
Ejemplo n.º 25
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);

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

            this.LoadResources();

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

                MagicForm.ApplyStyle(FormTable);
            }
            else
            {
                this.Page.Header.Controls.Add(Support.CreateStyleSheetLink(ResourceProvider.GetResourceUrl(ResourceProvider.LogOnStyleSheet, true)));
            }
        }
Ejemplo n.º 26
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)
            {
                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["ao"], "1", StringComparison.OrdinalIgnoreCase) == 0)
                {
                    ActiveInstanceControl.ShowError(Resources.ActiveOrganizationControl_YouAreLoggedIntoAnotherOrganization, ErrorPanel);
                }

                LogOffLink.Text = Resources.ActiveOrganizationControl_LogoffLink_Text;

                UserContext user = UserContext.Current;

                if (user.IsFrameworkAdministrator)
                {
                    OrLabel1.Text = Resources.ActiveOrganizationControl_OrText;
                    SetupLinkContainer.Visible = true;
                    SetupLink.Text             = Resources.ActiveOrganizationControl_SetupLink_Text;
                    action = ActionProvider.PagesAndControls.FindByActionId(ActionProvider.SetupPageActionId);
                    if (action != null)
                    {
                        SetupLink.NavigateUrl = action.AbsoluteNavigateUrl;
                    }
                }

                if (user.CanLogOnAsUser)
                {
                    OrLabel2.Text = Resources.ActiveOrganizationControl_OrText;
                    LogOnAsAnotherUserLinkContainer.Visible = true;
                    LogOnAsAnotherUserLink.Text             = Resources.ActiveOrganizationControl_LogOnAsAnotherUserLink_Text;
                    action = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.LoginAsUserGlobalNavigationLinkActionId);
                    if (action != null)
                    {
                        LogOnAsAnotherUserLink.NavigateUrl = action.AbsoluteNavigateUrl;
                    }
                }

                OrganizationCollection coll = LoginProvider.Current.GetOrganizationsByLoginId(user.UserId);
                int count = 0;
                if (coll != null)
                {
                    count = coll.Count;
                    if (count > 1)
                    {
                        coll  = coll.FindAllVisible();
                        count = coll.Count;
                        if (count == 1)
                        {
                            if (user.OrganizationId != Guid.Empty)
                            {
                                if (coll[0].OrganizationId != user.OrganizationId)
                                {
                                    count = 2;
                                }
                            }
                        }
                    }
                }

                if (count == 0)
                {
                    if (user.IsFrameworkAdministrator)
                    {
                        OrLabel1.Visible = false;
                    }
                    else if (user.CanLogOnAsUser)
                    {
                        OrLabel2.Visible = false;
                    }
                }

                if (count == 0)
                {
                    ActiveInstanceControl.ShowError(Resources.UserContext_ErrorMessage_YouAreNotAssociatedWithOrganizations, ErrorPanel);
                }
                else if ((count == 1) && (!user.CanLogOnAsUser))
                {
                    OrganizationArea.Visible = false;
                    OrLabel3.Visible         = false;
                    ErrorPanel.Style.Add(HtmlTextWriterStyle.PaddingBottom, "7px");
                    SelectOrganization(coll[0].OrganizationId, Request.QueryString["returnurl"], true, ErrorPanel);
                }
                else
                {
                    DescriptionLabel.Text = Resources.ActiveOrganizationControl_DescriptionLabel_Text;
                    OrLabel3.Text         = Resources.ActiveOrganizationControl_OrText;

                    coll.SortByExpiration();

                    OrganizationList.DataSource = coll;
                    OrganizationList.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)));
            }
        }
Ejemplo n.º 27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            m_IsModernTheme = (FrameworkConfiguration.Current.WebApplication.MasterPage.Theme == Pages.MasterPageTheme.Modern);
            m_UserContext   = UserContext.Current;

            this.LoadResources();

            if (!this.IsPostBack)
            {
                this.EnsureActiveInstance();
            }

            this.List_DataBind();

            if (!string.IsNullOrEmpty(this.ReturnUrl))
            {
                CancelLink.NavigateUrl = this.ReturnUrl;
            }

            DetailMenu1.ShowDescriptionAsToolTip = true;

            if (this.DisplayedSettingLevel != SettingLevels.Group)
            {
                if (this.MasterPage != null)
                {
                    if (this.ActionId != Guid.Empty)
                    {
                        this.MasterPage.CustomName = this.Action.CustomName;
                    }

                    Micajah.Common.Bll.Action action = this.MasterPage.ActiveAction;
                    while ((action != null) && (action.ActionId != ActionProvider.ConfigurationPageActionId))
                    {
                        action = action.ParentAction;
                        if (action != null)
                        {
                            if (!action.GroupInDetailMenu)
                            {
                                break;
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(this.ReturnUrl))
                    {
                        if (action != null)
                        {
                            CancelLink.NavigateUrl = action.CustomAbsoluteNavigateUrl;
                        }
                    }
                }

                if (this.Action == null)
                {
                    DetailMenu1.Visible = false;
                }
                else
                {
                    DetailMenu1.ParentActionId = m_Action.ActionId;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(this.ReturnUrl))
                {
                    CancelLink.NavigateUrl = string.Concat(CustomUrlProvider.CreateApplicationAbsoluteUrl(ResourceProvider.GroupsInstancesRolesPageVirtualPath), "?GroupId=", GroupId.ToString("N"));
                }

                DetailMenu1.Visible = false;

                if (this.DiagnoseConflictingSettings)
                {
                    CommandBar.Visible = false;
                }
            }

            if (m_IsModernTheme)
            {
                CancelLink.Visible = false;
            }
            else
            {
                AutoGeneratedButtonsField.InsertButtonSeparator(ButtonsSeparator);
            }
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Creates the global navigation links.
        /// </summary>
        /// <param name="isSecureConnection">The flag indicating whether the HTTP connection uses secure sockets.</param>
        /// <returns>The control that represents the global navigation links.</returns>
        private Control CreateGlobalNavigation(bool isSecureConnection)
        {
            ControlList        links = null;
            HyperLink          link  = null;
            HyperLink          link2 = null;
            HtmlGenericControl ul    = null;
            HtmlGenericControl ul2   = null;
            HtmlGenericControl li    = null;
            HtmlGenericControl li2   = null;

            try
            {
                if (m_ModernTheme)
                {
                    ul = new HtmlGenericControl("ul");
                    ul.Attributes["class"] = "nav pull-right";
                }
                else
                {
                    links = new ControlList();
                }

                Micajah.Common.Bll.ActionCollection items = ActionProvider.GlobalNavigationLinks.FindByActionId(ActionProvider.GlobalNavigationLinksActionId).GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);

                if (m_ModernTheme)
                {
                    li = (HtmlGenericControl)CreateApplicationLogoListItem("Al");

                    ul.Controls.Add(li);
                }
                else
                {
                    Micajah.Common.Bll.Action item = items.FindByActionId(ActionProvider.MyAccountMenuGlobalNavigationLinkActionId);

                    if (item != null)
                    {
                        Micajah.Common.Bll.ActionCollection items2 = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);

                        items.AddRange(items2);

                        items.Sort();
                    }
                }

                foreach (Micajah.Common.Bll.Action item in items)
                {
                    link             = new HyperLink();
                    link.NavigateUrl = item.CustomAbsoluteNavigateUrl;
                    link.ToolTip     = item.Description;

                    if (m_ModernTheme)
                    {
                        li = new HtmlGenericControl("li");

                        string iconUrl  = null;
                        string text     = item.CustomName;
                        string cssClass = "Icon";

                        if (item.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
                        {
                            iconUrl = string.Format(CultureInfo.InvariantCulture, "{0}{1}www.gravatar.com/avatar/{2}?s=24"
                                                    , (isSecureConnection ? Uri.UriSchemeHttps : Uri.UriSchemeHttp), Uri.SchemeDelimiter, Support.CalculateMD5Hash(m_UserContext.Email.ToLowerInvariant()));

                            cssClass += " Avtr";
                        }
                        else
                        {
                            if (item.ActionId == ActionProvider.PageHelpGlobalNavigationLinkActionId)
                            {
                                if (!m_MasterPage.VisibleHelpLink)
                                {
                                    continue;
                                }

                                link.Attributes["onclick"] = m_MasterPage.HelpLinkOnClick;
                            }

                            if (!string.IsNullOrEmpty(item.IconUrl))
                            {
                                iconUrl = item.IconUrl;
                                if (iconUrl.IndexOf("glyphicon", StringComparison.OrdinalIgnoreCase) == -1)
                                {
                                    iconUrl = CustomUrlProvider.CreateApplicationAbsoluteUrl(iconUrl);
                                }
                                else
                                {
                                    using (Label label = new Label())
                                    {
                                        label.CssClass = "glyphicon " + iconUrl;

                                        if (string.IsNullOrEmpty(text))
                                        {
                                            label.CssClass += " no-margin";
                                        }

                                        link.Controls.Add(label);
                                    }

                                    iconUrl = null;
                                }
                            }
                        }

                        if (!string.IsNullOrEmpty(iconUrl))
                        {
                            using (Image image = new Image())
                            {
                                image.ImageUrl = iconUrl;
                                image.CssClass = cssClass;

                                link.Controls.Add(image);
                            }
                        }

                        if (!string.IsNullOrEmpty(text))
                        {
                            using (LiteralControl literal = new LiteralControl(text))
                            {
                                link.Controls.Add(literal);
                            }
                        }

                        li.Controls.Add(link);
                        ul.Controls.Add(li);

                        ActionCollection childActions = item.GetAvailableChildActions(m_ActionIdList, m_IsFrameworkAdmin, m_IsAuthenticated);
                        if (childActions.Count > 0)
                        {
                            link.CssClass = "dropdown-toggle";
                            link.Attributes["data-toggle"] = "dropdown";

                            using (Label label = new Label())
                            {
                                label.CssClass = "caret";
                                link.Controls.Add(label);
                            }

                            ul2 = new HtmlGenericControl("ul");
                            ul2.Attributes["class"] = "dropdown-menu blue";

                            foreach (Micajah.Common.Bll.Action item2 in childActions)
                            {
                                li2 = new HtmlGenericControl("li");

                                link2             = new HyperLink();
                                link2.Text        = item2.CustomName;
                                link2.NavigateUrl = item2.CustomAbsoluteNavigateUrl;
                                link2.ToolTip     = item2.Description;

                                li2.Controls.Add(link2);
                                ul2.Controls.Add(li2);
                            }

                            li.Attributes["class"] = "dropdown";
                            li.Controls.Add(ul2);
                        }
                    }
                    else
                    {
                        if (item.ActionId == ActionProvider.MyAccountMenuGlobalNavigationLinkActionId)
                        {
                            if ((m_UserContext != null) && (m_UserContext.OrganizationId == Guid.Empty))
                            {
                                continue;
                            }
                        }

                        link.Text = item.CustomName;

                        links.Add(link);
                    }
                }

                if (m_ModernTheme)
                {
                    return(ul);
                }
                else
                {
                    return((links.Count > 0) ? links : null);
                }
            }
            finally
            {
                if (ul2 != null)
                {
                    ul2.Dispose();
                }
                if (li2 != null)
                {
                    li2.Dispose();
                }
                if (ul != null)
                {
                    ul.Dispose();
                }
                if (li != null)
                {
                    li.Dispose();
                }
                if (link != null)
                {
                    link.Dispose();
                }
                if (links != null)
                {
                    links.Dispose();
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Occurs when the request state (for example, session state) that is associated with the current request has been obtained.
        /// </summary>
        /// <param name="sender">The sourceRow of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        protected virtual void Application_PostAcquireRequestState(object sender, EventArgs e)
        {
            HttpContext http = HttpContext.Current;

            if (http == null)
            {
                return;
            }
            if (http.Session == null)
            {
                return;
            }

            UserContext user = null;

            Micajah.Common.Bll.Action action = null;

            CustomUrlElement customUrlSettings = FrameworkConfiguration.Current.WebApplication.CustomUrl;
            string           host = http.Request.Url.Host;
            bool             isDefaultPartialCustomUrl = false;

            if (customUrlSettings.Enabled)
            {
                isDefaultPartialCustomUrl = CustomUrlProvider.IsDefaultVanityUrl(host);
            }

            if (!isDefaultPartialCustomUrl)
            {
                if (http.Session.IsNewSession)
                {
                    user = UserContext.Current;
                    if (user != null)
                    {
                        LoginProvider.Current.UpdateSession(user.UserId, http.Session.SessionID);
                    }
                }

                if (!http.SkipAuthorization)
                {
                    if (user == null)
                    {
                        user = UserContext.Current;
                    }

                    if (user == null)
                    {
                        action = ActionProvider.FindAction(CustomUrlProvider.CreateApplicationAbsoluteUrl(Request.Url.PathAndQuery));
                        if (action != null)
                        {
                            if (action.AuthenticationRequired)
                            {
                                LoginProvider.Current.SignOut(true, Request.Url.PathAndQuery);
                            }
                        }
                    }
                    else if (!customUrlSettings.Enabled)
                    {
                        if (!LoginProvider.Current.ValidateSession(user.UserId, http.Session.SessionID))
                        {
                            LoginProvider.Current.SignOut(true, true, true);
                        }
                    }
                }
            }

            if (!customUrlSettings.Enabled)
            {
                return;
            }

            if (!((http.User != null) && (http.User.Identity != null) && http.User.Identity.IsAuthenticated))
            {
                return;
            }

            string redirectUrl    = string.Empty;
            Guid   organizationId = Guid.Empty;
            Guid   instanceId     = Guid.Empty;

            if (http.Session.IsNewSession || (string.Compare(host, UserContext.VanityUrl, StringComparison.OrdinalIgnoreCase) != 0))
            {
                if (isDefaultPartialCustomUrl)
                {
                    return;
                }

                string vanityUrl     = null;
                bool   setAuthCookie = true;

                CustomUrlProvider.ParseHost(host, ref organizationId, ref instanceId);

                if (organizationId == Guid.Empty)
                {
                    Guid userId = Guid.Empty;
                    LoginProvider.ParseUserIdentityName(out userId, out organizationId, out instanceId);

                    if (userId != Guid.Empty)
                    {
                        setAuthCookie = false;
                        vanityUrl     = CustomUrlProvider.GetVanityUrl(organizationId, instanceId);
                    }
                }
                else
                {
                    vanityUrl             = host;
                    UserContext.VanityUrl = host;
                }

                if (string.IsNullOrEmpty(vanityUrl))
                {
                    if (!isDefaultPartialCustomUrl)
                    {
                        http.Session.Abandon(); // Important fix of the issue with the same SessionID for all the child domains.

                        redirectUrl = CustomUrlProvider.CreateApplicationUri(http.Request.Url.PathAndQuery);
                    }
                }
                else
                {
                    if (string.Compare(host, vanityUrl, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        if (user == null)
                        {
                            user = UserContext.Current;
                        }

                        if (user != null)
                        {
                            try
                            {
                                if (user.OrganizationId != organizationId)
                                {
                                    user.SelectOrganization(organizationId, setAuthCookie, null, null);
                                    user.SelectInstance(instanceId, setAuthCookie, null);
                                }
                                else if (user.InstanceId != instanceId)
                                {
                                    user.SelectInstance(instanceId, setAuthCookie, null);
                                }
                            }
                            catch (AuthenticationException)
                            {
                                redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, Guid.Empty, Guid.Empty, null, CustomUrlProvider.CreateApplicationUri(host, null));
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(redirectUrl))
                    {
                        if (string.Compare(host, customUrlSettings.PartialCustomUrlRootAddressesFirst, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            http.Session.Abandon(); // Important fix of the issue with the same SessionID for all the child domains.
                        }
                        redirectUrl = CustomUrlProvider.CreateApplicationUri(vanityUrl, http.Request.Url.PathAndQuery);
                    }
                }
            }
            else
            {
                if (user == null)
                {
                    user = UserContext.Current;
                }

                if (user != null)
                {
                    CustomUrlProvider.ParseHost(host, ref organizationId, ref instanceId);

                    if (user.OrganizationId != Guid.Empty)
                    {
                        if (user.OrganizationId != organizationId)
                        {
                            redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, organizationId, instanceId, null);
                        }
                        else
                        {
                            if (instanceId == Guid.Empty)
                            {
                                if (user.InstanceId != Guid.Empty)
                                {
                                    try
                                    {
                                        user.SelectOrganization(organizationId, true, null, null);
                                    }
                                    catch (AuthenticationException)
                                    {
                                        redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, organizationId, Guid.Empty, null);
                                    }
                                }
                            }
                            else if (user.InstanceId != instanceId)
                            {
                                redirectUrl = LoginProvider.Current.GetLoginUrl(null, null, organizationId, instanceId, null);
                            }
                        }
                    }
                    else if (organizationId != Guid.Empty)
                    {
                        redirectUrl = LoginProvider.Current.GetLoginUrl(Guid.Empty, organizationId);
                    }
                }
            }

            if (!string.IsNullOrEmpty(redirectUrl))
            {
                if ((redirectUrl.IndexOf(http.Request.Url.ToString(), StringComparison.OrdinalIgnoreCase) == -1) &&
                    (http.Request.Url.ToString().IndexOf(redirectUrl, StringComparison.OrdinalIgnoreCase) == -1))
                {
                    http.Response.Redirect(redirectUrl);
                }
            }
        }
Ejemplo n.º 30
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)));
            }
        }