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


C# CommunicationService.Get方法代码示例

本文整理汇总了C#中Rock.Model.CommunicationService.Get方法的典型用法代码示例。如果您正苦于以下问题:C# CommunicationService.Get方法的具体用法?C# CommunicationService.Get怎么用?C# CommunicationService.Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rock.Model.CommunicationService的用法示例。


在下文中一共展示了CommunicationService.Get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: gCommunication_Delete

        /// <summary>
        /// Handles the Delete event of the gCommunication control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gCommunication_Delete( object sender, Rock.Web.UI.Controls.RowEventArgs e )
        {
            var rockContext = new RockContext();
            var communicationService = new CommunicationService( rockContext );
            var communication = communicationService.Get( e.RowKeyId );
            if ( communication != null )
            {
                string errorMessage;
                if ( !communicationService.CanDelete( communication, out errorMessage ) )
                {
                    mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                    return;
                }

                communicationService.Delete( communication );

                rockContext.SaveChanges();
            }

            BindGrid();
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:26,代码来源:CommunicationList.ascx.cs

示例2: gCommunication_Delete

        /// <summary>
        /// Handles the Delete event of the gCommunication control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="Rock.Web.UI.Controls.RowEventArgs"/> instance containing the event data.</param>
        protected void gCommunication_Delete( object sender, Rock.Web.UI.Controls.RowEventArgs e )
        {
            RockTransactionScope.WrapTransaction( () =>
            {
                var communicationService = new CommunicationService();
                var communication = communicationService.Get( e.RowKeyId );
                if ( communication != null )
                {
                    string errorMessage;
                    if ( !communicationService.CanDelete( communication, out errorMessage ) )
                    {
                        mdGridWarning.Show( errorMessage, ModalAlertType.Information );
                        return;
                    }

                    communicationService.Delete( communication, CurrentPersonId );
                    communicationService.Save( communication, CurrentPersonId );
                }
            } );

            BindGrid();
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:27,代码来源:CommunicationList.ascx.cs

示例3: btnCancel_Click

 protected void btnCancel_Click( object sender, EventArgs e )
 {
     if ( _editingApproved )
     {
         var communicationService = new CommunicationService( new RockContext() );
         var communication = communicationService.Get( CommunicationId.Value );
         if ( communication != null && communication.Status == CommunicationStatus.PendingApproval )
         {
             // Redirect back to same page without the edit param
             var pageRef = new Rock.Web.PageReference();
             pageRef.PageId = CurrentPageReference.PageId;
             pageRef.RouteId = CurrentPageReference.RouteId;
             pageRef.Parameters = new Dictionary<string, string>();
             pageRef.Parameters.Add("CommunicationId", communication.Id.ToString());
             Response.Redirect( pageRef.BuildUrl() );
             Context.ApplicationInstance.CompleteRequest();
         }
     }
 }
开发者ID:NewPointe,项目名称:Rockit,代码行数:19,代码来源:CommunicationEntry.ascx.cs

示例4: UpdateCommunication

        /// <summary>
        /// Updates a communication model with the user-entered values
        /// </summary>
        /// <param name="communicationService">The service.</param>
        /// <returns></returns>
        private Rock.Model.Communication UpdateCommunication(RockContext rockContext)
        {
            var communicationService = new CommunicationService(rockContext);
            var recipientService = new CommunicationRecipientService(rockContext);

            Rock.Model.Communication communication = null;
            IQueryable<CommunicationRecipient> qryRecipients = null;

            if ( CommunicationId.HasValue )
            {
                communication = communicationService.Get( CommunicationId.Value );
            }

            if ( communication != null )
            {
                // Remove any deleted recipients
                HashSet<int> personIdHash = new HashSet<int>( Recipients.Select( a => a.PersonId ) );
                qryRecipients = communication.GetRecipientsQry( rockContext );

                foreach ( var item in qryRecipients.Select( a => new
                {
                    Id = a.Id,
                    PersonId = a.PersonAlias.PersonId
                }) )
                {
                    if ( !personIdHash.Contains(item.PersonId) )
                    {
                        var recipient = qryRecipients.Where( a => a.Id == item.Id ).FirstOrDefault();
                        recipientService.Delete( recipient );
                        communication.Recipients.Remove( recipient );
                    }
                }
            }

            if (communication == null)
            {
                communication = new Rock.Model.Communication();
                communication.Status = CommunicationStatus.Transient;
                communication.SenderPersonAliasId = CurrentPersonAliasId;
                communicationService.Add( communication );
            }

            if (qryRecipients == null)
            {
                qryRecipients = communication.GetRecipientsQry( rockContext );
            }

            // Add any new recipients
            HashSet<int> communicationPersonIdHash = new HashSet<int>( qryRecipients.Select( a => a.PersonAlias.PersonId ) );
            foreach(var recipient in Recipients )
            {
                if ( !communicationPersonIdHash.Contains( recipient.PersonId ) )
                {
                    var person = new PersonService( rockContext ).Get( recipient.PersonId );
                    if ( person != null )
                    {
                        var communicationRecipient = new CommunicationRecipient();
                        communicationRecipient.PersonAlias = person.PrimaryAlias;
                        communication.Recipients.Add( communicationRecipient );
                    }
                }
            }

            communication.IsBulkCommunication = cbBulk.Checked;

            communication.MediumEntityTypeId = MediumEntityTypeId;
            communication.MediumData.Clear();
            GetMediumData();
            foreach ( var keyVal in MediumData )
            {
                if ( !string.IsNullOrEmpty( keyVal.Value ) )
                {
                    communication.MediumData.Add( keyVal.Key, keyVal.Value );
                }
            }

            if ( communication.MediumData.ContainsKey( "Subject" ) )
            {
                communication.Subject = communication.MediumData["Subject"];
                communication.MediumData.Remove( "Subject" );
            }

            DateTime? futureSendDate = dtpFutureSend.SelectedDateTime;
            if ( futureSendDate.HasValue && futureSendDate.Value.CompareTo( RockDateTime.Now ) > 0 )
            {
                communication.FutureSendDateTime = futureSendDate;
            }
            else
            {
                communication.FutureSendDateTime = null;
            }

            return communication;
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:99,代码来源:CommunicationEntry.ascx.cs

示例5: UpdateCommunication

        /// <summary>
        /// Updates a communication model with the user-entered values
        /// </summary>
        /// <param name="communicationService">The service.</param>
        /// <returns></returns>
        private Rock.Model.Communication UpdateCommunication(RockContext rockContext)
        {
            var communicationService = new CommunicationService(rockContext);
            var recipientService = new CommunicationRecipientService(rockContext);

            Rock.Model.Communication communication = null;
            if ( CommunicationId.HasValue )
            {
                communication = communicationService.Get( CommunicationId.Value );

                // Remove any deleted recipients
                foreach(var recipient in recipientService.GetByCommunicationId( CommunicationId.Value ) )
                {
                    if (!Recipients.Any( r => recipient.PersonAlias != null && r.PersonId == recipient.PersonAlias.PersonId))
                    {
                        recipientService.Delete(recipient);
                        communication.Recipients.Remove( recipient );
                    }
                }
            }

            if (communication == null)
            {
                communication = new Rock.Model.Communication();
                communication.Status = CommunicationStatus.Transient;
                communication.SenderPersonAliasId = CurrentPersonAliasId;
                communicationService.Add( communication );
            }

            // Add any new recipients
            foreach(var recipient in Recipients )
            {
                if ( !communication.Recipients.Any( r => r.PersonAlias != null && r.PersonAlias.PersonId == recipient.PersonId ) )
                {
                    var person = new PersonService( rockContext ).Get( recipient.PersonId );
                    if ( person != null )
                    {
                        var communicationRecipient = new CommunicationRecipient();
                        communicationRecipient.PersonAlias = person.PrimaryAlias;
                        communication.Recipients.Add( communicationRecipient );
                    }
                }
            }

            communication.IsBulkCommunication = cbBulk.Checked;

            communication.MediumEntityTypeId = MediumEntityTypeId;
            communication.MediumData.Clear();
            GetMediumData();
            foreach ( var keyVal in MediumData )
            {
                if ( !string.IsNullOrEmpty( keyVal.Value ) )
                {
                    communication.MediumData.Add( keyVal.Key, keyVal.Value );
                }
            }

            if ( communication.MediumData.ContainsKey( "Subject" ) )
            {
                communication.Subject = communication.MediumData["Subject"];
                communication.MediumData.Remove( "Subject" );
            }

            DateTime? futureSendDate = dtpFutureSend.SelectedDateTime;
            if ( futureSendDate.HasValue && futureSendDate.Value.CompareTo( RockDateTime.Now ) > 0 )
            {
                communication.FutureSendDateTime = futureSendDate;
            }
            else
            {
                communication.FutureSendDateTime = null;
            }

            return communication;
        }
开发者ID:Higherbound,项目名称:Higherbound-2016-website-upgrades,代码行数:80,代码来源:CommunicationEntry.ascx.cs

示例6: 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!";
                    }
                }

                rockContext.SaveChanges();
            }

            base.Send( communication );
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:37,代码来源:Sms.cs

