本文整理汇总了C#中Rock.Model.CommunicationService.Join方法的典型用法代码示例。如果您正苦于以下问题:C# CommunicationService.Join方法的具体用法?C# CommunicationService.Join怎么用?C# CommunicationService.Join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.CommunicationService
的用法示例。
在下文中一共展示了CommunicationService.Join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BindGrid
private void BindGrid()
{
using ( new UnitOfWorkScope() )
{
var communications = new CommunicationService()
.Queryable()
.Where( c => c.Status != CommunicationStatus.Transient );
string subject = rFilter.GetUserPreference( "Subject" );
if ( !string.IsNullOrWhiteSpace( subject ) )
{
communications = communications.Where( c => c.Subject.StartsWith( subject ) );
}
Guid entityTypeGuid = Guid.Empty;
if ( Guid.TryParse( rFilter.GetUserPreference( "Channel" ), out entityTypeGuid ) )
{
communications = communications.Where( c => c.ChannelEntityType != null && c.ChannelEntityType.Guid.Equals( entityTypeGuid ) );
}
string status = rFilter.GetUserPreference( "Status" );
if ( !string.IsNullOrWhiteSpace( status ) )
{
var communicationStatus = (CommunicationStatus)System.Enum.Parse( typeof( CommunicationStatus ), status );
communications = communications.Where( c => c.Status == communicationStatus );
}
if ( canApprove )
{
int personId = 0;
if ( int.TryParse( rFilter.GetUserPreference( "Created By" ), out personId ) && personId != 0 )
{
communications = communications.Where( c => c.SenderPersonId.HasValue && c.SenderPersonId.Value == personId );
}
}
else
{
communications = communications.Where( c => c.SenderPersonId.HasValue && c.SenderPersonId.Value == CurrentPersonId );
}
string content = rFilter.GetUserPreference( "Content" );
if ( !string.IsNullOrWhiteSpace( content ) )
{
communications = communications.Where( c => c.ChannelDataJson.Contains( content ) );
}
var recipients = new CommunicationRecipientService().Queryable();
var sortProperty = gCommunication.SortProperty;
var queryable = communications
.Join( recipients,
c => c.Id,
r => r.CommunicationId,
( c, r ) => new { c, r } )
.GroupBy( cr => cr.c )
.Select( g => new CommunicationItem
{
Id = g.Key.Id,
Communication = g.Key,
Recipients = g.Count(),
PendingRecipients = g.Count( s => s.r.Status == CommunicationRecipientStatus.Pending ),
SuccessRecipients = g.Count( s => s.r.Status == CommunicationRecipientStatus.Success ),
FailedRecipients = g.Count( s => s.r.Status == CommunicationRecipientStatus.Failed ),
CancelledRecipients = g.Count( s => s.r.Status == CommunicationRecipientStatus.Cancelled )
} );
if ( sortProperty != null )
{
queryable = queryable.Sort( sortProperty );
}
else
{
queryable = queryable.OrderByDescending( c => c.Communication.Id );
}
gCommunication.DataSource = queryable.ToList();
gCommunication.DataBind();
}
}