private void LoadPagesModules(int websiteId)
        {
            //get all webpages in the selected website.
            Website     website         = Website.Get(websiteId);
            WebpageInfo websiteRootPage = website.RootWebpage;

            _webpages = Webpage.GetDescendants(websiteRootPage);
            _webpages.Insert(0, websiteRootPage);

            //List<WebModuleType> moduleTypes = WebModuleType.GetModuleTypes();

            List <WebApplicationType> webappTypes = WebApplicationType.GetApplications();

            //sort alphabetically
            webappTypes.Sort(delegate(WebApplicationType app1, WebApplicationType app2)
                             { return(app1.Name.CompareTo(app2.Name)); });

            //get applications that have >=1 addable module.
            WebAppsList.DataSource = webappTypes.FindAll(delegate(WebApplicationType app)
            {
                foreach (WebModuleType m in app.Modules.Values)
                {
                    if (m.CanAddModule)
                    {
                        return(true);
                    }
                }
                return(false);
            });
            WebAppsList.DataBind();
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Form.DefaultButton = UpdateButton.UniqueID;

            if (Request.QueryString["InstanceId"] != null)
            {
                _instanceId   = int.Parse(Request.QueryString["InstanceId"]);
                _urlReferrer += "?InstanceId=" + _instanceId;
                _link         = Webpage.GetWebpage(_instanceId);
            }
            else
            {
                Response.Redirect(_urlReferrer);
            }

            if (!IsPostBack)
            {
                //check user permissions.
                if (!BayshoreSolutions.WebModules.Security.NavigationRole.IsUserAuthorized(_instanceId, Page.User))
                {
                    throw new System.Security.SecurityException(BayshoreSolutions.WebModules.Security.Permission.MSG_SECURITY_FAILURE);
                }

                if (_link == null)
                {
                    Response.Redirect(_urlReferrer);
                }

                TextText.Text                    = _link.Text;
                PathNameEditCtl.PathName         = _link.PathName;
                TargetUrlText.Text               = _link.ExternalUrl;
                DisplayLinkInNavCheckBox.Checked = _link.Visible;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WebpageBase webpageBase = this.Page as WebpageBase;
                if (null != webpageBase)
                {
                    _webpage = webpageBase.WebpageInfo;
                }
                if (_webpage != null)
                {
                    Page.Title = webpageBase.Title;
                }
                //TemplateSetting example...
                //Header.Visible = !String.IsNullOrEmpty(HeaderImagePath);

                lblFullName.Text  = "";
                lblUserName.Text  = "";
                lblUserEmail.Text = "";

                MembershipUser user = Helpers.LoggedUser;
                if (user == null || (user != null && Roles.IsUserInRole(user.UserName, "Customer")))
                {
                    if (user != null && Roles.IsUserInRole(user.UserName, "Customer"))
                    {
                        hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey);
                        lblFullName.Text  = parentProfile.FullName;
                        lblUserName.Text  = parentProfile.FirstName;
                        lblUserEmail.Text = user.Email;
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected void SubpagesGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                WebpageInfo page = e.Row.DataItem as WebpageInfo;
                //disable the page if the user does not have permissions to it.
                e.Row.Enabled = NavigationRole.IsUserAuthorized(page.InstanceId, Page.User);

                string iconPath  = "~/WebModules/Admin/Images/Icons/Small/";
                Image  iconImage = (Image)e.Row.Cells[0].FindControl("IconImage");
                if (e.Row.Enabled)
                {
                    if (page.IsAlias || !string.IsNullOrEmpty(page.ExternalUrl))
                    {
                        iconImage.ImageUrl = iconPath + "WebpageAlias.png";
                    }
                    else
                    {
                        iconImage.ImageUrl = iconPath + "Webpage.gif";
                    }
                }
                else
                {
                    iconImage.ImageUrl = iconPath + "Security.gif";
                }
            }
        }
        public WebpageInfo GetInput_WebpageInfo(WebpageInfo page)
        {
            // If no title is specified, use the nav text
            page.Title           = string.IsNullOrEmpty(tbTitle.Text.Trim()) ? tbPageNavigationText.Text.Trim() : tbTitle.Text.Trim();
            page.Text            = tbPageNavigationText.Text;
            page.MetaKeywords    = tbMetaKeywords.Text.Trim();
            page.MetaDescription = tbMetaDescription.Text.Trim();
            page.Visible         = cbIsVisible.Checked;
            if (calPostDate.Date > DateTime.MinValue)
            {
                DateTime dtPostDate = calPostDate.Date;

                if (!string.IsNullOrEmpty(tbPostTime.Text))
                {
                    DateTime dtTimeOfDay = DateTime.Parse(tbPostTime.Text);
                    dtPostDate = dtPostDate.Add(dtTimeOfDay.TimeOfDay);
                }

                page.PostDate = dtPostDate;
            }
            else
            {
                page.PostDate = null;
            }

            if (calRemoveDate.Date > DateTime.MinValue)
            {
                page.RemoveDate = calRemoveDate.Date;
            }
            else
            {
                page.RemoveDate = null;
            }
            return(page);
        }
Exemplo n.º 6
0
        private void InitModule()
        {
            int moduleId = 0;

            int.TryParse(Request["ModuleId"], out moduleId);
            this.ModuleId = moduleId;

            WebModuleInfo module = WebModule.GetModule(this.ModuleId);
            WebpageInfo   page   = null;

            if (this.ModuleId <= 0 ||
                null == module ||
                null == (page = module.Webpage))
            {
                cms.Admin.RedirectToMainMenu();
            }
            this.PageNavigationId = page.InstanceId;

            //check user permissions.
            if (!BayshoreSolutions.WebModules.Security.NavigationRole.IsUserAuthorized(this.PageNavigationId, Page.User))
            {
                throw new System.Security.SecurityException("The current user does not have permission to access this resource.");
            }

            ModuleName.Text    = module.Name;
            ModulTypeName.Text = module.WebModuleType.Name;
            Page.Title         = module.WebModuleType.Name + " Module";
            MainMenuLink.HRef  = cms.Admin.GetMainMenuUrl(this.PageNavigationId);

            EnsureModule();
        }
Exemplo n.º 7
0
        protected override void OnInit(EventArgs e)
        {
            //unfortunately PagePicker now requires "instanceId" or "parentInstanceID" to be in the query string.
            //we should probably expose a setter in the future, but it's not quite that simple...
            int navigationId;

            if (int.TryParse(Request.QueryString["instanceId"], out navigationId)
                //admin pages such as AddLink.aspx won't have an instance id.
                || int.TryParse(Request.QueryString["parentInstanceID"], out navigationId))
            {
                WebpageInfo webpage = Webpage.GetWebpage(navigationId);
                if (null == webpage)
                {
                    throw new ArgumentException("Invalid page.");
                }
                //get the webpage's website by recursive lookup.
                Website website = webpage.Website;
                if (null == website)
                {
                    throw new InvalidOperationException("The current page is not associated with a website. A pages hierarchy cannot be constructed.");
                }
                //magically override the SiteMapProvider root nav id. (yuck)
                BayshoreSolutions.WebModules.SiteMapProvider.magic_rootNavigationId =
                    website.RootNavigationId;
            }
            else
            { //we're screwed.
                navigationId = Website.Current.RootNavigationId;
            }

            base.OnInit(e);
        }
Exemplo n.º 8
0
        private void InitModule()
        {
            int moduleId = 0;

            int.TryParse(Request["ModuleId"], out moduleId);
            this.ModuleId = moduleId;

            WebModuleInfo module = WebModule.GetModule(this.ModuleId);
            WebpageInfo   page   = null;

            if (this.ModuleId <= 0 ||
                null == module ||
                null == (page = module.Webpage))
            {
                cms.Admin.RedirectToMainMenu();
                //uncomment line below (and remove line above) for legacy WebModules.
                //Response.Redirect("~/WebModules/Admin/MyWebsite/Default.aspx?instanceId=" + Webpage.RootNavigationId);
            }
            this.PageNavigationId = page.InstanceId;

            //check user permissions.
            if (!BayshoreSolutions.WebModules.Security.NavigationRole.IsUserAuthorized(this.PageNavigationId, Page.User))
            {
                throw new System.Security.SecurityException("The current user does not have permission to access this resource.");
            }

            ModuleName.Text    = module.Name;
            ModulTypeName.Text = module.WebModuleType.Name;
            MainMenuLink.HRef  = cms.Admin.GetMainMenuUrl(this.PageNavigationId);
            //uncomment line below (and remove line above) for legacy WebModules.
            //MainMenuLink.HRef = "~/WebModules/Admin/MyWebsite/Default.aspx?instanceId=" + this.PageNavigationId;

            EnsureModule();
        }
        protected void MasterDetail_Item_List_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                WebModuleInfo    MasterDetailModule = (WebModuleInfo)e.Row.DataItem;
                WebpageInfo      page = MasterDetailModule.Webpage;
                MasterDetailItem item = MasterDetailItem.GetSafeResource(MasterDetailModule.Id);
                System.Web.UI.HtmlControls.HtmlAnchor selectLink = (System.Web.UI.HtmlControls.HtmlAnchor)e.Row.FindControl("SelectLink");
                selectLink.HRef = ResolveUrl(MasterDetailModule.GetEditUrl())
                                  //cheesy
                                  + "&returnTo=" + Server.UrlEncode(Request.Url.PathAndQuery);

                selectLink.InnerHtml = MasterDetailItem.Chop(page.Title, 45, true);

                Literal postDateCtl = (Literal)e.Row.FindControl("PostDateCtl");
                if (page.PostDate.HasValue)
                {
                    postDateCtl.Text = page.PostDate.Value.ToShortDateString();
                    if (page.PostDate.Value.TimeOfDay.TotalSeconds > .001)
                    {
                        postDateCtl.Text = string.Format("{0} {1}", postDateCtl.Text, page.PostDate.Value.ToShortTimeString());
                    }
                }

                CheckBox visibleCtl = (CheckBox)e.Row.FindControl("VisibleCtl");
                visibleCtl.Checked = page.Visible;

                CheckBox featuredCtl = (CheckBox)e.Row.FindControl("FeaturedCtl");
                featuredCtl.Checked = item.IsFeatured;
            }
        }
