protected void DoSearch()
 {
     if (divPageError.Visible || !Page.IsValid)
     {
         // Error on page, get out of here
         return;
     }
     try
     {
         FillSearchParams();
         _dataModel.SearchResults =
             _dataService.Search(DataItem, VisitHelper.GetVisit(), false);
         if (CollectionUtils.IsNullOrEmpty(_dataModel.SearchResults))
         {
             noItemsDiv.Visible = true;
         }
         else
         {
             noItemsDiv.Visible = false;
             foreach (Activity activity in _dataModel.SearchResults)
             {
                 activity.ModifiedById = GetUsernameById(activity.ModifiedById);
             }
             _dataModel.SearchResults.Sort(_dataModel.SortProperty, _dataModel.SortAscending);
         }
         _dataModel.PageIndex     = 0;
         _dataModel.RebindResults = true;
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
     }
 }
Beispiel #2
0
        protected virtual void UpdateStatusOfTransaction(NodeTransaction transaction, ITransactionManager transactionManager,
                                                         INodeEndpointClientFactory nodeEndpointClientFactory)
        {
            try
            {
                AppendAuditLogEvent("Attempting to update status of local transaction id \"{0}\" that has endpoint transaction id \"{1}\" and current endpoint transaction status of \"{2}\" at url \"{3}\" and endpoint version \"{4}\" ...",
                                    transaction.Id, transaction.NetworkId, transaction.NetworkEndpointStatus,
                                    transaction.NetworkEndpointUrl, transaction.NetworkEndpointVersion);

                CommonTransactionStatusCode statusCode;
                using (INodeEndpointClient endpointClient =
                           nodeEndpointClientFactory.Make(transaction.NetworkEndpointUrl, transaction.NetworkEndpointVersion))
                {
                    statusCode = endpointClient.GetStatus(transaction.NetworkId);
                    AppendAuditLogEvent("Successfully got an endpoint transaction status of \"{0}\"", statusCode.ToString());
                    if (statusCode != transaction.NetworkEndpointStatus)
                    {
                        if (OnTransactionStatusChanged(transaction, endpointClient, statusCode))
                        {
                            AppendAuditLogEvent("Updating status of local transaction id \"{0}\" from \"{1}\" to \"{2}\"",
                                                transaction.Id, transaction.NetworkEndpointStatus, statusCode);
                            transactionManager.SetNetworkIdStatus(transaction.Id, statusCode);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to get status of transaction: {0}", ExceptionUtils.GetDeepExceptionMessage(e));
            }
        }
        public void DoExtract()
        {
            if (string.IsNullOrEmpty(_storedProcName))
            {
                AppendAuditLogEvent("An extract stored procedure was not specified.");
                return;
            }
            AppendAuditLogEvent("Executing stored procedure \"{0}\" with {1} ({2}), {3} ({4}), {5} ({6}), and {7} ({8}) ...",
                                _storedProcName, PARAM_START_DATE_KEY, _startDate, PARAM_END_DATE_KEY, _endDate,
                                PARAM_SITE_ID_KEY, _siteId, PARAM_COUNTY_CODE_KEY, _countyCode);

            try
            {
                IDbParameters parameters = _baseDao.AdoTemplate.CreateDbParameters();
                parameters.AddWithValue(p_facility_site_id, _siteId);
                parameters.AddWithValue(p_county_cd, _countyCode);
                parameters.AddWithValue(p_monitor_start_date, _startDate);
                parameters.AddWithValue(p_monitor_end_date, _endDate);
                IDbDataParameter runtimeTextParameter = parameters.AddOut(p_runtime_txt, DbType.String, 2048);

                _baseDao.AdoTemplate.Execute <int>(delegate(DbCommand command)
                {
                    command.CommandType    = CommandType.StoredProcedure;
                    command.CommandText    = _storedProcName;
                    command.CommandTimeout = _commandTimeout;
                    Spring.Data.Support.ParameterUtils.CopyParameters(command, parameters);

                    try
                    {
                        SpringBaseDao.ExecuteCommandWithTimeout(command, _commandTimeout, delegate(DbCommand commandToExecute)
                        {
                            commandToExecute.ExecuteNonQuery();
                        });
                    }
                    catch (Exception ex2)
                    {
                        AppendAuditLogEvent("Error returned from stored procedure: {0}", ExceptionUtils.GetDeepExceptionMessage(ex2));
                        throw;
                    }

                    if (command.Parameters[runtimeTextParameter.ParameterName].Value != DBNull.Value)
                    {
                        string procMessage = command.Parameters[runtimeTextParameter.ParameterName].Value.ToString();
                        procMessage        = procMessage.Replace("\r\n", "\r");
                        procMessage        = procMessage.Replace("\r", "\r\n");
                        AppendAuditLogEvent(procMessage);
                    }

                    return(0);
                });

                AppendAuditLogEvent("Successfully executed stored procedure \"{0}\"", _storedProcName);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to execute stored procedure \"{0}\" with error: {1}",
                                    _storedProcName, ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
        }
Beispiel #4
0
        protected virtual string PerformSolicit()
        {
            string transactionId;

            AppendAuditLogEvent("Soliciting endpoint \"{0}\" at url \"{1}\" with flow name \"{2}\" and service name \"{3}\"",
                                _solicitPartner.Name, _solicitPartner.Url, NETWORK_RCRA_FLOW_NAME, _queryServiceName);

            try
            {
                using (INodeEndpointClient endpointClient =
                           _endpointUserManager.GetNodeEndpointClient(_solicitPartner.Url, _solicitPartner.Version, _solicitEndpointUsername))
                {
                    transactionId = endpointClient.Solicit(NETWORK_RCRA_FLOW_NAME, _queryServiceName, _queryParameters);
                }
                AppendAuditLogEvent("Successfully solicited the node endpoint \"{0}\" with returned transaction id \"{1}\"",
                                    _solicitPartner.Name, transactionId);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to solicit the node endpoint \"{0}\" with exception: {1}",
                                    _solicitPartner.Name, ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
            _endpointUserManager.SetNetworkEndpointTransactionInfo(_dataRequest.TransactionId, transactionId, _solicitPartner.Version,
                                                                   _solicitPartner.Url, NETWORK_RCRA_FLOW_NAME, _queryServiceName,
                                                                   _solicitEndpointUsername);
            return(transactionId);
        }
Beispiel #5
0
        private static DataTable GetTableSchema(DbConnection connection, string viewName)
        {
            DataTable       table = null;
            ConnectionState origConnectionState = connection.State;

            try
            {
                if (origConnectionState != ConnectionState.Open)
                {
                    connection.Open();
                }
                DbCommand command = connection.CreateCommand();
                command.CommandText = "SELECT * FROM \"" + viewName + "\" WHERE 0 = 1";
                DbDataReader reader = command.ExecuteReader(CommandBehavior.KeyInfo);
                table = new DataTable(viewName);
                table.Load(reader);
            }
            catch (Exception ex)
            {
                throw new ArgException("An error occurred attempting to load the view \"{0}\" for display: {1}",
                                       viewName, ExceptionUtils.GetDeepExceptionMessage(ex));
            }
            finally
            {
                if (origConnectionState != ConnectionState.Open)
                {
                    connection.Close();
                }
            }
            if (table.Columns.Count < 1)
            {
                throw new ArgException("The view \"{0}\" does not contain any data (columns) to display", viewName);
            }
            return(table);
        }
 protected void OnClickReset(object sender, EventArgs e)
 {
     try
     {
         exchangeDropDownList.SelectedValue  = NOT_SELECTED_TEXT;
         operationDropDownList.SelectedValue = NOT_SELECTED_TEXT;
         noItemsDiv.Visible       = false;
         fromDateImageButton.Text = string.Empty;
         toDateImageButton.Text   = string.Empty;
         fromDateCalendarExtender.SelectedDate = null;
         toDateCalendarExtender.SelectedDate   = null;
         activityTypeCtrl.SelectedValue        = NOT_SELECTED_TEXT;
         nodeMethodTypeDropdown.SelectedValue  = NOT_SELECTED_TEXT;
         transactionIdCtrl.Text   = string.Empty;
         fromIpCtrl.SelectedValue = NOT_SELECTED_TEXT;
         byUserCtrl.SelectedValue = NOT_SELECTED_TEXT;
         contentCtrl.Text         = string.Empty;
         _dataModel = new DataModel();
         _dataModel.SearchParams    = new ActivitySearchParams();
         _dataModel.UserIdToNameMap = DataService.GetUserIdToNameMap();
         _dataModel.RebindResults   = true;
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
     }
 }
Beispiel #7
0
        public static void ErrorMessageBox(IWin32Window owner, Exception exception, string messageFormat, params object[] args)
        {
            if (!CollectionUtils.IsNullOrEmpty(args))
            {
                messageFormat = string.Format(messageFormat, args);
            }
            if (exception != null)
            {
                if (!messageFormat.EndsWith(":") && !messageFormat.EndsWith("."))
                {
                    messageFormat += ":";
                }

                messageFormat += Environment.NewLine + Environment.NewLine;

                if (ShowDetailedErrorMessages)
                {
                    messageFormat += ExceptionUtils.ToLongString(exception);
                }
                else
                {
                    messageFormat += ExceptionUtils.GetDeepExceptionMessage(exception);
                    messageFormat  = messageFormat.Replace(", Message:", Environment.NewLine + Environment.NewLine + "Message:");
                }
            }
            XTRA_MSG_BOX.Show(owner, WrapMessage(messageFormat), Application.ProductName + " Error",
                              MessageBoxButtons.OK, MessageBoxIcon.Error, exception);
        }
Beispiel #8
0
        protected virtual string InsertDocumentIntoDatabase(Type xmlDataType, NodeTransaction nodeTransaction, Document document)
        {
            if (_baseDao == null)
            {
                string noInsertMessage = "No data was inserted into the database since a data destination was not configured for the service";
                AppendAuditLogEvent(noInsertMessage);
                return(noInsertMessage);
            }
            AppendAuditLogEvent("Loading RCRA content from transaction document \"{0}\" ...",
                                document.DocumentName);
            string operation;
            object xmlData = GetHeaderDocumentContent(xmlDataType, nodeTransaction.Id, document.Id, _settingsProvider,
                                                      _serializationHelper, _compressionHelper, _documentManager,
                                                      out operation);

            AppendAuditLogEvent("Inserting RCRA content into database for document \"{0}\" ...",
                                document.DocumentName);

            try
            {
                Dictionary <string, int> tableRowCounts = _objectsToDatabase.SaveToDatabase(xmlData, _baseDao);
                string tableCountsString = string.Format("Successfully inserted RCRA content into database for document \"{0}\" with table counts: {1}",
                                                         document.DocumentName, CreateTableRowCountsString(tableRowCounts));
                AppendAuditLogEvent(tableCountsString);

                return(tableCountsString);
            }
            catch (Exception ex)
            {
                AppendAuditLogEvent("Failed to insert RCRA content into database for document \"{0}\" with exception: {1}",
                                    document.DocumentName, ExceptionUtils.GetDeepExceptionMessage(ex));
                throw;
            }
        }
Beispiel #9
0
        /// <summary>
        /// GetData
        /// </summary>
        /// <param name="whereSql"></param>
        /// <param name="connectionString"></param>
        /// <returns></returns>
        private static DataTable GetData(bool isOracle,
                                         string sql,
                                         string connectionString)
        {
            try
            {
                sql = FixSql(sql);
                LOG.Debug("GetData: " + sql);

                //Populate the dataset with the results of the query

                if (isOracle)
                {
                    return(OracleHelper.ExecuteDataset(
                               connectionString,
                               CommandType.Text,
                               sql).Tables[0]);
                }
                else
                {
                    return(SqlHelper.ExecuteDataset(
                               connectionString,
                               CommandType.Text,
                               sql).Tables[0]);
                }
            }
            catch (Exception ex)
            {
                throw new ArgumentException("FRS query failed: " + ExceptionUtils.GetDeepExceptionMessage(ex));
            }
        }
Beispiel #10
0
        protected virtual void AttachSubmissionResponseToTransaction(string transactionId)
        {
            string tempXmlFilePath = _settingsProvider.NewTempFilePath();
            string tempZipFilePath = _settingsProvider.NewTempFilePath();

            try
            {
                Windsor.Node2008.WNOSPlugin.ICISAIR_54.SubmissionResponseDataType response =
                    new Windsor.Node2008.WNOSPlugin.ICISAIR_54.SubmissionResponseDataType();
                response.CreationDate          = response.SubmissionDate = DateTime.Now;
                response.TransactionIdentifier = transactionId;

                _serializationHelper.Serialize(response, tempXmlFilePath);

                string zipDocumentName         = string.Format("{0}_Response.xml", transactionId);
                string transactionDocumentName = Path.ChangeExtension(zipDocumentName, ".zip");

                _compressionHelper.CompressFile(tempXmlFilePath, zipDocumentName, tempZipFilePath);

                var document =
                    new Windsor.Node2008.WNOSDomain.Document(transactionDocumentName, CommonContentType.ZIP,
                                                             File.ReadAllBytes(tempZipFilePath));
                _documentManager.AddDocument(transactionId, CommonTransactionStatusCode.Completed, null, document);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to add response file to transaction \"{0}\" with error: {1}",
                                    transactionId, ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
            finally
            {
                FileUtils.SafeDeleteFile(tempXmlFilePath);
            }
        }
        protected void SaveDataFileToTransaction(string transactionId, WQXDataType data)
        {
            string tempXmlFilePath = _settingsProvider.NewTempFilePath();

            tempXmlFilePath = Path.ChangeExtension(tempXmlFilePath, ".xml");

            try
            {
                AppendAuditLogEvent("Saving generated WQX xml file to transaction ...");

                _serializationHelper.Serialize(data, tempXmlFilePath);

                _documentManager.AddDocument(transactionId,
                                             CommonTransactionStatusCode.Completed,
                                             null, tempXmlFilePath);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to save generated WQX xml file to transaction: {0}",
                                    ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
            finally
            {
                FileUtils.SafeDeleteFile(tempXmlFilePath);
            }
        }
Beispiel #12
0
        protected virtual void DoImport()
        {
            AppendAuditLogEvent("Importing CSV file \"{0}\" ...", _csvFilePath);

            try
            {
                AqsDeserializeCsv cdr = new AqsDeserializeCsv(_baseDao);

                AppendAuditLogEvent("Generating AQS data from CSV file \"{0}\" ...", _csvFilePath);
                AirQualitySubmissionType data =
                    cdr.GetAirQualityData(_csvFilePath, Windsor.Node2008.WNOSPlugin.AQS2.AqsDeserializeCsv.AqsFileType.rawResults,
                                          _mappingTemplateName, this);

                AppendAuditLogEvent("Importing AQS data into database ...");

                AQSPersistDataToDatabase dataPersister = new AQSPersistDataToDatabase(_baseDao, _clearMetadata);
                dataPersister.UpsertAirQualityData(data, this);

                AppendAuditLogEvent("Successfully imported CSV file");
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to import CSV file with error: {0}",
                                    ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
        }
Beispiel #13
0
        public string LogError(NodeMethod method, string flowName, string operation, ActivityType type, Exception exception,
                               NodeVisit visit, string messageFormat, params object[] args)
        {
            Activity activity = new Activity(method, flowName, operation, type, null, (visit == null) ? string.Empty : visit.IP,
                                             messageFormat, args);

            activity.ModifiedById = (visit == null) ? AccountManager.AdminAccount.Id : visit.Account.Id;
            activity.AppendFormat("EXCEPTION: {0}", ExceptionUtils.GetDeepExceptionMessage(exception));
            return(Log(activity));
        }
Beispiel #14
0
        protected virtual void DoImport()
        {
            AppendAuditLogEvent("Executing stored procedure \"{0}\" with {1} ({2}), {3} ({4}), {5} ({6}), and {7} ({8}) ...",
                                _storedProcName, PARAM_RAW_DATA_FILE_NAME, _rawDataFileName, PARAM_PRECISION_DATA_FILE_NAME, _precisionDataFileName,
                                PARAM_ACCURACY_DATA_FILE_NAME, _accuracyDataFileName, PARAM_BLANK_DATA_FILE_NAME, _blankDataFileName);

            try
            {
                IDbParameters parameters = _baseDao.AdoTemplate.CreateDbParameters();
                parameters.AddWithValue(p_raw_file, _rawDataFileName);
                parameters.AddWithValue(p_precision_file, _precisionDataFileName);
                parameters.AddWithValue(p_accuracy_file, _accuracyDataFileName);
                parameters.AddWithValue(p_blank_file, _blankDataFileName);
                IDbDataParameter runtimeTextParameter = parameters.AddOut(p_runtime_txt, DbType.String, 2048);

                _baseDao.AdoTemplate.Execute <int>(delegate(DbCommand command)
                {
                    command.CommandType    = CommandType.StoredProcedure;
                    command.CommandText    = _storedProcName;
                    command.CommandTimeout = _commandTimeout;
                    Spring.Data.Support.ParameterUtils.CopyParameters(command, parameters);

                    try
                    {
                        SpringBaseDao.ExecuteCommandWithTimeout(command, _commandTimeout, delegate(DbCommand commandToExecute)
                        {
                            commandToExecute.ExecuteNonQuery();
                        });
                    }
                    catch (Exception ex2)
                    {
                        AppendAuditLogEvent("Error returned from stored procedure: {0}", ExceptionUtils.GetDeepExceptionMessage(ex2));
                        throw;
                    }

                    if (command.Parameters[runtimeTextParameter.ParameterName].Value != DBNull.Value)
                    {
                        string procMessage = command.Parameters[runtimeTextParameter.ParameterName].Value.ToString();
                        procMessage        = procMessage.Replace("\r\n", "\r");
                        procMessage        = procMessage.Replace("\r", "\r\n");
                        AppendAuditLogEvent(procMessage);
                    }

                    return(0);
                });

                AppendAuditLogEvent("Successfully executed stored procedure \"{0}\"", _storedProcName);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to execute stored procedure \"{0}\" with error: {1}",
                                    _storedProcName, ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
        }
Beispiel #15
0
        protected virtual bool ProcessOutstandingTransaction(NodeTransaction nodeTransaction)
        {
            try
            {
                if (HasTransactionBeenProcessed(nodeTransaction))
                {
                    return(false);
                }
                AppendAuditLogEvent("*** Begin processing network submission transaction \"{0}\" to {1} service \"{2}\" ...",
                                    nodeTransaction.NetworkId, nodeTransaction.NetworkFlowName, nodeTransaction.NetworkOperationName);

                AppendAuditLogEvent("Checking status of the network transaction \"{0}\" associated with the local transaction \"{1}\" ...",
                                    nodeTransaction.NetworkId, nodeTransaction.Id);

                TransactionStatus           transactionStatus = _transactionManager.RefreshNetworkStatus(nodeTransaction.Id);
                CommonTransactionStatusCode currentStatus     = transactionStatus.Status;

                AppendAuditLogEvent("The network transaction \"{0}\" associated with the local transaction \"{1}\" has a network status of \"{2}\" ...",
                                    nodeTransaction.NetworkId, nodeTransaction.Id, currentStatus.ToString());

                if ((currentStatus == CommonTransactionStatusCode.Completed) || (currentStatus == CommonTransactionStatusCode.Failed))
                {
                    AppendAuditLogEvent("Attempting to download documents for the network transaction \"{0}\" ...",
                                        nodeTransaction.NetworkId);

                    nodeTransaction.NetworkEndpointStatus = currentStatus;
                    _transactionManager.DownloadNetworkDocumentsAndAddToTransaction(nodeTransaction.Id, out currentStatus);

                    AppendAuditLogEvent("Any documents associated with the network transaction \"{0}\" were downloaded and saved.",
                                        nodeTransaction.NetworkId);

                    DoEmailNotifications(nodeTransaction);

                    CheckStatusComplete checkStatusComplete = new CheckStatusComplete(DateTime.Now);
                    SaveCheckStatusComplete(nodeTransaction.Id, checkStatusComplete);
                    return(true);
                }
                else
                {
                    AppendAuditLogEvent("Another attempt to process the network transaction \"{0}\" will be made when the schedule runs again.",
                                        nodeTransaction.NetworkId);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                AppendAuditLogEvent("ERROR: Failed to process network submission transaction \"{0}\" to {1} service \"{2}\" with exception: {3}.",
                                    nodeTransaction.NetworkId, nodeTransaction.NetworkFlowName, nodeTransaction.NetworkOperationName,
                                    ExceptionUtils.GetDeepExceptionMessage(ex));
                AppendAuditLogEvent("Another attempt to process the network transaction \"{0}\" will be made when the schedule runs again.",
                                    nodeTransaction.NetworkId);
                return(false);
            }
        }
 public override void SetValue(object value)
 {
     try
     {
         Value = (T)Convert.ChangeType(value, typeof(T));
         //Value = (T)value;
     }
     catch (Exception ex)
     {
         DebugUtils.CheckDebuggerBreak();
         throw new ArgException("Failed to convert the database value \"{0}\" to type \"{1}\" with exception: {2}",
                                value, typeof(T).Name, ExceptionUtils.GetDeepExceptionMessage(ex));
     }
 }
        public INodeEndpointClient Make(string targetEndpointUrl, EndpointVersionType type, string username,
                                        string testPassword, string prodPassword)
        {
            ExceptionUtils.ThrowIfEmptyString(username);
            ExceptionUtils.ThrowIfEmptyString(testPassword);
            ExceptionUtils.ThrowIfEmptyString(prodPassword);

            INodeEndpointClient client = null;

            try
            {
                AuthenticationCredentials credentials = new AuthenticationCredentials(username, testPassword);
                client = Make(targetEndpointUrl, type, credentials);
                // First, check to ping the node to make sure it is up and running
                try
                {
                    client.NodePing();
                }
                catch (Exception pingEx)
                {
                    throw new ArgumentException(string.Format("The node endpoint \"{0}\" cannot be contacted.  NodePing returned the error: {1}",
                                                              targetEndpointUrl, ExceptionUtils.GetDeepExceptionMessage(pingEx)));
                }

                client.Authenticate();
            }
            catch (Exception)
            {
                DisposableBase.SafeDispose(ref client);
            }
            if (client == null)
            {
                try
                {
                    AuthenticationCredentials credentials = new AuthenticationCredentials(username, prodPassword);
                    client = Make(targetEndpointUrl, type, credentials);
                    client.Authenticate();
                }
                catch (Exception)
                {
                    DisposableBase.SafeDispose(ref client);
                }
            }
            if (client == null)
            {
                throw new ArgumentException(string.Format("The NAAS user \"{0}\" failed to authenticate against the node endpoint \"{1}\".  Please check that the NAAS user's username and password have been entered correctly.",
                                                          username, targetEndpointUrl));
            }
            return(client);
        }
        protected virtual void GetLookups(string lookupTableFilePath)
        {
            if (!File.Exists(lookupTableFilePath))
            {
                //throw new FileNotFoundException(string.Format("The lookup tables file \"{0}\" could not be found", lookupTableFilePath));
            }
            try {
                using (CommaSeparatedFileParser parser = new CommaSeparatedFileParser(lookupTableFilePath))
                {
                    while (parser.NextLine())
                    {
                        string context = parser["CONTEXT"];
                        string type = parser["TYPE"];
                        string id = parser["ID"].ToUpper();
                        string name, description;
                        parser.GetValue("NAME", out name);
                        parser.GetValue("DESCRIPTION", out description);
                        if (!string.IsNullOrEmpty(name) || !string.IsNullOrEmpty(description))
                        {
                            switch (type.ToUpper())
                            {
                            case "SAMPLECOLLECTIONMETHOD":
                                CollectionUtils.Add(id, new LookupValues(context, name, description),
                                                    ref _sampleCollectionMethodLookups);
                                break;

                            case "RESULTANALYTICALMETHOD":
                                CollectionUtils.Add(id + context.ToUpper(), new LookupValues(context, name, description),
                                                    ref _resultAnalyticalMethodLookups);
                                break;

                            default:
                                throw new ArgumentException(string.Format("Invalid TYPE found in lookup tables file: {0}",
                                                                          type.ToString()));
                            }
                        }
                    }
                    AppendAuditLogEvent("Found {0} SampleCollectionMethod lookup(s) and {1} ResultAnalyticalMethod lookup(s) in the lookup tables file \"{2}\".",
                                        CollectionUtils.Count(_sampleCollectionMethodLookups).ToString(),
                                        CollectionUtils.Count(_resultAnalyticalMethodLookups).ToString(),
                                        lookupTableFilePath);
                }
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to parse the lookup tables file \"{0}\" with error: {1}",
                                    lookupTableFilePath, ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
        }
 protected override void BindFormData()
 {
     try
     {
         if (!this.IsPostBack)
         {
             base.BindFormData();
         }
     }
     catch (Exception ex)
     {
         divPageError.Visible   = true;
         divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
     }
 }
Beispiel #20
0
        protected virtual string InsertDocumentIntoDatabase(Type xmlDataType, NodeTransaction nodeTransaction, Document document)
        {
            if (_baseDao == null)
            {
                string noInsertMessage = "No data was inserted into the database since a data destination was not configured for the service";
                AppendAuditLogEvent(noInsertMessage);
                return(noInsertMessage);
            }
            AppendAuditLogEvent("Loading FACID content from transaction document \"{0}\" ...",
                                document.DocumentName);
            string operation;
            object xmlData = GetHeaderDocumentContent(xmlDataType, nodeTransaction.Id, document.Id, _settingsProvider,
                                                      _serializationHelper, _compressionHelper, _documentManager,
                                                      out operation);

            AppendAuditLogEvent("Inserting FACID content into database for document \"{0}\" ...",
                                document.DocumentName);

            try
            {
                if (_deleteExistingDataBeforeInsert)
                {
                    AppendAuditLogEvent("Deleting existing FACID data of type \"{0}\" from the data store ...", xmlDataType.Name);
                    int numRowsDeleted = _objectsToDatabase.DeleteAllFromDatabase(xmlDataType, _baseDao);

                    if (numRowsDeleted > 0)
                    {
                        AppendAuditLogEvent("Deleted {0} existing FACID data rows from the data store", numRowsDeleted.ToString());
                    }
                    else
                    {
                        AppendAuditLogEvent("Did not find any existing FACID data to delete from the data store");
                    }
                }
                Dictionary <string, int> tableRowCounts = _objectsToDatabase.SaveToDatabase(xmlData, _baseDao);
                string tableCountsString = string.Format("Successfully inserted FACID content into database for document \"{0}\" with table counts: {1}",
                                                         document.DocumentName, CreateTableRowCountsString(tableRowCounts));
                AppendAuditLogEvent(tableCountsString);

                return(tableCountsString);
            }
            catch (Exception ex)
            {
                AppendAuditLogEvent("Failed to insert FACID content into database for document \"{0}\" with exception: {1}",
                                    document.DocumentName, ExceptionUtils.GetDeepExceptionMessage(ex));
                throw;
            }
        }
 protected override void BindFormData()
 {
     try
     {
         if (!this.IsPostBack)
         {
             base.BindFormData();
         }
         DeleteAllButton.Visible = !CollectionUtils.IsNullOrEmpty(_dataModel.SearchResults);
     }
     catch (Exception ex)
     {
         divPageError.Visible   = true;
         divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
     }
 }
Beispiel #22
0
        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);
                }
                AppendAuditLogEvent("The ETL stored procedure returned \"{0}\" for the submission tracking PK ...", _submissionTrackingDataTypePK);


                try
                {
                    AppendAuditLogEvent("Attempting to read the submission tracking row with PK \"{0}\" ...", _submissionTrackingDataTypePK);
                    _submissionTrackingDataType = SubmissionTrackingTableHelper.GetActiveSubmissionTrackingElement(_stagingDao, _submissionTrackingDataTypePK);
                    AppendAuditLogEvent("Successfully read the submission tracking row with PK \"{0}\".", _submissionTrackingDataTypePK);
                }
                catch (Exception ex)
                {
                    AppendAuditLogEvent("Failed to read the submission tracking row with PK \"{0}\" with exception: {1}",
                                        _submissionTrackingDataTypePK, ExceptionUtils.GetDeepExceptionMessage(ex));
                    throw;
                }
            }
            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);
        }
Beispiel #23
0
        protected virtual void DoEmailNotifications(NodeTransaction nodeTransaction)
        {
            if (!CollectionUtils.IsNullOrEmpty(_notificationEmails))
            {
                string tempFilePath = null;
                try
                {
                    string notificationEmails = StringUtils.Join(";", _notificationEmails);

                    AppendAuditLogEvent("Sending email notifications to {0} ...", StringUtils.JoinCommaEnglish(_notificationEmails));

                    TransactionStatus transactionStatus = new TransactionStatus();
                    transactionStatus.Id     = nodeTransaction.Id;
                    transactionStatus.Status = nodeTransaction.NetworkEndpointStatus;

                    string attachmentPath = null, attachmentName = null;

                    string message = "This email is to notify you that OpenNode2 has downloaded results for a recent AQS submission.";

                    if (_attachDocsToNotificationEmails)
                    {
                        tempFilePath = _transactionManager.GetZippedTransactionDocumentsAsTempFile(nodeTransaction.Id);

                        attachmentPath = tempFilePath;
                        attachmentName = "AQS Transaction Documents.zip";
                        message       += Environment.NewLine + Environment.NewLine +
                                         "The attached documents were returned from the AQS system for the submission.";
                    }

                    string subject = string.Format("AQS Submission Report");

                    _notificationManager.DoScheduleNotifications(transactionStatus, notificationEmails, subject, _dataRequest.Service.Name,
                                                                 attachmentPath, attachmentName, message);

                    AppendAuditLogEvent("Sent email notifications");
                }
                catch (Exception ex)
                {
                    AppendAuditLogEvent("Failed to send email notifications: {0}", ExceptionUtils.GetDeepExceptionMessage(ex));
                }
                finally
                {
                    FileUtils.SafeDeleteFile(tempFilePath);
                }
            }
        }
        protected override void UnbindFormData()
        {
            try
            {
                divPageError.Visible = false;

                this.Validate();

                if (this.IsValid)
                {
                    base.UnbindFormData();
                }
            }
            catch (Exception ex)
            {
                divPageError.Visible   = true;
                divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
            }
        }
        protected virtual string AddExchangeDocumentHeader(object data, bool doCompress, string docTransactionId)
        {
            string tempXmlFilePath = _settingsProvider.NewTempFilePath(".xml");

            try
            {
                ExceptionUtils.ThrowIfNull(data, "data");

                _serializationHelper.Serialize(data, tempXmlFilePath);
            }
            catch (Exception ex)
            {
                AppendAuditLogEvent("Failed to serialized data of type \"{0}\" with exception: {1}",
                                    data.GetType().Name, ExceptionUtils.GetDeepExceptionMessage(ex));
                throw;
            }

            return(AddExchangeDocumentHeader(tempXmlFilePath, doCompress, docTransactionId));
        }
        protected virtual void CallPostProcessingStoredProc()
        {
            AppendAuditLogEvent("Executing stored procedure \"{0}\" with ORGID of \"{1}\" and timeout of {2} seconds ...",
                                _storedProcName, _organizationId, _storedProcTimeout.ToString());

            try
            {
                IDbParameters parameters = _storedProcBaseDao.AdoTemplate.CreateDbParameters();
                parameters.AddWithValue("ORGID", _organizationId);

                _storedProcBaseDao.AdoTemplate.Execute <int>(delegate(DbCommand command)
                {
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = _storedProcName;
                    Spring.Data.Support.ParameterUtils.CopyParameters(command, parameters);

                    try
                    {
                        SpringBaseDao.ExecuteCommandWithTimeout(command, _storedProcTimeout,
                                                                delegate(DbCommand commandToExecute)
                        {
                            commandToExecute.ExecuteNonQuery();
                        });
                    }
                    catch (Exception ex2)
                    {
                        AppendAuditLogEvent("Error returned from stored procedure: {0}", ExceptionUtils.GetDeepExceptionMessage(ex2));
                        throw;
                    }

                    return(0);
                });

                AppendAuditLogEvent("Successfully executed stored procedure \"{0}\"", _storedProcName);
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to execute stored procedure \"{0}\" with error: {1}",
                                    _storedProcName, ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
        }
 protected void OnDeleteAllActivities(object sender, EventArgs e)
 {
     if (divPageError.Visible || !Page.IsValid)
     {
         // Error on page, get out of here
         return;
     }
     try
     {
         FillSearchParams();
         _dataService.DeleteActivities(DataItem, VisitHelper.GetVisit());
         DoSearch();
     }
     catch (Exception ex)
     {
         LOG.Error(ex.Message, ex);
         divPageError.Visible   = true;
         divPageError.InnerText = ExceptionUtils.GetDeepExceptionMessage(ex);
     }
 }
        protected virtual void DoEmailNotifications(Windsor.Node2008.WNOSDomain.Document zipResponseDocument, string localTransactionId)
        {
            if (!CollectionUtils.IsNullOrEmpty(_notificationEmails))
            {
                string tempFilePath = null;
                try
                {
                    string notificationEmails = StringUtils.Join(",", _notificationEmails);

                    AppendAuditLogEvent("Sending email notifications to {0} ...", StringUtils.JoinCommaEnglish(_notificationEmails));

                    TransactionStatus transactionStatus = new TransactionStatus();
                    transactionStatus.Id     = localTransactionId;
                    transactionStatus.Status = CommonTransactionStatusCode.Completed;

                    tempFilePath = _settingsProvider.NewTempFilePath();
                    File.WriteAllBytes(tempFilePath, zipResponseDocument.Content);

                    string attachmentPath = tempFilePath;
                    string attachmentName = zipResponseDocument.DocumentName;

                    string subject = string.Format("ICIS-NPDES Submission Processing Report");
                    string message =
                        string.Format("This email is to notify you that OpenNode2 has received and successfully processed submission results data from ICIS-NPDES.{0}{0}" +
                                      "The attached documents were returned from ICIS-NPDES in connection with the most recent submission.", Environment.NewLine);

                    _notificationManager.DoScheduleNotifications(transactionStatus, notificationEmails, subject, _dataRequest.Service.Name,
                                                                 attachmentPath, attachmentName, message);

                    AppendAuditLogEvent("Sent email notifications");
                }
                catch (Exception ex)
                {
                    AppendAuditLogEvent("Failed to send email notifications: {0}", ExceptionUtils.GetDeepExceptionMessage(ex));
                }
                finally
                {
                    FileUtils.SafeDeleteFile(tempFilePath);
                }
            }
        }
Beispiel #29
0
        public void ProcessSubmit(string transactionId)
        {
            LazyInit();

            IList <string> documentIds = _documentManager.GetDocumentIds(transactionId);

            if (CollectionUtils.IsNullOrEmpty(documentIds))
            {
                AppendAuditLogEvent("Didn't find any submit documents to process.");
                return;
            }
            else if (documentIds.Count > 1)
            {
                throw new InvalidOperationException(string.Format("More than one TRI document was attached to the transaction: {0}",
                                                                  documentIds.Count.ToString()));
            }

            string username = _transactionManager.GetTransactionUsername(transactionId);
            string docId    = documentIds[0];

            try
            {
                AppendAuditLogEvent("Calling stored procedure \"{0}\" to copy the document id \"{1}\" associated with transaction id \"{2}\" and NAAS account \"{3}\" ...",
                                    _copyStoredProcName, docId, transactionId, username);

                _baseDao.DoStoredProcWithArgs(_copyStoredProcName, STORED_PROC_PARAM_NAME_TRANSACTION_ID + ";" + STORED_PROC_PARAM_NAME_USER_NAME,
                                              new object[] { transactionId, username });

                AppendAuditLogEvent("Successfully called stored procedure \"{0}\" to copy the document id \"{1}\" associated with transaction id \"{2}\"",
                                    _copyStoredProcName, docId, transactionId);

                _documentManager.SetDocumentStatus(transactionId, docId, CommonTransactionStatusCode.Processed,
                                                   "Copied using stored proc " + _copyStoredProcName);
            }
            catch (Exception ex)
            {
                AppendAuditLogEvent("Failed to call stored procedure \"{0}\" to copy the document id \"{1}\" associated with transaction id \"{2}\": {3}",
                                    _copyStoredProcName, docId, transactionId, ExceptionUtils.GetDeepExceptionMessage(ex));
                throw;
            }
        }
Beispiel #30
0
        protected virtual void DoImport()
        {
            try
            {
                AppendAuditLogEvent("Deserializing AQS XML from file \"{0}\" ...", _xmlFilePath);
                AirQualitySubmissionType data = _serializationHelper.Deserialize <AirQualitySubmissionType>(_xmlFilePath);

                AppendAuditLogEvent("Importing AQS data into database ...");

                AQSPersistDataToDatabase dataPersister = new AQSPersistDataToDatabase(_baseDao, _clearMetadata);
                dataPersister.UpsertAirQualityData(data, this);

                AppendAuditLogEvent("Successfully imported AQS XML into database.");
            }
            catch (Exception e)
            {
                AppendAuditLogEvent("Failed to import AQS XML into database with error: {0}",
                                    ExceptionUtils.GetDeepExceptionMessage(e));
                throw;
            }
        }