Ejemplo n.º 1
0
        public async Task GetShopingInfo(IDialogContext context, IAwaitable <string> result)
        {
            try
            {
                string   dateStr = await result;
                DateTime date;
                if (dateStr.ToLower() == "all")
                {
                    date = new DateTime();
                }
                else
                {
                    date = DateTime.Parse(dateStr);
                }

                await context.PostAsync($"Getting shoping list from {date.ToShortDateString()}");

                var shopingList = new FDH_BotService().GetShopingItems(date);
                await context.PostAsync(shopingList);

                context.Wait(MessageReceivedAsync);
            }
            catch (Exception e)
            {
                await context.PostAsync(e.Message);

                context.Wait(MessageReceivedAsync);
            }
        }
Ejemplo n.º 2
0
        public void TimerCallbackCustom(object source, ElapsedEventArgs e)
        {
            try
            {
                var     resumeJson = new FDH_BotService().GetUserCookie(this.userName).UserCookie;
                dynamic resumeData = JsonConvert.DeserializeObject(resumeJson);

                string botId          = resumeData.address.botId;
                string channelId      = resumeData.address.channelId;
                string userId         = resumeData.address.userId;
                string conversationId = resumeData.address.conversationId;
                string serviceUrl     = resumeData.address.serviceUrl;
                string userName       = resumeData.userName;
                bool   isGroup        = resumeData.isGroup;

                var resume = new ResumptionCookie(new Address(botId, channelId, userId, conversationId, serviceUrl), userName, isGroup, "en");

                var messageActyvity = (Activity)resume.GetMessage();
                var replay          = messageActyvity.CreateReply();

                replay.Text = this._timerMessage;
                var client = new ConnectorClient(new Uri(messageActyvity.ServiceUrl));
                client.Conversations.ReplyToActivity(replay);
                this._timer.Dispose();
            }
            catch (Exception e1)
            {
                this._timer.Dispose();
            }

            //this._timer.Dispose();
        }
Ejemplo n.º 3
0
        public async Task GetWishInfo(IDialogContext context)
        {
            try
            {
                var wishs = new FDH_BotService().GetUsersWish();
                await context.PostAsync(wishs);

                context.Wait(MessageReceivedAsync);
            }
            catch (Exception e)
            {
                await context.PostAsync(e.Message);

                context.Wait(MessageReceivedAsync);
            }
        }