/// <summary> /// Polls the database for new cases. Useful when the service is restarted and some jobs were submitted while the Windows Service was down /// </summary> private void databasePoll() { try { int rows = 0; do { DataTable dtPendingCases = bi.GetPendingCases(); rows = dtPendingCases == null ? 0 : dtPendingCases.Rows.Count; foreach (DataRow dr in dtPendingCases.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"); } } while (rows > 0); } catch (Exception ex) { // log errors but don't break on them. we want to keep the service running even if we experience issues. CreateDailyLogEntry("Error in service: " + ex.ToString() + ex.StackTrace); } }