public static async Task UploadDocToBlobStorage(float version, string filename) { string storageConnectionString = ""; CloudStorageAccount storageAccount = Common.GetStorageAccount(storageConnectionString); string blobUrl = await Common.GetBlobUrl(storageAccount, "tncdata", filename); CloudTable table = await Common.GetTableAsnyc(storageAccount, "CommonURL"); var v = "v" + version; VersionURL content = new VersionURL("TnC", v); content.ETag = "*"; content.URL = blobUrl; var query = new TableQuery <VersionURL>().Where(TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, v)); TableContinuationToken continuationToken = null; do { var result = await table.ExecuteQuerySegmentedAsync(query, continuationToken); continuationToken = result.ContinuationToken; if (result.Count() != 0) { foreach (VersionURL entity in result) { if (entity.RowKey == v) { try { var dec = version + .1; content.RowKey = "v" + dec; TableOperation updateOperation = TableOperation.Insert(content); await table.ExecuteAsync(updateOperation); } catch (Exception ex) { } } } } else { TableOperation insertOperation = TableOperation.Insert(content); await table.ExecuteAsync(insertOperation); } } while (continuationToken != null); }
/// <summary> /// Main updater method. Handles all update related functions for ease of use. /// </summary> public void HandleUpdates(bool hasUpdater = true, bool closeProgram = true) { /*if (hasUpdater) //commented our for now * DeleteUpdater();*///delete updater if found to keep directory clean and prevent using old updater GetGitApiText(); if (String.IsNullOrEmpty(VersionTextFromWeb)) { MelonLogger.Log("Failed to read release info for " + ProjectName); return; } if (String.IsNullOrEmpty(CurrentVersion)) { if (String.IsNullOrEmpty(ProjectExePath)) { MelonLogger.Log("Can't check for version info because Current version and Project EXE Path were set to null"); return; } CurrentVersion = FileVersionInfo.GetVersionInfo(ProjectExePath).FileVersion; } bool isUpdate = false; if (VersionURL.Contains("api.github.com/repos")) //This is a github api url { isUpdate = IsUpdate(CurrentVersion, GetLatestVersion(VersionTextFromWeb)); } else { isUpdate = IsUpdate(CurrentVersion, VersionTextFromWeb); } if (!isUpdate) { MelonLogger.Log(ProjectName + " is up to date!"); return; } MelonLogger.Log("An update is available for " + ProjectName); if (!DownloadUpdate) { return; } MelonLogger.Log("Downloading latest version..."); DownloadUpdates(); ExtractUpdater(); if (closeProgram) { MelonLogger.Log("Closing " + ProjectName + "..."); } if (hasUpdater) { LaunchUpdater(); } if (closeProgram) { Environment.Exit(0); } }