예제 #1
0
        public static void Print(string msg, Dictionary <string, Session> sessionPool, string sendIP)
        {
            string answerMsgType = Convert.ToInt32(TCPMessageType.打印小票).ToString();

            object msgObj        = Utils.DeserializeObject(msg);
            object ticketData    = Utils.GetJsonObjectValue(msgObj, "data");
            object ticketTypeObj = Utils.GetJsonObjectValue(ticketData, "ticketType");

            if (ticketTypeObj != null)
            {
                //获取票据参数
                var data = ((Dictionary <string, object>)ticketData)["ticketData"];
                Dictionary <string, object> dict = TicketBusiness.GetTicketParams(ticketTypeObj.ToString(), (Dictionary <string, object>)data);
                //打印票据
                PrintUtility printUtility = new PrintUtility(dict, SysConfigBusiness.PrinterName);
                printUtility.Print();
            }
            else
            {
                SendFailData(answerMsgType, sessionPool, sendIP, "小票类型不正确");
            }
        }