예제 #1
0
        private void SaveRedirection()
        {
            IRedirection redirection = new Redirection();
            var redirectionController = new RedirectionController();

            if (RedirectId > Null.NullInteger)
            {
                redirection = redirectionController.GetRedirectionById(ModuleContext.PortalId, RedirectId);
            }

            redirection.Name = txtRedirectName.Text;
            redirection.Enabled = chkEnable.Checked;
            redirection.PortalId = ModuleContext.PortalId;
            if (optRedirectSource.SelectedValue == "Tab")
            {
                redirection.SourceTabId = int.Parse(cboSourcePage.SelectedValue);
                redirection.IncludeChildTabs = chkChildPages.Checked;
            }
            else
            {
                redirection.SourceTabId = -1;
                redirection.IncludeChildTabs = false;
            }

            redirection.Type = (RedirectionType)Enum.Parse(typeof(RedirectionType), optRedirectType.SelectedValue);
            //Other, save new capabilities
            if (redirection.Type == RedirectionType.Other)
            {
                if (RedirectId > Null.NullInteger)
                {
                    // Delete capabilities that no longer exist in the grid
                    foreach (var rule in redirection.MatchRules.Where(rule => Capabilities.Where(c => c.Id == rule.Id).Count() < 1))
                    {
                        redirectionController.DeleteRule(ModuleContext.PortalId, redirection.Id, rule.Id);
                    }
                }

                // A new capabilities
                foreach (var capability in Capabilities.Where(capability => capability.Id == -1))
                {
                    redirection.MatchRules.Add(capability);
                }

                redirection.MatchRules = Capabilities;
            }
            else if (RedirectId > Null.NullInteger && redirection.MatchRules.Count > 0)
            {
                foreach(var rule in redirection.MatchRules)
                {
                    redirectionController.DeleteRule(ModuleContext.PortalId, redirection.Id, rule.Id);
                }
            }

            redirection.TargetType = (TargetType)Enum.Parse(typeof(TargetType), optRedirectTarget.SelectedValue);
            switch (redirection.TargetType)
            {
                case TargetType.Portal:
                    redirection.TargetValue = cboPortal.SelectedItem.Value;
                    break;
                case TargetType.Tab:
                    redirection.TargetValue = int.Parse(cboTargetPage.SelectedValue);
                    break;
                case TargetType.Url:
                    redirection.TargetValue = txtTargetUrl.Text;
                    break;
            }

            // Save the redirect
            redirectionController.Save(redirection);      
        }
        private void SaveRedirection()
        {
            IRedirection redirection = new Redirection();
            var redirectionController = new RedirectionController();

            if (RedirectId > Null.NullInteger)
            {
                redirection = redirectionController.GetRedirectionById(ModuleContext.PortalId, RedirectId);
            }

            redirection.Name = txtRedirectName.Text;
            redirection.Enabled = chkEnable.Checked;
            redirection.PortalId = ModuleContext.PortalId;
            if (optRedirectSource.SelectedValue == "Tab")
            {
                redirection.SourceTabId = cboSourcePage.SelectedItemValueAsInt;
                redirection.IncludeChildTabs = chkChildPages.Checked;
            }
            else
            {
                redirection.SourceTabId = -1;
                redirection.IncludeChildTabs = false;
            }

            redirection.Type = (RedirectionType)Enum.Parse(typeof(RedirectionType), optRedirectType.SelectedValue);
			if (redirection.Type == RedirectionType.SmartPhone && optRedirectType.SelectedValue != "")//save smart phone value to other type with capability match.
			{
				if (RedirectId > Null.NullInteger)
                {
                    // Delete capabilities that no longer exist in the grid
                    foreach (var rule in redirection.MatchRules)
                    {
                        redirectionController.DeleteRule(ModuleContext.PortalId, redirection.Id, rule.Id);
                    }
                }

				redirection.Type = RedirectionType.Other;
				redirection.MatchRules.Add(new MatchRule(){Capability = "IsSmartPhone", Expression = "True"});
			}
			else if (redirection.Type == RedirectionType.Other)//Other, save new capabilities
            {
                if (RedirectId > Null.NullInteger)
                {
                    // Delete capabilities that no longer exist in the grid
                    foreach (var rule in redirection.MatchRules.Where(rule => Capabilities.All(c => c.Id != rule.Id)))
                    {
                        redirectionController.DeleteRule(ModuleContext.PortalId, redirection.Id, rule.Id);
                    }
                }

                redirection.MatchRules = Capabilities;
            }
            else if (RedirectId > Null.NullInteger && redirection.MatchRules.Count > 0)
            {
                foreach(var rule in redirection.MatchRules)
                {
                    redirectionController.DeleteRule(ModuleContext.PortalId, redirection.Id, rule.Id);
                }
            }

            redirection.TargetType = (TargetType)Enum.Parse(typeof(TargetType), optRedirectTarget.SelectedValue);
            switch (redirection.TargetType)
            {
                case TargetType.Portal:
                    redirection.TargetValue = cboPortal.SelectedItem.Value;
                    break;
                case TargetType.Tab:
                    redirection.TargetValue = cboTargetPage.SelectedItemValueAsInt;
                    break;
                case TargetType.Url:
                    redirection.TargetValue = txtTargetUrl.Text;
                    break;
            }

            // Save the redirect
            redirectionController.Save(redirection);      
        }
