예제 #1
0
        /// <summary>
        /// Install a New Agency
        /// </summary>
        /// <param name="implementation">The "State" Implementation relevant to the Agency.</param>
        /// <param name="name">Name of the Agency</param>
        /// <param name="ori">Federal Identifier for the Agency</param>
        /// <param name="classicRmsConnectionString">Connection string to the Classic RMS Database.</param>
        public static Guid Create(string implementation, string name, string ori, string classicRmsConnectionString)
        {
            Log.Info("Creating Agency: " + name + " - " + ori);
            Log.Info(Program.LineBreak);

            // Create a new Agency.
            var agencyId = CreateAgency(name, ori);

            // Create the Agency's Classic Integration Role
            ClassicIntegrationRole.Setup(agencyId);

            // Create the Default Workflow
            DefaultWorkflow.CreateInAgency(agencyId);

            // Install the TriTech Default Templates
            TriTechDefaultTemplates.Install(agencyId);

            // Install the Implementation Templates
            ImplementationTemplates.Install(agencyId, implementation);

            // Import Codes From Classic RMS
            SystemCodes.UpdateAgencyCodes(agencyId, classicRmsConnectionString);
            VehicleCodes.ImportIntoAgency(agencyId, classicRmsConnectionString);
            AgencyViolationCodes.ImportAgencyViolationCodes(agencyId, classicRmsConnectionString);
            AgencySystemConfigGlobal.UpdateAgencySettings(agencyId, classicRmsConnectionString);

            // Configuration
            AgencyDefaults.Apply(agencyId);

            return(agencyId);
        }
        /// <summary>
        /// Always Invoked after all pending updates have been applied.
        /// </summary>
        /// <remarks>It is Safe to Use the Domain Models and Services here as the database will match the current entity model.</remarks>
        private void PostUpdate(bool isNewInstall)
        {
            // Work that should only be peformed for a new install.
            if (isNewInstall)
            {
                // Create the SQL Login for the App Pool.
                // TODO: We may want to do this every time in case the app pool identity changes?
                AppPoolIdentityLogin.Create(Context.TargetDatabaseConnectionString, Context.AppPoolIdentity);

                // Create a new RMS System
                RMSSystemFactory.CreateNewRmsSystem(Context.SystemName, ProductVersion);

                // Enable FileStreaming on the Media Database
                MediaFileStreaming.Enable();

                // Setup Durable Instancing
                MicrosoftDurableInstancing.Setup();
            }

            #region Update System

            // Always Update the Metadata BEFORE templates are Updated
            MetadataInfo.Update(Context.TargetImplementation);

            // Update Classic RMS Codes (NCIC, Violation, UCR, etc)
            ClassicRmsCodes.UpdateFromClassicRms(Context.ClassicDatabaseConnectionString);

            #endregion

            #region Update Agencies

            // Update the System Codes in all Agencies.
            AgencyCodes.UpdateAllAgencies(Context.ClassicDatabaseConnectionString);

            // Update the TriTechDefault Templates in all Agencies.
            TriTechDefaultTemplates.UpdateAllAgencies();

            // Update the Implementation Default Templates in all Agencies.
            ImplementationTemplates.UpdateAllAgencies(Context.TargetImplementation);

            // Update any Agency specific Violation Codes
            AgencyViolationCodes.UpdateAllAgencies(Context.ClassicDatabaseConnectionString);

            #endregion

            // Always Make Sure the AppPool login has access to the databases.
            // TODO: This assumes the Login was already created on Install.
            AppPoolIdentityPermissions.Apply(Context.AppPoolIdentity);
        }