public void doRing(Object threadContext) { string ringState = ""; bool hasError = false; moden md = new moden(); try { md.PortName = bean.portName; md.init(); md.openCmdEcho(); //AT+CPAS log("查询设备状态..."); if (md.getModenState() != 0) { log("设备忙,挂断"); md.hangsUp(); } md.reset(); md.checkSimCard(); if (Regex.IsMatch(bean.mobile, "\\d{11}")) { log("拨号:" + bean.mobile); md.ring(bean.mobile); log("等待结果:" + bean.mobile); ringState = md.getRingStat(); } else { ringState = "手机号码格式不正确"; } log("完成!"); } catch (Exception ex) { log(ex.Message); ringState += ex.Message; hasError = true; } finally { if (md != null && md.IsOpen) { try { md.Close(); } catch (Exception ex) { log(ex.Message); } } } form1.finishTestHandler(bean, ringState, hasError); }
public void doRing(Object threadContext) { string ringState=""; bool hasError = false; moden md = new moden(); try { md.PortName = bean.portName; md.init(); md.openCmdEcho(); //AT+CPAS log("查询设备状态..."); if (md.getModenState() != 0) { log("设备忙,挂断"); md.hangsUp(); } md.reset(); md.checkSimCard(); if (Regex.IsMatch(bean.mobile, "\\d{11}")) { log("拨号:" + bean.mobile); md.ring(bean.mobile); log("等待结果:" + bean.mobile); ringState = md.getRingStat(); } else { ringState = "手机号码格式不正确"; } log("完成!"); } catch (Exception ex) { log(ex.Message); ringState += ex.Message; hasError = true; } finally { if (md != null && md.IsOpen) { try { md.Close(); } catch (Exception ex) { log(ex.Message); } } } form1.finishTestHandler(bean, ringState, hasError); }