예제 #1
0
        public void StartGetAllChannels(DSimpleEventListener taskeventlistener, string sourcename)
        {
            lock (this)
            {
                if (TaskState == ESimpleEvent.started)
                {
                    DoError("Busy");
                    return;
                }
                if (!SourcesByName.ContainsKey(sourcename))
                {
                    DoError("Wrong source name");
                    return;
                }
                TaskEventListener = taskeventlistener;
                TaskState         = ESimpleEvent.started;
                OnTaskEvent(ESimpleEvent.started);

                foreach (CSource sr in Sources)
                {
                    sr.ClearState();
                }
                SourcesByName[sourcename].ReadAllChannels(OnUpdateSourceEvent);
            }
        }
예제 #2
0
        void OnDownloadEvent(CDownload downloader, ESimpleEvent downloadEvent, string msg)
        {
            lock (this)
            {
                switch (downloadEvent)
                {
                case ESimpleEvent.started:
                    OnStateChanged(ESourceState.DownloadStarted);
                    break;

                case ESimpleEvent.canceled:
                    LogError("download canceled");
                    OnStateChanged(ESourceState.DownloadFailed);
                    break;

                case ESimpleEvent.failed:
                    OnStateChanged(ESourceState.DownloadFailed);
                    break;

                case ESimpleEvent.finished:
                    OnStateChanged(ESourceState.DownloadFinished);
                    break;
                }
            }
            OnSubTaskEvent(downloadEvent);
        }
예제 #3
0
 void OnTaskEvent(ESimpleEvent taskevent)
 {
     if (TaskEventListener != null)
     {
         TaskEventListener(taskevent);
     }
 }
예제 #4
0
 public void SaveXMLTvFile(string filename)
 {
     if (TaskState == ESimpleEvent.started)
     {
         DoError("Busy");
         return;
     }
     TaskState = ESimpleEvent.started;
     SaveXMLTvFileA(filename);
     TaskState = ESimpleEvent.finished;
 }
예제 #5
0
 public void LoadUserData(string filename)
 {
     if (TaskState == ESimpleEvent.started)
     {
         DoError("Busy");
         return;
     }
     TaskState = ESimpleEvent.started;
     LoadUserDataA(filename);
     TaskState = ESimpleEvent.finished;
 }
예제 #6
0
 void OnUpdateAllEvent(CSource sender, ESimpleEvent taskevent)
 {
     lock (this)
     {
         TaskState = CheckScheduledTasks();
         if (TaskState == ESimpleEvent.finished)
         {
             AfterUpdateAll(true);
         }
         if (TaskState == ESimpleEvent.failed)
         {
             AfterUpdateAll(false);
         }
     }
 }
예제 #7
0
        private void OnSubTaskEvent(ESimpleEvent endEvent)
        {
            lock (this)
            {
                SubTaskState = endEvent;
                switch (endEvent)
                {
                case ESimpleEvent.failed:
                    if (ScheduledTasks.Count == 0)
                    {
                        DoError("Task state error");
                        return;
                    }
                    ScheduledTasks.Clear();
                    OnTaskEvent(ESimpleEvent.failed);

                    break;

                case ESimpleEvent.canceled:
                    if (ScheduledTasks.Count == 0)
                    {
                        DoError("Task state error");
                        return;
                    }
                    ScheduledTasks.Clear();
                    OnTaskEvent(ESimpleEvent.canceled);

                    break;

                case ESimpleEvent.finished:
                    if (ScheduledTasks.Count == 0)
                    {
                        DoError("Task state error");
                        return;
                    }
                    ScheduledTasks.RemoveAt(0);
                    if (ScheduledTasks.Count == 0)
                    {
                        OnTaskEvent(ESimpleEvent.finished);
                    }
                    else
                    {
                        StartNextScheduledTasks();
                    }
                    break;
                }
            }
        }
