예제 #1
0
        public void DoWorker(object state)
        {
            Core.Log.Info("商家DoWorker方法进入");
            var currentInfo = PrintHub.ConnectedUsers.FirstOrDefault(p => p.UserKey == _userKey);

            if (currentInfo == null)//如果已失去客户端连接,则结束
            {
                return;
            }

            int  printCount  = currentInfo.PrintCount;
            bool isAutoPrint = currentInfo.IsAutoPrint;

            if (isAutoPrint)
            {
                var orderIds = OrderApplication.GetOrderIdsByLatestTime(5, 0, CurrentUser.ShopId);//读取最近时间段内满足打印条件都的订单ID
                Core.Log.Info("商家取到订单了吗" + orderIds.Count);
                if (orderIds != null && orderIds.Count > 0)
                {
                    orderIds.ForEach(p =>
                    {
                        Core.Log.Info("商家开始调用客户端了吗,打印订单:" + p);

                        /*
                         * Clients.Client(currentInfo.ConnectionId).autoPrint(new PrintOrder()
                         * {
                         *  OrderId = p,
                         *  PrintCount = printCount
                         * });//无法检测是否打印成功*/
                    });
                }
            }
        }