Пример #1
0
        public async Task <IEnumerable <IRepository> > GetAsync(Func <IRepository, bool> filter)
        {
            var pk   = RepositoryEntity.GeneratePartitionKey();
            var list = await _tableStorage.GetDataAsync(pk, filter : filter);

            return(list);
        }
Пример #2
0
        public async Task SaveRepositoryAsync(IRepository repository)
        {
            if (repository is RepositoryEntity rs)
            {
                rs.PartitionKey = RepositoryEntity.GeneratePartitionKey();
                rs.RowKey       = repository.RepositoryId;
            }
            else
            {
                var pk = RepositoryEntity.GeneratePartitionKey();
                var rk = RepositoryEntity.GenerateRowKey(repository.RepositoryId);

                rs = await _tableStorage.GetDataAsync(pk, rk)
                     ?? new RepositoryEntity
                {
                    PartitionKey = pk, RowKey = rk
                };

                rs.Name              = repository.Name;
                rs.GitUrl            = repository.GitUrl;
                rs.Branch            = repository.Branch;
                rs.FileName          = repository.FileName;
                rs.UserName          = repository.UserName;
                rs.ConnectionUrl     = repository.ConnectionUrl;
                rs.UseManualSettings = repository.UseManualSettings;
                rs.Tag = repository.Tag;
            }

            await _tableStorage.InsertOrMergeAsync(rs);
        }
Пример #3
0
        public async Task <IRepository> GetAsync(string repositoryId)
        {
            var pk = RepositoryEntity.GeneratePartitionKey();
            var rk = RepositoryEntity.GenerateRowKey(repositoryId);

            return(await _tableStorage.GetDataAsync(pk, rk));
        }
        public async Task SaveRepositoryAsync(IRepository repository)
        {
            if (!(repository is RepositoryEntity rs))
            {
                rs = (RepositoryEntity) await GetAsync(repository.RowKey) ?? new RepositoryEntity();

                rs.ETag              = repository.ETag;
                rs.Name              = repository.Name;
                rs.GitUrl            = repository.GitUrl;
                rs.Branch            = repository.Branch;
                rs.FileName          = repository.FileName;
                rs.UserName          = repository.UserName;
                rs.ConnectionUrl     = repository.ConnectionUrl;
                rs.UseManualSettings = repository.UseManualSettings;
                rs.Tag = repository.Tag;
            }
            rs.PartitionKey = RepositoryEntity.GeneratePartitionKey();
            rs.RowKey       = repository.RowKey;
            await _tableStorage.InsertOrMergeAsync(rs);
        }
Пример #5
0
 public async Task RemoveRepositoryAsync(string repositoryId)
 {
     var pk = RepositoryEntity.GeneratePartitionKey();
     await _tableStorage.DeleteAsync(pk, repositoryId);
 }
Пример #6
0
        public async Task <IEnumerable <IRepository> > GetAllAsync()
        {
            var pk = RepositoryEntity.GeneratePartitionKey();

            return(await _tableStorage.GetDataAsync(pk));
        }
Пример #7
0
        public async Task <bool> ExistsWithNameAsync(string repositoryName, string tag)
        {
            string queryText        = TableQuery.GenerateFilterCondition(nameof(RepositoryEntity.PartitionKey), QueryComparisons.Equal, RepositoryEntity.GeneratePartitionKey());
            string repositoryFilter = TableQuery.GenerateFilterCondition(nameof(RepositoryEntity.Name), QueryComparisons.Equal, repositoryName);

            queryText = TableQuery.CombineFilters(queryText, TableOperators.And, repositoryFilter);
            var query = new TableQuery <RepositoryEntity>().Where(queryText);

            var records = await _tableStorage.WhereAsync(query, i => i.Tag == tag);

            return(records.Any());
        }