Exemplo n.º 1
0
        // 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); });
                        }
                    }
                }
            });
        }