/////////////////////////////////////////////////////////////////////// private static string ReleaseTypeToString( ReleaseType releaseType ) { string result = releaseType.ToString(); if (!String.IsNullOrEmpty(result) && Char.IsDigit(result[result.Length - 1])) { result += DigitSeparator; } return(result); }
internal static string ToVersionString(this ReleaseType releaseType) { switch (releaseType) { case ReleaseType.Release: return(""); case ReleaseType.Preview: return(releaseType.ToString()); default: throw new ArgumentOutOfRangeException(nameof(releaseType), releaseType, null); } }
public bool SaveToFile(string productCodeName, string versionCodeName) { var dirPath = Path.Combine(AppGlobal.AppDataDirectory, productCodeName, versionCodeName); var XMLFilePath = Path.Combine(dirPath, string.Format("{0}.{1}", CodeName, RelXMLExtension)); var xDoc = new XmlDocument(); var declarationNode = xDoc.CreateXmlDeclaration("1.0", "", ""); xDoc.AppendChild(declarationNode); var comment = xDoc.CreateComment(string.Format("This file contains information about {0} - {1}", CodeName, DisplayName)); xDoc.AppendChild(comment); var docRoot = xDoc.CreateElement(xtRelease); XmlNode ndCodeName = xDoc.CreateElement(xtReleaseCode), ndDisplayName = xDoc.CreateElement(xtDisplayName), ndDescription = xDoc.CreateElement(xtDescription), ndStage = xDoc.CreateElement(xtStage), ndTargetDate = xDoc.CreateElement(xtTargetDate), ndRiskLevel = xDoc.CreateElement(xtRiskLevel), ndBuildNumber = xDoc.CreateElement(xtBuildNumber), ndReleaseType = xDoc.CreateElement(xtReleaseType); ndCodeName.InnerText = CodeName; ndDisplayName.InnerText = DisplayName; ndDescription.InnerText = Description; ndStage.InnerText = Stage.ToString(); ndTargetDate.InnerText = TargetDate; ndRiskLevel.InnerText = Risk.ToString(); ndBuildNumber.InnerText = BuildNumber.ToString(); ndReleaseType.InnerText = ReleaseType.ToString(); docRoot.AppendChild(ndCodeName); docRoot.AppendChild(ndDisplayName); docRoot.AppendChild(ndDescription); docRoot.AppendChild(ndStage); docRoot.AppendChild(ndTargetDate); docRoot.AppendChild(ndRiskLevel); docRoot.AppendChild(ndBuildNumber); docRoot.AppendChild(ndReleaseType); xDoc.AppendChild(docRoot); try { AppGlobal.CreateDirectory(dirPath); xDoc.Save(XMLFilePath); return(true); } catch (Exception e) { throw new Exception(string.Format("Unable to save Version {0} to file.{1}Message:{2}.", CodeName, Environment.NewLine, e.Message), e); } }
public static IFluentApi <T> ForReleaseType <T>(this IFluentApi <T> api, ReleaseType releaseType) where T : HasReleaseTypeParameter { return(api.ForReleaseType(releaseType.ToString())); }
/// <summary> /// Fetches a new release of the provided type, optionally at the specific version. /// </summary> /// <param name="releaseType">The <see cref="ReleaseType">ReleaseType</see> to fetch.</param> /// <param name="releaseVersion">The optional version to fetch.</param> /// <returns>The release on success, null on failure. Failure can occur if no versionwas found.</returns> public static Release Fetch(ReleaseType releaseType, GameVersion?releaseVersion = null) { string url; if (releaseVersion.HasValue) { url = String.Format("{0}/api/download/{1}/version/{2}", LauncherClient.Domain, releaseType.ToString().ToLowerInvariant(), releaseVersion.Value.ToVersionString()); } else { url = String.Format("{0}/api/download/{1}/version", LauncherClient.Domain, releaseType.ToString().ToLowerInvariant()); } using (var client = new WebClient()) { string value = client.DownloadString(url); JObject json = JObject.Parse(value); ReleaseType fetchedReleaseType; if (!Enum.TryParse((string)json["type"], true, out fetchedReleaseType) || releaseType != fetchedReleaseType) { return(null); } GameVersion fetchedVersion; if (!GameVersion.TryParse((string)json["version"], out fetchedVersion) || (releaseVersion.HasValue && !releaseVersion.Value.Equals(fetchedVersion))) { return(null); } string patchNotes = (string)json["patchNotes"]; var release = new Release() { mVersion = fetchedVersion, mPatchNotes = patchNotes, mType = fetchedReleaseType }; foreach (var download in json["downloads"]) { ReleasePlatform platform; if (Enum.TryParse((string)download["platform"], true, out platform)) { release.mPlatformChecksums.Add(platform, (string)download["checksum"]); } } return(release); } }
public static UpdateInfo CheckForUpdate(ReleaseType channel = ReleaseType.Unknown) { if (channel == ReleaseType.Unknown) { channel = AutoUpdateSettings.DefaultUpdateChannel; } foreach (var rawurl in MANIFEST_URLS) { var url = rawurl; // Attempt to match the url to change the channel if possible // This allows overrides to the URLs for deployment of custom builds, // but does not require that they adopt the channel system var match = AutoUpdateSettings.MATCH_AUTOUPDATE_URL.Match(url); if (match.Success) { var mg = match.Groups[AutoUpdateSettings.MATCH_UPDATE_URL_CHANNEL_GROUP]; // Replace the channel name with the chosen channel url = url.Substring(0, mg.Index) + channel.ToString().ToLowerInvariant() + url.Substring(mg.Index + mg.Length); } try { using (var tmpfile = new Library.Utility.TempFile()) { System.Net.WebClient wc = new System.Net.WebClient(); wc.Headers.Add(System.Net.HttpRequestHeader.UserAgent, string.Format("{0} v{1}{2}", APPNAME, SelfVersion.Version, string.IsNullOrWhiteSpace(InstallID) ? "" : " -" + InstallID)); wc.Headers.Add("X-Install-ID", InstallID); wc.DownloadFile(url, tmpfile); using (var fs = System.IO.File.OpenRead(tmpfile)) using (var ss = new SignatureReadingStream(fs, SIGN_KEY)) using (var tr = new System.IO.StreamReader(ss)) using (var jr = new Newtonsoft.Json.JsonTextReader(tr)) { var update = new Newtonsoft.Json.JsonSerializer().Deserialize <UpdateInfo>(jr); if (TryParseVersion(update.Version) <= TryParseVersion(SelfVersion.Version)) { return(null); } // Don't install a debug update on a release build and vice versa if (string.Equals(SelfVersion.ReleaseType, "Debug", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(update.ReleaseType, SelfVersion.ReleaseType, StringComparison.CurrentCultureIgnoreCase)) { return(null); } ReleaseType rt; if (!Enum.TryParse <ReleaseType>(update.ReleaseType, true, out rt)) { rt = ReleaseType.Unknown; } // If the update is too low to be considered, skip it // Should never happen, but protects against mistakes in deployment if (rt > channel) { return(null); } LastUpdateCheckVersion = update; return(update); } } } catch (Exception ex) { if (OnError != null) { OnError(ex); } } } return(null); }
public string PackageFolderPathLive() { return("/approot/" + Name + "_" + ReleaseType.ToString()); }
public string PackageFolderPath() { return("../../../DNNPackages/" + Name + "_" + ReleaseType.ToString()); }
public WorldRelease CutWorldRelease(string token, ReleaseType releaseType) { RestRequest request = BuildRequest("/Server/CutWorldRelease", Method.GET, token); request.AddQueryParameter("ReleaseType", releaseType.ToString()); var savedTimeout = _client.Timeout; _client.Timeout = 600000; IRestResponse response = _client.Execute(request); _client.Timeout = savedTimeout; WorldRelease newRelease = null; // No updates available or // Currently cutting a release / server is busy if (response.StatusCode == HttpStatusCode.NoContent || response.StatusCode == HttpStatusCode.Conflict) { return(newRelease); } if (response.StatusCode == HttpStatusCode.OK) { // check to make sure that the release was successful: var storedReleasePath = Path.GetFullPath(ConfigurationManager.AppSettings["WorldReleaseDir"]); newRelease = JsonConvert.DeserializeObject <WorldRelease>(response.Content); if (!Directory.Exists(storedReleasePath)) { try { Directory.CreateDirectory(storedReleasePath); } catch (Exception ex) { throw new ApplicationException("Unable to create stored release folder: " + ex.Message, ex); } } // If version is missing, no changes available: if (newRelease?.Version == null) { return(null); } if (!(newRelease.Version?.Length > 0)) { throw new ApplicationException( "World Release information contained errors: " + response.Content, response.ErrorException); } // Save the release info too th `estoredReleasePath` path in the App.config try { File.WriteAllText( Path.GetFullPath(Path.Combine(storedReleasePath, newRelease.Version + ".json")), response.Content); } catch (Exception e) { throw new ApplicationException( "Could not save release information to disk: " + e.Message + response.Content, response.ErrorException); } try { // Get the release var release = GetWorldRelease(token, newRelease.FileName); File.WriteAllBytes(Path.Combine(storedReleasePath, newRelease.FileName), release); } catch (Exception e) { throw new ApplicationException( "Could not save release to disk: " + e.Message + response.Content, response.ErrorException); } return(newRelease); } throw new ApplicationException("Unable to get the world release info from server: " + response.Content, response.ErrorException); }
public static UpdateInfo CheckForUpdate(ReleaseType channel = ReleaseType.Unknown) { if (channel == ReleaseType.Unknown) channel = AutoUpdateSettings.DefaultUpdateChannel; foreach(var rawurl in MANIFEST_URLS) { var url = rawurl; // Attempt to match the url to change the channel if possible // This allows overrides to the URLs for deployment of custom builds, // but does not require that they adopt the channel system var match = AutoUpdateSettings.MATCH_AUTOUPDATE_URL.Match(url); if (match.Success) { var mg = match.Groups[AutoUpdateSettings.MATCH_UPDATE_URL_CHANNEL_GROUP]; // Replace the channel name with the chosen channel url = url.Substring(0, mg.Index) + channel.ToString().ToLowerInvariant() + url.Substring(mg.Index + mg.Length); } try { using(var tmpfile = new Library.Utility.TempFile()) { System.Net.WebClient wc = new System.Net.WebClient(); wc.Headers.Add(System.Net.HttpRequestHeader.UserAgent, string.Format("{0} v{1}{2}", APPNAME, SelfVersion.Version, string.IsNullOrWhiteSpace(InstallID) ? "" : " -" + InstallID)); wc.Headers.Add("X-Install-ID", InstallID); wc.DownloadFile(url, tmpfile); using(var fs = System.IO.File.OpenRead(tmpfile)) using(var ss = new SignatureReadingStream(fs, SIGN_KEY)) using(var tr = new System.IO.StreamReader(ss)) using(var jr = new Newtonsoft.Json.JsonTextReader(tr)) { var update = new Newtonsoft.Json.JsonSerializer().Deserialize<UpdateInfo>(jr); if (TryParseVersion(update.Version) <= TryParseVersion(SelfVersion.Version)) return null; // Don't install a debug update on a release build and vice versa if (string.Equals(SelfVersion.ReleaseType, "Debug", StringComparison.InvariantCultureIgnoreCase) && !string.Equals(update.ReleaseType, SelfVersion.ReleaseType, StringComparison.CurrentCultureIgnoreCase)) return null; ReleaseType rt; if (!Enum.TryParse<ReleaseType>(update.ReleaseType, true, out rt)) rt = ReleaseType.Unknown; // If the update is too low to be considered, skip it // Should never happen, but protects against mistakes in deployment if (rt > channel) return null; LastUpdateCheckVersion = update; return update; } } } catch (Exception ex) { if (OnError != null) OnError(ex); } } return null; }