public void AddReport(Report report) { var dateKey = report.Date.ToString("yyyy-MM"); reports[dateKey] = report; StatsReport statsReport = null; if (!statsReports.TryGetValue(dateKey, out statsReport)) { statsReport = new StatsReport();; statsReports[dateKey] = statsReport; } var items = report.Item; if (!string.IsNullOrEmpty(items)) { foreach (var split in items.Split(')')) { switch (split + ")") { case "(1)": statsReport.IncreateItem1(); break; case "(2)": statsReport.IncreateItem2(); break; case "(3)": statsReport.IncreateItem3(); break; case "(4)": statsReport.IncreateItem4(); break; case "(5)": statsReport.IncreateItem5(); break; case "(6)": statsReport.IncreateItem6(); break; default: break; } } } }
private MamaChurnCS(string[] args) { try { if (parseCommandLine(args)) { // Start up the underlying API initializeMama(); try { // Create all of the subscriptions createSubscriptions(); try { // Create the autoreset event that will be used to shutdown m_killEvent = new ManualResetEvent(false); // Create a spearate thread to perform the churn m_churnThread = new Thread(new ThreadStart(this.ChurnThreadProc)); m_churnThread.IsBackground = true; m_churnThread.Name = "destroyerThread: "; m_churnThread.Start(); stats = new StatsReport(mamaDefaultQueue); // If the timeout has been supplied then create a new timer if (m_killTimeout > 0) { MamaTimer killTimer = new MamaTimer(); killTimer.create(Mama.getDefaultEventQueue(mamaBridge), new KillTimerCallback(mamaBridge), m_killTimeout, null); } // Keep procssing messages until the kill timer elapses Mama.start(mamaBridge); // Destroy the stats timer stats.destroy(); // Kill the churn thread by signaling the auto reset event m_killEvent.Set(); // Wait until the thread terminates m_churnThread.Join(); } finally { // Stop processing all the queues mamaQueueGroup.stop(); // Destroy all the subscriptions for (int subIndex = 0; subIndex < mamaSubscriptions.Length; subIndex++) { mamaSubscriptions[subIndex].destroy(); mamaSubscriptions[subIndex] = null; } } } finally { // Uninitialise the api unintializeMama(); } } } catch (Exception e) { Console.WriteLine(e.Message); } }