/// <summary> /// 获取打印机状态 /// </summary> /// <param name="Type">打印机型号</param> /// <returns></returns> public string GetStatusDYJ(string Type) { int state = -99; string msg = ""; try { state = Msprint.GetState(Type); if (state != 0) { if (state == 1) { msg = "打印机未连接,或未初始化,请联系管理员"; //......\n错误码[001] } if (state == 2) { msg = "色带已用完,请联系管理员"; //......\n错误码[002] } if (state == 3) { msg = "本机病历本已发完,请联系管理员"; //......\n错误码[003] } if (state == 4) { msg = "病历本堵塞,请联系管理员"; //......\n错误码[004] } if (state == 5) { msg = "本机病历本已经发完,请联系管理员"; //......\n错误码[005] } if (state == 6) { msg = "打印头温度异常,请联系管理员"; //......\n错误码[006] } if (state == 7) { msg = "抬压头异常,请联系管理员"; //......\n错误码[007] } if (state == 8) { msg = "打印机正在忙,请稍候重试"; //......\n错误码[008] } Msprint.Close(Type); return("{\"Code\":" + state + ",\"msg\":\"" + msg + "\"}"); } return("{\"Code\":" + state + ",\"msg\":\"" + msg + "\"}"); } catch (Exception e) { return("{\"Code\":-3,\"msg\":\"获取打印机状态异常!" + e.Message + "\"}"); } }
/// <summary> /// 关闭打印机 /// </summary> /// <param name="Type">打印机型号</param> /// <returns></returns> public string CloseDYJ(string Type) { int ret = -99; try { ret = Msprint.Close(Type); if (ret != 0) { return("{\"Code\":-5,\"msg\":\"关闭打印机串口失败\"}"); } } catch { return("{\"Code\":-6,\"msg\":\"关闭打印机失败\"}"); //"{\"Code\":-6,\"msg\":\"" + ee.Message + "\"}"; } return("{\"Code\":" + ret + ",\"msg\":\"关闭打印机成功\"}"); }