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); } }
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); }
void OnTaskEvent(ESimpleEvent taskevent) { if (TaskEventListener != null) { TaskEventListener(taskevent); } }
public void SaveXMLTvFile(string filename) { if (TaskState == ESimpleEvent.started) { DoError("Busy"); return; } TaskState = ESimpleEvent.started; SaveXMLTvFileA(filename); TaskState = ESimpleEvent.finished; }
public void LoadUserData(string filename) { if (TaskState == ESimpleEvent.started) { DoError("Busy"); return; } TaskState = ESimpleEvent.started; LoadUserDataA(filename); TaskState = ESimpleEvent.finished; }
void OnUpdateAllEvent(CSource sender, ESimpleEvent taskevent) { lock (this) { TaskState = CheckScheduledTasks(); if (TaskState == ESimpleEvent.finished) { AfterUpdateAll(true); } if (TaskState == ESimpleEvent.failed) { AfterUpdateAll(false); } } }
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; } } }
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); } }
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); } } } }
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); } } }
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; } }
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); }
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); }
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); }
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; } }
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(); }
void OnGetAllChannelsEvent(ESimpleEvent taskevent) { Invoke(new Action <ESimpleEvent>(OnGetAllChannelsEventA) , new object[] { taskevent }); }
void OnUpdateSourceEvent(CSource sender, ESimpleEvent taskevent) { OnUpdateAllEvent(sender, taskevent); }
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](); } }
void OnGetAllChannelsEvent(ESimpleEvent taskevent) { Invoke(new Action<ESimpleEvent>(OnGetAllChannelsEventA) , new object[] { taskevent }); }
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); } }
void OnUpdateAllEvent(ESimpleEvent taskevent) { Invoke(new Action<ESimpleEvent>(OnUpdateAllEventA) , new object[] { taskevent }); }
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); } } } }
void OnUpdateAllEvent(ESimpleEvent taskevent) { Invoke(new Action <ESimpleEvent>(OnUpdateAllEventA) , new object[] { taskevent }); }
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; } }
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); } }
void OnTaskEvent(ESimpleEvent taskevent) { if (TaskEventListener != null) TaskEventListener(taskevent); }
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; } }
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); } }