예제 #1
0
 private void AddEvent(object sender, SelectionChangedEventArgs e)
 {
     //MessageBox.Show(ActionList.SelectedIndex.ToString());
     ProgramItem pi = new ProgramItem();
     pi = (ProgramItem)ActionList.SelectedItem;
     App.ViewModel.SelectedEventTV = pi;
 }
예제 #2
0
        /// <summary>
        /// Get information of action on channel by date
        /// </summary>
        /// <param name="ch">channel id</param>
        /// <param name="date">date</param>
        /// <returns></returns>
        public List<ProgramItem> ActionByChDt(string ch, string date)
        {
            List<ProgramItem> progitem = new List<ProgramItem>();
            StreamReader sr = new StreamReader(xmlpath);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(sr.ReadToEnd());
            sr.Close();

            foreach (XmlElement xe in doc.DocumentElement.SelectNodes("//programme"))
            {
                if (xe.GetAttribute("channel") == ch)
                {
                    ProgramItem pitem = new ProgramItem();
                    XmlDocument pdoc = new XmlDocument();
                    pdoc.LoadXml("<root>" + xe.InnerXml+"</root>");

                    pitem.Start = DateTimeConvert(xe.GetAttribute("start")).ToString();
                    pitem.End = DateTimeConvert(xe.GetAttribute("stop")).ToString();

                    string dt = "";
                    for (int i = 6; i < 8; i++)
                    {
                        dt = dt + xe.GetAttribute("start")[i];
                    }
                    dt = dt + ".";
                    for (int i = 4; i < 6; i++)
                    {
                        dt = dt + xe.GetAttribute("start")[i];
                    }
                    dt = dt + ".";
                    for (int i = 0; i < 4; i++)
                    {
                        dt = dt + xe.GetAttribute("start")[i];
                    }
                    if (dt==date)
                    {
                        foreach (XmlElement x in pdoc.DocumentElement.SelectNodes("//title"))
                        {
                            pitem.Name = x.InnerText;
                        }
                        try
                        {
                            foreach (XmlElement x in pdoc.DocumentElement.SelectNodes("//desc"))
                            {
                                pitem.Discription = x.InnerText;
                            }
                        }catch(Exception){}
                        try
                        {
                            foreach (XmlElement x in pdoc.DocumentElement.SelectNodes("//category"))
                            {
                                pitem.Category = x.InnerText;
                            }
                        }catch(Exception){}
                    }
                    progitem.Add(pitem);
                }
            }
            return progitem;
        }
예제 #3
0
 private void AddSearchEvent(object sender, RoutedEventArgs e)
 {
     ProgramItem pi = new ProgramItem();
     pi = (ProgramItem)Search.SelectedItem;
     App.ViewModel.SelectedEventTV = pi;
 }
