// in its own thread.. public static Task <bool> DownloadMaps(IDiscoveryController discoveryform, Func <bool> cancelRequested, Action <string> logLine, Action <string> logError) // ASYNC process { try { string mapsdir = Path.Combine(EDDOptions.Instance.AppDataDirectory, "Maps"); if (!Directory.Exists(mapsdir)) { Directory.CreateDirectory(mapsdir); } logLine("Checking for new EDDiscovery maps"); BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload, discoveryform.LogLine); var files = github.ReadDirectory("Maps/V1"); return(Task.Factory.StartNew(() => github.DownloadFiles(files, mapsdir))); } catch (Exception ex) { logError("DownloadImages exception: " + ex.Message); var tcs = new TaskCompletionSource <bool>(); tcs.SetException(ex); return(tcs.Task); } }
// in its own thread.. public void DownloadMaps(Func <bool> cancelRequested) { LogLine("Checking for new EDDiscovery maps"); Task.Factory.StartNew(() => { BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload, LogLine); var files = github.ReadDirectory("Maps/V1"); if (files != null) { string mapsdir = Path.Combine(EDDOptions.Instance.AppDataDirectory, "Maps"); if (!Directory.Exists(mapsdir)) { Directory.CreateDirectory(mapsdir); } if (github.DownloadFiles(files, mapsdir)) { if (!cancelRequested()) { InvokeAsyncOnUiThread(() => { OnMapsDownloaded?.Invoke(); }); } } } }); }
// in its own thread.. public void DownloadExpeditions(Func <bool> cancelRequested) { LogLine("Checking for new Expedition data"); Task.Factory.StartNew(() => { BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload, LogLine); var files = github.ReadDirectory("Expeditions"); if (files != null) // may be empty, unlikely, but { string expeditiondir = Path.Combine(EDDOptions.Instance.AppDataDirectory, "Expeditions"); if (!Directory.Exists(expeditiondir)) { Directory.CreateDirectory(expeditiondir); } if (github.DownloadFiles(files, expeditiondir)) { if (!cancelRequested()) { bool changed = SavedRouteClass.UpdateDBFromExpeditionFiles(expeditiondir); InvokeAsyncOnUiThread(() => { OnExpeditionsDownloaded?.Invoke(changed); }); } } } }); }
public void DownloadHelp(Func <bool> cancelRequested) { Task.Factory.StartNew(() => { string helpdir = EDDOptions.Instance.HelpDirectory(); BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload, LogLine); var files = github.ReadDirectory("Help"); if (files != null) // may be empty, unlikely, but { if (github.DownloadFiles(files, helpdir)) { if (!cancelRequested()) { InvokeAsyncOnUiThread(() => { OnHelpDownloaded?.Invoke(); }); } } } }); }
public void DownloadExploration(Func <bool> cancelRequested) { LogLine("Checking for new Exploration data".Tx(this, "EXPL")); Task.Factory.StartNew(() => { string explorationdir = EDDOptions.Instance.ExploreAppDirectory(); BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload, LogLine); var files = github.ReadDirectory("Exploration"); if (files != null) // may be empty, unlikely, but { if (github.DownloadFiles(files, explorationdir)) { if (!cancelRequested()) { InvokeAsyncOnUiThread(() => { OnExplorationDownloaded?.Invoke(); }); } } } }); }