public object UnBindPrinters(PrinterBaseViewModel unBindModel) { LogUtil.Info(string.Format("解绑打印设备,输入参数:{0}", JsonUtil.Serialize(unBindModel))); SingleInstance <PrinterService> .Instance.UnBindPrinters(unBindModel); return(OK()); }
public object DoUnBindPrinter(PrinterBaseViewModel unBindModel) { var url = string.Format("{0}/mcp/sys/unBindPrinters", apiurl); var parms = string.Format("access_token={0}&merchant_code={1}&printer_codes={2}", unBindModel.access_token.Trim(), unBindModel.merchant_code.Trim(), unBindModel.printer_codes.Trim()); var result = NetUtil.ResponseByPost(url, parms); ViewBag.Result = result; return(View("UnBindPrinter")); }
/// <summary> /// 解除打印机绑定 /// </summary> /// <param name="shopId">门店Id</param> /// <param name="printerCode">打印机设备号</param> /// <returns></returns> public object DoUnBindShopPrinter(long shopId, string printerCode) { object list = null; var db = new RepositoryFactory().BaseRepository().BeginTrans(); try { var printer = GetValidPrinter(shopId, printerCode); if (printer != null) { //获取访问令牌 var accessToken = GetAccessToken(); //执行解绑打印机 var errMsg = string.Empty; var unBindModel = new PrinterBaseViewModel(); unBindModel.access_token = accessToken; unBindModel.merchant_code = shopId.ToString(); unBindModel.printer_codes = printerCode; var isUnBind = DoUnBindPrinter(unBindModel, out errMsg); if (isUnBind) { //平台删除绑定关系 spServ.DeleteEntity(printer.PrinterCode); //删除打印机配置信息 pcServ.Delete(shopId, printer.PrinterCode); } else { throw new BusinessException(errMsg); } } db.Commit(); //返回门店打印机列表 list = GetShopPrinterList(shopId); } catch (Exception ex) { db.Rollback(); LogUtil.Error(string.Format("解绑打印机失败,参考消息:{0}", ex.Message)); throw new BusinessException(ex.Message); } return(list); }
/// <summary> /// 解绑打印机 /// </summary> /// <param name="unBindModel"></param> /// <returns></returns> public bool DoUnBindPrinter(PrinterBaseViewModel unBindModel, out string errMsg) { var isOk = false; var url = string.Format("{0}/mcp/sys/unBindPrinters", apiDomain); var parms = string.Format("access_token={0}&merchant_code={1}&printer_codes={2}", unBindModel.access_token.Trim(), unBindModel.merchant_code.Trim(), unBindModel.printer_codes.Trim().ToUpper()); var result = HttpRequestUtil.HttpPost(url, parms); var apiData = JsonUtil.ToObject <ApiDataQueryModel>(result); if (apiData != null) { isOk = apiData.status == 1; errMsg = isOk ? string.Empty : apiData.data.ToString(); } else { errMsg = "解除打印机失败"; } return(isOk); }