// Token: 0x060006B7 RID: 1719 RVA: 0x0002A608 File Offset: 0x00028808 public int StoreNotification(AuditDatabaseDecoratedContainer container) { if (container == null) { throw new ArgumentNullException("container"); } return(this.StoreNotification(container, this.GetActionIdFromActionType(container.ActionType))); }
// Token: 0x060006B9 RID: 1721 RVA: 0x0002A6DC File Offset: 0x000288DC protected int StoreNotification(AuditDatabaseDecoratedContainer decoratedDecoratedContainer, int actionTypeId) { if (AuditingDAL.log.IsTraceEnabled) { AuditingDAL.log.Trace("StoreNotification actionTypeId: " + actionTypeId); } int count = decoratedDecoratedContainer.Args.Count; if (AuditingDAL.log.IsDebugEnabled) { AuditingDAL.log.Debug("args.Count: " + count); } AuditingDAL.NetObjectInfo netObjectInfo = this.GetNetObjectInfo(decoratedDecoratedContainer.Args); StringBuilder stringBuilder = new StringBuilder("\r\nDECLARE @msg VARCHAR(max), @sev INT, @st INT;\r\n\r\n INSERT INTO [dbo].[AuditingEvents] \r\n (\r\n [TimeLoggedUtc], \r\n [AccountID], \r\n [ActionTypeID], \r\n [AuditEventMessage],\r\n [NetworkNode],\r\n [NetObjectID],\r\n [NetObjectType]\r\n )\r\n VALUES\r\n (\r\n @TimeLoggedUtc, \r\n @AccountID, \r\n @ActionTypeID, \r\n @AuditEventMessage,\r\n @NetworkNode,\r\n @NetObjectID,\r\n @NetObjectType\r\n );\r\n"); if (count > 0) { stringBuilder.Append(" SELECT @lastID = @@IDENTITY;\r\n\r\n INSERT INTO [dbo].[AuditingArguments] \r\n ([AuditEventID], [ArgsKey], [ArgsValue])\r\n "); stringBuilder.Append(string.Join(" UNION ALL ", from i in Enumerable.Range(0, count) select string.Format(" SELECT @lastID, @ArgsKey{0}, @ArgsValue{0} ", i))); } int result; using (SqlConnection sqlConnection = DatabaseFunctions.CreateConnection()) { using (SqlTransaction sqlTransaction = sqlConnection.BeginTransaction()) { using (SqlCommand textCommand = SqlHelper.GetTextCommand(stringBuilder.ToString())) { try { textCommand.Parameters.AddWithValue("@TimeLoggedUtc", decoratedDecoratedContainer.IndicationTime.ToUniversalTime()); textCommand.Parameters.AddWithValue("@AccountID", decoratedDecoratedContainer.AccountId.ToLower()); textCommand.Parameters.AddWithValue("@ActionTypeID", actionTypeId); textCommand.Parameters.AddWithValue("@AuditEventMessage", decoratedDecoratedContainer.Message); textCommand.Parameters.AddWithValue("@NetworkNode", (netObjectInfo.NetworkNodeID != null) ? netObjectInfo.NetworkNodeID.Value : DBNull.Value); textCommand.Parameters.AddWithValue("@NetObjectID", (netObjectInfo.NetObjectID != null) ? netObjectInfo.NetObjectID.Value : DBNull.Value); textCommand.Parameters.AddWithValue("@NetObjectType", (netObjectInfo.NetObjectType != null) ? netObjectInfo.NetObjectType : DBNull.Value); textCommand.Parameters.Add(new SqlParameter("@lastID", SqlDbType.Int) { Direction = ParameterDirection.InputOutput, Value = 0 }); for (int j = 0; j < count; j++) { string key = decoratedDecoratedContainer.Args.ElementAt(j).Key; string value = decoratedDecoratedContainer.Args.ElementAt(j).Value; if (AuditingDAL.log.IsDebugEnabled) { AuditingDAL.log.DebugFormat("Adding argument: '{0}':'{1}'", key, value); } textCommand.Parameters.AddWithValue(string.Format("@ArgsKey{0}", j), key); textCommand.Parameters.AddWithValue(string.Format("@ArgsValue{0}", j), value ?? string.Empty); } AuditingDAL.log.Trace("Executing query."); SqlHelper.ExecuteScalar(textCommand, sqlConnection, sqlTransaction); sqlTransaction.Commit(); int num = 0; int.TryParse(textCommand.Parameters["@lastID"].Value.ToString(), out num); result = num; } catch (Exception ex) { sqlTransaction.Rollback(); AuditingDAL.log.Error("Error while storing notification.", ex); throw; } } } } return(result); }
protected int StoreNotification( AuditDatabaseDecoratedContainer decoratedDecoratedContainer, int actionTypeId) { if (AuditingDAL.log.get_IsTraceEnabled()) { AuditingDAL.log.Trace((object)("StoreNotification actionTypeId: " + (object)actionTypeId)); } int count = decoratedDecoratedContainer.get_Args().Count; if (AuditingDAL.log.get_IsDebugEnabled()) { AuditingDAL.log.Debug((object)("args.Count: " + (object)count)); } AuditingDAL.NetObjectInfo netObjectInfo = this.GetNetObjectInfo((IDictionary <string, string>)decoratedDecoratedContainer.get_Args()); StringBuilder stringBuilder = new StringBuilder("\r\nDECLARE @msg VARCHAR(max), @sev INT, @st INT;\r\n\r\n INSERT INTO [dbo].[AuditingEvents] \r\n (\r\n [TimeLoggedUtc], \r\n [AccountID], \r\n [ActionTypeID], \r\n [AuditEventMessage],\r\n [NetworkNode],\r\n [NetObjectID],\r\n [NetObjectType]\r\n )\r\n VALUES\r\n (\r\n @TimeLoggedUtc, \r\n @AccountID, \r\n @ActionTypeID, \r\n @AuditEventMessage,\r\n @NetworkNode,\r\n @NetObjectID,\r\n @NetObjectType\r\n );\r\n"); if (count > 0) { stringBuilder.Append(" SELECT @lastID = @@IDENTITY;\r\n\r\n INSERT INTO [dbo].[AuditingArguments] \r\n ([AuditEventID], [ArgsKey], [ArgsValue])\r\n "); stringBuilder.Append(string.Join(" UNION ALL ", Enumerable.Range(0, count).Select <int, string>((Func <int, string>)(i => string.Format(" SELECT @lastID, @ArgsKey{0}, @ArgsValue{0} ", (object)i))))); } using (SqlConnection connection = DatabaseFunctions.CreateConnection()) { using (SqlTransaction sqlTransaction = connection.BeginTransaction()) { using (SqlCommand textCommand = SqlHelper.GetTextCommand(stringBuilder.ToString())) { try { textCommand.Parameters.AddWithValue("@TimeLoggedUtc", (object)decoratedDecoratedContainer.IndicationTime.ToUniversalTime()); textCommand.Parameters.AddWithValue("@AccountID", (object)decoratedDecoratedContainer.AccountId.ToLower()); textCommand.Parameters.AddWithValue("@ActionTypeID", (object)actionTypeId); textCommand.Parameters.AddWithValue("@AuditEventMessage", (object)decoratedDecoratedContainer.Message); SqlParameterCollection parameters1 = textCommand.Parameters; int? nullable = netObjectInfo.NetworkNodeID; object obj1; if (!nullable.HasValue) { obj1 = (object)DBNull.Value; } else { nullable = netObjectInfo.NetworkNodeID; obj1 = (object)nullable.Value; } parameters1.AddWithValue("@NetworkNode", obj1); SqlParameterCollection parameters2 = textCommand.Parameters; nullable = netObjectInfo.NetObjectID; object obj2; if (!nullable.HasValue) { obj2 = (object)DBNull.Value; } else { nullable = netObjectInfo.NetObjectID; obj2 = (object)nullable.Value; } parameters2.AddWithValue("@NetObjectID", obj2); textCommand.Parameters.AddWithValue("@NetObjectType", netObjectInfo.NetObjectType != null ? (object)netObjectInfo.NetObjectType : (object)DBNull.Value); SqlParameterCollection parameters3 = textCommand.Parameters; SqlParameter sqlParameter = new SqlParameter("@lastID", SqlDbType.Int); sqlParameter.Direction = ParameterDirection.InputOutput; sqlParameter.Value = (object)0; parameters3.Add(sqlParameter); for (int index = 0; index < count; ++index) { string key = decoratedDecoratedContainer.get_Args().ElementAt <KeyValuePair <string, string> >(index).Key; string str = decoratedDecoratedContainer.get_Args().ElementAt <KeyValuePair <string, string> >(index).Value; if (AuditingDAL.log.get_IsDebugEnabled()) { AuditingDAL.log.DebugFormat("Adding argument: '{0}':'{1}'", (object)key, (object)str); } textCommand.Parameters.AddWithValue(string.Format("@ArgsKey{0}", (object)index), (object)key); textCommand.Parameters.AddWithValue(string.Format("@ArgsValue{0}", (object)index), (object)(str ?? string.Empty)); } AuditingDAL.log.Trace((object)"Executing query."); SqlHelper.ExecuteScalar(textCommand, connection, sqlTransaction); sqlTransaction.Commit(); int result = 0; int.TryParse(textCommand.Parameters["@lastID"].Value.ToString(), out result); return(result); } catch (Exception ex) { sqlTransaction.Rollback(); AuditingDAL.log.Error((object)"Error while storing notification.", ex); throw; } } } } }