public static void LoadS2ImportTestData(RSMDB.RSMDataModelDataContext context, string prefix)
        {
            var s2 = context.ExternalSystems.FirstOrDefault(x => x.Id == S2In.Id);

            var factory = new StageFactory(context);

            //factory.createSetting(1001, string.Format("{0}.Repeat", prefix), "Allow S2 import task to repeat.", "true", 0, false, InputTypes.Checkbox, s2);
            //factory.createSetting(1002, string.Format("{0}.RepeatInterval", prefix), "S2 import repeat interval in minutes.", "3", 0, false, InputTypes.Text, s2);
            //factory.createSetting(1003, string.Format("{0}.LastAccessEvent", prefix), "Date time on last S2 record imported.", "", 0, false, InputTypes.Text, s2);
            //factory.createSetting(1004, string.Format("{0}.PersonImport", prefix), "Allow importing of People from S2.", "true", 0, false, InputTypes.Checkbox, s2);
            //factory.createSetting(1005, string.Format("{0}.ServiceAddress", prefix), "Appliance Address", "http://localhost", 2, true, InputTypes.Text, s2);
            //factory.createSetting(1006, string.Format("{0}.ServiceAccount", prefix), "S2 Service User Id", "asdfasasdfasd", 3, true, InputTypes.Text, s2);
            //factory.createSetting(1007, string.Format("{0}.ServicePassword", prefix), "S2 Service Password", "admin", 4, true, InputTypes.Password, s2);
            //factory.createSetting(1007, string.Format("{0}.ServicePassword", prefix), "S2 Service Password", "admin", 4, true, InputTypes.Password, s2);

            var location = factory.createLocation(name: "Location1", id: 1, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Location, "Location1", s2.Id, location.LocationID);

            var portal = factory.createPortal("Portal1", location.LocationID, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Portal, "Portal1", s2.Id, portal.Id);

            var reader = factory.createReader("Reader1", portal.Id, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Reader, "Reader1", s2.Id, reader.Id);

            context.SubmitChanges();
        }
Beispiel #2
0
        public void ExternalEntity_Get_Internal()
        {
            var externalId = "50";
            var id         = 1;
            var keys       = DataFactory.CreateExternalApplicationKey(EntityType.Person, externalId, S2In.Id, id);

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();
            }

            var criteria = new ExternalEntity
            {
                EntityType       = EntityType.Person,
                ExternalSystemId = S2In.Id,
                InternalId       = id
            };

            var result = criteria.GetKeys(SelectKeys.Internal);

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());
            Assert.IsNotNull(result.Entity, "Missing entity");
            Assert.IsNotNull(result.Entity.ExternalSystem, "Missing ExternalSystem entity");
            Assert.IsTrue(result.Entity.EntityType == EntityType.Person, "EntityType mismatch");
        }
Beispiel #3
0
        public void Person_Get_External()
        {
            var externalId = "50";
            var id         = 1;
            var person     = DataFactory.CreatePerson("John", "Smith", "middle");

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                context.Persons.InsertOnSubmit(person);
                context.SubmitChanges();

                id = person.PersonID;

                var keys = DataFactory.CreateExternalApplicationKey(EntityType.Person, externalId, S2In.Id, id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();
            }

            var criteria = new Person
            {
                EntityType       = EntityType.Person,
                ExternalSystemId = S2In.Id,
                ExternalId       = externalId
            };

            var result = criteria.Get();

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());
            Assert.IsNotNull(result.Entity, "Missing entity");
            Assert.IsNotNull(result.Entity.ExternalSystem, "Missing ExternalSystem entity");
            Assert.IsTrue(result.Entity.EntityType == EntityType.Person, "EntityType mismatch");
            Assert.IsTrue((result.Entity as ExternalEntity).InternalId == id, "Incorrect id for entity");
        }
Beispiel #4
0
        public Person CreateTestPerson(RSMDB.RSMDataModelDataContext context, string firstName, string middleName, string lastName, string employeeId, ExternalSystem system, Bitmap imageFile = null)
        {
            var key = context.ExternalApplicationKeys.FirstOrDefault(x => x.EntityType == "Person" && x.ExternalId == employeeId);

            if (key != null)
            {
                DeleteTestPerson(context, employeeId, system);
            }

            var person = StageFactory.CreatePerson(firstName, lastName, middleName);

            if (imageFile != null)
            {
                var ms = new MemoryStream();
                imageFile.Save(ms, ImageFormat.Jpeg);
                person.Image = ms.ToArray();
            }

            context.Persons.InsertOnSubmit(person);
            context.SubmitChanges();
            var modelPerson = person.ToModel();

            var keys = StageFactory.CreateExternalApplicationKey(EntityType.Person, employeeId, system.Id, person.Id);

            context.ExternalApplicationKeys.InsertOnSubmit(keys);
            context.SubmitChanges();
            keys.ToModel(modelPerson);

            return(modelPerson);
        }
