void Reload(object sender, System.Timers.ElapsedEventArgs args) { string sql = "select ID, FilterType, Word, UserID, Region from TwitterTrackFilter where IsActive;"; List <TrackFilter> newFilters = new List <TrackFilter>(); Helpers.RunSelect(_name, sql, newFilters, (values, reader) => { TrackFilter filter = new TrackFilter(); try { filter.ID = reader.GetInt32("ID"); filter.Type = (TrackFilter.FilterType)reader.GetByte("FilterType"); if (filter.Type == TrackFilter.FilterType.User) { filter.UserID = reader.GetInt64("UserID"); } else if (filter.Type == TrackFilter.FilterType.Region) { string[] coordinates = reader.GetString("Region").Split(','); filter.Longitude1 = double.Parse(coordinates[0], CultureInfo.InvariantCulture); filter.Latitude1 = double.Parse(coordinates[1], CultureInfo.InvariantCulture); filter.Longitude2 = double.Parse(coordinates[2], CultureInfo.InvariantCulture); filter.Latitude2 = double.Parse(coordinates[3], CultureInfo.InvariantCulture); } else //Word { filter.SetWords(reader.GetString("Word")); } values.Add(filter); } catch (Exception) { } } ); if (newFilters.Count() != GetFilterCount() || newFilters.Where(n => !IsFilterIDActive(n.ID.Value)).Any()) { ResetFilters(newFilters); } }
void Reload(object sender, System.Timers.ElapsedEventArgs args) { string sql = "select ID, FilterType, Word, UserID, Region from TwitterTrackFilter where IsActive;"; List<TrackFilter> newFilters = new List<TrackFilter>(); Helpers.RunSelect(_name, sql, newFilters, (values, reader) => { TrackFilter filter = new TrackFilter(); try { filter.ID = reader.GetInt32("ID"); filter.Type = (TrackFilter.FilterType)reader.GetByte("FilterType"); if (filter.Type == TrackFilter.FilterType.User) { filter.UserID = reader.GetInt64("UserID"); } else if (filter.Type == TrackFilter.FilterType.Region) { string[] coordinates = reader.GetString("Region").Split(','); filter.Longitude1 = double.Parse(coordinates[0], CultureInfo.InvariantCulture); filter.Latitude1 = double.Parse(coordinates[1], CultureInfo.InvariantCulture); filter.Longitude2 = double.Parse(coordinates[2], CultureInfo.InvariantCulture); filter.Latitude2 = double.Parse(coordinates[3], CultureInfo.InvariantCulture); } else //Word { filter.SetWords(reader.GetString("Word")); } values.Add(filter); } catch (Exception) { } } ); if (newFilters.Count() != GetFilterCount() || newFilters.Where(n => !IsFilterIDActive(n.ID.Value)).Any()) { ResetFilters(newFilters); } }
List<TrackFilter> GetActiveTrackFilters() { string sql = "select ID, FilterType, IsStrong, Word, UserID, Region from TwitterTrackFilter where IsActive;"; List<TrackFilter> activeFilters = new List<TrackFilter>(); Helpers.RunSelect(Name, sql, activeFilters, (values, reader) => { TrackFilter filter = new TrackFilter(); try { filter.ID = reader.GetInt32("ID"); filter.Type = (TrackFilter.FilterType)reader.GetByte("FilterType"); filter.IsStrong = reader.GetBoolean("IsStrong"); if (filter.Type == TrackFilter.FilterType.User) { filter.UserID = reader.GetInt64("UserID"); } else if (filter.Type == TrackFilter.FilterType.Region) { string[] coordinates = reader.GetString("Region").Split(','); filter.Longitude1 = double.Parse(coordinates[0], CultureInfo.InvariantCulture); filter.Latitude1 = double.Parse(coordinates[1], CultureInfo.InvariantCulture); filter.Longitude2 = double.Parse(coordinates[2], CultureInfo.InvariantCulture); filter.Latitude2 = double.Parse(coordinates[3], CultureInfo.InvariantCulture); } else //Word { filter.SetWords(reader.GetString("Word")); } values.Add(filter); } catch (Exception) { } }); return activeFilters; }
void Reload(object sender, System.Timers.ElapsedEventArgs args) { /* * Instead of * ID * IsActive * IsStrong * Hits1d * Discards1d * FilterType * Word * UserID * UserName * Region * * Replace with * ID * IsActive * Track * Hits1d * Discards1d * Tag * Weight * FilterType * Word * UserID * UserName * Region * */ string sql = "select FilterType, Word, UserID, Region from TwitterTrackFilter where IsActive;"; List<TrackFilter> newFilters = new List<TrackFilter>(); Helpers.RunSelect(_name, sql, newFilters, (values, reader) => { TrackFilter filter = new TrackFilter(); try { filter.Type = (TrackFilter.FilterType)reader.GetByte("FilterType"); if (filter.Type == TrackFilter.FilterType.User) { filter.UserID = reader.GetInt64("UserID"); } else if (filter.Type == TrackFilter.FilterType.Region) { string[] coordinates = reader.GetString("Region").Split(','); filter.Longitude1 = double.Parse(coordinates[0], CultureInfo.InvariantCulture); filter.Latitude1 = double.Parse(coordinates[1], CultureInfo.InvariantCulture); filter.Longitude2 = double.Parse(coordinates[2], CultureInfo.InvariantCulture); filter.Latitude2 = double.Parse(coordinates[3], CultureInfo.InvariantCulture); } else //Word { filter.Word = reader.GetString("Word"); } values.Add(filter); } catch (Exception) { } } ); if (newFilters.Count() != _filters.Count || newFilters.Where(n => _filters.Any(m => m.ID == n.ID)).Count() < newFilters.Count) { ResetFilters(newFilters); } }