Exemplo n.º 10
0
        private void InitModule()
        {
            int moduleId = 0;

            int.TryParse(Request["ModuleId"], out moduleId);
            this.ModuleId = moduleId;

            WebModuleInfo module = WebModule.GetModule(this.ModuleId);
            WebpageInfo   page   = null;

            if (this.ModuleId <= 0 ||
                null == module ||
                null == (page = module.Webpage))
            {
                cms.Admin.RedirectToMainMenu();
            }
            Page.Title = module.WebModuleType.Name + " Module";

            if (string.IsNullOrEmpty(txtStartDate.Text))
            {
                txtStartDate.Text = DateTime.Now.AddMonths(-1).ToShortDateString();
            }
            if (string.IsNullOrEmpty(txtEndDate.Text))
            {
                txtEndDate.Text = DateTime.Now.ToShortDateString();
            }
        }
Exemplo n.º 11
0
        private void InitModule()
        {
            int moduleId = 0;

            int.TryParse(Request.QueryString["ModuleId"], out moduleId);
            this.ModuleId = moduleId;

            WebModuleInfo module = WebModule.GetModule(this.ModuleId);
            WebpageInfo   page   = null;

            if (this.ModuleId <= 0 ||
                null == module ||
                null == (page = module.Webpage))
            {
                Redirect(Webpage.RootNavigationId);
            }
            this.PageNavigationId = page.InstanceId;

            //check user permissions.
            if (!BayshoreSolutions.WebModules.Security.NavigationRole.IsUserAuthorized(this.PageNavigationId, Page.User))
            {
                throw new System.Security.SecurityException("The current user does not have permission to access this resource.");
            }

            HeaderCtl.Text = module.WebModuleType.Name;

            EnsureModule();
        }
