Esempio n. 1
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);
        }
        /// <summary>
        /// Install the "TriTech Default" Templates into the Agency
        /// </summary>
        private static void UpdateTriTechDefaultTemplatesInAgency(Domain.Administration.Aggregates.Agency.Agency agency,
                                                                  IAdministrationUnitOfWork admin, IMetadataUnitOfWork meta)
        {
            Log.Info("Processing TriTech Default Templates for {0}", agency.Jurisdiction.Ori);

            // Create a Template Manager Service Instance
            var templateManager = new TemplateManagementService(admin, meta);

            // Create or Update the TriTech Default Template for all Modules.
            foreach (var dataEntryContract in meta.GetAllDataEntryContracts())
            {
                // Get the "TriTech Default" Template Name
                var defaultTemplateName = DataEntryContractInspector.GetContractNameForModule(dataEntryContract.ModuleType);

                // Find or Create the Default Template
                var triTechDefaultTemplate = agency.GetTemplate(dataEntryContract.ModuleType, defaultTemplateName);
                if (triTechDefaultTemplate == null)
                {
                    Log.Info("Installing {0}", defaultTemplateName);

                    // Create the TriTech Default Template.
                    triTechDefaultTemplate = agency.CreateTemplate(dataEntryContract.Id, dataEntryContract.ModuleType, defaultTemplateName);

                    // Set the Template Workflow [Until the Concept of a "Default" workflow is defined this is the best we can do.]
                    triTechDefaultTemplate.SetWorkflow(agency.Workflows.First());

                    // Assign all roles to the Template
                    agency.Roles.ForEach(x => triTechDefaultTemplate.AssignRole(x));
                }
                else
                {
                    Log.Info("Updating {0} ", defaultTemplateName);
                }

                // Reset the Template Layout
                templateManager.ResetTemplateLayout(triTechDefaultTemplate);

                // Load the Template Layout from the Metadata
                templateManager.LoadFromMeta(triTechDefaultTemplate, dataEntryContract);
            }
        }