/// <summary> /// Subclasses should call this, instead of "Callback()" directly. /// </summary> /// <param name="src"></param> /// <param name="dest"></param> protected void RaiseCallbackEvent(ConversionFile src, IEnumerable<ConversionFile> dest) { if (this.Callback != null) { Task.Run(() => this.Callback(src, dest)); } }
/// <summary> /// Subclasses should call this, instead of "Callback()" directly. /// </summary> /// <param name="src"></param> /// <param name="dest"></param> protected void RaiseCallbackEvent(ConversionFile src, IEnumerable <ConversionFile> dest) { if (this.Callback != null) { Task.Run(() => this.Callback(src, dest)); } }
private string GetOutputDir(ConversionFile toBeConverted) { if (toBeConverted == null) { return(string.Empty); } //string hash = Hash.GetEncodedHash(toBeConverted.RowId); return(Path.Combine( _rootOutputPath, toBeConverted.GetHashBasedOfRowId(), "images")); }
private string GetOutputDir(ConversionFile toBeConverted) { if (toBeConverted == null) { return string.Empty; } //string hash = Hash.GetEncodedHash(toBeConverted.RowId); return Path.Combine( _rootOutputPath, toBeConverted.GetHashBasedOfRowId(), "images"); }
public override void Execute(ConversionFile toBeConverted) { File file = this.UploadFile(toBeConverted.GetStream(), toBeConverted.FileName, toBeConverted.MimeType, true); Stream stream = this.DownloadPdf(file.Id); //TODO: I wonder what the effect would be if the converter callback used QueueBackgroundWorkItem too... if (this.Callback != null) { var dir = Path.GetDirectoryName(toBeConverted.Path); if (!string.IsNullOrWhiteSpace(dir)) { var output = ConversionFile.SaveAs(stream, Path.Combine(dir, Path.GetFileNameWithoutExtension(toBeConverted.Path) + ".pdf")); Callback(toBeConverted, new List <ConversionFile>(new[] { output }).AsEnumerable()); } } }
public override void Execute(ConversionFile toBeConverted) { File file = this.UploadFile(toBeConverted.GetStream(), toBeConverted.FileName, toBeConverted.MimeType, true); Stream stream = this.DownloadPdf(file.Id); //TODO: I wonder what the effect would be if the converter callback used QueueBackgroundWorkItem too... if (this.Callback != null) { var dir = Path.GetDirectoryName(toBeConverted.Path); if (!string.IsNullOrWhiteSpace(dir)) { var output = ConversionFile.SaveAs(stream, Path.Combine(dir, Path.GetFileNameWithoutExtension(toBeConverted.Path) + ".pdf")); Callback(toBeConverted, new List<ConversionFile>(new[] { output }).AsEnumerable()); } } }
public override void Execute(ConversionFile toBeConverted) { var outputDir = GetOutputDir(toBeConverted); if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var fileNames = PdfToImages(toBeConverted.Path, outputDir, 120); List<ConversionFile> outputFiles = new List<ConversionFile>(); foreach (string file in fileNames) { ConversionFile f = new ConversionFile { Path = file }; outputFiles.Add(f); } this.RaiseCallbackEvent(toBeConverted, outputFiles); }
public override void Execute(ConversionFile toBeConverted) { var outputDir = GetOutputDir(toBeConverted); if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } var fileNames = PdfToImages(toBeConverted.Path, outputDir, 120); List <ConversionFile> outputFiles = new List <ConversionFile>(); foreach (string file in fileNames) { ConversionFile f = new ConversionFile { Path = file }; outputFiles.Add(f); } this.RaiseCallbackEvent(toBeConverted, outputFiles); }
public static ConversionFile SaveAs(Stream stream, string path) { try { using (var fileStream = System.IO.File.Create(path)) { stream.Seek(0, SeekOrigin.Begin); stream.CopyTo(fileStream); } ConversionFile f = new ConversionFile { Path = path, Type = FileType.Local }; return(f); } // ReSharper disable once RedundantCatchClause catch (Exception ex) { //TODO: log File.SaveAs errors System.Diagnostics.Debug.WriteLine("SaveAs() Exception: " + ex.Message); throw; } }
public abstract void Execute(ConversionFile toBeConverted);
public abstract void Execute(ConversionFile toBeConverted);
public static ConversionFile SaveAs(Stream stream, string path) { try { using (var fileStream = System.IO.File.Create(path)) { stream.Seek(0, SeekOrigin.Begin); stream.CopyTo(fileStream); } ConversionFile f = new ConversionFile { Path = path, Type = FileType.Local }; return f; } // ReSharper disable once RedundantCatchClause catch (Exception ex) { //TODO: log File.SaveAs errors System.Diagnostics.Debug.WriteLine("SaveAs() Exception: " + ex.Message); throw; } }