Ejemplo n.º 1
0
        public async Task <IHttpActionResult> GetBiblosDocuments(Guid uniqueId, Guid?workflowArchiveChainId)
        {
            return(await ActionHelper.TryCatchWithLoggerGeneric(async() =>
            {
                DocumentUnit documentUnit = _unitOfWork.Repository <DocumentUnit>().GetById(uniqueId).SingleOrDefault();

                if (documentUnit == null)
                {
                    throw new ArgumentNullException("Document unit not found");
                }

                IList <DocumentModel> documents = new List <DocumentModel>();
                foreach (DocumentUnitChain documentUnitChain in documentUnit.DocumentUnitChains)
                {
                    foreach (ModelDocument.Document item in await _documentService.GetDocumentsFromChainAsync(documentUnitChain.IdArchiveChain))
                    {
                        documents.Add(new DocumentModel
                        {
                            DocumentId = item.IdDocument,
                            FileName = item.Name,
                            ChainType = (DocSuiteWeb.Model.Entities.DocumentUnits.ChainType)documentUnitChain.ChainType,
                            ChainId = item.IdChain.Value,
                            ArchiveSection = documentUnitChain.DocumentLabel
                        });
                    }
                }
                if (workflowArchiveChainId.HasValue)
                {
                    foreach (ModelDocument.Document item in await _documentService.GetDocumentsFromChainAsync(workflowArchiveChainId.Value))
                    {
                        documents.Add(new DocumentModel
                        {
                            ChainType = (DocSuiteWeb.Model.Entities.DocumentUnits.ChainType)ChainType.Miscellanea,
                            DocumentId = item.IdDocument,
                            FileName = item.Name,
                            ChainId = workflowArchiveChainId.Value,
                            ArchiveSection = "Miscellanea"
                        });
                    }
                }
                return Ok(documents.AsQueryable());
            }, _logger, LogCategories));
        }
Ejemplo n.º 2
0
        public async Task <IHttpActionResult> GetFascicleFlatDocuments(Guid uniqueId)
        {
            return(await ActionHelper.TryCatchWithLoggerGeneric(async() =>
            {
                FascicleFolder internetFolder = _unitOfWork.Repository <FascicleFolder>().GetInternetFolderByFascicle(uniqueId).SingleOrDefault();
                if (internetFolder == null)
                {
                    return Ok(new List <FascicleModel>()
                    {
                    }.AsQueryable());
                }

                ICollection <FascicleDocument> miscellaneas = _unitOfWork.Repository <FascicleDocument>().GetByIdFascicleFolder(internetFolder.UniqueId, true).ToList();
                ICollection <FascicleDocumentUnit> documentUnits = _unitOfWork.Repository <FascicleDocumentUnit>().GetByIdFascicleFolder(internetFolder.UniqueId, true).ToList();
                ICollection <DocumentUnitChain> documentUnitChains = documentUnits.SelectMany(s => _unitOfWork.Repository <DocumentUnitChain>().GetByDocumentUnit(s.DocumentUnit, true)).ToList();
                ICollection <Guid> chains = miscellaneas.Select(s => s.IdArchiveChain).Union(documentUnitChains.Select(s => s.IdArchiveChain)).ToList();

                FascicleModel model = _mapper.Map <Fascicle, FascicleModel>(internetFolder.Fascicle);
                IList <DocumentModel> documents = new List <DocumentModel>();
                ICollection <ModelDocument.Document> biblosDocuments;
                foreach (Guid archiveChain in chains)
                {
                    biblosDocuments = await _documentService.GetDocumentsFromChainAsync(archiveChain);
                    foreach (ModelDocument.Document biblosDocument in biblosDocuments)
                    {
                        documents.Add(new DocumentModel(biblosDocument.IdDocument, biblosDocument.Name)
                        {
                            DocumentType = DocumentType.Miscellanea,
                            ChainId = biblosDocument.IdChain.Value
                        });
                    }
                }

                model.Documents = documents;

                return Ok(new List <FascicleModel>()
                {
                    model
                }.AsQueryable());
            }, _logger, LogCategories));
        }
Ejemplo n.º 3
0
        public async Task <IHttpActionResult> GetProtocolDocuments(Guid uniqueId)
        {
            return(await ActionHelper.TryCatchWithLoggerGeneric(async() =>
            {
                DocumentUnit documentUnit = _unitOfWork.Repository <DocumentUnit>().GetByNumbering(uniqueId, (int)DSWEnvironmentType.Protocol).SingleOrDefault();
                if (documentUnit == null)
                {
                    throw new ArgumentNullException("Protocol not found");
                }
                ProtocolModel model = _mapper.Map <Protocol, ProtocolModel>(new Protocol()
                {
                    UniqueId = uniqueId,
                    Year = documentUnit.Year,
                    Number = documentUnit.Number,
                    Object = documentUnit.Subject,
                    Category = new Category(),
                    Container = new Container()
                });

                foreach (DocumentUnitChain documentUnitChain in documentUnit.DocumentUnitChains)
                {
                    foreach (ModelDocument.Document item in await _documentService.GetDocumentsFromChainAsync(documentUnitChain.IdArchiveChain))
                    {
                        model.Documents.Add(new DocumentModel(item.IdDocument, item.Name)
                        {
                            DocumentType = documentUnitChain.ChainType == ChainType.MainChain ? DocumentType.Main : documentUnitChain.ChainType == ChainType.AttachmentsChain ? DocumentType.Attachment : DocumentType.Annexed,
                            ChainId = item.IdChain.Value
                        });
                    }
                }
                return Ok(new List <ProtocolModel>()
                {
                    model
                }.AsQueryable());
            }, _logger, LogCategories));
        }