Esempio n. 1
0
 private void SetUpUser()
 {
     _rmsSystem = new RMSSystem(Guid.NewGuid(), "RMS Description");
     _agency    = AdministrationUnitTestFixture.AgencyDetails;
     _user      = _rmsSystem.CreateUserAccount(_agency, "New User", Password);
     _administrationUnitOfWork.Setup(item => item.Find <User>(It.IsAny <Guid>(), TrackingMode.Automatic, It.IsAny <ThrowIf>())).Returns(_user);
 }
        public void AgencyQueryServiceClassSetUp()
        {
            _factory             = new MockRepository(MockBehavior.Loose);
            _unitOfWorkAdmin     = _factory.Create <IAdministrationUnitOfWork>();
            _jurisdiction        = new Jurisdiction("ori", "agencyCode");
            _agency              = new AgencyDerived(_jurisdiction, "name");
            _agencyConfiguration = new AgencyConfigurationDerived(_agency, "name");
            _rmsSystem           = new RMSSystem(Guid.NewGuid(), "description");
            _user = _rmsSystem.CreateUserAccount(_agency, "username", "password");
            _unitOfWorkAdmin.Setup(item => item.Find <Agency>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_agency);

            _unitOfWorkAdmin.Setup(item => item.Find <User>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_user);

            _authorizationPolicy = new Mock <IServiceAuthorizationPolicy>();
            _identityProvider    = new Mock <IServiceIdentityProvider>();

            var identityContext = new IdentityContext()
            {
                IdentityId = Guid.NewGuid()
            };

            _identityProvider.Setup(x => x.GetPrincipalIdentifier()).Returns(identityContext.IdentityId);
            _identityProvider.Setup(x => x.GetIdentityContext()).Returns(identityContext);


            _iPasswordQueryService = new PasswordQueryService(_unitOfWorkAdmin.Object, Mock.Of <ILog>(), _authorizationPolicy.Object, _identityProvider.Object);
            SetUpAgencyPasswordConfiguration();
        }
Esempio n. 3
0
        public void CodeSetCommandServiceSetup()
        {
            _unitOfWorkAdmin = _factory.Create <IAdministrationUnitOfWork>();
            _iLogMock        = _factory.Create <ILog>();
            _jurisdiction    = new ValueObjects.Jurisdiction("ori", "agencyCode");
            _agencyDerived   = new AgencyDerived(_jurisdiction, "name");
            _codeSetDerived  = new CodeSetDerived(_agencyDerived, "category", "name", "description");
            _unitOfWorkAdmin.Setup(item => item.Find <Agency>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_agencyDerived);
            _unitOfWorkAdmin.Setup(item => item.Find <CodeSet>(It.IsAny <Guid>(), It.IsAny <TrackingMode>(), It.IsAny <ThrowIf>()))
            .Returns(_codeSetDerived);
            var urcCode = new RMSSystem(It.IsAny <Guid>(), "description");

            _unitOfWorkAdmin.Setup(item => item.GetSystemInstance()).Returns(urcCode);
            _authorizationPolicy = new Mock <IServiceAuthorizationPolicy>();
            _identityProvider    = new Mock <IServiceIdentityProvider>();

            var identityContext = new IdentityContext()
            {
                IdentityId = Guid.NewGuid()
            };

            _identityProvider.Setup(x => x.GetPrincipalIdentifier()).Returns(identityContext.IdentityId);
            _identityProvider.Setup(x => x.GetIdentityContext()).Returns(identityContext);


            _codeSetCommandService = new Administration.Services.Command.CodeSetCommandService(_unitOfWorkAdmin.Object, _iLogMock.Object, _authorizationPolicy.Object,
                                                                                               _identityProvider.Object);
        }
Esempio n. 4
0
        public IdentityDerived(Guid id, RMSSystem rmsSystem, string username, IdentityType identityType)

        {
            if (rmsSystem == null)
            {
                throw new ArgumentNullException("rmsSystem");
            }
            if (string.IsNullOrWhiteSpace(username))
            {
                throw new ArgumentNullException("username");
            }
            if (identityType == IdentityType.Unset)
            {
                throw new ArgumentException("Identity Type is Unset", "identityType");
            }

            Id           = id;
            RMSSystem    = rmsSystem;
            RMSSystemId  = rmsSystem.Id;
            IdentityType = identityType;
            Username     = username;

            // All new Identities are Inactive by Default.
            IsActive = false;
        }
