public ConvertResult Convert(ref DocumentObject document, ConvertFileType convertType) { try { string path = DocumentSettings.GetStorePath(document.FileName); _storePolicy.Copy(path, document.StorePath); string tmpName = document.Id + convertType.ToSuffix(); var convertPath = DocumentSettings.GetConvertPath(tmpName); int result = _documentConverter.Convert(path, convertPath, convertType); if (File.Exists(tmpName)) { File.Delete(tmpName); } return(new ConvertResult { ErrorCode = result, SourcePath = document.StorePath, TargetPath = convertPath }); } catch (Exception ex) { _logger.Error(ex.Message); _logger.Error(ex.StackTrace); throw; } }
public void should_convert_from_word_to_html() { string file = Environment.CurrentDirectory + @"\TestFiles\智慧市政综合指挥平台.docx"; string target = file + ".html"; int result = _documentConverter.Convert(file, target, ConvertFileType.WordToHtml); Assert.AreEqual(result, 0); Assert.IsTrue(File.Exists(target)); }