Пример #1
0
        /// <summary>
        /// Load the Layout Information to an Existing Template Instance.
        /// </summary>
        /// <param name="layout">The Layout Information to apply.</param>
        /// <param name="template">The Template Instance to apply the layout to.</param>
        /// <param name="dataEntryContract">Local Metadata for the Template.</param>
        private void LoadLayout(TemplateLayout layout, Template template, DataEntryContract dataEntryContract)
        {
            // Load the Template Information
            template.Description       = layout.Description;
            template.IsSupplement      = layout.IsSupplement;
            template.ValidationEnabled = layout.ValidationEnabled;

            // Apply the Section Layouts
            foreach (var sectionLayout in layout.Sections)
            {
                // Lookup the Section Information
                var sectionMetadata = dataEntryContract.GetSection(sectionLayout.DataEntrySectionName);
                var section         = template.GetSection(sectionMetadata.Id);

                // If the Section does not exist in the Template, create a new section
                // using the layout information and add it to the Template.
                if (section == null)
                {
                    // Create a new section using the layout
                    section = template.CreateSection(sectionMetadata.Id, sectionLayout.Label);
                    template.Sections.Add(section);
                }

                // Apply the Layout to the Section
                ApplySectionLayout(sectionLayout, section, sectionMetadata);
            }
        }
Пример #2
0
        /// <summary>
        /// Get the Layout information for a supplied Template and Metadata.
        /// The Metadata is used to lookup identifier information.
        /// </summary>
        private TemplateLayout GetTemplateLayout(Template template, DataEntryContract dataEntryContract, string implementation)
        {
            // Create the Template Layout
            // This information can be used to create a new Template in a Different System that structurally matches the original.
            var templateLayout =
                new TemplateLayout()
            {
                ApiVersion        = template.ApiVersion,
                Description       = template.Description,
                Implementation    = implementation,
                IsSupplement      = template.IsSupplement,
                ModuleType        = template.ModuleType,
                Name              = template.Name,
                Sections          = new List <SectionLayout>(),
                ValidationEnabled = template.ValidationEnabled,
                IsDefault         = false // This Value is not part of the actual Layout. This is a placeholder for data that is managed elsewhere.
            };

            // Create Scaffolding for Each Section
            foreach (var section in template.Sections)
            {
                // Get the Section Metadata
                var dataEntrySection = dataEntryContract.GetSection(section.DataEntrySectionId);
                templateLayout.Sections.Add(GetSectionLayout(section, dataEntrySection));
            }

            return(templateLayout);
        }