// // Basic memeber management // public void Add(PackageContainerRepoItem fi) { if (fi == null) { return; } this.FileMap?.Add(fi); fi.ContainerList = this; }
public bool Contains(PackageContainerRepoItem fi) { foreach (var fr in this) { if (true == fr?.Contains(fi)) { return(true); } } return(false); }
// // Further finds // public PackageContainerListBase FindRepository(PackageContainerRepoItem fi) { foreach (var fr in this) { if (true == fr?.Contains(fi)) { return(fr); } } return(null); }
public void Remove(PackageContainerRepoItem fi) { if (fi == null || this.FileMap == null) { return; } if (!this.FileMap.Contains(fi)) { return; } this.FileMap.Remove(fi); }
public void Push(PackageContainerRepoItem item, string fullPath) { // access if (item == null || !fullPath.HasContent()) { return; } // make a COPY (flexible in types) var jsonCopy = JsonConvert.SerializeObject(item); var itemCopy = JsonConvert.DeserializeObject <PackageContainerRepoItem>(jsonCopy); if (itemCopy == null) { return; } // record new location itemCopy.Location = fullPath; // check, if already in PackageContainerRepoItem foundItem = null; foreach (var it in EnumerateItems()) { if (it?.Location?.Trim().ToLower() == fullPath.Trim().ToLower()) { foundItem = it; break; } } // if so, delete it if (foundItem != null) { this.Remove(foundItem); } // add at top FileMap.Insert(0, itemCopy); itemCopy.ContainerList = this; // if to large, crop if (FileMap.Count > MaxItems) { FileMap.Remove(FileMap.Last()); } }
public void StartAnimation(PackageContainerRepoItem fi, PackageContainerRepoItem.VisualStateEnum state) { // access if (fi == null || this.FileMap == null || !this.FileMap.Contains(fi)) { return; } // stop? if (state == PackageContainerRepoItem.VisualStateEnum.Idle) { fi.VisualState = PackageContainerRepoItem.VisualStateEnum.Idle; fi.VisualTime = 0.0d; return; } // start fi.VisualState = state; fi.VisualTime = this.DefaultAnimationTime; }
public async Task <List <PackageContainerRepoItem> > GenerateRepositoryFromEndpointAsync() { // access if (!IsValid()) { throw new PackageConnectorException("PackageConnector::GenerateRepositoryFromEndpoint() " + "connection not valid!"); } // results var res = new List <PackageContainerRepoItem>(); // Log Log.Singleton.Info($"Building repository items for aas-list from {this.ToString()} .."); // sync-query for the list var aasItems = new List <ListAasItem>(); try { if (OpenIDClient.auth) { var responseAuth = _client.GetAsync("/authserver").Result; if (responseAuth.IsSuccessStatusCode) { var content = responseAuth.Content.ReadAsStringAsync().Result; if (content != null && content != "") { OpenIDClient.authServer = content; var response2 = await OpenIDClient.RequestTokenAsync(null); OpenIDClient.token = response2.AccessToken; OpenIDClient.auth = false; } } } if (OpenIDClient.token != "") { _client.SetBearerToken(OpenIDClient.token); } // query var listAasResponse = await _client.GetAsync( StartQuery("server", "listaas")); listAasResponse.EnsureSuccessStatusCode(); var listAasString = await listAasResponse.Content.ReadAsStringAsync(); // get some structures dynamic listAas = Newtonsoft.Json.Linq.JObject.Parse(listAasString); foreach (var li in listAas.aaslist) { string line = "" + li; var arr = line.Trim().Split(new[] { " : " }, StringSplitOptions.RemoveEmptyEntries); if (arr.Length == 4) { aasItems.Add(new ListAasItem() { Index = arr[0].Trim(), AasIdShort = arr[1].Trim(), AasId = arr[2].Trim(), Fn = arr[3].Trim() }); } } } catch (Exception ex) { Log.Singleton.Error(ex, $"when parsing /server/listaas/ for {this.ToString()}"); } // go thru the list foreach (var aasi in aasItems) { try { // query var x = await GetAasAssetCore(aasi.Index); if (x.Item1 == null || x.Item2 == null) { Log.Singleton.Error($"when retrieving /aas/{aasi.Index}/, some null contents for AAS or" + $"Asset were found."); } // file item var fi = new PackageContainerRepoItem() { ContainerOptions = PackageContainerOptionsBase.CreateDefault(Options.Curr), Location = CombineQuery(_client.BaseAddress.ToString(), _endPointSegments, "server", "getaasx", aasi.Index), Description = $"\"{"" + x.Item1?.idShort}\",\"{"" + x.Item2?.idShort}\"", Tag = "" + AdminShellUtil.ExtractPascalCasingLetters(x.Item1?.idShort).SubstringMax(0, 3) }; fi.AasIds.Add("" + x.Item1?.identification?.id); fi.AssetIds.Add("" + x.Item2?.identification?.id); res.Add(fi); } catch (Exception ex) { Log.Singleton.Error(ex, $"when parsing index {aasi.Index}"); } } // return results return(res); }
public void MoveDown(PackageContainerRepoItem fi) { this.MoveElementInListDownwards <PackageContainerRepoItem>(this.FileMap, fi); }
public bool Contains(PackageContainerRepoItem fi) { return(true == this.FileMap?.Contains(fi)); }