コード例 #1
0
        public IActionResult Download(Guid fileId)
        {
            var fileStoreDTO = Service.GetDetailDTO().FirstOrDefault(x => x.Id == fileId);
            var coreModel    = new Core.Data.DTO.Common.FileStoreDTO();

            _objectMapper.Map(fileStoreDTO, coreModel);
            if (FileStoreHelper.LoadFile(coreModel, out var stream, out var contentType))
            {
                return(File(stream, contentType, fileStoreDTO.OrigFileName));
            }
コード例 #2
0
        private async Task <MemoryStream> GetFile(Guid fileId)
        {
            var dto = (await DataService.GetDtoAsync <FileStoreDTO>(x => x.Id == fileId)).FirstOrDefault();
            // С новым кором переделать FileStoreDTO
            var dtoCore = new Core.Data.DTO.Common.FileStoreDTO();

            _objectMapper.Map(dto, dtoCore);
            if (FileStoreHelper.LoadFile(dtoCore, out var stream, out var contentType))
            {
                return(stream);
            }
コード例 #3
0
        public async Task <FilesViewModel> GetEDocumentJsonFile(Guid id)
        {
            var applicationBranchesIds = _commonDataService
                                         .GetEntity <ApplicationBranch>(x => x.LimsDocumentId == id && x.RecordState != RecordState.D)
                                         .Select(x => x.BranchId)
                                         .Distinct()
                                         .ToList();
            var applicationEdocumentBranches =
                _commonDataService.GetEntity <BranchEDocument>(x => applicationBranchesIds.Contains(x.BranchId) && x.RecordState != RecordState.D);
            var applicationEdocumentIds = applicationEdocumentBranches.Select(x => x.EDocumentId).Distinct().ToList();
            var applicationEdocuments   = _commonDataService
                                          .GetEntity <EDocument>(x => applicationEdocumentIds.Contains(x.Id) && x.RecordState != RecordState.D).ToList();
            var listEDocJson = new List <EDocumentMD5Model>();

            foreach (var applicationEdocument in applicationEdocuments)
            {
                var fileStore = _commonDataService
                                .GetEntity <FileStore>(x => x.EntityName == "EDocument" && x.EntityId == applicationEdocument.Id && x.RecordState != RecordState.D)
                                .ToList();
                try
                {
                    foreach (var file in fileStore)
                    {
                        var dto = (await _commonDataService.GetDtoAsync <FileStoreDTO>(x => x.Id == file.Id)).FirstOrDefault();
                        // С новым кором переделать FileStoreDTO
                        var dtoCore = new Core.Data.DTO.Common.FileStoreDTO();
                        _objectMapper.Map(dto, dtoCore);
                        if (FileStoreHelper.LoadFile(dtoCore, out var stream, out var contentType))
                        {
                            var plainTextBytes = Encoding.UTF8.GetBytes(dto?.OrigFileName);
                            var base64Name     = Convert.ToBase64String(plainTextBytes);
                            listEDocJson.Add(new EDocumentMD5Model()
                            {
                                Id = file.Id, Name = base64Name, File = FileSignHelper.CalculateMd5(stream)
                            });
                        }
                        else
                        {
                            throw new Exception();
                        }
                    }
                }