public override bool Process(ImageWI iwi) { logger.Info("task {0} start processing: {1}", this.Name, iwi); iwi.CleanUp(); logger.Info("task {0} cleaned memory for: {1}", this.Name, iwi); return true; }
public override bool Process(ImageWI iwi) { // what to do? switch (this.WorkingStyle) { case TASKWORKINGSTYLE.STRAIGHT: // destroy fib (will be reloaded by next task) iwi.CleanUp(); // save to temp file FileInfo tmpFI; if (iwi.ImageHandleWeak != null) { // when we hav a image handle save that to disk tmpFI = new FileInfo(Path.Combine(iwi.CurrentFile.DirectoryName ?? "./", DateTime.Now.Millisecond.ToString())); ImageWorker.SaveJPGImageHandle(iwi.ImageHandle, tmpFI); } else { // if we dont have a image handle use currentfileinfo tmpFI = iwi.CurrentFile; } // transform temp file ImageWorker.AutoRotateImageFI(tmpFI, this.nameExtension); // load into fib FIBITMAP? fibitmap = ImageWorker.GetJPGImageHandle(tmpFI); if (fibitmap != null) { iwi.ImageHandle = (FIBITMAP)fibitmap; } else { // tell anyone? } // remove tempfile tmpFI.Delete(); break; case TASKWORKINGSTYLE.COPYOUTPUT: // leave fib alone // save current version, if necessary if (iwi.ImageHandleWeak != null) { ImageWorker.SaveJPGImageHandle(iwi.ImageHandle, iwi.CurrentFile); } // transform current version to new name ImageWorker.AutoRotateImageFI(iwi.CurrentFile, this.nameExtension); break; case TASKWORKINGSTYLE.COPYINPUT: // destroy fib (will be reloaded by next task) // save current file // transform file to new name break; default: throw new ArgumentOutOfRangeException(); } ImageWorker.AutoRotateImageFI(iwi.CurrentFile, string.Empty); return true; }
public override bool Process(ImageWI iwi) { bool success = false; if (iwi != null) { try { if (string.IsNullOrEmpty(this.currentDir) || this.pixInDir >= this.DirectoryFillCount) { // create new directory this.currentDir = this.createNewDirName(); if (iwi.CurrentFile != null) { if (iwi.CurrentFile.DirectoryName != null) { this.currentDirComplete = Path.Combine(iwi.CurrentFile.DirectoryName, this.currentDir); } if (!Directory.Exists(currentDirComplete)) { Directory.CreateDirectory(this.currentDirComplete); } // TODO: what about counting files in the dir? and use that count? pixInDir = 0; } } if (!string.IsNullOrEmpty(this.currentDir)) { // move file if (iwi.CurrentFile != null) { string nuLocation = Path.Combine(this.currentDirComplete, iwi.CurrentFile.Name); if (File.Exists(nuLocation)) { File.Delete(nuLocation); } // handle mode switch (WorkingStyle) { case TASKWORKINGSTYLE.STRAIGHT: File.Move(iwi.CurrentFile.FullName, nuLocation); break; case TASKWORKINGSTYLE.COPYOUTPUT: File.Copy(iwi.CurrentFile.FullName, nuLocation); break; case TASKWORKINGSTYLE.COPYINPUT: File.Copy(iwi.CurrentFile.FullName, nuLocation); // the handovered file is the file on the new location iwi.CleanUp(); iwi.CurrentFile = new FileInfo(nuLocation); break; default: throw new ArgumentOutOfRangeException(); } pixInDir++; } } success = true; } catch (Exception ex) { logger.Error("{0} got exception while processing {1}: {2}", this.Name, iwi.Name, ex); } } return success; }