Beispiel #5
0
        public static void LoadS2ImportTestData(RSMDB.RSMDataModelDataContext context, string prefix)
        {
            var s2 = context.ExternalSystems.FirstOrDefault(x => x.Id == S2In.Id);

            var factory = new StageFactory(context);

            factory.createSetting(s2, prefix, S2Import.Repeat);
            factory.createSetting(s2, prefix, S2Import.RepeatInterval, "3");
            factory.createSetting(s2, prefix, S2Import.LastAccessed);
            factory.createSetting(s2, prefix, S2Import.PersonImport, "true");
            factory.createSetting(s2, prefix, S2Import.ServiceAddress, "http://localhost");
            factory.createSetting(s2, prefix, S2Import.ServiceAccount, "asdfasasdfasd");
            factory.createSetting(s2, prefix, S2Import.ServicePassword, "admin");

            var location = factory.createLocation("Location1", action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Location, "Location1", s2.Id, location.LocationID);

            var portal = factory.createPortal("Portal1", location.LocationID, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Portal, "Portal1", s2.Id, portal.Id);

            var reader = factory.createReader("Reader1", portal.Id, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Reader, "Reader1", s2.Id, reader.Id);

            context.SubmitChanges();
        }
Beispiel #6
0
        public void AccessLog_Get_External()
        {
            var externalId = "Access50";
            var id         = 1;
            var locationId = 1;

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var person = DataFactory.CreatePerson("first", "last", "middle");
                context.Persons.InsertOnSubmit(person);
                context.SubmitChanges();
                var keys = DataFactory.CreateExternalApplicationKey(EntityType.Person, externalId, S2In.Id, person.PersonID);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);

                var location = DataFactory.CreateLocation("Location1");
                context.Locations.InsertOnSubmit(location);
                context.SubmitChanges();
                locationId = location.LocationID;

                var portal = DataFactory.CreatePortal("Portal1", locationId);
                context.Portals.InsertOnSubmit(portal);
                context.SubmitChanges();
                keys = DataFactory.CreateExternalApplicationKey(EntityType.Portal, externalId, S2In.Id, portal.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);

                var reader = DataFactory.CreateReader("Reader50", portal.Id);
                context.Readers.InsertOnSubmit(reader);
                context.SubmitChanges();
                keys = DataFactory.CreateExternalApplicationKey(EntityType.Reader, externalId, S2In.Id, reader.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);

                var access = DataFactory.CreateAccessHistory("Access50", person.PersonID, portal.Id, reader.Id, 30);
                context.AccessHistories.InsertOnSubmit(access);
                context.SubmitChanges();
                keys = DataFactory.CreateExternalApplicationKey(EntityType.AccessLog, externalId, S2In.Id, access.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();

                id = access.Id;
            }

            var criteria = new AccessLog
            {
                EntityType       = EntityType.AccessLog,
                ExternalSystemId = S2In.Id,
                ExternalId       = externalId
            };

            var result = criteria.Get();

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());
            Assert.IsNotNull(result.Entity, "Missing entity");
            Assert.IsNotNull(result.Entity.ExternalSystem, "Missing ExternalSystem entity");
            Assert.IsTrue(result.Entity.EntityType == EntityType.AccessLog, "EntityType mismatch");
            Assert.IsTrue((result.Entity as ExternalEntity).InternalId == id, "Incorrect id for entity");
        }
