Пример #1
0
 public IHttpActionResult UpdateStauts([FromBody] DeviceStatusDto model)
 {
     deviceStatusService.Save(model);
     return(Ok(new
     {
         code = 0,
         msg = "success"
     }));
 }
Пример #2
0
        private static ContextStatusDto GetOtmContextStatus(OtmContext ctx)
        {
            var ctxStatus = new ContextStatusDto
            {
                Name            = ctx.Config.Name,
                Enabled         = ctx.Config.Enabled,
                DeviceStatus    = new Dictionary <string, DeviceStatusDto>(),
                DataPointStatus = new Dictionary <string, DataPointStatusDto>()
            };

            if (ctx.Devices != null)
            {
                foreach (var device in ctx.Devices.Values)
                {
                    var deviceStatusDto = new DeviceStatusDto
                    {
                        Name          = device.Name,
                        Enabled       = device.Enabled,
                        Connected     = device.Connected,
                        LastErrorTime = device.LastErrorTime,
                        TagValues     = device.TagValues
                    };

                    ctxStatus.DeviceStatus[device.Name] = deviceStatusDto;
                }
            }

            if (ctx.DataPoints != null)
            {
                foreach (var dataPoint in ctx.DataPoints.Values)
                {
                    var datapointStatusDto = new DataPointStatusDto
                    {
                        Name          = dataPoint.Name,
                        DebugMessages = dataPoint.DebugMessages,
                        Script        = dataPoint.Script,
                        Driver        = dataPoint.Driver,
                    };

                    ctxStatus.DataPointStatus[dataPoint.Name] = datapointStatusDto;
                }
            }
            return(ctxStatus);
        }
Пример #3
0
        public void Save(DeviceStatusDto config)
        {
            //
            var entity = _statusRepository.GetById(config.DeviceUUID);

            if (entity != null)
            {
                entity            = config.ToEntity(entity);
                entity.UpdateTime = DateTime.Now;
                entity.SyncStatus = false;
                _statusRepository.Update(entity);
            }
            else
            {
                entity             = config.ToEntity();
                entity.CreateTime  = DateTime.Now;
                entity.UpdateTime  = DateTime.Now;
                entity.SyncStatus  = false;
                entity.SyncVersion = 0;
                _statusRepository.Insert(entity);
            }

            Synchronization(entity);
        }
Пример #4
0
 public static DeviceStatusEntity ToEntity(this DeviceStatusDto model, DeviceStatusEntity destination)
 {
     return(model.MapTo(destination));
 }
Пример #5
0
 public static DeviceStatusEntity ToEntity(this DeviceStatusDto model)
 {
     return(model.MapTo <DeviceStatusDto, DeviceStatusEntity>());
 }