コード例 #1
0
 public override void FillIndividualPlaceholders(IEmailPerson personObject)
 {
     try
     {
         if (!(personObject is Person))
         {
             throw new ArgumentException(BaseName +
                                         ".MakeIndividualReplacements called with wrong type of person object");
         }
         Person person = (Person)personObject;
         MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
         HexIdentifier         = person.HexIdentifier();
         MemberNumber          = person.PersonId.ToString();
         if (People.FromPhoneNumber(person.Country.Code, person.Phone).Count == 1)
         {
             MemberPhoneNumber = person.Phone;
         }
     }
     catch (Exception e)
     {
         throw new Exception(
                   "Failed in FillIndividualPlaceholders person is " + personObject == null
                 ? "null"
                 : personObject.Identity.ToString(), e);
     }
 }
コード例 #2
0
        /// <summary>
        /// Renders the mail for a specific recipient, in text.
        /// </summary>
        /// <param name="person">The person to render for.</param>
        /// <returns>Text with proper replacements done</returns>
        ///
        public string RenderText(IEmailPerson recipient, string culture)
        {
            // First, check if there is a mail template AT ALL. If not, return the raw text.
            if (MailType == (int)TypedMailTemplate.TemplateType.None)
            {
                return(Body);
            }

            // (If there is a template, the body contains the serialized placeholder values)
            return(Render(recipient, culture, true).PlainText);
        }
コード例 #3
0
        public override void FillIndividualPlaceholders(IEmailPerson personObject)
        {
            if (!(personObject is Person))
            {
                throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
            }
            Person person = (Person)personObject;

            this.MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
            this.HexIdentifier         = person.HexIdentifier();
            this.MemberNumber          = person.PersonId.ToString();
        }
コード例 #4
0
        /// <summary>
        /// Renders the mail for a specific recipient
        ///
        /// </summary>
        /// <param name="recipient">The person to render for.</param>
        /// <param name="recipient">The culture to render for.</param>
        /// <param name="renderText">True if "Plain" template should be used (if available)</param>
        /// <returns>MailTemplate with proper replacements done</returns>
        ///
        public MailTemplate Render(IEmailPerson recipient, string culture, bool renderText)
        {
            lock (lockTemplates)
            {
                //Locking is needed since this is used in a multithreading scenario and the template is cached for efficiency

                TypedMailTemplate template = PrepareTemplate(culture, renderText); // Setup template and load serialized replacements
                template.FillIndividualPlaceholders(recipient);                    // Add recipient data
                template.InsertAllPlaceHoldersToTemplate();                        // Make all replacements
                this.Title = template.Template.TemplateTitleText;                  // Get the resulting title
                template.Template.TemplateBody = template.Template.TemplateBody;   // Force it to save Html
                return(new MailTemplate(template.Template));
            }
        }
コード例 #5
0
 private void CachePerson ()
 {
     if (this.person == null)
     {
         RecipientType type = (RecipientType)base.PersonType;
         if (type == RecipientType.Person)
         {
             this.person = Person.FromIdentity(base.PersonId);
         }
         else if (type == RecipientType.Reporter)
         {
             this.person = Reporter.FromIdentity(base.PersonId);
         }
     }
 }
コード例 #6
0
 private void CachePerson()
 {
     if (this.person == null)
     {
         RecipientType type = (RecipientType)base.PersonType;
         if (type == RecipientType.Person)
         {
             this.person = Person.FromIdentity(base.PersonId);
         }
         else if (type == RecipientType.Reporter)
         {
             this.person = Reporter.FromIdentity(base.PersonId);
         }
     }
 }
コード例 #7
0
        public override void FillIndividualPlaceholders(IEmailPerson personObject)
        {
            if (!(personObject is Person))
            {
                throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
            }
            Person person = (Person)personObject;

            this.MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
            this.HexIdentifier         = person.HexIdentifier();
            this.MemberNumber          = person.PersonId.ToString();
            this.Name           = person.Name;
            this.NameUrl        = HttpUtility.UrlEncode(person.Name);
            this.EmailBase64Url = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(person.Mail)));
            this.PhoneBase64Url = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(person.Phone)));
        }
