public string CreateMessage(InputData data, SensorDry sensor, House house) { StringBuilder body = new StringBuilder(); body.Append(house.Street); body.Append(house.Number); body.Append(sensor.Premises1.Name); body.Append(sensor.Door1.Name); body.Append(sensor.SensorDryType.Name); body.Append("изменил свое состояние на"); if (data.Data == 1) body.Append(sensor.SensorDryType.SensorDryValueType.Value1); else body.Append(sensor.SensorDryType.SensorDryValueType.Value0); return body.ToString(); }
public void DoWork(InputData data) { House house = HouseRepository.GetBySensorId(data.DeviceId); int warning = SensorDryRepository.GetWarningSensorByHouseId(house.Id); var context = GlobalHost.ConnectionManager.GetHubContext<SensorHub>(); context.Clients.Group(data.DeviceId.ToString()).updateSensor(new { SensorId = data.SensorId, Data = data.Data, Date = data.Date.ToString(), HouseId = house.Id.ToString(), Warning = warning.ToString() }); SensorDry sensor = SensorDryRepository.GetById(data.SensorId); if (sensor.Status != 0) { IEnumerable<AspNetUsers> Users = UserRepository.GetListByHouseId(house.Id); EmailNotification.Send(Users.Select(x => x.Email).ToList(), "Изменение состояние охраны", EmailNotification.CreateMessage(data, sensor, house)); } }