Пример #1
0
        /// <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();
                    }
                }
            }
        }
Пример #2
0
        public override CommandExecutionResult Execute()
        {
            var ctx       = new AdministrationDbContext();
            var rmsSystem = ctx.GetSystemInstance();
            var sysAdmin  = rmsSystem.FindIdentity("sys_admin");

            if (Password != null)
            {
                if (string.IsNullOrWhiteSpace(Password))
                {
                    return(CommandExecutionResult.Fail("Password cannot be blank"));
                }

                sysAdmin.SetPassword(Password);
            }

            if (Enable)
            {
                sysAdmin.MakeActive();
            }

            if (Disable)
            {
                sysAdmin.MakeActive(false);
            }

            ctx.SaveChanges();


            return(CommandExecutionResult.Ok());
        }
Пример #3
0
        public override CommandExecutionResult Execute()
        {
            try
            {
                using (var adminContext = new AdministrationDbContext())
                {
                    var system = adminContext.GetSystemInstance();
                    Log.Info(system.Description);

                    var agencies = adminContext.GetSystemInstance()
                                   .Agencies
                                   .Select(a => new { a.Name, a.Jurisdiction.Ori })
                                   .ToList();

                    foreach (var agency in agencies)
                    {
                        Log.Info("[{0}]\t{1}", agency.Ori, agency.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                return(CommandExecutionResult.Exception(ex));
            }

            return(CommandExecutionResult.Ok());
        }
Пример #4
0
        private void ExportTemplatesButton_Click(object sender, RoutedEventArgs e)
        {
            if (_browserDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            foreach (TemplateDescription templateDescription in TemplatesListBox.SelectedItems)
            {
                try
                {
                    using (var admin = new AdministrationDbContext())
                        using (var meta = new MetadataDbContext())
                        {
                            // Create a Template Layout Service
                            var templateLayoutService = new TemplateLayoutService(admin, meta);

                            // Get the Layout Information for the Template
                            var templateLayout = templateLayoutService.GetTemplateLayout(templateDescription.Template.Id, State);

                            // Serialize the Layout Information to an XML File.
                            using (var s = new StreamWriter(Path.Combine(_browserDialog.SelectedPath, templateDescription.Template.Name + " Template.xml")))
                            {
                                s.Write(Serializer <TemplateLayout> .Serialize(templateLayout));
                            }
                        }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.Message);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Provides the roles needed for the user to interact with the STS.
        /// </summary>
        public IEnumerable <string> GetRoles(string userName)
        {
            var roles = new List <string>();

            using (var context = new AdministrationDbContext() as IAdministrationUnitOfWork)
            {
                var rmsSystem = context.GetSystemInstance();
                var identity  = rmsSystem.FindIdentity(userName);

                if (identity == null)
                {
                    return(roles);
                }

                if (identity.IsActive) // the user can request a token ( We may need to look closer at this )
                {
                    roles.Add(IdentityServerUsersRole);
                }

                if (identity.IsAdministrator) // the user can administer the STS ( Should Interface Accounts be able to do this? )
                {
                    roles.Add(IdentityServerAdministratorsRole);
                }
            }

            return(roles);
        }
Пример #6
0
        /// <summary>
        /// Import Vehicle Codes into all Agencies in the system.
        /// </summary>
        /// <remarks>TODO: This method does not support Update.  This assumes the SystemCodes.UpdateAllAgencies() has run first purging all existing codes.</remarks>
        public static void ImportIntoAllAgencies(string classicRmsConnectionString)
        {
            List <Guid> agencyIds;

            using (var context = new AdministrationDbContext())
                agencyIds = context.Set <Domain.Administration.Aggregates.Agency.Agency>().Select(x => x.Id).ToList();
            agencyIds.ForEach(x => ImportIntoAgency(x, classicRmsConnectionString));
        }
Пример #7
0
 public static void Setup()
 {
     using (var context = new AdministrationDbContext())
     {
         var rmsSystem = context.GetSystemInstance();
         rmsSystem.Settings["TODO"] = "There are currently no Default System Configurations.";
         context.Commit();
     }
 }
Пример #8
0
 /// <summary>
 /// Import any Agency Specific Violation Codes
 /// </summary>
 /// <param name="agencyId">Id of the Agency to Import Codes for.</param>
 /// <param name="classicRmsConnectionString">Connection string to the Classic RMS Database.</param>
 public static void ImportAgencyViolationCodes(Guid agencyId, string classicRmsConnectionString)
 {
     using (var context = new AdministrationDbContext())
     {
         var rmsSystem = context.GetSystemInstance();
         ImportAgencyViolationsFromClassicRms(rmsSystem, agencyId, classicRmsConnectionString);
         context.Commit();
     }
 }
Пример #9
0
        /// <summary>
        /// Update the System Codes in All Agencies.
        /// </summary>
        public static void UpdateAllAgencies(string classicDatabaseConnectionString)
        {
            List <Guid> agencyIds;

            using (var context = new AdministrationDbContext())
                agencyIds = context.Set <Domain.Administration.Aggregates.Agency.Agency>()
                            .Select(x => x.Id).ToList();

            agencyIds.ForEach(id => UpdateAgencyCodes(id, classicDatabaseConnectionString));
        }
Пример #10
0
        /// <summary>
        /// Load the Vehicle Codes(VMA and VMO) from Classic RMS into a Web RMS Agency.
        /// <remarks>TODO: This method does not support Update.  This assumes the SystemCodes.UpdateAllAgencies() has run first purging all existing codes.</remarks>
        /// </summary>
        public static void ImportIntoAgency(Guid agencyId, string classicRmsConnectionString)
        {
            using (var context = new AdministrationDbContext())
            {
                var agency = context.Find <Domain.Administration.Aggregates.Agency.Agency>(agencyId);
                LoadNcicCodes(classicRmsConnectionString, agency, "VMA", "Vehicle Make", "Category", "Category_desc");
                LoadNcicCodes(classicRmsConnectionString, agency, "VMO", "Vehicle Model", "Property_Code", "Property_Code_desc", "VMOTTCH");

                context.Commit();
            }
        }
Пример #11
0
 /// <summary>
 /// Purge all ImageInfo Codes from the System
 /// </summary>
 public static void Purge()
 {
     using (var context = new AdministrationDbContext())
     {
         var count = context.DeleteAll <ImageInfo>();
         if (count > 0)
         {
             Log.Info("Purged {0} ImageInfo Codes", count);
         }
         context.SaveChanges();
     }
 }
Пример #12
0
        /// <summary>
        /// Create a Default Officer Role in an Agency
        /// </summary>
        public static Guid CreateInAgency(Guid agencyId)
        {
            using (var context = new AdministrationDbContext())
            {
                var agency = context.Find <Domain.Administration.Aggregates.Agency.Agency>(agencyId);
                var role   = agency.CreateRole(Name, "Default Officer Role");
                ModuleTypeInfo.ReportModules.ForEach(x => role.SetModulePermissions(x, new ModulePermissions(false, true, false, false)));

                context.Commit();
                return(role.Id);
            }
        }
Пример #13
0
        public override CommandExecutionResult Execute()
        {
            using (var ctx = new AdministrationDbContext())
            {
                var rmsSystem = ctx.GetSystemInstance();

                var sysInfo = "Description: " + rmsSystem.Description + Environment.NewLine +
                              "Key: [" + rmsSystem.Id.As64BitString() + "]" + Environment.NewLine +
                              "Version: " + rmsSystem.Version + Environment.NewLine;

                return(CommandExecutionResult.Ok(sysInfo));
            }
        }
Пример #14
0
        /// <summary>
        /// Update The Implementation Default Templates for all Agencies in the System.
        /// </summary>
        /// <param name="implementation">The State Implementation of the System.</param>
        public static void UpdateAllAgencies(string implementation)
        {
            using (var meta = new MetadataDbContext())
                using (var admin = new AdministrationDbContext())
                {
                    // Install or Update Templates in All Agencies
                    admin.GetEntityQuery <Domain.Administration.Aggregates.Agency.Agency>()
                    .ToList()
                    .ForEach(agency => InstallOrUpdateTemplatesInAgency(agency, implementation, admin, meta));

                    // Commit the Work
                    admin.Commit();
                }
        }
Пример #15
0
            public void ToRole(Guid roleId)
            {
                using (var context = new AdministrationDbContext())
                {
                    var agency    = context.Find <Domain.Administration.Aggregates.Agency.Agency>(_agencyId);
                    var templates = agency.Templates.ToList();
                    var role      = agency.GetRole(roleId);

                    // Assign the role to all available Templates
                    templates.ForEach(t => t.AssignRole(role));

                    context.Commit();
                }
            }
Пример #16
0
        /// <summary>
        /// Update the Agency Specific Violation Codes for all Agencies in the system.
        /// </summary>
        /// <remarks>TODO: We are assuming the update process has purged all existing Violations.</remarks>
        public static void UpdateAllAgencies(string classicRmsConnectionString)
        {
            using (var context = new AdministrationDbContext())
            {
                var rmsSystem = context.GetSystemInstance();
                var agencyIds = rmsSystem.Agencies.Select(x => x.Id).ToList();
                foreach (var agencyId in agencyIds)
                {
                    ImportAgencyViolationsFromClassicRms(rmsSystem, agencyId, classicRmsConnectionString);
                }

                context.Commit();
            }
        }
Пример #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            var metadataContext = new MetadataDbContext();
            var adminContext    = new AdministrationDbContext();

            foreach (var agency in adminContext.GetSystemInstance().Agencies)
            {
                foreach (var contract in metadataContext.GetEntityQuery <DataEntryContract>())
                {
                    TemplateFactory.Create(agency, contract);
                }
            }

            adminContext.SaveChanges();
        }
Пример #18
0
        /// <summary>
        /// Setup the Classic Integration Role in the Agency.
        /// </summary>
        /// <param name="agencyId">Id of the Agency to Create the Role in.</param>
        /// <returns>Id of the new Role.</returns>
        public static Guid Setup(Guid agencyId)
        {
            using (var context = new AdministrationDbContext())
            {
                var rmsSystem  = context.GetSystemInstance();
                var etlAccount = rmsSystem.FindIdentity(ClassicIntegrationAccount.Username);
                var agency     = rmsSystem.GetAgency(agencyId);
                var etlRole    = CreateInAgency(agency);
                etlAccount.AssignRole(etlRole);
                SetupRolePermissions(etlRole);
                context.Commit();

                return(etlRole.Id);
            }
        }
Пример #19
0
        /// <summary>
        /// Create a Default Supervisor Role in an Agency.
        /// </summary>
        public static Guid CreateInAgency(Guid agencyId)
        {
            using (var context = new AdministrationDbContext())
            {
                var agency = context.Find <Domain.Administration.Aggregates.Agency.Agency>(agencyId);
                var role   = agency.CreateRole(Name, "Default Supervisor Role");
                role.SetAgencyPermissions(new AgencyPermissions(true, false, true, true));
                role.SetModulePermissions(ModuleType.Arrest, ModulePermissions.All);
                role.SetModulePermissions(ModuleType.Case, ModulePermissions.All);   // Case doesn't really make sense here.
                role.SetModulePermissions(ModuleType.FieldInterview, ModulePermissions.All);
                role.SetModulePermissions(ModuleType.Incident, ModulePermissions.All);

                context.Commit();
                return(role.Id);
            }
        }
Пример #20
0
        /// <summary>
        /// Create a Default Admin Role in an Agency.
        ///
        /// </summary>
        public static Guid CreateInAgency(Guid agencyId)
        {
            using (var context = new AdministrationDbContext())
            {
                var agency = context.Find <Domain.Administration.Aggregates.Agency.Agency>(agencyId);
                var role   = agency.CreateRole(Name, "Default Administrator Role");
                role.SetAgencyPermissions(new AgencyPermissions(true, true, true, true));

                // Assign the role to all available Templates
                var agencyTemplates = agency.Templates.ToList();
                agencyTemplates.ForEach(t => t.AssignRole(role));

                context.Commit();
                return(role.Id);
            }
        }
Пример #21
0
        /// <summary>
        /// Import ImageInfo codes from the ClassicRMS database into the RMSSystem instance.
        /// </summary>
        public static void ImportFromClassicRms(string classicRmsConnectionString)
        {
            // TODO: Until Codes are managed in Web we must purge everytime we update from Classic.
            Purge();
            using (var context = new AdministrationDbContext())
            {
                // Get the RMSSystem Instance
                var rmsSystem = context.GetSystemInstance();

                // Load the SMT Codes into the RMSSystem
                LoadSMTCodes(rmsSystem);

                // Save any Changes
                context.Commit();
            }
        }
Пример #22
0
        /// <summary>
        /// Create the Default Workflow for the Agency
        /// </summary>
        public static void CreateInAgency(Guid agencyId)
        {
            using (var context = new AdministrationDbContext())
            {
                // Find the Agency
                var agency = context.Find <Domain.Administration.Aggregates.Agency.Agency>(agencyId);

                // Create a New Workflow
                var defaultWorkflow = agency.CreateWorkflow("Default Workflow", CreateDefaultWorkflowSequence().Serialize());

                // Enable the Workflow
                defaultWorkflow.Enable();

                context.Commit();
            }
        }
Пример #23
0
        /// <summary>
        /// Apply the "Default" settings to an Agency.
        /// </summary>
        public static void Apply(Guid agencyId)
        {
            using (var context = new AdministrationDbContext())
            {
                var agency = context.Find <Domain.Administration.Aggregates.Agency.Agency>(agencyId);
                Log.Info("Setting default configuration for " + agency.Jurisdiction.Ori);

                // Get the Agency's Configuration
                var config = agency.Configuration;

                // default setting for number control behavior in incident.
                config.ReportNumberEqualsCaseNumber = true;

                context.Commit();
            }
        }
Пример #24
0
 /// <summary>
 /// Purge all Violation Codes from the System
 /// </summary>
 public static void Purge()
 {
     using (var context = new AdministrationDbContext())
     {
         var count = context.DeleteAll <ViolationCode>();
         if (count > 0)
         {
             Log.Info("Purged {0} Violation Codes", count);
         }
         count = context.DeleteAll <UcrCode>();
         if (count > 0)
         {
             Log.Info("Purged {0} UCR Codes", count);
         }
         context.SaveChanges();
     }
 }
Пример #25
0
        /// <summary>
        /// Register the Default Modules with the RMSSystem.
        /// </summary>
        public static void Register()
        {
            Log.Info("Registering Default Modules");

            using (var context = new AdministrationDbContext())
            {
                var rmsSystem = context.GetSystemInstance();

                // TODO: Look into seeding more detailed information into the Resources table.(ModuleTypeInfo)
                var moduleTypes = ModuleTypeInfo.AllModules;

                moduleTypes.ForEach(moduleType =>
                                    rmsSystem.CreateResource(moduleType, moduleType.GetDescription()));

                context.Commit();
            }
        }
Пример #26
0
        /// <summary>
        /// Re-Import all "Agency Settings" from a ClassicRMS server into an Agency in WebRMS.
        /// </summary>
        public static void UpdateAgencySettings(Guid agencyId, string classicRmsConnectionString)
        {
            using (var context = new AdministrationDbContext())
            {
                var agency = context.Find <Domain.Administration.Aggregates.Agency.Agency>(agencyId);

                // Remove all existing code sets from the Agency.
                // TODO: This is in place until we solve the problem of Web getting its codes from Classic.


                Log.Info("Resetting Agency Settings for jurisdiction {0}", agency.Jurisdiction.Ori);

                // Load Agency Settings from Classic
                LoadAgencySettingsFromClassicRms(agency, classicRmsConnectionString);
                context.Commit();
            }
        }
Пример #27
0
        /// <summary>
        /// Setup any Default Accounts in the new RMSSystem
        /// </summary>
        public static void SetupDefaultAccounts( )
        {
            Log.Info("Setting up default accounts");

            using (var context = new AdministrationDbContext())
            {
                var rmsSystem = context.GetSystemInstance();

                // Setup System Admin Account
                SysAdminAccount.Setup(rmsSystem);

                // Setup Classic Integration Account
                ClassicIntegrationAccount.Setup(rmsSystem);

                context.Commit();
            }
        }
Пример #28
0
        /// <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();
                }
        }
Пример #29
0
        /// <summary>k
        /// Create an RMSSystem
        /// </summary>
        private static void CreateRmsSystem(string systemName, Version version)
        {
            using (var context = new AdministrationDbContext())
            {
                // Create a new RMS System Instance
                var rmsSystem = new RMSSystem(Guid.Empty, systemName)
                {
                    Version = version.ToString()
                };

                Log.Info("System: " + rmsSystem.Description);
                Log.Info("Version: " + rmsSystem.Version);
                Log.Info("Key: [" + rmsSystem.Id.As64BitString() + "] ");

                context.Add(rmsSystem);
                context.Commit();
            }
        }
Пример #30
0
        /// <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();
                }
        }