Esempio n. 5
0
        public void ClassSetUp()
        {
            _factory                 = new MockRepository(MockBehavior.Loose);
            _jurisdiction            = new ValueObjects.Jurisdiction("ori", "agencyCode");
            _agency                  = new AgencyDerived(_jurisdiction, "name");
            _agencyConfiguration     = new AgencyConfigurationDerived(_agency, "name");
            _agencyConfigurationList = new List <AgencyConfiguration>();
            _agencyConfigurationList.Add(_agencyConfiguration);
            _agencyReference = new List <AgencyReference>();
            var agencyReference = new AgencyReference();

            agencyReference.AgencyId = _agency.Id;
            _agencyReference.Add(agencyReference);
            _authorizationPolicy = new Mock <IServiceAuthorizationPolicy>();
            _identityProvider    = new Mock <IServiceIdentityProvider>();

            _unitOfWorkAdmin = _factory.Create <IAdministrationUnitOfWork>();
            _rmsSystem       = new RMSSystem(Guid.NewGuid(), "description");

            _unitOfWorkAdmin.Setup(item => item.GetEntityQuery <AgencyConfiguration>(It.IsAny <TrackingMode>()))
            .Returns(_agencyConfigurationList.AsQueryable());
            _unitOfWorkAdmin.Setup(item => item.GetSystemInstance()).Returns(_rmsSystem);
            _agencyCommandService = new Administration.Services.Command.AgencyCommandService(
                _unitOfWorkAdmin.Object, Mock.Of <ILog>(), _authorizationPolicy.Object, _identityProvider.Object);
        }
        /// <summary>
        /// Setup the Classic Integration Account in the RMSSystem
        /// </summary>
        public static void Setup(RMSSystem rmsSystem)
        {
            // Find or Create the Account
            var classicIntegrationAccount = rmsSystem.CreateInterfaceAccount(IdentityId, Username, "M3T4D474", "Classic Integration Service");

            // Make the Account Active.
            classicIntegrationAccount.MakeActive();
        }
Esempio n. 7
0
        private void CreateUser()
        {
            _users = new List <User>();
            var rmsSystem = new RMSSystem(Guid.NewGuid(), "RMS Description");
            var user      = rmsSystem.CreateUserAccount(_agencyDerived, "New User", "1ab");

            _users.Add(user);
        }
Esempio n. 8
0
        private void SetUpUser()
        {
            var rmsSystem = new RMSSystem(Guid.NewGuid(), "RMS System");
            var user      = rmsSystem.CreateUserAccount(_agency, "Ronald Di", "ron123");
            var userList  = new List <User>();

            userList.Add(user);
            _administrationUnitOfWork.Setup(item => item.GetEntityQuery <User>(It.IsAny <TrackingMode>())).Returns(userList.AsQueryable);
        }
        public void ClassLevelSetUp()
        {
            var jurisdiction = new Jurisdiction("ori", "agencyCode");
            var agency       = new AgencyDerived(jurisdiction, "name");
            var rmsSystem    = new RMSSystem(Guid.NewGuid(), "RMS Description");

            _user = rmsSystem.CreateUserAccount(agency, "New User", "1ab");
            _passwordConfiguration = PasswordConfiguration.Empty;
        }
Esempio n. 10
0
        private void SetUpUser()
        {
            var userList  = new List <User>();
            var rmsSystem = new RMSSystem(Guid.NewGuid(), "RMS Description");
            var user      = rmsSystem.CreateUserAccount(_agency, "Workflow User", "A123@TR");

            userList.Add(user);
            _administrationUnitOfWork.Setup(mock => mock.GetEntityQuery <User>(TrackingMode.Automatic)).Returns(userList.AsQueryable);
            _identityId = user.Id;
        }
Esempio n. 11
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);
 }
Esempio n. 12
0
        public static void Setup(RMSSystem rmsSystem)
        {
            // Create the Sys_Admin account.
            var systemAdmin = rmsSystem.CreateSystemAccount(IdentityId, Username, "admin");

            // Activate the Account
            systemAdmin.MakeActive();

            // Make an Administrator.
            systemAdmin.MakeAdministrator();
        }
