示例#1
0
        protected async Task<HttpOperationResponse<object>> UpsertData(string botId, string channelId, string userId, string conversationId, BotStoreType storeType, BotData data)
        {
            var _result = new HttpOperationResponse<object>();
            try
            {
                await memoryDataStore.SaveAsync(new BotDataKey { BotId = botId, UserId = userId, ConversationId = conversationId, ChannelId = channelId }, storeType, data, CancellationToken.None);
            }
            catch(HttpException e)
            {
                _result.Body = e.Data;
                _result.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.PreconditionFailed };
                return _result; 
            }
            catch(Exception)
            {
                _result.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError };
                return _result;
            }

            _result.Body = data;
            _result.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
            return _result;
        }
 protected HttpOperationResponse<object> UpsertData(string botId, string userId, string conversationId, BotData data)
 {
     var _result = new HttpOperationResponse<object>();
     data.ETag = "MockedDataStore";
     DataStore[GetBotDataKey(botId, userId, conversationId)] = data;
     _result.Body = data;
     _result.Response = new HttpResponseMessage { StatusCode = HttpStatusCode.OK };
     return _result;
 }
 /// <summary>
 /// SetUserData
 /// </summary>
 /// Update the bot's data for a user
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='channelId'>
 /// channelId
 /// </param>
 /// <param name='userId'>
 /// id for the user on the channel
 /// </param>
 /// <param name='botData'>
 /// the new botdata
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task<BotData> SetUserDataAsync(this IBotState operations, string channelId, string userId, BotData botData, CancellationToken cancellationToken = default(CancellationToken))
 {
     var _result = await operations.SetUserDataWithHttpMessagesAsync(channelId, userId, botData, null, cancellationToken).ConfigureAwait(false);
     return _result.HandleError<BotData>();
 }
 /// <summary>
 /// SetUserData
 /// </summary>
 /// Update the bot's data for a user
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='channelId'>
 /// channelId
 /// </param>
 /// <param name='userId'>
 /// id for the user on the channel
 /// </param>
 /// <param name='botData'>
 /// the new botdata
 /// </param>
 public static BotData SetUserData(this IBotState operations, string channelId, string userId, BotData botData)
 {
     return Task.Factory.StartNew(s => ((IBotState)s).SetUserDataAsync(channelId, userId, botData), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
示例#5
0
 /// <summary>
 /// SetUserData
 /// </summary>
 /// Update the bot's data for a user
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='channelId'>
 /// channelId
 /// </param>
 /// <param name='userId'>
 /// id for the user on the channel
 /// </param>
 /// <param name='botData'>
 /// the new botdata
 /// </param>
 public static BotData SetUserData(this IBotState operations, string channelId, string userId, BotData botData)
 {
     return(Task.Factory.StartNew(s => ((IBotState)s).SetUserDataAsync(channelId, userId, botData), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#6
0
 /// <summary>
 /// SetPrivateConversationData
 /// </summary>
 /// Update the bot's data for a single user in a conversation
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='channelId'>
 /// channelId
 /// </param>
 /// <param name='conversationId'>
 /// The id for the conversation on the channel
 /// </param>
 /// <param name='userId'>
 /// id for the user on the channel
 /// </param>
 /// <param name='botData'>
 /// the new botdata
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <BotData> SetPrivateConversationDataAsync(this IBotState operations, string channelId, string conversationId, string userId, BotData botData, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.SetPrivateConversationDataWithHttpMessagesAsync(channelId, conversationId, userId, botData, null, cancellationToken).ConfigureAwait(false))
     {
         return(await _result.HandleErrorAsync <BotData>().ConfigureAwait(false));
     }
 }