Exemplo n.º 1
0
        /// <summary>
        /// Get the Layout information for a specific template in the System.
        /// </summary>
        /// <param name="templateId">Id of the template extract the layout information from..</param>
        /// <param name="implementation">
        ///     Implementation to inject in the layout.
        ///     This is required until the system becomes aware of its implementation.
        /// </param>
        public TemplateLayout GetTemplateLayout(Guid templateId, string implementation)
        {
            // Load the Template
            var template = _admin.GetTemplate(templateId);

            if (template == null)
            {
                throw new Exception("The specified template[" + templateId + "] could not be found in the system.");
            }

            // Load the Metadata
            var dataEntryContract = _meta.GetDataEntryContract(template.DataEntryContractId);

            if (dataEntryContract == null)
            {
                throw new Exception("The metadata[" + template.DataEntryContractId + "] for template[" + template.Name + "] could not be found in the system.");
            }

            return(GetTemplateLayout(template, dataEntryContract, implementation));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update all the Metadata in the system for the specified implementation.
        /// </summary>
        public void UpdateMetadata(string implementation)
        {
            // The DTO types to extract Metadata From
            var dtoTypes = MetadataInfo.DataEntryDtoTypes;

            // Track the contracts we encounter so we can load Implemenataion Metadata
            var dataentryContracts = new List <DataEntryContract>();

            // Process all DTO Types
            foreach (var dtoType in dtoTypes)
            {
                // Generate the Latest Metadata
                var generatedContractInfo = DataEntryContractInspector.GetContractInfo(dtoType, implementation);

                if (generatedContractInfo == null)
                {
                    throw new Exception("DataEntryContractInspector.GetContractInfo returned null");
                }

                // Check if any meta already exists for the module.
                var dataEntryContract = _metadataUnitOfWork.GetDataEntryContract(generatedContractInfo.ModuleType);
                if (dataEntryContract == null)
                {
                    // If no Metadata exists for the Module create it.
                    _log.Info("Generating Metadata for " + generatedContractInfo.ModuleType);
                    dataentryContracts.Add(_metadataUnitOfWork.Add(generatedContractInfo));
                }
                else
                {
                    // Otherwise Update the Existing Metadata
                    _log.Info("Updating Metadata for " + generatedContractInfo.ModuleType);
                    UpdateMetadata(generatedContractInfo, dataEntryContract);
                    dataentryContracts.Add(dataEntryContract);
                }
            }

            // Implementation Metadata Loader
            var loader = new ExtendedFieldsMetadataLoader(MetadataInfo.MetadataFolder, implementation);

            // Update the metadata about ancillary fields.
            loader.LoadInto(dataentryContracts);
        }