Ewl » Canonical The canonical version of EWL Read More
Clone URL:  
Pushed to 2 repositories · View In Graph Contained in tip and canonical

Added filesDeletedNotifier to BlobFileCollectionManager.

Changeset c818fe1eb9a7

Parent 8f97a97d4c5c

by Profile picture of William GrossWilliam Gross

Changes to one file · Browse files at c818fe1eb9a7 Showing diff from parent 8f97a97d4c5c Diff from another changeset...

 
7
8
9
10
11
12
13
 
22
23
24
25
 
 
26
27
28
 
42
43
44
45
46
47
48
49
50
51
52
 
56
57
58
59
 
 
 
 
 
60
61
62
 
 
63
64
65
 
113
114
115
116
 
 
117
 
118
119
120
 
206
207
208
209
 
210
211
212
 
7
8
9
 
10
11
12
 
21
22
23
 
24
25
26
27
28
 
42
43
44
 
 
 
 
 
45
46
47
 
51
52
53
 
54
55
56
57
58
59
60
61
62
63
64
65
66
 
114
115
116
 
117
118
119
120
121
122
123
 
209
210
211
 
212
213
214
215
@@ -7,7 +7,6 @@
 using System.Web.UI.WebControls;  using EnterpriseWebLibrary.DataAccess.BlobStorage;  using EnterpriseWebLibrary.EnterpriseWebFramework.Controls; -using EnterpriseWebLibrary.InputValidation;  using EnterpriseWebLibrary.IO;  using EnterpriseWebLibrary.WebSessionState;   @@ -22,7 +21,8 @@
  private string[] acceptableFileExtensions;   private readonly bool sortByName;   private readonly string postBackIdBase; - private Action<Validator, System.Drawing.Image> validateImage = delegate {}; + private readonly NewFileNotificationMethod fileCreatedOrReplacedNotifier; + private readonly Action filesDeletedNotifier;   private IEnumerable<BlobFile> files;   private readonly IReadOnlyCollection<DataModification> dataModifications;   @@ -42,11 +42,6 @@
  public bool AcceptOnlyImages { get; set; }     /// <summary> - /// Set the method to execute when a new file is uploaded. - /// </summary> - public NewFileNotificationMethod NewFileNotificationMethod { private get; set; } - - /// <summary>   /// Sets the method used to get thumbnail URLs for files with the image content type. The method takes a file ID and returns a resource info object.   /// </summary>   public Func<decimal, ResourceInfo> ThumbnailResourceInfoCreator { private get; set; } @@ -56,10 +51,16 @@
  /// </summary>   /// <param name="sortByName"></param>   /// <param name="postBackIdBase">Do not pass null.</param> - public BlobFileCollectionManager( bool sortByName = false, string postBackIdBase = "" ) { + /// <param name="fileCreatedOrReplacedNotifier">A method that executes after a file is created or replaced.</param> + /// <param name="filesDeletedNotifier">A method that executes after one or more files are deleted.</param> + public BlobFileCollectionManager( + bool sortByName = false, string postBackIdBase = "", NewFileNotificationMethod fileCreatedOrReplacedNotifier = null, + Action filesDeletedNotifier = null ) {   Caption = "";   this.sortByName = sortByName;   this.postBackIdBase = PostBack.GetCompositeId( "ewfFileCollection", postBackIdBase ); + this.fileCreatedOrReplacedNotifier = fileCreatedOrReplacedNotifier; + this.filesDeletedNotifier = filesDeletedNotifier;     dataModifications = FormState.Current.DataModifications;   } @@ -113,8 +114,10 @@
  var deletePb = PostBack.CreateFull(   id: PostBack.GetCompositeId( postBackIdBase, "delete" ),   firstModificationMethod: () => { - if( deleteModMethods.Aggregate( false, ( deletesOccurred, method ) => method() || deletesOccurred ) ) + if( deleteModMethods.Aggregate( false, ( deletesOccurred, method ) => method() || deletesOccurred ) ) { + filesDeletedNotifier?.Invoke();   EwfPage.AddStatusMessage( StatusMessageType.Info, "Selected files deleted successfully." ); + }   } );   FormState.ExecuteWithDataModificationsAndDefaultAction(   deletePb.ToCollection(), @@ -206,7 +209,7 @@
  file.Contents,   BlobStorageStatics.GetContentTypeForPostedFile( file ) );   - NewFileNotificationMethod?.Invoke( newFileId ); + fileCreatedOrReplacedNotifier?.Invoke( newFileId );   EwfPage.AddStatusMessage( StatusMessageType.Info, "File uploaded successfully." );   } );   return FormState.ExecuteWithDataModificationsAndDefaultAction(