protected void Page_Load(object sender, EventArgs e)
        {
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            var homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath.ToString());
            homePageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);

            //Add dynamic content to header
            HtmlHead head = (HtmlHead)Page.Header;

            //Add Open Tag
            if (Session["sess_User"] != null)
            {
                User objUser = (User)Session["sess_User"];
                if (objUser.Preferences != null)
                {
                    if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
                    {
                        head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
                    }
                }
            }

            //Add Page Title
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();
            markupBuilder.Append(@"<meta name='viewport' content='width=1020'>");
            markupBuilder.Append(@"<link rel='apple-touch-icon' href='/virginactive/images/apple-touch-icon.png'>");
            markupBuilder.Append(@"<link rel='shortcut icon' href='/virginactive/images/favicon.ico'>");
            markupBuilder.Append(@"<link href='/virginactive/css/fonts.css' rel='stylesheet'>");
            markupBuilder.Append(@"<link href='/va_campaigns/css/campaign.css' rel='stylesheet'>");
            head.Controls.Add(new LiteralControl(markupBuilder.ToString()));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            LandingPageItem currentLanding = null;

            if(currentItem!=null)
                currentLanding = new LandingPageItem(currentItem.InnerItem.Parent);

            if (currentLanding != null)
            {
                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                urlOptions.AlwaysIncludeServerUrl = true;
                urlOptions.AddAspxExtension = false;
                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                OriginalReferer = currentLanding.UrlToTweet.Rendered;
                TwitterShareText = currentItem.TwitterShareText.Rendered;
                FacebookShareText = currentItem.FacebookShareText.Rendered;
                GoogleShareText = currentItem.GooglePlusShareText.Rendered;

                if (currentItem.InnerItem.Parent != null)
                {
                    TwitterUsername = new LandingPageItem(currentItem.InnerItem.Parent).Username.Rendered;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Set featured promo link and home page link
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            //Get widget details
            cookieRibbon = Sitecore.Context.Database.GetItem(ItemPaths.CookieRibbon);

            cookieForm = Sitecore.Context.Database.GetItem(ItemPaths.CookiesForm);

            if (cookieForm != null)
            {

                urlOptions.SiteResolving = Sitecore.Configuration.Settings.Rendering.SiteResolving;
                cookieFormUrl = LinkManager.GetItemUrl(cookieForm, urlOptions);
            }

            //            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script>
            //		            $(function(){
            //	                    DisableCookies();
            //                    });
            //                </script>"));
        }
        private void BindClubDropDown()
        {
            clubFindSelect.Items.Add(new ListItem(Translate.Text("Select a club"), ""));

            List<Club> clubs = GetClubListByLandingId(_landingId);

            if (clubs != null)
            {
                foreach (Club club in clubs)
                {
                    string clubLabel = HtmlRemoval.StripTagsCharArray(club.ClubItm.Clubname.Text).Trim();

                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = false;
                    urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                    string clubUrl = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item, urlOptions) + "/enquiry?_clubId=" + club.ClubItm.ClubId.Rendered;

                    if(Sitecore.Context.Item.TemplateID.ToString() == Settings.LandingPagesEnquiryTemplate)
                        clubUrl = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item, urlOptions) + "?_clubId=" + club.ClubItm.ClubId.Rendered;

                    ListItem lst = new ListItem(clubLabel, clubUrl);
                    clubFindSelect.Items.Add(lst);
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get Form Submission data back from session object
            if (Session["sess_FormSubmission"] != null)
            {
                Feedback objFeedback = (Feedback)Session["sess_FormSubmission"];

                //Populate labels on page
                ClubName = SitecoreHelper.GetClubNameOnClubId(objFeedback.PrimaryClubID);
                CustomerName = objFeedback.Customer.Firstname + " " + objFeedback.Customer.Surname;
                EmailAddress = objFeedback.Customer.EmailAddress;
                Telephone = objFeedback.Customer.TelephoneNumber;
                SubscribeMessage = objFeedback.Customer.SubscribeToNewsletter ? Translate.Text("You have opted to receive our newsletter") : Translate.Text("You have opted NOT to receive our newsletter");

                //Set home and club home urls
                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                urlOptions.AlwaysIncludeServerUrl = true;
                urlOptions.AddAspxExtension = false;
                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                ClubItem club = SitecoreHelper.GetClubOnClubId(objFeedback.PrimaryClubID);
                ClubHomeUrl = Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions);

                string startPath = Sitecore.Context.Site.StartPath.ToString();
                var homeItem = Sitecore.Context.Database.GetItem(startPath);
                HomeUrl = LinkManager.GetItemUrl(homeItem, urlOptions);

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                listing = new YourHealthListingItem( article.InnerItem.Axes.SelectSingleItem(String.Format(@"ancestor-or-self::*[@@tid=""{0}""]", YourHealthListingItem.TemplateId)));

                if (Session["sess_User"] != null)
                {
                    User objUser = (User)Session["sess_User"];

                    if (objUser.Preferences.SocialCookies)
                    {
                        Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                        urlOptions.AlwaysIncludeServerUrl = true;
                        urlOptions.AddAspxExtension = true;
                        urlOptions.LanguageEmbedding = LanguageEmbedding.Never;
                        articleUrl = Sitecore.Links.LinkManager.GetItemUrl(article, urlOptions);

                        //Have permission to load in Social
                        showSocial = true;
                    }
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Could not get Your health listing ancestor: {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get widget details
            //clubFinder = Sitecore.Context.Database.GetItem(ItemPaths.IndoorTriathlonClubFinderWidget);
            registrationForm = Sitecore.Context.Database.GetItem(ItemPaths.IndoorTriathlonRegistrationForm);

            if (currentItem.Panel1title.Rendered == "")
            {
                panel1.Visible = false;
            }
            if (currentItem.Panel2title.Rendered == "")
            {
                panel2.Visible = false;
            }
            if (currentItem.Panel3title.Rendered == "")
            {
                panel3.Visible = false;
            }
            if (currentItem.Panel4title.Rendered == "")
            {
                panel4.Visible = false;
            }

            //Add dynamic content
            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script src=""/virginactive/scripts/indoortriathlon/indoor-tri.js""></script>"));

            //Add club list
            System.Text.StringBuilder markupBuilder;
            markupBuilder = new System.Text.StringBuilder();

            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            foreach (Item item in currentItem.Clubs.ListItems)
            {
                ClubItem club = (ClubItem)item;
                if (!club.IsHiddenFromMenu())
                {

                    if (club.PlaceholderCampaign.Item == null)
                    {
                        markupBuilder.Append(@"<li><a href=""" + Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions) + @""">" + club.Clubname.Rendered + @"</a></li>");
                    }
                    else
                    {
                        Item campaign = new IndoorEventsItem(club.PlaceholderCampaign.Item);
                        markupBuilder.Append(@"<li><a href=""" + Sitecore.Links.LinkManager.GetItemUrl(campaign, urlOptions) + @""">" + club.Clubname.Rendered + @"</a></li>");
                    }
                }
            }

            clubList.Text = markupBuilder.ToString();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //Set featured promo link and home page link
                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                urlOptions.AlwaysIncludeServerUrl = true;
                urlOptions.AddAspxExtension = true;
                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                //Set home page link (set as club home if home club set)
                string startPath = Sitecore.Context.Site.StartPath.ToString();
                var homeItem = Sitecore.Context.Database.GetItem(startPath);

                HomeOrClubPageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            privacyPolicyUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy);
            termsConditionsUrl = new PageSummaryItem(campaign.CampaignBase.Termsandconditionslink.Item).QualifiedUrl;
            findYourClubUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.ClubFinder);

            var homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath.ToString());
            homePageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);

            //add the item specific css stylesheet
            //string classNames = article.Attributes["class"];
            //article.Attributes.Add("class", classNames.Length > 0 ? classNames + " campaign-" + campaign.CampaignBase.Cssstyle.Raw : "campaign-" + campaign.CampaignBase.Cssstyle.Raw);

            //Add dynamic content to header
            HtmlHead head = (HtmlHead)Page.Header;

            //Add Open Tag
            if (Session["sess_User"] != null)
            {
                User objUser = (User)Session["sess_User"];
                if (objUser.Preferences != null)
                {
                    if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
                    {
                        head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
                    }
                }
            }

            //Add Page Title
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();
            markupBuilder.Append(@"<meta name='viewport' content='width=1020'>");
            markupBuilder.Append(@"<link rel='apple-touch-icon' href='/virginactive/images/apple-touch-icon.png'>");
            markupBuilder.Append(@"<link rel='shortcut icon' href='/virginactive/images/favicon.ico'>");
            markupBuilder.Append(@"<link href='/virginactive/css/fonts.css' rel='stylesheet'>");
            markupBuilder.Append(@"<link href='/va_campaigns/css/campaign.css' rel='stylesheet'>");
            head.Controls.Add(new LiteralControl(markupBuilder.ToString()));
        }
Beispiel #10
0
        /// <summary>
        /// Resolves a ContentUrl from an id.
        /// </summary>
        /// <param name="contentId">Id of a sitecore item.</param>
        /// <returns>Url to a given item from sitecore.</returns>
        public virtual Ucommerce.Content.Content GetContent(string contentId)
        {
            var content = new Ucommerce.Content.Content
            {
                Id   = contentId,
                Name = "",
                Url  = ""
            };

            if (string.IsNullOrEmpty(contentId))
            {
                return(content);
            }

            var item = GetItemFromId(contentId);

            if (item == null)
            {
                _loggingService.Information <SitecoreContentService>(string.Format("Item with id: {0} was not found. Check that content exists in database", contentId));
                return(content);
            }

            var urlOptions = new Links.UrlOptions()
            {
                AlwaysIncludeServerUrl = false,
                Language = Context.Language,
                Site     = SiteContext.Current
            };

            content.Url = Links.LinkManager.LanguageEmbedding.ToString().ToLower() == "never"
                ? Links.LinkManager.GetDynamicUrl(item, new Links.LinkUrlOptions()
            {
                Language = Context.Language
            })
                : Links.LinkManager.GetItemUrl(item, urlOptions);

            content.Icon = "/~/icon/" + item.Appearance.Icon;
            content.Name = item.Name;

            return(content);
        }
        private void SetSitecoreData()
        {
            //Get User from Session
            //Check Session
            User objUser = new User();
            if (Session["sess_User_landing"] != null)
            {
                objUser = (User)Session["sess_User_landing"];

                clubId = objUser.BrowsingHistory.LandingClubID;
                profile = objUser.BrowsingHistory.LandingProfile;
                region = objUser.BrowsingHistory.LandingRegion;
            }

            //Set currentLanding item
            if (currentItem != null)
            {
                currentLanding = currentItem.InnerItem.Parent;
            }

            if (currentLanding != null)
                btnSubmit.Attributes.Add("data-gaqlabel", currentLanding.LandingBase.LandingId.Rendered);

            //Get Club Data

            if (!String.IsNullOrEmpty(clubId))
                clubItem = SitecoreHelper.GetClubOnClubId(clubId);

            if (clubItem != null)
            {
                //Image Carousel
                List<MediaItem> imageList;
                if (!String.IsNullOrEmpty(clubItem.Imagegallery.Raw))
                {
                    imageList = clubItem.Imagegallery.ListItems.ConvertAll(X => new MediaItem(X));

                    ClubImages.DataSource = imageList;
                    ClubImages.DataBind();
                }

                System.Text.StringBuilder markupBuilder;
                markupBuilder = new System.Text.StringBuilder();

                markupBuilder.Append(clubItem.Addressline1.Rendered);
                markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline2.Rendered) ? ", " + clubItem.Addressline2.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline3.Rendered) ? ", " + clubItem.Addressline3.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline4.Rendered) ? ", " + clubItem.Addressline4.Rendered : "");
                markupBuilder.Append(", " + clubItem.Postcode.Rendered);
                markupBuilder.Append(" | " + clubItem.Salestelephonenumber.Rendered);

                litClubAddress.Text = markupBuilder.ToString();

                Item timetableItem = clubItem.InnerItem.Axes.SelectSingleItem(String.Format("child::*[@@name='{0}']", Settings.TimetableSectionName.ToLower()));

                    //clubItem.InnerItem.Axes.SelectSingleItem(String.Format("descendant::*[@@name='{0}']", Settings.TimetableSectionName));
                if (timetableItem != null)
                {
                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = false;
                    urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                    string timetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableItem, urlOptions);

                    TimeTableUrl = timetableUrl;
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid == true)
                {
                    //Get User from Session
                    //Check Session
                    User objUser = new User();
                    if (Session["sess_User_landing"] != null)
                    {
                        objUser = (User)Session["sess_User_landing"];

                        clubId = objUser.BrowsingHistory.LandingClubID;
                        profile = objUser.BrowsingHistory.LandingProfile;
                        region = objUser.BrowsingHistory.LandingRegion;
                    }

                    //Get Club Data

                    if (!String.IsNullOrEmpty(clubId))
                    {
                        clubItem = SitecoreHelper.GetClubOnClubId(clubId);

                        if (clubItem != null)
                        {

                            //Store Feedback Entitiy Details
                            Feedback objFeedback = new Feedback();

                            //Store Customer Entitiy Details
                            Customer objCustomer = new Customer();

                            string FirstName = "";
                            string Surname = "";

                            if (txtName.Value.IndexOf(" ") != -1)
                            {
                                FirstName = txtName.Value.Substring(0, txtName.Value.IndexOf(" ")).Trim();
                                Surname = txtName.Value.Substring(txtName.Value.IndexOf(" ") + 1).Trim();
                            }
                            else
                            {
                                FirstName = txtName.Value.Trim();
                            }

                            objCustomer.EmailAddress = txtEmail.Value;
                            objCustomer.Firstname = FirstName;
                            objCustomer.Surname = Surname;
                            objCustomer.HomeClubID = clubItem.ClubId.Rendered;
                            objCustomer.TelephoneNumber = txtPhone.Value;
                            objCustomer.SubscribeToNewsletter = chkSubscribe.Checked;

                            objFeedback.Customer = objCustomer;
                            objFeedback.FeedbackSubject = "Landing Enquiry"; //Landing Enquiry
                            objFeedback.FeedbackSubjectDetail = "Virgin Active Website Landing Page"; //Virgin Active Website Landing Page
                            objFeedback.FeedbackTypeID = Convert.ToInt32(currentLanding.LandingBase.LandingId.Rendered);
                            objFeedback.PrimaryClubID = clubItem.ClubId.Rendered;
                            objFeedback.SubmissionDate = DateTime.Now;

                            //Add Comment
                            Comment objComment = new Comment();

                            //objComment.CommentDetail = source.Items[source.SelectedIndex].Value;
                            objComment.CommentDetail = currentLanding.LandingBase.LandingIdName.Rendered;// "Q1 Landing Page -2013"; //Other
                            objComment.CommentImageTypeID = Constants.CommentImageType.QuestionnaireAnswer;
                            objComment.SortOrder = 1;
                            objComment.Subject = Translate.Text("How did you hear about us?");

                            List<Comment> objComments = new List<Comment>();
                            objComments.Add(objComment);

                            objFeedback.Comments = objComments;

                            string connection = Sitecore.Configuration.Settings.GetSetting("ConnectionString_VirginActiveReports");
                            DataAccessLayer dal = new DataAccessLayer(connection);
                            int successFlag = dal.SaveFeedback(Context.User.Identity.Name, currentItem.DisplayName, objFeedback);

                            if (successFlag > 0)
                            {
                                //Data is sent to client via email
                                SendAdminEmail();

                                //Data is sent to client via service
                                SendEnquiryDataService();

                                //Data is sent to customer via email
                                SendConfirmationEmail();

                                //Save objFeedback back to session
                                Session["sess_Customer"] = objCustomer;

                                //Redirect to 'Whats Next' Page
                                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                                urlOptions.AlwaysIncludeServerUrl = true;
                                urlOptions.AddAspxExtension = false;
                                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                                Item whatNextItem = currentItem.InnerItem.Parent.Axes.SelectSingleItem(String.Format("descendant-or-self::*[@@tid = '{0}']", Settings.LandingPagesWhatsNextTemplate));

                                string whatNextUrl = Sitecore.Links.LinkManager.GetItemUrl(whatNextItem, urlOptions)+"?_clubid=" + clubItem.ClubId.Rendered;

                                Response.Redirect(whatNextUrl);
                            }
                            else
                            {
                                //imageStatic.Attributes.Add("style", "display:none;");
                                //formToComplete.Attributes.Add("style", "display:block;");
                                //formCompleted.Attributes.Add("style", "display:none;");
                                //pnlForm.Update();

                                Log.Error(String.Format("Error storing campaign details"), this);
                            }
                        }
                        else
                        {
                            //imageStatic.Attributes.Add("style", "display:none;");
                            //formToComplete.Attributes.Add("style", "display:block;");
                            //formCompleted.Attributes.Add("style", "display:none;");
                            //pnlForm.Update();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
Beispiel #13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //set current item
            currentItem = Sitecore.Context.Database.GetItem(ItemPaths.Header);

            //Header links
            Item[] links = currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", LinkItem.TemplateId));
            if (links != null)
            {
                List<LinkItem> headerLinks = links.ToList().ConvertAll(X => new LinkItem(X));
                LinkList.DataSource = headerLinks;
                LinkList.DataBind();
            }

            //Set featured promo link and home page link
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            //set Featured Promo Event Teaser
            if (currentItem.InnerItem.HasChildren)
            {
                List<FeaturedPromotionEventWidgetItem> allFeatures = currentItem.InnerItem.Children.ToList().ConvertAll(X => new FeaturedPromotionEventWidgetItem(X));
                fpew = new FeaturedPromotionEventWidgetItem(allFeatures.First());
            }

            //Set home page link (set as club home if home club set)
            string startPath = Sitecore.Context.Site.StartPath.ToString();
            var homeItem = Sitecore.Context.Database.GetItem(startPath);
            hdnLastClubVisitedId.Value = "";

            //set hidden field for javascript referencing
            homePageUrl.Value = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);
            homePageUrl.Value = homePageUrl.Value.IndexOf("Home.aspx") != -1 ? homePageUrl.Value : homePageUrl.Value + "Home.aspx";

            //Set home page link
            homeOrClubPageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);

            //Set Header Text -need logic to display <h1> or <h2>
            //Format Contact Address
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            if (Sitecore.Context.Item.ID == homeItem.ID)
            {
                //Page is home page
                markupBuilder.Append(@"<h1 class=""headertext""><a href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @""">");
                markupBuilder.Append(Translate.Text("Virgin Active") + " <span>");
                markupBuilder.Append(Translate.Text("Health Clubs") + "</span></a></h1>");
            }
            else
            {
                markupBuilder.Append(@"<h2 class=""headertext""><a href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @""">");
                markupBuilder.Append(Translate.Text("Virgin Active") + " <span>");
                markupBuilder.Append(Translate.Text("Health Clubs") + "</span></a></h2>");
            }

            ltrHeaderText.Text = markupBuilder.ToString();

            //CREATE NEW USER SESSION
            //Check if we are loading home page for the first time
            User objUser = new User();

            //Check Session
            if (Session["sess_User"] == null)
            {
                newSession = true;
            }
            else
            {
                objUser = (User)Session["sess_User"];
            }

            //READ/SET COOKIE OPTIONS
            if (newSession)
            {
                //New Session

                //Check gallery preference
                if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery)))
                {
                    //Store to session
                    objUser.ShowGallery = CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery) == "Y" ? true : false;
                }

                //Check if cookie preferences session cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                {
                    Preferences preferences = new Preferences();

                    preferences.MarketingCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies) == "Y" ? true : false;
                    preferences.MetricsCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MetricsCookies) == "Y" ? true : false;
                    preferences.PersonalisedCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.PersonalisedCookies) == "Y" ? true : false;
                    preferences.SocialCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.SocialCookies) == "Y" ? true : false;

                    //Store to session
                    objUser.Preferences = preferences;
                }
                else
                {
                    //Interorgate the request 'Do Not Track' settings.
                    HttpContext objContext = HttpContext.Current;
                    bool headerDoNotTrack = false;

                    if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
                    {
                        headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
                    }

                    if (headerDoNotTrack)
                    {
                        //Set Preferences in User Session -default to N
                        Preferences preferences = new Preferences();

                        preferences.MarketingCookies = false;
                        preferences.MetricsCookies = false;
                        preferences.PersonalisedCookies = false;
                        preferences.SocialCookies = false;

                        objUser.Preferences = preferences;

                        //Set Cookie Preferences Cookie
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "N");

                        //Delete Existing Personalisation Cookie
                        CookieHelper.DeleteCookie();
                    }
                }
            }

            //DEFAULT PREFERENCES
            if (objUser.Preferences == null)
            {
                //Set preferences in User Session -default to Y
                Preferences preferences = new Preferences();

                preferences.MarketingCookies = true;
                preferences.MetricsCookies = true;
                preferences.PersonalisedCookies = true;
                preferences.SocialCookies = true;

                //Store to session
                objUser.Preferences = preferences;

                //Set Cookie Preferences Cookie -default to permission allowed
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "Y");
            }

            //SHOW/HIDE PERSONALISED CONTENT
            if (newSession && (Sitecore.Context.Item.ID == homeItem.ID))
            {
                //Loading home page for the first time -Check if last page visited cookie exists
                //if(!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited)))
                if (!string.IsNullOrEmpty(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited)))
                {
                    //Display message prompting then to go to club
                    phLastClubVisitedPrompt.Visible = true;
                    //clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited));
                    clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited));
                    if (clubLastVisited != null)
                    {
                        ClubLastVisitedUrl = Sitecore.Links.LinkManager.GetItemUrl(clubLastVisited, urlOptions);
                        ClubName = clubLastVisited.Clubname.Rendered;
                        hdnLastClubVisitedId.Value = clubLastVisited.ClubId.Rendered;

                        //Store to session
                        objUser.ClubLastVisitedID = clubLastVisited.ClubId.Rendered;
                    }
                }
            }
            else
            {
                //User session already exists but only visiting home page for the first time
                if ((objUser.HomePageVisited == false) && (Sitecore.Context.Item.ID == homeItem.ID))
                {
                    //if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited)))
                    if (!string.IsNullOrEmpty(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited)))
                    {
                        //Display message prompting then to go to club
                        phLastClubVisitedPrompt.Visible = true;
                        //clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited));
                        clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetClubLastVisitedCookieValue(CookieKeyNames.ClubLastVisited));
                        if (clubLastVisited != null)
                        {
                            ClubLastVisitedUrl = Sitecore.Links.LinkManager.GetItemUrl(clubLastVisited, urlOptions);
                            ClubName = clubLastVisited.Clubname.Rendered;
                            hdnLastClubVisitedId.Value = clubLastVisited.ClubId.Rendered;

                            //Store to session
                            objUser.ClubLastVisitedID = clubLastVisited.ClubId.Rendered;
                        }
                    }
                }
            }

            //Check if a club has been set as home page
            if (!String.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.HomeClub)))
            {
                ClubItem club = SitecoreHelper.GetClubOnClubId(CookieHelper.GetCookieValue(CookieKeyNames.HomeClub));
                if (club != null)
                {
                    homeOrClubPageUrl = Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions);

                    //Store to session
                    objUser.HomeClubID = club.ClubId.Rendered;
                }
            }

            //Save session
            Session["sess_User"] = objUser;

            Sitecore.Data.Items.Item headerItem = Sitecore.Context.Database.GetItem("/sitecore/content/page-elements/header");

            //Get featured promotion event item details for banner
            Sitecore.Data.Items.Item featuredPromotionEventItem = Sitecore.Context.Database.GetItem("/sitecore/content/Widgets/featured-promotion-event");
            if (featuredPromotionEventItem != null)
            {
                //fldPromotionEventDate.DataSource = featuredPromotionEventItem.ID.ToString();

                //fldPromotionEventSubheading.DataSource = featuredPromotionEventItem.ID.ToString();
            }
        }
        private Boolean SendConfirmationEmail()
        {
            bool blnEmailSent = false;

            try
            {

                //get managers info
                List<ManagerItem> staffMembers = null;
                if (clubItem.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                {
                    staffMembers = clubItem.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                    manager = staffMembers.First();
                }

                if (currentLanding != null && currentLanding.LandingBase.EmailTemplate.Item != null)
                {
                        //Get Campaign Email object
                    EmailBaseItem emailItem = currentLanding.LandingBase.EmailTemplate.Item;

                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = true;

                        //string strEmailSubject = campaign.CampaignBase.Emailsubject.Rendered;
                        string strEmailSubject = emailItem.Subject.Raw;
                        //string strEmailFromAddress = Settings.WebsiteMailFromText;
                        string strEmailFromAddress = emailItem.Fromaddress.Raw;
                        string strEmailToAddress = txtEmail.Value.Trim();

                        //Populate email text variables
                        Hashtable objTemplateVariables = new Hashtable();
                        objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
                        objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesAndClasses));
                        objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealth));
                        objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.Memberships));
                        objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
                        objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
                        objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));

                        //objTemplateVariables.Add("CampaignTermsAndConditionsLinkUrl", new PageSummaryItem(currentCampaign.CampaignBase.Termsandconditionslink.Item).QualifiedUrl);
                        objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
                        if (manager != null)
                        {
                            objTemplateVariables.Add("ClubManagerName", manager.Person.Firstname.Rendered + " " + manager.Person.Lastname.Rendered);
                        }
                        else
                        {
                            objTemplateVariables.Add("ClubManagerName", "");
                        }
                        objTemplateVariables.Add("ClubName", clubItem.Clubname.Rendered);
                        objTemplateVariables.Add("EmailSubject", strEmailSubject);
                        objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                        objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
                        objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
                        objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
                        objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
                        objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
                        objTemplateVariables.Add("ImageRootUrl", Sitecore.Web.WebUtil.GetServerUrl());
                        objTemplateVariables.Add("ClubPhoneNumber", clubItem.Salestelephonenumber.Rendered);
                        objTemplateVariables.Add("ClubHomePageUrl", Sitecore.Links.LinkManager.GetItemUrl(clubItem, urlOptions));

                        System.Text.StringBuilder markupBuilder;
                        markupBuilder = new System.Text.StringBuilder();

                        markupBuilder.Append(clubItem.Addressline1.Rendered);
                        markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline2.Rendered) ? "<br />" + clubItem.Addressline2.Rendered : "");
                        markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline3.Rendered) ? "<br />" + clubItem.Addressline3.Rendered : "");
                        markupBuilder.Append(!String.IsNullOrEmpty(clubItem.Addressline4.Rendered) ? "<br />" + clubItem.Addressline4.Rendered : "");
                        markupBuilder.Append("<br />" + clubItem.Postcode.Rendered);

                        objTemplateVariables.Add("ClubAddress", markupBuilder.ToString());

                        //Parser objParser = new Parser(campaign.CampaignBase.GetTemplateHtml(), objTemplateVariables);
                        Parser objParser = new Parser(objTemplateVariables);

                        if (emailItem.InnerItem.TemplateName == Templates.CampaignEmail)
                        {
                            CampaignEmailItem campaignEmail = (CampaignEmailItem)emailItem.InnerItem;
                            //First parse the Email Body text
                            objParser.SetTemplate(campaignEmail.Emailbody.Raw);
                            string strEmailBody = objParser.Parse();

                            objTemplateVariables.Add("EmailBody", strEmailBody);

                            //Second parse the full html -substituting in title and preheader
                            objTemplateVariables.Add("EmailTitle", campaignEmail.Emailtitle.Raw);
                            objTemplateVariables.Add("EmailPreheader", campaignEmail.Emailpreheader.Raw);

                            objParser = new Parser(objTemplateVariables);
                            if (clubItem.InnerItem.TemplateName == Templates.ClassicClub)
                            {
                                objParser.SetTemplate(campaignEmail.Classichtml.Raw);
                            }
                            else
                            {
                                objParser.SetTemplate(campaignEmail.Standardhtml.Raw);
                            }
                        }
                        else
                        {
                            EmailItem standardEmail = (EmailItem)emailItem.InnerItem;
                            //Standard email
                            objParser.SetTemplate(standardEmail.Emailhtml.Raw);
                        }
                        //Parser objParser = new Parser(Server.MapPath(EmailTemplates.FreeGuestPassConfirmation), objTemplateVariables);
                        string strEmailHtml = objParser.Parse();

                        mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                        mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                        string strAttachments = "";

                        //now call messaging service
                        objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strEmailHtml, strAttachments);

                        if (objSendResult.Success == true)
                        {
                            blnEmailSent = true;
                        }
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending module enquiry email confirmation {1}: {0}", ex.Message, clubItem.Clubname.Raw), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
Beispiel #15
0
        private string SetHomeClub()
        {
            try
            {
                string clubId = WebUtil.GetQueryString("clubId");
                bool clubIsHomeClub = false;
                if (WebUtil.GetQueryString("clubIsHomeClub") == "true")
                {
                    clubIsHomeClub = true;
                }

                User objUser = new User();
                //Set user session variable
                if (Session["sess_User"] != null)
                {
                    objUser = (User)Session["sess_User"];
                }

                if (!clubIsHomeClub)
                {
                    //Set Home Club ID User Session
                    objUser.HomeClubID = clubId;
                    Session["sess_User"] = objUser;

                    //Set Home Club ID Cookie
                    CookieHelper.AddUpdateCookie(CookieKeyNames.HomeClub, clubId);

                    //Get club url
                    ClubItem club = SitecoreHelper.GetClubOnClubId(clubId);
                    if (club != null)
                    {
                        Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                        urlOptions.AlwaysIncludeServerUrl = true;
                        urlOptions.AddAspxExtension = true;
                        urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                        StringWriter result = new StringWriter();

                        using (JsonTextWriter writer = new JsonTextWriter(result))
                        {
                            writer.WriteStartArray();
                            writer.WriteStartObject();
                            writer.WritePropertyName("resultUrl");
                            writer.WriteValue(Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions));
                            writer.WriteEndObject();
                            writer.WriteEndArray();
                        }

                        return result.ToString();
                    }
                }
                else
                {
                    //Set Home Club ID User Session
                    objUser.HomeClubID = "";
                    Session["sess_User"] = objUser;

                    //Set Home Club ID Cookie
                    CookieHelper.AddUpdateCookie(CookieKeyNames.HomeClub, "");
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Unable to set club home page cookie: {0}", ex.Message), null);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
            return "";
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            //Redirect to club home
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = false;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            if(club != null)
            {
                //Get opening hours
                if (club.Openinghours.Rendered.Trim() != "")
                {
                    //add opening hours details
                    markupBuilder.Append(@"<p class=""openingtimes"">");
                    markupBuilder.Append(club.Openinghours.Rendered);
                    markupBuilder.Append(@"</p>");

                    openingHours = markupBuilder.ToString();
                }

                //Get address

                markupBuilder = new System.Text.StringBuilder();

                markupBuilder.Append(club.Addressline1.Text);
                markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline2.Text) ? "<br />" + club.Addressline2.Text : "");
                markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline3.Text) ? "<br />" + club.Addressline3.Text : "");
                markupBuilder.Append("<br />");
                markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline4.Text) ? club.Addressline4.Text + " " : "");
                markupBuilder.Append(club.Postcode.Text);

                Address.Text = markupBuilder.ToString();

                //Get Club details

                ClubName = club.Clubname.Rendered;
                lng = club.Long.Raw;
                lat = club.Lat.Raw;

                //Get timetable link
                if (club.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableItem.TemplateId)) != null)
                {
                    TimetableItem timetableItem = new TimetableItem(club.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableItem.TemplateId)));
                    SectionContainerItem timetableSectionItem = new SectionContainerItem(timetableItem.InnerItem.Axes.SelectSingleItem(String.Format(@"..", SectionContainerItem.TemplateId)));
                    ClubTimetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableSectionItem);
                }
                else
                {
                    if (club.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableDownloadItem.TemplateId)) != null)
                    {
                        TimetableDownloadItem timetableDownloadItem = new TimetableDownloadItem(club.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableDownloadItem.TemplateId)));
                        ClubTimetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableDownloadItem);
                    }
                }

                //Get enquiries link
                PageSummaryItem enqForm = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.EnquiryForm));
                if(enqForm != null)
                {
                    ClubEnquiriesUrl = enqForm.Url + "?sc_trk=enq&c=" + club.InnerItem.ID.ToShortID();
                }

                List<MediaItem> imageList;
                if (!String.IsNullOrEmpty(club.Imagegallery.Raw))
                {
                    imageList = club.Imagegallery.ListItems.ConvertAll(X => new MediaItem(X));
                    ImageList.DataSource = imageList;
                    ImageList.DataBind();
                }

                //Set club last visited
                User objUser = new User();
                if (Session["sess_User"] != null)
                {
                    objUser = (User)Session["sess_User"];
                }
                objUser.ClubLastVisitedID = club.ClubId.Rendered;
                Session["sess_User"] = objUser;

                //Set club last visited cookie
                CookieHelper.AddClubsLastVisitedCookie(CookieKeyNames.ClubLastVisited, club.ClubId.Rendered);

                //Add club name to page title
                string clubNameTitle = String.Format(" - {0}", club.Clubname.Raw);
                clubNameTitle = HtmlRemoval.StripTagsCharArray(clubNameTitle);

                Page.Title = Page.Title + clubNameTitle;

            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int NoOfResultsToShow = Convert.ToInt32(SitecoreHelper.GetSitecoreSetting("No of Club Results To Show"));

            Item currentItem = Sitecore.Context.Item;

            List<Club> clubs = null;

            clubs = GetClubListByLandingId(clubs);

            if(clubs!=null)
                clubs = ClubUtil.GetNearestClubs(Lat, Lng, NoOfResultsToShow, clubs);
            else
                clubs = ClubUtil.GetNearestClubs(Lat, Lng, NoOfResultsToShow);

            MatchingResults = String.Format(Translate.Text("{0} clubs matching your search criteria"), clubs != null ? clubs.Count : 0);

            StringWriter result = new StringWriter();

            using (JsonTextWriter w = new JsonTextWriter(result))
            {

                w.WriteStartArray();
                foreach (Club club in clubs)
                {
                    ClubItem clubItem = club.ClubItm;

                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = false;
                    urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                    string clubUrl = Sitecore.Links.LinkManager.GetItemUrl(currentItem, urlOptions) + "/enquiry?_clubId=" + clubItem.ClubId.Rendered;
                    string clubLabel = HtmlRemoval.StripTagsCharArray(clubItem.Clubname.Text).Trim();
                    //WriteClubAsJson(w, clubLabel, club.DistanceFromSource.ToString(), clubItem.InnerItem.ID.ToString());
                    //WriteClubAsJson(w, clubLabel, club.DistanceFromSource.ToString(),  new PageSummaryItem(clubItem.InnerItem).Url);
                    WriteClubAsJson(w, clubLabel, String.Format("{0:0.00}", club.DistanceFromSource), clubUrl);
                }

                w.WriteEndArray();
                ClubDetails = result.ToString();
            }
        }
