//check to see if queue has items public void ProcessQueue() { //Check connection string _sqlConnectionManager.CheckIfDatabaseConnectable(); //check if items are in Queue var numberOfItemsInQueue = _dataHarmonizationService.GetPendingCountForAllActionRequests(); if (numberOfItemsInQueue != 0) { _logManager.LogMessage(numberOfItemsInQueue + " items in Queue"); while (numberOfItemsInQueue != 0) { //get first item in queue var firstPendingItem = GetFirstItemInQueue(); _logManager.LogMessage("Processing LicenseId " + firstPendingItem.LicenseId + ", Action Type: " + ReturnActionType(firstPendingItem.ActionTypeId)); if (firstPendingItem.ActionTypeId == 1) { //create _logManager.LogMessage("About to create snapshot for LicenseId " + firstPendingItem.LicenseId); _dataHarmonizationManager.CreateLicenseSnapshot(firstPendingItem.LicenseId, firstPendingItem); } else { //delete _logManager.LogMessage("About to delete snapshot for LicenseId " + firstPendingItem.LicenseId); _dataHarmonizationManager.DeleteLicenseSnapshot(firstPendingItem.LicenseId, firstPendingItem); } _logManager.LogMessage("Finsihed Processing LicenseId: " + firstPendingItem.LicenseId + " Action: " + ReturnActionType(firstPendingItem.ActionTypeId)); numberOfItemsInQueue = _dataHarmonizationService.GetPendingCountForAllActionRequests(); _logManager.LogMessage(numberOfItemsInQueue + " items in Queue"); } } else { _logManager.LogMessage(numberOfItemsInQueue + " items in Queue. Queue is empty. Sleep for 5 seconds."); _dataProcessorService.PauseForXSeconds(5); } }