/// <summary> /// 获取Iot /// </summary> /// <param name="id">Iot Id</param> public IIot GetIot(Guid id) { if (!_dicIotClients.TryGetValue(id, out IotClient client)) { byte[] byteId = id.ToByteArray(); uint typeId = BitConverter.ToUInt32(byteId, 0); if (!_dicIotTypes.TryGetValue(typeId, out Func <Guid, IIot> clientConstructor)) { return(null); } client = new IotClient() { Iot = clientConstructor.Invoke(id) }; lock (_dicIotClients) { _dicIotClients.Add(id, client); } } client.Lifetime = DateTime.Now.AddMinutes(10.0); return(client.Iot); }
public Storage(IotClient client) { this.Data = new Dictionary <string, List <string> >(); this.Station = new StationStorage(); this.IotClient = client; }
public JsonResult UpdateShadow(string deviceId, string[] jsonContent) { try { var deviceShadow = IotClient.UpdateShadowRaw(deviceId, jsonContent); return(Json(deviceShadow)); } catch (Exception ex) { Console.WriteLine("JsonResult UpdateShadow " + ex); } return(Json("")); }
public JsonResult GetShadow(string deviceId) { try { var deviceShadow = IotClient.GetShadowRaw(deviceId); return(Json(deviceShadow)); } catch (Exception ex) { Console.WriteLine("JsonResult GetShadow " + ex); } return(Json("")); }