public NasuniFiler() { Name = ""; Guid = ""; Serialno = ""; Build = ""; Offline = true; PercentUsed = 0.0; BasicInfo = new BasicInformation(); CifsInfo = new CIFSSettings(); FilerStatus = new Status(); }
private void LoadFilers() { if (authtoken == null) { GenerateToken(); } ValidateToken(); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); //Generate list of AD Subnets try { subnetlist.Clear(); adsites.Clear(); DirectoryContext adcontext = new DirectoryContext(DirectoryContextType.Forest, domain); Forest adforest = Forest.GetForest(adcontext); foreach (ActiveDirectorySite site in adforest.Sites) { ADSite newadsite = new ADSite { Sitename = site.Name }; foreach (ActiveDirectorySubnet subnet in site.Subnets) { newadsite.Subnets.Add(subnet.Name); subnetlist.Add(subnet.Name, site.Name); } adsites.Add(newadsite); } } catch { MessageBox.Show($"Please configure domain[{domain}] settings under File -> Settings", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } nasunifilers.Clear(); //Generate list of Nasuni Filers var client = new RestClient($"{nmc}/api/v1.1/filers/"); var request = new RestRequest(Method.GET); request.AddHeader("Authorization", authtoken); request.AddHeader("cache-control", "no-cache"); request.AddHeader("accept", "application/json"); request.AddHeader("content-type", "application/json"); IRestResponse response = client.Execute(request); filers = JsonConvert.DeserializeObject(response.Content); foreach (dynamic filer in filers.items) { BasicInformation newinfo = new BasicInformation { Build = filer.build, Description = filer.description, Guid = filer.guid, MgmtState = filer.management_state, SerialNo = filer.serial_number, Timezone = filer.settings.time.timezone }; CIFSSettings newcifs = new CIFSSettings { SMB = filer.settings.cifs.smb3, VetoFiles = filer.settings.cifs.veto_files, AioSupport = filer.settings.cifs.aio_support, SmbEncrypt = filer.settings.cifs.smb_encrypt, FruitSupport = filer.settings.cifs.fruit_support, DenyAccess = filer.settings.cifs.deny_access, ProtoLevel = filer.settings.cifs.proto_level, UnixExt = filer.settings.cifs.unix_ext, Anonymous = filer.settings.cifs.restrict_anonymous }; Status newstatus = new Status { Offline = filer.status.offline, Version = filer.status.osversion, Platform = filer.status.platform.platform_name, CacheSize = filer.status.platform.cache_status.size, CacheUsed = filer.status.platform.cache_status.used, CacheFree = filer.status.platform.cache_status.free, PercentFree = filer.status.platform.cache_status.percent_used, CpuCores = filer.status.platform.cpu.cores, CpuModel = filer.status.platform.cpu.model, CpuFreq = filer.status.platform.cpu.frequency, Sockets = filer.status.platform.cpu.sockets, Memory = filer.status.platform.memory, UpdateAvail = filer.status.updates.updates_available, CurrentVersion = filer.status.updates.current_version, NewVersion = filer.status.updates.new_version, Uptime = filer.status.uptime }; NasuniFiler newfiler = new NasuniFiler { Name = filer.description, Guid = filer.guid, Serialno = filer.serial_number, Build = filer.build, PercentUsed = Math.Round((Double)filer.status.platform.cache_status.percent_used, 2), Offline = filer.status.offline, BasicInfo = newinfo, CifsInfo = newcifs, FilerStatus = newstatus }; nasunifilers.Add(newfiler); } stopwatch.Stop(); TimeSpan ts = stopwatch.Elapsed; string elapsedTime = String.Format("{0:00}.{1:00}", ts.Seconds, ts.Milliseconds / 10); listviewFilers.ItemsSource = nasunifilers; buttonLoadFilers.IsEnabled = false; buttonRefreshFilers.IsEnabled = true; tabSearch.IsEnabled = true; if (sitesloaded) { statusbarStatus.Content = $"Nasuni Filer Refresh Completed in {elapsedTime} Seconds"; } else { statusbarStatus.Content = $"Nasuni Filer Load Completed in {elapsedTime} Seconds"; sitesloaded = true; } }