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); }
//A partire dal modello Uds crea un modello di default JSon public JsModel ConvertToJs(UDSModel uds) { UnitaDocumentariaSpecifica model = uds.Model; //title List <Element> elements = new List <Element>(); Element titleElement = new Element { ctrlType = ctlTitle, label = model.Title, readOnly = false, searchable = true, modifyEnable = model.Subject.ModifyEnabled, subject = model.Subject.DefaultValue, clientId = "SubjectId", enabledWorkflow = model.WorkflowEnabled, enabledProtocol = model.ProtocolEnabled, enabledPEC = model.PECEnabled, enabledPECButton = model.PECButtonEnabled, enabledMailButton = model.MailButtonEnabled, enabledMailRoleButton = model.MailRoleButtonEnabled, enabledLinkButton = model.LinkButtonEnabled, enabledCQRSSync = model.DocumentUnitSynchronizeEnabled, alias = model.Alias, enabledCancelMotivation = model.CancelMotivationRequired, incrementalIdentityEnabled = model.IncrementalIdentityEnabled, subjectResultVisibility = model.Subject.ResultVisibility, hideRegistrationIdentifier = model.HideRegistrationIdentifier, stampaConformeEnabled = model.StampaConformeEnabled, showArchiveInProtocolSummaryEnabled = model.ShowArchiveInProtocolSummaryEnabled, requiredRevisionUDSRepository = model.RequiredRevisionUDSRepository, showLastChangedDate = model.ShowLastChangedDate, showLastChangedUser = model.ShowLastChangedUser }; if (model.Category != null) { titleElement.idCategory = model.Category.IdCategory; titleElement.categoryReadOnly = model.Category.ReadOnly; titleElement.categorySearchable = model.Category.Searchable; titleElement.categoryDefaultEnabled = model.Category.DefaultEnabled; titleElement.categoryResultVisibility = model.Category.ResultVisibility; } if (model.Container != null) { titleElement.idContainer = model.Container.IdContainer; titleElement.containerSearchable = model.Container.Searchable; titleElement.createContainer = model.Container.CreateContainer; } elements.Add(titleElement); //sections if (model.Metadata != null) { foreach (Section section in model.Metadata) { if (section.SectionLabel != SectionManager.DefaultSectionName) { elements.Add(new Element { ctrlType = ctlHeader, label = section.SectionLabel }); } if (section.Items != null) { foreach (FieldBaseType field in section.Items) { Element element = CreateFieldElement(field); if (element != null) { if (element.clientId == "0" || string.IsNullOrEmpty(element.clientId)) { element.clientId = string.Concat("uds_", element.columnName, "_", elements.Count()); } elements.Add(element); } } } } } //documents if (model.Documents != null && model.Documents.Document != null) { elements.Add(CreateDocumentElement(model.Documents.Document, collectionDocument)); } if (model.Documents != null && model.Documents.DocumentAnnexed != null) { elements.Add(CreateDocumentElement(model.Documents.DocumentAnnexed, collectionAnnexed)); } if (model.Documents != null && model.Documents.DocumentAttachment != null) { elements.Add(CreateDocumentElement(model.Documents.DocumentAttachment, collectionAttachment)); } //contacts if (model.Contacts != null) { foreach (Contacts contact in model.Contacts) { elements.Add(CreateContactElement(contact)); } } //authorizations if (model.Authorizations != null) { elements.Add(CreateAuthorizationsElement(model.Authorizations)); } return(new JsModel { elements = elements.ToArray() }); }