예제 #8
0
 private void OnTaskEvent(ESimpleEvent endEvent)
 {
     TaskState = endEvent;
     if (endEvent == ESimpleEvent.canceled)
     {
         OnStateChanged(ESourceState.Canceled);
     }
     if (endEvent == ESimpleEvent.finished)
     {
         OnStateChanged(ESourceState.AllDone);
     }
     if (TaskEventListener != null)
     {
         TaskEventListener(this, endEvent);
     }
 }
예제 #9
0
        public void StartUpdateSelectedSourceFromWebTask(DSimpleEventListener taskeventlistener)
        {
            lock (this)
            {
                if (TaskState == ESimpleEvent.started)
                {
                    DoError("Busy");
                    return;
                }

                string[] sources = Settings.SelectedSources.Split(";".ToCharArray());
                if (sources == null || sources.Length == 0)
                {
                    return;
                }

                int srct = 0;

                foreach (var s in sources)
                {
                    if (SourcesByName.ContainsKey(s))
                    {
                        srct++;
                    }
                }
                if (srct == 0)
                {
                    return;
                }

                TaskEventListener = taskeventlistener;
                TaskState         = ESimpleEvent.started;
                OnTaskEvent(ESimpleEvent.started);

                foreach (CSource sr in Sources)
                {
                    sr.ClearState();
                }
                foreach (var s in sources)
                {
                    if (SourcesByName.ContainsKey(s))
                    {
                        SourcesByName[s].ReadDataFromWeb(OnUpdateAllEvent);
                    }
                }
            }
        }
예제 #10
0
        public void StartUpdateAllFromGzTask(DSimpleEventListener taskeventlistener)
        {
            lock (this)
            {
                if (TaskState == ESimpleEvent.started)
                {
                    DoError("Busy");
                    return;
                }
                ClearEPG();
                TaskEventListener = taskeventlistener;
                TaskState         = ESimpleEvent.started;
                OnTaskEvent(ESimpleEvent.started);

                foreach (CSource sr in Sources)
                {
                    sr.ReadDataFromGz(OnUpdateAllEvent);
                }
            }
        }
예제 #11
0
        void OnGetAllChannelsEventA(ESimpleEvent taskevent)
        {
            switch (taskevent)
            {
            case ESimpleEvent.finished:
                RefreshSelectSource();
                Application.DoEvents();
                DoMsg("Done!");
                MainForm mainform = Parent as MainForm;
                if (mainform != null)
                {
                    mainform.HideTaskMonitorX();
                }
                break;

            case ESimpleEvent.failed:
                DoMsg("Failed!");
                break;
            }
        }
예제 #12
0
        ESimpleEvent CheckScheduledTasks()
        {
            ESimpleEvent ret = ESimpleEvent.finished;

            foreach (CSource sr in Sources)
            {
                switch (sr.TaskState)
                {
                case ESimpleEvent.started:
                    return(ESimpleEvent.started);

                    break;

                case ESimpleEvent.failed:
                case ESimpleEvent.canceled:
                    ret = ESimpleEvent.failed;
                    break;
                }
            }
            return(ret);
        }
예제 #13
0
        void OnXMLReadEvent(ESimpleEvent xmlReadEvent)
        {
            lock (this)
            {
                switch (xmlReadEvent)
                {
                case ESimpleEvent.started:
                    OnStateChanged(ESourceState.ReadXMLStarted);
                    break;

                case ESimpleEvent.failed:
                case ESimpleEvent.canceled:
                    OnStateChanged(ESourceState.ReadXMLFailed);
                    break;

                case ESimpleEvent.finished:
                    OnStateChanged(ESourceState.ReadXMLFinished);
                    break;
                }
            }
            OnSubTaskEvent(xmlReadEvent);
        }
예제 #14
0
        void OnGZipExtractEvent(GZipExtract gzipExtract, ESimpleEvent gzipExtractEvent)
        {
            lock (this)
            {
                switch (gzipExtractEvent)
                {
                case ESimpleEvent.started:
                    OnStateChanged(ESourceState.GzExtractStarted);
                    break;

                case ESimpleEvent.failed:
                case ESimpleEvent.canceled:
                    OnStateChanged(ESourceState.GzFailed);
                    break;

                case ESimpleEvent.finished:
                    OnStateChanged(ESourceState.GzFinished);
                    break;
                }
            }
            OnSubTaskEvent(gzipExtractEvent);
        }
예제 #15
0
        void OnUpdateAllEventA(ESimpleEvent taskevent)
        {
            switch (taskevent)
            {
            case ESimpleEvent.started:
                closeToolStripMenuItem.Enabled = false;
                break;

            case ESimpleEvent.finished:
                DoMsg("Done!");
                closeToolStripMenuItem.Enabled = true;
                HideTaskMonitorX();
                RefreshView();
                break;

            case ESimpleEvent.canceled:
            case ESimpleEvent.failed:
                closeToolStripMenuItem.Enabled = true;
                DoMsg("Failed!");
                break;
            }
        }
예제 #16
0
        private void OnSubTaskEvent(ESimpleEvent endEvent)
        {
            lock (this)
            {
                SubTaskState = endEvent;
                switch (endEvent)
                {
                    case ESimpleEvent.failed:
                        if (ScheduledTasks.Count == 0)
                        {
                            DoError("Task state error");
                            return;
                        }
                        ScheduledTasks.Clear();
                        OnTaskEvent(ESimpleEvent.failed);

                        break;

                    case ESimpleEvent.canceled:
                        if (ScheduledTasks.Count == 0)
                        {
                            DoError("Task state error");
                            return;
                        }
                        ScheduledTasks.Clear();
                        OnTaskEvent(ESimpleEvent.canceled);

                        break;

                    case ESimpleEvent.finished:
                        if (ScheduledTasks.Count == 0)
                        {
                            DoError("Task state error");
                            return;
                        }
                        ScheduledTasks.RemoveAt(0);
                        if (ScheduledTasks.Count == 0)
                        {
                            OnTaskEvent(ESimpleEvent.finished);
                        }
                        else
                        {
                            StartNextScheduledTasks();
                        }
                        break;
                }
            }
        }
예제 #17
0
 void StartScheduledTasks()
 {
     if (ScheduledTasks.Count == 0)
     {
         DoError("state error");
         return;
     }
     State = ESourceState.None;
     if (CancelToken)
     {
         TaskState = ESimpleEvent.canceled;
         OnStateChanged(ESourceState.Canceled);
         return;
     }
     TaskState = ESimpleEvent.started;
     OnTaskEvent(ESimpleEvent.started);
     StartNextScheduledTasks();
 }
예제 #18
0
 void OnGetAllChannelsEvent(ESimpleEvent taskevent)
 {
     Invoke(new Action <ESimpleEvent>(OnGetAllChannelsEventA)
            , new object[] { taskevent });
 }
예제 #19
0
 void OnUpdateSourceEvent(CSource sender, ESimpleEvent taskevent)
 {
     OnUpdateAllEvent(sender, taskevent);
 }
예제 #20
0
 void StartNextScheduledTasks()
 {
     lock (this)
     {
         if (ScheduledTasks.Count == 0 || SubTaskState == ESimpleEvent.started
             || TaskState != ESimpleEvent.started)
         {
             DoError("state error");
             return;
         }
         if (CancelToken)
         {
             ClearState();
             TaskState = ESimpleEvent.canceled;
             OnTaskEvent(ESimpleEvent.canceled);
             return;
         }
         SubTaskState = ESimpleEvent.started;
         ScheduledTasks[0]();
     }
 }
예제 #21
0
        void OnDownloadEvent(CDownload downloader, ESimpleEvent downloadEvent, string msg)
        {
            lock (this)
            {
                switch (downloadEvent)
                {
                    case ESimpleEvent.started:
                        OnStateChanged(ESourceState.DownloadStarted);
                        break;
                    case ESimpleEvent.canceled:
                        LogError("download canceled");
                        OnStateChanged(ESourceState.DownloadFailed);
                        break;
                    case ESimpleEvent.failed:
                        OnStateChanged(ESourceState.DownloadFailed);
                        break;

                    case ESimpleEvent.finished:
                        OnStateChanged(ESourceState.DownloadFinished);
                        break;
                }
            }
            OnSubTaskEvent(downloadEvent);
        }
예제 #22
0
 void OnGetAllChannelsEvent(ESimpleEvent taskevent)
 {
     Invoke(new Action<ESimpleEvent>(OnGetAllChannelsEventA)
         , new object[] { taskevent });
 }
예제 #23
0
 private void OnTaskEvent(ESimpleEvent endEvent)
 {
     TaskState = endEvent;
     if (endEvent == ESimpleEvent.canceled)
         OnStateChanged(ESourceState.Canceled);
     if (endEvent == ESimpleEvent.finished)
         OnStateChanged(ESourceState.AllDone);
     if (TaskEventListener != null)
     {
         TaskEventListener(this, endEvent);
     }
 }
예제 #24
0
 public void LoadUserData(string filename)
 {
     if (TaskState == ESimpleEvent.started)
     {
         DoError("Busy");
         return;
     }
     TaskState = ESimpleEvent.started;
     LoadUserDataA(filename);
     TaskState = ESimpleEvent.finished;
 }
예제 #25
0
 void OnUpdateAllEventA(ESimpleEvent taskevent)
 {
     switch (taskevent)
     {
         case ESimpleEvent.started:
             closeToolStripMenuItem.Enabled = false;
             break;
         case ESimpleEvent.finished:
             DoMsg("Done!");
             closeToolStripMenuItem.Enabled = true;
             HideTaskMonitorX();
             RefreshView();
             break;
         case ESimpleEvent.canceled:
         case ESimpleEvent.failed:
             closeToolStripMenuItem.Enabled = true;
             DoMsg("Failed!");
             break;
     }
 }
예제 #26
0
 void OnUpdateAllEvent(ESimpleEvent taskevent)
 {
     Invoke(new Action<ESimpleEvent>(OnUpdateAllEventA)
         , new object[] { taskevent });
 }
예제 #27
0
        void OnGZipExtractEvent(GZipExtract gzipExtract, ESimpleEvent gzipExtractEvent)
        {
            lock (this)
            {
                switch (gzipExtractEvent)
                {
                    case ESimpleEvent.started:
                        OnStateChanged(ESourceState.GzExtractStarted);
                        break;
                    case ESimpleEvent.failed:
                    case ESimpleEvent.canceled:
                        OnStateChanged(ESourceState.GzFailed);
                        break;

                    case ESimpleEvent.finished:
                        OnStateChanged(ESourceState.GzFinished);
                        break;
                }
            }
            OnSubTaskEvent(gzipExtractEvent);
        }
예제 #28
0
 void OnUpdateSourceEvent(CSource sender, ESimpleEvent taskevent)
 {
     OnUpdateAllEvent(sender, taskevent);
 }
예제 #29
0
        public void StartUpdateSelectedSourceFromWebTask(DSimpleEventListener taskeventlistener)
        {
            lock (this)
            {
                if (TaskState == ESimpleEvent.started)
                {
                    DoError("Busy");
                    return;
                }

                string[] sources = Settings.SelectedSources.Split(";".ToCharArray());
                if (sources == null || sources.Length == 0) return;

                int srct = 0;

                foreach (var s in sources)
                {
                    if (SourcesByName.ContainsKey(s))
                    {
                        srct++;
                    }

                }
                if (srct == 0) return;

                TaskEventListener = taskeventlistener;
                TaskState = ESimpleEvent.started;
                OnTaskEvent(ESimpleEvent.started);

                foreach (CSource sr in Sources)
                {
                    sr.ClearState();
                }
                foreach (var s in sources)
                {
                    if (SourcesByName.ContainsKey(s))
                    {
                        SourcesByName[s].ReadDataFromWeb(OnUpdateAllEvent);
                    }
                }
            }
        }
