protected void Page_Load(object sender, EventArgs e)
        {
            RedirectToLoginIfAnonymous();

            if (ForceRegistration && !ServiceContext.ValidateProfileSuccessfullySaved(Contact))
            {
                MissingFieldsMessage.Visible = true;
            }

            if (ShowMarketingOptionsPanel)
            {
                MarketingOptionsPanel.Visible = true;
            }

            ProfileDataSource.FetchXml       = _userFetchXmlFormat.FormatWith(Contact.Id);
            ProfileDataSource.IsSingleSource = true;

            ProfileAlertInstructions.Visible = Contact.GetAttributeValue <bool?>("adx_profilealert") ?? false;

            if (Session[ConfirmationOneTimeMessageSessionKey] != null)
            {
                ConfirmationMessage.Visible = true;
                Session.Remove(ConfirmationOneTimeMessageSessionKey);
            }

            if (IsPostBack)
            {
                return;
            }

            var contact = !Contact.Contains("donotemail") || !Contact.Contains("donotfax") || !Contact.Contains("donotphone") || !Contact.Contains("donotpostalmail")
                                ? PortalOrganizationService.RetrieveSingle(
                "contact",
                new[] { "donotemail", "donotfax", "donotphone", "donotpostalmail" },
                new[] {
                new Condition("statecode", ConditionOperator.Equal, 0),
                new Condition("contactid", ConditionOperator.Equal, Contact.Id)
            })
                                : Contact;

            if (contact == null)
            {
                throw new ApplicationException(string.Format("Couldn't retrieve contact record with contactid equal to {0}.", Contact.Id));
            }

            if (ShowMarketingOptionsPanel)
            {
                marketEmail.Checked = !contact.GetAttributeValue <bool>("donotemail");
                marketFax.Checked   = !contact.GetAttributeValue <bool>("donotfax");
                marketPhone.Checked = !contact.GetAttributeValue <bool>("donotphone");
                marketMail.Checked  = !contact.GetAttributeValue <bool>("donotpostalmail");
            }

            PopulateMarketingLists();
        }
Exemplo n.º 2
0
        protected void Page_Init(object sender, EventArgs args)
        {
            if (!System.Web.SiteMap.Enabled)
            {
                return;
            }

            var currentNode = System.Web.SiteMap.CurrentNode;

            if (currentNode == null)
            {
                return;
            }

            var templateIdString = currentNode["adx_webtemplateid"];

            if (string.IsNullOrEmpty(templateIdString))
            {
                return;
            }

            Guid templateId;

            if (!Guid.TryParse(templateIdString, out templateId))
            {
                return;
            }

            var fetch = new Fetch
            {
                Entity = new FetchEntity("adx_webtemplate")
                {
                    Attributes = new[] { new FetchAttribute("adx_source"), new FetchAttribute("adx_mimetype") },
                    Filters    = new[]
                    {
                        new Filter
                        {
                            Conditions = new[]
                            {
                                new Condition("adx_webtemplateid", ConditionOperator.Equal, templateId),
                                new Condition("statecode", ConditionOperator.Equal, 0)
                            }
                        }
                    }
                }
            };

            var webTemplate = PortalOrganizationService.RetrieveSingle(fetch);

            if (webTemplate == null)
            {
                return;
            }

            var source = webTemplate.GetAttributeValue <string>("adx_source");

            using (var output = new System.IO.StringWriter())
            {
                Html.RenderLiquid(source, string.Format("{0}:{1}", webTemplate.LogicalName, webTemplate.Id), output);
                Liquid.Html = output.ToString();
            }

            var mimetype = webTemplate.GetAttributeValue <string>("adx_mimetype");

            if (!string.IsNullOrWhiteSpace(mimetype))
            {
                ContentType = mimetype;
            }
        }