public MessageTO getJobErrorResponse(MessageTO request) { MessageTO response = new MessageTO(); response.MessageType = MessageTypeTO.JobErrorResponse; if (request == null || request.Configuration == null || !request.Configuration.isCompleteConfiguration()) { response.MessageType = MessageTypeTO.Error; response.Error = "Incomplete ExtractorConfiguration parameter on request"; logging.Log.LOG("The ExtractorConfiguration object sent to the job error request handler is incomplete! Unable to process request"); //LOG.Error("The ExtractorConfiguration object sent to the job error request handler is incomplete! Unable to process request: " + request.Configuration.ToString()); return(response); } if (WorkStack == null) { logging.Log.LOG("The work stack is null for the job error request. Was everything setup correctly?"); //LOG.Debug("The work stack is null - was everything set up correctly?"); response.MessageType = MessageTypeTO.Error; response.Error = "WorkStack has not been initialized"; return(response); } // the remove function keys off the site code and vista file - those are the only params we need Extractors.Remove(new Extractor("", 0, request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File, DateTime.Now)); ActiveExtractions.Remove(request.Configuration); ErroredExtractions.Push(request.Configuration); // bug fix: some edge cases will allow duplicate configs to be added to stack - need to check not already there //bool alreadyOnStack = false; //if (WorkStack.Contains(request.Configuration)) //{ // //LOG.Debug("It looks like this job was already on the stack - no need to add it again"); // alreadyOnStack = true; //} // decided to temporarily stop adding errored jobs back to the stack to check for patterns in error site codes //if (!alreadyOnStack) //{ // LOG.Debug("Adding a job back to the work stack since the client reported an error while processing"); // ErroredExtractions.Push(request.Configuration); // ActiveExtractions.Remove(request.Configuration); // WorkStack.Push(request.Configuration); //} // end bug fix try { String sqlProvider = ConfigurationManager.AppSettings[config.AppConfigSettingsConstants.SqlProvider]; String connectionString = ConfigurationManager.AppSettings[config.AppConfigSettingsConstants.SqlConnectionString]; ISqlDao sqlDao = new SqlDaoFactory().getSqlDao(new SqlConnectionFactory().getConnection(sqlProvider, connectionString)); if (request.ExtractorReport != null) { try { logging.Log.LOG("Saving error report..."); sqlDao.saveReport(request.ExtractorReport); } catch (Exception exc) { //LOG.Error("Unable to save an extractor's report!", exc); } } sqlDao.unlockSite(request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File); //LOG.Debug("Successfully unlocked job so another client can process"); // should check site completion on job error reports too try { checkSiteCompleteAndTrigger(request.ExtractorReport.BatchId, request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File); } catch (Exception te) { /* problems with trigger file shouldn't effect extractor */ logging.Log.LOG("An error occured when checking trigger file creation criteria: " + te.ToString()); } } catch (Exception exc) { logging.Log.LOG("The call to unlock the extraction job for site " + request.Configuration.SiteCode + ", file " + request.Configuration.QueryConfigurations.RootNode.Value.File + " has failed unexpectedly"); logging.Log.LOG(exc.Message); response.MessageType = MessageTypeTO.Error; response.Error = exc.ToString(); return(response); } return(response); }
public MessageTO getJobCompletedResponse(MessageTO request) { MessageTO response = new MessageTO(); response.MessageType = MessageTypeTO.JobCompletedResponse; if (request == null || String.IsNullOrEmpty(request.Configuration.SiteCode) || String.IsNullOrEmpty(request.Configuration.QueryConfigurations.RootNode.Value.File)) { //LOG.Debug("Received an invalid job completed request from the client - unable to process: " + request.Configuration.ToString()); logging.Log.LOG("Problem with job complete request!"); response.MessageType = MessageTypeTO.Error; response.Error = "Invalid request!"; return(response); } try { String sqlProvider = ConfigurationManager.AppSettings[config.AppConfigSettingsConstants.SqlProvider]; String connectionString = ConfigurationManager.AppSettings[config.AppConfigSettingsConstants.SqlConnectionString]; ISqlDao sqlDao = new SqlDaoFactory().getSqlDao(new SqlConnectionFactory().getConnection(sqlProvider, connectionString)); if (request.ExtractorReport != null) { try { logging.Log.LOG("Saving successful job report..."); sqlDao.saveReport(request.ExtractorReport); } catch (Exception exc) { logging.Log.LOG("Unable to save extractors report: " + request.Configuration.SiteCode + " - " + request.Configuration.QueryConfigurations.RootNode.Value.File + ", " + exc.Message); } } // get last IEN from message and save to tracking table sqlDao.saveLastIen(request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File, request.ExtractorReport.StartIen, request.ExtractorReport.LastIen, request.ExtractorReport.BatchId); // unlock site from locks table sqlDao.unlockSite(request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File); // the remove function keys off the site code and vista file - those are the only params we need Extractors.Remove(new Extractor("", 0, request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File, DateTime.Now)); CompletedExtractions.Push(request.Configuration); ActiveExtractions.Remove(request.Configuration); // all done with site? try { checkSiteCompleteAndTrigger(request.ExtractorReport.BatchId, request.Configuration.SiteCode, request.Configuration.QueryConfigurations.RootNode.Value.File); } catch (Exception triggerExc) // shouldn't fail job complete request if there is a problem with this - we just won't create the trigger { logging.Log.LOG("An unexpected error occured when checking if it was ok to create the trigger for site " + request.Configuration.SiteCode + "\r\n\r\n" + triggerExc.ToString()); } response.Message = "Nice Work!"; } catch (Exception exc) { logging.Log.LOG(exc.Message); response.MessageType = MessageTypeTO.Error; response.Error = exc.ToString(); } // handle post process in separate thread Thread postProcessThread = new Thread(new ParameterizedThreadStart(RequestHandler.getInstance().postProcess)); postProcessThread.Start(request); return(response); }