Beispiel #7
0
        public void LubrizolEmployeeImport_Execute()
        {
            var taskName = "LubrizolImportAPIStub";

            RSMModel.Person modelPerson;
            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                //Load settings.
                //Includes a field level filter on
                LoadLubrizolImportTestData(context, taskName);

                //Create an existing person that will be updated
                var person = StageFactory.CreatePerson("OrigFirst2", "OrigLast", "OrigMid");
                context.Persons.InsertOnSubmit(person);
                context.SubmitChanges();
                modelPerson = person.ToModel();

                var keys = StageFactory.CreateExternalApplicationKey(EntityType.Person, "2", S2In.Id, person.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();
                keys.ToModel(modelPerson);
            }

            Task            task   = null;
            Result <string> result = Result <string> .Success();

            try
            {
                task = Task.Create(taskName, new ServiceProfile());

                var import = task as RSM.Integration.S2.Import.People;
                result = import.Execute(null);
            }
            catch (Exception e)
            {
                Assert.Fail("Test exception! {0}", e.ToString());
            }

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());
            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var newPerson = context.Persons.FirstOrDefault(x => x.PersonID == modelPerson.InternalId);
                Assert.IsTrue(newPerson.MiddleName == modelPerson.MiddleName, "Middle name updated but not in field list to update.");
                Assert.IsTrue(newPerson.FirstName != modelPerson.FirstName, "First name should have been updated.");
                Assert.IsTrue(newPerson.Image != modelPerson.Image, "Image should have been updated.");

                var newKeys = context.ExternalApplicationKeys.FirstOrDefault(x => x.ExternalId == modelPerson.ExternalId && x.InternalId == modelPerson.InternalId && x.SystemId == modelPerson.ExternalSystemId && x.EntityType == Enum.GetName(typeof(EntityType), EntityType.Person));
                Assert.IsTrue(newKeys.ExternalEntityLastUpdated != null, "ExternalEntityLastUpdated should have been updated.");

                Assert.IsTrue(context.Persons.FirstOrDefault(x => x.UDF4 == null || x.UDF4.Length == 0) == null, "There should be no records with an empty UDF4 field due to field filter.");
            }
        }
Beispiel #8
0
        public virtual void Initialize()
        {
            Cleanup();

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var sysList = new List <RSMDB.ExternalSystem>()
                {
                    StageFactory.CreateExternalSystem(1, Constants.R1SMSystemName, RSMDB.ExternalSystemDirection.None),
                    StageFactory.CreateExternalSystem(2, "S2 Import", RSMDB.ExternalSystemDirection.Incoming),
                    StageFactory.CreateExternalSystem(3, "Track", RSMDB.ExternalSystemDirection.Outgoing),
                    StageFactory.CreateExternalSystem(4, "S2 Export", RSMDB.ExternalSystemDirection.Outgoing),
                    StageFactory.CreateExternalSystem(5, "PeopleSoft", RSMDB.ExternalSystemDirection.Incoming),
                };

                var settingsList = new List <RSMDB.Setting>()
                {
                    StageFactory.CreateSetting(1, "RuleEngineAllow", "Allow the R1SM rule engine to assign roles.", "false", 0, true, InputTypes.Checkbox, sysList[0]),
                    StageFactory.CreateSetting(2, "JobCodesFirst", "Show job codes before job titles when editing rules.", "false", 1, true, InputTypes.Checkbox, sysList[0]),
                    StageFactory.CreateSetting(3, "RequireAccessApproval", "Require approval of changes made by the rule engine", "false", 2, false, InputTypes.Checkbox, sysList[0]),
                    StageFactory.CreateSetting(4, "AdminPass", "New Admin Password", "Testing", 3, true, InputTypes.Password, sysList[0]),
                    StageFactory.CreateSetting(5, "LevelImport", "Allow importing of levels from S2.", "false", 1, true, InputTypes.Text, sysList[1]),
                    StageFactory.CreateSetting(6, "S2Import.ServiceAddress", "Appliance Address", "http://localhost", 2, true, InputTypes.Text, sysList[1]),
                    StageFactory.CreateSetting(7, "S2Import.PersonImport", "Allow importing of People from S2.", "true", 0, true, InputTypes.Checkbox, sysList[1]),
                    StageFactory.CreateSetting(8, "TrackExport.PersonExport", "Allow exporting of People to Track", "true", 0, true, InputTypes.Checkbox, sysList[2]),
                    StageFactory.CreateSetting(9, "TrackExport.LocationExport", "Allow exporting of Locations to Track", "true", 1, true, InputTypes.Checkbox, sysList[2]),
                    StageFactory.CreateSetting(10, "TrackExport.AccessExport", "Allow exporting of Access History to Track", "true", 2, true, InputTypes.Checkbox, sysList[2]),
                    StageFactory.CreateSetting(11, "S2Import.ServiceAccount", "S2 Service User Id", "asdfasasdfasd", 3, true, InputTypes.Text, sysList[1]),
                    StageFactory.CreateSetting(12, "S2Import.ServicePassword", "S2 Service Password", "admin", 4, true, InputTypes.Password, sysList[1]),
                    StageFactory.CreateSetting(13, "PersonExport", "Allow exporting of user data and roles to S2", "false", 0, false, InputTypes.Checkbox, sysList[1]),

                    StageFactory.CreateSetting(14, "S2Import.Repeat", "Allow S2 import task to repeat.", "true", 0, false, InputTypes.Checkbox, sysList[1]),
                    StageFactory.CreateSetting(15, "S2Import.RepeatInterval", "S2 import repeat interval in minutes.", "3", 0, false, InputTypes.Text, sysList[1]),
                    StageFactory.CreateSetting(16, "S2Import.LastAccessEvent", "Date time of last access record imported from S2.", "", 0, false, InputTypes.Text, sysList[1]),

                    StageFactory.CreateSetting(17, "TrackExport.ServiceAddress", "Appliance Address", "http://localhost", 2, true, InputTypes.Text, sysList[2]),
                    StageFactory.CreateSetting(18, "TrackExport.ServiceAccount", "Track Service User Id", "asdfasasdfasd", 3, true, InputTypes.Text, sysList[2]),
                    StageFactory.CreateSetting(19, "TrackExport.ServicePassword", "Track Service Password", "admin", 4, true, InputTypes.Password, sysList[2]),
                    StageFactory.CreateSetting(20, "TrackExport.LastAccessEvent", "Date time of last access record exported to Track.", "", 0, false, InputTypes.Text, sysList[2]),
                    StageFactory.CreateSetting(21, "TrackExport.SourceSystem", "System whose data will be exported to Track.", "", 0, false, InputTypes.Text, sysList[2]),
                    StageFactory.CreateSetting(22, "TrackExport.Repeat", "Allow Track export task to repeat.", "true", 0, false, InputTypes.Checkbox, sysList[2]),
                    StageFactory.CreateSetting(23, "TrackExport.RepeatInterval", "Track export repeat interval in minutes.", "3", 0, false, InputTypes.Text, sysList[2]),
                    StageFactory.CreateSetting(24, "TrackExport.LastAccessEvent", "Date time of last access record exported to Track.", "", 0, false, InputTypes.Text, sysList[2]),

                    StageFactory.CreateSetting(25, "S2Import.Contractors", "Comma delimited list of contractors to get from S2.", "S & B,Mustang", 0, false, InputTypes.Text, sysList[1]),
                };

                context.ExternalSystems.InsertAllOnSubmit(sysList);
                context.Settings.InsertAllOnSubmit(settingsList);
                context.SubmitChanges();
            }
        }
