Beispiel #1
0
        public static List <CommandsExecuted> getSpiritQuotesToBeAdded()
        {
            List <CommandsExecuted> commandsExecuted = new List <CommandsExecuted>();
            string sqlCommand = "select * from dbo.QuoteMessagesToBeAdded";

            using (SqlConnection con = new SqlConnection(connectionstring))
            {
                con.Open();
                using (SqlCommand command = new SqlCommand(sqlCommand, con))
                {
                    try
                    {
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            CommandsExecuted executedCommand = new CommandsExecuted();
                            executedCommand.id      = reader.GetInt32(0);
                            executedCommand.author  = reader.GetString(1);
                            executedCommand.content = reader.GetString(2);
                            executedCommand.channel = reader.GetString(4);
                            executedCommand.time    = reader.GetDateTimeOffset(5);
                            commandsExecuted.Add(executedCommand);
                        }
                        return(commandsExecuted);
                    }

                    catch
                    {
                        return(commandsExecuted);
                    }// using (SqlDataReader reader = command.ExecuteReader())
                }
            }
        }
Beispiel #2
0
        //get commands executed past 24 hr
        public static List <CommandsExecuted> getSpiritExecutedCommandsLast10Cmd()
        {
            List <CommandsExecuted> commandsExecuted = new List <CommandsExecuted>();
            string sqlCommand = "SELECT TOP(10) * FROM CommandExecuted ORDER BY [CreationTimeStamp] DESC ";

            using (SqlConnection con = new SqlConnection(connectionstring))
            {
                con.Open();
                using (SqlCommand command = new SqlCommand(sqlCommand, con))
                {
                    try
                    {
                        SqlDataReader reader = command.ExecuteReader();
                        while (reader.Read())
                        {
                            CommandsExecuted executedCommand = new CommandsExecuted();
                            executedCommand.author  = reader.GetString(1);
                            executedCommand.content = reader.GetString(2);
                            executedCommand.channel = reader.GetString(4);
                            executedCommand.time    = reader.GetDateTimeOffset(5);
                            commandsExecuted.Add(executedCommand);
                        }
                        return(commandsExecuted);
                    }

                    catch
                    {
                        return(commandsExecuted);
                    }// using (SqlDataReader reader = command.ExecuteReader())
                }
            }
        }