/// <summary> /// 修改直连设备信息 /// </summary> /// <param name="deviceId"></param> /// <param name="modifyDeviceInfoMode"></param> /// <returns></returns> public static string ModifyDeviceInfo(string deviceId, ModifyDeviceInfoMode modifyDeviceInfoMode) { //格式化json string json = Newtonsoft.Json.JsonConvert.SerializeObject(modifyDeviceInfoMode, Newtonsoft.Json.Formatting.Indented); string result = AuthenticationServer.GetNorthAPIContent($"dm/v1.2.0/devices/{deviceId}?appId={AuthenticationServer.AppID}", "PUT", json); return(result); }
/// <summary> /// 修改设备信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnModifyDevice_Click(object sender, EventArgs e) { //修改设备信息 try { ModifyDeviceInfoMode modifyDevice = new ModifyDeviceInfoMode(); string buildID2 = cboxBiuldInfo2.GetItemText(cboxBiuldInfo2.SelectedValue); string deviceId = cboxDeviceID2.GetItemText(cboxDeviceID2.SelectedValue); string deviceName = textBoxDeviceName2.Text; string deviceNodeId = cboxDeviceID2.GetItemText(cboxDeviceID2.Items[cboxDeviceID2.SelectedIndex]); string manufacturerId = textBoxManufacturerId.Text; string manufacturerName = textBoxManufacturerName.Text; string deviceType = textBoxDeviceType.Text; string model = textBoxModel.Text; string protocolType = textBoxProtocolType.Text; modifyDevice.name = textBoxDeviceName2.Text; modifyDevice.manufacturerId = textBoxManufacturerId.Text; modifyDevice.manufacturerName = textBoxManufacturerName.Text; modifyDevice.deviceType = textBoxDeviceType.Text; modifyDevice.model = textBoxModel.Text; modifyDevice.protocolType = textBoxProtocolType.Text; string Result = DevicesManageServer.ModifyDeviceInfo(deviceId, modifyDevice); Runtime.ShowLog("修改 设备 成功:" + Result); Runtime.ShowLog("请求响应的状态码:" + AuthenticationServer.httpStatusCode); MessageBox.Show("修改 设备 成功 " + Result, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { Runtime.ShowLog("!!! 修改 设备 失败!!! 详细:" + ex.Message); LogHelper.log.Error("!!! 修改 设备 失败!!! 详细:" + ex.Message); MessageBox.Show("!!! 修改 设备 失败!!! 详细:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }