public void should_GetDefault_Device() { var device = _deviceSetupService.GetDefault(); Assert.IsNotNull(device); Console.WriteLine(device); }
private void LoadInit() { var deviceJson = _settings.GetValue("device.id", ""); var hapiLocal = _settings.GetValue("hapi.local", ""); var theDeviceJson = _settings.GetValue("device.reg", ""); if (null == RegisteredDevice && !string.IsNullOrWhiteSpace(theDeviceJson)) { RegisteredDevice = JsonConvert.DeserializeObject <Device>(theDeviceJson); } else { RegisteredDevice = _deviceSetupService.GetDefault(); if (null != RegisteredDevice) { var json = JsonConvert.SerializeObject(RegisteredDevice); _settings.AddOrUpdateValue("device.reg", json); } } if (null == Device && !string.IsNullOrWhiteSpace(deviceJson)) { Device = JsonConvert.DeserializeObject <Device>(deviceJson); } else { Device = _deviceSetupService.GetDefault(); if (null == Device) { Device = new Device(); } else { var json = JsonConvert.SerializeObject(Device); _settings.AddOrUpdateValue("device.id", json); } } if (null == Local && !string.IsNullOrWhiteSpace(hapiLocal)) { Local = JsonConvert.DeserializeObject <ServerConfig>(hapiLocal); } else { Local = _deviceSetupService.GetLocal(); if (null == Local) { Local = new ServerConfig(); } else { var json = JsonConvert.SerializeObject(Local); _settings.AddOrUpdateValue("hapi.local", json); } } Address = Local.Address; }
private void LoadInit() { var deviceJson = _settings.GetValue("device.id", ""); var hapiLocal = _settings.GetValue("hapi.local", ""); if (null == Device && !string.IsNullOrWhiteSpace(deviceJson)) { Device = JsonConvert.DeserializeObject <Device>(deviceJson); } else { Device = _deviceSetupService.GetDefault(Serial); if (null == Device) { Device = new Device(); } else { var json = JsonConvert.SerializeObject(Device); _settings.AddOrUpdateValue("device.id", json); } } if (null == Local && !string.IsNullOrWhiteSpace(hapiLocal)) { Local = JsonConvert.DeserializeObject <ServerConfig>(hapiLocal); } else { Local = _deviceSetupService.GetLocal(); if (null == Local) { Local = new ServerConfig(); Local.Address = "http://data.kenyahmis.org:4747"; } else { var json = JsonConvert.SerializeObject(Local); _settings.AddOrUpdateValue("hapi.local", json); } } Url = Local.Address; }
private void LoadInit() { var deviceJson = _settings.GetValue("device.id", ""); var hapiCentral = _settings.GetValue("hapi.central", ""); var hapiLocal = _settings.GetValue("hapi.local", ""); if (null == Device && !string.IsNullOrWhiteSpace(deviceJson)) { Device = JsonConvert.DeserializeObject <Device>(deviceJson); } else { Device = _deviceSetupService.GetDefault(Serial); if (null == Device) { Device = new Device(); } else { var json = JsonConvert.SerializeObject(Device); _settings.AddOrUpdateValue("device.id", json); } } Code = Device.Code; if (null == Central && !string.IsNullOrWhiteSpace(hapiCentral)) { Central = JsonConvert.DeserializeObject <ServerConfig>(hapiCentral); } else { Central = _deviceSetupService.GetCentral(); if (null == Central) { Central = new ServerConfig(); } else { var json = JsonConvert.SerializeObject(Central); _settings.AddOrUpdateValue("hapi.central", json); } } CentralAddress = Central.Address; CentralName = Central.Name; if (null == Local && !string.IsNullOrWhiteSpace(hapiLocal)) { Local = JsonConvert.DeserializeObject <ServerConfig>(hapiLocal); } else { Local = _deviceSetupService.GetLocal(); if (null == Local) { Local = new ServerConfig(); } else { var json = JsonConvert.SerializeObject(Local); _settings.AddOrUpdateValue("hapi.local", json); } } LocalAddress = Local.Address; LocalName = Local.Name; }