public async Task <bool> RemoveAsync(string resourceUriString) { bool result = false; if (State.Container.Contains(resourceUriString)) { result = State.Container.Remove(resourceUriString); await ChainupAsync(); return(await Task.FromResult(result)); } while (!result) { long nextId = State.Id; nextId++; ISigmaAlgebraChain nextChain = GrainFactory.GetGrain <ISigmaAlgebraChain>(nextId); int cnt = await nextChain.GetCountAsync(); if (cnt == 0) { break; } result = await nextChain.RemoveAsync(resourceUriString); } if (result) { await ChainupAsync(); } return(await Task.FromResult(result)); }
public async Task RemoveAsync(string resourceUriString) { _ = resourceUriString ?? throw new ArgumentNullException(nameof(resourceUriString)); long id = 1; ISigmaAlgebraChain chain = GrainFactory.GetGrain <ISigmaAlgebraChain>(id); bool result = await chain.RemoveAsync(resourceUriString); await logger?.LogInformationAsync($"SigmaAlgebra removed {result} on {resourceUriString}."); await Task.FromResult(result); }
public async Task ChainupAsync() { if (State.Container.Count == 0) { return; } long nextId = State.Id; nextId++; ISigmaAlgebraChain nextChain = GrainFactory.GetGrain <ISigmaAlgebraChain>(nextId); int count = State.Container.Count; int nextCount = await nextChain.GetCountAsync(); if (count <= 1000 && nextCount > 0) { List <string> list = await nextChain.GetListAsync(); int qty = 1000 - count; int delta = qty > list.Count ? list.Count : qty; for (int i = 0; i < delta; i++) { State.Container.Add(list[i]); await nextChain.RemoveAsync(list[i]); } nextCount = await nextChain.GetCountAsync(); if (nextCount > 0) { await nextChain.ChainupAsync(); } } }