本文整理汇总了C#中Rock.Model.CommunicationService.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# CommunicationService.Delete方法的具体用法?C# CommunicationService.Delete怎么用?C# CommunicationService.Delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.CommunicationService
的用法示例。
在下文中一共展示了CommunicationService.Delete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例3: btnTest_Click
/// <summary>
/// Handles the Click event of the btnSubmit 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 btnTest_Click( object sender, EventArgs e )
{
if ( Page.IsValid && CurrentPersonAliasId.HasValue )
{
// Get existing or new communication record
var rockContext = new RockContext();
var communication = UpdateCommunication( rockContext );
if ( communication != null )
{
// Using a new context (so that changes in the UpdateCommunication() are not persisted )
var testCommunication = new Rock.Model.Communication();
testCommunication.SenderPersonAliasId = communication.SenderPersonAliasId;
testCommunication.Subject = communication.Subject;
testCommunication.IsBulkCommunication = communication.IsBulkCommunication;
testCommunication.MediumEntityTypeId = communication.MediumEntityTypeId;
testCommunication.MediumDataJson = communication.MediumDataJson;
testCommunication.AdditionalMergeFieldsJson = communication.AdditionalMergeFieldsJson;
testCommunication.FutureSendDateTime = null;
testCommunication.Status = CommunicationStatus.Approved;
testCommunication.ReviewedDateTime = RockDateTime.Now;
testCommunication.ReviewerPersonAliasId = CurrentPersonAliasId;
var testRecipient = new CommunicationRecipient();
if ( communication.GetRecipientCount( rockContext ) > 0 )
{
var recipient = communication.GetRecipientsQry(rockContext).FirstOrDefault();
testRecipient.AdditionalMergeValuesJson = recipient.AdditionalMergeValuesJson;
}
testRecipient.Status = CommunicationRecipientStatus.Pending;
testRecipient.PersonAliasId = CurrentPersonAliasId.Value;
testCommunication.Recipients.Add( testRecipient );
var communicationService = new CommunicationService( rockContext );
communicationService.Add( testCommunication );
rockContext.SaveChanges();
var medium = testCommunication.Medium;
if ( medium != null )
{
medium.Send( testCommunication );
}
communicationService.Delete( testCommunication );
rockContext.SaveChanges();
nbTestResult.Visible = true;
}
}
}
示例4: btnTest_Click
/// <summary>
/// Handles the Click event of the btnTest control and sends a test communication to the
/// current person if they have an email address on their record.
/// </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 btnTest_Click( object sender, EventArgs e )
{
if ( Page.IsValid && CurrentPerson != null )
{
SetActionButtons( resetToSend: true );
if ( string.IsNullOrWhiteSpace( CurrentPerson.Email ) )
{
nbError.Text = "A test email cannot be sent because you do not have an email address.";
nbError.Visible = true;
return;
}
// Get existing or new communication record
var communication = GetCommunication( new RockContext(), null );
if ( communication != null && CurrentPersonAliasId.HasValue )
{
// Using a new context (so that changes in the UpdateCommunication() are not persisted )
var testCommunication = new Rock.Model.Communication();
testCommunication.SenderPersonAliasId = communication.SenderPersonAliasId;
testCommunication.Subject = communication.Subject;
testCommunication.IsBulkCommunication = communication.IsBulkCommunication;
testCommunication.MediumEntityTypeId = communication.MediumEntityTypeId;
testCommunication.MediumDataJson = communication.MediumDataJson;
testCommunication.AdditionalMergeFieldsJson = communication.AdditionalMergeFieldsJson;
testCommunication.FutureSendDateTime = null;
testCommunication.Status = CommunicationStatus.Approved;
testCommunication.ReviewedDateTime = RockDateTime.Now;
testCommunication.ReviewerPersonAliasId = CurrentPersonAliasId.Value;
var testRecipient = new CommunicationRecipient();
if ( communication.Recipients.Any() )
{
var recipient = communication.Recipients.FirstOrDefault();
testRecipient.AdditionalMergeValuesJson = recipient.AdditionalMergeValuesJson;
}
testRecipient.Status = CommunicationRecipientStatus.Pending;
testRecipient.PersonAliasId = CurrentPersonAliasId.Value;
testCommunication.Recipients.Add( testRecipient );
var rockContext = new RockContext();
var communicationService = new CommunicationService( rockContext );
communicationService.Add( testCommunication );
rockContext.SaveChanges();
var medium = testCommunication.Medium;
if ( medium != null )
{
medium.Send( testCommunication );
}
communicationService.Delete( testCommunication );
rockContext.SaveChanges();
nbTestResult.Visible = true;
}
}
}
示例5: DeleteExistingFamilyData
/// <summary>
/// Deletes the family's addresses, phone numbers, photos, viewed records, and people.
/// TODO: delete attendance codes for attendance data that's about to be deleted when
/// we delete the person record.
/// </summary>
/// <param name="families">The families.</param>
/// <param name="rockContext">The rock context.</param>
private void DeleteExistingFamilyData( XElement families, RockContext rockContext )
{
PersonService personService = new PersonService( rockContext );
PhoneNumberService phoneNumberService = new PhoneNumberService( rockContext );
PersonViewedService personViewedService = new PersonViewedService( rockContext );
PageViewService pageViewService = new PageViewService( rockContext );
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
PersonAliasService personAliasService = new PersonAliasService( rockContext );
PersonDuplicateService personDuplicateService = new PersonDuplicateService( rockContext );
NoteService noteService = new NoteService( rockContext );
AuthService authService = new AuthService( rockContext );
CommunicationService communicationService = new CommunicationService( rockContext );
CommunicationRecipientService communicationRecipientService = new CommunicationRecipientService( rockContext );
FinancialBatchService financialBatchService = new FinancialBatchService( rockContext );
FinancialTransactionService financialTransactionService = new FinancialTransactionService( rockContext );
PersonPreviousNameService personPreviousNameService = new PersonPreviousNameService( rockContext );
ConnectionRequestService connectionRequestService = new ConnectionRequestService( rockContext );
ConnectionRequestActivityService connectionRequestActivityService = new ConnectionRequestActivityService( rockContext );
// delete the batch data
List<int> imageIds = new List<int>();
foreach ( var batch in financialBatchService.Queryable().Where( b => b.Name.StartsWith( "SampleData" ) ) )
{
imageIds.AddRange( batch.Transactions.SelectMany( t => t.Images ).Select( i => i.BinaryFileId ).ToList() );
financialTransactionService.DeleteRange( batch.Transactions );
financialBatchService.Delete( batch );
}
// delete all transaction images
foreach ( var image in binaryFileService.GetByIds( imageIds ) )
{
binaryFileService.Delete( image );
}
foreach ( var elemFamily in families.Elements( "family" ) )
{
Guid guid = elemFamily.Attribute( "guid" ).Value.Trim().AsGuid();
GroupService groupService = new GroupService( rockContext );
Group family = groupService.Get( guid );
if ( family != null )
{
var groupMemberService = new GroupMemberService( rockContext );
var members = groupMemberService.GetByGroupId( family.Id, true );
// delete the people records
string errorMessage;
List<int> photoIds = members.Select( m => m.Person ).Where( p => p.PhotoId != null ).Select( a => (int)a.PhotoId ).ToList();
foreach ( var person in members.Select( m => m.Person ) )
{
person.GivingGroup = null;
person.GivingGroupId = null;
person.PhotoId = null;
// delete phone numbers
foreach ( var phone in phoneNumberService.GetByPersonId( person.Id ) )
{
if ( phone != null )
{
phoneNumberService.Delete( phone );
}
}
// delete communication recipient
foreach ( var recipient in communicationRecipientService.Queryable().Where( r => r.PersonAlias.PersonId == person.Id ) )
{
communicationRecipientService.Delete( recipient );
}
// delete communication
foreach ( var communication in communicationService.Queryable().Where( c => c.SenderPersonAliasId == person.PrimaryAlias.Id ) )
{
communicationService.Delete( communication );
}
// delete person viewed records
foreach ( var view in personViewedService.GetByTargetPersonId( person.Id ) )
{
personViewedService.Delete( view );
}
// delete page viewed records
foreach ( var view in pageViewService.GetByPersonId( person.Id ) )
{
pageViewService.Delete( view );
}
// delete notes created by them or on their record.
foreach ( var note in noteService.Queryable().Where ( n => n.CreatedByPersonAlias.PersonId == person.Id
|| (n.NoteType.EntityTypeId == _personEntityTypeId && n.EntityId == person.Id ) ) )
{
noteService.Delete( note );
//.........这里部分代码省略.........
示例6: DeleteExistingFamilyData
/// <summary>
/// Deletes the family's addresses, phone numbers, photos, viewed records, and people.
/// TODO: delete attendance codes for attendance data that's about to be deleted when
/// we delete the person record.
/// </summary>
/// <param name="families">The families.</param>
/// <param name="rockContext">The rock context.</param>
private void DeleteExistingFamilyData( XElement families, RockContext rockContext )
{
PersonService personService = new PersonService( rockContext );
PhoneNumberService phoneNumberService = new PhoneNumberService( rockContext );
PersonViewedService personViewedService = new PersonViewedService( rockContext );
PageViewService pageViewService = new PageViewService( rockContext );
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
PersonAliasService personAliasService = new PersonAliasService( rockContext );
NoteService noteService = new NoteService( rockContext );
AuthService authService = new AuthService( rockContext );
CommunicationService communicationService = new CommunicationService( rockContext );
CommunicationRecipientService communicationRecipientService = new CommunicationRecipientService( rockContext );
foreach ( var elemFamily in families.Elements( "family" ) )
{
Guid guid = elemFamily.Attribute( "guid" ).Value.Trim().AsGuid();
GroupService groupService = new GroupService( rockContext );
Group family = groupService.Get( guid );
if ( family != null )
{
var groupMemberService = new GroupMemberService( rockContext );
var members = groupMemberService.GetByGroupId( family.Id );
// delete the people records
string errorMessage;
List<int> photoIds = members.Select( m => m.Person ).Where( p => p.PhotoId != null ).Select( a => (int)a.PhotoId ).ToList();
foreach ( var person in members.Select( m => m.Person ) )
{
person.GivingGroup = null;
person.GivingGroupId = null;
person.PhotoId = null;
// delete phone numbers
foreach ( var phone in phoneNumberService.GetByPersonId( person.Id ) )
{
if ( phone != null )
{
phoneNumberService.Delete( phone );
}
}
// delete communication recipient
foreach ( var recipient in communicationRecipientService.Queryable().Where( r => r.PersonId == person.Id ) )
{
communicationRecipientService.Delete( recipient );
}
// delete communication
foreach ( var communication in communicationService.Queryable().Where( c => c.SenderPersonId == person.Id ) )
{
communicationService.Delete( communication );
}
// delete person viewed records
foreach ( var view in personViewedService.GetByTargetPersonId( person.Id ) )
{
personViewedService.Delete( view );
}
// delete page viewed records
foreach ( var view in pageViewService.GetByPersonId( person.Id ) )
{
pageViewService.Delete( view );
}
// delete notes created by them or on their record.
foreach ( var note in noteService.Queryable().Where ( n => n.CreatedByPersonAlias.PersonId == person.Id
|| (n.NoteType.EntityTypeId == _personEntityTypeId && n.EntityId == person.Id ) ) )
{
noteService.Delete( note );
}
//// delete any GroupMember records they have
//foreach ( var groupMember in groupMemberService.Queryable().Where( gm => gm.PersonId == person.Id ) )
//{
// groupMemberService.Delete( groupMember );
//}
//// delete any Authorization data
//foreach ( var auth in authService.Queryable().Where( a => a.PersonId == person.Id ) )
//{
// authService.Delete( auth );
//}
// delete their aliases
foreach ( var alias in personAliasService.Queryable().Where( a => a.PersonId == person.Id ) )
{
personAliasService.Delete( alias );
}
//foreach ( var relationship in person.Gro)
//.........这里部分代码省略.........