Exemplo n.º 1
0
        public async Task <IClientDialog> AddDialogAsync(IClientDialog clientDialog)
        {
            var entity = ClientDialogEntity.Create(clientDialog);
            await _tableStorage.InsertOrMergeAsync(entity);

            return(entity);
        }
Exemplo n.º 2
0
 public Task SetDialogConditionTypeAsync(string dialogId, DialogConditionType?type)
 {
     return(_tableStorage.ReplaceAsync(ClientDialogEntity.GeneratePartitionKey(),
                                       ClientDialogEntity.GenerateRowKey(dialogId),
                                       entity =>
     {
         entity.ConditionType = type;
         return entity;
     }));
 }
Exemplo n.º 3
0
        public Task DeleteDialogAsync(string clientId, string dialogId)
        {
            var tasks = new List <Task>
            {
                _clientDialogIndex.DeleteIfExistAsync(clientId, dialogId),
                _clientDialogIndex.DeleteIfExistAsync(ClientDialogEntity.GenerateDialogIndex(dialogId), clientId)
            };

            return(Task.WhenAll(tasks));
        }
Exemplo n.º 4
0
        public async Task <IEnumerable <IClientDialog> > GetClientDialogsAsync(string clientId)
        {
            var indexesTask       = _clientDialogIndex.GetDataAsync(clientId);
            var globalIndexesTask = _globalDialogIndex.GetDataAsync(ClientDialogEntity.GenerateGlobalDialogPartitionKey());

            await Task.WhenAll(indexesTask, globalIndexesTask);

            var indexes       = await indexesTask;
            var globalIndexes = await globalIndexesTask;

            var clientDialogs = (await _tableStorage.GetDataAsync(indexes)).ToList();
            var globalDialogs = (await _tableStorage.GetDataAsync(globalIndexes)).ToList();

            clientDialogs.AddRange(globalDialogs.Where(item => clientDialogs.All(x => x.Id != item.Id)));

            return(clientDialogs);
        }
Exemplo n.º 5
0
        public async Task DeleteDialogAsync(string dialogId)
        {
            await _tableStorage.DeleteIfExistAsync(ClientDialogEntity.GeneratePartitionKey(), ClientDialogEntity.GenerateRowKey(dialogId));

            var tasks = new List <Task>();

            var dialogIndexes = (await _clientDialogIndex.GetDataAsync(ClientDialogEntity.GenerateDialogIndex(dialogId))).ToList();

            foreach (var index in dialogIndexes)
            {
                tasks.Add(_clientDialogIndex.DeleteIfExistAsync(index.RowKey, dialogId));
                tasks.Add(_clientDialogIndex.DeleteIfExistAsync(ClientDialogEntity.GenerateDialogIndex(dialogId), index.RowKey));
            }

            tasks.Add(UnAssignGlobalDialogAsync(dialogId));

            await Task.WhenAll(tasks);
        }
Exemplo n.º 6
0
 public Task UnAssignGlobalDialogAsync(string dialogId)
 {
     return(_globalDialogIndex.DeleteIfExistAsync(ClientDialogEntity.GenerateGlobalDialogPartitionKey(), dialogId));
 }
Exemplo n.º 7
0
 public async Task <IClientDialog> GetDialogAsync(string dialogId)
 {
     return(await _tableStorage.GetDataAsync(ClientDialogEntity.GeneratePartitionKey(),
                                             ClientDialogEntity.GenerateRowKey(dialogId)));
 }
Exemplo n.º 8
0
 private AzureIndex CreateGlobalDialogIndex(string dialogId)
 {
     return(AzureIndex.Create(ClientDialogEntity.GenerateGlobalDialogPartitionKey(), dialogId,
                              ClientDialogEntity.GeneratePartitionKey(), dialogId));
 }
Exemplo n.º 9
0
 private AzureIndex CreateClientDialogIndex(string clientId, string dialogId)
 {
     return(AzureIndex.Create(clientId, dialogId, ClientDialogEntity.GeneratePartitionKey(), dialogId));
 }
Exemplo n.º 10
0
        public async Task <IEnumerable <IClientDialog> > GetGlobalDialogsAsync()
        {
            var indexes = await _globalDialogIndex.GetDataAsync(ClientDialogEntity.GenerateGlobalDialogPartitionKey());

            return(await _tableStorage.GetDataAsync(indexes));
        }