Beispiel #1
0
        protected void Save()
        {
            // Cancel unused notifications
            foreach (var key in Notifications.Keys.ToList())
            {
                if (!Times.Contains(key))
                {
                    int nID = Notifications[key];
                    NotificationCenter.Cancel(nID);
                    Notifications.Remove(key);
                }
            }
            // Create new notifications
            foreach (var time in Times)
            {
                if (!Notifications.ContainsKey(time))
                {
                    var nt = MakeNotification(time);
                    NotificationCenter.Schedule(nt);
                    Notifications[time] = nt.ID;
                }
            }

            Preferences.Set(PreferencesKey("times"), Times);
            Preferences.Set(PreferencesKey("checkFrom"), checkFrom);
            Preferences.Set(PreferencesKey("notifications"), Notifications);

            Profile.Debug(new {
                Action        = "Saved monitor",
                Key           = this.key,
                Times         = Times,
                checkFrom     = checkFrom,
                Notifications = Notifications
            });
        }
        //Get data
        private void GetData()
        {
            try
            {
                var doc = new HtmlDocument();
                URL = ConfigurationManager.AppSettings["BaseURL"] + this.ClubID;
                doc.LoadHtml(ReadData(URL));

                var table = doc.GetElementbyId("tblSchedule");

                foreach (var tr in table.SelectSingleNode("tbody").SelectNodes("tr"))
                {
                    string time                = tr.SelectSingleNode("th").SelectSingleNode("h5").InnerText;
                    string className           = string.Empty;
                    string classDescriptionuri = string.Empty;
                    string classDescription    = string.Empty;
                    int    currDayInt          = 0;
                    foreach (var td in tr.SelectNodes("td"))
                    {
                        string currDay = Days[currDayInt];
                        if (td.HasChildNodes)
                        {
                            className        = td.InnerText;
                            classDescription = className.Split('(')[0].Trim();
                            try
                            {
                                classDescriptionuri = td.SelectSingleNode(".//strong//a").GetAttributeValue("href", "Class Description Link not found");
                            }
                            catch (NullReferenceException)
                            {
                                classDescriptionuri = td.SelectSingleNode(".//a").GetAttributeValue("href", "Class Description Link not found");
                            }
                            if (!ClassDescriptionsURIs.Contains(classDescriptionuri))
                            {
                                ClassDescriptionsURIs.Add(classDescriptionuri);
                            }
                        }
                        else
                        {
                            className = "No Class"; classDescriptionuri = "No Description URI";
                        }
                        ClassesList.Add(new Class(time, currDay, className, classDescriptionuri, classDescription));
                        currDayInt += 1;
                    }
                    //Store unique times
                    if (!Times.Contains(time))
                    {
                        Times.Add(time);
                    }
                }
            }
            catch (Exception e) { throw new Exception(e.Message); }
        }
Beispiel #3
0
        public virtual bool HasTime(TimeSpan time)
        {
            Validate(ref time);

            return(Times.Contains(time));
        }
Beispiel #4
0
 public bool CanConstruct(Value val)
 {
     return(Days.Contains(val.DayValue) && Times.Contains(val.TimeValue) &&
            Teachers.Contains(val.TeacherValue) && Audiences.Contains(val.AudienceValue));
 }