示例#1
0
        /// <summary>
        /// 打印订单及菜品信息
        /// </summary>
        async Task printDine(string dineId, List <int> dineMenuIds, List <PrintType> printTypes)
        {
            DineForPrinting dp = null;

            try {
                dp = await getDineForPrinting(dineId, dineMenuIds);

                if (dp == null)
                {
                    serverLog("获取订单信息失败,请检查网络设置", LogLevel.Error);
                    return;
                }

                serverLog($"发送打印命令 单号: {dineId}", LogLevel.Info);

                if (Config.IsIPPrinter)
                {
                    DinePrinter dinePrinter = new DinePrinter();
                    await dinePrinter.Print(dp, printTypes, dineMenuIds.Count == 0);
                }
                else
                {
                    DineDriverPrinter dineDriverPrinter = new DineDriverPrinter();
                    dineDriverPrinter.Print(dp, printTypes, dineMenuIds.Count == 0);
                }

                serverLog($"发送命令成功 单号: {dineId}", LogLevel.Success);
                printCompleted(dineId);
            }
            catch (Exception e) {
                serverLog($"无法打印 单号: {dineId}, 错误信息: {e.Message}", LogLevel.Error);
                remoteLog(Log.LogLevel.Error, $"DineId: {dineId}, {e.Message}", $"Data: {JsonConvert.SerializeObject(dp)}, Error: {e}");
            }
        }
示例#2
0
        /// <summary>
        /// 打印本地测试
        /// </summary>
        async Task printLocalTest(List <PrintType> printTypes, string ipOrName)
        {
            DineForPrinting dp = Config.GetTestProtocol(ipOrName);

            try {
                serverLog($"开始本地测试, 打印机: {ipOrName}", LogLevel.Info);
                serverLog($"发送本地测试单命令", LogLevel.Info);

                if (Config.IsIPPrinter)
                {
                    DinePrinter dinePrinter = new DinePrinter();
                    await dinePrinter.Print(dp, printTypes, true);
                }
                else
                {
                    DineDriverPrinter dineDriverPrinter = new DineDriverPrinter();
                    dineDriverPrinter.Print(dp, printTypes, true);
                }

                serverLog($"发送本地测试单命令成功", LogLevel.Success);
            }
            catch (Exception e) {
                serverLog($"无法打印本地测试单, 错误信息: {e.Message}", LogLevel.Error);
                remoteLog(Log.LogLevel.Error, $"Local Test, {e.Message}", $"Data: {JsonConvert.SerializeObject(dp)}, Error: {e}");
            }
        }
示例#3
0
        /// <summary>
        /// 打印远程测试
        /// </summary>
        async Task printRemoteTest(List <PrintType> printTypes, string ipOrName)
        {
            DineForPrinting dp = null;

            try {
                serverLog($"开始测试, 打印机: {ipOrName}", LogLevel.Info);
                dp = await getDineForPrinting("00000000000000");

                if (dp == null)
                {
                    serverLog("获取订单信息失败,请检查网络设置", LogLevel.Error);
                    return;
                }
                dp.Dine.Desk.ReciptPrinter.IpAddress = ipOrName;
                dp.Dine.Desk.ReciptPrinter.Name      = ipOrName;
                dp.Dine.Desk.ServePrinter.IpAddress  = ipOrName;
                dp.Dine.Desk.ServePrinter.Name       = ipOrName;
                foreach (var dineMenu in dp.Dine.DineMenus)
                {
                    dineMenu.Menu.Printer.IpAddress = ipOrName;
                    dineMenu.Menu.Printer.Name      = ipOrName;
                }

                serverLog($"发送测试单命令", LogLevel.Info);

                if (Config.IsIPPrinter)
                {
                    DinePrinter dinePrinter = new DinePrinter();
                    await dinePrinter.Print(dp, printTypes, true);
                }
                else
                {
                    DineDriverPrinter dineDriverPrinter = new DineDriverPrinter();
                    dineDriverPrinter.Print(dp, printTypes, true);
                }

                serverLog($"发送测试单命令成功", LogLevel.Success);
                printCompleted("00000000000000");
            }
            catch (Exception e) {
                serverLog($"无法打印测试单, 错误信息: {e}", LogLevel.Error);
                remoteLog(Log.LogLevel.Error, $"Online Test, {e.Message}", $"Data: {JsonConvert.SerializeObject(dp)}, Error: {e}");
            }
        }