예제 #30
0
 void OnUpdateAllEvent(ESimpleEvent taskevent)
 {
     Invoke(new Action <ESimpleEvent>(OnUpdateAllEventA)
            , new object[] { taskevent });
 }
예제 #31
0
 public void ClearState()
 {
     lock (this)
     {
         if (TaskState == ESimpleEvent.started)
         {
             DoError("busy");
         }
         ScheduledTasks.Clear();
         CancelToken = false;
         State = ESourceState.None;
         TaskState = ESimpleEvent.none;
         SubTaskState = ESimpleEvent.none;
         Downloader = null;
         GzipExtract = null;
         Progress = 0;
     }
 }
예제 #32
0
        public void StartUpdateSourceFromWebTask(DSimpleEventListener taskeventlistener, string sourcename)
        {
            lock (this)
            {
                if (TaskState == ESimpleEvent.started)
                {
                    DoError("Busy");
                    return;
                }
                if (!SourcesByName.ContainsKey(sourcename))
                {
                    DoError("Wrong source name");
                    return;
                }
                TaskEventListener = taskeventlistener;
                TaskState = ESimpleEvent.started;
                OnTaskEvent(ESimpleEvent.started);

                foreach (CSource sr in Sources)
                {
                    sr.ClearState();
                }
                SourcesByName[sourcename].ReadDataFromWeb(OnUpdateSourceEvent);
            }
        }
예제 #33
0
 void OnTaskEvent(ESimpleEvent taskevent)
 {
     if (TaskEventListener != null)
         TaskEventListener(taskevent);
 }
예제 #34
0
 void OnUpdateAllEvent(CSource sender, ESimpleEvent taskevent)
 {
     lock (this)
     {
         TaskState = CheckScheduledTasks();
         if (TaskState == ESimpleEvent.finished)
         {
             AfterUpdateAll(true);
         }
         if (TaskState == ESimpleEvent.failed)
         {
             AfterUpdateAll(false);
         }
     }
 }
예제 #35
0
 public void SaveXMLTvFile(string filename)
 {
     if (TaskState == ESimpleEvent.started)
     {
         DoError("Busy");
         return;
     }
     TaskState = ESimpleEvent.started;
     SaveXMLTvFileA(filename);
     TaskState = ESimpleEvent.finished;
 }
예제 #36
0
        void OnXMLReadEvent(ESimpleEvent xmlReadEvent)
        {
            lock (this)
            {
                switch (xmlReadEvent)
                {
                    case ESimpleEvent.started:
                        OnStateChanged(ESourceState.ReadXMLStarted);
                        break;
                    case ESimpleEvent.failed:
                    case ESimpleEvent.canceled:
                        OnStateChanged(ESourceState.ReadXMLFailed);
                        break;

                    case ESimpleEvent.finished:
                        OnStateChanged(ESourceState.ReadXMLFinished);
                        break;
                }
            }
            OnSubTaskEvent(xmlReadEvent);
        }
예제 #37
0
 void OnGetAllChannelsEventA(ESimpleEvent taskevent)
 {
     switch (taskevent)
     {
         case ESimpleEvent.finished:
             RefreshSelectSource();
             Application.DoEvents();
             DoMsg("Done!");
             MainForm mainform = Parent as MainForm;
             if (mainform != null) mainform.HideTaskMonitorX();
             break;
         case ESimpleEvent.failed:
             DoMsg("Failed!");
             break;
     }
 }
예제 #38
0
        public void StartUpdateAllTask(DSimpleEventListener taskeventlistener)
        {
            lock (this)
            {
                if (TaskState == ESimpleEvent.started)
                {
                    DoError("Busy");
                    return;
                }
                ClearEPG();
                TaskEventListener = taskeventlistener;
                TaskState = ESimpleEvent.started;
                OnTaskEvent(ESimpleEvent.started);

                foreach (CSource sr in Sources)
                    sr.ReadDataFromWeb(OnUpdateAllEvent);
            }
        }