private void CleanFile(string fileName, List<ContentType> listContentTypes, List<Exclusion> listExclusion) { try { using (PptDocumentReader pptReader = new PptDocumentReader(fileName, true)) { pptReader.Clean(listContentTypes, listExclusion); } } catch (System.Exception ex) { Logger.LogError("Powerpoint Binary cleaning failed"); Logger.LogError(ex); throw; } }
private void CleanFile(string fileName, List<ContentType> listContentTypes) { try { PptDocumentReader pptReader = new PptDocumentReader(fileName, true); pptReader.Clean(listContentTypes); } catch (System.Exception ex) { Logger.LogError(ex); throw; } finally { } }
/// <summary> /// Original incarnation of lightspeed clean method. Left for comparison. There is at least one document that gets corrupted by the /// lightspeed clean user action as opposed to the method below. see Rally DE8912 in Professional & Deltaview project. /// </summary> /// <param name="listContentTypes"></param> private void DoLightSpeedClean(List<ContentType> listContentTypes) { System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); watch.Start(); switch (m_ft) { case Workshare.Policy.FileType.WordDocument: using (WordDocumentReader Word2003Reader1 = new WordDocumentReader(m_sFileForBinClean, true)) { Word2003Reader1.Clean(listContentTypes); } break; case Workshare.Policy.FileType.ExcelSheet: using (ExcelDocumentReader Excel2003Reader1 = new ExcelDocumentReader(m_sFileForBinClean, true)) { Excel2003Reader1.Clean(listContentTypes); } break; case Workshare.Policy.FileType.PowerPoint: using (Workshare.FCS.Lite.PptDocumentReader Ppt2003Reader1 = new PptDocumentReader(m_sFileForBinClean, true)) { Ppt2003Reader1.Clean(listContentTypes); } break; case Workshare.Policy.FileType.WordDocumentX: case Workshare.Policy.FileType.WordDocumentMacroX: case Workshare.Policy.FileType.WordDocumentTemplateX: case Workshare.Policy.FileType.WordDocumentMacroTemplateX: { string outFileName = System.IO.Path.GetTempFileName(); using (DocxDocumentReader Word2007Reader1 = new DocxDocumentReader(m_sFileForBinClean)) { using (Stream outStr = File.Open(outFileName, FileMode.Create)) { Word2007Reader1.CleanTo(outStr, listContentTypes); } } File.Copy(outFileName, m_sFileForBinClean, true); File.Delete(outFileName); break; } case Workshare.Policy.FileType.ExcelSheetX: case Workshare.Policy.FileType.ExcelSheetMacroX: case Workshare.Policy.FileType.ExcelSheetTemplateX: case Workshare.Policy.FileType.ExcelSheetMacroTemplateX: { string outFileName = System.IO.Path.GetTempFileName(); using (XlsxDocumentReader Excel2007Reader1 = new XlsxDocumentReader(m_sFileForBinClean)) { using (Stream outStr = File.Open(outFileName, FileMode.Create)) { Excel2007Reader1.CleanTo(outStr, listContentTypes); } } File.Copy(outFileName, m_sFileForBinClean, true); File.Delete(outFileName); break; } case Workshare.Policy.FileType.PowerPointX: case Workshare.Policy.FileType.PowerPointMacroX: case Workshare.Policy.FileType.PowerPointTemplateX: case Workshare.Policy.FileType.PowerPointMacroTemplateX: case Workshare.Policy.FileType.PowerPointShowX: case Workshare.Policy.FileType.PowerPointMacroShowX: { string outFileName = System.IO.Path.GetTempFileName(); using (PptxDocumentReader Ppt2007Reader1 = new PptxDocumentReader(m_sFileForBinClean)) { using (Stream outStr = File.Open(outFileName, FileMode.Create)) { Ppt2007Reader1.CleanTo(outStr, listContentTypes); } } File.Copy(outFileName, m_sFileForBinClean, true); File.Delete(outFileName); break; } default: break; } watch.Stop(); m_binCleanTime = watch.Elapsed.TotalSeconds; }
public void DoBinaryClean(List<ContentType> listContentTypes) { switch (m_ft) { case Workshare.Policy.FileType.WordDocument: using (WordDocumentReader Word2003Reader1 = new WordDocumentReader(m_filenameIn, true)) { Word2003Reader1.Clean(listContentTypes); } break; case Workshare.Policy.FileType.ExcelSheet: using (ExcelDocumentReader Excel2003Reader1 = new ExcelDocumentReader(m_filenameIn, true)) { Excel2003Reader1.Clean(listContentTypes); } break; case Workshare.Policy.FileType.PowerPoint: using (Workshare.FCS.Lite.PptDocumentReader Ppt2003Reader1 = new PptDocumentReader(m_filenameIn, true)) { Ppt2003Reader1.Clean(listContentTypes); } break; default: break; } }