public MhtWebFile(MhtBuilder parent, string url) { _Builder = parent; if (url != "") { this.Url = url; } }
private void RunRenderMht(IStreamGen sg) { OneFileStreamGen temp = null; FileStream fs = null; try { string tempHtmlReportFileName = Path.ChangeExtension(Path.GetTempFileName(), "htm"); temp = new OneFileStreamGen(tempHtmlReportFileName, true); RunRender(temp, OutputPresentationType.HTML); temp.CloseMainStream(); // Create the mht file (into a temporary file position) MhtBuilder mhtConverter = new MhtBuilder(); string fileName = Path.ChangeExtension(Path.GetTempFileName(), "mht"); mhtConverter.SavePageArchive(fileName, "file://" + tempHtmlReportFileName); // clean up the temporary files foreach (string tempFileName in temp.FileList) { try { File.Delete(tempFileName); } catch {} } // Copy the mht file to the requested stream Stream os = sg.GetStream(); fs = File.OpenRead(fileName); byte[] ba = new byte[4096]; int rb = 0; while ((rb = fs.Read(ba, 0, ba.Length)) > 0) { os.Write(ba, 0, rb); } } catch (Exception ex) { rl.LogError(8, "Error converting HTML to MHTML " + ex.Message + Environment.NewLine + ex.StackTrace); } finally { if (temp != null) { temp.CloseMainStream(); } if (fs != null) { fs.Close(); } _Cache = new RCache(); } }
public MhtWebFile(MhtBuilder parent, string url) { _Builder = parent; if (url != "") this.Url = url; }
public MhtWebFile(MhtBuilder parent) { _Builder = parent; }
private void RunRenderMht(IStreamGen sg) { OneFileStreamGen temp = null; FileStream fs=null; try { string tempHtmlReportFileName = Path.ChangeExtension(Path.GetTempFileName(), "htm"); temp = new OneFileStreamGen(tempHtmlReportFileName, true); RunRender(temp, OutputPresentationType.HTML); temp.CloseMainStream(); // Create the mht file (into a temporary file position) MhtBuilder mhtConverter = new MhtBuilder(); string fileName = Path.ChangeExtension(Path.GetTempFileName(), "mht"); mhtConverter.SavePageArchive(fileName, "file://" + tempHtmlReportFileName); // clean up the temporary files foreach (string tempFileName in temp.FileList) { try { File.Delete(tempFileName); } catch{} } // Copy the mht file to the requested stream Stream os = sg.GetStream(); fs = File.OpenRead(fileName); byte[] ba = new byte[4096]; int rb=0; while ((rb = fs.Read(ba, 0, ba.Length)) > 0) { os.Write(ba, 0, rb); } } catch (Exception ex) { rl.LogError(8, "Error converting HTML to MHTML " + ex.Message + Environment.NewLine + ex.StackTrace); } finally { if (temp != null) temp.CloseMainStream(); if (fs != null) fs.Close(); _Cache = new RCache(); } }
public MhtWebFile(MhtBuilder parent) { _Builder = parent; }