コード例 #1
0
 // GET api/cashregister
 public IEnumerable <string> Get()
 {
     try
     {
         byte[] data = new byte[] { 27, 112, 0, 25, 250 };
         PrintThroughDriver.SendStringToPrinter("POS58", Encoding.ASCII.GetString(data));
         return(new string[] { "value1", "sucess" });
     }
     catch (Exception)
     {
         return(new string[] { "value1", "fail" });
     }
 }
コード例 #2
0
        private void PrintToKitchen(RegisterSale registerSale, string tableName, List <Product> printList)
        {
            var printString = new StringBuilder();

            printString.Append(Encoding.ASCII.GetString(headerPrintMode));
            printString.Append(tableName + "\n\n");
            printString.Append(Encoding.ASCII.GetString(normalPrintMode));
            printString.Append("   Created Date: " + registerSale.SaleDate + "\n");

            printString.Append(Encoding.ASCII.GetString(menuPrintMode));
            printString.Append("    Printed Date: " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "\n\n");

            printString.Append(Encoding.ASCII.GetString(underlinePrintModeOn));
            printString.Append("Foor Order\n\n");
            printString.Append(Encoding.ASCII.GetString(underlinePrintModeOff));

            printString.Append(Encoding.ASCII.GetString(menuPrintMode));
            foreach (var product in printList)
            {
                printString.Append("\t" + product.Name + "\n");
            }

            printString.Append("\n\n");
            printString.Append(Encoding.ASCII.GetString(normalPrintMode));
            if (!string.IsNullOrEmpty(registerSale.Note))
            {
                printString.Append(Encoding.ASCII.GetString(underlinePrintModeOn));
                printString.Append("Notes:\n\n");
                printString.Append(Encoding.ASCII.GetString(underlinePrintModeOff));
                printString.Append(Encoding.ASCII.GetString(normalPrintMode));
                printString.Append(registerSale.Note + "\n");
            }

            if (!string.IsNullOrEmpty(registerSale.UserName))
            {
                printString.Append("User: "******"\n\n");
            var performCut = new byte[] { 29, 86, 66, 240 };

            printString.Append(Encoding.ASCII.GetString(performCut));
            PrintThroughDriver.SendStringToPrinter("EPSON TM-T88IV Receipt", printString.ToString());
        }