Exemplo n.º 12
0
        private void InitModule()
        {
            int moduleId = 0;

            int.TryParse(Request["ModuleId"], out moduleId);
            this.ModuleId = moduleId;

            _webmodule = WebModule.GetModule(moduleId);

            WebpageInfo page = null;

            if (this.ModuleId <= 0 ||
                null == _webmodule ||
                null == (page = _webmodule.Webpage))
            {
                Admin.RedirectToMainMenu();
            }
            this.PageNavigationId = page.InstanceId;

            //check user permissions.
            if (!BayshoreSolutions.WebModules.Security.NavigationRole.IsUserAuthorized(this.PageNavigationId, Page.User))
            {
                throw new System.Security.SecurityException("The current user does not have permission to access this resource.");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Msg.Visible = false;

            //string q_siteId = Request.QueryString["SiteId"];
            //if (null == q_siteId) LoadList();
            //this.SiteId = int.Parse(q_siteId);

            if (!int.TryParse(Request.QueryString["instanceId"], out _rootPageNavigationId))
            {
                throw new ArgumentException("Invalid instance/navigation id.");
            }

            WebpageInfo page = Webpage.GetWebpage(_rootPageNavigationId);

            if (page.ParentInstanceId != Webpage.RootNavigationId)
            {
                throw new ArgumentException("Invalid instance/navigation id: only a top-level page may be associated with a website.");
            }

            if (!this.Page.IsPostBack)
            {
                //check user permissions.
                if (!BayshoreSolutions.WebModules.Security.Permission.AllowManageSystem())
                {
                    throw new System.Security.SecurityException(BayshoreSolutions.WebModules.Security.Permission.MSG_SECURITY_FAILURE);
                }

                EditItem();
            }
        }
        public WebpageInfo CreatePage(int parentPageNavigationId)
        {
            WebpageInfo currentPage = Webpage.GetWebpage(parentPageNavigationId);
            WebpageInfo newPage     = GetInput_WebpageInfo(currentPage);

            Webpage.WebpageCreateStatus status;
            newPage.ParentInstanceId = parentPageNavigationId;

            //this will be sanitized by CreateWebpage()
            newPage.PathName = string.IsNullOrEmpty(tbTitle.Text.Trim()) ? tbPageNavigationText.Text.Trim() : tbTitle.Text.Trim();

            // Set the template
            if (!String.IsNullOrEmpty(ModuleTemplate))
            {
                var tplGroup = ModuleTemplate.Replace(" - ", "-").Split('-');
                newPage.TemplateGroup = tplGroup[0];
                newPage.Template      = tplGroup[1];
            }

            newPage = Webpage.CreateWebpage(newPage, out status);
            if (status != Webpage.WebpageCreateStatus.Success)
            {
                throw new InvalidOperationException("page creation failed: " + status);
            }

            return(newPage);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.Form.DefaultButton = UpdateButton.UniqueID;

            _instanceId = Convert.ToInt32(Request.QueryString["InstanceId"]);
            _moduleId   = Convert.ToInt32(Request.QueryString["ModuleId"]);
            _versionId  = Convert.ToInt32(Request.QueryString["VersionId"]);

            if (Request.QueryString["InstanceId"] != null)
            {
                urlReferrer += "?InstanceId=" + Request.QueryString["InstanceId"];
            }

            if (!IsPostBack)
            {
                //check user permissions.
                if (!BayshoreSolutions.WebModules.Security.NavigationRole.IsUserAuthorized(_instanceId, Page.User))
                {
                    throw new System.Security.SecurityException(BayshoreSolutions.WebModules.Security.Permission.MSG_SECURITY_FAILURE);
                }

                WebpageInfo   page   = Webpage.GetWebpage(_instanceId);
                WebModuleInfo module = WebModule.GetModule(_moduleId);

                Cms.Admin.BindPlaceholdersToList(page, PlaceholderDropDownList, module.Placeholder);
                ModuleNameTextBox.Text          = module.Name;
                ModuleTypeName.InnerText        = module.WebModuleType.Name;
                ModuleTypeDescription.InnerText = module.WebModuleType.Description;
            }
        }
Exemplo n.º 16
0
        public static List <WebModuleInfo> GetMasterDetailChildrenFiltered(int moduleId,
                                                                           bool filteryByPostDateAndRemoveDate,
                                                                           bool orderByMostRecentPosting,
                                                                           string filterTag)
        {
            //get the module object.
            WebModuleInfo module = WebModule.GetModule(moduleId);
            //get the container page of the module.
            WebpageInfo page = module.Webpage;
            //get all the MasterDetail modules on the child pages.
            List <WebpageInfo>   childPages          = page.Children;
            List <WebModuleInfo> MasterDetailModules = new List <WebModuleInfo>();

            foreach (WebpageInfo p in childPages)
            {
                MasterDetailModules.AddRange(p.Modules.FindAll(
                                                 delegate(WebModuleInfo m)
                {
                    return(m.WebModuleType == MasterDetailItem.ModuleType && !m.IsAlias);
                }));
            }

            if (filteryByPostDateAndRemoveDate)
            { //remove premature/expired/non-visible items.
                MasterDetailModules.RemoveAll(
                    delegate(WebModuleInfo m)
                {
                    WebpageInfo p = m.Webpage;
                    return((p.PostDate.HasValue && DateTime.Now < p.PostDate) ||
                           (p.RemoveDate.HasValue && DateTime.Today >= p.RemoveDate) ||
                           (!p.Visible));
                });
            }

            if (!string.IsNullOrEmpty(filterTag))
            {
                //remove non-matching tags.
                MasterDetailModules.RemoveAll(
                    delegate(WebModuleInfo m)
                {
                    MasterDetailItem item = MasterDetailItem.GetSafeResource(m.Id);
                    string[] tagArray     = item.Tags.Split(',');
                    foreach (var s in tagArray)
                    {
                        if (s == filterTag)
                        {
                            return(false);
                        }
                    }
                    return(true);
                });
            }

            if (orderByMostRecentPosting)
            {
                MasterDetailModules.Sort(CompareWebModulesByPostDate);
            }

            return(MasterDetailModules);
        }
Exemplo n.º 17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WebpageBase webpageBase = this.Page as WebpageBase;

            if (null != webpageBase)
            {
                _webpage = webpageBase.WebpageInfo;
            }
            if (_webpage != null)
            {
                PageNameLiteral.Text = _webpage.Text;
                Page.Title           = webpageBase.Title;
            }
            lblUserName.Text  = "";
            lblUserEmail.Text = "";
            lblFullName.Text  = "";
            MembershipUser user = Helpers.LoggedUser;

            if (user == null || (user != null && Roles.IsUserInRole(user.UserName, "Customer")))
            {
                if (user != null && Roles.IsUserInRole(user.UserName, "Customer"))
                {
                    hccUserProfile parentProfile = hccUserProfile.GetParentProfileBy((Guid)user.ProviderUserKey);
                    lblFullName.Text  = parentProfile.FullName;
                    lblUserName.Text  = parentProfile.FirstName;
                    lblUserEmail.Text = user.Email;
                }
            }
        }
