private async Task DoDrinkWine( int workId, string sCode, string sNotes, WineInfo wni, bool fCheckOnly, bool fErrorSoundsOnly, // we ignore this for wines -- we don't do bulk wine scanning Guid crids, FinalScanCodeReportAndCleanupDelegate del) { string sCheck = fCheckOnly ? "[CheckOnly] " : ""; m_lp.LogEvent(crids, EventType.Verbose, "Service returned info for {0}", sCode); m_lp.LogEvent(crids, EventType.Verbose, "{1}Drinking wine {0}", sCode, sCheck); // now update the last scan date bool fResult = fCheckOnly || await DrinkWine(sCode, wni.Wine, wni.Vintage, sNotes, crids); if (fResult) { m_lp.LogEvent(crids, EventType.Verbose, "{1}Successfully drank wine for {0}", sCode, sCheck); m_isr.AddMessage(AlertType.Drink, "{1}{0}: Drank wine!", wni.Wine, sCheck); } else { m_lp.LogEvent(crids, EventType.Error, "Failed to drink wine {0}", sCode); m_isr.AddMessage(AlertType.BadInfo, "{0}: Failed to drink wine!", wni.Wine); } await del(workId, sCode, crids, wni.Wine, true); }
private async Task DoUpdateWineInventory( int workId, string sCode, string sBinCode, WineInfo wni, bool fCheckOnly, bool fErrorSoundsOnly, // we ignore this for wines -- we don't do bulk wine scanning Guid crids, FinalScanCodeReportAndCleanupDelegate del) { string sCheck = fCheckOnly ? "[CheckOnly] " : ""; m_lp.LogEvent(crids, EventType.Verbose, "Service returned info for {0}", sCode); m_lp.LogEvent(crids, EventType.Verbose, "{1}Updating inventory for wine {0} ({2})", sCode, sCheck, sBinCode); // now update the last scan date bool fResult = fCheckOnly || await UpdateWineInventory(sCode, wni.Wine, sBinCode, crids); if (fResult) { m_lp.LogEvent(crids, EventType.Verbose, "{1}Successfully updated inventory for wine for {0}", sCode, sCheck); m_isr.AddMessage(fErrorSoundsOnly ? AlertType.None : AlertType.GoodInfo, "{1}{0}: Updated inventory for wine!", wni.Wine, sCheck); } else { m_lp.LogEvent(crids, EventType.Error, "Failed to update inventory for wine {0}", sCode); m_isr.AddMessage(AlertType.BadInfo, "{0}: Failed to update inventory for wine!", wni.Wine); } await del(workId, sCode, crids, wni.Wine, true); }
public async Task DoHandleWineScanCode( int workId, string sCode, string sNotes, string sBinCode, bool fCheckOnly, bool fErrorSoundsOnly, Guid crids, FinalScanCodeReportAndCleanupDelegate del) { bool fInventory = sBinCode != null; if (sNotes.StartsWith("!!") && !fInventory) { m_isr.AddMessage(AlertType.BadInfo, "Notes not set: {0}", sNotes); await del(workId, sCode, crids, null, false); return; } string sTitle = null; m_lp.LogEvent(crids, EventType.Verbose, "Continuing with processing for {0}...Checking for WineInfo from service", sCode); WineInfo wni = await WineInfoRetrieve(sCode); if (wni != null) { string sOriginalCode = sCode; // we want to refresh the code to what we just retrieved, but first we have to capture the // original scancode so it can be sent to the delgate correctly FinalScanCodeReportAndCleanupDelegate delWrapper = async(int workIdDel, string scanCodeDel, Guid cridsDel, string sFinalTitleDel, bool fResultDel) => { await del(workIdDel, sOriginalCode, cridsDel, sFinalTitleDel, fResultDel); }; sCode = wni.Code; if (fInventory) { await DoUpdateWineInventory(workId, sCode, sBinCode, wni, fCheckOnly, fErrorSoundsOnly, crids, delWrapper); } else { await DoDrinkWine(workId, sCode, sNotes, wni, fCheckOnly, fErrorSoundsOnly, crids, delWrapper); } } else { m_isr.AddMessage(AlertType.BadInfo, "Could not find wine for {0}", sCode); sTitle = "!!WINE NOTE FOUND"; await del(workId, sCode, crids, sTitle, false); } }