Beispiel #9
0
        public static void LoadTrackExportTestData(RSMDB.RSMDataModelDataContext context, string prefix)
        {
            var s2       = context.ExternalSystems.FirstOrDefault(x => x.Id == S2In.Id);
            var trackOut = context.ExternalSystems.FirstOrDefault(x => x.Id == TrackOut.Id);

            var factory = new StageFactory(context);

            factory.createSetting(trackOut, prefix, TrackExport.Repeat);
            factory.createSetting(trackOut, prefix, TrackExport.RepeatInterval);
            factory.createSetting(trackOut, prefix, TrackExport.LastAccessEvent);
            factory.createSetting(trackOut, prefix, TrackExport.PersonExport);
            factory.createSetting(trackOut, prefix, TrackExport.ServiceAddress, "http://localhost:8088/mockACS2TrackWebSvcSoap12");
            factory.createSetting(trackOut, prefix, TrackExport.Account);
            factory.createSetting(trackOut, prefix, TrackExport.Password);
            factory.createSetting(trackOut, prefix, TrackExport.SourceSystem, s2.Id.ToString());

            factory.createSetting(trackOut, prefix, TrackExport.LocationExport);
            factory.createSetting(trackOut, prefix, TrackExport.AccessExport);
            factory.createSetting(trackOut, prefix, TrackExport.EventCode);
            factory.createSetting(trackOut, prefix, TrackExport.SysId);
            factory.createSetting(trackOut, prefix, TrackExport.DataSource);
            factory.createSetting(trackOut, prefix, TrackExport.CompanyExport);

            var location = factory.createLocation("Location1", action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Location, "Location1", s2.Id, location.LocationID);
            factory.createExternalApplicationKey(EntityType.Location, "1", trackOut.Id, location.LocationID);

            var portal = factory.createPortal("Portal 1001", location.LocationID, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Portal, "1001", s2.Id, portal.Id);

            var reader = factory.createReader("Reader1", portal.Id, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Reader, "Reader1", s2.Id, reader.Id);

            var person = factory.createPerson("Jane", "Smith", null, UDFs: new Dictionary <int, string> {
                { 4, "Contractor Co1" }
            }, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Person, "Person1", s2.Id, person.Id);

            var start = DateTime.Now;

            for (var i = 0; i < 5; i++)
            {
                var extId  = string.Format("access{0}", i);
                var access = factory.createAccessHistory(extId, person.Id, portal.Id, reader.Id, (int)AccessType.Valid, accessed: start.Subtract(TimeSpan.FromMinutes(i)), action: EntityAction.InsertAndSubmit);
                factory.createExternalApplicationKey(EntityType.AccessLog, extId, s2.Id, access.Id);
            }
            context.SubmitChanges();
        }
