Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        public static DocumentObject Build(BaseFile fileData,
                                           string spaceId,
                                           string spaceSeqNo,
                                           string spaceName,
                                           string userId,
                                           string userName,
                                           string depId,
                                           Visible visible)
        {
            var fileName = fileData.FileName;

            _logger.Debug("存储原始文件...");
            var storePath = DocumentSettings.GetStorePath(fileName);

            _logger.Debug("存储原始文件完成");
            var document = new DocumentObject
            {
                Id             = fileData.Id,
                FileName       = fileData.FileName,
                StorePath      = storePath,
                FileSize       = fileData.ContentLength,
                CreateTime     = DateTime.Now,
                DocumentType   = fileName.ToDocumentType(),
                UpdateTime     = DateTime.Now,
                CreateUserId   = userId,
                CreateUserName = userName,
                SpaceId        = spaceId,
                SpaceSeqNo     = spaceSeqNo,
                SpaceName      = spaceName,
                UpdateUserId   = userId,
                UpdateUserName = userName,
                IsConvert      = false,
                Visible        = (int)visible,
                DepId          = depId,
            };


            document.DisplayPath = DocumentSettings.GetDisplayUrl(Path.GetFileName(document.ConvertPath));


            return(document);
        }