本文整理汇总了C#中System.ComponentModel.Model.HasPendingRecipients方法的典型用法代码示例。如果您正苦于以下问题:C# Model.HasPendingRecipients方法的具体用法?C# Model.HasPendingRecipients怎么用?C# Model.HasPendingRecipients使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.Model
的用法示例。
在下文中一共展示了Model.HasPendingRecipients方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Send
/// <summary>
/// Sends the specified communication.
/// </summary>
/// <param name="communication">The communication.</param>
public override void Send( Model.Communication communication )
{
var rockContext = new RockContext();
var communicationService = new CommunicationService( rockContext );
communication = communicationService.Get( communication.Id );
if ( communication != null &&
communication.Status == Model.CommunicationStatus.Approved &&
communication.HasPendingRecipients( rockContext ) &&
( !communication.FutureSendDateTime.HasValue || communication.FutureSendDateTime.Value.CompareTo( RockDateTime.Now ) <= 0 ) )
{
// Update any recipients that should not get sent the communication
var recipientService = new CommunicationRecipientService( rockContext );
foreach ( var recipient in recipientService.Queryable( "PersonAlias.Person" )
.Where( r =>
r.CommunicationId == communication.Id &&
r.Status == CommunicationRecipientStatus.Pending )
.ToList() )
{
var person = recipient.PersonAlias.Person;
if ( person.IsDeceased )
{
recipient.Status = CommunicationRecipientStatus.Failed;
recipient.StatusNote = "Person is deceased!";
}
}
rockContext.SaveChanges();
}
base.Send( communication );
}
示例2: Send
/// <summary>
/// Sends the specified communication.
/// </summary>
/// <param name="communication">The communication.</param>
public override void Send( Model.Communication communication )
{
var rockContext = new RockContext();
var communicationService = new CommunicationService( rockContext );
communication = communicationService.Queryable()
.FirstOrDefault( t => t.Id == communication.Id );
if ( communication != null &&
communication.Status == Model.CommunicationStatus.Approved &&
communication.HasPendingRecipients( rockContext ) &&
( !communication.FutureSendDateTime.HasValue || communication.FutureSendDateTime.Value.CompareTo( RockDateTime.Now ) <= 0 ) )
{
// Update any recipients that should not get sent the communication
var recipientService = new CommunicationRecipientService( rockContext );
foreach ( var recipient in recipientService.Queryable( "PersonAlias.Person" )
.Where( r =>
r.CommunicationId == communication.Id &&
r.Status == CommunicationRecipientStatus.Pending )
.ToList() )
{
var person = recipient.PersonAlias.Person;
if ( !person.IsEmailActive)
{
recipient.Status = CommunicationRecipientStatus.Failed;
recipient.StatusNote = "Email is not active!";
}
if ( person.IsDeceased )
{
recipient.Status = CommunicationRecipientStatus.Failed;
recipient.StatusNote = "Person is deceased!";
}
if ( person.EmailPreference == Model.EmailPreference.DoNotEmail )
{
recipient.Status = CommunicationRecipientStatus.Failed;
recipient.StatusNote = "Email Preference of 'Do Not Email!'";
}
else if ( person.EmailPreference == Model.EmailPreference.NoMassEmails && communication.IsBulkCommunication )
{
recipient.Status = CommunicationRecipientStatus.Failed;
recipient.StatusNote = "Email Preference of 'No Mass Emails!'";
}
}
// If an unsubscribe value has been entered, and this is a bulk email, add the text
if ( communication.IsBulkCommunication )
{
string unsubscribeHtml = GetAttributeValue( "UnsubscribeHTML" );
if ( !string.IsNullOrWhiteSpace( unsubscribeHtml ) )
{
communication.SetMediumDataValue( "UnsubscribeHTML", unsubscribeHtml );
}
}
string defaultPlainText = GetAttributeValue( "DefaultPlainText" );
if ( !string.IsNullOrWhiteSpace( defaultPlainText ) )
{
communication.SetMediumDataValue( "DefaultPlainText", defaultPlainText );
}
rockContext.SaveChanges();
}
base.Send( communication );
}