コード例 #8
0
ファイル: OutboundMail.cs プロジェクト: aciofini/Swarmops
        /// <summary>
        ///     Renders the mail for a specific recipient, in HTML.
        /// </summary>
        /// <param name="recipient">The person to render for.</param>
        /// <returns>HTML with proper replacements done</returns>
        public string RenderHtml(IEmailPerson recipient, string culture)
        {
            // First, check if there is a mail template AT ALL. If not, return the raw text,
            // within <PRE></PRE> if not already html

            if (MailType == (int)TypedMailTemplate.TemplateType.None)
            {
                Regex reHtmlType = new Regex(@"(</[a-z1-4]+>)", RegexOptions.IgnoreCase);

                if (reHtmlType.IsMatch(Body))
                {
                    return(Body);
                }
                return("<PRE>" + Body + "</PRE>");
            }

            // (If there is a template, the body contains the serialized placeholder values)
            return(Render(recipient, culture, false).Html);
        }
コード例 #9
0
 public override void FillIndividualPlaceholders(IEmailPerson personObject)
 {
     if (personObject is Reporter)
     {
         Reporter person = (Reporter)personObject;
         this.ReporterEmail      = person.Email;
         this.ReporterName       = person.Name;
         this.ReporterCategories = GetConcatenatedCategoryString(person.MediaCategories);
     }
     else if (personObject is Person)
     {
         Person person = (Person)personObject;
         this.ReporterEmail      = person.Mail;
         this.ReporterName       = person.Name;
         this.ReporterCategories = "Piratpartiet/Funktionär";
     }
     else
     {
         throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
     }
 }
コード例 #10
0
 /// <summary>
 /// Serialize values from placeholder dictionary
 /// </summary>
 /// <remarks>Used to serialize the values from the placeholder dictionary wich are then placed in the body of the OutboundMail record. from where they later are deserialized when the actual rendering takes place.</remarks>
 public virtual void FillIndividualPlaceholders (IEmailPerson personObject)
 {
 }
コード例 #11
0
 public override void FillIndividualPlaceholders (IEmailPerson personObject)
 {
     if (!(personObject is Person))
         throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
     Person person = (Person)personObject;
     this.MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
     this.HexIdentifier = person.HexIdentifier();
     this.MemberNumber = person.PersonId.ToString();
 }
コード例 #12
0
 public override void FillIndividualPlaceholders (IEmailPerson personObject)
 {
     if (personObject is Reporter)
     {
         Reporter person = (Reporter)personObject;
         this.ReporterEmail = person.Email;
         this.ReporterName = person.Name;
         this.ReporterCategories = GetConcatenatedCategoryString(person.MediaCategories);
     }
     else if (personObject is Person)
     {
         Person person = (Person)personObject;
         this.ReporterEmail = person.Mail;
         this.ReporterName = person.Name;
         this.ReporterCategories = "Piratpartiet/Funktionär";
     }
     else
         throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
 }
コード例 #13
0
 /// <summary>
 ///     Serialize values from placeholder dictionary
 /// </summary>
 /// <remarks>
 ///     Used to serialize the values from the placeholder dictionary wich are then placed in the body of the
 ///     OutboundMail record. from where they later are deserialized when the actual rendering takes place.
 /// </remarks>
 public virtual void FillIndividualPlaceholders(IEmailPerson personObject)
 {
 }
コード例 #14
0
        public override void FillIndividualPlaceholders (IEmailPerson personObject)
        {
            try
            {
                if (!(personObject is Person))
                    throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
                Person person = (Person)personObject;
                this.MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
                this.HexIdentifier = person.HexIdentifier();
                this.MemberNumber = person.PersonId.ToString();
                if (People.FromPhoneNumber(person.Country.Code, person.Phone).Count == 1)
                {
                    this.MemberPhoneNumber = person.Phone.ToString();
                }
            }
            catch (Exception e)
            {
                throw new Exception("Failed in FillIndividualPlaceholders person is " + personObject == null ? "null" : personObject.Identity.ToString(), e);
            }

        }