示例7: btnEdit_Click

 protected void btnEdit_Click( object sender, EventArgs e )
 {
     var rockContext = new RockContext();
     var service = new CommunicationService( rockContext );
     var communication = service.Get( CommunicationId.Value );
     if ( communication != null &&
         communication.Status == CommunicationStatus.PendingApproval &&
         IsUserAuthorized( "Approve" ) )
     {
         // Redirect back to same page without the edit param
         var pageRef = CurrentPageReference;
         pageRef.Parameters.Add( "edit", "true" );
         Response.Redirect( pageRef.BuildUrl() );
         Context.ApplicationInstance.CompleteRequest();
     }
 }
开发者ID:NewPointe,项目名称:Rockit,代码行数:16,代码来源:CommunicationDetail.ascx.cs

示例8: btnDeny_Click

        /// <summary>
        /// Handles the Click event of the btnDeny control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnDeny_Click( object sender, EventArgs e )
        {
            if ( Page.IsValid && CommunicationId.HasValue )
            {
                var rockContext = new RockContext();
                var service = new CommunicationService( rockContext );
                var communication = service.Get( CommunicationId.Value );
                if ( communication != null )
                {
                    if ( communication.Status == CommunicationStatus.PendingApproval )
                    {
                        if ( IsUserAuthorized( "Approve" ) )
                        {
                            communication.Status = CommunicationStatus.Denied;
                            communication.ReviewedDateTime = RockDateTime.Now;
                            communication.ReviewerPersonAliasId = CurrentPersonAliasId;

                            rockContext.SaveChanges();

                            // TODO: Send notice to sneder that communication was denied

                            ShowResult( "The communication has been denied", communication, NotificationBoxType.Warning );
                        }
                        else
                        {
                            ShowResult( "Sorry, you are not authorized to approve or deny this communication!", communication, NotificationBoxType.Danger );
                        }
                    }
                    else
                    {
                        ShowResult( string.Format( "This communication is already {0}!", communication.Status.ConvertToString() ),
                            communication, NotificationBoxType.Warning );
                    }
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:41,代码来源:CommunicationDetail.ascx.cs

示例9: btnCopy_Click

        /// <summary>
        /// Handles the Click event of the btnCopy control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnCopy_Click( object sender, EventArgs e )
        {
            if ( Page.IsValid && CommunicationId.HasValue )
            {
                var rockContext = new RockContext();
                var service = new CommunicationService( rockContext );
                var communication = service.Get( CommunicationId.Value );
                if ( communication != null )
                {
                    var newCommunication = communication.Clone( false );
                    newCommunication.CreatedByPersonAlias = null;
                    newCommunication.CreatedByPersonAliasId = null;
                    newCommunication.CreatedDateTime = RockDateTime.Now;
                    newCommunication.ModifiedByPersonAlias = null;
                    newCommunication.ModifiedByPersonAliasId = null;
                    newCommunication.ModifiedDateTime = RockDateTime.Now;
                    newCommunication.Id = 0;
                    newCommunication.Guid = Guid.Empty;
                    newCommunication.SenderPersonAliasId = CurrentPersonAliasId;
                    newCommunication.Status = CommunicationStatus.Draft;
                    newCommunication.ReviewerPersonAliasId = null;
                    newCommunication.ReviewedDateTime = null;
                    newCommunication.ReviewerNote = string.Empty;

                    communication.Recipients.ToList().ForEach( r =>
                        newCommunication.Recipients.Add( new CommunicationRecipient()
                        {
                            PersonAliasId = r.PersonAliasId,
                            Status = CommunicationRecipientStatus.Pending,
                            StatusNote = string.Empty,
                            AdditionalMergeValuesJson = r.AdditionalMergeValuesJson
                        } ) );

                    service.Add( newCommunication );
                    rockContext.SaveChanges();

                    // Redirect to new communication
                    if ( CurrentPageReference.Parameters.ContainsKey( "CommunicationId" ) )
                    {
                        CurrentPageReference.Parameters["CommunicationId"] = newCommunication.Id.ToString();
                    }
                    else
                    {
                        CurrentPageReference.Parameters.Add( "CommunicationId", newCommunication.Id.ToString() );
                    }

                    Response.Redirect( CurrentPageReference.BuildUrl() );
                    Context.ApplicationInstance.CompleteRequest();
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:56,代码来源:CommunicationDetail.ascx.cs

示例10: btnCancel_Click

        /// <summary>
        /// Handles the Click event of the btnCancel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnCancel_Click( object sender, EventArgs e )
        {
            if ( Page.IsValid && CommunicationId.HasValue )
            {
                var rockContext = new RockContext();
                var service = new CommunicationService( rockContext );
                var communication = service.Get( CommunicationId.Value );
                if ( communication != null )
                {
                    if (communication.Status == CommunicationStatus.Approved || communication.Status == CommunicationStatus.PendingApproval)
                    {
                        if ( !communication.Recipients
                            .Where( r => r.Status == CommunicationRecipientStatus.Delivered )
                            .Any() )
                        {
                            communication.Status = CommunicationStatus.Draft;
                            rockContext.SaveChanges();

                            ShowResult( "This communication has successfully been cancelled without any recipients receiving communication!", communication, NotificationBoxType.Success );
                        }
                        else
                        {
                            communication.Recipients
                                .Where( r => r.Status == CommunicationRecipientStatus.Pending )
                                .ToList()
                                .ForEach( r => r.Status = CommunicationRecipientStatus.Cancelled );
                            rockContext.SaveChanges();

                            int delivered = communication.Recipients.Count( r => r.Status == CommunicationRecipientStatus.Delivered );
                            ShowResult( string.Format("This communication has been cancelled, however the communication was delivered to {0} recipients!", delivered)
                                , communication, NotificationBoxType.Warning );
                        }
                    }
                    else
                    {
                        ShowResult( "This communication has already been cancelled!", communication, NotificationBoxType.Warning );
                    }
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:45,代码来源:CommunicationDetail.ascx.cs

示例11: 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 );
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:63,代码来源:Email.cs

示例12: UpdateCommunication

        /// <summary>
        /// Updates a communication model with the user-entered values
        /// </summary>
        /// <param name="service">The service.</param>
        /// <returns></returns>
        private Rock.Model.Communication UpdateCommunication(CommunicationService service)
        {
            Rock.Model.Communication communication = null;
            if ( CommunicationId.HasValue )
            {
                communication = service.Get( CommunicationId.Value );
            }

            if (communication == null)
            {
                communication = new Rock.Model.Communication();
                communication.Status = CommunicationStatus.Transient;
                communication.SenderPersonId = CurrentPersonId;
                service.Add( communication, CurrentPersonId );
            }

            communication.ChannelEntityTypeId = ChannelEntityTypeId;

            foreach(var recipient in Recipients)
            {
                if ( !communication.Recipients.Where( r => r.PersonId == recipient.PersonId ).Any() )
                {
                    var communicationRecipient = new CommunicationRecipient();
                    communicationRecipient.Person = new PersonService().Get( recipient.PersonId );
                    communicationRecipient.Status = CommunicationRecipientStatus.Pending;
                    communication.Recipients.Add( communicationRecipient );
                }
            }

            GetChannelData();
            communication.ChannelData = ChannelData;
            if ( communication.ChannelData.ContainsKey( "Subject" ) )
            {
                communication.Subject = communication.ChannelData["Subject"];
                communication.ChannelData.Remove( "Subject" );
            }

            communication.FutureSendDateTime = dtpFutureSend.SelectedDateTime;

            return communication;
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:46,代码来源:Communication.ascx.cs

示例13: btnCancel_Click

        /// <summary>
        /// Handles the Click event of the btnCancel control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        protected void btnCancel_Click( object sender, EventArgs e )
        {
            if ( Page.IsValid )
            {
                if ( CommunicationId.HasValue )
                {
                    var service = new CommunicationService();
                    var communication = service.Get( CommunicationId.Value );
                    if ( communication != null )
                    {
                        var prevStatus = communication.Status;

                        communication.Recipients
                            .Where( r => r.Status == CommunicationRecipientStatus.Pending )
                            .ToList()
                            .ForEach( r => r.Status = CommunicationRecipientStatus.Cancelled );

                        // Save and re-read communication to reload recipient statuses
                        service.Save( communication, CurrentPersonId );
                        communication = service.Get( communication.Id );

                        if ( !communication.Recipients
                            .Where( r => r.Status == CommunicationRecipientStatus.Success )
                            .Any() )
                        {
                            communication.Status = CommunicationStatus.Draft;
                        }

                        ShowResult( "The communication has been cancelled", communication );
                    }
                }
            }
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:38,代码来源:Communication.ascx.cs


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