Example #1
0
        public virtual async Task <List <T> > GetItemsAsync()
        {
            try
            {
                await InitializeTask.ConfigureAwait(false);

                return(await Database.Table <T>().ToListAsync().ConfigureAwait(false));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Example #2
0
        public virtual async Task <bool> RemoveAsync(T item)
        {
            try
            {
                await InitializeTask.ConfigureAwait(false);

                await Database.DeleteAsync(item).ConfigureAwait(false);

                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(false);
            }
        }
Example #3
0
        public virtual async Task <T> InsertAsync(T item)
        {
            try
            {
                await InitializeTask.ConfigureAwait(false);

                await Database.InsertAsync(item).ConfigureAwait(false);

                return(item);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(null);
            }
        }
Example #4
0
        GetIssuesWithConnections()
        {
            await InitializeTask.ConfigureAwait(false);

            var concurrentBag = new List <IssueLinkLight>();
            var rawIssues     = await _repository.GetAllIssuesInProject(CustomFields).ConfigureAwait(false);

            Console.WriteLine($"Loaded issues (count): {rawIssues.Count}");

            var getLinks = new TransformManyBlock <IssueLight, IssueLinkLight>(
                async i => await _repository.GetLinks(i),
                new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = Environment.ProcessorCount * 4
            }
                );
            var collect = new ActionBlock <IssueLinkLight>(
                i => concurrentBag.Add(i),
                new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = 1
            }
                );

            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            using var l1 = getLinks.LinkTo(collect, linkOptions);

            if (rawIssues.Any(x => !getLinks.Post(x)))
            {
                throw new Exception($"Failure to queue data for processing. Block already has {getLinks.InputCount} items to be processed.");
            }

            getLinks.Complete();
            await getLinks.Completion;
            await collect.Completion;

            Console.WriteLine($"Loaded links: (count): {concurrentBag.Count}");

            return(rawIssues, concurrentBag);
        }
Example #5
0
        public virtual async Task <T> GetItemAsync(string id)
        {
            try
            {
                await InitializeTask.ConfigureAwait(false);

                var items = await Database.Table <T>().Where(s => s.Id == id).ToListAsync().ConfigureAwait(false);

                if (items == null || items.Count == 0)
                {
                    return(null);
                }

                return(items[0]);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(null);
            }
        }