Beispiel #1
0
        internal void SaveValue(DTOs.External.DeviceValue value)
        {
            tKovanContext ctx = new tKovanContext();

            Models.EntityClass.DeviceValue deviceValue = new Models.EntityClass.DeviceValue();

            deviceValue = Utilities.Map <TeknolojiKovaniWebApi.Domain.Values.DTOs.External.DeviceValue, TeknolojiKovaniWebApi.Models.EntityClass.DeviceValue>(value, deviceValue);

            deviceValue.DataServerTime = DateTime.UtcNow.AddHours(3);
            deviceValue.DataDeviceTime = DateTime.UtcNow.AddHours(3);

            ProfileDomain profileDomain = new ProfileDomain();
            PropertyRead  property      = profileDomain.GetProperty(value.PropertyName);

            deviceValue.PropertyId = property.Id;

            DeviceDomain deviceDomain = new DeviceDomain();
            DeviceRead   device       = deviceDomain.GetDevice(value.DeviceId);

            deviceValue.EnvironmentId = device.EnvironmentId.Value;
            deviceValue.UserId        = device.UserId;

            ctx.DeviceValue.Add(deviceValue);
            ctx.SaveChanges();
        }
        public IHttpActionResult GetDeviceCommands()
        {
            Guid         currentDeviceId = StaticContext.GetCurrentDeviceId();
            DeviceDomain deviceDomain    = new DeviceDomain();

            string[] commands = deviceDomain.GetDeviceCommands(currentDeviceId);
            return(Ok(commands));
        }
        public IHttpActionResult GetDeviceConfig()
        {
            DeviceDomain deviceDomain    = new DeviceDomain();
            Guid         currentDeviceId = StaticContext.GetCurrentDeviceId();
            DeviceConfig config          = deviceDomain.GetDeviceConfig(currentDeviceId);

            return(Ok(config));
        }
 public RequestController()
 {
     _requestDomain          = new RequestDomain();
     _agencyDomain           = new AgencyDomain();
     _serviceITSupportDomain = new ServiceITSupportDomain();
     _serviceItemDomain      = new ServiceItemDomain();
     _deviceDomain           = new DeviceDomain();
     _ticketDomain           = new TicketDomain();
 }
 public AgencyController()
 {
     _agencyDomain           = new AgencyDomain();
     _serviceITSupportDomain = new ServiceITSupportDomain();
     _serviceItemDomain      = new ServiceItemDomain();
     _deviceDomain           = new DeviceDomain();
     _accountDomain          = new AccountDomain();
     _requestDomain          = new RequestDomain();
     _deviceTypeDomain       = new DeviceTypeDomain();
 }
Beispiel #6
0
        public void AddNewDevice(DeviceDomain deviceDomain, int userId)
        {
            var device = new Device
            {
                Name   = deviceDomain.Name,
                Number = deviceDomain.Number,
                Type   = deviceDomain.Type,
                UserId = deviceDomain.UserId
            };

            _userRepository.AddNewDevice(device, userId);
        }
Beispiel #7
0
        public void PingDevice(int tenantId, PingDeviceDomain pingDeviceDomain)
        {
            if (tenantId < 0)
            {
                throw new ArgumentNullException("Tennat Id must be set and valid");
            }

            if (pingDeviceDomain is null)
            {
                throw new ArgumentNullException("PingDeviceDomain cannot be null");
            }

            if (pingDeviceDomain.DeviceId <= 0)
            {
                throw new ArgumentNullException("Device Id must be valid");
            }

            if (pingDeviceDomain.ActionId <= 0)
            {
                throw new ArgumentNullException("Action Id must be valid");
            }

            if (string.Equals(pingDeviceDomain.Content, string.Empty))
            {
                throw new ArgumentException("Cannot send empty content to device");
            }

            // Get device and check if it is active
            DeviceDomain device = this._deviceRepository.GetDeviceById(pingDeviceDomain.DeviceId);

            if (!device.IsActive)
            {
                throw new ArgumentException("Device is no longer active");
            }

            _publishEndpoint.Publish <IPingDeviceReceived>(new
            {
                PingDeviceId = Guid.NewGuid(),
                TenantId     = tenantId,
                DeviceId     = pingDeviceDomain.DeviceId,
                ActionId     = pingDeviceDomain.ActionId,
                Content      = pingDeviceDomain.Content,
                Timestamp    = DateTime.Now
            });
        }
        public EntityListResult<Device> FindAll()
        {
            DeviceDomain DeviceDomain = new DeviceDomain(1, ATSCommon.Enums.LanguagesEnum.Arabic);
            EntityListResult<Device> entityListResult = new EntityListResult<Device>();
            try
            {
                entityListResult.ReturnedEntities = DeviceDomain.FindAll();
                if (DeviceDomain.ActionState.Status != ATSCommon.Enums.ActionStatusEnum.NoError)
                {
                    entityListResult.Message = DeviceDomain.ActionState.Result;
                }

            }
            catch (Exception ex)
            {
                entityListResult.Message = ex.Message;
            }
            return entityListResult;
        }
        public EntityResult<Device> Delete(Device entity)
        {
            EntityResult<Device> entityResult = new EntityResult<Device>();
            DeviceDomain deviceDomain = new DeviceDomain(1, ATSCommon.Enums.LanguagesEnum.Arabic);

            try
            {
                deviceDomain.Delete(entity);
                entityResult.ReturnedEntity = entity;
                if (deviceDomain.ActionState.Status != ATSCommon.Enums.ActionStatusEnum.NoError)
                {
                    entityResult.Message = deviceDomain.ActionState.Result;
                }

            }
            catch (Exception ex)
            {
                entityResult.Message = ex.Message;
            }
            return entityResult;
        }
Beispiel #10
0
        public static Device FromDomainModel(this Device obj, DeviceDomain domain)
        {
            if (obj == null)
            {
                obj = new Device();
            }

            obj.DeviceId       = domain.DeviceId;
            obj.Identifier     = domain.Identifier;
            obj.Description    = domain.Description;
            obj.Name           = domain.Name;
            obj.IsActive       = domain.IsActive;
            obj.IsDeleted      = domain.IsDeleted;
            obj.DeviceTypeId   = domain.DeviceTypeId;
            obj.DeviceStatusId = domain.DeviceStatusId;
            obj.TenantId       = domain.TenantId;
            obj.CreatedBy      = domain.AuditTrail.CreatedyById;
            obj.DateCreated    = domain.AuditTrail.DateCreated;
            obj.DeviceImage    = domain.DeviceImage;

            return(obj);
        }
        public EntityResult<Device> FindByID(int entityID)
        {
            EntityResult<Device> entityResult = new EntityResult<Device>();
            DeviceDomain deviceDomain = new DeviceDomain(1, ATSCommon.Enums.LanguagesEnum.Arabic);

            try
            {
                entityResult.ReturnedEntity = deviceDomain.FindByID(entityID);
                if (deviceDomain.ActionState.Status != ATSCommon.Enums.ActionStatusEnum.NoError)
                {
                    entityResult.Message = deviceDomain.ActionState.Result;
                }

            }
            catch (Exception ex)
            {
                entityResult.Message = ex.Message;
            }
            return entityResult;
        }
 public DeviceController()
 {
     _deviceDomain = new DeviceDomain();
 }
Beispiel #13
0
        public void GetDeviceById_Success()
        {
            DeviceDomain device = _deviceManipulation.GetDeviceById(1);

            Assert.AreEqual(1, device.DeviceId);
        }
Beispiel #14
0
 public ITSupporterController()
 {
     _ITSupporterDomain = new ITSupporterDomain();
     _accountDomain     = new AccountDomain();
     _deviceDomain      = new DeviceDomain();
 }
Beispiel #15
0
 public AgencyController()
 {
     _agencyDomain = new AgencyDomain();
     _deviceDomain = new DeviceDomain();
 }