示例#1
0
        private static void LoadNcicCodes(string classicRmsConnectionString, Domain.Administration.Aggregates.Agency.Agency agency, string propertyClass, string className,
                                          string codeField, string codeDescriptionField, string mapPropertyClass = null)
        {
            using (var conn = new SqlConnection(classicRmsConnectionString))
            {
                conn.Open();

                // if a mapPropertyClass is passed use it, otherwise use propertyClass
                var codeSet = agency.CreateCodeSet(mapPropertyClass ?? propertyClass, className, "");

                using (var codeData = new DataSet())
                {
                    var codevalueSelect =
                        String.Format(
                            "SELECT [NCIC_Property_Code_Link], [Class], [Category], [Category_desc], [Property_Code], [Property_Code_Desc], [Date_Entered] FROM [VSI_SYSTEM].[dbo].[NCIC_Property_Code]  where Class = '{0}' ",
                            propertyClass);

                    using (var adapter = new SqlDataAdapter(codevalueSelect, conn)) adapter.Fill(codeData, "CodeValues");

                    Log.Info("Importing {0} {1} codes into {2}", codeData.Tables["CodeValues"].Rows.Count, className, agency.Jurisdiction.Ori);

                    foreach (DataRow code in codeData.Tables["CodeValues"].Rows)
                    {
                        var classicId = code["NCIC_Property_Code_Link"].ToString();

                        var codeValue     = codeSet.CreateCode(code[codeField] as string, code[codeDescriptionField] as string, String.Format("{0}N", classicId));
                        var effectiveDate = DateTime.Now;
                        DateTime.TryParse(code["Date_Entered"] as string, out effectiveDate);
                        codeValue.SetLifetime(effectiveDate, DateTime.MaxValue);
                    }
                }
            }
        }
        /// <summary>
        /// Create or Find the Classic Integration Role in an Agency
        /// </summary>
        /// <param name="agency"></param>
        /// <returns></returns>
        public static Role CreateInAgency(Domain.Administration.Aggregates.Agency.Agency agency)
        {
            // Find or Create the Classic Integration Role in the Agency
            var etlRole = agency.GetRole(Name) ??
                          agency.CreateRole(Name, "Classic Integration");

            return(etlRole);
        }
示例#3
0
 /// <summary>
 /// License the Default Modules that All Agencies Get.
 /// TODO: It doesn't look like the system is using any of this information right now.
 /// </summary>
 private static void LicenseDefaultModules(RMSSystem rmsSystem, Domain.Administration.Aggregates.Agency.Agency agency)
 {
     rmsSystem.LicenseModule(agency, ModuleType.Incident);
     rmsSystem.LicenseModule(agency, ModuleType.Arrest);
     rmsSystem.LicenseModule(agency, ModuleType.FieldInterview);
     rmsSystem.LicenseModule(agency, ModuleType.Case);
     rmsSystem.LicenseModule(agency, ModuleType.Citation);
     rmsSystem.LicenseModule(agency, ModuleType.Crash);
     rmsSystem.LicenseModule(agency, ModuleType.OtherEvent);
     rmsSystem.LicenseModule(agency, ModuleType.CallForService);
 }
        /// <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);
            }
        }
        private static void LoadAgencySettingsFromClassicRms(Domain.Administration.Aggregates.Agency.Agency agency, string classicRmsConnectionString)
        {
            using (var conn = new SqlConnection(classicRmsConnectionString))
            {
                conn.Open();

                using (var settingsData = new DataSet())
                {
                    string settingsSelect = String.Format("SELECT [User_Option], [User_Value] FROM [VSI_SYSTEM].[dbo].[System_Config_Global] WHERE [Jurisdiction] = '{0}'", agency.Jurisdiction.Ori);

                    using (var adapter = new SqlDataAdapter(settingsSelect, conn))
                        adapter.Fill(settingsData, "Settings");

                    Log.Info("Importing {0} Settings into {1}", settingsData.Tables["Settings"].Rows.Count, agency.Jurisdiction.Ori);

                    agency.Settings.Clear();

                    foreach (DataRow settingRow in settingsData.Tables["Settings"].Rows)
                    {
                        var userOption = settingRow["User_Option"] as string;
                        var userValue  = settingRow["User_Value"] as string;

                        // just in case
                        if (string.IsNullOrEmpty(userOption))
                        {
                            Log.Info(@"WARNING: Blank Setting Option Detected Validate Classic Settings");
                            continue;
                        }


                        var value = new SettingValue(userOption, userValue);

                        agency.Settings.Add(value);
                    }
                }
            }
        }
