/// <summary> /// EV Exception if thrown use error code for locating message from resource file. /// This function logs the message as well... /// </summary> /// <param name="evException">EV specific application error.</param> /// <param name="consumerClass">Type</param> /// <param name="location">Location from which message is being logged - normally it's function name</param> /// <param name="jobId">int</param> /// <param name="jobRunId">int</param> /// <returns>Success Status.</returns> private void LogToEventLog(EVException evException, Type consumerClass, string location, int jobId, int jobRunId) { string message = Msg.FromRes(evException.GetErrorCode()); // Get user friendly message by the error code. LogMessage(message, true, LogCategory.Job, null); // Log message LogMessage(message + Constants.NextLineCharacter + evException.ToUserString(), consumerClass, location, EventLogEntryType.Error, jobId, jobRunId); }
/// <summary> /// Alert details are updated after Notification is sent. /// </summary> /// <param name="actualOccuranceCount">Number of times Job ran - Count incremented by one</param> /// <param name="runDate">Timestamp at which job ran</param> /// <param name="resultCount">Number of results found when job ran</param> /// <param name="allResultcount"></param> /// <param name="nextAlertRunDate">Future timestamp this alert has to run</param> /// <param name="alertId">Identifier for the alert</param> /// <param name="notificationId">Notification Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="searchQueryXml">Serialized Search Query object</param> /// <returns>success of failure status for the update</returns> internal bool UpdateAlertPostNotification(long actualOccuranceCount, DateTime runDate, long resultCount, long allResultcount, DateTime nextAlertRunDate, long alertId, Int64 notificationId, Int64 jobRunId, string searchQueryXml) { // Create Command object DbCommand dbCommand = AlertsDbManager.GetStoredProcCommand(Constants.STORED_PROCEDURE_UPDATE_ALERT_POST_NOTIFICATION); #region Add in parameters // Add in parameters AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_ACUAL_OCCURANCE_COUNT, DbType.Int32, actualOccuranceCount); if ((runDate == Constants.MSSQL2005_MINDATE) || (runDate == DateTime.MinValue)) { AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_LAST_RUN_DATE, DbType.DateTime, null); } else { AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_LAST_RUN_DATE, DbType.DateTime, runDate); } AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_MANUALALERT_RUNDATE, DbType.DateTime, null); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_LAST_RUN_RESULT_COUNT, DbType.Int32, resultCount); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_ALL_RUN_RESULT_COUNT, DbType.Int32, allResultcount); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_NEXT_RUN_DATE, DbType.DateTime, nextAlertRunDate); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_SEARCH_ALERT_ID, DbType.Int64, alertId); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_NOTIFICATION_ID, DbType.Int64, notificationId); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_JOB_RUN_ID, DbType.Int64, jobRunId); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_SEARCH_QUERY, DbType.Xml, searchQueryXml); #endregion // execute the stored procedure and use the return value for identifying errors object oFlag = AlertsDbManager.ExecuteScalar(dbCommand); int flag = (oFlag == null) ? Constants.INTEGER_INITIALIZE_VALUE : Convert.ToInt16(oFlag); // success of failure status if (flag > Constants.INTEGER_INITIALIZE_VALUE) { return(Constants.SUCCESS); } #region Error Conditions // exception handling EVException evException; // Check flag returned by the stored procedure to pin point errors. switch (flag) { case (Constants.UAPN_ERROR_NO_ALERT_RECORD_UPDATED): evException = new EVException().AddResMsg(Constants.ERROR_NO_ALERT_RECORD_UPDATED_POST_NOTIFICATION); break; case (Constants.UAPN_ERROR_UPDATING_ALERT_RECORD): evException = new EVException().AddResMsg(Constants.ERROR_UPDATING_ALERT_RECORD_POST_NOTIFICATION); break; case (Constants.UAPN_ERROR_UPDATING_ALERT_HISTORY): evException = new EVException().AddResMsg(Constants.ERROR_CREATING_ALERT_HISTORY); break; case (Constants.UAPN_ERROR_NO_ALERT_HISTORY_RECORD_INSERTED): evException = new EVException().AddResMsg(Constants.ERROR_RECORD_NOT_INSERTED_IN_HISTORY); break; default: // Unknown status returned by the stored procedure. evException = new EVException().AddResMsg(Constants.ERROR_UNKNOWN_FROM_STORED_PROCEDURE); break; } throw evException; #endregion }
/// <summary> /// Gets the EV exception description. /// </summary> /// <param name="evException">The ev exception.</param> /// <returns></returns> private string GetEvExceptionDescription(EVException evException) { string message = Msg.FromRes(evException.GetErrorCode()); // Get user friendly message by the error code. return(message); }
/// <summary> /// Alert details are updated after Notification is sent. /// </summary> /// <param name="actualOccuranceCount">Number of times Job ran - Count incremented by one</param> /// <param name="runDate">Timestamp at which job ran</param> /// <param name="resultCount">Number of results found when job ran</param> /// <param name="allResultcount"></param> /// <param name="nextAlertRunDate">Future timestamp this alert has to run</param> /// <param name="alertId">Identifier for the alert</param> /// <param name="notificationId">Notification Identifier</param> /// <param name="jobRunId">Job Run Identifier</param> /// <param name="searchQueryXml">Serialized Search Query object</param> /// <returns>success of failure status for the update</returns> internal bool UpdateAlertPostNotification(long actualOccuranceCount, DateTime runDate, long resultCount, long allResultcount, DateTime nextAlertRunDate, long alertId, Int64 notificationId, Int64 jobRunId, string searchQueryXml) { // Create Command object DbCommand dbCommand = AlertsDbManager.GetStoredProcCommand(Constants.STORED_PROCEDURE_UPDATE_ALERT_POST_NOTIFICATION); #region Add in parameters // Add in parameters AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_ACUAL_OCCURANCE_COUNT, DbType.Int32, actualOccuranceCount); if ((runDate == Constants.MSSQL2005_MINDATE) || (runDate == DateTime.MinValue)) { AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_LAST_RUN_DATE, DbType.DateTime, null); } else { AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_LAST_RUN_DATE, DbType.DateTime, runDate); } AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_MANUALALERT_RUNDATE, DbType.DateTime, null); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_LAST_RUN_RESULT_COUNT, DbType.Int32, resultCount); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_ALL_RUN_RESULT_COUNT, DbType.Int32, allResultcount); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_NEXT_RUN_DATE, DbType.DateTime, nextAlertRunDate); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_SEARCH_ALERT_ID, DbType.Int64, alertId); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_NOTIFICATION_ID, DbType.Int64, notificationId); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_JOB_RUN_ID, DbType.Int64, jobRunId); AlertsDbManager.AddInParameter(dbCommand, Constants.UAPN_SEARCH_QUERY, DbType.Xml, searchQueryXml); #endregion // execute the stored procedure and use the return value for identifying errors object oFlag = AlertsDbManager.ExecuteScalar(dbCommand); int flag = (oFlag == null) ? Constants.INTEGER_INITIALIZE_VALUE : Convert.ToInt16(oFlag); // success of failure status if (flag > Constants.INTEGER_INITIALIZE_VALUE) { return Constants.SUCCESS; } #region Error Conditions // exception handling EVException evException; // Check flag returned by the stored procedure to pin point errors. switch (flag) { case (Constants.UAPN_ERROR_NO_ALERT_RECORD_UPDATED): evException = new EVException().AddResMsg(Constants.ERROR_NO_ALERT_RECORD_UPDATED_POST_NOTIFICATION); break; case (Constants.UAPN_ERROR_UPDATING_ALERT_RECORD): evException = new EVException().AddResMsg(Constants.ERROR_UPDATING_ALERT_RECORD_POST_NOTIFICATION); break; case (Constants.UAPN_ERROR_UPDATING_ALERT_HISTORY): evException = new EVException().AddResMsg(Constants.ERROR_CREATING_ALERT_HISTORY); break; case (Constants.UAPN_ERROR_NO_ALERT_HISTORY_RECORD_INSERTED): evException = new EVException().AddResMsg(Constants.ERROR_RECORD_NOT_INSERTED_IN_HISTORY); break; default:// Unknown status returned by the stored procedure. evException = new EVException().AddResMsg(Constants.ERROR_UNKNOWN_FROM_STORED_PROCEDURE); break; } throw evException; #endregion }