/// <summary> /// Deserializza una struttura JSON di tipo UDSWorkflowModel recuperata da Workflow (property). /// </summary> /// <returns>oggetto UDSDto</returns> public UDSDto ReadUDSWorkflowJson(string udsWorkflowJson, Data.Entity.UDS.UDSRepository repository) { if (string.IsNullOrEmpty(udsWorkflowJson)) { throw new ArgumentNullException("udsWorkflowJson"); } if (repository == null) { throw new ArgumentNullException("repository"); } UDSModel udsModel = UDSModel.LoadXml(repository.ModuleXML); UDSWorkflowModel model = JsonConvert.DeserializeObject <UDSWorkflowModel>(udsWorkflowJson, DocSuiteContext.DefaultWebAPIJsonSerializerSettings); UDSModelField udsField; foreach (Section metadata in udsModel.Model.Metadata) { foreach (FieldBaseType item in metadata.Items) { udsField = new UDSModelField(item); foreach (KeyValuePair <string, string> data in model.DynamicDatas) { if (data.Key.Eq(udsField.ColumnName)) { udsField.Value = data.Value; } } } } if (udsModel.Model.Contacts != null && model.Contact != null) { //todo: sarà sempre e solo un singolo contatto? Contacts contact = udsModel.Model.Contacts.FirstOrDefault(); if (model.Contact.HasId()) { ContactInstance newInstance = new ContactInstance() { IdContact = model.Contact.Id.Value }; contact.ContactInstances = (contact.ContactInstances ?? Enumerable.Empty <ContactInstance>()).Concat(new ContactInstance[] { newInstance }).ToArray(); } else if (!string.IsNullOrEmpty(model.Contact.Description)) { ContactManualInstance newManualInstance = new ContactManualInstance() { ContactDescription = model.Contact.Description }; contact.ContactManualInstances = (contact.ContactManualInstances ?? Enumerable.Empty <ContactManualInstance>()).Concat(new ContactManualInstance[] { newManualInstance }).ToArray(); } } UDSDto udsDto = new UDSDto() { UDSModel = udsModel }; return(udsDto); }
/// <summary> /// Deserializza una struttura JSON dinamica recuperata da WebAPI. /// </summary> /// <returns>oggetto UDSDto</returns> public UDSDto ReadUDSJson(string udsJson, Data.Entity.UDS.UDSRepository repository) { if (string.IsNullOrEmpty(udsJson)) { throw new ArgumentNullException("udsJson"); } if (repository == null) { throw new ArgumentNullException("repository"); } UDSModel udsModel = UDSModel.LoadXml(repository.ModuleXML); string jsonParsed = ParseJson(udsJson); UDSEntityDto entityDto = JsonConvert.DeserializeObject <IList <UDSEntityDto> >(jsonParsed, DocSuiteContext.DefaultUDSJsonSerializerSettings).FirstOrDefault(); if (entityDto == null) { return(null); } FillBaseData(entityDto, udsModel); FillMetadata(jsonParsed, udsModel); FillDocuments(entityDto, udsModel); FillContacts(entityDto, udsModel); FillAuthorization(entityDto, udsModel); FillMessages(entityDto, udsModel); FillPECMails(entityDto, udsModel); FillProtocols(entityDto, udsModel); FillCollaborations(entityDto, udsModel); UDSDto dto = new UDSDto() { Id = entityDto.Id.Value, Year = entityDto.Year.Value, Number = entityDto.Number.Value, Status = entityDto.Status, CancelMotivation = entityDto.CancelMotivation, RegistrationDate = entityDto.RegistrationDate.Value, RegistrationUser = entityDto.RegistrationUser, LastChangedDate = entityDto.LastChangedDate, LastChangedUser = entityDto.LastChangedUser, Subject = entityDto.Subject, Category = entityDto.Category, UDSRepository = entityDto.UDSRepository, Authorizations = entityDto.Authorizations, Contacts = entityDto.Contacts, Documents = entityDto.Documents, Messages = entityDto.Messages, PecMails = entityDto.PecMails, Collaborations = entityDto.Collaborations, DocumentUnits = entityDto.DocumentUnits, UDSModel = udsModel }; return(dto); }
public UDSRelationFacade(string xml, string xmlSchema, string dbSchema = "dbo") { bool validate = UDSModel.ValidateXml(xml, xmlSchema, out List <string> validationErrors); if (!validate) { throw new UDSRelationException(string.Format("UDSRelationFacade - Errori di validazione Xml: {0}", string.Join("\n", validationErrors))); } _uds = UDSModel.LoadXml(xml); _builder = new UDSTableBuilder(UDS, dbSchema); }
public UDSStorageFacade(ILogger logger, string xml, string xmlSchema, BiblosDS.BiblosDSManagement.AdministrationClient administrationClient, string dbSchema = "") { _logger = logger; bool validate = UDSModel.ValidateXml(xml, xmlSchema, out List <string> validationErrors); if (!validate) { throw new UDSStorageException(string.Format("UDSStorageFacade - Errore di validazione: {0}", string.Join("\n", validationErrors))); } _udsModel = UDSModel.LoadXml(xml); _udsTableBuilder = new UDSTableBuilder(_udsModel, dbSchema); _administrationClient = administrationClient; }
public DocumentInfo GetDocumentUnitChainsDocuments(ICollection <DocumentUnitChain> documentUnitChains, IDictionary <Model.Entities.DocumentUnits.ChainType, string> seriesCaptionLabel, bool?forceAuthorization = null) { if (documentUnitChains != null && documentUnitChains.Count > 0) { DocumentUnit documentUnit = documentUnitChains.First().DocumentUnit; FolderInfo mainFolder = new FolderInfo { Name = $"{documentUnit.DocumentUnitName} {documentUnit.Title}", ID = documentUnit.UniqueId.ToString() }; FolderInfo folderDoc; BiblosDocumentInfo[] docs; string folderName; foreach (DocumentUnitChain chain in documentUnitChains.Where(f => f.ChainType <= ChainType.UnpublishedAnnexedChain || f.ChainType == ChainType.DematerialisationChain).OrderBy(x => x.ChainType)) { docs = null; folderDoc = new FolderInfo { Parent = mainFolder }; folderName = string.Empty; switch (chain.ChainType) { case ChainType.MainChain: { folderName = "Documento"; if (documentUnit.Environment == (int)Data.DSWEnvironment.DocumentSeries && seriesCaptionLabel.ContainsKey(Model.Entities.DocumentUnits.ChainType.MainChain)) { folderName = seriesCaptionLabel[Model.Entities.DocumentUnits.ChainType.MainChain]; } folderDoc.Name = folderName; break; } case ChainType.AttachmentsChain: { folderDoc.Name = "Allegati (parte integrante)"; break; } case ChainType.AnnexedChain: { folderName = "Annessi (non parte integrante)"; if (documentUnit.Environment == (int)Data.DSWEnvironment.DocumentSeries && seriesCaptionLabel.ContainsKey(Model.Entities.DocumentUnits.ChainType.AnnexedChain)) { folderName = seriesCaptionLabel[Model.Entities.DocumentUnits.ChainType.AnnexedChain]; } folderDoc.Name = folderName; break; } case ChainType.UnpublishedAnnexedChain: { folderName = "Annessi non pubblicati"; if (documentUnit.Environment == (int)Data.DSWEnvironment.DocumentSeries && seriesCaptionLabel.ContainsKey(Model.Entities.DocumentUnits.ChainType.UnpublishedAnnexedChain)) { folderName = seriesCaptionLabel[Model.Entities.DocumentUnits.ChainType.UnpublishedAnnexedChain]; } folderDoc.Name = folderName; break; } case ChainType.DematerialisationChain: { folderDoc.Name = "Attestazione di conformità "; break; } default: break; } docs = BiblosDocumentInfo.GetDocuments(chain.IdArchiveChain).ToArray(); if (docs != null) { //TODO: attributi da non salvare in Biblos foreach (BiblosDocumentInfo doc in docs) { doc.AddAttribute(BIBLOS_ATTRIBUTE_Environment, documentUnit.Environment.ToString()); doc.AddAttribute(BIBLOS_ATTRIBUTE_Year, documentUnit.Year.ToString()); doc.AddAttribute(BIBLOS_ATTRIBUTE_Number, documentUnit.Number.ToString()); doc.AddAttribute(BIBLOS_ATTRIBUTE_UniqueId, documentUnit.UniqueId.ToString()); if (chain.DocumentUnit != null && chain.DocumentUnit.UDSRepository != null) { UDSModel model = UDSModel.LoadXml(chain.DocumentUnit.UDSRepository.ModuleXML); if (!model.Model.StampaConformeEnabled) { doc.AddAttribute(BIBLOS_ATTRIBUTE_Disabled, bool.TrueString); } } if (forceAuthorization.HasValue && forceAuthorization.Value) { doc.AddAttribute(BIBLOS_ATTRIBUTE_UserVisibilityAuthorized, bool.TrueString); } } folderDoc.AddChildren(docs); } } return(mainFolder); } return(null); }