public static List <AuditLog> GetPagedAuditLog(string ouid, int skip, ref int count, bool retCount, string filterBy, string orderBy, IDBConnection database) { Debug.Assert(database != null); var list = new List <AuditLog>(); using (var command = database.CreateStoredProcCommand("core", "usp_AuditLogGetFiltered")) { command.AddInParameter("@ouid", ouid); command.AddInParameter("@skip", skip); command.AddInParameter("@retcount", retCount); if (!string.IsNullOrEmpty(filterBy)) { command.AddInParameter("@filterBy", filterBy); } command.AddInParameter("@orderBy", orderBy); command.AddParameter("@count", ParameterDirection.InputOutput, count); command.ExecuteReader(dataReader => { var item = new AuditLog(); while (populateAuditLog(item, dataReader)) { list.Add(item); item = new AuditLog(); } }); if (retCount) { count = int.Parse(command.GetOutParameter("@count").Value.ToString()); } } return(list); }
public static void MarkAuditLogSuccessFul(string trackingUID, string entityKey, IDBConnection database) { Debug.Assert(database != null); using (var command = database.CreateStoredProcCommand("core", "usp_AuditLogMarkSuccessfulAdd")) { command.AddInParameter("@trackingUID", trackingUID); command.AddInParameter("@entityKey", entityKey); command.ExecuteNonQuery(); } }
public static int AddAuditLog(AuditLog auditLog, IDBConnection database, bool useLocalTime) { Debug.Assert(database != null); using (var command = database.CreateStoredProcCommand("core", "usp_AuditLogAdd")) { buildAuditLogCommandParameters(auditLog, command, useLocalTime, true); command.ExecuteNonQuery(); if (command.GetOutParameter("@id").Value == null) { return(-1); } auditLog.ID = Int32.Parse(command.GetOutParameter("@id").Value.ToString()); return(auditLog.ID.Value); } }
public static AuditLog GetAuditLog(string ouid, string uid, IDBConnection database) { Debug.Assert(database != null); var AuditLogReturned = new AuditLog(); using (var command = database.CreateStoredProcCommand("core", "usp_AuditLogGet")) { command.AddInParameter("@ouid", ouid); command.AddInParameter("@uid", uid); command.ExecuteReader(dataReader => { if (!populateAuditLog(AuditLogReturned, dataReader)) { AuditLogReturned = null; } }); } return(AuditLogReturned); }
public static IEnumerable <T> GetPaged <T>(Container container, IEntityRequestContext context, IEntityInfo info, int skip, ref int count, bool retCount, string filterBy, string orderBy, IDBConnection database) where T : class, IEntityIdentity { using (Logger.CreateTrace(LoggingBoundaries.ServiceBoundary, typeof(SqlQuery), "GetPaged")) { try { var view = $"[{info.Module}].[VW_{info.Entity}]"; List <T> list = new List <T>(); using (var command = database.CreateStoredProcCommand("common", "usp_EntityGetByFilter")) { string where = null; if (!string.IsNullOrEmpty(filterBy)) { where = OData3FilterBuilder.ParseExpression(command, filterBy, info.Properties.Keys.ToArray()); } command.AddInParameter("@view", view); command.AddInParameter("@skip", skip); command.AddInParameter("@retCount", retCount); if (!string.IsNullOrEmpty(where)) { command.AddInParameter("@where", where); } if (!string.IsNullOrEmpty(orderBy)) { command.AddInParameter("@orderBy", orderBy.Replace(", ", ",").Replace(" ", "_")); } command.AddParameter("@count", ParameterDirection.InputOutput, count); command.AddOutParameter("@debug", ""); var entity = new Entity(); var factory = container.GetInstance <IEntityCreateFactory>(); command.ExecuteReader(dataReader => { T item = factory.CreateNew(info) as T; while (PopulateEntity(item, info, dataReader, true)) { list.Add(item); item = factory.CreateNew(info) as T; } }); Logger.LogTrace(LoggingBoundaries.Database, "DYNAMIC SQL EXECUTED: {0}", command.GetOutParameter("@debug").Value.ToString()); if (retCount) { count = int.Parse(command.GetOutParameter("@count").Value.ToString()); } } return(list); } catch (Exception ex) { if (Logger.HandleException(LoggingBoundaries.ServiceBoundary, ex)) { throw; } } } return(null); }