当前位置: 首页>>代码示例>>C#>>正文


C# CommunicationService.Join方法代码示例

本文整理汇总了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();
            }

        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:81,代码来源:CommunicationList.ascx.cs


注:本文中的Rock.Model.CommunicationService.Join方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。