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


C# Model.CommunicationService类代码示例

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


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

示例1: GetHtmlPreview

        /// <summary>
        /// Gets the HTML preview.
        /// </summary>
        /// <param name="communication">The communication.</param>
        /// <param name="person">The person.</param>
        /// <returns></returns>
        public override string GetHtmlPreview( Model.Communication communication, Person person )
        {
            var rockContext = new RockContext();

            // Requery the Communication object
            communication = new CommunicationService( rockContext ).Get( communication.Id );

            var globalAttributes = Rock.Web.Cache.GlobalAttributesCache.Read();
            var mergeValues = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( null );

            if ( person != null )
            {
                mergeValues.Add( "Person", person );

                var recipient = communication.Recipients.Where( r => r.PersonId == person.Id ).FirstOrDefault();
                if ( recipient != null )
                {
                    // Add any additional merge fields created through a report
                    foreach ( var mergeField in recipient.AdditionalMergeValues )
                    {
                        if ( !mergeValues.ContainsKey( mergeField.Key ) )
                        {
                            mergeValues.Add( mergeField.Key, mergeField.Value );
                        }
                    }
                }
            }

            string message = communication.GetChannelDataValue( "Message" );
            return message.ResolveMergeFields( mergeValues );
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:37,代码来源:Sms.cs

示例2: Execute

        /// <summary>
        /// Execute method to write transaction to the database.
        /// </summary>
        public void Execute()
        {
            var communication = new CommunicationService( new RockContext() ).Get( CommunicationId );

            if ( communication != null && communication.Status == CommunicationStatus.Approved )
            {
                var channel = communication.Channel;
                if ( channel != null )
                {
                    channel.Send( communication );
                }
            }
        }
开发者ID:Ganon11,项目名称:Rock,代码行数:16,代码来源:SendCommunicationTransaction.cs

示例3: Execute

        /// <summary>
        /// Execute method to write transaction to the database.
        /// </summary>
        public void Execute()
        {
            using ( var rockContext = new RockContext() )
            {
                var communication = new CommunicationService( rockContext ).Get( CommunicationId );

                if ( communication != null && communication.Status == CommunicationStatus.Approved )
                {
                    var medium = communication.Medium;
                    if ( medium != null )
                    {
                        medium.Send( communication );
                    }
                }
            }
        }
开发者ID:NewSpring,项目名称:Rock,代码行数:19,代码来源:SendCommunicationTransaction.cs

示例4: Execute

        /// <summary>
        /// Execute method to write transaction to the database.
        /// </summary>
        public void Execute()
        {
            var communication = new CommunicationService().Get( CommunicationId );

            if ( communication != null && communication.Status == CommunicationStatus.Approved )
            {
                var channel = communication.Channel;
                if ( channel != null )
                {
                    var transport = channel.Transport;
                    if ( transport != null )
                    {
                        transport.Send( communication, PersonId );
                    }
                }
            }
        }
开发者ID:pkdevbox,项目名称:Rock,代码行数:20,代码来源:SendCommunicationTransaction.cs

示例5: 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

示例6: GetBreadCrumbs

        /// <summary>
        /// Returns breadcrumbs specific to the block that should be added to navigation
        /// based on the current page reference.  This function is called during the page's
        /// oninit to load any initial breadcrumbs.
        /// </summary>
        /// <param name="pageReference">The <see cref="Rock.Web.PageReference" />.</param>
        /// <returns>
        /// A <see cref="System.Collections.Generic.List{BreadCrumb}" /> of block related <see cref="Rock.Web.UI.BreadCrumb">BreadCrumbs</see>.
        /// </returns>
        public override List<Rock.Web.UI.BreadCrumb> GetBreadCrumbs( Rock.Web.PageReference pageReference )
        {
            var breadCrumbs = new List<BreadCrumb>();

            string pageTitle = "New Communication";

            int? commId = PageParameter( "CommunicationId" ).AsIntegerOrNull();
            if ( commId.HasValue )
            {
                var communication = new CommunicationService( new RockContext() ).Get( commId.Value );
                if ( communication != null )
                {
                    RockPage.SaveSharedItem( "communication", communication );

                    switch ( communication.Status )
                    {
                        case CommunicationStatus.Approved:
                        case CommunicationStatus.Denied:
                        case CommunicationStatus.PendingApproval:
                            {
                                pageTitle = string.Format( "Communication #{0}", communication.Id );
                                break;
                            }
                        default:
                            {
                                pageTitle = "New Communication";
                                break;
                            }
                    }
                }
            }

            breadCrumbs.Add( new BreadCrumb( pageTitle, pageReference ) );
            RockPage.Title = pageTitle;

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

示例7: Execute

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        public virtual void Execute( IJobExecutionContext context )
        {
            JobDataMap dataMap = context.JobDetail.JobDataMap;
            var beginWindow = RockDateTime.Now.AddDays( 0 - dataMap.GetInt( "ExpirationPeriod" ) );
            var endWindow = RockDateTime.Now.AddMinutes( 0 - dataMap.GetInt( "DelayPeriod" ) );

            var qry = new CommunicationService( new RockContext() ).Queryable()
                .Where( c =>
                    c.Status == CommunicationStatus.Approved &&
                    c.Recipients.Where( r => r.Status == CommunicationRecipientStatus.Pending ).Any() &&
                    (
                        ( !c.FutureSendDateTime.HasValue && c.CreatedDateTime.HasValue && c.CreatedDateTime.Value.CompareTo( beginWindow ) >= 0 && c.CreatedDateTime.Value.CompareTo( endWindow ) <= 0 ) ||
                        ( c.FutureSendDateTime.HasValue && c.FutureSendDateTime.Value.CompareTo( beginWindow ) >= 0 && c.FutureSendDateTime.Value.CompareTo( endWindow ) <= 0 )
                    ) );

            foreach ( var comm in qry.AsNoTracking().ToList() )
            {
                var medium = comm.Medium;
                if ( medium != null )
                {
                    medium.Send( comm );
                }
            }
        }
开发者ID:azturner,项目名称:Rock,代码行数:28,代码来源:SendCommunications.cs

示例8: 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

示例9: 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

示例10: 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

示例11: SendCommunication

        /// <summary>
        /// Sends the communication.
        /// </summary>
        private void SendCommunication()
        {
            // create communication
            if ( this.CurrentPerson != null && _groupId != -1 && !string.IsNullOrWhiteSpace( GetAttributeValue( "CommunicationPage" ) ) )
            {
                var rockContext = new RockContext();
                var service = new Rock.Model.CommunicationService( rockContext );
                var communication = new Rock.Model.Communication();
                communication.IsBulkCommunication = false;
                communication.Status = Rock.Model.CommunicationStatus.Transient;

                communication.SenderPersonAliasId = this.CurrentPersonAliasId;

                service.Add( communication );

                var personAliasIds = new GroupMemberService( rockContext ).Queryable()
                                    .Where( m => m.GroupId == _groupId && m.GroupMemberStatus != GroupMemberStatus.Inactive )
                                    .ToList()
                                    .Select( m => m.Person.PrimaryAliasId )
                                    .ToList();

                // Get the primary aliases
                foreach ( int personAlias in personAliasIds )
                {
                    var recipient = new Rock.Model.CommunicationRecipient();
                    recipient.PersonAliasId = personAlias;
                    communication.Recipients.Add( recipient );
                }

                rockContext.SaveChanges();

                Dictionary<string, string> queryParameters = new Dictionary<string, string>();
                queryParameters.Add( "CommunicationId", communication.Id.ToString() );

                NavigateToLinkedPage( "CommunicationPage", queryParameters );
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:40,代码来源:GroupDetailLava.ascx.cs

示例12: 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

示例13: OnLoad

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            if ( !Page.IsPostBack )
            {
                // Check if CommunicationDetail has already loaded existing communication
                var communication = RockPage.GetSharedItem( "Communication" ) as Rock.Model.Communication;
                if ( communication == null )
                {
                    CommunicationId = PageParameter( "CommunicationId" ).AsIntegerOrNull();
                    if ( CommunicationId.HasValue )
                    {
                        communication = new CommunicationService( new RockContext() )
                            .Queryable( "CreatedByPersonAlias.Person" )
                            .Where( c => c.Id == CommunicationId.Value )
                            .FirstOrDefault();
                    }
                }
                else
                {
                    CommunicationId = communication.Id;
                }

                // If not valid for this block, hide contents and return
                if ( communication == null ||
                    communication.Status == CommunicationStatus.Transient ||
                    communication.Status == CommunicationStatus.Draft ||
                    communication.Status == CommunicationStatus.Denied ||
                    ( communication.Status == CommunicationStatus.PendingApproval && _editingApproved ) )
                {
                    // If viewing a new, transient or draft communication, hide this block and use NewCommunication block
                    this.Visible = false;
                }
                else
                {
                    ShowDetail( communication );
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:44,代码来源:CommunicationDetail.ascx.cs

示例14: Send

        /// <summary>
        /// Sends the specified communication.
        /// </summary>
        /// <param name="communication">The communication.</param>
        /// <exception cref="System.NotImplementedException"></exception>
        public override void Send( Rock.Model.Communication communication )
        {
            using ( var rockContext = new RockContext() )
            {
                // Requery the Communication object
                communication = new CommunicationService( rockContext )
                    .Queryable( "CreatedByPersonAlias.Person" )
                    .FirstOrDefault( c => c.Id == 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 ) )
                {
                    var currentPerson = communication.CreatedByPersonAlias.Person;
                    var globalAttributes = Rock.Web.Cache.GlobalAttributesCache.Read();
                    var globalConfigValues = Rock.Web.Cache.GlobalAttributesCache.GetMergeFields( currentPerson );

                    // From - if none is set, use the one in the Organization's GlobalAttributes.
                    string fromAddress = communication.GetMediumDataValue( "FromAddress" );
                    if ( string.IsNullOrWhiteSpace( fromAddress ) )
                    {
                        fromAddress = globalAttributes.GetValue( "OrganizationEmail" );
                    }

                    string fromName = communication.GetMediumDataValue( "FromName" );
                    if ( string.IsNullOrWhiteSpace( fromName ) )
                    {
                        fromName = globalAttributes.GetValue( "OrganizationName" );
                    }

                    // Resolve any possible merge fields in the from address
                    fromAddress = fromAddress.ResolveMergeFields( globalConfigValues, currentPerson );
                    fromName = fromName.ResolveMergeFields( globalConfigValues, currentPerson );

                    MailMessage message = new MailMessage();
                    message.From = new MailAddress( fromAddress, fromName );

                    // Reply To
                    string replyTo = communication.GetMediumDataValue( "ReplyTo" );
                    if ( !string.IsNullOrWhiteSpace( replyTo ) )
                    {
                        message.ReplyToList.Add( new MailAddress( replyTo ) );
                    }

                    CheckSafeSender( message, globalAttributes );

                    // CC
                    string cc = communication.GetMediumDataValue( "CC" );
                    if ( !string.IsNullOrWhiteSpace( cc ) )
                    {
                        foreach ( string ccRecipient in cc.SplitDelimitedValues() )
                        {
                            message.CC.Add( new MailAddress( ccRecipient ) );
                        }
                    }

                    // BCC
                    string bcc = communication.GetMediumDataValue( "BCC" );
                    if ( !string.IsNullOrWhiteSpace( bcc ) )
                    {
                        foreach ( string bccRecipient in bcc.SplitDelimitedValues() )
                        {
                            message.Bcc.Add( new MailAddress( bccRecipient ) );
                        }
                    }

                    message.IsBodyHtml = true;
                    message.Priority = MailPriority.Normal;

                    using ( var smtpClient = GetSmtpClient() )
                    {
                        // Add Attachments
                        string attachmentIds = communication.GetMediumDataValue( "Attachments" );
                        if ( !string.IsNullOrWhiteSpace( attachmentIds ) )
                        {
                            var binaryFileService = new BinaryFileService( rockContext );

                            foreach ( string idVal in attachmentIds.SplitDelimitedValues() )
                            {
                                int binaryFileId = int.MinValue;
                                if ( int.TryParse( idVal, out binaryFileId ) )
                                {
                                    var binaryFile = binaryFileService.Get( binaryFileId );
                                    if ( binaryFile != null )
                                    {
                                        message.Attachments.Add( new Attachment( binaryFile.ContentStream, binaryFile.FileName ) );
                                    }
                                }
                            }
                        }

                        var historyService = new HistoryService( rockContext );
                        var recipientService = new CommunicationRecipientService( rockContext );

//.........这里部分代码省略.........
开发者ID:azturner,项目名称:Rock,代码行数:101,代码来源:SMTPComponent.cs

示例15: OnLoad

        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad( EventArgs e )
        {
            base.OnLoad( e );

            nbTestResult.Visible = false;

            if ( Page.IsPostBack )
            {
                LoadMediumControl( false );
            }
            else
            {
                ShowAllRecipients = false;

                // Check if CommunicationDetail has already loaded existing communication
                var communication = RockPage.GetSharedItem( "Communication" ) as Rock.Model.Communication;
                if ( communication == null )
                {
                    // If not, check page parameter for existing communiciaton
                    int? communicationId = PageParameter( "CommunicationId" ).AsIntegerOrNull();
                    if ( communicationId.HasValue )
                    {
                        communication = new CommunicationService( new RockContext() ).Get( communicationId.Value );
                    }
                }
                else
                {
                    CommunicationId = communication.Id;
                }

                if ( communication == null ||
                    communication.Status == CommunicationStatus.Transient ||
                    communication.Status == CommunicationStatus.Draft ||
                    communication.Status == CommunicationStatus.Denied ||
                    ( communication.Status == CommunicationStatus.PendingApproval && _editingApproved ) )
                {
                    // If viewing a new, transient, draft, or denied communication, use this block
                    ShowDetail( communication );
                }
                else
                {
                    // Otherwise, use the communication detail block
                    this.Visible = false;
                }

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


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