Esempio n. 13
0
        public void GetUsersInRole()
        {
            var rmsSystem    = new RMSSystem(Guid.NewGuid(), "RMS Description");
            var identity     = rmsSystem.CreateInterfaceAccount(Guid.NewGuid(), "New User", "123", "user description");
            var assignedRole = identity.AssignRole(_role);

            _assignedRoleList.Add(assignedRole);
            var usersInRole = _roleCommandService.GetUsersInRole(_role.Id);

            usersInRole.Should().NotBeNullOrEmpty();
            usersInRole.FirstOrDefault().Should().NotBeEmpty();
            usersInRole.FirstOrDefault().Should().Be(identity.Id.ToString());
        }
Esempio n. 14
0
        public void ClassSetUp()
        {
            _agency = QueueUnitTestFixture.AgencyDetails;
            var rmsSystem = new RMSSystem(Guid.NewGuid(), "RMS Description");

            _identity                 = new IdentityDerived(Guid.NewGuid(), rmsSystem, "New User", IdentityType.User);
            _factory                  = new MockRepository(MockBehavior.Loose);
            _reportsUnitOfWork        = _factory.Create <IReportsUnitOfWork>();
            _administrationUnitOfWork = _factory.Create <IAdministrationUnitOfWork>();

            SetUpAgencies();
            SetUpReport();
            SetUpRole();
            //SetUpIdentity();
            _reportQueueService = new ReportQueueService(_reportsUnitOfWork.Object, _administrationUnitOfWork.Object, Mock.Of <ILog>(), Mock.Of <IServiceAuthorizationPolicy>(), Mock.Of <IServiceIdentityProvider>());
        }
Esempio n. 15
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();
            }
        }
Esempio n. 16
0
        public void GetUsers()
        {
            var userList  = new List <User>();
            var systemId  = Guid.NewGuid();
            var rmsSystem = new RMSSystem(systemId, "description");
            var user      = rmsSystem.CreateUserAccount(_agency, "username", "password");

            userList.Add(user);
            _unitOfWorkAdmin.Setup(item => item.GetEntityQuery <User>(It.IsAny <TrackingMode>()))
            .Returns(userList.AsQueryable());

            var result = _agencyQueryService.GetUsers(_agency.Id);

            result.Should().NotBeNullOrEmpty();
            result.Select(item => item.PrimaryAgencyId).FirstOrDefault().Should().Be(_agency.Id);
            result.Select(item => item.UserId).FirstOrDefault().Should().Be(user.Id);
            result.Select(item => item.Username).FirstOrDefault().Should().Be("username");
        }
