Esempio n. 1
0
 public void Run()
 {
     try
     {
         SleepState.Stop(true);
         this.sql = new Sql(true);
         this.tuner.Open(false);
         bool flag = false;
         while (!flag)
         {
             Service service = this.epgQueue.Dequeue(this.tuner);
             if (service == null)
             {
                 Log.Write(this.tuner.Name + ": このチューナの番組表取得完了。");
                 break;
             }
             int wait = EpgWait.GetInstance().GetWait(service.Nid);
             Log.Write("{4}: 番組表を取得しています... {1} ({0}/{3}/{2}s)".Formatex(new object[]
             {
                 this.epgQueue.Count,
                 service.Name,
                 wait,
                 service.EpgBasic ? "基本" : "詳細",
                 this.tuner.Name
             }));
             this.tuner.SetService(service);
             Stopwatch stopwatch = new Stopwatch();
             stopwatch.Start();
             while (stopwatch.ElapsedMilliseconds < (long)(wait * 1000))
             {
                 Record nextRecord = Record.GetNextRecord(this.tuner, this.sql);
                 flag = (this.StoppdApp() || !this.epgQueue.Enable || nextRecord != null);
                 if (flag)
                 {
                     Log.Write(this.tuner.Name + ": 中断しました。" + service.Name);
                     break;
                 }
                 Thread.Sleep(1000);
             }
             this.GetEvents(service);
         }
     }
     catch (Exception ex)
     {
         Log.Write(this.tuner.Name + ": 番組表取得に失敗しました。" + ex.Message);
         Log.Write(1, ex.StackTrace);
     }
     finally
     {
         try
         {
             this.sql.Dispose();
             this.tuner.Close();
         }
         catch
         {
         }
         SleepState.Stop(false);
     }
 }
Esempio n. 2
0
 public static EpgWait GetInstance()
 {
     if (EpgWait.singleObj == null)
     {
         EpgWait.singleObj = new EpgWait();
     }
     return(EpgWait.singleObj);
 }
Esempio n. 3
0
        public void Enqueue()
        {
            List <Service> obj = this.list;

            lock (obj)
            {
                this.list.Clear();
                using (Sql sql = new Sql(true))
                {
                    string nids = MainDef.GetInstance()["epg.basic"];
                    if (nids == "")
                    {
                        nids = "-1";
                    }
                    else
                    {
                        string[] array = nids.Split(new char[]
                        {
                            ','
                        });
                        string where = "";
                        for (int i = 0; i < array.Length; i++)
                        {
                            string s   = "(nid = " + array[i];
                            int    sid = EpgWait.GetInstance().GetSid(array[i].ToInt());
                            if (sid != -1)
                            {
                                s += " and sid = ";
                                s += sid;
                            }
                            s     += ")";
                            where += s;
                            if (i < (array.Length - 1))
                            {
                                where += " or ";
                            }
                        }
                        sql.Text = "select *, (fsid >> 32) as nid, (fsid & 0xffff) as sid from service where {0} group by nid, driver order by id";
                        sql.Text = sql.Text.Formatex(new object[]
                        {
                            where
                        });
//						Log.Write("sql(basic) = [{0}]".Formatex(new object[]{sql.Text}));
                        this.AddList(sql, true);
                    }

                    sql.Text = "select *, (fsid >> 32) as nid, ((fsid >> 16) & 0xffff) as tsid from service where nid not in ({0}) group by tsid, driver order by id";
                    sql.Text = sql.Text.Formatex(new object[]
                    {
                        nids
                    });
//					Log.Write("sql(ex) = [{0}]".Formatex(new object[]{sql.Text}));
                    this.AddList(sql, false);
                }
                this.Enable = (this.list.Count > 0);
            }
        }
Esempio n. 4
0
 private static void LoadDef()
 {
     Log.Write("初期化中...");
     Util.CopyUserFile();
     MainDef.GetInstance().Check();
     GenreConv.GetInstance();
     TextConv.GetInstance();
     EpgWait.GetInstance();
 }