public string JsToXml(JsModel jsModel, out List <String> errors) { errors = new List <String>(); UDSModel uds = ConvertFromJson(jsModel); if (!uds.Model.Metadata.SelectMany(f => f.Items).Any()) { errors.Add("E' necessario specificare almeno un metadato dell'archivio."); } return(uds.SerializeToXml()); }
public UDSModel ConvertFromJson(JsModel jsonModel) { if (jsonModel.elements == null) { return(null); } Dictionary <string, Func <Element, bool> > parseDict = GetElementParserDict(); foreach (Element el in jsonModel.elements) { if (!parseDict.ContainsKey(el.ctrlType)) { continue; } parseDict[el.ctrlType](el); } UDSModel uds = new UDSModel(); UnitaDocumentariaSpecifica model = uds.Model; category.ClientId = "CategoryId"; category.Label = "Classificatore"; container.ClientId = "ContainerId"; container.Label = "Contenitore"; container.CreateContainer = createContainer; subjectType.DefaultValue = subject; subjectType.ClientId = "SubjectId"; subjectType.Label = "Oggetto"; subjectType.ResultVisibility = resultVisibility; model.Title = title; model.Category = category; model.Container = container; model.Subject = subjectType; model.Subject.ModifyEnabled = modifyEnabled; model.WorkflowEnabled = enabledWorkflow; model.ProtocolEnabled = enabledProtocol; model.PECEnabled = enabledPEC; model.PECButtonEnabled = enabledPECButton; model.MailButtonEnabled = enabledMailButton; model.MailRoleButtonEnabled = enabledMailRoleButton; model.LinkButtonEnabled = enabledLinkButton; model.DocumentUnitSynchronizeEnabled = enabledCQRSSync; model.IncrementalIdentityEnabled = incrementalIdentityEnabled; model.Alias = alias; model.CancelMotivationRequired = enabledCancelMotivation; model.HideRegistrationIdentifier = hideRegistrationIdentifier; model.StampaConformeEnabled = stampaConformeEnabled; model.ShowArchiveInProtocolSummaryEnabled = showArchiveInProtocolSummaryEnabled; model.RequiredRevisionUDSRepository = requiredRevisionUDSRepository; model.ShowLastChangedDate = showLastChangedDate; model.ShowLastChangedUser = showLastChangedUser; model.Contacts = contacts.ToArray(); model.Documents = new Documents(); if (documents.Count() > 0) { Document doc = null; if (documents.TryGetValue(collectionDocument, out doc)) { doc.ClientId = string.Concat("uds_doc_main_0"); model.Documents.Document = doc; } if (documents.TryGetValue(collectionAnnexed, out doc)) { doc.ClientId = string.Concat("uds_doc_annexed_1"); model.Documents.DocumentAnnexed = doc; } if (documents.TryGetValue(collectionAttachment, out doc)) { doc.ClientId = string.Concat("uds_doc_attachment_1"); model.Documents.DocumentAttachment = doc; } } model.Authorizations = authorizations; model.Metadata = sections.GetSections(); return(uds); }