Exemplo n.º 1
0
        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 object GetVoteEvents()
        {
            HttpContext.Current.Items["govtrack-UseGlobalPath"] = this;             // must be non-null

            ArrayList mon = new ArrayList();

            mon.Add("misc:allvotes");

            int    backdays = 14;
            string days     = HttpContext.Current.Request["days"];

            if (days != null)
            {
                backdays = int.Parse(days);
            }

            ArrayList events = Event.GetTrackedEvents(
                mon,
                DateTime.Today - TimeSpan.FromDays(backdays),
                DateTime.Today + TimeSpan.FromDays(1),
                new Monitor.Options());

            string people = HttpContext.Current.Request["people"];

            if (people == null)
            {
                people = "";
            }

            foreach (string person in people.Split(','))
            {
                if (person == "")
                {
                    continue;
                }
                int pid = int.Parse(person);
                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);
        }
Exemplo n.º 3
0
        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);
        }