Inheritance: SqlRow, TwitchUserInChannel
        public static SqlTwitchUserInChannel[] GetAllWithUsernames(TwitchChannel channel)
        {
            try {
                List <object[]> results = _table.Select("join twitch_users on id=" + _table.tableName + ".UserId", _table.tableName + ".*, name", "ChannelUserId=?a", new object[] { channel.user.id }, null, 0);

                if (results != null)
                {
                    SqlTwitchUserInChannel[] followers = new SqlTwitchUserInChannel[results.Count];
                    for (int i = 0; i < followers.Length; i++)
                    {
                        followers[i] = FromSql(channel, results[i]);
                    }

                    return(followers);
                }
                else
                {
                    return(null);
                }
            } catch (Exception e) {
                Log.exception(e);

                return(null);
            }
        }
        public static SqlTwitchUserInChannel[] GetNew(TwitchAlert twitchAlerts)
        {
            try {
                DateTime latestCreatedAt = twitchAlerts.lastFollowerNotification;

                List <object[]> results = _table.Select(null, null, "ChannelUserId=?a AND CreatedAt>?b",
                                                        new object[] { twitchAlerts.connection.channel.user.id, twitchAlerts.lastFollowerNotification }, null, 3);

                if (results != null && results.Count > 0)
                {
                    SqlTwitchUserInChannel[] followers = new SqlTwitchUserInChannel[results.Count];
                    for (int i = 0; i < followers.Length; i++)
                    {
                        followers[i] = FromSql(twitchAlerts.connection.channel, results[i]);
                        if (latestCreatedAt < followers[i].createdAt)
                        {
                            latestCreatedAt = followers[i].createdAt;
                        }
                    }

                    twitchAlerts.lastFollowerNotification = latestCreatedAt;
                    twitchAlerts.Save(false);

                    return(followers);
                }
                else
                {
                    return(null);
                }
            } catch (Exception e) {
                Log.exception(e);

                return(null);
            }
        }
        public static SqlTwitchUserInChannel[] GetAllWithUsernames(TwitchChannel channel)
        {
            try {
                List<object[]> results = _table.Select("join twitch_users on id=" + _table.tableName + ".UserId", _table.tableName + ".*, name", "ChannelUserId=?a", new object[] { channel.user.id }, null, 0);

                if(results != null) {
                    SqlTwitchUserInChannel[] followers = new SqlTwitchUserInChannel[results.Count];
                    for(int i = 0; i < followers.Length; i++) {
                        followers[i] = FromSql(channel, results[i]);
                    }

                    return followers;
                } else {
                    return null;
                }
            } catch(Exception e) {
                Log.exception(e);

                return null;
            }
        }
        public static SqlTwitchUserInChannel[] GetNew(TwitchAlert twitchAlerts)
        {
            try {
                DateTime latestCreatedAt = twitchAlerts.lastFollowerNotification;

                List<object[]> results = _table.Select(null, null, "ChannelUserId=?a AND CreatedAt>?b",
                        new object[] { twitchAlerts.connection.channel.user.id, twitchAlerts.lastFollowerNotification }, null, 3);

                if(results != null && results.Count > 0) {
                    SqlTwitchUserInChannel[] followers = new SqlTwitchUserInChannel[results.Count];
                    for(int i = 0; i < followers.Length; i++) {
                        followers[i] = FromSql(twitchAlerts.connection.channel, results[i]);
                        if(latestCreatedAt < followers[i].createdAt) {
                            latestCreatedAt = followers[i].createdAt;
                        }
                    }

                    twitchAlerts.lastFollowerNotification = latestCreatedAt;
                    twitchAlerts.Save(false);

                    return followers;
                } else {
                    return null;
                }
            } catch(Exception e) {
                Log.exception(e);

                return null;
            }
        }
Beispiel #5
0
 public TwitchUserInChannel[] GetNewFollowers(TwitchAlert alerts)
 {
     return(SqlTwitchUserInChannel.GetNew(alerts));
 }
Beispiel #6
0
 public TwitchUserInChannel[] GetAllUserInChannels(TwitchChannel channel)
 {
     return(SqlTwitchUserInChannel.GetAllWithUsernames(channel));
 }