private async Task GetProPlusVersions() { await Retry.BlockAsync(3, 1, async() => { var cd = new ProPlusDownloader(); var channelVersionJson = await cd.GetChannelVersionJson(); var branches = GlobalObjects.ViewModel.JsonToBranches(channelVersionJson); if (branches != null) { GlobalObjects.ViewModel.Branches = branches; } var ppDownload = new ProPlusDownloader(); foreach (var channel in GlobalObjects.ViewModel.Branches) { var latestVersion = await ppDownload.GetLatestVersionAsync(channel.Branch.ToString(), OfficeEdition.Office32Bit); channel.CurrentVersion = latestVersion; if (channel.Versions.All(v => v.Version != latestVersion)) { channel.Versions.Insert(0, new Build() { Version = latestVersion }); } } }); }
public async Task <string> GetChannelBaseUrlAsync(string channel, OfficeEdition officeEdition) { if (_updateFiles == null) { using (var releaser = await myLock2.LockAsync()) { if (_updateFiles == null) { await Retry.BlockAsync(10, 1, async() => { _updateFiles = await DownloadCabAsync(); }); } } } var selectUpdateFiles = _updateFiles.FirstOrDefault(f => f.OfficeEdition == officeEdition); if (selectUpdateFiles == null) { return(null); } var branchBase = selectUpdateFiles.BaseURL.FirstOrDefault(b => b.Branch.ToLower() == channel.ToLower()); if (branchBase == null) { return(null); } return(branchBase.URL); }
public async Task <string> GenerateConfigXml() { var currentDirectory = Directory.GetCurrentDirectory() + @"\Scripts"; if (!System.IO.File.Exists(currentDirectory + @"\Generate-ODTConfigurationXML.ps1")) { currentDirectory = Directory.GetCurrentDirectory() + @"\Project\Scripts"; } var xmlFilePath = Environment.ExpandEnvironmentVariables(@"%temp%\localConfig.xml"); if (System.IO.File.Exists(xmlFilePath)) { System.IO.File.Delete(xmlFilePath); } var scriptPath = currentDirectory + @"\Generate-ODTConfigurationXML.ps1"; var scriptPathTmp = currentDirectory + @"\Tmp-Generate-ODTConfigurationXML.ps1"; if (!System.IO.File.Exists(scriptPathTmp)) { System.IO.File.Copy(scriptPath, scriptPathTmp, true); } var scriptUrl = AppSettings.GenerateScriptUrl; try { await Retry.BlockAsync(5, 1, async() => { using (var webClient = new WebClient()) { await webClient.DownloadFileTaskAsync(new Uri(scriptUrl), scriptPath); } }); } catch (Exception ex) { } var n = 1; await Retry.BlockAsync(2, 1, async() => { var arguments = @"/c Powershell -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle " + @"Hidden -File .\RunGenerateXML.ps1"; if (n == 2) { System.IO.File.Copy(scriptPathTmp, scriptPath, true); } var p = new Process { StartInfo = new ProcessStartInfo() { FileName = "cmd", Arguments = arguments, CreateNoWindow = true, UseShellExecute = false, WorkingDirectory = currentDirectory, RedirectStandardOutput = true, RedirectStandardError = true }, }; p.Start(); p.WaitForExit(); var error = await p.StandardError.ReadToEndAsync(); if (!string.IsNullOrEmpty(error)) { throw (new Exception(error)); } n++; }); await Task.Delay(100); var configXml = ""; if (System.IO.File.Exists(xmlFilePath)) { configXml = System.IO.File.ReadAllText(xmlFilePath); } try { var installOffice = new InstallOffice(); var updateUrl = installOffice.GetBaseCdnUrl(); if (!string.IsNullOrEmpty(updateUrl)) { var pd = new ProPlusDownloader(); var channelName = await pd.GetChannelNameFromUrlAsync(updateUrl, OfficeEdition.Office32Bit); if (!string.IsNullOrEmpty(configXml) && !string.IsNullOrEmpty(channelName)) { configXml = installOffice.SetUpdateChannel(configXml, channelName); } } } catch { } return(configXml); }