Beispiel #1
0
        public async Task <ActionResult> Privacy()
        {
            IList <Models.EventLog> logs = new List <Models.EventLog>();

            using (SqlConnection connection = new SqlConnection(this.sqlConnectionString))
            {
                await connection.OpenAsync().ConfigureAwait(false);

                using var sqlcommand   = connection.CreateCommand();
                sqlcommand.CommandText = "GetLeaderboard";
                sqlcommand.CommandType = System.Data.CommandType.StoredProcedure;
                using (var reader = await sqlcommand.ExecuteReaderAsync().ConfigureAwait(false))
                {
                    while (reader.HasRows)
                    {
                        while (await reader.ReadAsync().ConfigureAwait(false))
                        {
                            var log = new Models.EventLog();
                            log.UserId = reader.GetString(0);
                            log.Qno    = reader.GetInt32(1);
                            logs.Add(log);
                        }
                        await reader.NextResultAsync().ConfigureAwait(false);
                    }
                }
            }
            return(View(logs));
        }
Beispiel #2
0
        /// <summary>
        /// Insert Log
        /// </summary>
        /// <param name="log"></param>
        /// <returns></returns>
        public bool InsertLog(Models.EventLog log)
        {
            string command = $@"INSERT INTO [dbo].[CoreEventLogs] ([EventId], [Logger],[LogLevel],[Message],[CreatedDate]) VALUES (@EventId, @Logger, @LogLevel, @Message, @CreatedDate)";
            List <SqlParameter> paramList = new List <SqlParameter>();

            paramList.Add(new SqlParameter("EventId", log.EventId));
            paramList.Add(new SqlParameter("Logger", log.Logger));
            paramList.Add(new SqlParameter("LogLevel", log.LogLevel));
            paramList.Add(new SqlParameter("Message", log.Message));
            paramList.Add(new SqlParameter("CreatedDate", log.CreatedDate));
            return(ExecuteNonQuery(command, paramList));
        }
 public FilterEventLog(Models.EventLog eventLog)
 {
     Fill(eventLog);
 }