本文整理汇总了C#中Rock.Model.CommunicationService.GetRecipientCount方法的典型用法代码示例。如果您正苦于以下问题:C# CommunicationService.GetRecipientCount方法的具体用法?C# CommunicationService.GetRecipientCount怎么用?C# CommunicationService.GetRecipientCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.CommunicationService
的用法示例。
在下文中一共展示了CommunicationService.GetRecipientCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Executes this instance.
/// </summary>
public void Execute()
{
using ( var rockContext = new RockContext() )
{
var communication = new CommunicationService( rockContext ).Get( CommunicationId );
if ( communication != null && communication.Status == CommunicationStatus.PendingApproval )
{
// get notification group
var approvers = new GroupService( rockContext ).Get(SystemGuid.Group.GROUP_COMMUNICATION_APPROVERS.AsGuid());
if ( approvers != null )
{
var mergeFields = Rock.Lava.LavaHelper.GetCommonMergeFields( null );
string fromName = Rock.Web.Cache.GlobalAttributesCache.Value("OrganizationName");
string fromEmail = Rock.Web.Cache.GlobalAttributesCache.Value( "OrganizationEmail" );
string subject = "Pending Communication Requires Approval";
var appRoot = Rock.Web.Cache.GlobalAttributesCache.Read( rockContext ).GetValue( "PublicApplicationRoot" );
string communicationDetails = string.Empty;
string typeName = string.Empty;
// get custom details by type
switch ( communication.Medium.TypeName )
{
case "Rock.Communication.Medium.Email":
string emailFromName = communication.GetMediumDataValue( "FromName" );
string emailFromAddress = communication.GetMediumDataValue( "FromAddress" );
communicationDetails = string.Format( @"
<strong>From Name:</strong> {0}<br/>
<strong>From Address:</strong> {1}<br/>
<strong>Subject:</strong> {2}<br/>"
, emailFromName
, emailFromAddress
, communication.Subject );
typeName = "Email";
break;
case "Rock.Communication.Medium.Sms":
int fromValueId = communication.GetMediumDataValue( "FromValue" ).AsInteger();
var fromValue = new DefinedValueService( rockContext ).Get( fromValueId );
typeName = "SMS";
if ( fromValue != null )
{
communicationDetails = string.Format( "<strong>SMS Number:</strong> {0} ({1})<br/>", fromValue.Description, fromValue.Value );
}
break;
}
// create approval link if one was not provided
if ( ApprovalPageUrl == null )
{
ApprovalPageUrl = string.Format( "{0}Communication/{1}", Rock.Web.Cache.GlobalAttributesCache.Read( rockContext ).GetValue( "InternalApplicationRoot" ), communication.Id );
}
foreach ( var approver in approvers.Members )
{
string message = string.Format( @"
{{{{ 'Global' | Attribute:'EmailHeader' }}}}
<p>{0}:</p>
<p>A new communication requires approval. Information about this communication can be found below.</p>
<p>
<strong>From:</strong> {1}<br />
<strong>Type:</strong> {2}<br />
{3}
<strong>Recipient Count:</strong> {4}<br />
</p>
<p>
<a href='{5}'>View Communication</a>
</p>
{{{{ 'Global' | Attribute:'EmailFooter' }}}}",
approver.Person.NickName,
communication.SenderPersonAlias.Person.FullName,
typeName,
communicationDetails,
communication.GetRecipientCount(rockContext),
ApprovalPageUrl);
var recipients = new List<string>();
recipients.Add( approver.Person.Email );
Email.Send( fromEmail, fromName, subject, recipients, message.ResolveMergeFields( mergeFields ), appRoot, string.Empty, null, false );
}
}
}
}
}