protected virtual bool DoExtract() { if (!_submissionTrackingDataType.ETLCompletionDateTimeSpecified || !_submissionTrackingDataType.DETChangeCompletionDateTimeSpecified) { // Attempt to run the ETL to populate staging tables if (_submissionTrackingDataType.ETLCompletionDateTimeSpecified || _submissionTrackingDataType.DETChangeCompletionDateTimeSpecified) { // Both must be specified, or neither must be specified throw new ArgException("Both ETL completion dates have not been set for row {0} in the submission tracking table", _submissionTrackingDataTypePK); } if (string.IsNullOrEmpty(_storedProcName)) { AppendAuditLogEvent("The \"{0}\" config param has not been specified for the service and the ETL stored procedure has not executed, so the service cannot continue, exiting plugin ...", CONFIG_PARAM_ETL_NAME); return(false); } _submissionTrackingDataTypePK = DoExtract(this, _etlDao, _storedProcName, _commandTimeout); if (_submissionTrackingDataTypePK == null) { AppendAuditLogEvent("The ETL stored procedure indicated that this service should not continue, exiting plugin ..."); return(false); } _submissionTrackingDataType = SubmissionTrackingTableHelper.GetActiveSubmissionTrackingElement(_stagingDao, _submissionTrackingDataTypePK); } else { AppendAuditLogEvent("The ETL stored procedure has already run as referenced by row {0} in the submission tracking table with status \"{1}\" ...", _submissionTrackingDataTypePK, _submissionTrackingDataType.WorkflowStatus.ToString()); } return(true); }
public static SubmissionTrackingDataType GetActiveSubmissionTrackingElement(SpringBaseDao baseDao, string pk) { SubmissionTrackingDataType data = null; baseDao.DoSimpleQueryWithRowCallbackDelegate(TABLE_NAME, PK_COLUMN, pk, LOAD_COLUMNS, delegate(IDataReader reader) { int index = 0; data = new SubmissionTrackingDataType(); data.ETLCompletionDateTime = GetNullableDateTime(reader, ref index, out data.ETLCompletionDateTimeSpecified); data.DETChangeCompletionDateTime = GetNullableDateTime(reader, ref index, out data.DETChangeCompletionDateTimeSpecified); data.SubmissionDateTime = GetNullableDateTime(reader, ref index, out data.SubmissionDateTimeSpecified); data.SubmissionTransactionId = GetNullableString(reader, ref index); data.SubmissionTransactionStatus = GetNullableEnum <TransactionStatusCode>(reader, ref index, out data.SubmissionTransactionStatusSpecified); data.SubmissionStatusDateTime = GetNullableDateTime(reader, ref index, out data.SubmissionStatusDateTimeSpecified); data.ResponseParseDateTime = GetNullableDateTime(reader, ref index, out data.ResponseParseDateTimeSpecified); data.WorkflowStatus = GetEnum <TransactionStatusCode>(reader, ref index); data.WorkflowStatusMessage = GetNullableString(reader, ref index); }); if (data == null) { throw new ArgException("Could not find data in the {0} table with PK {1}", TABLE_NAME, pk); } return(data); }
// TSM: The following method is for testing purposes only, to enable, have this class implement ISubmitProcessor above public virtual void ProcessSubmit(string transactionId) { LazyInit(); IList <string> docNames = _documentManager.GetAllDocumentNames(transactionId); _submissionTrackingDataType = new SubmissionTrackingDataType(); _submissionTrackingDataType.SubmissionTransactionId = transactionId; _submissionTrackingDataTypePK = Guid.NewGuid().ToString(); Windsor.Node2008.WNOSDomain.Document zipResponseFile; DoProcessResponseDocuments(transactionId, docNames, out zipResponseFile); }
public static SubmissionTrackingDataType GetActiveSubmissionTrackingElement(SpringBaseDao baseDao, out string submissionTrackingDataTypePK) { IList <string> pks = GetActiveSubmissionTrackingElementPKs(baseDao); if (CollectionUtils.IsNullOrEmpty(pks)) { submissionTrackingDataTypePK = null; return(null); } if (pks.Count != 1) { throw new ArgException("There is more than one active row in the {0} table: {1}", TABLE_NAME, StringUtils.JoinCommaEnglish(pks)); } submissionTrackingDataTypePK = pks[0]; SubmissionTrackingDataType submissionTrackingDataType = GetActiveSubmissionTrackingElement(baseDao, submissionTrackingDataTypePK); if (submissionTrackingDataType.WorkflowStatus != TransactionStatusCode.Pending) { throw new ArgException("The workflow status in the {0} table for row \"{1}\" is invalid: \"{2}\"", TABLE_NAME, submissionTrackingDataTypePK, submissionTrackingDataType.WorkflowStatus.ToString()); } return(submissionTrackingDataType); }
public static void Update(SpringBaseDao baseDao, string submissionTrackingDataTypePK, SubmissionTrackingDataType data) { const int MAX_STATUS_MESSAGE_LENGTH = 4000; if (!string.IsNullOrEmpty(data.WorkflowStatusMessage) && (data.WorkflowStatusMessage.Length > MAX_STATUS_MESSAGE_LENGTH)) { data.WorkflowStatusMessage = data.WorkflowStatusMessage.Substring(0, MAX_STATUS_MESSAGE_LENGTH); } baseDao.DoSimpleUpdate(TABLE_NAME, PK_COLUMN, submissionTrackingDataTypePK, UPDATE_COLUMNS, 1, data.SubmissionDateTimeSpecified ? (object)data.SubmissionDateTime : null, data.SubmissionTransactionId, data.SubmissionTransactionStatusSpecified ? (object)data.SubmissionTransactionStatus.ToString() : null, data.SubmissionStatusDateTimeSpecified ? (object)data.SubmissionStatusDateTime : null, data.ResponseParseDateTimeSpecified ? (object)data.ResponseParseDateTime : null, data.WorkflowStatus.ToString(), data.WorkflowStatusMessage); }
public override void ProcessTask(string requestId) { ProcessTaskInit(requestId); _submissionTrackingDataType = SubmissionTrackingTableHelper.GetActiveSubmissionTrackingElement(_stagingDao, out _submissionTrackingDataTypePK); if (_submissionTrackingDataType == null) { _submissionTrackingDataType = new SubmissionTrackingDataType(); } if (_submissionTrackingDataType.WorkflowStatus == TransactionStatusCode.Pending && _submissionTrackingDataType.ETLCompletionDateTimeSpecified == false) { AppendAuditLogEvent("Previous ETL execution in the tracking table with primary key \"{0}\" did not complete due to unrecoverable database error. Setting transaction to Failed." , _submissionTrackingDataTypePK); // Update submission status in tracking table _submissionTrackingDataType.WorkflowStatus = TransactionStatusCode.Failed; _submissionTrackingDataType.WorkflowStatusMessage = "ETL did not complete due to unrecoverable database error"; SubmissionTrackingTableHelper.Update(_stagingDao, _submissionTrackingDataTypePK, _submissionTrackingDataType); //create a new submission tracking record for the current workflow execution _submissionTrackingDataType = new SubmissionTrackingDataType(); _submissionTrackingDataTypePK = null; } else if (_submissionTrackingDataType.SubmissionDateTimeSpecified) { DebugUtils.AssertDebuggerBreak(_submissionTrackingDataTypePK != null); AppendAuditLogEvent("There is a pending partner submission in the tracking table with primary key \"{0}\", exiting plugin ...", _submissionTrackingDataTypePK); return; } try { // Attempt to run the ETL to populate staging tables if (!DoExtract()) { return; } DebugUtils.AssertDebuggerBreak(_submissionTrackingDataTypePK != null); // Attempt to load the submission file from staging string submitFilePath; if (!DoXmlLoad(out submitFilePath)) { return; } // Attempt to submit file string submitTransactionId; if (!DoSubmission(submitFilePath, out submitTransactionId)) { return; } // Update submission status in tracking table _submissionTrackingDataType.WorkflowStatus = TransactionStatusCode.Pending; _submissionTrackingDataType.WorkflowStatusMessage = "The ICIS data has been submitted"; _submissionTrackingDataType.SubmissionDateTime = DateTime.Now; _submissionTrackingDataType.SubmissionDateTimeSpecified = true; _submissionTrackingDataType.SubmissionTransactionId = submitTransactionId; SubmissionTrackingTableHelper.Update(_stagingDao, _submissionTrackingDataTypePK, _submissionTrackingDataType); } catch (Exception ex) { if (_submissionTrackingDataTypePK != null) { _submissionTrackingDataType.WorkflowStatus = TransactionStatusCode.Failed; _submissionTrackingDataType.WorkflowStatusMessage = string.Format("An error occurred during processing: {0}", ExceptionUtils.GetDeepExceptionMessage(ex)); SubmissionTrackingTableHelper.Update(_stagingDao, _submissionTrackingDataTypePK, _submissionTrackingDataType); } throw; } }
public virtual void ProcessTask(string requestId) { ProcessTaskInit(requestId); _submissionTrackingDataType = SubmissionTrackingTableHelper.GetActiveSubmissionTrackingElement(_baseDao, out _submissionTrackingDataTypePK); if (_submissionTrackingDataType == null) { AppendAuditLogEvent("There are no pending submissions in the submission tracking table, existing plugin ..."); return; } DebugUtils.AssertDebuggerBreak(_submissionTrackingDataTypePK != null); if (!_submissionTrackingDataType.SubmissionDateTimeSpecified) { AppendAuditLogEvent("There is a pending row in the submission tracking table, \"{0},\" but it does not have a submission date/time yet, existing plugin ...", _submissionTrackingDataTypePK); return; } try { if (string.IsNullOrEmpty(_submissionTrackingDataType.SubmissionTransactionId)) { throw new ArgumentException("There is a pending row in the submission tracking table, \"{0},\" with a submission date/time, but the submission transaction id is missing", _submissionTrackingDataTypePK); } // Attempt to get status of the active submission and download the response documents IList <string> documentNames; string localTransactionId; if (!DoGetStatusAndDownloadDocuments(out localTransactionId, out documentNames)) { return; } Windsor.Node2008.WNOSDomain.Document zipResponseFile; if (!DoProcessResponseDocuments(localTransactionId, documentNames, out zipResponseFile)) { return; } _submissionTrackingDataType.WorkflowStatus = TransactionStatusCode.Completed; _submissionTrackingDataType.WorkflowStatusMessage = string.Format("Successfully downloaded response data and inserted into database"); SubmissionTrackingTableHelper.Update(_baseDao, _submissionTrackingDataTypePK, _submissionTrackingDataType); DoEmailNotifications(zipResponseFile, localTransactionId); } catch (WorkflowStatusFailedException workflowStatusFailedException) { string errorMessage = string.Format("An error occurred during processing: {0}", ExceptionUtils.GetDeepExceptionMessage(workflowStatusFailedException)); if (_submissionTrackingDataTypePK != null) { _submissionTrackingDataType.WorkflowStatus = TransactionStatusCode.Failed; _submissionTrackingDataType.WorkflowStatusMessage = errorMessage; SubmissionTrackingTableHelper.Update(_baseDao, _submissionTrackingDataTypePK, _submissionTrackingDataType); } throw new ArgException(errorMessage); } catch (Exception) { // Continue on, do not set workflow status to failed, per Bill throw; } }