public async Task <IActionResult> Index() { var ARMtoken = await MsiHelper.GetToken("https://management.azure.com/"); var allCosmos = await GetAllCosmosDb(ARMtoken); ViewData["AllCosmosNames"] = new List <string>(allCosmos.Select(c => c.Name)); ViewData["AllCosmosJson"] = PrettyStringHelper.JsonPrettify(JsonConvert.SerializeObject(allCosmos)); // replace if in query, otherwise use defaults if (HttpContext.Request.Query.ContainsKey("rg")) { cosmos_rg = HttpContext.Request.Query["rg"]; } if (HttpContext.Request.Query.ContainsKey("name")) { cosmos_name = HttpContext.Request.Query["name"]; } ViewData["CosmosName"] = cosmos_name; var cosmosKeys = await CosmosHelper.GetKeysAsync(ARMtoken, subscription_id, cosmos_rg, cosmos_name); ViewData["NumKeys"] = cosmosKeys?.Keys?.Count.ToString() ?? "Failed to get keys for " + cosmos_name + " in rg " + cosmos_rg; if (cosmosKeys?.Keys != null) { ViewData["KeyNamesJson"] = PrettyStringHelper.JsonPrettify(JsonConvert.SerializeObject(cosmosKeys.Keys)); } else { ViewData["KeyNamesJson"] = "[]"; } return(View()); }
public async System.Threading.Tasks.Task <IActionResult> Index() { ViewData["SubscriptionId"] = subscription_id; try { var token = await MsiHelper.GetToken("https://storage.azure.com/"); ViewData["BlobTokenStatus"] = string.IsNullOrEmpty(token) ? "Failed to get token for storage.azure.com/" : "Got an ARM token for storage.azure.com/"; ViewData["DecodedToken"] = JwtHelper.DecodeToJson(token); if (string.IsNullOrEmpty(token)) { ViewData["Containers"] = "Get StorageToken was unsuccessful"; } else { ViewData["ContainersXML"] = AzureStorageHelper.GetAllContainerNamesXml(token, storage_account); } } catch (Exception ex) { Console.WriteLine(ex.Message); ViewData["Exception"] = ex?.Message; ViewData["InnerException"] = ex?.InnerException?.Message; } return(View()); }
public void get_MSI_details() { var apps = SystemHelpers.GetInstalledApplications().ToList(); var vsApps = apps.Where(app => app.Name.Contains("Visual Studio") || app.Name.Contains("Build Tools")).ToArray(); foreach (var appInfo in vsApps) { var path = MsiHelper.GetProductInfo(appInfo.Id.ToString("B")); if (!string.IsNullOrWhiteSpace(path)) { } } }
public async Task <IActionResult> Demo() { ViewData["SubscriptionId"] = subscription_id; try { var ARMtoken = await MsiHelper.GetToken("https://management.azure.com/"); ViewData["ARMTokenStatus"] = string.IsNullOrEmpty(ARMtoken) ? "Failed to get token for management.azure.com/" : "Got an ARM token for management.azure.com/"; var storageToken = await MsiHelper.GetToken("https://storage.azure.com/"); ViewData["BlobTokenStatus"] = string.IsNullOrEmpty(storageToken) ? "Failed to get token for storage.azure.com/" : "Got an ARM token for storage.azure.com/"; if (string.IsNullOrEmpty(ARMtoken)) { ViewData["NumKeys"] = "Get ARMtoken was unsuccessful, won't attempt to get COSMOS keys"; } else { // let's get this from input //var cosmosKey = CosmosHelper.GetKeys(ARMtoken, "e39a92b5-b9a4-43d1-97a3-c31c819a583a", "istiotest", "msitester-table"); var cosmosKey = await CosmosHelper.GetKeysAsync(ARMtoken, subscription_id, cosmos_rg, cosmos_name); ViewData["NumKeys"] = cosmosKey?.Keys?.Count.ToString() ?? "Failed to get keys for " + cosmos_name + " in rg " + cosmos_rg; } if (string.IsNullOrEmpty(storageToken)) { ViewData["Containers"] = "Get StorageToken was unsuccessful"; } else { ViewData["ContainersXML"] = AzureStorageHelper.GetAllContainerNamesXml(storageToken, storage_account); } var rgs = await AzureServiceHelper.GetResourceGroups(ARMtoken, subscription_id); ViewData["ResourceGroups"] = new List <string> (rgs.Select(r => r.Name).ToList()); } catch (Exception ex) { Console.WriteLine(ex.Message); ViewData["Exception"] = ex?.Message; ViewData["InnerException"] = ex?.InnerException?.Message; } return(View()); }
// Token: 0x060001F1 RID: 497 RVA: 0x0000BA34 File Offset: 0x00009C34 private void VerifyAndSetRegistry(object checkPath) { if (base.InvokeRequired) { base.Invoke(new UpdatesDownloadsPage.VerifyAndSetRegistryDelegate(this.VerifyAndSetRegistry), new object[] { checkPath }); return; } string text = (string)checkPath; string languagePackBundleFileName = Path.Combine(text, "LanguagePackBundle.exe"); bool flag = true; string value = string.Empty; if (File.Exists(languagePackBundleFileName)) { using (LanguagePackValidator languagePackValidator = new LanguagePackValidator(languagePackBundleFileName, this.localXMLVersioningPath, new Action <object>(this.UpdateDownloadUpdatesStatusBox))) { flag = languagePackValidator.Validate(); if (flag) { value = languagePackValidator.ValidatedFiles.FirstOrDefault((string x) => x.Equals(languagePackBundleFileName, StringComparison.InvariantCultureIgnoreCase)); } goto IL_C2; } } languagePackBundleFileName = null; IL_C2: bool flag2 = true; string text2 = string.Empty; if (Directory.Exists(text)) { string[] files = Directory.GetFiles(text, "*.msp", SearchOption.TopDirectoryOnly); if (files.Length != 0) { using (MspValidator mspValidator = new MspValidator(files, Path.Combine(this.sourceDir, "EXCHANGESERVER.msi"), languagePackBundleFileName, File.Exists(this.localXMLVersioningPath) ? this.localXMLVersioningPath : null, new Action <object>(this.UpdateDownloadUpdatesStatusBox))) { flag2 = mspValidator.Validate(); if (flag2) { text2 = mspValidator.ValidatedFiles.LastOrDefault((string x) => !string.IsNullOrEmpty(x) && MsiHelper.IsMspFileExtension(x)); } } } } bool flag3 = !string.IsNullOrEmpty(value); bool flag4 = !string.IsNullOrEmpty(text2); bool flag5 = false; if (flag && flag2) { flag5 = (text.Equals(this.saveToDirectory, StringComparison.InvariantCultureIgnoreCase) || this.MoveToSaveToPath()); } bool flag6 = false; if (flag5) { flag6 = this.SetRegistryKeyForBundle(); } if (flag6) { bool flag7 = false; string text3 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Temp\\ExchangeSetup\\MspTemp"); if (flag4) { MspUtility.UnpackMspCabs(Path.Combine(this.saveToDirectory, Path.GetFileName(text2)), text3); flag7 = SetupLauncherHelper.SetupRequiredFilesUpdated(SetupChecksFileConstant.GetSetupRequiredFiles(), SetupHelper.GetSetupRequiredFilesFromAssembly(text3), text3); } if (flag7 || flag3) { ExSetupUI.ExitApplication(ExitCode.Restart); } else if (flag4) { SetupLauncherHelper.CopyMspFiles(text3, Path.Combine(SetupHelper.WindowsDir, "Temp\\ExchangeSetup")); } this.UpdateDownloadUpdatesStatusBox(Strings.DownloadInstallationCompleted); base.SetWizardButtons(WizardButtons.Next); base.SetVisibleWizardButtons(WizardButtons.Next); return; } this.customProgressBarWithTitle.TitleOnly = true; this.UpdateDownloadUpdatesStatusBox(Strings.FinishedWithError(new LocalizedString(Logger.PathToFileLog))); base.SetVisibleWizardButtons(WizardButtons.Previous | WizardButtons.Next); base.SetWizardButtons(WizardButtons.Previous); }
// Token: 0x0600000D RID: 13 RVA: 0x0000241C File Offset: 0x0000061C internal ExitCode CheckForUpdates(Dictionary <string, object> parsedArguments) { string pathName = ((LongPath)parsedArguments["sourcedir"]).PathName; if (!Directory.Exists(pathName)) { this.ReportMessage(Strings.SetupChecksFailed(Strings.NoUpdates)); SetupLogger.Log(new LocalizedString("CurrentResult main.checkforupdates:283: " + ExitCode.Error)); return(ExitCode.Error); } string pathName2 = ((LongPath)parsedArguments["updatesdir"]).PathName; if (!Directory.Exists(pathName2)) { this.ReportMessage(Strings.SetupChecksFailed(Strings.NoUpdates)); SetupLogger.Log(new LocalizedString("CurrentResult main.checkforupdates:292: " + ExitCode.Error)); return(ExitCode.Error); } string text = Path.Combine(pathName, "ExchangeServer.msi"); if (!File.Exists(text)) { this.ReportMessage(Strings.SetupChecksFailed(Strings.NoUpdates)); SetupLogger.Log(new LocalizedString("CurrentResult main.checkforupdates:300: " + ExitCode.Error)); return(ExitCode.Error); } string[] files = Directory.GetFiles(pathName2, "*.msp", SearchOption.TopDirectoryOnly); if (files.Length == 0) { this.ReportMessage(Strings.SetupChecksFailed(Strings.NoUpdates)); SetupLogger.Log(new LocalizedString("CurrentResult main.checkforupdates:308: " + ExitCode.Error)); return(ExitCode.Error); } using (MspValidator mspValidator = new MspValidator(files, text, null, null, new Action <object>(this.ReportMessageCallback))) { if (!mspValidator.Validate()) { this.ReportMessage(Strings.SetupChecksFailed(Strings.InvalidUpdates)); SetupLogger.Log(new LocalizedString("CurrentResult main.checkforupdates:344: " + ExitCode.Error)); return(ExitCode.Error); } List <string> validatedFiles = mspValidator.ValidatedFiles; string text2 = validatedFiles.LastOrDefault((string x) => !string.IsNullOrEmpty(x) && MsiHelper.IsMspFileExtension(x)); if (!string.IsNullOrEmpty(text2)) { string text3 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "Temp\\ExchangeSetup\\MspTemp"); MspUtility.UnpackMspCabs(text2, text3); if (SetupLauncherHelper.SetupRequiredFilesUpdated(SetupChecksFileConstant.GetSetupRequiredFiles(), SetupHelper.GetSetupRequiredFilesFromAssembly(text3), text3)) { this.ReportMessage(Strings.RestartSetup); SetupLogger.Log(new LocalizedString("CurrentResult main.checkforupdates:336: " + ExitCode.Restart)); return(ExitCode.Restart); } } } SetupLogger.Log(new LocalizedString("CurrentResult main.checkforupdates:349: " + ExitCode.Success)); return(ExitCode.Success); }
private async Task <string> GetToken(string resource) { return(await MsiHelper.GetToken(resource)); // throws on error }