public void UpdateAwardBatch(Objects.AwardBatch awardBatch) { try { DbProvider.UpdateAwardBatch(awardBatch); } catch (Exception ex) { logger.Error(ex); throw ex; } }
public Objects.AwardBatch GetAwardBatch(Guid idAwardBatch) { logger.Info("GetAwardBatch - entry point"); try { Objects.AwardBatch ret = DbProvider.GetAwardBatch(idAwardBatch); logger.Info("GetAwardBatch - ritorno al chiamante"); return(ret); } catch (Exception ex) { logger.Error(ex); throw ex; } }
public void CloseAwardBatch(Objects.AwardBatch awardBatch) { try { if (!awardBatch.IsOpen) { logger.WarnFormat("Il pacchetto di conservazione con Id {0} risulta già chiuso", awardBatch.IdAwardBatch); return; } DbProvider.CloseAwardBatch(awardBatch.IdAwardBatch); } catch (Exception ex) { logger.Error(ex); throw; } }
public string CreateAwardBatchPDVXml(Objects.AwardBatch awardBatch, Objects.Preservation preservation) { try { Ipda ipda = new Ipda() { descGenerale = new DescGenerale() { id = awardBatch.Name, applicazione = new DescApplicazione() { nome = "Biblos Document Server", produttore = "Dgroove Srl", versione = "2015.0" } }, pda = new Pda() { extraInfo = new PdaExtraInfo() { metadati = new PdaMetadati() } } }; List <PdaAttributo> attrList = DbProvider.GetAttributeByPreservationPosition(awardBatch.IdArchive).Select(p => new PdaAttributo { nome = p.Description }).ToList(); attrList.Insert(0, new PdaAttributo() { nome = "NomeFile" }); attrList.Insert(1, new PdaAttributo() { nome = "DataVersamento" }); attrList.Add(new PdaAttributo() { nome = "ImprontaSHA" }); ipda.pda.extraInfo.metadati.attributoList = attrList.ToArray(); //TODO: Completamente da rivedere. Creare dei service specifici per creare e leggere i documenti da file system senza la necessità di chiamare ogni volta il WCFHost. List <FileGruppoFile> files = new List <FileGruppoFile>(); BindingList <Document> documents = DbProvider.GetAwardBatchDocuments(awardBatch.IdAwardBatch); List <DocumentAttribute> attributes = DbProvider.GetAttributesFromArchive(awardBatch.IdArchive).Where(x => !x.ConservationPosition.HasValue || x.ConservationPosition.Value > 0).OrderBy(x => x.ConservationPosition).ToList(); byte[] documentContent; string documentHash; BiblosStorageService.StorageService storageService = new BiblosStorageService.StorageService(); foreach (Document document in documents) { documentContent = null; documentHash = null; if (preservation != null && preservation.Documents != null) { Document currentDocument = preservation.Documents.SingleOrDefault(x => x.IdDocument == document.IdDocument); if (currentDocument != null) { documentHash = currentDocument.DocumentHash; } } if (string.IsNullOrEmpty(documentHash)) { DocumentContent currentDocumentContent = storageService.GetDocumentContent(document); documentContent = currentDocumentContent.Blob; documentHash = UtilityService.GetHash(documentContent, true); } document.AttributeValues = DbProvider.GetFullDocumentAttributeValues(document.IdDocument); List <FgAttributo> docAttrList = new List <FgAttributo>(); foreach (var attr in attributes) { FgAttributo fgAttr = new FgAttributo(); var currAttributeValue = document.AttributeValues.Where(x => x.IdAttribute == attr.IdAttribute).FirstOrDefault(); if (currAttributeValue == null) { continue; } if (currAttributeValue.Attribute == null) { currAttributeValue.Attribute = attr; } fgAttr.nome = string.IsNullOrEmpty(attr.Description) ? attr.Name : attr.Description; //L'attributo va formattato in funzione della proprieta' "Format" dell'Attributo, se valorizzata. string valoreAttr; if (currAttributeValue.Attribute != null && !string.IsNullOrEmpty(currAttributeValue.Attribute.Format)) { try { valoreAttr = string.Format(currAttributeValue.Attribute.Format, currAttributeValue.Value); } catch (Exception ex) { logger.Error(ex); valoreAttr = string.Empty; } } else { valoreAttr = (currAttributeValue.Value != null) ? currAttributeValue.Value.ToString() : string.Empty; } fgAttr.valore = valoreAttr; docAttrList.Add(fgAttr); } docAttrList.Insert(0, new FgAttributo() { nome = "NomeFile", valore = document.Name }); docAttrList.Insert(1, new FgAttributo() { nome = "DataVersamento", valore = document.DateMain.Value.ToString("dd/MM/yyyy") }); docAttrList.Add(new FgAttributo() { nome = "ImprontaSHA", valore = documentHash }); files.Add(new FileGruppoFile() { id = document.Name, impronta = documentHash, extraInfo = new FgExtraInfo() { metadati = new FgMetadati() { attributoList = docAttrList.ToArray() } } }); } ipda.fileGruppo = new FileGruppo() { files = files.ToArray() }; return(XmlFile <Ipda> .Serialize(ipda)); } catch (Exception ex) { logger.Error(ex.Message, ex); throw; } }
public string CreateAwardBatchPDVXml(Objects.AwardBatch awardBatch) { return(CreateAwardBatchPDVXml(awardBatch, null)); }