Ejemplo n.º 1
0
        private PrintResult Print(PrintConfigData printConfigData, Tbl_Scenic tbl_Scenic, Tbl_OrderDetail tbl_OrderDetail)
        {
            tbl_OrderDetail.UsedQuantity = tbl_OrderDetail.Quantity;
            tbl_OrderDetail.PrintCount++;
            if (tbl_OrderDetail.OrderStatus == (int)OrderDetailsDataStatus.Activate)
            {
                tbl_OrderDetail.OrderStatus = (int)OrderDetailsDataStatus.IsTaken;
            }

            _orderDetailService.Update(tbl_OrderDetail);
            var userInfo       = _enterpriseUserService.LoginForSession();
            var printOrderData = new PrintOrderData
            {
                OrderNo       = tbl_OrderDetail.OrderNo,
                TicketName    = tbl_OrderDetail.TicketName,
                Qunatity      = tbl_OrderDetail.Quantity,
                Price         = tbl_OrderDetail.Price,
                TotalAmount   = tbl_OrderDetail.Quantity * tbl_OrderDetail.Price,
                CertificateNo = tbl_OrderDetail.CertificateNO,
                QRcode        = SecurityExtension.DesEncrypt(tbl_OrderDetail.QRcode, DesKey.QrCodeKey),
                CreateTime    = tbl_OrderDetail.ValidityDateStart.ToString("yyyy-MM-dd"),
                PrintCount    = tbl_OrderDetail.PrintCount,
                RealName      = userInfo.RealName,
                UserName      = userInfo.UserName
            };

            if (tbl_Scenic != null)
            {
                printOrderData.ScenicName  = tbl_Scenic.ScenicName;
                printOrderData.ScenicPhone = tbl_Scenic.Tel;
            }
            return(_printGateway.Send(printOrderData, printConfigData));
        }
Ejemplo n.º 2
0
        public static PrintConfigData Get(string printKey)
        {
            var printConfigData = new PrintConfigData();
            var list            = GetSection();
            var data            = list.FirstOrDefault(a => a.Key == printKey);

            if (data != null)
            {
                printConfigData.Partner     = data.Partner;
                printConfigData.ApiKey      = data.ApiKey;
                printConfigData.MachineCode = data.MachineCode;
                printConfigData.MachineKey  = data.MachineKey;
                return(printConfigData);
            }
            return(null);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 打印报表
        /// </summary>
        /// <param name="data"></param>
        /// <param name="configData"></param>
        /// <returns></returns>
        public static PrintResult Send(PrintReportData data, PrintConfigData configData)
        {
            var text = GetReportContext(data);

            return(PrintHelper.Send(text, configData));
        }
Ejemplo n.º 4
0
 public PrintResult Send(PrintReportData data, PrintConfigData configData)
 {
     return(PrintReport.Send(data, configData));
 }
Ejemplo n.º 5
0
 public PrintResult Send(PrintOrderData data, PrintConfigData configData)
 {
     return(PrintHelper.Send(data, configData));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 打印
        /// </summary>
        /// <param name="text"></param>
        /// <param name="timeOut"></param>
        public static PrintResult Send(string text, PrintConfigData printConfigData, int timeOut = 10)
        {
            //用户id
            string partner = printConfigData.Partner;          //"21108";
            //apikey API 密钥
            string apikey = printConfigData.ApiKey;            //"2f12779e593499b981beb7fe9644bb934b9dada7";
            //机器码 终端编号
            string machine_code = printConfigData.MachineCode; //"4004547827";
            //终端密钥
            string machine_key = printConfigData.MachineKey;   //"6a7r3enumfbu";
            //接口地址
            string url = "http://open.10ss.net:8888";

            //时间戳
            string time = "";
            //签名
            string sign = "";

            #region 开始生成时间戳
            time = GetTimeSpan();
            #endregion

            #region 参数列表
            Dictionary <string, string> parameters = new Dictionary <string, string>();
            parameters.Add("machine_code", machine_code);
            parameters.Add("partner", partner);
            parameters.Add("time", time);
            #endregion

            //对apikey+(machine_code+partner+time)+mkey 进行签名加密
            sign = getSign(parameters, apikey, machine_key);

            PrintData data = new PrintData();
            data.Put("partner", partner);           //用户id
            data.Put("machine_code", machine_code); //机器码 终端编号
            data.Put("time", time);                 //时间戳
            data.Put("sign", sign);                 //签名
            data.Put("content", text);              //产生随机的商户订单号

            string response = HttpService.Post(url, data.ToUrl(), timeOut);

            JsonData jsonData = JsonMapper.ToObject(response);
            //服务器返回状态
            var state  = jsonData["state"].ToString();
            var result = new PrintResult {
                Success = false, Message = "系统繁忙,稍后再试"
            };
            if (state == "1")
            {
                result.Success = true;
                result.Message = "打印成功";
            }
            else if (state == "2")
            {
                result.Message = "打印失败,提交时间超时";
            }
            else if (state == "3")
            {
                result.Message = "打印失败,参数有误";
            }
            else if (state == "4")
            {
                result.Message = "打印失败,sign加密验证失败";
            }
            return(result);
            //Logger.Error("服务器错误:", actionExecutedContext.Exception);

            //state:"1","id":"1234"   数据提交成功,1234代表单号,打印完成上报时用、详情请查看:打印完成自动上报接口文档
            //state:"2"   提交时间超时。验证你所提交的时间戳超过3分钟后拒绝接受
            //state:"3"   参数有误
            //state:"4"   sign加密验证失败
        }
Ejemplo n.º 7
0
        public static PrintResult Send(PrintOrderData data, PrintConfigData configData)
        {
            var text = GetOrderContext(data);

            return(Send(text, configData));
        }