private async void GetReleaseNotes() { try { ReleaseNotes = "Loading..."; var originalLength = File.ReadAllLines("release_notes.txt").Length; var newVersion = NewVersion.ToString().Replace('.', '_'); var url = ApplicationDeployment.CurrentDeployment.UpdateLocation; var baseUrl = url.AbsoluteUri.Remove(url.AbsoluteUri.Length - url.Segments.Last().Length); var notesUri = $"{baseUrl}Application%20Files/ShadowClip_{newVersion}/release_notes.txt.deploy"; var client = new HttpClient(); var newReleaseNotes = await client.GetStringAsync(notesUri); var lines = newReleaseNotes.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var newLineCount = lines.Length - originalLength; var notesSinceLastUpdate = string.Join(Environment.NewLine, lines.Take(newLineCount)); ReleaseNotes = notesSinceLastUpdate; } catch (Exception e) { ReleaseNotes = $"Error Loading Release Notes: {e.Message}"; } }
public static bool HasUpdate() { GetUpdate(); Assembly CurentAssembly = Assembly.LoadFrom("LSExtendedWarrenty.dll"); Version CurrentVersion = CurentAssembly.GetName().Version; Assembly NewAssembly; Version NewVersion; try { NewAssembly = Assembly.LoadFrom("Repository\\LSExtendedWarrenty.dll"); NewVersion = NewAssembly.GetName().Version; } catch (System.IO.FileNotFoundException) { return(false); } try { int CurrentVersionVal = Int32.Parse(CurrentVersion.ToString().Replace(".", "")); int NewVersionVal = Int32.Parse(NewVersion.ToString().Replace(".", "")); if (CurrentVersionVal < NewVersionVal) { return(true); } } catch (Exception) { return(false); } return(false); }
private void CSVDownloadComplete(object sender, EventArgs e) { Dictionary <string, string> values = new Dictionary <string, string>(); string[] lines = File.ReadAllLines(CSVFile); foreach (string line in lines) { var lineValues = line.Split(','); values.Add(lineValues[0], lineValues[1]); } File.Delete(CSVFile); string os = ""; OperatingSystem os_info = Environment.OSVersion; PlatformID pid = os_info.Platform; switch (pid) { case PlatformID.Unix: os = "lin"; break; case PlatformID.MacOSX: os = "mac"; break; case PlatformID.Win32NT: os = "win"; if (Utils.Is64BitOperatingSystem) { os += ".64"; } else { os += ""; } break; default: break; } TrailerURL = "dQw4w9WgXcQ"; foreach (KeyValuePair <string, string> item in values) { if (item.Key == "curVerNum." + os) { NewVersion = Version.CreateFromString(item.Value); values.TryGetValue("URL." + os, out DownloadURL); } if (item.Key == "trailerID") { TrailerURL = item.Value; } } pbTrailer.LoadAsync("http://img.youtube.com/vi/" + TrailerURL + "/0.jpg"); if (!string.IsNullOrEmpty(TrailerURL)) { pbTrailer.Cursor = Cursors.Hand; } updateUI(); if (hasUpdate()) { MessageBox.Show("New Update for " + GameName + "\nNew Version: " + NewVersion.ToString() + "\nCurrent Installed Version: " + getVersionInstalled().ToString()); } if (JeremieLauncher.instance.index == index) { if (UpToDate()) { JeremieLauncher.instance.pb_gif.Image = Properties.Resources.no_update; } else { JeremieLauncher.instance.pb_gif.Image = Properties.Resources.update; } } }
static bool RefreshSettings() { List <string> Sections = GetSections(Path.Combine(Environment.CurrentDirectory, "config.ini")); Support.iniManager iniEngine = new Support.iniManager(Path.Combine(Environment.CurrentDirectory, "config.ini")); foreach (string item in Sections) { int NewVersion; if (!Int32.TryParse(iniEngine.IniReadValue(item, "Version"), out NewVersion)) { return(false); } string EncryptionKey = iniEngine.IniReadValue(item, "EncryptionKey"); string EncryptionIV = iniEngine.IniReadValue(item, "EncryptionIV"); int PingTimer; if (!int.TryParse(iniEngine.IniReadValue(item, "PingTimer"), out PingTimer)) { return(false); } int LogLevel; if (!int.TryParse(iniEngine.IniReadValue(item, "LogLevel"), out LogLevel)) { return(false); } if (AppsRunning.Count > 0) { int FormerVersion = Classes.CCstData.GetInstance(AppsRunning[0].Application).LatestClientVersion; if (NewVersion != FormerVersion) { Classes.CCstData.GetInstance(AppsRunning[0].Application).LatestClientVersion = NewVersion; Console.WriteLine("CONFIG update: Using now version " + NewVersion.ToString()); } int FormerLogLevel = Classes.CCstData.GetInstance(AppsRunning[0].Application).Logger.LogLevel; if (LogLevel != FormerLogLevel) { Classes.CCstData.GetInstance(AppsRunning[0].Application).Logger.LogLevel = LogLevel; Console.WriteLine("CONFIG update: Using now LogLevel " + LogLevel.ToString()); } string FormerEncryptionKey = Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionKey; if (FormerEncryptionKey != EncryptionKey) { Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionKey = EncryptionKey; Console.WriteLine("CONFIG update: Using now encryption key " + EncryptionKey); } string FormerEncryptionIV = Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionIV; if (FormerEncryptionIV != EncryptionIV) { Classes.CCstData.GetInstance(AppsRunning[0].Application).EncryptionIV = EncryptionIV; Console.WriteLine("CONFIG update: Using now encryption IV " + EncryptionIV); } int FormerPingTimer = Classes.CCstData.GetInstance(AppsRunning[0].Application).PingTimer; if (FormerEncryptionIV != EncryptionIV) { Classes.CCstData.GetInstance(AppsRunning[0].Application).PingTimer = PingTimer; Console.WriteLine("CONFIG update: Using now PingTimer " + PingTimer.ToString() + "ms"); } } } return(true); }
private string GetDownloadFileName() { string ext = url.Split('/').Last().Split('.').Last(); return(NewVersion.ToString() + "." + ext); }
public void IncrementAssemblyFileVersion(CommandLineArgs cmdArgs) { if (cmdArgs is null) { throw new ArgumentNullException(nameof(cmdArgs)); } if (!File.Exists(cmdArgs.FilePath)) { throw new OperationFailedException($"File {cmdArgs.FilePath} not found."); } this.CsprojFileName = Path.GetFileName(cmdArgs.FilePath); XName FileVersion = "FileVersion"; XElement csproj; try { csproj = System.Xml.Linq.XElement.Load(cmdArgs.FilePath); } catch (Exception e) { throw new OperationFailedException($"Unable to parse {CsprojFileName} as XML.", e); } if (csproj.Attribute("Sdk") is null) { throw new OperationFailedException($"{CsprojFileName} is not a Sdk-style project file."); } var propertyGroups = csproj.Elements().Where(x => x.Name == "PropertyGroup"); if (!propertyGroups.Any()) { throw new OperationFailedException($"{CsprojFileName} contains no <PropertyGroup>."); } XElement?fileVersion = propertyGroups.FirstOrDefault(x => x.Elements().Any(x => x.Name == FileVersion))?.Element(FileVersion); if (fileVersion is null) { //throw new OperationFailedException( // $"There is no <FileVersion>-Property in {CsprojFileName}. Open the project file and add <FileVersion>1.0.0.0</FileVersion> to the first <PropertyGroup>."); fileVersion = new XElement(FileVersion) { Value = "1.0.0.0" }; propertyGroups.First().Add(fileVersion); this.NewVersion = new Version(1, 0, 0, 0); } else if (fileVersion.Value.Length == 0) { fileVersion.Value = "1.0.0.0"; this.NewVersion = new Version(1, 0, 0, 0); this.OldVersion = new Version(); } else { try { string?[] parts = fileVersion.Value.Split('-', 2, StringSplitOptions.None); this.OldVersion = new Version(parts[0] !); if (cmdArgs.IncrementRevision) { this.NewVersion = new Version(OldVersion.Major, OldVersion.Minor, Math.Max(0, OldVersion.Build), OldVersion.Revision + 1); } else { this.NewVersion = new Version(OldVersion.Major, OldVersion.Minor, OldVersion.Build + 1, Math.Max(0, OldVersion.Revision)); } if (parts.Length == 2) { fileVersion.Value = $"{NewVersion.ToString(4)}-{parts[1]}"; } else { fileVersion.Value = NewVersion.ToString(4); } } catch (Exception e) { throw new OperationFailedException("Can't parse <FileVersion> as System.Version.", e); } } try { File.WriteAllText(cmdArgs.FilePath, csproj.ToString()); } catch (Exception e) { throw new OperationFailedException($"Can't write changes to {CsprojFileName}.", e); } }