Esempio n. 1
0
        public static Person CreatePerson(string externalId = null, ExternalSystem system = null)
        {
            var entity = CreateExternalEntity <Person>(EntityType.Person, externalId: externalId, system: system);

            entity.Active = true;
            return(entity);
        }
Esempio n. 2
0
        public static AccessLog CreateAccessLog(string externalId  = null, ExternalSystem system = null,
                                                string personExtId = null,
                                                string portalExtId = null,
                                                string readerExtId = null,
                                                DateTime?accessed  = null,
                                                int accessType     = 0,
                                                int accessId       = 0,
                                                int personId       = 0,
                                                int portalId       = 0,
                                                int readerId       = 0)
        {
            var entity = CreateExternalEntity <AccessLog>(EntityType.AccessLog
                                                          , externalId: externalId, system: system, internalId: accessId);

            entity.Person = personExtId != null?CreatePerson(personExtId, system, personId) : entity.Person;

            entity.Portal = portalExtId != null?CreatePortal(portalExtId, system, portalId) : entity.Portal;

            entity.Reader = readerExtId != null?CreateReader(readerExtId, system, readerId) : entity.Reader;

            entity.Accessed   = accessed != null ? (DateTime)accessed : entity.Accessed;
            entity.AccessType = accessType;

            return(entity);
        }
Esempio n. 3
0
        public Model.ExternalSystem GetExternalSystem(string name, bool usePrefix = true)
        {
            var systemId = GetIntValue(name);
            var criteria = new Model.ExternalSystem {
                Id = systemId
            };
            var system = criteria.Get();

            if (system.Failed)
            {
                throw new ArgumentException(_task.LogError("{0} setting is not a valid external system.", name));
            }

            return(system.Entity);
        }
Esempio n. 4
0
        public static Location CreateLocation(string externalId = null, ExternalSystem system = null, int internalId = 0)
        {
            var entity = CreateExternalEntity <Location>(EntityType.Location, externalId: externalId, system: system, internalId: internalId);

            return(entity);
        }
Esempio n. 5
0
        public static Reader CreateReader(string externalId = null, ExternalSystem system = null, int internalId = 0)
        {
            var entity = CreateExternalEntity <Reader>(EntityType.Reader, externalId: externalId, system: system, internalId: internalId);

            return(entity);
        }
Esempio n. 6
0
        public static Portal CreatePortal(string externalId = null, ExternalSystem system = null, int internalId = 0)
        {
            var entity = CreateExternalEntity <Portal>(EntityType.Portal, externalId: externalId, system: system, internalId: internalId);

            return(entity);
        }
Esempio n. 7
0
        public static T CreateExternalEntity <T>(EntityType type, string externalId = null, ExternalSystem system = null, int internalId = 0)
            where T : ExternalEntity, new()
        {
            var entity = new T()
            {
                EntityType       = type,
                ExternalId       = externalId,
                ExternalSystem   = system,
                ExternalSystemId = system.Id,
                InternalId       = internalId
            };

            return(entity);
        }