Exemplo n.º 18
0
        private void LoadExistingModules()
        {
            ExistingModulesPagesSelect.Items.Clear();
            UseExistingModule.Enabled = true;

            ExistingModulePanel.Visible = UseExistingModule.Checked;
            if (UseExistingModule.Checked)
            {
                WebpageInfo        currentPage        = Webpage.GetWebpage(_instanceId);
                WebModuleType      selectedModuleType = GetSelectedModuleType();
                List <WebpageInfo> allPages           = Webpage.GetDescendants(
                    Webpage.GetWebpage(currentPage.Website.RootNavigationId));
                allPages.Add(currentPage.Website.RootWebpage);

                List <WebpageInfo> pagesWithSelectedModuleType =
                    PagesModulesList.GetPagesWithModuleType(selectedModuleType, allPages);

                //sort by path
                pagesWithSelectedModuleType.Sort(
                    delegate(WebpageInfo p1, WebpageInfo p2)
                {
                    return(p1.Path.CompareTo(p2.Path));
                });

                bool existingModules = (pagesWithSelectedModuleType.Count > 0);
                ExistingModulesPagesSelect.Visible = existingModules;
                UseExistingModule.Enabled          = existingModules;
                NoExistingModulesFoundCtl.Visible  = !existingModules;
                if (!existingModules)
                {
                    NoExistingModulesFoundCtl.Text = string.Format("There are no existing '{0}' modules.",
                                                                   selectedModuleType.Name);
                    UseExistingModule.Checked = false;
                }
                else
                {
                    foreach (WebpageInfo p in pagesWithSelectedModuleType)
                    {
                        //find all modules of the specified type
                        //(a page may have multiple modules of the same type).
                        List <WebModuleInfo> modules =
                            p.Modules.FindAll(delegate(WebModuleInfo m)
                        {
                            return(!m.IsAlias &&  //currently, we don't support "alias to alias".
                                   m.WebModuleType.Name == selectedModuleType.Name);
                        });
                        foreach (WebModuleInfo m in modules)
                        {
                            //page path + module name.
                            ExistingModulesPagesSelect.Items.Add(new ListItem(
                                                                     ResolveUrl(p.Path) + " - " + m.Name,
                                                                     m.Id.ToString()));
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
        protected void RolesDropDown_SelectedIndexChanged(object sender, EventArgs e)
        {
            WebpageInfo p = Webpage.GetWebpage(_instanceId);

            p.AddRoleToAcl(RolesDropDown.Text);

            RolesDropDown.ClearSelection();
            load_();
        }
        /// <summary>Add webpage targeting criteria for the DSA ad group.</summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="adGroupResourceName">The resource name of the ad group for which targeting
        /// is aded.</param>
        private static void AddWebPageCriteria(GoogleAdsClient client, long customerId,
                                               string adGroupResourceName)
        {
            // Get the AdGroupCriterionService.
            AdGroupCriterionServiceClient adGroupCriterionService =
                client.GetService(Services.V4.AdGroupCriterionService);

            // Create the criterion.
            AdGroupCriterion adGroupCriterion = new AdGroupCriterion()
            {
                AdGroup      = adGroupResourceName,
                CpcBidMicros = 1_000_000,
                Status       = AdGroupCriterionStatus.Paused,

                // Set the webpage targeting criteria.
                Webpage = new WebpageInfo()
                {
                    CriterionName = "Special Offers",
                    Conditions    =
                    {
                        // Adds the url targeting criteria.
                        new WebpageConditionInfo()
                        {
                            Operand  = WebpageConditionOperand.Url,
                            Argument = "/specialoffers"
                        },
                        // Adds the page title criteria.
                        // The list of webpage targeting conditions are
                        // and-ed together when evaluated for targeting.
                        new WebpageConditionInfo()
                        {
                            Operand  = WebpageConditionOperand.PageTitle,
                            Argument = "Special Offer"
                        }
                    }
                }
            };

            // Create the operation.
            AdGroupCriterionOperation operation = new AdGroupCriterionOperation()
            {
                Create = adGroupCriterion
            };

            // Add the webpage criteria.
            MutateAdGroupCriteriaResponse response =
                adGroupCriterionService.MutateAdGroupCriteria(
                    customerId.ToString(), new[] { operation });

            // Displays the results.
            Console.WriteLine($"Added ad group criterion with resource name " +
                              $"'{response.Results[0].ResourceName}'");
        }
    }
Exemplo n.º 21
0
        protected void IsPublic_CheckedChanged(object sender, EventArgs e)
        {
            WebpageInfo p = Webpage.GetWebpage(_instanceId);

            p.IsPublic = IsPublic.Checked;
            Webpage.UpdateWebpage(p);

            //TODO: use Webpage.ForEachDescendant() to propogate changes down the tree.

            load_(p);
        }
Exemplo n.º 22
0
        protected void AclList_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int    navId    = int.Parse(AclList.DataKeys[e.RowIndex].Values[0].ToString());
            string roleName = AclList.DataKeys[e.RowIndex].Values[1].ToString();

            WebpageInfo p = Webpage.GetWebpage(navId);

            p.RemoveRoleFromAcl(roleName);

            load_();
        }
        //if WebpageInfo.MetaDescription is empty, generates a summary based on the BodyText.
        public string GetSummary(WebpageInfo p)
        {
            string summary = this.ShortDescription;

            if (null == summary || summary.Trim().Length == 0)
            {
                //auto-generate summary
                string fullBodyTextWithoutHtmlTags = Bss.Web.Html.StripTags(this.LongDescription);
                summary = Chop(fullBodyTextWithoutHtmlTags, 300, true);
            }
            return(summary);
        }
        protected void UpdateButton_Click(object sender, EventArgs e)
        {
            WebpageInfo p = Webpage.GetWebpage(_instanceId);

            if (null == p)
            {
                throw new ArgumentException("Invalid navigation id (page not found).");
            }
            WebModule.UpdatePageModuleSettings(ModuleNameTextBox.Text,
                                               p.Id, _moduleId, PlaceholderDropDownList.SelectedValue);
            Response.Redirect(urlReferrer);
        }
        public WebModuleInfo CreateModule(WebpageInfo page)
        {
            WebModuleType moduleType = MasterDetailItem.ModuleType;

            return(WebModule.CreateModule(
                       MasterDetailItem.Chop(page.Title, 30, false),
                       moduleType.WebApplicationType.Name,
                       moduleType.Name,
                       page.Id,
                       "Body",
                       -1));
        }
        //create new content item, content resource, cms page, and cms module.
        public void CreateNewContentPageModule(int parentPageNavigationId)
        {
            //create a new page, using the parent page as a base.
            //properties such as title/keywords/description are set from user inputs.
            WebpageInfo page = CreatePage(parentPageNavigationId);
            //create a MasterDetail module on the new page.
            WebModuleInfo module = CreateModule(page);

            //set the module id for the below methods to use.
            this.ModuleId = module.Id;

            SaveMasterDetailItem();
            Webpage.SortWebpageUp(page.InstanceId);
        }
        private void LoadWebsitesSelect()
        {
            WebsiteSelect.Items.Clear();
            foreach (Website website in Website.Get())
            {
                WebpageInfo rootPage = Webpage.GetWebpage(website.RootNavigationId);

                WebsiteSelect.Items.Add(
                    new ListItem(string.Format("{0} (root page: {1})",
                                               website.Resource.Name,
                                               rootPage.Text),
                                 website.SiteId.ToString()));
            }
        }
        // [END add_campaign_asset_set]

        // [START add_dsa_target]
        /// <summary>
        /// Adds the DSA target.
        /// </summary>
        /// <param name="client">The Google Ads client.</param>
        /// <param name="customerId">The Google Ads customer ID for which the call is made.</param>
        /// <param name="adGroupId">The ad group to which DSA label targeting is added.</param>
        /// <param name="dsaPageUrlLabel">The DSA page URL label.</param>
        private static void AddDsaTarget(
            GoogleAdsClient client, long customerId, long adGroupId, string dsaPageUrlLabel)
        {
            AdGroupCriterionServiceClient adGroupCriterionService = client.GetService(
                Services.V10.AdGroupCriterionService);

            string adGroupResourceName = ResourceNames.AdGroup(customerId, adGroupId);

            // Creates the webpage condition info that targets an advertiser's webpages
            // based on the custom label specified by the dsaPageUrlLabel (e.g. "discounts").
            WebpageConditionInfo webpageConditionInfo = new WebpageConditionInfo()
            {
                Operand  = WebpageConditionOperand.CustomLabel,
                Argument = dsaPageUrlLabel
            };

            // Creates the webpage info, or criterion for targeting webpages of an
            // advertiser's website.
            WebpageInfo webpageInfo = new WebpageInfo()
            {
                CriterionName = "Test Criterion",
                Conditions    = { webpageConditionInfo }
            };

            // Creates the ad group criterion.
            AdGroupCriterion adGroupCriterion = new AdGroupCriterion()
            {
                AdGroup      = adGroupResourceName,
                Webpage      = webpageInfo,
                CpcBidMicros = 1_500_000
            };

            // Creates the operation.
            AdGroupCriterionOperation operation = new AdGroupCriterionOperation()
            {
                Create = adGroupCriterion
            };

            // Adds the ad group criterion.
            MutateAdGroupCriteriaResponse response =
                adGroupCriterionService.MutateAdGroupCriteria(
                    customerId.ToString(), new[] { operation });

            string resourceName = response.Results[0].ResourceName;

            // Displays the results.
            Console.WriteLine($"Created ad group criterion with resource " +
                              $"name '{resourceName}'.");
        }
Exemplo n.º 29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //check user permissions.
            if (_instanceId.HasValue && !BayshoreSolutions.WebModules.Security.NavigationRole.IsUserAuthorized(_instanceId.Value, Page.User))
            {
                throw new System.Security.SecurityException(BayshoreSolutions.WebModules.Security.Permission.MSG_SECURITY_FAILURE);
            }

            int    n;
            string strModuleId = Request.QueryString["moduleId"];

            if (int.TryParse(strModuleId, out n))
            {
                _moduleId = n;
                _module   = WebModule.GetModule(_moduleId.Value);
            }

            string strInstanceId = Request.QueryString["InstanceId"];

            if (int.TryParse(strInstanceId, out n))
            {
                _instanceId = n;
                _page       = Webpage.GetWebpage(_instanceId.Value);
            }

            if (!IsPostBack)
            {
                lvPages.DataSource = null;
                if (_moduleId.HasValue)
                {
                    var pages = (from w in Webpage.GetWebpagesSharingModule(_moduleId.Value)
                                 orderby w.Path
                                 select new { w.InstanceId, w.Path }).Distinct();
                    lvPages.DataSource = pages;
                }
                lvPages.DataBind();

                if (Request.UrlReferrer != null)
                {
                    Referrer = Request.UrlReferrer.PathAndQuery;
                }

                if (_module != null)
                {
                    literalModuleName.Text = _module.Name;
                    literalModuleType.Text = _module.ModuleTypeName;
                }
            }
        }
Exemplo n.º 30
0
        // [END add_dynamic_page_feed]

        // [START add_dynamic_page_feed_2]
        private void AddDsaTarget(GoogleAdsClient client, long customerId, long adGroupId,
                                  string dsaPageUrlLabel)
        {
            // Get the AdGroupCriterionService.
            AdGroupCriterionServiceClient adGroupCriterionService = client.GetService(
                Services.V10.AdGroupCriterionService);

            // Create the webpage condition info.
            WebpageConditionInfo webpageConditionInfo = new WebpageConditionInfo()
            {
                Operand  = WebpageConditionOperand.CustomLabel,
                Argument = dsaPageUrlLabel,
            };

            // Creates the webpage info.
            WebpageInfo webpageInfo = new WebpageInfo()
            {
                CriterionName = "Test Criterion",
                Conditions    = { webpageConditionInfo }
            };

            // Creates the ad group criterion.
            AdGroupCriterion adGroupCriterion = new AdGroupCriterion()
            {
                AdGroup      = ResourceNames.AdGroup(customerId, adGroupId),
                Webpage      = webpageInfo,
                CpcBidMicros = 1_500_000
            };

            // Create the operation.
            AdGroupCriterionOperation operation = new AdGroupCriterionOperation()
            {
                Create = adGroupCriterion
            };

            // Add the ad group criterion.
            MutateAdGroupCriteriaResponse mutateAdGroupCriteriaResponse =
                adGroupCriterionService.MutateAdGroupCriteria(customerId.ToString(),
                                                              new[] { operation });

            // Display the results.
            foreach (MutateAdGroupCriterionResult result in mutateAdGroupCriteriaResponse.Results)
            {
                Console.WriteLine($"Created ad group criterion with resource name " +
                                  $"'{result.ResourceName}'.");
            }
        }