コード例 #1
0
        async Task <IWatchList> IWatchListsClient.GetCustomWatchListAsync(string clientId, string watchListId)
        {
            try
            {
                var data = _readerWatchListCustomNoSql.Get(WatchListCustomNoSql.GeneratePartitionKey(clientId), WatchListCustomNoSql.GenerateRowKey(watchListId));

                if (data != null)
                {
                    return(data);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Cannot read from MyNoSQL. Table: ${WatchListCustomNoSql.TableNameCustomWatchList}, PK: {WatchListCustomNoSql.GeneratePartitionKey(clientId)}", ex);
            }

            try
            {
                var result = await HttpClient.WatchListGetCustomAsync(watchListId, clientId);

                var data = FromWatchListResponse(result);
                return(data);
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Cannot read from API. Method: WatchListGetCustomAsync, clientId: {clientId}, watchListId: {watchListId}");
                throw;
            }
        }
コード例 #2
0
        async Task <List <IWatchList> > IWatchListsClient.GetAllCustom(string clientId)
        {
            try
            {
                var data = _readerWatchListCustomNoSql.Get(WatchListCustomNoSql.GeneratePartitionKey(clientId));

                if (data != null)
                {
                    return(data.Select(e => (IWatchList)e).ToList());
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Cannot read from MyNoSQL. Table: ${WatchListCustomNoSql.TableNameCustomWatchList}, PK: {WatchListCustomNoSql.GeneratePartitionKey(clientId)}", ex);
            }

            try
            {
                var result = await HttpClient.WatchListGetAllCustomAsync(clientId);

                var resultData = result.Select(e => (IWatchList)FromWatchListResponse(e)).ToList();
                return(resultData);
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Cannot read from API. Method: WatchListGetAllCustomAsync, clientId: {clientId}");
                throw;
            }
        }
コード例 #3
0
        private async Task <IEnumerable <IWatchList> > ReLoadCustomWatchListToNoSqlCache(string clientId)
        {
            try
            {
                var data = await _customWatchListRepository.GetAllAsync(clientId);

                var list = data.Select(e => WatchListCustomNoSql.Create(clientId, e)).ToList();
                await _myNoSqlWriterCustom.CleanAndBulkInsertAsync(WatchListCustomNoSql.GeneratePartitionKey(clientId),
                                                                   list);

                return(list);
            }
            catch (Exception ex)
            {
                _log.Error(ex, $"Cannot execute CleanAndBulkInsertAsync in NoSql. ClientId: {clientId}");
                throw;
            }
        }