本文整理汇总了C#中Rock.Model.CommunicationService.Save方法的典型用法代码示例。如果您正苦于以下问题:C# CommunicationService.Save方法的具体用法?C# CommunicationService.Save怎么用?C# CommunicationService.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.CommunicationService
的用法示例。
在下文中一共展示了CommunicationService.Save方法的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 )
{
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();
}
示例2: 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 )
{
using ( new UnitOfWorkScope() )
{
var service = new CommunicationService();
var communication = UpdateCommunication( service );
if ( communication != null )
{
var newCommunication = communication.Clone( false );
newCommunication.Id = 0;
newCommunication.Guid = Guid.Empty;
newCommunication.SenderPersonId = CurrentPersonId;
newCommunication.Status = CommunicationStatus.Transient;
newCommunication.ReviewerPersonId = null;
newCommunication.ReviewedDateTime = null;
newCommunication.ReviewerNote = string.Empty;
communication.Recipients.ToList().ForEach( r =>
newCommunication.Recipients.Add( new CommunicationRecipient()
{
PersonId = r.PersonId,
Status = CommunicationRecipientStatus.Pending,
StatusNote = string.Empty
} ) );
service.Add( newCommunication, CurrentPersonId );
service.Save( newCommunication, CurrentPersonId );
// 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();
}
}
}
示例3: 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 );
}
}
}
}
示例4: btnSave_Click
/// <summary>
/// Handles the Click event of the btnSave 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 btnSave_Click( object sender, EventArgs e )
{
if ( Page.IsValid )
{
using ( new UnitOfWorkScope() )
{
var service = new CommunicationService();
var communication = UpdateCommunication( service );
if ( communication != null )
{
var prevStatus = communication.Status;
if ( communication.Status == CommunicationStatus.Transient )
{
communication.Status = CommunicationStatus.Draft;
}
service.Save( communication, CurrentPersonId );
ShowResult( "The communication has been saved", communication );
}
}
}
}
示例5: 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 )
{
using ( new UnitOfWorkScope() )
{
var service = new CommunicationService();
var communication = UpdateCommunication( service );
if ( communication != null )
{
var prevStatus = communication.Status;
if ( IsUserAuthorized( "Approve" ) )
{
communication.Status = CommunicationStatus.Denied;
communication.ReviewedDateTime = DateTime.Now;
communication.ReviewerPersonId = CurrentPersonId;
}
service.Save( communication, CurrentPersonId );
// TODO: Send notice to sneder that communication was denied
ShowResult( "The communicaiton has been denied", communication );
}
}
}
}
示例6: btnSubmit_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 btnSubmit_Click( object sender, EventArgs e )
{
if ( Page.IsValid )
{
using ( new UnitOfWorkScope() )
{
var service = new CommunicationService();
var communication = UpdateCommunication( service );
if ( communication != null )
{
string message = string.Empty;
var prevStatus = communication.Status;
if ( CheckApprovalRequired( communication.Recipients.Count ) && !IsUserAuthorized( "Approve" ) )
{
communication.Status = CommunicationStatus.Submitted;
message = "Communication has been submitted for approval.";
}
else
{
communication.Status = CommunicationStatus.Approved;
communication.ReviewedDateTime = DateTime.Now;
communication.ReviewerPersonId = CurrentPersonId;
message = "Communication has been queued for sending.";
// TODO: Send notice to sender that communication was approved
}
communication.Recipients
.Where( r =>
r.Status == CommunicationRecipientStatus.Cancelled ||
r.Status == CommunicationRecipientStatus.Failed )
.ToList()
.ForEach( r =>
{
r.Status = CommunicationRecipientStatus.Pending;
r.StatusNote = string.Empty;
}
);
service.Save( communication, CurrentPersonId );
if ( communication.Status == CommunicationStatus.Approved )
{
bool sendNow = false;
if ( bool.TryParse( GetAttributeValue( "SendWhenApproved" ), out sendNow ) && sendNow )
{
var transaction = new Rock.Transactions.SendCommunicationTransaction();
transaction.CommunicationId = communication.Id;
transaction.PersonId = CurrentPersonId;
Rock.Transactions.RockQueue.TransactionQueue.Enqueue( transaction );
}
}
ShowResult( message, communication );
}
}
}
}