Beispiel #10
0
        public static void LoadTrackExportTestData(RSMDB.RSMDataModelDataContext context, string prefix)
        {
            var s2       = context.ExternalSystems.FirstOrDefault(x => x.Id == S2In.Id);
            var trackOut = context.ExternalSystems.FirstOrDefault(x => x.Id == TrackOut.Id);

            var factory = new StageFactory(context);

            factory.createSetting(1001, string.Format("{0}.Repeat", prefix), "Allow task to repeat.", "true", 0, false, InputTypes.Checkbox, trackOut);
            factory.createSetting(1002, string.Format("{0}.RepeatInterval", prefix), "repeat interval in minutes.", "3", 0, false, InputTypes.Text, trackOut);
            factory.createSetting(1003, string.Format("{0}.LastAccessEvent", prefix), "Date time on last record exported.", "", 0, false, InputTypes.Text, trackOut);
            factory.createSetting(1004, string.Format("{0}.PersonExport", prefix), "Allow export of People.", "true", 0, false, InputTypes.Checkbox, trackOut);
            factory.createSetting(1005, string.Format("{0}.ServiceAddress", prefix), "Appliance Address", "http://localhost:8088/mockACS2TrackWebSvcSoap12", 2, true, InputTypes.Text, trackOut);
            factory.createSetting(1006, string.Format("{0}.ServiceAccount", prefix), "Service User Id", "asdfasasdfasd", 3, true, InputTypes.Text, trackOut);
            factory.createSetting(1007, string.Format("{0}.ServicePassword", prefix), "Service Password", "admin", 4, true, InputTypes.Password, trackOut);
            factory.createSetting(1008, string.Format("{0}.SourceSystem", prefix), "System whose data will be exported to Track.", s2.Id.ToString(), 0, false, InputTypes.Text, trackOut);

            factory.createSetting(1009, string.Format("{0}.LocationExport", prefix), "Allow exporting of Locations to Track", "true", 1, true, InputTypes.Checkbox, trackOut);
            factory.createSetting(10010, string.Format("{0}.AccessExport", prefix), "Allow exporting of Access History to Track", "true", 2, true, InputTypes.Checkbox, trackOut);
            factory.createSetting(10011, string.Format("{0}.EventCode", prefix), "Event Code value for export to Track.", "8", 0, false, InputTypes.Text, trackOut);
            factory.createSetting(10012, string.Format("{0}.SysId", prefix), "System Id value for export to Track.", "1", 0, false, InputTypes.Text, trackOut);
            factory.createSetting(10013, string.Format("{0}.DataSource", prefix), "DataSource value for export to Track.", "TSTLBZDB", 0, false, InputTypes.Text, trackOut);
            factory.createSetting(10014, string.Format("{0}.CompanyExport", prefix), "Allow exporting of Companies to Track", "true", 1, true, InputTypes.Checkbox, trackOut);

            var location = factory.createLocation("Location1", action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Location, "Location1", s2.Id, location.LocationID);
            factory.createExternalApplicationKey(EntityType.Location, "1", trackOut.Id, location.LocationID);

            var portal = factory.createPortal("Portal 1001", location.LocationID, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Portal, "1001", s2.Id, portal.Id);

            var reader = factory.createReader("Reader1", portal.Id, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Reader, "Reader1", s2.Id, reader.Id);

            var person = factory.createPerson("Jane", "Smith", null, UDFs: new Dictionary <int, string> {
                { 4, "Contractor Co1" }
            }, action: EntityAction.InsertAndSubmit);

            factory.createExternalApplicationKey(EntityType.Person, "Person1", s2.Id, person.Id);

            var start = DateTime.Now;

            for (var i = 0; i < 5; i++)
            {
                var extId  = string.Format("access{0}", i);
                var access = factory.createAccessHistory(extId, person.Id, portal.Id, reader.Id, (int)AccessType.Valid, accessed: start.Subtract(TimeSpan.FromMinutes(i)), action: EntityAction.InsertAndSubmit);
                factory.createExternalApplicationKey(EntityType.AccessLog, extId, s2.Id, access.Id);
            }
            context.SubmitChanges();
        }
Beispiel #11
0
        public Person CreateTestPerson(RSMDB.RSMDataModelDataContext context, string firstName, string middleName, string lastName, string employeeId, ExternalSystem system)
        {
            var person = StageFactory.CreatePerson(firstName, lastName, middleName);

            context.Persons.InsertOnSubmit(person);
            context.SubmitChanges();
            var modelPerson = person.ToModel();

            var keys = StageFactory.CreateExternalApplicationKey(EntityType.Person, employeeId, system.Id, person.Id);

            context.ExternalApplicationKeys.InsertOnSubmit(keys);
            context.SubmitChanges();
            keys.ToModel(modelPerson);

            return(modelPerson);
        }