コード例 #15
0
ファイル: OutboundMail.cs プロジェクト: SwarmCorp/Swarmops
        /// <summary>
        /// Renders the mail for a specific recipient
        /// 
        /// </summary>
        /// <param name="recipient">The person to render for.</param>
        /// <param name="recipient">The culture to render for.</param>
        /// <param name="renderText">True if "Plain" template should be used (if available)</param>
        /// <returns>MailTemplate with proper replacements done</returns>
        /// 
        public MailTemplate Render (IEmailPerson recipient, string culture, bool renderText)
        {
            lock (lockTemplates)
            {
                //Locking is needed since this is used in a multithreading scenario and the template is cached for efficiency

                TypedMailTemplate template = PrepareTemplate(culture, renderText);   // Setup template and load serialized replacements
                template.FillIndividualPlaceholders(recipient);             // Add recipient data
                template.InsertAllPlaceHoldersToTemplate();                 // Make all replacements
                this.Title = template.Template.TemplateTitleText;           // Get the resulting title
                template.Template.TemplateBody = template.Template.TemplateBody; // Force it to save Html
                return new MailTemplate(template.Template);
            }
        }
コード例 #16
0
ファイル: OutboundMail.cs プロジェクト: SwarmCorp/Swarmops
        /// <summary>
        /// Renders the mail for a specific recipient, in HTML.
        /// </summary>
        /// <param name="recipient">The person to render for.</param>
        /// <returns>HTML with proper replacements done</returns>
        /// 
        public string RenderHtml (IEmailPerson recipient, string culture)
        {
            // First, check if there is a mail template AT ALL. If not, return the raw text,
            // within <PRE></PRE> if not already html

            if (MailType == (int)TypedMailTemplate.TemplateType.None)
            {
                Regex reHtmlType = new Regex(@"(</[a-z1-4]+>)", RegexOptions.IgnoreCase);

                if (reHtmlType.IsMatch(Body))
                    return Body;
                else
                    return "<PRE>" + Body + "</PRE>";
            }

            // (If there is a template, the body contains the serialized placeholder values)
            return Render(recipient, culture, false).Html;
        }
コード例 #17
0
ファイル: OutboundMail.cs プロジェクト: SwarmCorp/Swarmops
        /// <summary>
        /// Renders the mail for a specific recipient, in text.
        /// </summary>
        /// <param name="person">The person to render for.</param>
        /// <returns>Text with proper replacements done</returns>
        /// 
        public string RenderText (IEmailPerson recipient, string culture)
        {
            // First, check if there is a mail template AT ALL. If not, return the raw text.
            if (MailType == (int)TypedMailTemplate.TemplateType.None)
            {
                return Body;
            }

            // (If there is a template, the body contains the serialized placeholder values)
            return Render(recipient, culture, true).PlainText;
        }
コード例 #18
0
 public override void FillIndividualPlaceholders (IEmailPerson personObject)
 {
     if (!(personObject is Person))
         throw new ArgumentException(this.BaseName + ".MakeIndividualReplacements called with wrong type of person object");
     Person person = (Person)personObject;
     this.MemberNumberWithCheck = CheckDigit.AppendCheckDigit(person.Identity).ToString();
     this.HexIdentifier = person.HexIdentifier();
     this.MemberNumber = person.PersonId.ToString();
     this.Name = person.Name;
     this.NameUrl = HttpUtility.UrlEncode(person.Name);
     this.EmailBase64Url = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(person.Mail)));
     this.PhoneBase64Url = HttpUtility.UrlEncode(Convert.ToBase64String(Encoding.UTF8.GetBytes(person.Phone)));
 }