/// <summary> /// This method is the main method of the Comparison Case child thread. Here, we determine the type of comparison we are running, run that comparsion, /// print the report, and send out an e-mail, close the case, and remove ourselves from the running threads list. /// </summary> /// <param name="o"></param> void ComparisonWorkerThreadMain(object o) { try { // set case to "processing" FSTService.CreateDailyLogEntry("Case Started"); string message = bi.UpdateCaseStatus(recordID, "P"); if (String.IsNullOrEmpty(message)) { FSTService.CreateDailyLogEntry(message + Environment.NewLine); } if (comparisonData.Bulk) { // process bulk comparison FSTService.CreateDailyLogEntry("Bulk Search Started"); StartBulkSearch(); FSTService.CreateDailyLogEntry("Bulk Search Ended and sending Email"); } else { // process individual comparison FSTService.CreateDailyLogEntry("Individual Comparison Started"); StarIndividualComparison(); FSTService.CreateDailyLogEntry("Individual Comparison Ended and sending Email"); } // set status to "processed" message = bi.UpdateCaseStatus(recordID, "Y"); if (String.IsNullOrEmpty(message)) { FSTService.CreateDailyLogEntry(message + Environment.NewLine); } FSTService.CreateDailyLogEntry("Case Ended"); // remove ourselves from the running cases list if (comparisonData.Bulk && (comparisonData.CompareMethodID == 13 || comparisonData.CompareMethodID == 17 || comparisonData.CompareMethodID == 14)) { FSTService.removeLongRunningCase(this); } else { FSTService.removeRunningCase(this); } SendEmail(); FSTService.CreateDailyLogEntry("Email Sent"); } catch (Exception ex) { // if we experience any error, we log it and remove ourselves from the running cases list FSTService.CreateDailyLogEntry(ex.Message + Environment.NewLine + ex.StackTrace); if (comparisonData.Bulk && (comparisonData.CompareMethodID == 13 || comparisonData.CompareMethodID == 14 || comparisonData.CompareMethodID == 17)) { FSTService.removeLongRunningCase(this); } else { FSTService.removeRunningCase(this); } } }
/// <summary> /// This method is called by the web service when a job gets sent by one of the clients. /// </summary> /// <param name="recordID"></param> internal void RunJob(string recordID) { // We spawn a temporary thread so the service can return to the client quickly. If this isn't done, the service throws exceptions from here as well as its own. ThreadPool.QueueUserWorkItem(new WaitCallback(delegate { DataTable dtPendingCase = bi.GetPendingCase(recordID); foreach (DataRow dr in dtPendingCase.Rows) { // check to see whether the case we have is a long-running job or a normal job and queue appropriately switch (dr["CompareMethod"].ToString()) { case "13": case "14": case "17": lock (jobQueueLock) if (dr["Compare_Type"].ToString() == "N") { jobQueue.Enqueue(dr); } else { longJobQueue.Enqueue(dr); } break; default: lock (jobQueueLock) jobQueue.Enqueue(dr); break; } // set the case status to processing bi.UpdateCaseStatus(dr["RecordID"].ToString(), "P"); } return; })); }