예제 #4
0
        /// <summary>
        /// Get information of action on channel by date
        /// </summary>
        /// <param name="ch">channel id</param>
        /// <param name="date">date</param>
        /// <returns></returns>
        public List<ProgramItem> ActionByChDt(string ch, string date)
        {
            List<ProgramItem> items = new List<ProgramItem>();
            Boolean iscurrent = false;
            HtmlWeb hwObject = new HtmlWeb();
            HtmlAgilityPack.HtmlDocument htmldocObject = hwObject.Load("http://www.ntvplus.ru/tv/lite.xl?channel=" + ch + "&day=" + date);
            try
            {
                foreach (HtmlNode links in htmldocObject.DocumentNode.SelectNodes("//div[@class='row2']"))
                {
                    HtmlAgilityPack.HtmlDocument htmlDocuments = new HtmlAgilityPack.HtmlDocument();
                    htmlDocuments.LoadHtml(links.InnerHtml);
                    try
                    {
                        foreach (HtmlNode link in htmlDocuments.DocumentNode.SelectNodes("//div[@class='program current']"))
                        {
                            HtmlAgilityPack.HtmlDocument htmls = new HtmlAgilityPack.HtmlDocument();
                            htmls.LoadHtml(link.InnerHtml);
                            ProgramItem it = new ProgramItem();
                            iscurrent = true;
                            foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='time']"))
                            {
                                it.Start = lnk.InnerText;
                            }
                            foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='content']"))
                            {
                                it.Name = lnk.InnerText;
                            }
                            it.Discription = null;
                            it.Dateint = date;
                            items.Add(it);
                        }
                    }
                    catch (Exception) { }
                }
            }
            catch (Exception) {}

            try
            {
                foreach (HtmlNode links in htmldocObject.DocumentNode.SelectNodes("//div[@class='row2']"))
                {
                    HtmlAgilityPack.HtmlDocument htmlDocuments = new HtmlAgilityPack.HtmlDocument();
                    htmlDocuments.LoadHtml(links.InnerHtml);
                    if (iscurrent)
                    {
                        try
                        {
                            foreach (HtmlNode link in htmlDocuments.DocumentNode.SelectNodes("//div[@class='program']"))
                            {
                                HtmlAgilityPack.HtmlDocument htmls = new HtmlAgilityPack.HtmlDocument();
                                htmls.LoadHtml(link.InnerHtml);
                                ProgramItem it = new ProgramItem();
                                foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='time']"))
                                {
                                    it.Start = lnk.InnerText;
                                }
                                foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='content']"))
                                {
                                    it.Name = lnk.InnerText;
                                }
                                it.Discription = null;
                                it.Dateint = date;
                                items.Add(it);
                            }
                        }
                        catch (Exception) { }
                    }
                }
            }
            catch (Exception) { }

            try
            {
                foreach (HtmlNode links in htmldocObject.DocumentNode.SelectNodes("//div[@class='row2 lastrow']"))
                {
                    HtmlAgilityPack.HtmlDocument htmlDocuments = new HtmlAgilityPack.HtmlDocument();
                    htmlDocuments.LoadHtml(links.InnerHtml);
                    if (!iscurrent)
                    {
                        try
                        {
                            foreach (HtmlNode link in htmlDocuments.DocumentNode.SelectNodes("//div[@class='program current']"))
                            {
                                HtmlAgilityPack.HtmlDocument htmls = new HtmlAgilityPack.HtmlDocument();
                                htmls.LoadHtml(link.InnerHtml);
                                ProgramItem it = new ProgramItem();
                                foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='time']"))
                                {
                                    it.Start = lnk.InnerText;
                                }
                                foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='content']"))
                                {
                                    it.Name = lnk.InnerText;
                                }
                                it.Discription = null;
                                it.Dateint = date;
                                items.Add(it);
                            }
                        }
                        catch (Exception) { }
                    }
                }
            }
            catch (Exception) { }

            try
            {
                foreach (HtmlNode links in htmldocObject.DocumentNode.SelectNodes("//div[@class='row2 lastrow']"))
                {
                    HtmlAgilityPack.HtmlDocument htmlDocuments = new HtmlAgilityPack.HtmlDocument();
                    htmlDocuments.LoadHtml(links.InnerHtml);
                    try
                    {
                        foreach (HtmlNode link in htmlDocuments.DocumentNode.SelectNodes("//div[@class='program']"))
                        {
                            HtmlAgilityPack.HtmlDocument htmls = new HtmlAgilityPack.HtmlDocument();
                            htmls.LoadHtml(link.InnerHtml);
                            ProgramItem it = new ProgramItem();
                            foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='time']"))
                            {
                                it.Start = lnk.InnerText;
                            }
                            foreach (HtmlNode lnk in htmls.DocumentNode.SelectNodes("//div[@class='content']"))
                            {
                                it.Name = lnk.InnerText;
                            }
                            it.Discription = null;
                            it.Dateint = date;
                            items.Add(it);
                        }
                    }
                    catch (Exception) { }
                }
            }
            catch (Exception) { }

            return AnalyzeProgramItem(items);
        }
예제 #5
0
        public void AddEvent(ProgramItem item)
        {
            const string GoogleDateFormatString = "yyyy-MM-ddTHH:mm:00Z";
            //service.Key = Key;

            var list = service.Events.List("primary");
            var fetch = list.Fetch();

            var start = new EventDateTime();
            start.DateTime = "2013-03-05T10:30:00Z";
            start.TimeZone = "+0000";

            var end = new EventDateTime();
            end.DateTime = "2013-03-05T10:35:00Z";
            end.TimeZone = "+0000";

            var e = new Event();

            e.End = end;
            e.Kind = "calendar#event";
            e.Start = start;
            e.Summary = "Summary";
            e.Id = null;
            e.ICalUID = null;
            e.Location = "";

            var eventReminder = new EventReminder();
            eventReminder.Method = "sms";
            eventReminder.Minutes = 15;

            e.Reminders = new Event.RemindersData();
            e.Reminders.UseDefault = false;
            e.Reminders.Overrides = new List<EventReminder>();
            e.Reminders.Overrides.Add(eventReminder);

            // Recurrence:
            var recur = "RRULE:FREQ=DAILY;COUNT=20;INTERVAL=1;WKST=SU";

            e.Recurrence = new List<string>();
            e.Recurrence.Add(recur);
            e.RecurringEventId = "12345";
            e.OriginalStartTime = start;

            AddEvent(e);
        }