Пример #1
0
        public Guid CreateArchivesManagerActive(string instaceId)
        {
            var projectId = instaceId.ToGuid();
            var data      = new CreateOrUpdateArchivesManagerInput();

            data.Id = Guid.NewGuid();
            var files = from f in _projectFileRepository.GetAll()
                        join filetype in _aappraisalFileTypeRepository.GetAll() on f.AappraisalFileType equals filetype.Id
                        where f.SingleProjectId == projectId
                        select new { f.Id, f.FileName, f.FilePath, f.IsPaperFile, filetype.Name, f.PaperFileNumber };

            var projectModel = _singleProjectInfoRepository.Get(projectId);

            data.ProjectId = projectModel.Id;
            foreach (var file in files)
            {
                //if(string.IsNullOrWhiteSpace(file.FileName))
                //    continue;
                var entity = new CreateOrUpdateArchivesFileInput()
                {
                    FileName = file.FileName, Id = file.Id, FileType = file.Name, IsPaper = file.IsPaperFile, PaperNumber = file.PaperFileNumber
                };
                if (!string.IsNullOrWhiteSpace(file.FileName))
                {
                    entity.Files = Newtonsoft.Json.JsonConvert.DeserializeObject <List <FileUploadFiles> >(file.FileName);
                }
                data.Files.Add(entity);
            }

            var archivesManager = new ArchivesManager();

            archivesManager.Id           = data.Id.Value;
            archivesManager.ArchivesName = projectModel.SingleProjectName + "-归档";
            archivesManager.ProjectId    = data.ProjectId;
            _archivesManagerRepository.InsertAsync(archivesManager);

            foreach (var file in data.Files)
            {
                var entity = new ArchivesFile();
                file.Id         = Guid.NewGuid();
                file.ArchivesId = archivesManager.Id;
                file.MapTo(entity);
                _archivesFileRepository.Insert(entity);
            }
            return(archivesManager.Id);
        }
Пример #2
0
        protected virtual async Task CreateArchivesManagerAsync(CreateOrUpdateArchivesManagerInput input)
        {
            var archivesManager = new ArchivesManager();

            input.MapTo(archivesManager);
            var id = Guid.NewGuid();

            archivesManager.Id = id;
            await _archivesManagerRepository.InsertAsync(archivesManager);

            foreach (var file in input.Files)
            {
                var entity = new ArchivesFile();
                file.Id         = Guid.NewGuid();
                file.ArchivesId = id;
                file.MapTo(entity);
                await _archivesFileRepository.InsertAsync(entity);
            }
            await CurrentUnitOfWork.SaveChangesAsync();
        }