public static void loadAasx(blazorSessionService bi, string value) { bi.aasxFileSelected = value; bi.container = null; if (bi.env != null) { bi.env.Dispose(); } bi.env = new AdminShellPackageEnv(bi.aasxFileSelected); bi.editMode = false; bi.thumbNail = null; signalNewData(3, bi.sessionNumber); // build new tree, all nodes closed }
public static void loadAasxFiles(blazorSessionService bi, bool load = true) { bi.aasxFiles = Directory.GetFiles(".", "*.aasx"); Array.Sort(bi.aasxFiles); if (load) { // ReSharper disable once UseMethodAny.0 // ReSharper disable once UseCollectionCountProperty if (bi.aasxFiles.Count() > 0) { loadAasx(bi, bi.aasxFiles[0]); } } }
public static async Task getAasxAsync(blazorSessionService bi, string input) { var handler = new HttpClientHandler(); handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials; //// handler.AllowAutoRedirect = false; string dataServer = new Uri(input).GetLeftPart(UriPartial.Authority); var client = new HttpClient(handler) { BaseAddress = new Uri(dataServer) }; input = input.Substring(dataServer.Length, input.Length - dataServer.Length); client.DefaultRequestHeaders.Add("Accept", "application/aas"); var response = await client.GetAsync(input); //// var contentLength = response.Content.Headers.ContentLength; var contentFn = response.Content.Headers.ContentDisposition?.FileName; // ReSharper disable PossibleNullReferenceException var contentStream = await response?.Content?.ReadAsStreamAsync(); if (contentStream == null) { return; } // ReSharper enable PossibleNullReferenceException Console.WriteLine("Writing file: " + contentFn); await using (var file = new FileStream(contentFn, FileMode.Create, FileAccess.Write, FileShare.None)) { await contentStream.CopyToAsync(file); } loadAasxFiles(bi, false); loadAasx(bi, contentFn); }