Example #1
0
        public void Write(LoggingLevel level, string message, Exception exception, Type source)
        {
            var connectionKey = ConnectionKey;
            var insertCommand = InsertCommand;
            var parameters = new DynamicParameters(new Dictionary<string, object>()
            {
                { "@date", DateTime.Now },
                { "@utcdate", DateTime.UtcNow },
                { "@level", EnumMapper.GetName(level) },
                { "@message", message },
                { "@exception", exception != null ? exception.ToString() : null },
                { "@source", source != null ? source.FullName : null },
                { "@thread", Thread.CurrentThread.ManagedThreadId }
            });

            lock (sync)
                queue.Enqueue(parameters);

            signal.Set();
        }
Example #2
0
        public static TheTableInformation FetchTableAndHistory(Guid? jobID = null, string tableName = null)
        {
            if ((jobID == null) == (string.IsNullOrWhiteSpace(tableName)))
            {
                throw new ArgumentException("Either job ID or job Name should be supplied, not both.");
            }

            var dbArgs = new Dapper.DynamicParameters();
            if (jobID != null)
            {
                dbArgs.Add("@jobID", jobID);
                tableName = (string)DapperWrapper.ExecuteScalar("SELECT [dbo].[FetchJobName](@jobID)", dbArgs);
                dbArgs.Add("@JobNamePattern", tableName);
            }
            else
            {
                dbArgs.Add("@JobNamePattern", tableName);
                jobID = (Guid?)DapperWrapper.ExecuteScalar("SELECT [dbo].[FetchJobID](@JobNamePattern)", dbArgs);
                if (jobID != null)
                {
                    dbArgs.Add("@jobID", jobID);
                }
            }

            var model = new TheTableInformation { TheName = tableName, TheData = null, TheHistory = null };
            if (jobID != null)
            {
                model.TheData = DapperWrapper.Query<TheTableEntry>("SELECT * FROM [dbo].[FetchATable](@jobID)", dbArgs).ToList();
                model.TheHistory = DapperWrapper.Query<TheTableHistoryEntry>(
                    "SELECT * FROM [dbo].[FetchJobHistory](@jobID, @JobNamePattern) ORDER BY [Completed] DESC", dbArgs).ToList();
            }
            return model;
        }