Ejemplo n.º 1
0
 public async Task Delete(Guid tagId)
 {
     try
     {
         using var command = sql.CreateStoredProcedure("[Core].[DeleteTag]");
         command.WithParameter("tagId", tagId);
         await command.ExecuteNonQueryAsync().ConfigureAwait(false);
     }
     catch (Exception ex)
     {
         logger.LogWarning(ex, "Error when attempting to delete tag with id {tagId}", tagId);
         throw;
     }
 }
        public async Task <List <string> > GetSuspendedUsersForChannel(string channelName)
        {
            var result = new List <string>();

            using (var command = sql.CreateStoredProcedure("[Core].[GetSuspendedUsersForChannel]"))
            {
                command.WithParameter("channelOfOrigin", channelName);
                using var reader = await command.ExecuteReaderAsync().ConfigureAwait(false);

                while (await reader.ReadAsync().ConfigureAwait(false))
                {
                    result.Add(reader.GetString("username"));
                }
            }

            return(result);
        }
Ejemplo n.º 3
0
        public async Task <DateTime> GetTimeStampForLatestMessage()
        {
            using (var command = sql.CreateStoredProcedure("[Core].[GetLatestMessageTimestamp]"))
                using (var reader = await command.ExecuteReaderAsync().ConfigureAwait(false))
                {
                    if (await reader.ReadAsync().ConfigureAwait(false))
                    {
                        return(reader.GetDateTime("Timestamp"));
                    }
                }

            return(default);
Ejemplo n.º 4
0
        public async Task InsertPosition(RecordedPosition recordedPosition)
        {
            try
            {
                using (var command = sql.CreateStoredProcedure("[Core].[InsertPosition]"))
                {
                    command.WithParameter("latitude", recordedPosition.Latitude)
                    .WithParameter("longitude", recordedPosition.Longitude)
                    .WithParameter("altitude", recordedPosition.Altitude)
                    .WithParameter("timeStamp", recordedPosition.TimeStamp)
                    .WithParameter("username", recordedPosition.Username);

                    await command.ExecuteNonQueryAsync().ConfigureAwait(false);
                }
            }
            catch (Exception)
            {
                // LOG
                throw;
            }
        }
Ejemplo n.º 5
0
        public async Task <List <User> > GetUsers()
        {
            try
            {
                var result = new List <User>();

                using var command = sql.CreateStoredProcedure("[Core].[GetAllUsers]");
                using var reader  = await command.ExecuteReaderAsync().ConfigureAwait(false);

                while (await reader.ReadAsync().ConfigureAwait(false))
                {
                    result.Add(Serialization.Deserialize <User>(reader.GetString("data")));
                }

                return(result);
            }
            catch (Exception ex)
            {
                logger.LogWarning(ex, "Error when getting all users");
                throw;
            }
        }
Ejemplo n.º 6
0
        public async Task <List <Channel> > GetChannels()
        {
            try
            {
                var result = new List <Channel>();
                using var command = sql.CreateStoredProcedure("[Core].[GetChannels]");
                using var reader  = await command.ExecuteReaderAsync(System.Data.CommandBehavior.Default).ConfigureAwait(false);

                while (await reader.ReadAsync().ConfigureAwait(false))
                {
                    var channel = Serialization.Deserialize <Channel>(reader.GetString("data"));
                    result.Add(channel);
                }

                return(result);
            }
            catch (Exception ex)
            {
                logger.LogWarning(ex, "Error getting channels");
                throw;
            }
        }
        public async Task UpsertChatter(string twitchUsername, DateTime timestamp)
        {
            try
            {
                using var command = sql.CreateStoredProcedure("[Core].[UpsertChatter]");
                command.WithParameter("@twitchUsername", twitchUsername)
                .WithParameter("@firstTimeSeen", timestamp);

                await command.ExecuteNonQueryAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                logger.LogWarning(ex, "Error when attempting to save new chatter");
                throw;
            }
        }
Ejemplo n.º 8
0
        public async Task SaveBitrate(RecordedBitrate bitrate)
        {
            try
            {
                using (var command = sql.CreateStoredProcedure("[Core].[InsertBitrate]"))
                {
                    command.WithParameter("bitrate", bitrate.Bitrate)
                    .WithParameter("timestamp", bitrate.Timestamp)
                    .WithParameter("username", bitrate.Username);

                    await command.ExecuteNonQueryAsync().ConfigureAwait(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        public async Task Insert(string channel, string username, string deletedBy, string message, DateTime timestamp)
        {
            try
            {
                using var command = sql.CreateStoredProcedure("[Core].[InsertDeletedMessage]");
                command.WithParameter("username", username)
                .WithParameter("channelOfOrigin", channel)
                .WithParameter("message", message)
                .WithParameter("timestamp", timestamp)
                .WithParameter("deletedBy", deletedBy);

                await command.ExecuteNonQueryAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                logger.LogWarning(ex, "Error when attempting to save chat message");
                throw;
            }
        }