Beispiel #12
0
        public void ExternalEntity_Update()
        {
            var externalId = "50";
            var id         = 1;
            var keys       = DataFactory.CreateExternalApplicationKey(EntityType.Person, externalId, S2In.Id, id);

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();
            }

            var lastUpdated = DateTime.Now;
            var criteria    = new ExternalEntity
            {
                EntityType       = EntityType.Person,
                ExternalSystemId = S2In.Id,
                InternalId       = id,
                ExternalUpdated  = lastUpdated
            };

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                criteria.UpdateKeys(context);
                context.SubmitChanges();
            }

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                keys = context.ExternalApplicationKeys.FirstOrDefault(x => x.InternalId == criteria.InternalId &&
                                                                      x.SystemId == criteria.ExternalSystemId &&
                                                                      x.EntityType == Enum.GetName(typeof(EntityType), criteria.EntityType));

                Assert.IsNotNull(keys, "Keys not created");
                Assert.IsTrue(keys.ExternalEntityLastUpdated != null, "LastUpdated value not updated");

                //NOTE: it is possible for conversion into the db to cause millisecond differences
                Assert.IsTrue(keys.ExternalEntityLastUpdated.ToString() == lastUpdated.ToString(), "LastUpdated value not the same");
            }
        }
Beispiel #13
0
        public void Portal_Get_External()
        {
            var externalId = "Portal50";
            var id         = 1;
            var locationId = 1;

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var location = DataFactory.CreateLocation("Location1");
                context.Locations.InsertOnSubmit(location);
                context.SubmitChanges();
                locationId = location.LocationID;

                var portal = DataFactory.CreatePortal("Portal1", locationId);
                context.Portals.InsertOnSubmit(portal);
                context.SubmitChanges();

                id = portal.Id;

                var keys = DataFactory.CreateExternalApplicationKey(EntityType.Portal, externalId, S2In.Id, id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();
            }

            var criteria = new Portal
            {
                EntityType       = EntityType.Portal,
                ExternalSystemId = S2In.Id,
                ExternalId       = externalId
            };

            var result = criteria.Get();

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());
            Assert.IsNotNull(result.Entity, "Missing entity");
            Assert.IsNotNull(result.Entity.ExternalSystem, "Missing ExternalSystem entity");
            Assert.IsTrue(result.Entity.EntityType == EntityType.Portal, "EntityType mismatch");
            Assert.IsTrue((result.Entity as ExternalEntity).InternalId == id, "Incorrect id for entity");
        }
Beispiel #14
0
        public static void LoadS2ImportTestData(RSMDB.RSMDataModelDataContext context, string prefix)
        {
            var s2 = context.ExternalSystems.FirstOrDefault(x => x.Id == S2In.Id);

            var factory = new StageFactory(context);

            factory.createSetting(s2, prefix, S2PeopleImport.Available);
            factory.createSetting(s2, prefix, S2PeopleImport.Repeat);
            factory.createSetting(s2, prefix, S2PeopleImport.RepeatInterval);
            factory.createSetting(s2, prefix, S2PeopleImport.ServiceAccount);
            factory.createSetting(s2, prefix, S2PeopleImport.ServicePassword);
            factory.createSetting(s2, prefix, S2PeopleImport.ImageImport);
            factory.createSetting(s2, prefix, S2PeopleImport.ServiceAddress, value: "http://localhost:8766/RSM.Integration.S2.Stub/RestService.svc/test");

            //Note: MiddleName intentionally left out for tests
            factory.createSetting(s2, prefix, S2PeopleImport.FieldsToUpdate, value: "FirstName,LastName,ExternalUpdated,Image,"
                                  + "udf1,udf2,udf3,udf4,udf5,udf6,udf7,udf8,udf9,udf10,udf11,udf12,udf13,udf14,udf15,udf16,udf17,udf18,udf19,udf20");

            //Field filter to exclude unwanted person records
            factory.createSetting("Filter.Person.udf4", "Field filter that excludes records with an empty udf4 value.", ".+", prefix, viewable: false, system: s2);

            context.SubmitChanges();
        }
