public async Task <ActionResult> GetDeviceDetails(string deviceId) { IEnumerable <DevicePropertyValueModel> propModels; var device = await _deviceLogic.GetDeviceAsync(deviceId); if (device == null) { throw new InvalidOperationException("Unable to load device with deviceId " + deviceId); } if (device.DeviceProperties == null) { throw new DeviceRequiredPropertyNotFoundException("'DeviceProperties' property is missing"); } DeviceDetailModel deviceModel = new DeviceDetailModel { DeviceID = deviceId, HubEnabledState = device.DeviceProperties.GetHubEnabledState(), DevicePropertyValueModels = new List <DevicePropertyValueModel>() }; propModels = _deviceLogic.ExtractDevicePropertyValuesModels(device); propModels = ApplyDevicePropertyOrdering(propModels); deviceModel.DevicePropertyValueModels.AddRange(propModels); // check if value is cellular by checking iccid property deviceModel.IsCellular = device.SystemProperties.ICCID != null; deviceModel.Iccid = device.SystemProperties.ICCID; // todo: try get rid of null checks return(PartialView("_DeviceDetails", deviceModel)); }
private void OnItemSelect(object obj) { DeviceDetailModel model = (DeviceDetailModel)obj; model.IsChecked = !model.IsChecked; //throw new NotImplementedException(); }
public IActionResult Detail(int id) { var device = _devices.GetById(id); var currentHolds = _checkouts.GetCurrentHolds(id).Select(dev => new DeviceHoldModel { HoldPlaced = _checkouts.GetCurrentHoldPlaced(dev.Id).ToString("d"), UserName = _checkouts.GetCurrentHoldUserName(dev.Id) }); var model = new DeviceDetailModel { Id = id, Description = device.Description, OS = device.OS, Status = device.Status.Description, CurrentLocation = device.Site.Name, ImageUrl = device.ImageUrl, CheckoutHistory = _checkouts.GetCheckoutHistory(id), LatestCheckout = _checkouts.GetLatestCheckout(id), UserName = _checkouts.GetCurrentCheckoutUser(id), CurrentHolds = currentHolds }; return(View(model)); }
public static DeviceDetailModel ToDeviceDetailModel(this JObject jobject) { if (jobject == null) { return(null); } var retVal = new DeviceDetailModel(); retVal.DeviceName = (string)jobject.Property("deviceName").Value; retVal.LastTelemetry = jobject.ToDeviceTelemetryModel(); var historyData = jobject.Property("historyData").Value.ToObject <Dictionary <DateTimeOffset, DeviceData> >(); if (historyData != null) { retVal.TelemetryHistory = historyData .Select(kv => new DeviceTelemetryModel() { Timestamp = kv.Key, Temperature = kv.Value.Temperature, Humidity = kv.Value.Humidity }) .OrderBy(v => v.Timestamp) .ToList(); } return(retVal); }
public async Task <ActionResult> GetDeviceDetails(string deviceId) { IEnumerable <DevicePropertyValueModel> propModels; dynamic device = await _deviceLogic.GetDeviceAsync(deviceId); if (object.ReferenceEquals(device, null)) { throw new InvalidOperationException("Unable to load device with deviceId " + deviceId); } DeviceDetailModel deviceModel = new DeviceDetailModel() { DeviceID = deviceId, HubEnabledState = DeviceSchemaHelper.GetHubEnabledState(device), DevicePropertyValueModels = new List <DevicePropertyValueModel>() }; propModels = _deviceLogic.ExtractDevicePropertyValuesModels(device); propModels = ApplyDevicePropertyOrdering(propModels); deviceModel.DevicePropertyValueModels.AddRange(propModels); return(PartialView("_DeviceDetails", deviceModel)); }
public async Task <ActionResult> GetDeviceDetails(string deviceId) { IEnumerable <DevicePropertyValueModel> propModels; dynamic device = await _deviceLogic.GetDeviceAsync(deviceId); if (object.ReferenceEquals(device, null)) { throw new InvalidOperationException("Unable to load device with deviceId " + deviceId); } DeviceDetailModel deviceModel = new DeviceDetailModel { DeviceID = deviceId, HubEnabledState = DeviceSchemaHelper.GetHubEnabledState(device), DevicePropertyValueModels = new List <DevicePropertyValueModel>() }; propModels = _deviceLogic.ExtractDevicePropertyValuesModels(device); propModels = ApplyDevicePropertyOrdering(propModels); deviceModel.DevicePropertyValueModels.AddRange(propModels); // check if value is cellular by checking iccid property deviceModel.IsCellular = device.SystemProperties.ICCID != null; deviceModel.Iccid = device.SystemProperties.ICCID; // todo: try get rid of null checks return(PartialView("_DeviceDetails", deviceModel)); }
public void MapToDeviceDetailModel(DeviceDetailModel deviceDetailModel, DeviceDetail deviceDetail) { if (deviceDetail == null) { return; } deviceDetailModel.Id = deviceDetail.Id; deviceDetailModel.DeviceName = deviceDetail.DeviceName; deviceDetailModel.LinkedUserId = deviceDetail.LinkedUserId; }
public static DeviceDetailModel ToDeviceDetailModel(this DurableEntityStatus entity) { if (entity == null) { return(null); } var retVal = new DeviceDetailModel(); var jobject = entity.State as JObject; if (jobject != null) { retVal = jobject.ToDeviceDetailModel(); } retVal.DeviceId = entity.EntityId.EntityKey; return(retVal); }
public async Task <ActionResult> GetDeviceDetails(string deviceId) { IEnumerable <DevicePropertyValueModel> propModels; dynamic device = await this._deviceLogic.GetDeviceAsync(deviceId); if (object.ReferenceEquals(device, null)) { throw new InvalidOperationException("Unable to load device with deviceId " + deviceId); } double version = 1.0; string strversion = DeviceSchemaHelper.GetDeviceVersion(device); if (!string.IsNullOrEmpty(strversion)) { double.TryParse(strversion.Trim(), out version); } DeviceDetailModel deviceModel = new DeviceDetailModel { DeviceID = deviceId, HubEnabledState = DeviceSchemaHelper.GetHubEnabledState(device), DevicePropertyValueModels = new List <DevicePropertyValueModel>(), DeviceIsNewGeneration = version > Device_Version_1_0 ? true : false }; propModels = this._deviceLogic.ExtractDevicePropertyValuesModels(device); propModels = ApplyDevicePropertyOrdering(propModels); deviceModel.DevicePropertyValueModels.AddRange(propModels); // check if value is cellular by checking iccid property deviceModel.IsCellular = device.SystemProperties.ICCID != null; deviceModel.Iccid = device.SystemProperties.ICCID; // todo: try get rid of null checks return(this.PartialView("_DeviceDetails", deviceModel)); }
private void BackWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { try { foreach (DeviceDetailInfo deviceInfo in deviceDetails) { foreach (DeviceDetailInfo.DataInfo data in deviceInfo.deviceInfo) { DeviceDetailModel mdl = new DeviceDetailModel(); mdl.DeviceName = data.deviceName; mdl.DeviceStatus = "未知"; mdl.GroupName = deviceInfo.deviceGroupName; mdl.IpAddress = data.ipAddress; mdl.DeviceMac = data.macAddress; mdl.IsChecked = false; DeviceList.Add(mdl); } } } catch (Exception ex) { } }