public object GetEvents(string district) { DateTime starttime = DateTime.Today - TimeSpan.FromDays(30); ArrayList monitors = Login.GetMonitors(); if (monitors == null || monitors.Count == 0) { monitors = new ArrayList(); monitors.Add("district:" + district); } Monitor.Options monoptions = new Monitor.Options(); ArrayList events = Event.GetTrackedEvents( monitors, starttime, DateTime.Today + TimeSpan.FromDays(1), monoptions); Event.Options evoptions = new Event.Options(); evoptions.AllMonitors = monitors; ArrayList ret = new ArrayList(); foreach (Event e in events) { ret.Add(e.ToHashtable(evoptions)); } return(ret); }
public static void GetEventsInternal(bool testing) { TableRow user = Util.Database.DBSelectID("users", CurrentUserId, "monitors, emailupdates_last"); ArrayList monitors = Login.ParseMonitors((string)user["monitors"]); Monitor.Options monoptions = new Monitor.Options(); Event.Options evoptions = new Event.Options(); evoptions.AllMonitors = monitors; DateTime from = Util.UnixDateToDateTime((int)user["emailupdates_last"]); DateTime to = DateTime.Today; // i.e. the very start of today if (testing) { from = to.AddDays(-30); } if (from > to - TimeSpan.FromSeconds(60 * 60 * 12)) { return; } EndDate = to; ArrayList events = Event.GetTrackedEvents(monitors, from, to, monoptions); if (events.Count > 0) { HadEvents = true; } DateRange = from.ToString("d"); if (DateRange != to.AddDays(-.5).ToString("d")) { DateRange += " - " + to.AddDays(-.5).ToString("d"); } //Console.Error.WriteLine("Doing email updates for " + user["email"] + ": " + events.Count + " events."); ArrayList ret = new ArrayList(); foreach (Event e in events) { ret.Add(e.ToHashtable(evoptions)); } users_events = ret; }
public ArrayList GetEvents(int backdays, int norelativepaths, int ical) { if (backdays == -1) { int[] t = { 1, 2, 3, 5, 7, 10, 14, 21 }; ArrayList e = null; for (int i = 0; i < t.Length; i++) { e = GetEvents(t[i], norelativepaths, ical); if (e.Count > 25) { break; } } return(e); } if (norelativepaths == 1) { HttpContext.Current.Items["govtrack-UseGlobalPath"] = this; // must be non-null } string days = HttpContext.Current.Request["days"]; if (days != null) { backdays = int.Parse(days); } DateTime starttime = DateTime.Today - TimeSpan.FromDays(backdays); string since = HttpContext.Current.Request["since"]; if (since != null && since == "yesterday") { starttime = DateTime.Today - TimeSpan.FromDays(2); } ArrayList mon = Monitors(false); if (HttpContext.Current.Request["options"] != null) { mon.AddRange(Login.ParseMonitors(HttpContext.Current.Request["options"])); } Monitor.Options monoptions = new Monitor.Options(); monoptions.MeetingsByEventDate = (ical == 1); ArrayList events = Event.GetTrackedEvents( mon, starttime, DateTime.Today + TimeSpan.FromDays(1), monoptions); string people = HttpContext.Current.Request["people"]; if (people == null) { foreach (string m in Login.GetMonitors()) { if (m.StartsWith("p:") && !mon.Contains(m)) { mon.Add(m); } } } else { foreach (string person in people.Split(',')) { int pid = int.Parse(person); string m = "p:" + pid; if (!mon.Contains(m)) { mon.Add("p:" + pid); } } } Event.Options evoptions = new Event.Options(); evoptions.AllMonitors = mon; ArrayList ret = new ArrayList(); foreach (Event e in events) { ret.Add(e.ToHashtable(evoptions)); } return(ret); }