Beispiel #15
0
        public virtual void Initialize()
        {
            Cleanup();

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var sysList = new List <RSMDB.ExternalSystem>()
                {
                    StageFactory.CreateExternalSystem(1, Constants.R1SMSystemName, RSMDB.ExternalSystemDirection.None),
                    StageFactory.CreateExternalSystem(2, "S2 Import", RSMDB.ExternalSystemDirection.Incoming),
                    StageFactory.CreateExternalSystem(3, "Track", RSMDB.ExternalSystemDirection.Outgoing),
                    StageFactory.CreateExternalSystem(4, "S2 Export", RSMDB.ExternalSystemDirection.Outgoing),
                    StageFactory.CreateExternalSystem(5, "PeopleSoft", RSMDB.ExternalSystemDirection.Incoming),
                    StageFactory.CreateExternalSystem(6, "Lubrizol In", RSMDB.ExternalSystemDirection.Incoming),
                    StageFactory.CreateExternalSystem(7, "Lubrizol Out", RSMDB.ExternalSystemDirection.Outgoing),
                };

                var factory      = new StageFactory(context);
                var settingsList = new List <RSMDB.Setting>()
                {
                    factory.createSetting(sysList[0], R1Setting.DefaultPrefix, R1Setting.RuleEngineAllow),
                    factory.createSetting(sysList[0], R1Setting.DefaultPrefix, R1Setting.JobCodesFirst),
                    factory.createSetting(sysList[0], R1Setting.DefaultPrefix, R1Setting.RequireAccessApproval),
                    factory.createSetting(sysList[0], R1Setting.DefaultPrefix, R1Setting.AdminPass, "Testing"),

                    factory.createSetting(sysList[1], S2Import.DefaultPrefix, S2Import.ServiceAddress, "http://localhost"),
                    factory.createSetting(sysList[1], S2Import.DefaultPrefix, S2Import.PersonImport),
                    factory.createSetting(sysList[1], S2Import.DefaultPrefix, S2Import.ServiceAccount, "asdfasasdfasd"),
                    factory.createSetting(sysList[1], S2Import.DefaultPrefix, S2Import.ServicePassword),
                    factory.createSetting(sysList[1], S2Import.DefaultPrefix, S2Import.Repeat),
                    factory.createSetting(sysList[1], S2Import.DefaultPrefix, S2Import.RepeatInterval, "3"),
                    factory.createSetting(sysList[1], S2Import.DefaultPrefix, S2Import.LastAccessed),

                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.Available),
                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.Repeat),
                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.RepeatInterval),
                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.ServiceAddress, "http://10.1.1.234/goforms/nbapi"),
                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.ServiceAccount, "admin"),
                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.ServicePassword, "072159245241245031239120017047219193126250124056"),
                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.ImageImport),
                    factory.createSetting(sysList[1], S2PeopleImport.DefaultPrefix, S2PeopleImport.FieldsToUpdate, "FirstName,MiddleName,LastName,ExternalUpdated,Image,"
                                          + "udf1,udf2,udf3,udf4,udf5,udf6,udf7,udf8,udf9,udf10,udf11,udf12,udf13,udf14,udf15,udf16,udf17,udf18,udf19,udf20"),

                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.Available),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.Repeat),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.RepeatInterval),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.ServiceAddress, "http://localhost"),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.Account),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.Password),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.SourceSystem, ""),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.PersonExport),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.LocationExport),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.AccessExport),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.LastAccessEvent),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.LocationId),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.EventCode, ""),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.SysId, ""),
                    factory.createSetting(sysList[2], TrackExport.DefaultPrefix, TrackExport.DataSource, ""),

                    factory.createSetting(sysList[5], LubrizolImport.DefaultPrefix, LubrizolImport.Available),
                    factory.createSetting(sysList[5], LubrizolImport.DefaultPrefix, LubrizolImport.Repeat),
                    factory.createSetting(sysList[5], LubrizolImport.DefaultPrefix, LubrizolImport.RepeatInterval),
                    factory.createSetting(sysList[5], LubrizolImport.DefaultPrefix, LubrizolImport.SqlConnection),

                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.Available),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.Repeat),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.RepeatInterval),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.ServiceAddress),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.Account),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.Password),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.LastUpdated),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.SourceSystem),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.ActiveEmployeeLibrary),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.InactiveEmployeeLibrary),
                    factory.createSetting(sysList[6], LubrizolExport.DefaultPrefix, LubrizolExport.SqlConnection),
                };

                context.ExternalSystems.InsertAllOnSubmit(sysList);
                context.Settings.InsertAllOnSubmit(settingsList);
                context.SubmitChanges();
            }
        }
