Exemplo n.º 1
0
        public async Task <List <string> > GetListAsync(string filter)
        {
            _ = filter ?? throw new ArgumentNullException(nameof(filter));

            long id = 1;
            ISigmaAlgebraChain chain = GrainFactory.GetGrain <ISigmaAlgebraChain>(id);

            int cnt = await chain.GetCountAsync();

            if (cnt == 0)
            {
                return(await Task.FromResult(new List <string>()));
            }

            List <string> list = new List <string>();

            while (cnt > 0)
            {
                list.AddRange(await chain.GetListAsync(filter));
                id++;
                chain = GrainFactory.GetGrain <ISigmaAlgebraChain>(id);
                cnt   = await chain.GetCountAsync();
            }

            list.Sort();
            return(await Task.FromResult(list));
        }
Exemplo n.º 2
0
        public async Task <List <string> > GetListAsync()
        {
            long id = 1;
            ISigmaAlgebraChain chain = GrainFactory.GetGrain <ISigmaAlgebraChain>(id);

            int cnt = await chain.GetCountAsync();

            if (cnt == 0)
            {
                return(await Task.FromResult(new List <string>()));
            }

            List <string> list = new List <string>();

            while (cnt > 0)
            {
                list.AddRange(await chain.GetListAsync());
                id++;
                chain = GrainFactory.GetGrain <ISigmaAlgebraChain>(id);
                cnt   = await chain.GetCountAsync();
            }

            list.Sort();
            return(await Task.FromResult(list));
        }
Exemplo n.º 3
0
        public async Task <List <string> > GetListAsync(int index, int pageSize, string filter)
        {
            if (index < 0)
            {
                throw new IndexOutOfRangeException(nameof(index));
            }

            if (pageSize < 0)
            {
                throw new IndexOutOfRangeException(nameof(pageSize));
            }

            _ = filter ?? throw new ArgumentNullException(nameof(filter));

            long id = 1;
            ISigmaAlgebraChain chain = GrainFactory.GetGrain <ISigmaAlgebraChain>(id);

            int cnt = await chain.GetCountAsync();

            if (cnt == 0)
            {
                return(await Task.FromResult(new List <string>()));
            }

            List <string> list = new List <string>();

            while (cnt > 0)
            {
                int filterCount = +await chain.GetCountAsync(filter);

                if (index > filterCount)
                {
                    id++;
                    chain = GrainFactory.GetGrain <ISigmaAlgebraChain>(id);
                    cnt   = await chain.GetCountAsync();
                }
                else
                {
                    int           stdIndex  = index - (Convert.ToInt32(id) - 1) * 1000;
                    List <string> chainList = await chain.GetListAsync(filter);

                    if (pageSize <= filterCount - index)
                    {
                        list.AddRange(chainList.Skip(stdIndex).Take(pageSize));
                        return(await Task.FromResult(list));
                    }

                    if (pageSize > filterCount - index)
                    {
                        list.AddRange(chainList.Skip(stdIndex).Take(filterCount - index));
                        pageSize -= filterCount - index;
                    }
                }
            }

            return(await Task.FromResult(list));
        }
Exemplo n.º 4
0
        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();
                }
            }
        }