Beispiel #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack != true)
            {
                mobileItem = (MobileHomeItem)Sitecore.Context.Database.GetItem(ItemPaths.MobileHomePage);

                //generate the image carousel
                List<ImageCarouselItem> imgCar = new List<ImageCarouselItem>();
                if (mobileItem.InnerItem.HasChildren)
                {
                    imgCar = mobileItem.InnerItem.Children.ToList().ConvertAll(X => new ImageCarouselItem(X));
                    ImageList.DataSource = imgCar;
                    ImageList.DataBind();
                }

                //Set links
                ClubFinderUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.ClubFinder);
                TimetablesUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.ClubFinder) + "?action=timetables";
                MembershipEnquiryUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.EnquiryForm);

                //Redirect to club home
                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                urlOptions.AlwaysIncludeServerUrl = true;
                urlOptions.AddAspxExtension = false;
                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                User objUser = new User();
                //Set user session variable
                if (Session["sess_User"] != null)
                {
                    objUser = (User)Session["sess_User"];
                }
                //Set Home Page Visited Flag
                objUser.HomePageVisited = true;
                Session["sess_User"] = objUser;

                //Loading home page for the first time -Check if last page visited cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited)))
                {

                    string[] clubIds = CookieHelper.GetClubsLastVisitedCookieValue(CookieKeyNames.ClubLastVisited);
                    int count = 0;

                    if (clubIds != null && clubIds.Length > 0)
                    {
                        //Display message prompting then to go to club
                        phLastClubVisitedPrompt.Visible = true;

                        List<ClubItem> lastVisitedClubs = new List<ClubItem>();

                        foreach (string clubId in clubIds)
                        {
                            lastVisitedClubs.Add(SitecoreHelper.GetClubOnClubId(clubId));

                            if (count == 0)
                            {
                                //Store to session
                                objUser.ClubLastVisitedID = clubId;
                            }

                            count++;
                        }

                        ClubList.DataSource = lastVisitedClubs;
                        ClubList.DataBind();
                    }
                    //clubLastVisited = SitecoreHelper.GetClubOnClubId(CookieHelper.GetCookieValue(CookieKeyNames.ClubLastVisited));
                    //if (clubLastVisited != null)
                    //{
                    //    ClubLastVisitedUrl = Sitecore.Links.LinkManager.GetItemUrl(clubLastVisited, urlOptions);
                    //    ClubName = clubLastVisited.Clubname.Rendered;

                    //    //Store to session
                    //    objUser.ClubLastVisitedID = clubLastVisited.ClubId.Rendered;
                    //}
                }
            }
        }
        private Boolean SendConfirmationEmail()
        {
            bool blnEmailSent = false;

            try
            {
                string strEmailSubject = EmailSubjects.EnquiryConfirmation;
                string strEmailFromAddress = Settings.WebsiteMailFromText;
                string strEmailToAddress = txtEmail.Value.Trim();

                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                urlOptions.AlwaysIncludeServerUrl = true;
                urlOptions.AddAspxExtension = true;
                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                //Populate email text variables
                Hashtable objTemplateVariables = new Hashtable();
                objTemplateVariables.Add("HomePageUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.HomePage));
                objTemplateVariables.Add("FacilitiesAndClassesLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.FacilitiesLanding));
                objTemplateVariables.Add("YourHealthLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.YourHealthArticles));
                objTemplateVariables.Add("MembershipsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.MembershipOptions));
                objTemplateVariables.Add("PrivacyPolicyLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy));
                objTemplateVariables.Add("TermsAndConditionsLinkUrl", SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions));
                objTemplateVariables.Add("Copyright", Translate.Text("© Copyright ##Year## Virgin Active. All rights reserved."));
                objTemplateVariables.Add("CustomerName", txtName.Value.Trim());
                if (manager != null)
                {
                    objTemplateVariables.Add("ClubManagerName", manager.Person.Firstname.Rendered + " " + manager.Person.Lastname.Rendered);
                }
                else
                {
                    objTemplateVariables.Add("ClubManagerName", "");
                }
                objTemplateVariables.Add("ClubName", currentClub.Clubname.Rendered);
                objTemplateVariables.Add("ClubHomePageUrl", Sitecore.Links.LinkManager.GetItemUrl(currentClub, urlOptions));
                objTemplateVariables.Add("EmailSubject", strEmailSubject);
                objTemplateVariables.Add("EmailFromAddress", strEmailFromAddress);
                objTemplateVariables.Add("EmailToAddress", strEmailToAddress);
                objTemplateVariables.Add("YouTubeLinkUrl", Settings.YouTubeLinkUrl);
                objTemplateVariables.Add("TwitterLinkUrl", Settings.TwitterLinkUrl);
                objTemplateVariables.Add("FacebookLinkUrl", Settings.FacebookLinkUrl);
                objTemplateVariables.Add("McCormackMorrisonLinkUrl", Settings.McCormackMorrisonUrl);
                objTemplateVariables.Add("ImageRootUrl", WebUtil.GetServerUrl());
                objTemplateVariables.Add("ClubPhoneNumber", currentClub.Salestelephonenumber.Rendered);

                System.Text.StringBuilder markupBuilder;
                markupBuilder = new System.Text.StringBuilder();

                markupBuilder.Append(currentClub.Addressline1.Rendered);
                markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline2.Rendered) ? "<br />" + currentClub.Addressline2.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline3.Rendered) ? "<br />" + currentClub.Addressline3.Rendered : "");
                markupBuilder.Append(!String.IsNullOrEmpty(currentClub.Addressline4.Rendered) ? "<br />" + currentClub.Addressline4.Rendered : "");
                markupBuilder.Append("<br />" + currentClub.Postcode.Rendered);

                objTemplateVariables.Add("ClubAddress", markupBuilder.ToString());

                //Parser objParser = new Parser(Server.MapPath(EmailTemplates.EnquiryConfirmation), objTemplateVariables);
                Parser objParser = new Parser(objTemplateVariables);
                objParser.SetTemplate(((EmailItem)Sitecore.Context.Database.GetItem(EmailPaths.EnquiryConfirmation)).Emailhtml.Text);
                string strMessageBody = objParser.Parse();

                mm.sharedtools.EmailMessagingService.SendResult objSendResult = new mm.sharedtools.EmailMessagingService.SendResult();
                mm.sharedtools.EmailMessagingService.Messaging objMessaging = new mm.sharedtools.EmailMessagingService.Messaging();

                string strAttachments = "";

                //now call messaging service
                objSendResult = objMessaging.SendMailSecure(strEmailFromAddress, strEmailToAddress, "", Settings.BccEmailAddress, strEmailSubject, true, strMessageBody, strAttachments);

                if (objSendResult.Success == true)
                {
                    blnEmailSent = true;
                }

            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error sending confirmation email {1}: {0}", ex.Message, currentClub.Clubname.Raw), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }

            return blnEmailSent;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get widget details
            registrationForm = Sitecore.Context.Database.GetItem(ItemPaths.IndoorTriathlonRegistrationForm);

            //Add dynamic content
            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script src=""/virginactive/scripts/indoortriathlon/indoor-tri.js""></script>"));

            if (Session["sess_User"] != null)
            {
                User objUser = (User)Session["sess_User"];

                if (objUser.Preferences.SocialCookies)
                {

                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = true;
                    urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                    pageUrl = Sitecore.Links.LinkManager.GetItemUrl(currentItem, urlOptions);

                    //Have permission to load in Social
                    showSocial = true;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            lnkReferAnotherFriend.Text = campaign.Whatsnextbuttontext.Rendered;
            if (!Page.IsPostBack)
            {
                List<ClubItem> clubs = null;

                if (campaign.CampaignBase.Usecustomclublist.Checked)
                {
                    //Use a custom list of clubs
                    clubs = campaign.CampaignBase.Customclublist.ListItems.ConvertAll(X => new ClubItem(X));
                }
                else
                {
                    //Use a custom list of clubs
                    Item clubRoot = Sitecore.Context.Database.GetItem(ItemPaths.Clubs);
                    ChildList clubLst = clubRoot.Children;
                    clubs = clubLst.ToList().ConvertAll(X => new ClubItem(X));
                    clubs.RemoveAll(x => x.IsHiddenFromMenu());
                }
                if (clubs != null)
                {
                    clubFindSelect1.Items.Add(new ListItem(Translate.Text("Select a club"), "default"));
                    clubFindSelect2.Items.Add(new ListItem(Translate.Text("Select a club"), "default"));

                    foreach (ClubItem clubItem in clubs)
                    {
                        if (clubItem != null)
                        {
                            if (!String.IsNullOrEmpty(clubItem.Clubname.Text))
                            {
                                string clubLabel = HtmlRemoval.StripTagsCharArray(clubItem.Clubname.Text).Trim();

                                //clubFindSelect1.Items.Add(new ListItem(clubLabel, clubItem.ID.ToShortID().ToString()));
                                clubFindSelect1.Items.Add(new ListItem(clubLabel, clubItem.ID.ToString()));
                                //clubFindSelect2.Items.Add(new ListItem(clubLabel, clubItem.ID.ToShortID().ToString()));
                                clubFindSelect2.Items.Add(new ListItem(clubLabel, clubItem.ID.ToString()));
                            }
                        }
                    }

                }
            }

            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            var homeItem = Sitecore.Context.Database.GetItem(Sitecore.Context.Site.StartPath.ToString());
            homePageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);

            privacyPolicyUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy);
            termsConditionsUrl = new PageSummaryItem(campaign.CampaignBase.Termsandconditionslink.Item).QualifiedUrl;

            //add the item specific css stylesheet
            //string classNames = article.Attributes["class"];
            //article.Attributes.Add("class", classNames.Length > 0 ? classNames + " campaign-" + campaign.CampaignBase.Cssstyle.Raw : "campaign-" + campaign.CampaignBase.Cssstyle.Raw);

            //Add dynamic content to header
            HtmlHead head = (HtmlHead)Page.Header;

            //Add Open Tag
            if (Session["sess_User"] != null)
            {
                User objUser = (User)Session["sess_User"];
                if (objUser.Preferences != null)
                {
                    if (objUser.Preferences.MarketingCookies && objUser.Preferences.MetricsCookies)
                    {
                        head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));
                    }
                }
            }

            //Add Page Title

            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();
            markupBuilder.Append(@"<meta name='viewport' content='width=1020'>");
            markupBuilder.Append(@"<link rel='apple-touch-icon' href='/virginactive/images/apple-touch-icon.png'>");
            markupBuilder.Append(@"<link rel='shortcut icon' href='/virginactive/images/favicon.ico'>");
            markupBuilder.Append(@"<link href='/virginactive/css/fonts.css' rel='stylesheet'>");
            markupBuilder.Append(@"<link href='/va_campaigns/Bespoke/Refer-A-Friend/css/styles.css' rel='stylesheet'>");
            head.Controls.Add(new LiteralControl(markupBuilder.ToString()));

            Control scriptPh = this.Page.FindControl("ScriptPh");
            if (scriptPh != null)
            {
                scriptPh.Controls.Add(new LiteralControl(@"<script src='/va_campaigns/Bespoke/Refer-A-Friend/js/plugins.js'></script>
                    <script src='/va_campaigns/Bespoke/Refer-A-Friend/js/scripts.js'></script>
                    "));
            }
        }
        public void CreateGoogleProductFeed(Sitecore.Data.Items.Item[] items, Sitecore.Tasks.CommandItem command,
           Sitecore.Tasks.ScheduleItem scheduleItem)
        {
            if (!GoogleProductFeedConfiguration.IsGoogleProductFeedXMLSchedulerEnabled())
            {
                Log.Info("GoogleProductFeed scheduler is disabled. To enable it check GoogleProductFeed.config-> GoogleProductFeed.SchedulerEnabled setting.", this);
                return;
            }

            if (items != null && items.Any())
            {
                Log.Info("Google Product Feed Started", this);
                foreach (var item in items)
                {
                    var sitesInConfig = GoogleProductFeedConfiguration.GetSitecoreSites();

                    var currentConfigurations = sitesInConfig.Where(x => x.RootItemPath.ToLower().Equals(item.Paths.FullPath.ToLower())).FirstOrDefault();

                    if (currentConfigurations != null)
                    {
                        try
                        {
                            List<GoogleProductFeed> feeds = new List<GoogleProductFeed>();

                            //Get Google Product Feed Configuration Item
                            Item GPFConfigurationItem = Sitecore.Configuration.Factory.GetDatabase("master").GetItem(currentConfigurations.ConfigurationPath); //Sitecore.Context.Database.GetItem(new Sitecore.Data.ID("{3DA415DD-526E-4F59-BDE4-F10D07EFC7F1}"));

                            LinkField rootFolder = GPFConfigurationItem.Fields["Root Item Path"];

                            NameValueListField GPFProperties = GPFConfigurationItem.Fields["Fields"];
                            NameValueCollection fields = GPFProperties.NameValues;

                            if (GPFProperties != null && GPFProperties.NameValues != null && GPFProperties.NameValues.Count > 0)
                            {
                                string ProductTemplateID = GPFConfigurationItem["Template"];

                                using (var context = ContentSearchManager.CreateSearchContext((SitecoreIndexableItem)item))
                                {
                                    // All Products
                                    var searchResultItems = context.GetQueryable<SearchResultItem>()
                                        .Where(x => x.TemplateId == Sitecore.Data.ID.Parse(ProductTemplateID) && x.Path.Contains(rootFolder.TargetItem.Paths.FullPath))
                                        .AsEnumerable()
                                        .Where(x => x != null && x.GetItem() != null && x.Version == x.GetItem().Versions.GetLatestVersion().Version.ToString());

                                    if (searchResultItems != null && searchResultItems.Any())
                                    {
                                        foreach (var results in searchResultItems)
                                        {
                                            GoogleProductFeed feed = new GoogleProductFeed();
                                            var itemtest = results.GetItem();
                                            feed.Title = (results.GetField(fields[FieldNames.Title]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.Title]).Value))) ? results.GetField(fields[FieldNames.Title]).Value : string.Empty;

                                            Sitecore.Links.UrlOptions URLOptions = new Sitecore.Links.UrlOptions();
                                            URLOptions.Site = Sitecore.Configuration.Factory.GetSite(currentConfigurations.SiteName);
                                            URLOptions.LanguageEmbedding = LanguageEmbedding.Never;
                                            var itemUrl = LinkManager.GetItemUrl(results.GetItem(), URLOptions);
                                            feed.Link = string.Format("{0}{1}", currentConfigurations.UrlPrefix, itemUrl);
                                            feed.Description = (results.GetField(fields[FieldNames.Description]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.Description]).Value))) ? results.GetField(fields[FieldNames.Description]).Value : string.Empty;
                                            feed.gID = (results.GetField(fields[FieldNames.gID]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gID]).Value))) ? results.GetField(fields[FieldNames.gID]).Value : string.Empty;
                                            feed.gItem_Group_ID = (results.GetField(fields[FieldNames.gItem_Group_ID]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gItem_Group_ID]).Value))) ? results.GetField(fields[FieldNames.gItem_Group_ID]).Value : string.Empty;
                                            feed.gSize = (results.GetField(fields[FieldNames.gSize]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSize]).Value))) ? results.GetField(fields[FieldNames.gSize]).Value : string.Empty;
                                            feed.gSize_Type = (results.GetField(fields[FieldNames.gSize_Type]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSize_Type]).Value))) ? results.GetField(fields[FieldNames.gSize_Type]).Value : string.Empty;
                                            feed.gMPN = (results.GetField(fields[FieldNames.gMPN]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMPN]).Value))) ? results.GetField(fields[FieldNames.gMPN]).Value : string.Empty;
                                            feed.gBrand = (results.GetField(fields[FieldNames.gBrand]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gBrand]).Value))) ? results.GetField(fields[FieldNames.gBrand]).Value : string.Empty;
                                            feed.gCondition = (results.GetField(fields[FieldNames.gCondition]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gCondition]).Value))) ? results.GetField(fields[FieldNames.gCondition]).Value : string.Empty;
                                            feed.gPrice = (results.GetField(fields[FieldNames.gPrice]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gPrice]).Value))) ? results.GetField(fields[FieldNames.gPrice]).Value : string.Empty;
                                            if (!string.IsNullOrWhiteSpace(feed.gPrice) && GPFConfigurationItem.Fields["Add Currency"].Value.Equals("1"))
                                            {
                                                feed.gPrice = feed.gPrice + " " + GPFConfigurationItem.Fields["Currency"].Value;
                                            }
                                            feed.gAvailability = (results.GetField(fields[FieldNames.gAvailability]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAvailability]).Value))) ? results.GetField(fields[FieldNames.gAvailability]).Value : string.Empty;
                                            feed.gImage_Link = (results.GetField(fields[FieldNames.gImage_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gImage_Link]).Value))) ? results.GetField(fields[FieldNames.gImage_Link]).Value : string.Empty;
                                            feed.gMobile_Link = (results.GetField(fields[FieldNames.gMobile_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMobile_Link]).Value))) ? results.GetField(fields[FieldNames.gMobile_Link]).Value : string.Empty;
                                            feed.gAvailability_Date = (results.GetField(fields[FieldNames.gAvailability_Date]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAvailability_Date]).Value))) ? results.GetField(fields[FieldNames.gAvailability_Date]).Value : string.Empty;
                                            feed.gSale_Price = (results.GetField(fields[FieldNames.gSale_Price]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSale_Price]).Value))) ? results.GetField(fields[FieldNames.gSale_Price]).Value : string.Empty;
                                            feed.gTin = (results.GetField(fields[FieldNames.gTin]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gTin]).Value))) ? results.GetField(fields[FieldNames.gTin]).Value : string.Empty;
                                            feed.gColor = (results.GetField(fields[FieldNames.gColor]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gColor]).Value))) ? results.GetField(fields[FieldNames.gColor]).Value : string.Empty;
                                            feed.gGender = (results.GetField(fields[FieldNames.gGender]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGender]).Value))) ? results.GetField(fields[FieldNames.gGender]).Value : string.Empty;
                                            feed.gAge_Group = (results.GetField(fields[FieldNames.gAge_Group]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAge_Group]).Value))) ? results.GetField(fields[FieldNames.gAge_Group]).Value : string.Empty;
                                            feed.gMaterial = (results.GetField(fields[FieldNames.gMaterial]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMaterial]).Value))) ? results.GetField(fields[FieldNames.gMaterial]).Value : string.Empty;
                                            feed.gPattern = (results.GetField(fields[FieldNames.gPattern]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gPattern]).Value))) ? results.GetField(fields[FieldNames.gPattern]).Value : string.Empty;
                                            feed.gAdditional_Image_Link = (results.GetField(fields[FieldNames.gAdditional_Image_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdditional_Image_Link]).Value))) ? results.GetField(fields[FieldNames.gAdditional_Image_Link]).Value : string.Empty;
                                            feed.gGoogle_Product_Category = (results.GetField(fields[FieldNames.gGoogle_Product_Category]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGoogle_Product_Category]).Value))) ? results.GetField(fields[FieldNames.gGoogle_Product_Category]).Value : string.Empty;
                                            feed.gCountry = (results.GetField(fields[FieldNames.gCountry]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gCountry]).Value))) ? results.GetField(fields[FieldNames.gCountry]).Value : string.Empty;
                                            feed.gService = (results.GetField(fields[FieldNames.gService]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gService]).Value))) ? results.GetField(fields[FieldNames.gService]).Value : string.Empty;
                                            feed.gShippingPrice = (results.GetField(fields[FieldNames.gShipping_Price]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Price]).Value))) ? results.GetField(fields[FieldNames.gShipping_Price]).Value : string.Empty;
                                            if (!string.IsNullOrWhiteSpace(feed.gShippingPrice) && GPFConfigurationItem.Fields["Add Currency"].Value.Equals("1"))
                                            {
                                                feed.gShippingPrice = feed.gShippingPrice + " " + GPFConfigurationItem.Fields["Currency"].Value;
                                            }
                                            feed.gShipping_Weight = (results.GetField(fields[FieldNames.gShipping_Weight]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Weight]).Value))) ? results.GetField(fields[FieldNames.gShipping_Weight]).Value : string.Empty;
                                            feed.gShipping_Label = (results.GetField(fields[FieldNames.gShipping_Label]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Label]).Value))) ? results.GetField(fields[FieldNames.gShipping_Label]).Value : string.Empty;
                                            feed.gMultipack = (results.GetField(fields[FieldNames.gMultipack]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMultipack]).Value))) ? results.GetField(fields[FieldNames.gMultipack]).Value : string.Empty;
                                            feed.gIs_Bundle = (results.GetField(fields[FieldNames.gIs_Bundle]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gIs_Bundle]).Value))) ? results.GetField(fields[FieldNames.gIs_Bundle]).Value : string.Empty;
                                            feed.gAdult = (results.GetField(fields[FieldNames.gAdult]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdult]).Value))) ? results.GetField(fields[FieldNames.gAdult]).Value : string.Empty;
                                            feed.gAdwords_Redirect = (results.GetField(fields[FieldNames.gAdwords_Redirect]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdwords_Redirect]).Value))) ? results.GetField(fields[FieldNames.gAdwords_Redirect]).Value : string.Empty;
                                            feed.gExpiration_Date = (results.GetField(fields[FieldNames.gExpiration_Date]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gExpiration_Date]).Value))) ? results.GetField(fields[FieldNames.gExpiration_Date]).Value : string.Empty;
                                            feed.gExcluded_Destination = (results.GetField(fields[FieldNames.gExcluded_Destination]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gExcluded_Destination]).Value))) ? results.GetField(fields[FieldNames.gExcluded_Destination]).Value : string.Empty;
                                            feed.gGoogle_Product_Type = new List<GoogleProductType>();
                                            GoogleProductType type = new GoogleProductType();
                                            type.gProduct_Type = (results.GetField(fields[FieldNames.gGoogle_Product_Type]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGoogle_Product_Type]).Value))) ? results.GetField(fields[FieldNames.gGoogle_Product_Type]).Value : string.Empty;
                                            feed.gGoogle_Product_Type.Add(type);

                                            if (!string.IsNullOrWhiteSpace(feed.Description) && feed.Description.Count() > 5000)
                                            {
                                                feed.Description = feed.Description.Take(5000).ToString();
                                            }
                                            feeds.Add(feed);
                                        }
                                    }
                                }
                            }

                            try
                            {
                                if (feeds != null && feeds.Count() > 0)
                                {

                                    feeds = feeds.OrderBy(x => x.Title).ToList();
                                    string xmlContent = GoogleProductFeedCreation.BuildGoogleProductFeedXML(feeds);

                                    if (!string.IsNullOrWhiteSpace(xmlContent))
                                    {
                                        // Get Google Product Feed XML item from Master database, Update it and Publish it
                                        Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master");
                                        if (masterDb != null)
                                        {
                                            Item googleProductFeedXMLItem = masterDb.GetItem(currentConfigurations.XMLPath);
                                            if (googleProductFeedXMLItem != null)
                                            {
                                                bool isItemUpdatedSuccessfully = true;
                                                GoogleProductFeedCreation.UpdateGoogleProductFeedXMLItem(googleProductFeedXMLItem, xmlContent, ref isItemUpdatedSuccessfully);

                                                if (isItemUpdatedSuccessfully)
                                                {
                                                    GoogleProductFeedCreation.PublishGoogleProductFeedXMLItem(googleProductFeedXMLItem, masterDb, true, Sitecore.Configuration.Factory.GetDatabase("web"));
                                                }
                                            }
                                            else
                                            {
                                                Log.Warn("GoogleProductFeed XML Item not found for " + Sitecore.Context.Site.StartPath, this);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while generating googleproductfeed.xml for " + Sitecore.Context.Site, ex, this);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error in Google Product Feed", ex, this);
                        }
                    }
                }

                Log.Info("Google Product Feed Ended", this);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //Get widget details
            registrationForm = Sitecore.Context.Database.GetItem(ItemPaths.IndoorTriathlonRegistrationForm);

            //Add dynamic content
            this.Page.FindControl("ScriptPh").Controls.Add(new LiteralControl(@"<script src=""/virginactive/scripts/indoortriathlon/indoor-tri.js""></script>"));

            if (Session["sess_User"] != null)
            {
                User objUser = (User)Session["sess_User"];

                if (objUser.Preferences.SocialCookies)
                {

                    Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                    urlOptions.AlwaysIncludeServerUrl = true;
                    urlOptions.AddAspxExtension = true;
                    urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                    pageUrl = Sitecore.Links.LinkManager.GetItemUrl(currentItem, urlOptions);

                    //Have permission to load in Social
                    showSocial = true;
                }
            }

            if (currentItem.InnerItem.HasChildren)
            {

                //Check if we have Testimonials
                if (currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", TestimonialItem.TemplateId)) != null)
                {
                    List<TestimonialItem> linkList = currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", TestimonialItem.TemplateId)).ToList().ConvertAll(Y => new TestimonialItem(Y));

                    if (linkList.Count > 0)
                    {
                        Testimonials.DataSource = linkList;
                        Testimonials.DataBind();
                    }
                }

                //Check if we have Images
                if (currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", ImageCarouselItem.TemplateId)) != null)
                {
                    List<ImageCarouselItem> linkList = currentItem.InnerItem.Axes.SelectItems(String.Format("child::*[@@tid='{0}']", ImageCarouselItem.TemplateId)).ToList().ConvertAll(Y => new ImageCarouselItem(Y));

                    if (linkList.Count > 0)
                    {
                        OverlayImages.DataSource = linkList;
                        OverlayImages.DataBind();
                    }

                    System.Text.StringBuilder markupBuilder;

                    markupBuilder = new System.Text.StringBuilder();

                   // markupBuilder.Append("<li>");

                    int i = 0;
                    bool firstItem = true;

                    foreach(ImageCarouselItem item in linkList)
                    {

                        if (!string.IsNullOrEmpty(currentItem.Imagesperpage.Raw))
                        {

                            if (i % Convert.ToInt32(currentItem.Imagesperpage.Raw) == 0)
                            {
                                if(firstItem){
                                    markupBuilder.Append("<li>");
                                    firstItem = false;
                                }
                                else
                                {
                                    markupBuilder.Append("</li><li>");
                                }
                            }

                        }

                        markupBuilder.Append(@"<a href=""#overlay-" + i + @""">" + item.Image.RenderCrop("80x80") + @"</a>");
                        i++;
                    }

                    markupBuilder.Append("</li>");

                    ltrThumbnailItems.Text = markupBuilder.ToString();

                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                //check if we have a valid club selected
                Boolean blnClubSuccessfullySelected = clubs.Count > 0;

                if (blnClubSuccessfullySelected == true)
                {
                    //string[] clubs = txtClubGUID.Value.Split('|');
                    currentClubs = new List<ClubItem>();
                    foreach (string club in clubs)
                    {
                        if (club != "")
                        {
                            bool clubExists = false;
                            //Check for duplicates
                            foreach (ClubItem existingClubs in currentClubs)
                            {
                                if (existingClubs.ID.ToString() == club)
                                {
                                    clubExists = true;
                                }
                            }
                            if (clubExists == false)
                            {
                                currentClubs.Add((ClubItem)Sitecore.Context.Database.GetItem(Server.UrlDecode(club)));
                            }
                        }
                    }

                    if (currentClubs.Count > 0 && currentClubs[0] != null)
                    {
                        foreach (ClubItem club in currentClubs)
                        {
                            clubNames += HtmlRemoval.StripTagsCharArray(club.Clubname.Rendered).Trim() + ", ";
                        }
                        if (clubNames.LastIndexOf(",") != -1)
                        {
                            clubNames = clubNames.Substring(0, clubNames.LastIndexOf(","));
                        }

                        //set current club as first club in the collection
                        currentClub = currentClubs[0];
                        //get managers info
                        List<ManagerItem> staffMembers = null;
                        if (currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                        {
                            staffMembers = currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));
                            manager = staffMembers.First();
                        }
                        else
                        {
                            Log.Error(String.Format("No club manager exists for club: {0}", currentClub.Clubname.Raw), this);
                        }

                        //Send data to service
                        SendEnquiryDataService();

                        //Save feedback to report DB
                        SaveDataToReportDB();

                        //Send confirmation email
                        SendConfirmationEmail();

                        //get user session
                        User objUser = new User();
                        if (Session["sess_User"] != null)
                        {
                            objUser = (User)Session["sess_User"];
                        }

                        if (!string.IsNullOrEmpty(objUser.ClubLastVisitedID))
                        {
                            ClubItem club = SitecoreHelper.GetClubOnClubId(objUser.ClubLastVisitedID);
                            if (club != null)
                            {
                                //Set url
                                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                                urlOptions.AlwaysIncludeServerUrl = true;
                                urlOptions.AddAspxExtension = true;
                                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                                //Show club last visited link
                                System.Text.StringBuilder markupBuilder;
                                markupBuilder = new System.Text.StringBuilder();
                                markupBuilder.Append("<span>");
                                markupBuilder.Append(Translate.Text("You last visited") + " ");
                                markupBuilder.Append(@"<a href=""");
                                markupBuilder.Append(Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions));
                                markupBuilder.Append(@""" class=""wl"">");
                                markupBuilder.Append(club.Clubname.Rendered);
                                markupBuilder.Append("</a></span>");

                                //ltrClubLastVisitedLink.Text = markupBuilder.ToString();
                            }
                        }

                        formToComplete.Visible = false;
                        formCompleted.Visible = true;
                        pnlForm.Update();
                    }
                }
                else
                {
                    //cvClubName.IsValid = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Boolean specificSearchMatch = false;
            SkinnyItem SearchPrompt = null;

            //Check for special search term matches
            Item componentBase = Sitecore.Context.Database.GetItem(ItemPaths.Components);

            if (componentBase != null)
            {
                Item[] terms = componentBase.Axes.SelectItems(String.Format("descendant::*[@@tid='{0}']", SearchTermItem.TemplateId));
                if (terms != null)
                {
                    foreach (Item term in terms)
                    {
                        SearchTermItem itm = new SearchTermItem(term);

                        if (itm.Predictiveterm.Raw.Trim() != "")
                        {
                            Regex match = new Regex(itm.Predictiveterm.Raw);
                            if (match.IsMatch(Query))
                            {
                                specificSearchMatch = true;
                                SearchPrompt = new SkinnyItem(itm.InnerItem.Uri);
                                break;
                            }
                        }

                    }
                }
            }

            if (!String.IsNullOrEmpty(Query))
            {
                StringWriter result = new StringWriter();

                using (JsonTextWriter w = new JsonTextWriter(result))
                {
                    w.WriteStartArray();

                    //Advanced Database Search
                    var resultItems = new List<SkinnyItem>();
                    //var stopwatch = new Stopwatch();
                    try
                    {
                        //stopwatch.Start();
                        resultItems.AddRange(GetItems());
                        //stopwatch.Stop();

                        //Categorise the results
                        var clubResultList = new List<SkinnyItem>();
                        var classResultList = new List<SkinnyItem>();
                        var facilityResultList = new List<SkinnyItem>();

                        foreach (var resultItem in resultItems)
                        {
                            //check if hidden from menu
                            if (resultItem.Fields["_ishiddenfrommenu"] != null)
                            {
                                if (resultItem.Fields["_ishiddenfrommenu"].ToString() == "false" || resultItem.Fields["_showinsearchbar"].ToString() == "true")
                                {
                                    switch (resultItem.TemplateName)
                                    {
                                        case Templates.ClassicClub:
                                            clubResultList.Add(resultItem);
                                            break;
                                        case Templates.LifeCentre:
                                            clubResultList.Add(resultItem);
                                            break;
                                        case Templates.ClassModule:
                                            classResultList.Add(resultItem);
                                            break;
                                        case Templates.FacilityModule:
                                            facilityResultList.Add(resultItem);
                                            break;
                                    }
                                }
                            }
                            else
                            {
                                switch (resultItem.TemplateName)
                                {
                                    case Templates.ClassicClub:
                                        clubResultList.Add(resultItem);
                                        break;
                                    case Templates.LifeCentre:
                                        clubResultList.Add(resultItem);
                                        break;
                                    case Templates.ClassModule:
                                        classResultList.Add(resultItem);
                                        break;
                                    case Templates.FacilityModule:
                                        facilityResultList.Add(resultItem);
                                        break;
                                }
                            }
                        }

                        var filteredSortedList = new List<SkinnyItem>();

                        int j = 0; //total search result count
                        int i = 0; //category search result count

                        int categorySearchResultLimit = Settings.MaxCategorySearchResults;

                        int totalSearchResultLimit = Settings.MaxTotalSearchResults;

                        //filter and reorder the result set
                        foreach (var item in clubResultList)
                        {
                            //only read top x results
                            if (i < categorySearchResultLimit && j < totalSearchResultLimit)
                            {
                                filteredSortedList.Add(item);
                            }
                            else { break; }
                            i++;
                            j++;
                        }
                        //If specific search match found then add "more club results exist for this search" message and link (e.g. searching for London, Manchester)
                        if (i == categorySearchResultLimit && SearchPrompt != null)
                        {
                            filteredSortedList.Add(SearchPrompt);
                        }

                        i = 0;
                        foreach (var item in classResultList)
                        {
                            //only read top x results
                            if (i < categorySearchResultLimit && j < totalSearchResultLimit)
                            {
                                filteredSortedList.Add(item);
                            }
                            else { break; }
                            i++;
                            j++;
                        }
                        i = 0;

                        foreach (var item in facilityResultList)
                        {
                            //Only show in results if facility exists as a GUID in MultiList in main site area -N.B. potentially take out if taking too long

                            //Get the facilities from landing page item's facility list
                            FacilitiesLandingItem facilitiesLandingItem = Sitecore.Context.Database.GetItem(ItemPaths.FacilitiesLanding);
                            MultilistField facilityLandingList = facilitiesLandingItem.InnerItem.Fields["Facility List"];

                            foreach (Item facilityModuleItem in facilityLandingList.GetItems())
                            {
                                if (facilityModuleItem.Name == item.Name)
                                {
                                    //Facility is in main site -Add to results list

                                    //only read top x results
                                    if (i < categorySearchResultLimit && j < totalSearchResultLimit)
                                    {
                                        filteredSortedList.Add(item);
                                    }
                                    else { break; }
                                    i++;
                                    j++;
                                }
                            }
                        }

                        //write out results
                        foreach (var filteredSortedItem in filteredSortedList)
                        {
                            Item resultItem = filteredSortedItem.GetItem();
                            //Get the markup for presenting the result
                            string resultHTML = SearchResult.RenderToString(resultItem, Query);
                            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                            urlOptions.AddAspxExtension = false;
                            urlOptions.AlwaysIncludeServerUrl = true;
                            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;
                            string resultUrl = "";

                            switch (resultItem.TemplateName)
                            {
                                case Templates.SearchTerm:
                                    string clubFinderUrl = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.ClubResults)).Url;
                                    System.Text.StringBuilder url = new System.Text.StringBuilder();
                                    url.Append(clubFinderUrl);
                                    if (resultItem.Fields["Lat"] != null && resultItem.Fields["Long"] != null)
                                    {
                                        url.Append("?lat=" + resultItem.Fields["Lat"].Value);
                                        url.Append("&lng=" + resultItem.Fields["Long"].Value);
                                        url.Append("&searchloc=" + resultItem.DisplayName);
                                        url.Append("&ste=" + Query);
                                        url.Append("&sty=2");
                                    }
                                    resultUrl = url.ToString();
                                    break;
                                case Templates.ClassicClub:
                                    ClubItem ClubItm = new ClubItem(resultItem);

                                    //check if club is just a placeholder for a campaign
                                    if (ClubItm.IsPlaceholder.Checked == true)
                                    {
                                        Item campaign;

                                        if (ClubItm.PlaceholderCampaign.Item.TemplateID.ToString() == ClubMicrositeLandingItem.TemplateId)
                                        {
                                            campaign =
                                                ClubItm.PlaceholderCampaign.Item.Axes.SelectSingleItem(
                                                    String.Format("*[@@tid='{0}']", MicrositeHomeItem.TemplateId));
                                        }
                                        else
                                        {

                                            //redirect to campaign
                                            campaign = ClubItm.PlaceholderCampaign.Item;

                                        }

                                        if (campaign != null)
                                        {
                                            resultUrl = LinkManager.GetItemUrl(campaign, urlOptions);
                                        }
                                        else
                                        {
                                            resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                        }
                                    }
                                    else
                                    {
                                        resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                    }
                                    break;
                                case Templates.LifeCentre:
                                    CheckboxField IsPlaceholderLife = resultItem.Fields["Is Placeholder"];
                                    if (IsPlaceholderLife.Checked == true)
                                    {
                                        //redirect to campaign
                                        Item campaign = Sitecore.Context.Database.GetItem(resultItem.Fields["Placeholder Campaign"].Value);

                                        if (campaign != null)
                                        {
                                            UrlOptions opt = new UrlOptions();
                                            opt.AddAspxExtension = false;
                                            opt.LanguageEmbedding = LanguageEmbedding.Never;
                                            opt.AlwaysIncludeServerUrl = true;

                                            resultUrl = LinkManager.GetItemUrl(campaign, opt);
                                        }
                                        else
                                        {
                                            resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                        }
                                    }
                                    else
                                    {
                                        resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                    }
                                    break;
                                default:
                                    resultUrl = Sitecore.Links.LinkManager.GetItemUrl(resultItem, urlOptions);
                                    break;
                            }

                            //Write out html and result into JSON object
                            WriteResultAsJson(w, resultHTML, resultUrl);

                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(String.Format("Unable to load search results: {0}", ex.Message), null);
                        mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
                    }
                    finally
                    {
                        //stopwatch.Stop();
                    }

                    w.WriteEndArray();

                    Response.Write(result.ToString());
                }
            }
            else
            {
                Log.Error(String.Format("Unable to load search results: No query passed in"), null);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //CREATE NEW USER SESSION
            //Check if we are loading home page for the first time
            User objUser = new User();

            //Check Session
            if (Session["sess_User"] == null)
            {
                newSession = true;
            }
            else
            {
                objUser = (User)Session["sess_User"];
            }

            //READ/SET COOKIE OPTIONS
            if (newSession)
            {
                //New Session

                //Check gallery preference
                if (!string.IsNullOrEmpty(CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery)))
                {
                    //Store to session
                    objUser.ShowGallery = CookieHelper.GetCookieValue(CookieKeyNames.ShowGallery) == "Y" ? true : false;
                }

                //Check if cookie preferences session cookie exists
                if (!string.IsNullOrEmpty(CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies)))
                {
                    Preferences preferences = new Preferences();

                    preferences.MarketingCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MarketingCookies) == "Y" ? true : false;
                    preferences.MetricsCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.MetricsCookies) == "Y" ? true : false;
                    preferences.PersonalisedCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.PersonalisedCookies) == "Y" ? true : false;
                    preferences.SocialCookies = CookieHelper.GetOptInCookieValue(CookieKeyNames.SocialCookies) == "Y" ? true : false;

                    //Store to session
                    objUser.Preferences = preferences;
                }
                else
                {
                    //Interorgate the request 'Do Not Track' settings.
                    HttpContext objContext = HttpContext.Current;
                    bool headerDoNotTrack = false;

                    if (!string.IsNullOrEmpty(objContext.Request.Headers["DNT"]))
                    {
                        headerDoNotTrack = objContext.Request.Headers["DNT"] == "1" ? true : false;
                    }

                    if (headerDoNotTrack)
                    {
                        //Set Preferences in User Session -default to N
                        Preferences preferences = new Preferences();

                        preferences.MarketingCookies = false;
                        preferences.MetricsCookies = false;
                        preferences.PersonalisedCookies = false;
                        preferences.SocialCookies = false;

                        objUser.Preferences = preferences;

                        //Set Cookie Preferences Cookie
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "N");
                        CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "N");

                        //Delete Existing Personalisation Cookie
                        CookieHelper.DeleteCookie();
                    }
                }
            }

            //DEFAULT PREFERENCES
            if (objUser.Preferences == null)
            {
                //Set preferences in User Session -default to Y
                Preferences preferences = new Preferences();

                preferences.MarketingCookies = true;
                preferences.MetricsCookies = true;
                preferences.PersonalisedCookies = true;
                preferences.SocialCookies = true;

                //Store to session
                objUser.Preferences = preferences;

                //Set Cookie Preferences Cookie -default to permission allowed
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MarketingCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.MetricsCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.PersonalisedCookies, "Y");
                CookieHelper.AddUpdateOptInCookie(CookieKeyNames.SocialCookies, "Y");
            }

            //SET PAGE META DATA
            PageSummaryItem item = new PageSummaryItem(currentItem);

            string canonicalTag = item.GetCanonicalTag();

            string metaDescription = item.GetMetaDescription();

            //Add page title //todo: add club name
            string title = Translate.Text("Virgin Active");
            string browserPageTitle = item.GetPageTitle();

            if (!String.IsNullOrEmpty(browserPageTitle))
            {
                title = String.Format("{0} | {1}", browserPageTitle, title);
            }

            Page.Title = title;
            //Add canonical
            Page.Header.Controls.Add(new Literal() { Text = canonicalTag });
            //Add meta description
            Page.Header.Controls.Add(new Literal() { Text = metaDescription });

            //Load OpenTag container for all pages (Google needs it)
            HtmlHead head = (HtmlHead)Page.Header;
            head.Controls.Add(new LiteralControl(OpenTagHelper.OpenTagVirginActiveUK));

            //Add open graph tags (controls info facebook needs)
            string openGraphDescription = "";
            string openGraphImage = "";
            string openGraphTitle = title;

            string startPath = Sitecore.Context.Site.StartPath.ToString();
            var homeItem = Sitecore.Context.Database.GetItem(startPath);
            var options = new UrlOptions { AlwaysIncludeServerUrl = true, AddAspxExtension = false, LanguageEmbedding = LanguageEmbedding.Never };
            var homeUrl = LinkManager.GetItemUrl(homeItem, options);
            var mediaOptions = new MediaUrlOptions { AbsolutePath = true };

            //Set return to main site link
            HomeMainSiteUrl = homeUrl + "?sc_device=default&persisted=true";

            openGraphDescription = SitecoreHelper.GetSiteSetting("Facebook description");
            openGraphImage = SitecoreHelper.GetSiteSetting("Facebook image url");

            //Overwrite if we are inheriting from Social Open Graph
            SocialOpenGraphItem openGraphDetails;
            var itemTemplate = TemplateManager.GetTemplate(currentItem);

            if (itemTemplate.InheritsFrom("Social Open Graph"))
            {
                openGraphDetails = (SocialOpenGraphItem)currentItem;

                openGraphTitle = openGraphDetails.Title.Raw != "" ? openGraphDetails.Title.Raw : openGraphTitle;
                openGraphDescription = openGraphDetails.Description.Raw != "" ? openGraphDetails.Description.Raw : openGraphDescription;
                openGraphImage = openGraphDetails.ImageUrl.Raw != "" ? openGraphDetails.ImageUrl.Raw : openGraphImage;
            }

            Literal openGraphMeta = new Literal();
            openGraphMeta.Text = String.Format(metaProperty, "og:title", openGraphTitle);
            openGraphMeta.Text = openGraphMeta.Text +  String.Format(metaProperty, "og:description", openGraphDescription);
            openGraphMeta.Text = openGraphMeta.Text + String.Format(metaProperty, "og:image", openGraphImage);

            Page.Header.Controls.Add(openGraphMeta);

            //SET PAGE LINKS

            youTubeUrl = Settings.YouTubeLinkUrl;
            twitterUrl = Settings.TwitterLinkUrl;
            facebookUrl = Settings.FacebookLinkUrl;

            privacyUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.PrivacyPolicy);
            termsAndConditionsUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.TermsAndConditions);
            cookiesUrl = SitecoreHelper.GetQualifiedUrlFromItemPath(ItemPaths.CookiesForm);

            //Set featured promo link and home page link
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = true;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            //Set home page link (set as club home if home club set)
            homeOrClubPageUrl = Sitecore.Links.LinkManager.GetItemUrl(homeItem, urlOptions);

            //<h1><a href="/" class="logo"><strong>VIRGIN ACTIVE</strong> HEALTH CLUBS</a></h1>
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            if (Sitecore.Context.Item.ID == homeItem.ID)
            {
                //Page is home page
                markupBuilder.Append(@"<h1><a class=""logo"" href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @"""><strong class=""home"">");
                markupBuilder.Append(Translate.Text("VIRGIN ACTIVE") + "</strong> ");
                markupBuilder.Append(Translate.Text("HEALTH CLUBS") + "</a></h1>");
            }
            else
            {
                markupBuilder.Append(@"<a class=""logo"" href=""");
                markupBuilder.Append(HomeOrClubPageUrl + @"""><strong>");
                markupBuilder.Append(Translate.Text("VIRGIN ACTIVE") + "</strong> ");
                markupBuilder.Append(Translate.Text("HEALTH CLUBS") + "</a>");
            }

            ltrHeaderText.Text = markupBuilder.ToString();
        }
 public string GetUrl(Sitecore.Links.UrlOptions options)
 {
     return(LinkManager.GetItemUrl(_item, options));
 }
        public void CreateGoogleProductFeed(Sitecore.Data.Items.Item[] items, Sitecore.Tasks.CommandItem command,
                                            Sitecore.Tasks.ScheduleItem scheduleItem)
        {
            if (!GoogleProductFeedConfiguration.IsGoogleProductFeedXMLSchedulerEnabled())
            {
                Log.Info("GoogleProductFeed scheduler is disabled. To enable it check GoogleProductFeed.config-> GoogleProductFeed.SchedulerEnabled setting.", this);
                return;
            }

            if (items != null && items.Any())
            {
                Log.Info("Google Product Feed Started", this);
                foreach (var item in items)
                {
                    var sitesInConfig = GoogleProductFeedConfiguration.GetSitecoreSites();

                    var currentConfigurations = sitesInConfig.Where(x => x.RootItemPath.ToLower().Equals(item.Paths.FullPath.ToLower())).FirstOrDefault();

                    if (currentConfigurations != null)
                    {
                        try
                        {
                            List <GoogleProductFeed> feeds = new List <GoogleProductFeed>();

                            //Get Google Product Feed Configuration Item
                            Item GPFConfigurationItem = Sitecore.Configuration.Factory.GetDatabase("master").GetItem(currentConfigurations.ConfigurationPath); //Sitecore.Context.Database.GetItem(new Sitecore.Data.ID("{3DA415DD-526E-4F59-BDE4-F10D07EFC7F1}"));

                            LinkField rootFolder = GPFConfigurationItem.Fields["Root Item Path"];

                            NameValueListField  GPFProperties = GPFConfigurationItem.Fields["Fields"];
                            NameValueCollection fields        = GPFProperties.NameValues;

                            if (GPFProperties != null && GPFProperties.NameValues != null && GPFProperties.NameValues.Count > 0)
                            {
                                string ProductTemplateID = GPFConfigurationItem["Template"];

                                using (var context = ContentSearchManager.CreateSearchContext((SitecoreIndexableItem)item))
                                {
                                    // All Products
                                    var searchResultItems = context.GetQueryable <SearchResultItem>()
                                                            .Where(x => x.TemplateId == Sitecore.Data.ID.Parse(ProductTemplateID) && x.Path.Contains(rootFolder.TargetItem.Paths.FullPath))
                                                            .AsEnumerable()
                                                            .Where(x => x != null && x.GetItem() != null && x.Version == x.GetItem().Versions.GetLatestVersion().Version.ToString());

                                    if (searchResultItems != null && searchResultItems.Any())
                                    {
                                        foreach (var results in searchResultItems)
                                        {
                                            GoogleProductFeed feed = new GoogleProductFeed();
                                            var itemtest           = results.GetItem();
                                            feed.Title = (results.GetField(fields[FieldNames.Title]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.Title]).Value))) ? results.GetField(fields[FieldNames.Title]).Value : string.Empty;

                                            Sitecore.Links.UrlOptions URLOptions = new Sitecore.Links.UrlOptions();
                                            URLOptions.Site = Sitecore.Configuration.Factory.GetSite(currentConfigurations.SiteName);
                                            URLOptions.LanguageEmbedding = LanguageEmbedding.Never;
                                            var itemUrl = LinkManager.GetItemUrl(results.GetItem(), URLOptions);
                                            feed.Link           = string.Format("{0}{1}", currentConfigurations.UrlPrefix, itemUrl);
                                            feed.Description    = (results.GetField(fields[FieldNames.Description]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.Description]).Value))) ? results.GetField(fields[FieldNames.Description]).Value : string.Empty;
                                            feed.gID            = (results.GetField(fields[FieldNames.gID]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gID]).Value))) ? results.GetField(fields[FieldNames.gID]).Value : string.Empty;
                                            feed.gItem_Group_ID = (results.GetField(fields[FieldNames.gItem_Group_ID]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gItem_Group_ID]).Value))) ? results.GetField(fields[FieldNames.gItem_Group_ID]).Value : string.Empty;
                                            feed.gSize          = (results.GetField(fields[FieldNames.gSize]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSize]).Value))) ? results.GetField(fields[FieldNames.gSize]).Value : string.Empty;
                                            feed.gSize_Type     = (results.GetField(fields[FieldNames.gSize_Type]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSize_Type]).Value))) ? results.GetField(fields[FieldNames.gSize_Type]).Value : string.Empty;
                                            feed.gMPN           = (results.GetField(fields[FieldNames.gMPN]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMPN]).Value))) ? results.GetField(fields[FieldNames.gMPN]).Value : string.Empty;
                                            feed.gBrand         = (results.GetField(fields[FieldNames.gBrand]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gBrand]).Value))) ? results.GetField(fields[FieldNames.gBrand]).Value : string.Empty;
                                            feed.gCondition     = (results.GetField(fields[FieldNames.gCondition]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gCondition]).Value))) ? results.GetField(fields[FieldNames.gCondition]).Value : string.Empty;
                                            feed.gPrice         = (results.GetField(fields[FieldNames.gPrice]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gPrice]).Value))) ? results.GetField(fields[FieldNames.gPrice]).Value : string.Empty;
                                            if (!string.IsNullOrWhiteSpace(feed.gPrice) && GPFConfigurationItem.Fields["Add Currency"].Value.Equals("1"))
                                            {
                                                feed.gPrice = feed.gPrice + " " + GPFConfigurationItem.Fields["Currency"].Value;
                                            }
                                            feed.gAvailability      = (results.GetField(fields[FieldNames.gAvailability]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAvailability]).Value))) ? results.GetField(fields[FieldNames.gAvailability]).Value : string.Empty;
                                            feed.gImage_Link        = (results.GetField(fields[FieldNames.gImage_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gImage_Link]).Value))) ? results.GetField(fields[FieldNames.gImage_Link]).Value : string.Empty;
                                            feed.gMobile_Link       = (results.GetField(fields[FieldNames.gMobile_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMobile_Link]).Value))) ? results.GetField(fields[FieldNames.gMobile_Link]).Value : string.Empty;
                                            feed.gAvailability_Date = (results.GetField(fields[FieldNames.gAvailability_Date]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAvailability_Date]).Value))) ? results.GetField(fields[FieldNames.gAvailability_Date]).Value : string.Empty;
                                            feed.gSale_Price        = (results.GetField(fields[FieldNames.gSale_Price]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gSale_Price]).Value))) ? results.GetField(fields[FieldNames.gSale_Price]).Value : string.Empty;
                                            feed.gTin                     = (results.GetField(fields[FieldNames.gTin]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gTin]).Value))) ? results.GetField(fields[FieldNames.gTin]).Value : string.Empty;
                                            feed.gColor                   = (results.GetField(fields[FieldNames.gColor]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gColor]).Value))) ? results.GetField(fields[FieldNames.gColor]).Value : string.Empty;
                                            feed.gGender                  = (results.GetField(fields[FieldNames.gGender]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGender]).Value))) ? results.GetField(fields[FieldNames.gGender]).Value : string.Empty;
                                            feed.gAge_Group               = (results.GetField(fields[FieldNames.gAge_Group]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAge_Group]).Value))) ? results.GetField(fields[FieldNames.gAge_Group]).Value : string.Empty;
                                            feed.gMaterial                = (results.GetField(fields[FieldNames.gMaterial]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMaterial]).Value))) ? results.GetField(fields[FieldNames.gMaterial]).Value : string.Empty;
                                            feed.gPattern                 = (results.GetField(fields[FieldNames.gPattern]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gPattern]).Value))) ? results.GetField(fields[FieldNames.gPattern]).Value : string.Empty;
                                            feed.gAdditional_Image_Link   = (results.GetField(fields[FieldNames.gAdditional_Image_Link]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdditional_Image_Link]).Value))) ? results.GetField(fields[FieldNames.gAdditional_Image_Link]).Value : string.Empty;
                                            feed.gGoogle_Product_Category = (results.GetField(fields[FieldNames.gGoogle_Product_Category]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGoogle_Product_Category]).Value))) ? results.GetField(fields[FieldNames.gGoogle_Product_Category]).Value : string.Empty;
                                            feed.gCountry                 = (results.GetField(fields[FieldNames.gCountry]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gCountry]).Value))) ? results.GetField(fields[FieldNames.gCountry]).Value : string.Empty;
                                            feed.gService                 = (results.GetField(fields[FieldNames.gService]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gService]).Value))) ? results.GetField(fields[FieldNames.gService]).Value : string.Empty;
                                            feed.gShippingPrice           = (results.GetField(fields[FieldNames.gShipping_Price]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Price]).Value))) ? results.GetField(fields[FieldNames.gShipping_Price]).Value : string.Empty;
                                            if (!string.IsNullOrWhiteSpace(feed.gShippingPrice) && GPFConfigurationItem.Fields["Add Currency"].Value.Equals("1"))
                                            {
                                                feed.gShippingPrice = feed.gShippingPrice + " " + GPFConfigurationItem.Fields["Currency"].Value;
                                            }
                                            feed.gShipping_Weight      = (results.GetField(fields[FieldNames.gShipping_Weight]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Weight]).Value))) ? results.GetField(fields[FieldNames.gShipping_Weight]).Value : string.Empty;
                                            feed.gShipping_Label       = (results.GetField(fields[FieldNames.gShipping_Label]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gShipping_Label]).Value))) ? results.GetField(fields[FieldNames.gShipping_Label]).Value : string.Empty;
                                            feed.gMultipack            = (results.GetField(fields[FieldNames.gMultipack]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gMultipack]).Value))) ? results.GetField(fields[FieldNames.gMultipack]).Value : string.Empty;
                                            feed.gIs_Bundle            = (results.GetField(fields[FieldNames.gIs_Bundle]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gIs_Bundle]).Value))) ? results.GetField(fields[FieldNames.gIs_Bundle]).Value : string.Empty;
                                            feed.gAdult                = (results.GetField(fields[FieldNames.gAdult]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdult]).Value))) ? results.GetField(fields[FieldNames.gAdult]).Value : string.Empty;
                                            feed.gAdwords_Redirect     = (results.GetField(fields[FieldNames.gAdwords_Redirect]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gAdwords_Redirect]).Value))) ? results.GetField(fields[FieldNames.gAdwords_Redirect]).Value : string.Empty;
                                            feed.gExpiration_Date      = (results.GetField(fields[FieldNames.gExpiration_Date]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gExpiration_Date]).Value))) ? results.GetField(fields[FieldNames.gExpiration_Date]).Value : string.Empty;
                                            feed.gExcluded_Destination = (results.GetField(fields[FieldNames.gExcluded_Destination]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gExcluded_Destination]).Value))) ? results.GetField(fields[FieldNames.gExcluded_Destination]).Value : string.Empty;
                                            feed.gGoogle_Product_Type  = new List <GoogleProductType>();
                                            GoogleProductType type = new GoogleProductType();
                                            type.gProduct_Type = (results.GetField(fields[FieldNames.gGoogle_Product_Type]) != null && (!string.IsNullOrWhiteSpace(results.GetField(fields[FieldNames.gGoogle_Product_Type]).Value))) ? results.GetField(fields[FieldNames.gGoogle_Product_Type]).Value : string.Empty;
                                            feed.gGoogle_Product_Type.Add(type);

                                            if (!string.IsNullOrWhiteSpace(feed.Description) && feed.Description.Count() > 5000)
                                            {
                                                feed.Description = feed.Description.Take(5000).ToString();
                                            }
                                            feeds.Add(feed);
                                        }
                                    }
                                }
                            }

                            try
                            {
                                if (feeds != null && feeds.Count() > 0)
                                {
                                    feeds = feeds.OrderBy(x => x.Title).ToList();
                                    string xmlContent = GoogleProductFeedCreation.BuildGoogleProductFeedXML(feeds);

                                    if (!string.IsNullOrWhiteSpace(xmlContent))
                                    {
                                        // Get Google Product Feed XML item from Master database, Update it and Publish it
                                        Database masterDb = Sitecore.Configuration.Factory.GetDatabase("master");
                                        if (masterDb != null)
                                        {
                                            Item googleProductFeedXMLItem = masterDb.GetItem(currentConfigurations.XMLPath);
                                            if (googleProductFeedXMLItem != null)
                                            {
                                                bool isItemUpdatedSuccessfully = true;
                                                GoogleProductFeedCreation.UpdateGoogleProductFeedXMLItem(googleProductFeedXMLItem, xmlContent, ref isItemUpdatedSuccessfully);

                                                if (isItemUpdatedSuccessfully)
                                                {
                                                    GoogleProductFeedCreation.PublishGoogleProductFeedXMLItem(googleProductFeedXMLItem, masterDb, true, Sitecore.Configuration.Factory.GetDatabase("web"));
                                                }
                                            }
                                            else
                                            {
                                                Log.Warn("GoogleProductFeed XML Item not found for " + Sitecore.Context.Site.StartPath, this);
                                            }
                                        }
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                Log.Error("Error while generating googleproductfeed.xml for " + Sitecore.Context.Site, ex, this);
                            }
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Error in Google Product Feed", ex, this);
                        }
                    }
                }

                Log.Info("Google Product Feed Ended", this);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Text.StringBuilder markupBuilder = new System.Text.StringBuilder();

            //Redirect to club home
            Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
            urlOptions.AlwaysIncludeServerUrl = true;
            urlOptions.AddAspxExtension = false;
            urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

            micrositeLanding = micrositeHome.InnerItem.Parent;

            if (micrositeLanding != null)
            {
                club = micrositeLanding.Club.Item;

                if (club != null)
                {
                    //Get opening hours
                    if (club.Openinghours.Rendered.Trim() != "")
                    {
                        //add opening hours details
                        markupBuilder.Append(@"<p class=""openingtimes"">");
                        markupBuilder.Append(club.Openinghours.Rendered);
                        markupBuilder.Append(@"</p>");

                        openingHours = markupBuilder.ToString();
                    }

                    //Get address

                    markupBuilder = new System.Text.StringBuilder();

                    markupBuilder.Append(club.Addressline1.Text);
                    markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline2.Text) ? "<br />" + club.Addressline2.Text : "");
                    markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline3.Text) ? "<br />" + club.Addressline3.Text : "");
                    markupBuilder.Append("<br />");
                    markupBuilder.Append(!String.IsNullOrEmpty(club.Addressline4.Text) ? club.Addressline4.Text + " " : "");
                    markupBuilder.Append(club.Postcode.Text);

                    Address.Text = markupBuilder.ToString();

                    //Get Club details

                    ClubName = club.Clubname.Rendered;
                    lng = club.Long.Raw;
                    lat = club.Lat.Raw;

                    //Get timetable link
                    if (micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", MicrositeTimetableItem.TemplateId)) != null)
                    {
                        MicrositeTimetableItem timetableItem = new MicrositeTimetableItem(micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", MicrositeTimetableItem.TemplateId)));
                        MicrositeTimetableLandingItem timetableSectionItem = new MicrositeTimetableLandingItem(timetableItem.InnerItem.Parent);
                        ClubTimetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableSectionItem);
                    }
                    else
                    {
                        if (micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableDownloadItem.TemplateId)) != null)
                        {
                            TimetableDownloadItem timetableDownloadItem = new TimetableDownloadItem(micrositeHome.InnerItem.Axes.SelectSingleItem(String.Format(@"descendant-or-self::*[@@tid = '{0}']", TimetableDownloadItem.TemplateId)));
                            ClubTimetableUrl = Sitecore.Links.LinkManager.GetItemUrl(timetableDownloadItem);
                        }
                    }

                    //Get enquiries link
                    PageSummaryItem enqForm = new PageSummaryItem(Sitecore.Context.Database.GetItem(ItemPaths.EnquiryForm));
                    if (enqForm != null)
                    {
                        ClubEnquiriesUrl = enqForm.Url + "?sc_trk=enq&c=" + club.InnerItem.ID.ToShortID();
                    }

                    //Get Media Items from Widget Container
                    List<FacilityModuleItem> facilities = GetDataSource(micrositeHome.InnerItem);
                    List<MediaItem> mediaItems = new List<MediaItem>();
                    if (facilities != null)
                    {
                        foreach (FacilityModuleItem facilityModule in facilities)
                        {
                            List<MediaItem> galleryItems = facilityModule.Imagegallery.ListItems.ConvertAll(x => new MediaItem(x));
                            if (galleryItems != null && galleryItems.Count > 0)
                            {
                                mediaItems.Add(galleryItems[0]);
                            }
                        }
                    }

                    if (mediaItems.Count > 0)
                    {
                        ImageList.DataSource = mediaItems;
                        ImageList.DataBind();
                    }

                    //Set club last visited
                    User objUser = new User();
                    if (Session["sess_User"] != null)
                    {
                        objUser = (User)Session["sess_User"];
                    }
                    objUser.ClubLastVisitedID = club.ClubId.Rendered;
                    Session["sess_User"] = objUser;

                    //Set club last visited cookie
                    //if (objUser.Preferences != null)
                    //{
                    //    if (objUser.Preferences.PersonalisedCookies)
                    //    {
                    CookieHelper.AddClubsLastVisitedCookie(CookieKeyNames.ClubLastVisited, club.ClubId.Rendered);
                    //    }
                    //}
                }
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                //check if we have a valid club selected
                //Boolean blnClubSuccessfullySelected = txtClubGUID.Value != "";

                //check if we have a valid club selected
                Boolean blnClubSuccessfullySelected = clubFindSelect.SelectedIndex != 0;

                if (blnClubSuccessfullySelected == true)
                {
                    //Guid id = new Guid(
                    currentClub = (ClubItem)Sitecore.Context.Database.GetItem(clubFindSelect.SelectedValue);

                    if (currentClub != null)
                    {
                        //get managers info
                        List<ManagerItem> staffMembers = null;
                        if (currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)) != null)
                        {
                            staffMembers = currentClub.InnerItem.Axes.SelectItems(String.Format("descendant-or-self::*[@@tid = '{0}']", ManagerItem.TemplateId)).ToList().ConvertAll(x => new ManagerItem(x));

                            manager = staffMembers.First();
                        }

                        //if (currentClub.GetCrmSystem() == ClubCrmSystemTypes.ClubCentric)
                        //{
                        //    //Data is sent to client via email
                        //    SendAdminEmail();
                        //}
                        //   else
                        //   {
                                //Data is sent to client via service
                        //       SendEnquiryDataService();
                        //   }

                        //Data is sent to client via service
                        SendEnquiryDataService();

                        //Save feedback to report DB
                        SaveDataToReportDB();

                        //Send confirmation email
                        SendConfirmationEmail();

                        //get user session
                        User objUser = new User();
                        if(Session["sess_User"] != null)
                        {
                            objUser = (User)Session["sess_User"];
                        }

                        if (!string.IsNullOrEmpty(objUser.ClubLastVisitedID))
                        {
                            ClubItem club = SitecoreHelper.GetClubOnClubId(objUser.ClubLastVisitedID);
                            if (club != null)
                            {
                                //Set url
                                Sitecore.Links.UrlOptions urlOptions = new Sitecore.Links.UrlOptions();
                                urlOptions.AlwaysIncludeServerUrl = true;
                                urlOptions.AddAspxExtension = true;
                                urlOptions.LanguageEmbedding = LanguageEmbedding.Never;

                                //Show club last visited link
                                System.Text.StringBuilder markupBuilder;
                                markupBuilder = new System.Text.StringBuilder();
                                markupBuilder.Append("<span>");
                                markupBuilder.Append(Translate.Text("You last visited") + " ");
                                markupBuilder.Append(@"<a href=""");
                                markupBuilder.Append(Sitecore.Links.LinkManager.GetItemUrl(club, urlOptions));
                                markupBuilder.Append(@""" class=""wl"">");
                                markupBuilder.Append(club.Clubname.Rendered);
                                markupBuilder.Append("</a></span>");

                                //ltrClubLastVisitedLink.Text = markupBuilder.ToString();
                            }
                        }

                        formToComplete.Visible = false;
                        formCompleted.Visible = true;

                        //System.Threading.Thread.Sleep(5000);
                        pnlForm.Update();
                    }
                }
                else
                {
                    cvClubName.IsValid = false;
                }
            }
            catch (Exception ex)
            {
                Log.Error(String.Format("Error processing club enquiry form {0}", ex.Message), this);
                mm.virginactive.common.EmailMessagingService.ErrorEmailNotification.SendMail(ex);
            }
        }
Beispiel #31
0
        public static string GetItemUrl(Item item, SiteContext site, Language language = null)
        {
            Sitecore.Links.UrlOptions options = Sitecore.Links.UrlOptions.DefaultOptions;

            options.SiteResolving          = Sitecore.Configuration.Settings.Rendering.SiteResolving;
            options.Site                   = SiteContext.GetSite(site.Name);
            options.AlwaysIncludeServerUrl = false;
            if (language != null)
            {
                options.LanguageEmbedding = LanguageEmbedding.Always;
                options.Language          = language;
            }

            string url = Sitecore.Links.LinkManager.GetItemUrl(item, options);

            var serverUrl = (new SitemapManagerConfiguration(site.Name)).ServerUrl;

            var isHttps = false;

            if (serverUrl.Contains("http://"))
            {
                serverUrl = serverUrl.Substring("http://".Length);
                isHttps   = false;
            }
            else if (serverUrl.Contains("https://"))
            {
                serverUrl = serverUrl.Substring("https://".Length);
                isHttps   = true;
            }

            StringBuilder sb = new StringBuilder();

            if (!string.IsNullOrEmpty(serverUrl))
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    if (isHttps)
                    {
                        sb.Append("https://");
                    }
                    else
                    {
                        sb.Append("http://");
                    }
                    sb.Append(serverUrl);
                    if (url.IndexOf("/", 3) > 0)
                    {
                        sb.Append(url.Substring(url.IndexOf("/", 3)));
                    }
                }
                else
                {
                    if (isHttps)
                    {
                        sb.Append("https://");
                    }
                    else
                    {
                        sb.Append("http://");
                    }
                    sb.Append(serverUrl);
                    sb.Append(url);
                }
            }
            else if (!string.IsNullOrEmpty(site.Properties["hostname"]))
            {
                if (isHttps)
                {
                    sb.Append("https://");
                }
                else
                {
                    sb.Append("http://");
                }
                sb.Append(site.Properties["hostname"]);
                sb.Append(url);
            }
            else
            {
                if (url.Contains("://") && !url.Contains("http"))
                {
                    if (isHttps)
                    {
                        sb.Append("https://");
                    }
                    else
                    {
                        sb.Append("http://");
                    }
                    sb.Append(url);
                }
                else
                {
                    sb.Append(Sitecore.Web.WebUtil.GetFullUrl(url));
                }
            }
            return(sb.ToString());
        }