Beispiel #16
0
        public void AccessLog_AddBadFilter()
        {
            var externalId = "Access50";
            var id         = 1;
            var locationId = 1;

            var criteria = new AccessLog
            {
                EntityType       = EntityType.AccessLog,
                ExternalSystemId = S2In.Id,
                ExternalId       = externalId
            };

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var person = DataFactory.CreatePerson("first", "last", "middle", null, false, false, null, null, false, null, null, "Test", null, new Dictionary <int, string>()
                {
                    { 4, "S & B" }
                });
                context.Persons.InsertOnSubmit(person);
                context.SubmitChanges();
                var keys = DataFactory.CreateExternalApplicationKey(EntityType.Person, externalId, S2In.Id, person.PersonID);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();

                var location = DataFactory.CreateLocation("Location1");
                context.Locations.InsertOnSubmit(location);
                context.SubmitChanges();
                locationId = location.LocationID;
                context.SubmitChanges();

                var portal = DataFactory.CreatePortal("Portal1", locationId);
                context.Portals.InsertOnSubmit(portal);
                context.SubmitChanges();
                keys = DataFactory.CreateExternalApplicationKey(EntityType.Portal, externalId, S2In.Id, portal.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();

                var reader = DataFactory.CreateReader("Reader50", portal.Id);
                context.Readers.InsertOnSubmit(reader);
                context.SubmitChanges();
                keys = DataFactory.CreateExternalApplicationKey(EntityType.Reader, externalId, S2In.Id, reader.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);
                context.SubmitChanges();

                criteria.PersonId   = person.PersonID;
                criteria.PortalId   = portal.Id;
                criteria.ReaderId   = reader.Id;
                criteria.AccessType = (int)AccessType.Valid;
                criteria.Accessed   = DateTime.Now.Subtract(TimeSpan.FromMinutes(10));
            }

            var result = criteria.Add();

            result.Entity.Person.ExternalId = externalId;
            result.Entity.Reader.ExternalId = externalId;
            result.Entity.Portal.ExternalId = externalId;

            var filterTest = new Integration.S2.Import.AccessHistory();

//            filterTest.Configuration =
            filterTest.Load();

            Assert.IsFalse(filterTest.Filter(result.Entity), "Filter did not remove!");
        }
Beispiel #17
0
        public void AccessLog_Add()
        {
            var externalId = "Access50";
            var id         = 1;
            var locationId = 1;

            var criteria = new AccessLog
            {
                EntityType       = EntityType.AccessLog,
                ExternalSystemId = S2In.Id,
                ExternalId       = externalId
            };

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var person = DataFactory.CreatePerson("first", "last", "middle");
                context.Persons.InsertOnSubmit(person);
                context.SubmitChanges();
                var keys = DataFactory.CreateExternalApplicationKey(EntityType.Person, externalId, S2In.Id, person.PersonID);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);

                var location = DataFactory.CreateLocation("Location1");
                context.Locations.InsertOnSubmit(location);
                context.SubmitChanges();
                locationId = location.LocationID;

                var portal = DataFactory.CreatePortal("Portal1", locationId);
                context.Portals.InsertOnSubmit(portal);
                context.SubmitChanges();
                keys = DataFactory.CreateExternalApplicationKey(EntityType.Portal, externalId, S2In.Id, portal.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);

                var reader = DataFactory.CreateReader("Reader50", portal.Id);
                context.Readers.InsertOnSubmit(reader);
                context.SubmitChanges();
                keys = DataFactory.CreateExternalApplicationKey(EntityType.Reader, externalId, S2In.Id, reader.Id);
                context.ExternalApplicationKeys.InsertOnSubmit(keys);

                criteria.PersonId   = person.PersonID;
                criteria.PortalId   = portal.Id;
                criteria.ReaderId   = reader.Id;
                criteria.AccessType = 123;
                criteria.Accessed   = DateTime.Now.Subtract(TimeSpan.FromMinutes(10));
            }

            var result = criteria.Add();

            Assert.IsNotNull(result, "Missing results");
            Assert.IsTrue(result.Succeeded, result.ToString());
            Assert.IsNotNull(result.Entity, "Missing entity");
            Assert.IsNotNull(result.Entity.ExternalSystem, "Missing ExternalSystem entity");
            Assert.IsTrue(result.Entity.EntityType == EntityType.AccessLog, "EntityType mismatch");
            Assert.IsTrue(result.Entity.InternalId > 0, "Invalid id");

            using (var context = new RSMDB.RSMDataModelDataContext())
            {
                var keys = context.ExternalApplicationKeys.FirstOrDefault(x => x.ExternalId == externalId &&
                                                                          x.SystemId == S2In.Id && x.EntityType == Enum.GetName(typeof(EntityType), EntityType.AccessLog));
                Assert.IsNotNull(keys, "Keys not created");

                var row = context.AccessHistories.FirstOrDefault(x => x.Id == keys.InternalId);
                Assert.IsNotNull(row, "AccessHistory not created");
            }
        }