示例#6
0
        private static void LoadSystemCodesFromClassicRms(Domain.Administration.Aggregates.Agency.Agency agency, string classicRmsConnectionString)
        {
            using (var conn = new SqlConnection(classicRmsConnectionString))
            {
                conn.Open();

                using (var systemCodesData = new DataSet())
                {
                    const string categorySelect = "SELECT DISTINCT [Category], [Code_Name] FROM [VSI_SYSTEM].[dbo].[System_Code]";

                    using (var adapter = new SqlDataAdapter(categorySelect, conn))
                        adapter.Fill(systemCodesData, "Categories");

                    Log.Info("Importing {0} System Code Categories into {1}", systemCodesData.Tables["Categories"].Rows.Count, agency.Jurisdiction.Ori);

                    foreach (DataRow categoryRow in systemCodesData.Tables["Categories"].Rows)
                    {
                        var category = categoryRow["Category"] as string;
                        var codeName = categoryRow["Code_Name"] as string;

                        // just in case
                        if (string.IsNullOrEmpty(category))
                        {
                            Log.Info(@"WARNING: Blank Category Detected for Code_Name '{0}'", codeName);
                            continue;
                        }

                        // Find or create codeset using category
                        var codeSet = agency.CodeSets.FirstOrDefault(x => x.Category == category) ?? agency.CreateCodeSet(category, codeName, codeName);

                        using (var codeData = new DataSet())
                        {
                            var codevalueSelect =
                                String.Format(
                                    "SELECT [System_Code_Link], [Category], [Code], [Description], [Date_Entered] FROM [VSI_SYSTEM].[dbo].[System_Code]  where category = '{0}' ",
                                    category);

                            using (var adapter = new SqlDataAdapter(codevalueSelect, conn))
                                adapter.Fill(codeData, "CodeValues");

                            foreach (DataRow codeRow in codeData.Tables["CodeValues"].Rows)
                            {
                                var classicId   = codeRow["System_Code_Link"].ToString();
                                var value       = codeRow["Code"] as string;
                                var description = codeRow["Description"] as string;
                                var dateEntered = codeRow["Date_Entered"].ToString();

                                var      codeValue = codeSet.CreateCode(value, description, String.Format("{0}S", classicId));
                                DateTime effectiveDate;
                                if (DateTime.TryParse(dateEntered, out effectiveDate))
                                {
                                    codeValue.SetLifetime(effectiveDate, DateTime.MaxValue);
                                }
                                else
                                {
                                    codeValue.MakeActive();
                                }
                            }
                        }
                    }
                }
            }
        }
        private static void InstallOrUpdateTemplatesInAgency(Domain.Administration.Aggregates.Agency.Agency agency,
                                                             string implementation, IAdministrationUnitOfWork admin, IMetadataUnitOfWork meta)
        {
            Log.Info("Processing {0} templates for {1}", implementation, agency.Jurisdiction.Ori);

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

            // Load All the Metadata
            var dataEntryContracts = meta.GetAllDataEntryContracts();

            // Load All the Template Layouts
            var templateLayouts = LoadTemplateLayoutsFromFolder(TemplateFolder);

            // Setup the Default Templates for Each DataEntryContract defined in the Metadata
            foreach (var contract in dataEntryContracts)
            {
                // Find any layouts defined for the Implementation
                var impTemplateLayouts = templateLayouts.Where(t => t.ModuleType == contract.ModuleType && t.Implementation == implementation).ToList();

                // If none are defined use the "Generic" templates
                if (impTemplateLayouts.Count == 0)
                {
                    impTemplateLayouts = templateLayouts.Where(t => t.ModuleType == contract.ModuleType && t.Implementation == StateImplementations.Generic).ToList();
                }

                // Setup the Templates in the Agency
                foreach (var templateLayout in impTemplateLayouts)
                {
                    // Find or Create the Template
                    var agencyTemplate = agency.GetTemplate(templateLayout.ModuleType, templateLayout.Name);
                    if (agencyTemplate == null)
                    {
                        Log.Info("Installing {0}", templateLayout.Name);
                        agencyTemplate = agency.CreateTemplate(contract.Id, contract.ModuleType, templateLayout.Name);

                        // TODO: This assumes the First Workflow is the Correct Workflow
                        agencyTemplate.SetWorkflow(agency.Workflows.First());

                        // Make the Template Active
                        agencyTemplate.MakeActive();

                        // Assign all roles to the Template
                        agency.Roles.ForEach(x => agencyTemplate.AssignRole(x));

                        // Determine if the template should be set as the Agency Default
                        var templateIsDefault = templateLayout.IsDefault ||    // Template is Explicitly Marked as a Default.
                                                impTemplateLayouts.Count == 1; // There is only one template being installed for this contract.

                        // Set the template as the Agency Default
                        if (templateIsDefault)
                        {
                            agency.SetDefaultTemplate(agencyTemplate);
                        }
                    }
                    else
                    {
                        Log.Info("Updating {0}", templateLayout.Name);

                        // Reset the Template
                        templateManager.ResetTemplateLayout(agencyTemplate);
                    }

                    // Load the Template Layout Information
                    templateLayoutService.LoadLayout(templateLayout, agencyTemplate);
                }
            }
        }