Esempio n. 1
0
        private async Task <bool> GetDataA(EpgChannel ch, DateTime date)
        {
            if (EpgData1.Source == "api")
            {
                return(false);
            }
            string url = GetURL(ch, date);

            string page = await ADownloader.GetString(url, LTC.Properties.Settings.Default.HTTPClientTimeOut);

            if (page == null)
            {
                TaskFormMsg(
                    string.Format("Failed to download programs for {0}: {1}",
                                  task_cur_ch.Name, task_date.ToString("yyyy.MM.dd"))
                    );
                return(false);
            }

            //File.WriteAllText(GetBasePath()+"\\e1.html", page);

            bool ret1 = await Task <bool> .Run(() =>
            {
                return(task_cur_ch.ReadProgrammsA(page, task_date));
            });

            if (!ret1)
            {
                TaskFormMsg(
                    string.Format("Failed to read programs for {0}: {1}",
                                  task_cur_ch.Name, task_date.ToString("yyyy.MM.dd"))
                    );
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public async void GetChannelListFromURL(string url, bool useapi)
        {
            if (string.IsNullOrEmpty(url))
            {
                MessageBox.Show("Wrong URL");
                return;
            }

            string s = await ADownloader.GetString(url, LTC.Properties.Settings.Default.HTTPClientTimeOut);

            if (string.IsNullOrEmpty(s))
            {
                MessageBox.Show("Download failed");
                return;
            }

            bool rt = false;

            if (useapi)
            {
                rt = EpgData1.ReadChannels(s);
            }
            else
            {
                rt = EpgData1.ReadChannelsA(s);
            }

            if (!rt)
            {
                MessageBox.Show("Failed to read channel list");
                return;
            }

            bsChannels.DataSource = EpgData1.Channels;
            MessageBox.Show("Done!");
        }