示例#1
0
        public Msg <string> PrintKB(string code, string order_item_nr, string machine_nr)
        {
            Msg <string> msg = new Msg <string>();

            try
            {
                var req = new RestRequest(ApiConfig.PrintKBAction, Method.GET);
                req.RequestFormat = DataFormat.Json;
                req.AddParameter("code", code);
                req.AddParameter("order_item_nr", order_item_nr);
                req.AddParameter("machine_nr", machine_nr);

                Printer printer = PrinterConfig.Find(code);

                var res  = new ApiClient().Execute(req);
                var data = JSONHelper.parse <RecordSet>(res.Content);
                if (data != null && data.Count > 0)
                {
                    printer.Print(data);
                    msg.Result  = true;
                    msg.Content = "Print Sucess";
                }
                else
                {
                    msg.Content = "Print Fail, No Content";
                }
            }
            catch (Exception e)
            {
                msg.Content = e.Message;
                LogUtil.Logger.Error(e.Message);
            }
            return(msg);
        }
示例#2
0
        public Msg <string> Print(string code, string id, string printer_name = null, string copy = null)
        {
            Msg <string> msg = new Msg <string>();

            try {
                var req = new RestRequest(ApiConfig.PrintDataAction, Method.GET);
                req.RequestFormat = DataFormat.Json;
                req.AddParameter("code", code);
                req.AddParameter("id", id);
                Printer printer = PrinterConfig.Find(code);

                var res  = new APIClient().Execute(req);
                var data = parse <RecordSet>(res.Content);
                if (data != null && data.Count > 0)
                {
                    printer.Print(data, printer_name, copy);
                    msg.Result  = true;
                    msg.Content = "打印成功";
                }
                else
                {
                    msg.Content = "打印失败,无打印内容";
                }
            }
            catch (Exception e) {
                msg.Content = e.Message;
                LogUtil.Logger.Error(e.Message);
            }
            return(msg);
        }