예제 #3
0
        private void BindRedirection(int redirectId)
        {
            // Populating existing redirection settings
            if (redirectId != Null.NullInteger)
            {
                var redirectController = new RedirectionController();
                var redirect = redirectController.GetRedirectionById(ModuleContext.PortalId, redirectId);

                txtRedirectName.Text = redirect.Name;
                chkEnable.Checked = redirect.Enabled;
                chkChildPages.Checked = redirect.IncludeChildTabs;

                if (redirect.SourceTabId != -1)
                {
                    optRedirectSource.SelectedValue = "Tab";
                    cboSourcePage.SelectedIndex = cboSourcePage.Items.IndexOf(cboSourcePage.Items.FindByValue(redirect.SourceTabId.ToString()));
                }
                else
                {
                    optRedirectSource.SelectedValue = "Portal";
                }

                optRedirectType.SelectedValue = redirect.Type.ToString();
                optRedirectTarget.SelectedValue = redirect.TargetType.ToString();

                //Other, populate Capabilities
                if (redirect.Type == RedirectionType.Other)
                {
                    BindRedirectionCapabilties();
                }

                switch (redirect.TargetType)
                {
                    case TargetType.Portal:
                        if (cboPortal.Items.Count < 1) optRedirectTarget.SelectedValue = "Tab";
                        else if (cboPortal.Items.FindByValue(redirect.TargetValue.ToString()) != null)
                            cboPortal.SelectedValue = redirect.TargetValue.ToString();
                        break;
                    case TargetType.Tab:
                        if (cboTargetPage.Items.FindByValue(redirect.TargetValue.ToString()) != null)
                            cboTargetPage.SelectedValue = redirect.TargetValue.ToString();
                        break;
                    case TargetType.Url:
                        txtTargetUrl.Text = redirect.TargetValue.ToString();
                        break;
                }
            }
        }
        private void BindRedirection(int redirectId)
        {
            // Populating existing redirection settings
            if (redirectId != Null.NullInteger)
            {
                var redirectController = new RedirectionController();
                var redirect = redirectController.GetRedirectionById(ModuleContext.PortalId, redirectId);

                txtRedirectName.Text = redirect.Name;
                chkEnable.Checked = redirect.Enabled;
                chkChildPages.Checked = redirect.IncludeChildTabs;
                var tabs = new TabController().GetTabsByPortal(ModuleContext.PortalId).AsList().Where(IsVisible);
                var tabInfos = tabs as IList<TabInfo> ?? tabs.ToList();
                if (redirect.SourceTabId != -1)
                {
                    optRedirectSource.SelectedValue = "Tab";
                    cboSourcePage.SelectedPage = tabInfos.SingleOrDefault(t => t.TabID == redirect.SourceTabId);
                }
                else
                {
                    optRedirectSource.SelectedValue = "Portal";
                }

				if (IsSmartPhoneRedirect(redirect))
				{
					optRedirectType.SelectedValue = "SmartPhone";
				}
				else
				{
					optRedirectType.SelectedValue = redirect.Type.ToString();
				}

                optRedirectTarget.SelectedValue = redirect.TargetType.ToString();

                //Other, populate Capabilities
                if (redirect.Type == RedirectionType.Other)
                {
                    BindRedirectionCapabilties();
                }

                switch (redirect.TargetType)
                {
                    case TargetType.Portal:
                        if (cboPortal.Items.Count < 1) optRedirectTarget.SelectedValue = "Tab";
                        else
                            cboPortal.Select(redirect.TargetValue.ToString(), false);
                        break;
                    case TargetType.Tab:
                        int redirectTargetInt;
                        if(int.TryParse(redirect.TargetValue.ToString(), out redirectTargetInt))
                            cboTargetPage.SelectedPage = tabInfos.SingleOrDefault(t => t.TabID == redirectTargetInt);
                        break;
                    case TargetType.Url:
                        txtTargetUrl.Text = redirect.TargetValue.ToString();
                        break;
                }
            }
        }