// Close the form and process the wallets. public void doClose() { ModuleScanning.setScannedOut(scannedOut); // Actually process the scanned items! for (int i = 0; i <= (lstScanned.Items.Count - 1); i++) { ListViewItem item = lstScanned.Items[i]; // If the item exists, just update the quantity. Listener theListener = serviceLayer.GetListenerById(int.Parse(item.SubItems[0].Text)); if ((theListener != null)) { theListener.inOutRecords.Out8 = int.Parse(item.SubItems[1].Text); // Also adjust stock. theListener.Stock = theListener.Stock - int.Parse(item.SubItems[1].Text); theListener.LastOut = DateTime.Now; if (!serviceLayer.UpdateListener(theListener)) { Interaction.MsgBox("Error: Failed to update scan information on listener."); this.Close(); } serviceLayer.RecordScan(theListener.Wallet, ScanTypes.OUT); } } // Show message and close. exitMe = true; this.Close(); }
/// <summary> /// Update weekly stats /// </summary> public static void UpdateStatsWeek(IServiceLayer DBServiceLayer, bool updateInOuts = false) { WeeklyStats stats = DBServiceLayer.GetCurrentWeekStats(); stats.WeekNumber = DBServiceLayer.GetCurrentWeekNumber(); stats.ScannedIn = stats.ScannedIn + ModuleScanning.getScannedIn(); stats.ScannedOut = stats.ScannedOut + ModuleScanning.getScannedOut(); stats.TotalListeners = DBServiceLayer.GetCurrentListenerCount(); stats.PausedCount = DBServiceLayer.GetListenersByStatus(ListenerStates.PAUSED).Count; // Just update it if it already exists if (DBServiceLayer.WeeklyStatExistsForWeek(stats.WeekNumber)) { DBServiceLayer.UpdateWeeklyStats(stats); } else { DBServiceLayer.SaveWeekStats(stats); } // Update the in/outs if required if (updateInOuts) { // Update in/out stats. DBServiceLayer.UpdateListenerInOuts(); } }
// On load. private void formFinished_Load(object sender, EventArgs e) { ModuleGeneric.saveEndTime(); // Setup labels. int weeknumb = serviceLayer.GetCurrentWeekNumber(); lblStartTime.Text = ModuleGeneric.getStartTimeString(); lblFinishTime.Text = ModuleGeneric.getEndTimeString(); lblElapsedTime.Text = ModuleGeneric.getElapsedTimeString(); lblScannedIn.Text = ModuleScanning.getScannedIn().ToString(); lblScannedOut.Text = ModuleScanning.getScannedOut().ToString(); // Update the stats week ModuleGeneric.UpdateStatsWeek(serviceLayer, false); readyToExit = true; }
// Close the form and process the wallets. public void doClose() { ModuleScanning.setScannedIn(scannedIn); // Actually process the scanned items! for (int i = 0; i <= (lstScanned.Items.Count - 1); i++) { ListViewItem item = lstScanned.Items[i]; // If the item exists, just update the quantity. Listener theListener = serviceLayer.GetListenerById(int.Parse(item.SubItems[0].Text)); if ((theListener != null)) { theListener.inOutRecords.In8 = int.Parse(item.SubItems[1].Text); // Also adjust stock. theListener.Stock = theListener.Stock + int.Parse(item.SubItems[1].Text); // Are there more than 3 stock items? if (theListener.Stock > Listener.DEFAULT_STOCK) { int overStock = theListener.Stock; theListener.Stock = 3; MessageBox.Show("Listener with Wallet: " + theListener.Wallet + ", Name: " + theListener.GetNiceName() + " would have " + overStock + " stock after scanning in these wallets. " + Environment.NewLine + Environment.NewLine + "Please look for any old wallets and remove the labels before clicking OK to continue."); log.Warn("Listner " + theListener.GetNiceName() + " would have " + overStock + " stock after the scanning in. Limiting to " + Listener.DEFAULT_STOCK + " and displaying warning."); } // If the listener is active, we will be also sending it out if (theListener.Status.Equals(ListenerStates.ACTIVE)) { theListener.Stock = theListener.Stock - 1; // Increment scanned out count ModuleScanning.setScannedOut(ModuleScanning.getScannedOut() + 1); // Also update the last out time (as we will be updating this listener in a minute with out8 = 1). theListener.LastOut = DateTime.Now; } theListener.LastIn = DateTime.Now; if (!serviceLayer.UpdateListener(theListener)) { Interaction.MsgBox("Error: Failed to update scan information on listener."); log.Error("Error: Failed to update scan information on listener."); this.Close(); } else { log.Debug("Updated listener information."); } serviceLayer.RecordScan(theListener.Wallet, ScanTypes.IN); } } // Show message and close. MessageBox.Show("The " + scannedIn + " wallets you have scanned have been successfully processed." + Environment.NewLine + Environment.NewLine + "You can now load them with memory sticks and place them in GPO mailbags.", ModuleGeneric.getAppShortName(), MessageBoxButtons.OK); exitMe = true; // Update the new week stats ModuleGeneric.UpdateStatsWeek(serviceLayer, true); this.Close(); }