/* The DoorDash confirm api is a GET request, so we make that request * to confirm the DoorDash order, then we call the callback function with * the orderContainer and the retrieved HttpStatus code to update the UI. */ public static async Task ConfirmDoorDashOrder(OrderContainer orderCon, ConfirmOrderCallBack cb) { string apiURL = orderCon.Order.ConfirmURL; HttpResponseMessage res = await client.GetAsync(apiURL); cb(orderCon, res.StatusCode); return; }
/* The GrubHub confirm api is a POST request, so we make that request * to confirm the GrubHub order, then we call the callback function with * the orderContainer and the retrieved HttpStatus code to update the UI. */ public static async Task ConfirmGrubHubOrder(OrderContainer orderCon, ConfirmOrderCallBack cb) { string apiURL = orderCon.Order.ConfirmURL; //The 2nd StringContent param is required for PostAsync, it doesn't seem to do anything though HttpResponseMessage res = await client.PostAsync(apiURL, new StringContent("")); cb(orderCon, res.StatusCode); return; }
/* "E:T4FORM4.ZPL" Item Template * -------------------------------------------- * Index|CharLimit|FieldName | Example * 1 | 8 |"Item Count" |"100/100" * 2 | 10 |"Service" |"GrubHub" * 3 | 20 |"Customer Name" | * 4 | 15 |"Label Name" | * 5 | 40 |"Item Name" | * 6 | 5 |"Size" |"Large" * 7 | 3 |"Temperature" |"Hot" * 8 | 6 |"Ice Level" |"80% I" * 9 | 6 |"Sugar Level" |"50% S" * 10 | 14 |"Milk Subsitution"|"Whole Milk Sub" * 11 | 40 |"Toppings" |"Pearls, Pudding," * 12 | 48 |"Special Instructions1" * 13 | 48 |"Special Instructions2" */ public static bool PrintOrder(OrderContainer orderCon) { string[][] items = orderCon.OrderArray; bool printStatus = true; Debug.WriteLine("START: PrintOrder()"); try { if (printerConn == null) { //Get the connection to the printer driver printerConn = FindConnection(); if (printerConn == null) { orderCon.PrintStatus = "Error: Printer not detected"; Debug.WriteLine("Error: Printer not detected"); return(false); } } //We try to open the connection try { printerConn.Open(); } catch (Exception e) { Debug.WriteLine("Error: Cannot open connection" + e.Message); orderCon.PrintStatus = "Error: Cannot open connection"; return(false); } //The connection is open, so we get the instance of the printer and try to print try { ZebraPrinter printer = ZebraPrinterFactory.GetInstance(PrinterLanguage.ZPL, printerConn); Debug.WriteLine("PrinterOrder() - got printer instance"); for (int i = items.Length - 1; i > -1; i--) { printer.PrintStoredFormat(PrintTemplatePath, items[i]); } }catch (Exception e) { Debug.WriteLine("Error: " + e.Message); try { //We check the status of the printer to see why it failed, which takes a long time without a UsbStatus channel //which is why we only check if printing fails string status = CheckPrinterStatus(printerConn); if (status != "true") { Debug.WriteLine(status); orderCon.PrintStatus = status; return(false); } }catch (Exception e2) { Debug.WriteLine("Error: " + e2.Message); orderCon.PrintStatus = "Error: Connection error"; return(false); } }finally { printerConn.Close(); } } catch (ConnectionException e) { Debug.WriteLine($"Error discovering local printers: {e.Message}"); orderCon.PrintStatus = "Error: Can't discover local printers"; printStatus = false; } return(printStatus); }