Exemplo n.º 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();
                    }
                }
            }
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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));
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 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();
                }
        }
Exemplo n.º 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();
                }
            }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
     }
 }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
                }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 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();
                }
        }