public void OnGet() { Console.WriteLine("GET called in index page."); try { GraphAssets assets = AssetConfiguration.Load(config.TableName, config.StorageConnectionString); List <VrtuAsset> list = new List <VrtuAsset>(); foreach (var item in assets.VirtualRtus) { list.Add(new VrtuAsset(item)); } list.Sort(); Data = JsonConvert.SerializeObject(list); } catch (Exception ex) { Console.WriteLine($"Exception getting assets - {ex.Message}"); } ClaimsPrincipal user = HttpContext.User; Name = user.Identity.Name; Console.WriteLine($"User identity name = {Name}"); }
public async Task <IActionResult> OnGetAsync(int id) { GraphAssets assets = AssetConfiguration.Load(config.TableName, config.StorageConnectionString); List <VrtuAsset> list = new List <VrtuAsset>(); foreach (var item in assets.VirtualRtus) { list.Add(new VrtuAsset(item)); } Data = JsonConvert.SerializeObject(list); return(Page()); }
public void OnGet() { GraphAssets assets = AssetConfiguration.Load(config.TableName, config.StorageConnectionString); List <VrtuAsset> list = new List <VrtuAsset>(); foreach (var item in assets.VirtualRtus) { list.Add(new VrtuAsset(item)); } Data = JsonConvert.SerializeObject(list); }
public void OnGet() { if (!this.Request.Query.ContainsKey("device")) { throw new Exception("Invalid request."); } string device = this.Request.Query["device"][0]; //if (!device.Contains("#")) //{ // throw new Exception("Invalid virtual rtu and device."); //} string formatted = device.Replace("#", ""); string[] parts = formatted.Split(new string[] { "-" }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length != 2) { throw new Exception("Invalid device specification."); } GraphAssets assets = AssetConfiguration.Load(config.TableName, config.StorageConnectionString); foreach (var vrtu in assets.VirtualRtus) { if (vrtu.Id.ToLowerInvariant() == parts[0].ToLowerInvariant()) { foreach (var item in vrtu.Devices) { if (item.Id.ToLowerInvariant() == parts[1].ToLowerInvariant()) { Device = item.Id; VirtualRtu = vrtu.Id; return; } } } } }