static public BaseUtils.GitHubRelease CheckForNewinstaller(bool force = false) { try { BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDownload); BaseUtils.GitHubRelease rel = github.GetLatestRelease(); if (rel != null) { var currentVersion = System.Reflection.Assembly.GetExecutingAssembly().GetVersionString(); var releaseVersion = rel.ReleaseVersion; Version v1 = new Version(releaseVersion); Version v2 = new Version(currentVersion); if (force || v1.CompareTo(v2) > 0) // Test if newer installer exists: { return(rel); } } } catch (Exception) { } return(null); }
public static Task <bool> DownloadMaps(IDiscoveryController discoveryform, Func <bool> cancelRequested, Action <string> logLine, Action <string> logError) // ASYNC process { try { string mapsdir = Path.Combine(EDDConfig.Options.AppDataDirectory, "Maps"); if (!Directory.Exists(mapsdir)) { Directory.CreateDirectory(mapsdir); } logLine("Checking for new EDDiscovery maps"); BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(discoveryform.LogLine); var files = github.GetDataFiles("Maps/V1"); return(Task.Factory.StartNew(() => github.DownloadFiles(files, mapsdir))); /* * DeleteMapFile("DW4.png", logLine); * DeleteMapFile("SC-00.jpg", logLine); * return DownloadMapFiles(new[] * { * "SC-01.jpg", * "SC-02.jpg", * "SC-03.jpg", * "SC-04.jpg", * "SC-L4.jpg", * "SC-U4.jpg", * "SC-00.png", * "SC-00.json", * "Galaxy_L.jpg", * "Galaxy_L.json", * "Galaxy_L_Grid.jpg", * "Galaxy_L_Grid.json", * "DW1.jpg", * "DW1.json", * "DW2.jpg", * "DW2.json", * "DW3.jpg", * "DW3.json", * "DW4.jpg", * "DW4.json", * "Formidine.png", * "Formidine.json", * "Formidine trans.png", * "Formidine trans.json" * }, * (s) => logLine("Map check complete."), * cancelRequested, * logLine); */ } catch (Exception ex) { logError("DownloadImages exception: " + ex.Message); var tcs = new TaskCompletionSource <bool>(); tcs.SetException(ex); return(tcs.Task); } }
public bool DownloadFromGitHub(string downloadfolder, string gitdir) { DirectoryInfo di = new DirectoryInfo(downloadfolder); foreach (FileInfo file in di.GetFiles()) { file.Delete(); } BaseUtils.GitHubClass ghc = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDownload); List <BaseUtils.GitHubFile> files = ghc.GetDataFiles(gitdir); return(ghc.DownloadFiles(files, downloadfolder)); }
private void CheckState() { downloadactfolder = System.IO.Path.Combine(EDDOptions.Instance.AppDataDirectory, "temp\\act"); if (!System.IO.Directory.Exists(downloadactfolder)) { System.IO.Directory.CreateDirectory(downloadactfolder); } downloadflightfolder = System.IO.Path.Combine(EDDOptions.Instance.AppDataDirectory, "temp\\flights"); if (!System.IO.Directory.Exists(downloadflightfolder)) { System.IO.Directory.CreateDirectory(downloadflightfolder); } downloadaddonfolder = System.IO.Path.Combine(EDDOptions.Instance.AppDataDirectory, "temp\\addonfiles"); if (!System.IO.Directory.Exists(downloadaddonfolder)) { System.IO.Directory.CreateDirectory(downloadaddonfolder); } #if DEBUG downloadactdebugfolder = System.IO.Path.Combine(EDDOptions.Instance.AppDataDirectory, "temp\\Debug"); if (!System.IO.Directory.Exists(downloadactdebugfolder)) { System.IO.Directory.CreateDirectory(downloadactdebugfolder); } #endif if (managedownloadmode && EDDOptions.Instance.DontAskGithubForPacks == false) { BaseUtils.GitHubClass ghc = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload); System.Diagnostics.Debug.WriteLine("Checking github"); ghc.Download(downloadactfolder, "ActionFiles/V1", "*.act"); ghc.Download(downloadflightfolder, "VideoFiles/V1", "*.vid"); ghc.Download(downloadaddonfolder, "AddonFiles/V1", "*.inf"); #if DEBUG ghc.Download(downloadactdebugfolder, "ActionFiles/Debug", "*.act"); #endif } BeginInvoke((MethodInvoker)ReadyToDisplay); }
static public Task CheckForNewNotifications(Action <List <Notification> > callbackinthread) { return(Task.Factory.StartNew(() => { // only download if check github is on and we are not debugging the notifications with an override.. bool check = EDDOptions.Instance.CheckGithubFiles && EDDOptions.Instance.NotificationFolderOverride == null; string notificationsdir = EDDOptions.Instance.NotificationsAppDirectory(); if (check) // if download from github first.. { BaseUtils.GitHubClass github = new BaseUtils.GitHubClass(EDDiscovery.Properties.Resources.URLGithubDataDownload); var gitfiles = github.ReadDirectory("Notifications"); if (gitfiles != null) // may be empty, unlikely, but { check = github.DownloadFiles(gitfiles, notificationsdir); } } // always go thru what we have in that folder.. FileInfo[] allfiles = Directory.EnumerateFiles(notificationsdir, "*.xml", SearchOption.TopDirectoryOnly).Select(f => new System.IO.FileInfo(f)).OrderByDescending(p => p.LastWriteTime).ToArray(); List <Notification> nlist = new List <Notification>(); foreach (FileInfo f in allfiles) // process all files found.. { var list = ReadNotificationsFile(f.FullName); nlist.AddRange(list); } if (nlist.Count > 0) // if there are any, indicate.. { nlist.Sort(delegate(Notification left, Notification right) // in order, oldest first { return left.StartUTC.CompareTo(right.StartUTC); }); callbackinthread?.Invoke(nlist); } })); }