本文整理汇总了C#中System.ComponentModel.Model.SetChannelDataValue方法的典型用法代码示例。如果您正苦于以下问题:C# Model.SetChannelDataValue方法的具体用法?C# Model.SetChannelDataValue怎么用?C# Model.SetChannelDataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.ComponentModel.Model
的用法示例。
在下文中一共展示了Model.SetChannelDataValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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.Recipients.Where( r => r.Status == Model.CommunicationRecipientStatus.Pending ).Any() &&
( !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( "Person" )
.Where( r =>
r.CommunicationId == communication.Id &&
r.Status == CommunicationRecipientStatus.Pending )
.ToList() )
{
var person = recipient.Person;
if ( person.IsDeceased ?? false )
{
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 unbsubcribe 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.SetChannelDataValue( "UnsubscribeHTML", unsubscribeHtml );
}
}
string defaultPlainText = GetAttributeValue( "DefaultPlainText" );
if ( !string.IsNullOrWhiteSpace( defaultPlainText ) )
{
communication.SetChannelDataValue( "DefaultPlainText", defaultPlainText );
}
rockContext.SaveChanges();
}
base.Send( communication );
}