/// <summary> /// Update All TriTech Default Templates in the System /// </summary> public static void UpdateAllAgencies() { // Get the list of Agencies in the System. List <Guid> agencyIds; using (var admin = new AdministrationDbContext()) agencyIds = admin.GetEntityQuery <Domain.Administration.Aggregates.Agency.Agency>() .Select(x => x.Id) .ToList(); // We can use the same Metadata Context because we are only reading data. using (var meta = new MetadataDbContext()) { foreach (var agencyId in agencyIds) { // Distribute the work so we do not pay the performance price // of tracking too many entities at the same time. // This is important in systems that have a lot of Agencies. using (var admin = new AdministrationDbContext()) { // Load the Agency var agency = admin.GetAgency(agencyId); // Update the Templates UpdateTriTechDefaultTemplatesInAgency(agency, admin, meta); // Commit the Work admin.Commit(); } } } }
/// <summary> /// Installs the TriTech Default Templates into a specific Agency. /// </summary> public static void Install(Guid agencyId) { using (var admin = new AdministrationDbContext()) using (var meta = new MetadataDbContext()) { var agency = admin.GetAgency(agencyId); if (agency == null) { throw new Exception("Unable to Find Agency [" + agencyId + "]"); } UpdateTriTechDefaultTemplatesInAgency(agency, admin, meta); // Commit the Work admin.Commit(); } }
/// <summary> /// Install the "Implementation Default" Templates in a Specific Agency. /// </summary> /// <param name="agencyId">Id of the Agency to setup templates in.</param> /// <param name="implementation">Implementation of the Templates to Install.</param> public static void Install(Guid agencyId, string implementation) { using (var meta = new MetadataDbContext()) using (var admin = new AdministrationDbContext()) { var agency = admin.GetAgency(agencyId); if (agency == null) { throw new Exception("Agency [" + agencyId + "] not found."); } // Install or Update Templates InstallOrUpdateTemplatesInAgency(agency, implementation, admin, meta); // Commit the Work admin.Commit(); } }