ImageResizer  3.4.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
Public Member Functions | Static Public Member Functions | Public Attributes | Events | List of all members
ImageResizer.Plugins.BatchZipper.BatchResizeSettings Class Reference

Use this to configure the a resize job. After you start the job, do not modify this instance. More...

Collaboration diagram for ImageResizer.Plugins.BatchZipper.BatchResizeSettings:
Collaboration graph
[legend]

Public Member Functions

 BatchResizeSettings (string destinationFile, Guid jobId, IList< BatchResizeItem > files)
 Use this to configure a batch resize job. Mutable. Remember to assign at least a JobEvent handler so you know the fate of the job. More...
 
void FixDuplicateFilenames (string prefix="_")
 Loops through all files, assigning targetFilenames if they are null, and eliminating duplicate names by adding _1, _2, etc. Also normalizes filenames for use in zip folder. Used internally. May be used externally also if calling code wishes to to know the final file names. More...
 

Static Public Member Functions

static string NormalizePathForUseInZipFile (string pathName)
 Utility routine for transforming path names from filesystem format (on Windows that means backslashes) to a format suitable for use within zipfiles. This means trimming the volume letter and colon (if any) And swapping backslashes for forward slashes. More...
 

Public Attributes

Guid jobId
 
IList< BatchResizeItemfiles
 
string destinationFile
 
Config conf = null
 

Events

ItemCallback ItemEvent
 Fired when a file is successfully written to the zip file, or if an item fails to be added to the zip file. Will execute on a thread pool thread. Catch all your exeptions, or they will cause the jobe to fail. Set e.Cancel to cancel the job. Uses the same thread the job is processing on - I/O bound tasks in handlers should be async if possible. More...
 
JobCallback JobEvent
 Fires when the Zip file has successfully been written to disk, when the job fails. Will execute on a thread pool thread. Catch all your exeptions, or they will cause the asp.net proccess to restart! More...
 

Detailed Description

Use this to configure the a resize job. After you start the job, do not modify this instance.

Definition at line 117 of file BatchJobSettings.cs.

Constructor & Destructor Documentation

ImageResizer.Plugins.BatchZipper.BatchResizeSettings.BatchResizeSettings ( string  destinationFile,
Guid  jobId,
IList< BatchResizeItem files 
)
inline

Use this to configure a batch resize job. Mutable. Remember to assign at least a JobEvent handler so you know the fate of the job.

Parameters
jobIdThe job ID, can be generated with Guid.NewGuid()
destinationFileThe physical path to the destination archive
filesA List<BatchResizeItem> of items to to resize and place in the folder.

Definition at line 126 of file BatchJobSettings.cs.

127  {
128  this.jobId = jobId;
129  this.destinationFile = destinationFile;
130  this.files = files;
131  this.conf = Config.Current;
132  }

Member Function Documentation

void ImageResizer.Plugins.BatchZipper.BatchResizeSettings.FixDuplicateFilenames ( string  prefix = "_")
inline

Loops through all files, assigning targetFilenames if they are null, and eliminating duplicate names by adding _1, _2, etc. Also normalizes filenames for use in zip folder. Used internally. May be used externally also if calling code wishes to to know the final file names.

Definition at line 169 of file BatchJobSettings.cs.

170  {
171  HashSet<string> names = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
172  foreach (BatchResizeItem i in files)
173  {
174  //Assign default if null
175  if (i.TargetFilename == null) i.TargetFilename = System.IO.Path.GetFileNameWithoutExtension(i.PhysicalPath);
176 
177  //See if it is a duplicate
178  if (names.Contains(i.TargetFilename))
179  {
180  //Generate a unique filename by appending a number.
181  int index = 1;
182  string next = i.TargetFilename + prefix + index;
183  while (names.Contains(next))
184  {
185  index++;
186  next = i.TargetFilename + prefix + index;
187  }
188  i.TargetFilename = next;
189  }
190 
191  //Normalize for zip usage
192  i.TargetFilename = NormalizePathForUseInZipFile(i.TargetFilename);
193 
194  //Add to names set, so we can verify future filename uniqueness.
195  names.Add(i.TargetFilename);
196 
197  }
198  }
static string NormalizePathForUseInZipFile(string pathName)
Utility routine for transforming path names from filesystem format (on Windows that means backslashes...
static string ImageResizer.Plugins.BatchZipper.BatchResizeSettings.NormalizePathForUseInZipFile ( string  pathName)
inlinestatic

Utility routine for transforming path names from filesystem format (on Windows that means backslashes) to a format suitable for use within zipfiles. This means trimming the volume letter and colon (if any) And swapping backslashes for forward slashes.

Parameters
pathNamesource path.
Returns
transformed path

Definition at line 206 of file BatchJobSettings.cs.

207  {
208  // boundary case
209  if (String.IsNullOrEmpty(pathName)) return pathName;
210 
211  // trim volume if necessary
212  if ((pathName.Length >= 2) && ((pathName[1] == ':') && (pathName[2] == '\\')))
213  pathName = pathName.Substring(3);
214 
215  // swap slashes
216  pathName = pathName.Replace('\\', '/');
217 
218  // trim all leading slashes
219  while (pathName.StartsWith("/")) pathName = pathName.Substring(1);
220 
221  return SimplifyFwdSlashPath(pathName);
222  }

Event Documentation

ItemCallback ImageResizer.Plugins.BatchZipper.BatchResizeSettings.ItemEvent

Fired when a file is successfully written to the zip file, or if an item fails to be added to the zip file. Will execute on a thread pool thread. Catch all your exeptions, or they will cause the jobe to fail. Set e.Cancel to cancel the job. Uses the same thread the job is processing on - I/O bound tasks in handlers should be async if possible.

Definition at line 147 of file BatchJobSettings.cs.

JobCallback ImageResizer.Plugins.BatchZipper.BatchResizeSettings.JobEvent

Fires when the Zip file has successfully been written to disk, when the job fails. Will execute on a thread pool thread. Catch all your exeptions, or they will cause the asp.net proccess to restart!

Definition at line 152 of file BatchJobSettings.cs.


The documentation for this class was generated from the following file: