本文整理汇总了C#中Rock.Model.BinaryFileService.CanDelete方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryFileService.CanDelete方法的具体用法?C# BinaryFileService.CanDelete怎么用?C# BinaryFileService.CanDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rock.Model.BinaryFileService
的用法示例。
在下文中一共展示了BinaryFileService.CanDelete方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnSave_Click
//.........这里部分代码省略.........
{
if ( changes.Any() )
{
HistoryService.SaveChanges(
rockContext,
typeof( Person ),
Rock.SystemGuid.Category.HISTORY_PERSON_DEMOGRAPHIC_CHANGES.AsGuid(),
person.Id,
changes );
}
if ( orphanedPhotoId.HasValue )
{
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
var binaryFile = binaryFileService.Get( orphanedPhotoId.Value );
if ( binaryFile != null )
{
// marked the old images as IsTemporary so they will get cleaned up later
binaryFile.IsTemporary = true;
rockContext.SaveChanges();
}
}
// if they used the ImageEditor, and cropped it, the uncropped file is still in BinaryFile. So clean it up
if ( imgPhoto.CropBinaryFileId.HasValue )
{
if ( imgPhoto.CropBinaryFileId != person.PhotoId )
{
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
var binaryFile = binaryFileService.Get( imgPhoto.CropBinaryFileId.Value );
if ( binaryFile != null && binaryFile.IsTemporary )
{
string errorMessage;
if ( binaryFileService.CanDelete( binaryFile, out errorMessage ) )
{
binaryFileService.Delete( binaryFile );
rockContext.SaveChanges();
}
}
}
}
}
// save address
if ( pnlAddress.Visible )
{
Guid? familyGroupTypeGuid = Rock.SystemGuid.GroupType.GROUPTYPE_FAMILY.AsGuidOrNull();
if ( familyGroupTypeGuid.HasValue )
{
var familyGroup = new GroupService( rockContext ).Queryable()
.Where( f => f.GroupType.Guid == familyGroupTypeGuid.Value
&& f.Members.Any( m => m.PersonId == person.Id ) )
.FirstOrDefault();
if ( familyGroup != null )
{
Guid? addressTypeGuid = GetAttributeValue("LocationType").AsGuidOrNull();
if ( addressTypeGuid.HasValue )
{
var groupLocationService = new GroupLocationService( rockContext );
var dvHomeAddressType = DefinedValueCache.Read( addressTypeGuid.Value );
var familyAddress = groupLocationService.Queryable().Where( l => l.GroupId == familyGroup.Id && l.GroupLocationTypeValueId == dvHomeAddressType.Id ).FirstOrDefault();
if ( familyAddress != null && string.IsNullOrWhiteSpace( acAddress.Street1 ) )
{
// delete the current address
History.EvaluateChange( changes, familyAddress.GroupLocationTypeValue.Value + " Location", familyAddress.Location.ToString(), string.Empty );
示例2: gBinaryFile_Delete
/// <summary>
/// Handles the Delete event of the gBinaryFile control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gBinaryFile_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
BinaryFile binaryFile = binaryFileService.Get( e.RowKeyId );
if ( binaryFile != null )
{
string errorMessage;
if ( !binaryFileService.CanDelete( binaryFile, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
binaryFileService.Delete( binaryFile );
rockContext.SaveChanges();
}
BindGrid();
}
示例3: gBinaryFile_Delete
/// <summary>
/// Handles the Delete event of the gBinaryFile control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gBinaryFile_Delete( object sender, RowEventArgs e )
{
var rockContext = new RockContext();
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
BinaryFile binaryFile = binaryFileService.Get( e.RowKeyId );
if ( binaryFile != null )
{
string errorMessage;
if ( !binaryFileService.CanDelete( binaryFile, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
Guid guid = binaryFile.Guid;
bool clearDeviceCache = binaryFile.BinaryFileType.Guid.Equals( Rock.SystemGuid.BinaryFiletype.CHECKIN_LABEL.AsGuid() );
binaryFileService.Delete( binaryFile );
rockContext.SaveChanges();
if ( clearDeviceCache )
{
Rock.CheckIn.KioskDevice.FlushAll();
Rock.CheckIn.KioskLabel.Flush( guid );
}
}
BindGrid();
}
示例4: btnSave_Click
//.........这里部分代码省略.........
connectionOpportunityCampus = new ConnectionOpportunityCampus();
connectionOpportunity.ConnectionOpportunityCampuses.Add( connectionOpportunityCampus );
}
connectionOpportunityCampus.CampusId = campusId;
connectionOpportunityCampus.DefaultConnectorPersonAliasId = DefaultConnectors.ContainsKey( campusId ) ? DefaultConnectors[campusId] : (int?)null;
}
// remove any group configs that were removed in the UI
var uiGroupConfigs = GroupConfigsState.Select( r => r.Guid );
foreach ( var connectionOpportunityGroupConfig in connectionOpportunity.ConnectionOpportunityGroupConfigs.Where( r => !uiGroupConfigs.Contains( r.Guid ) ).ToList() )
{
connectionOpportunity.ConnectionOpportunityGroupConfigs.Remove( connectionOpportunityGroupConfig );
connectionOpportunityGroupConfigService.Delete( connectionOpportunityGroupConfig );
}
// Add or Update group configs from the UI
foreach ( var groupConfigStateObj in GroupConfigsState )
{
ConnectionOpportunityGroupConfig connectionOpportunityGroupConfig = connectionOpportunity.ConnectionOpportunityGroupConfigs.Where( a => a.Guid == groupConfigStateObj.Guid ).FirstOrDefault();
if ( connectionOpportunityGroupConfig == null )
{
connectionOpportunityGroupConfig = new ConnectionOpportunityGroupConfig();
connectionOpportunity.ConnectionOpportunityGroupConfigs.Add( connectionOpportunityGroupConfig );
}
connectionOpportunityGroupConfig.GroupTypeId = groupConfigStateObj.GroupTypeId;
connectionOpportunityGroupConfig.GroupMemberRoleId = groupConfigStateObj.GroupMemberRoleId;
connectionOpportunityGroupConfig.GroupMemberStatus = groupConfigStateObj.GroupMemberStatus;
connectionOpportunityGroupConfig.UseAllGroupsOfType = groupConfigStateObj.UseAllGroupsOfType;
connectionOpportunityGroupConfig.ConnectionOpportunityId = connectionOpportunity.Id;
}
// Remove any groups that were removed in the UI
var uiGroups = GroupsState.Select( r => r.Guid );
foreach ( var connectionOpportunityGroup in connectionOpportunity.ConnectionOpportunityGroups.Where( r => !uiGroups.Contains( r.Guid ) ).ToList() )
{
connectionOpportunity.ConnectionOpportunityGroups.Remove( connectionOpportunityGroup );
connectionOpportunityGroupService.Delete( connectionOpportunityGroup );
}
// Add or Update groups from the UI
foreach ( var groupStateObj in GroupsState )
{
ConnectionOpportunityGroup connectionOpportunityGroup = connectionOpportunity.ConnectionOpportunityGroups.Where( a => a.Guid == groupStateObj.Guid ).FirstOrDefault();
if ( connectionOpportunityGroup == null )
{
connectionOpportunityGroup = new ConnectionOpportunityGroup();
connectionOpportunity.ConnectionOpportunityGroups.Add( connectionOpportunityGroup );
}
connectionOpportunityGroup.GroupId = groupStateObj.GroupId;
connectionOpportunityGroup.ConnectionOpportunityId = connectionOpportunity.Id;
}
connectionOpportunity.LoadAttributes();
Rock.Attribute.Helper.GetEditValues( phAttributes, connectionOpportunity );
if ( !Page.IsValid )
{
return;
}
if ( !connectionOpportunity.IsValid )
{
// Controls will render the error messages
return;
}
// use WrapTransaction since SaveAttributeValues does it's own RockContext.SaveChanges()
rockContext.WrapTransaction( () =>
{
rockContext.SaveChanges();
connectionOpportunity.SaveAttributeValues( rockContext );
if ( orphanedPhotoId.HasValue )
{
BinaryFileService binaryFileService = new BinaryFileService( rockContext );
var binaryFile = binaryFileService.Get( orphanedPhotoId.Value );
if ( binaryFile != null )
{
string errorMessage;
if ( binaryFileService.CanDelete( binaryFile, out errorMessage ) )
{
binaryFileService.Delete( binaryFile );
rockContext.SaveChanges();
}
}
}
} );
ConnectionWorkflowService.FlushCachedTriggers();
var qryParams = new Dictionary<string, string>();
qryParams["ConnectionTypeId"] = PageParameter( "ConnectionTypeId" );
NavigateToParentPage( qryParams );
}
}
示例5: CleanupTemporaryBinaryFiles
/// <summary>
/// Cleanups the temporary binary files.
/// </summary>
private void CleanupTemporaryBinaryFiles()
{
var binaryFileRockContext = new Rock.Data.RockContext();
// clean out any temporary binary files
BinaryFileService binaryFileService = new BinaryFileService( binaryFileRockContext );
foreach ( var binaryFile in binaryFileService.Queryable().Where( bf => bf.IsTemporary == true ).ToList() )
{
if ( binaryFile.ModifiedDateTime < RockDateTime.Now.AddDays( -1 ) )
{
string errorMessage;
if ( binaryFileService.CanDelete( binaryFile, out errorMessage ) )
{
binaryFileService.Delete( binaryFile );
binaryFileRockContext.SaveChanges();
}
}
}
}
示例6: gBinaryFile_Delete
/// <summary>
/// Handles the Delete event of the gBinaryFile control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="RowEventArgs" /> instance containing the event data.</param>
protected void gBinaryFile_Delete( object sender, RowEventArgs e )
{
RockTransactionScope.WrapTransaction( () =>
{
BinaryFileService binaryFileService = new BinaryFileService();
BinaryFile binaryFile = binaryFileService.Get( (int)e.RowKeyValue );
if ( binaryFile != null )
{
string errorMessage;
if ( !binaryFileService.CanDelete( binaryFile, out errorMessage ) )
{
mdGridWarning.Show( errorMessage, ModalAlertType.Information );
return;
}
binaryFileService.Delete( binaryFile, CurrentPersonId );
binaryFileService.Save( binaryFile, CurrentPersonId );
}
} );
BindGrid();
}