Esempio n. 17
0
        private static void LoadSMTCodes(RMSSystem rmsSystem)
        {
            using (var conn = new SqlConnection(Settings.Classic))
            {
                conn.Open();

                using (var smtCodesData = new DataSet())
                {
                    const string smtSelect =
                        "SELECT DISTINCT [Image_Code_Link], [Category], [Code], [Description], [Code_Name], [Global] ,[Code_Length] FROM [VSI_SYSTEM].[dbo].[Image_Code] WHERE Category IN ('SMT', 'ABP', 'BOD', 'MCD', 'MDB', 'PDF')";

                    using (var adapter = new SqlDataAdapter(smtSelect, conn))
                        adapter.Fill(smtCodesData, "ImageInfo");

                    Log.Info("Importing {0} SMT Codes for Scars/Marks", smtCodesData.Tables["ImageInfo"].Rows.Count);

                    foreach (DataRow smtCodeRow in smtCodesData.Tables["ImageInfo"].Rows)
                    {
                        // Find or create SMT Code record

                        var classicId = Convert.ToInt32(smtCodeRow["Image_Code_Link"].ToString());

                        var imageInfo = (rmsSystem.ImageInfo).FirstOrDefault(i => i.ClassicId == classicId);
                        if (imageInfo == null)
                        {
                            var category    = (smtCodeRow["Category"] as string).Trim();
                            var code        = (smtCodeRow["Code"] as string).Trim();
                            var description = (smtCodeRow["Description"] as string).Trim();
                            var codeName    = (smtCodeRow["Code_Name"] as string).Trim();
                            var global      = smtCodeRow["Global"] as bool?;
                            var codeLength  = smtCodeRow["Code_Length"] as int?;

                            rmsSystem.CreateImageInfo(classicId, category, code, description, codeName, global, codeLength);
                        }
                    }
                }
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Connect to the Classic RMS database and look for any violations that belong to the Agency using it's ORI.
        /// Load any Agency Violations into the Web RMS System.
        /// </summary>
        private static void ImportAgencyViolationsFromClassicRms(RMSSystem rmsSystem, Guid agencyId, string classicRmsConnectionString)
        {
            // call Safe Get(), eat exception and set default value of UCR.
            var agencyOri = rmsSystem.GetAgency(agencyId).Jurisdiction.Ori;

            using (var conn = new SqlConnection(classicRmsConnectionString))
            {
                conn.Open();

                using (var ucrCodesData = new DataSet())
                {
                    string violationSelect = @"SELECT DISTINCT [VC].[Violation_Code_Link], [VC].[Code], [VC].[Description], [VC].[Statute], [VC].[Statute_Description],  " +
                                             "ISNULL([VC].[UCR_Code],'') UCR_Code, IsNull([VC].[UCR_Category],'') UCR_Category, IsNull([UC].[Description],'') UCR_Description, [VC].[Type_Statute], [VC].[Level_Degree], [VC].[State_Code], [VC].[NCIC_Code], " +
                                             "[VC].[Effective_Date],[VC].[Repeal_Date], ISNULL([VC].[Citation],0) Citation, ISNULL([VC].[Warrant],0) Warrant, ISNULL([VC].[Arrest],0) Arrest, " +
                                             "  ISNULL([VC].[Violation_Hierarchy],0) Violation_Hierarchy, ISNULL([VC].[Incident],0) Incident,  ISNULL([VC].[Jail],0) Jail," +
                                             " ISNULL([VC].[Inactive],0) Inactive,  ISNULL([VC].[Reportable],0) Reportable " +
                                             "  FROM [VSI_SYSTEM].[dbo].[Violation_Code] [VC] " +
                                             "LEFT OUTER JOIN [VSI_SYSTEM].[dbo].[UCR_Code] [UC] " +
                                             "ON [VC].[UCR_Code] = [UC].[UCR_Code] " +
                                             "  WHERE ISNULL([VC].[JURISDICTION],'ALL') = '" + agencyOri + "' ";


                    using (var adapter = new SqlDataAdapter(violationSelect, conn))
                        adapter.Fill(ucrCodesData, "ViolationCodes");

                    Log.Info("Importing {0} Agency Violation Codes into {1}", ucrCodesData.Tables["ViolationCodes"].Rows.Count, agencyOri);

                    foreach (DataRow violationCodeRow in ucrCodesData.Tables["ViolationCodes"].Rows)
                    {
                        // Find or create UCR Code record

                        var classicId            = Convert.ToInt32(violationCodeRow["Violation_Code_Link"].ToString());
                        var code                 = violationCodeRow["Code"] as string;
                        var violationDescription = violationCodeRow["Description"] as string;
                        var violationHierarchy   = violationCodeRow["Violation_Hierarchy"].ToString();
                        var statuteCode          = violationCodeRow["Statute"] as string;
                        var statuteDescription   = violationCodeRow["Statute_Description"] as string;
                        var ucrCode              = violationCodeRow["UCR_Code"] as string;
                        var ucrCategory          = violationCodeRow["UCR_Category"] as string;
                        var ucrDescription       = violationCodeRow["UCR_Description"] as string;
                        var typeStatute          = violationCodeRow["Type_Statute"] as string;
                        var levelDegree          = violationCodeRow["Level_Degree"] as string;
                        var stateCode            = violationCodeRow["State_Code"] as string;
                        var ncicCode             = violationCodeRow["NCIC_Code"] as string;

                        var effectiveDatestr = violationCodeRow["Effective_Date"] as string;
                        var effectiveDate    = String.IsNullOrEmpty(effectiveDatestr) ? DateTime.Now.AddYears(-100) : Convert.ToDateTime(effectiveDatestr);

                        var repealDatestr = violationCodeRow["Repeal_Date"] as string;
                        var repealDate    = String.IsNullOrEmpty(repealDatestr) ? DateTime.Now.AddYears(100) : Convert.ToDateTime(repealDatestr);

                        var citation   = Convert.ToBoolean(violationCodeRow["Citation"].ToString());
                        var warrant    = Convert.ToBoolean(violationCodeRow["Warrant"].ToString());
                        var arrest     = Convert.ToBoolean(violationCodeRow["Arrest"].ToString());
                        var incident   = Convert.ToBoolean(violationCodeRow["Incident"].ToString());
                        var jail       = Convert.ToBoolean(violationCodeRow["Jail"].ToString());
                        var inactive   = Convert.ToBoolean(violationCodeRow["Inactive"].ToString());
                        var reportable = Convert.ToBoolean(violationCodeRow["Reportable"].ToString());

                        statuteCode        = String.IsNullOrEmpty(statuteCode) ? "" : statuteCode;
                        statuteDescription = String.IsNullOrEmpty(statuteDescription) ? "" : statuteDescription;
                        ucrCode            = String.IsNullOrEmpty(ucrCode) ? "" : ucrCode;
                        ucrDescription     = String.IsNullOrEmpty(ucrDescription) ? "" : ucrDescription;
                        code = String.IsNullOrEmpty(code) ? "" : code;

                        var statuteDefinition = String.Format("{0} {1} {2} {3} {4}", statuteCode, statuteDescription, ucrCode, ucrDescription, code);

                        var filterCode = String.IsNullOrEmpty(ucrCode) ? "" : ucrCode;
                        var filterDesc = String.IsNullOrEmpty(ucrDescription) ? "" : ucrDescription;

                        var filter = new CodeValue {
                            Code = filterCode, Description = filterDesc
                        };

                        var existingViolation = rmsSystem.ViolationCodes.FirstOrDefault(x => x.ClassicId == classicId);
                        if (existingViolation != null)
                        {
                            existingViolation.AgencyId             = agencyId;
                            existingViolation.Arrest               = arrest;
                            existingViolation.Citation             = citation;
                            existingViolation.Code                 = code;
                            existingViolation.EffectiveDate        = effectiveDate;
                            existingViolation.Filter               = filter;
                            existingViolation.Inactive             = inactive;
                            existingViolation.Incident             = incident;
                            existingViolation.Jail                 = jail;
                            existingViolation.LevelOrDegree        = levelDegree;
                            existingViolation.NcicCode             = ncicCode;
                            existingViolation.RepealDate           = repealDate;
                            existingViolation.Reportable           = reportable;
                            existingViolation.StateCode            = stateCode;
                            existingViolation.StatuteCode          = statuteCode;
                            existingViolation.StatuteDefinition    = statuteDefinition;
                            existingViolation.StatuteDescription   = statuteDescription;
                            existingViolation.Type                 = typeStatute;
                            existingViolation.UcrCategory          = ucrCategory;
                            existingViolation.UcrCode              = ucrCode;
                            existingViolation.ViolationDescription = violationDescription;
                            existingViolation.ViolationHierarchy   = violationHierarchy;
                            existingViolation.Warrant              = warrant;
                        }
                        else
                        {
                            rmsSystem.CreateViolationCode(agencyId, classicId, code, violationDescription, reportable, ucrCode,
                                                          ucrCategory, statuteCode, statuteDescription, violationHierarchy, typeStatute, levelDegree,
                                                          stateCode, ncicCode, effectiveDate, repealDate, inactive, incident, citation,
                                                          arrest, warrant, jail, statuteDefinition, filter);
                        }
                    }
                }
            }
        }
Esempio n. 19
0
 public void Constructor()
 {
     RMSSystem rmssystem = new RMSSystem(Guid.NewGuid(), null);
 }
Esempio n. 20
0
 private void SetUpAgency()
 {
     _rmsSystem = new RMSSystem(Guid.NewGuid(), "RMS Description");
     _agency    = _rmsSystem.CreateAgency("New Agency", "new Ori");
     _administrationUnitOfWork.Setup(item => item.GetSystemInstance()).Returns(_rmsSystem);
 }
Esempio n. 21
0
 public void SetUp()
 {
     rmssystem = new RMSSystem(Guid.NewGuid(), "description");
 }