Пример #1
0
        /// <summary>
        /// Sends the invite.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="component">The component.</param>
        /// <param name="document">The document.</param>
        /// <param name="person">The person.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        private bool SendInvite(RockContext rockContext, DigitalSignatureComponent component, SignatureDocument document, Person person, out List <string> errors)
        {
            errors = new List <string>();
            if (document != null &&
                document.SignatureDocumentTemplate != null &&
                document.SignatureDocumentTemplate.InviteSystemEmailId.HasValue &&
                person != null &&
                !string.IsNullOrWhiteSpace(person.Email))
            {
                string inviteLink = component.GetInviteLink(document, person, out errors);
                if (!errors.Any())
                {
                    var systemEmail = new SystemEmailService(rockContext).Get(document.SignatureDocumentTemplate.InviteSystemEmailId.Value);
                    if (systemEmail != null)
                    {
                        var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(null, person);
                        mergeFields.Add("SignatureDocument", document);
                        mergeFields.Add("InviteLink", inviteLink);

                        var emailMessage = new RockEmailMessage(systemEmail);
                        emailMessage.AddRecipient(new RecipientData(person.Email, mergeFields));
                        emailMessage.Send();
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #2
0
        /// <summary>
        /// Sends the invite.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="component">The component.</param>
        /// <param name="document">The document.</param>
        /// <param name="person">The person.</param>
        /// <param name="errors">The errors.</param>
        /// <returns></returns>
        private bool SendInvite(RockContext rockContext, DigitalSignatureComponent component, SignatureDocument document, Person person, out List <string> errors)
        {
            errors = new List <string>();
            if (document != null &&
                document.SignatureDocumentTemplate != null &&
                document.SignatureDocumentTemplate.InviteSystemEmailId.HasValue &&
                person != null &&
                !string.IsNullOrWhiteSpace(person.Email))
            {
                string inviteLink = component.GetInviteLink(document, person, out errors);
                if (!errors.Any())
                {
                    var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields(null, person);
                    mergeFields.Add("SignatureDocument", document);
                    mergeFields.Add("InviteLink", inviteLink);

                    var recipients = new List <RecipientData>();
                    recipients.Add(new RecipientData(person.Email, mergeFields));

                    var systemEmail = new SystemEmailService(rockContext).Get(document.SignatureDocumentTemplate.InviteSystemEmailId.Value);
                    if (systemEmail != null)
                    {
                        var appRoot = Rock.Web.Cache.GlobalAttributesCache.Read(rockContext).GetValue("InternalApplicationRoot");
                        Email.Send(systemEmail.Guid, recipients, appRoot, string.Empty, false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }