예제 #1
0
        public Tbl_Devices PrepareDeviceDataModel(DevicesDetails devObj)
        {
            Tbl_Devices dev = new Tbl_Devices();

            dev.CreatedDate      = System.DateTime.Now;
            dev.DeviceId         = devObj.deviceId;
            dev.DeviceIp         = devObj.deviceIp;
            dev.DeviceName       = devObj.deviceName;
            dev.DeviceStatus     = devObj.deviceStatus;
            dev.IsDeleted        = devObj.isDeleted;
            dev.IsShutdownDevice = devObj.isShutdownDevice;
            return(dev);
        }
예제 #2
0
        public void SaveDeviceIfNotExists(DevicesDetails devObj)
        {
            try
            {
                entity = new MonitoringSystemEntities();
                var v = entity.Tbl_Devices.Where(p => p.DeviceId.Equals(devObj.deviceId)).FirstOrDefault();
                if (v != null)
                {
                    return;
                }

                entity.Tbl_Devices.Add(PrepareDeviceDataModel(devObj));
                entity.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #3
0
        public void UpdateDeviceIfNotExists(DevicesDetails devObj)
        {
            try
            {
                entity = new MonitoringSystemEntities();
                var dev = entity.Tbl_Devices.Where(p => p.DeviceId.Equals(devObj.deviceId) && p.IsDeleted == false).FirstOrDefault();
                if (dev == null)
                {
                    return;
                }

                dev.DeviceIp           = devObj.deviceId;
                dev.ScreenshotInterval = devObj.screenshotInterval;
                entity.SaveChanges();
            }
            catch (Exception)
            {
                throw;
            }
        }