/// <summary> /// 扫码获取设备信息 /// </summary> /// <param name="codeContent">二维码信息</param> /// <param name="userID">用户ID</param> /// <param name="sessionID">当前请求所在设备储存的SessionID</param> /// <returns>设备信息</returns> public JsonResult GetDeviceByQRCode(int userID, string sessionID, string codeContent) { ServiceResultModel <EquipmentInfo> result = new ServiceResultModel <EquipmentInfo>(); try { if (!CheckSessionID(userID, sessionID, result)) { return(MyJson(result, JsonRequestBehavior.AllowGet)); } if (string.IsNullOrEmpty(codeContent)) { result.SetFailed(ResultCodes.ParameterError, "二维码内容为空,请重新扫码");//您输入的codeContent参数不正确 } else { string strEquipmentID = codeContent.Split('=')[codeContent.Split('=').Count() - 1]; int equipmentID = 0; if (Int32.TryParse(strEquipmentID, out equipmentID) == false) { result.SetFailed(ResultCodes.ParameterError, "二维码参数不正确,请重新扫码");//您输入的codeContent参数不正确 return(MyJson(result, JsonRequestBehavior.AllowGet)); } EquipmentInfo info = this.equipmentManager.GetEquipment(equipmentID); if (info == null) { result.SetFailed(ResultCodes.ParameterError, "设备系统编号不正确,请重新扫码"); //您输入的设备系统编号不正确 } else { result.Data = info.Copy4App(); } } } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message); result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage); } return(MyJson(result, JsonRequestBehavior.AllowGet)); }