Пример #1
0
 public static DeviceStateHistory CreateDeviceStateHistory(this DeviceStatusCommand item, Guid deviceId, string deviceName)
 {
     return(new DeviceStateHistory
     {
         DeviceId = deviceId,
         Name = deviceName,
         DeviceStateId = item.DeviceStateId,
         StateName = item.Name,
         Timestamp = item.Timestamp,
         Version = item.Version.Value
     });
 }
Пример #2
0
        public void Apply(DeviceStatusCommand statusUpdate)
        {
            this.DeviceStateId = statusUpdate.DeviceStateId;
            this.Name          = statusUpdate.Name;
            this.Timestamp     = statusUpdate.Timestamp;
            this.Version       = statusUpdate.Version.HasValue ? statusUpdate.Version.Value : this.Version++;

            if (this.History.ContainsKey(this.Version))
            {
                return;
            }

            this.History.Add(this.Version, new DeviceStatusHistory
            {
                DeviceStateId = this.DeviceStateId,
                Name          = this.Name,
                Timestamp     = this.Timestamp,
                Version       = this.Version
            });
        }