private static string GetExeFileNameFromConfigFile() { var exeFn = string.Empty; try { var path = InstalledVersionManager.StartUpPathOfExe + "Config.ini"; using (var reader = new StreamReader(path)) { string fullVersion = reader.ReadToEnd().Trim(); if (fullVersion.StartsWith("v")) { fullVersion = fullVersion.Substring(1); string[] subVs = fullVersion.Split('.'); int version = Convert.ToInt32(subVs[0]) * 10000; version += Convert.ToInt32(subVs[1]) * 100; version += Convert.ToInt32(subVs[2]); exeFn = InstalledVersionManager.GetExistPathByVersion(version) + "\\Bot.exe"; } } if (!string.IsNullOrEmpty(exeFn) && !File.Exists(exeFn)) { exeFn = null; } } catch { exeFn = null; } return(exeFn); }
private static InstalledVersion GetNewestVersion() { InstalledVersion newestVersion = null; var allInstalledVersions = InstalledVersionManager.GetAllInstalledVersionAndSortByVersionDesc(); if (allInstalledVersions != null && allInstalledVersions.Count() > 0) { newestVersion = allInstalledVersions[0]; } return(newestVersion); }
public static string GetExeFileName() { var fn = InstalledVersionManager.GetExeFileNameFromConfigFile(); if (string.IsNullOrEmpty(fn)) { fn = InstalledVersionManager.GetReleaseVersionExeFileNameForTest(); } if (string.IsNullOrEmpty(fn)) { fn = InstalledVersionManager.GetMaxVersionExeFileName(); } return(fn); }
private static string GetMaxVersionExeFileName() { var fn = string.Empty; var newestVersion = InstalledVersionManager.GetNewestVersion(); if (newestVersion != null) { fn = newestVersion.Path + "\\Bot.exe"; } if (!string.IsNullOrEmpty(fn) && !File.Exists(fn)) { fn = string.Empty; } return(fn); }
private static string GetExistPathByVersion(int version) { var path = string.Empty; var allInstalledVersions = InstalledVersionManager.GetAllInstalledVersionAndSortByVersionDesc(); if (allInstalledVersions != null && allInstalledVersions.Count() > 0) { InstalledVersion installedVersion = allInstalledVersions.SingleOrDefault(k => k.Version == version); if (installedVersion != null) { path = installedVersion.Path; } } return(path); }
public static void Main(string[] args) { try { if (BootUp.IsReboot(args)) { BootUp.WaitAppClose(30); } var exeFileName = InstalledVersionManager.GetExeFileName(); if (string.IsNullOrEmpty(exeFileName)) { throw new Exception("找不到可执行文件"); } Process.Start(exeFileName); } catch (Exception ex) { MessageBox.Show(ex.Message, "引导器错误"); } }
private static List <InstalledVersion> GetAllInstalledVersionAndSortByVersionDesc() { var installedVersions = new List <InstalledVersion>(); var dirts = Directory.GetDirectories(InstalledVersionManager.StartUpPathOfExe, "v*"); if (dirts != null && dirts.Length != 0) { foreach (string dir in dirts) { var versionFromDir = InstalledVersionManager.GetVersionFromDir(dir); if (versionFromDir > 0) { installedVersions.Add(new InstalledVersion { Path = dir, Version = versionFromDir }); } } } installedVersions = installedVersions.OrderByDescending(k => k.Version).ToList(); return(installedVersions); }