Exemplo n.º 1
0
 private void ShowUserAccountsOptions(IDialogContext context)
 {
     PromptDialog.Choice(context, OnOptionSelectedAsync, _clientAccounts
                         .Select(x => x.AccountNumber).ToList(),
                         TextProvider.Provide(TextCategory.ACCOUNTBALANCE_MoreThanOneAccount),
                         TextProvider.Provide(TextCategory.COMMON_NotValidOption));
 }
Exemplo n.º 2
0
        public override async Task StartAsync(IDialogContext context)
        {
            List <Branch> branches = DAL.GetBranches();

            IMessageActivity selectBranchReply = context.MakeMessage();

            selectBranchReply.AttachmentLayout = AttachmentLayoutTypes.List;
            selectBranchReply.Text             = TextProvider.Provide(TextCategory.SELECTBRANCH_PleaseSelect);
            selectBranchReply.Attachments      = new List <Attachment>();

            foreach (Branch branch in branches)
            {
                List <CardImage> cardImages = new List <CardImage>();
                cardImages.Add(new CardImage("https://image.ibb.co/fPqt70/blue-location-icon.png"));

                ThumbnailCard thumbnailCard = new ThumbnailCard()
                {
                    Images   = cardImages,
                    Title    = branch.BranchName,
                    Subtitle = $"{branch.ZipCode} {branch.City}, {branch.Street} {branch.HouseNumber}.",
                    Text     = $"Open on weekdays: {branch.WeekDayOpeningHours}",
                    Tap      = new CardAction(ActionTypes.PostBack, value: branch.BranchId.ToString())
                };

                selectBranchReply.Attachments.Add(thumbnailCard.ToAttachment());
            }

            await context.PostAsync(selectBranchReply);

            context.Wait(BranchIdReceivedAsync);
        }
Exemplo n.º 3
0
        public override async Task StartAsync(IDialogContext context)
        {
            List <DebitCard> clientDebitCards = DAL.GetClientDebitCards(1);

            IMessageActivity selectCardReply = context.MakeMessage();

            //itt állítjuk be, hogy görgethető legyen a menüsor
            selectCardReply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
            selectCardReply.Text             = TextProvider.Provide(TextCategory.SELECTCARD_PleaseSelect);
            selectCardReply.Attachments      = new List <Attachment>();

            foreach (DebitCard card in clientDebitCards)
            {
                List <CardImage>  cardImages  = new List <CardImage>();
                List <CardAction> cardButtons = new List <CardAction>();

                cardImages.Add(new CardImage("https://image.ibb.co/jPo20L/mastercard-blue.png"));

                cardButtons.Add(new CardAction(ActionTypes.PostBack, "Select", value: card.DebitCardId.ToString()));

                HeroCard hc = new HeroCard()
                {
                    Images   = cardImages,
                    Title    = card.DebitCardType.Type,
                    Subtitle = card.CardNumber,
                    Text     = "Expiration: " + (card.ExpirationDate != null ? card.ExpirationDate.Value.ToString("MM'/'yy") : "UNKNOWN"),
                    Buttons  = cardButtons
                };
                selectCardReply.Attachments.Add(hc.ToAttachment());
            }

            await context.PostAsync(selectCardReply);

            context.Wait(CardIdReceivedAsync);
        }
Exemplo n.º 4
0
 public static IForm <BranchAppointmentForm> BuildForm()
 {
     return(new FormBuilder <BranchAppointmentForm>()
            .Message(TextProvider.Provide(
                         TextCategory.BRANCHAPPOINTMENT_Welcome))
            .Build());
 }
Exemplo n.º 5
0
        public override async Task StartAsync(IDialogContext context)
        {
            switch (_limitType)
            {
            case CardLimitType.PurchaseLimit:
                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_OldPurchaseLimit) +
                                        _selectedCard.DailyPaymentLimit + " " + _cardCurrencyIso);

                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_InputPurchaseLimit));

                context.Wait(ResumeAfterLimitChangedAsync);
                break;

            case CardLimitType.CashWithdrawalLimit:
                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_OldWithdrawalLimit) +
                                        _selectedCard.DailyCashWithdrawalLimit + " " + _cardCurrencyIso);

                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_InputWithdrawalLimit));

                context.Wait(ResumeAfterLimitChangedAsync);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 6
0
        private async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            IMessageActivity message = await result;

            _clientDebitCards = DAL.GetClientDebitCards(_clientId);

            switch (_clientDebitCards.Count)
            {
            case 1:
                int cardId = _clientDebitCards.Single().DebitCardId;
                await PostLimitInformationAsync(context, cardId);

                context.Done <object>(null);
                break;

            case 0:
                await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_ZeroCard));

                context.Done <object>(null);
                break;

            default:
                await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_MoreThanOneCard));

                context.Call(new SelectCardDialog(), ResumeAfterSelectCardDialogAsync);
                break;
            }
        }
Exemplo n.º 7
0
        private async Task ResumeAfterSearchBranchDialogAsync(IDialogContext context, IAwaitable <object> result)
        {
            await result;

            PromptDialog.Confirm(context, ResumeBookAppointmentBranchConfirmDialogAsync,
                                 TextProvider.Provide(TextCategory.BRANCHAPPOINTMENT_WishToBook),
                                 TextProvider.Provide(TextCategory.COMMON_NotUnderstandable));
        }
Exemplo n.º 8
0
        private async Task ResumeAfterGetCardLimitDialogAsync(IDialogContext context, IAwaitable <object> result)
        {
            await result;

            PromptDialog.Confirm(context, ResumeAfterSetLimitConfirmDialogAsync,
                                 TextProvider.Provide(TextCategory.SETCARDLIMIT_WishToChange),
                                 TextProvider.Provide(TextCategory.COMMON_NotUnderstandable));
        }
Exemplo n.º 9
0
        private async Task ResumeAfterSelectBranchDialogAsync(IDialogContext context, IAwaitable <int> result)
        {
            int    branchId       = await result;
            Branch selectedBranch = DAL.GetBranch(branchId);
            await context.PostAsync(
                $"{TextProvider.Provide(TextCategory.SELECTBRANCH_SelectedBranch)}\nName: {selectedBranch.BranchName}\nAddress: {selectedBranch.ZipCode} {selectedBranch.City}, {selectedBranch.Street} {selectedBranch.HouseNumber}.");

            context.Done <object>(null);
        }
Exemplo n.º 10
0
 public async Task GreetAsync(IDialogContext context, LuisResult result)
 {
     if (CheckMinimumIntentScore(result.TopScoringIntent.Score))
     {
         await context.PostAsync(TextProvider.Provide(TextCategory.GREETING));
     }
     else
     {
         await AskForAccurateInput(context);
     }
 }
Exemplo n.º 11
0
 private void CreateLimitTypeChoice(IDialogContext context)
 {
     PromptDialog.Choice(context, ResumeAfterLimitTypeChoiceAsync,
                         new[] { CardLimitType.PurchaseLimit, CardLimitType.CashWithdrawalLimit, CardLimitType.Both },
                         TextProvider.Provide(TextCategory.SETCARDLIMIT_PleaseSelectLimitType),
                         TextProvider.Provide(TextCategory.COMMON_NotValidOption),
                         descriptions: new[]
     {
         TextProvider.Provide(TextCategory.SETCARDLIMIT_PurchaseLimitDesc),
         TextProvider.Provide(TextCategory.SETCARDLIMIT_WithDrawalLimitDesc),
         TextProvider.Provide(TextCategory.SETCARDLIMIT_BothLimitTypeDesc)
     });
 }
Exemplo n.º 12
0
        private async Task PostLimitInformationAsync(IDialogContext context, int cardId)
        {
            DebitCard card          = _clientDebitCards.Single(x => x.DebitCardId == cardId);
            string    cardTypeName  = card.DebitCardType.Type;
            int       withdrawLimit = card.DailyCashWithdrawalLimit ?? 0;
            int       purchaseLimit = card.DailyPaymentLimit ?? 0;
            string    currency      = card.Account.Currency;

            await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_WithdrawalLimit) + withdrawLimit +
                                    " " + currency);

            await context.PostAsync(TextProvider.Provide(TextCategory.GETCARDLIMIT_PurchaseLimit) + purchaseLimit +
                                    " " + currency);
        }
Exemplo n.º 13
0
        private async Task ResumeAfterSetCardLimitInitializationDialogAsync(IDialogContext context, IAwaitable <bool> result)
        {
            bool success = await result;

            if (success)
            {
                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_Success));
            }
            else
            {
                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_Error));
            }

            context.PrivateConversationData.RemoveValue("selectedCardId");
            await HelpMore(context);
        }
Exemplo n.º 14
0
        private async Task ResumeAfterLimitChangedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            string newLimitAsString = (await result).Text;
            bool   success          = int.TryParse(newLimitAsString, out int newLimit);

            if (!success || newLimit <= 0)
            {
                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_InvalidAmount));

                context.Wait(ResumeAfterLimitChangedAsync);
            }
            else
            {
                DAL.UpdateCardLimit(_cardId, _limitType, newLimit);

                CardLimitModificationResult modificationResult;
                switch (_limitType)
                {
                case CardLimitType.PurchaseLimit:
                    modificationResult = new CardLimitModificationResult()
                    {
                        PurchaseLimitChanged = true,
                        PurchaseLimit        = newLimit
                    };
                    await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_PurchaseLimitChanged) +
                                            newLimit + " " + _cardCurrencyIso);

                    break;

                case CardLimitType.CashWithdrawalLimit:
                    modificationResult = new CardLimitModificationResult()
                    {
                        WithDrawalLimitChanged = true,
                        WithDrawalLimit        = newLimit
                    };
                    await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_WithdrawalLimitChanged) +
                                            newLimit + " " + _cardCurrencyIso);

                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                context.Done(modificationResult);
            }
        }
Exemplo n.º 15
0
        private async Task BranchIdReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            IMessageActivity branchIdAsString = await result;

            if (int.TryParse(branchIdAsString.Text, out int branchId))
            {
                context.PrivateConversationData.SetValue("branchId", branchId);
                context.Done(branchId);
            }
            else
            {
                await context.PostAsync(TextProvider.Provide(TextCategory.SELECTBRANCH_InvalidBranchIdentifier));

                await context.PostAsync(TextProvider.Provide(TextCategory.SELECTBRANCH_PleaseSelect));

                context.Wait(RetryAsync);
            }
        }
Exemplo n.º 16
0
        private async Task RetryAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            IMessageActivity branchIdAsString = await result;

            if (int.TryParse(branchIdAsString.Text, out int branchId))
            {
                context.PrivateConversationData.SetValue("branchId", branchId);
                context.Done(branchId);
            }
            else
            {
                await context.PostAsync(TextProvider.Provide(TextCategory.SELECTBRANCH_InvalidBranchIdentifier));

                await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_TooManyAttempt));

                context.Reset();
            }
        }
Exemplo n.º 17
0
        private async Task <Activity> HandleSystemMessage(Activity activity)
        {
            string messageType = activity.GetActivityType();

            if (messageType == ActivityTypes.DeleteUserData)
            {
                // Implement user deletion here
                // If we handle user deletion, return a real message
            }
            else if (messageType == ActivityTypes.ConversationUpdate)
            {
                // Handle conversation state changes, like members being added and removed
                // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
                // Not available in all channels
                IConversationUpdateActivity update = activity;
                using (ILifetimeScope scope = Microsoft.Bot.Builder.Dialogs.Internals.DialogModule.BeginLifetimeScope(Conversation.Container, activity))
                {
                    IConnectorClient client = scope.Resolve <IConnectorClient>();
                    if (update.MembersAdded.Any())
                    {
                        Activity reply = activity.CreateReply();
                        foreach (ChannelAccount newMember in update.MembersAdded)
                        {
                            if (newMember.Id != activity.Recipient.Id)
                            {
                                reply.Text = TextProvider.Provide(TextCategory.GREETING_UserAdded);
                                await client.Conversations.ReplyToActivityAsync(reply);
                            }
                        }
                    }
                }
            }
            else if (messageType == ActivityTypes.ContactRelationUpdate)
            {
                // Handle add/remove from contact lists
                // Activity.From + Activity.Action represent what happened
            }
            else if (messageType == ActivityTypes.Typing)
            {
                // Handle knowing that the user is typing
            }

            return(null);
        }
Exemplo n.º 18
0
        private async Task RetryAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            IMessageActivity cardIdAsString = await result;

            if (int.TryParse(cardIdAsString.Text, out int cardId))
            {
                //betöltjük a kiválasztott kártyát a conversationdata-ba
                context.PrivateConversationData.SetValue("selectedCardId", cardId);
                context.Done(cardId);
            }
            else
            {
                await context.PostAsync(TextProvider.Provide(TextCategory.SELECTCARD_InvalidCardIdentifier));

                await context.PostAsync(TextProvider.Provide(TextCategory.COMMON_TooManyAttempt));

                context.Reset();
            }
        }
Exemplo n.º 19
0
 private async Task ResumeBookAppointmentBranchConfirmDialogAsync(IDialogContext context, IAwaitable <bool> result)
 {
     try
     {
         bool appoint = await result;
         if (appoint)
         {
             await context.Forward(FormDialog.FromForm(BranchAppointmentForm.BuildForm),
                                   ResumeAfterBranchAppointmentForm, Activity.CreateMessageActivity());
         }
         else
         {
             await HelpMore(context);
         }
     }
     catch (TooManyAttemptsException)
     {
         await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_TooManyAttempt));
     }
 }
Exemplo n.º 20
0
        public async Task MessageReceivedAsync(IDialogContext context, IAwaitable <IMessageActivity> result)
        {
            _clientAccounts = DAL.GetClientAccounts(_clientId);

            if (_clientAccounts.Count > 1)
            {
                ShowUserAccountsOptions(context);
            }
            else if (_clientAccounts.Count == 1)
            {
                _selectedAccount = _clientAccounts.Single();
                await WriteOutBalanceAsync(context, _selectedAccount);

                context.Done(true);
            }
            else
            {
                await context.PostAsync(TextProvider.Provide(TextCategory.ACCOUNTBALANCE_ZeroAccount));

                context.Done(true);
            }
        }
Exemplo n.º 21
0
        private async Task ResumeAfterBranchAppointmentForm(IDialogContext context, IAwaitable <BranchAppointmentForm> result)
        {
            BranchAppointmentForm appointment = await result;

            if (appointment != null)
            {
                if (context.PrivateConversationData.TryGetValue("branchId", out int branchId))
                {
                    DAL dal = new DAL();
                    //A vasárnapot átalakítjuk hetedik napra
                    int      currentDayOfWeek = (int)DateTime.Now.DayOfWeek == 0 ? 7 : (int)DateTime.Now.DayOfWeek;
                    int      remainsFromWeek  = 7 - currentDayOfWeek;
                    int      selectedWorkDay  = (int)appointment.Days + 1;
                    DateTime bookingDate      = DateTime.Now
                                                .AddDays(selectedWorkDay + 7 * (int)appointment.Term + remainsFromWeek).Date.AddHours((int)appointment.Hour);
                    dal.InsertAppointmentBooking(branchId, _clientId, (int)appointment.Case, bookingDate);

                    await context.PostAsync(TextProvider.Provide(TextCategory.BRANCHAPPOINTMENT_BookingSaved));
                }
            }
            await HelpMore(context);
        }
Exemplo n.º 22
0
 private async Task ResumeAfterSetLimitConfirmDialogAsync(IDialogContext context, IAwaitable <bool> result)
 {
     try
     {
         bool changeSettings = await result;
         if (changeSettings)
         {
             context.Call(
                 new SetCardLimitInitializationDialog(1,
                                                      context.PrivateConversationData.GetValue <int>("selectedCardId")),
                 ResumeAfterSetCardLimitInitializationDialogAsync);
         }
         else
         {
             await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_WontChange));
         }
     }
     catch (TooManyAttemptsException)
     {
         await context.PostAsync(TextProvider.Provide(TextCategory.SETCARDLIMIT_TooManyAttempt));
     }
 }
Exemplo n.º 23
0
 private async Task WriteOutBalanceAsync(IDialogContext context, Account account)
 {
     await context.PostAsync(TextProvider.Provide(TextCategory.ACCOUNTBALANCE_BalanceIs) +
                             $"{account.Balance} {account.Currency}");
 }
Exemplo n.º 24
0
        //ez reagál a felhasználónak, amennyiben a score alapján ez a dialógus veszi át az irányítást
        protected override async Task PostAsync(IActivity item, string state, CancellationToken token)
        {
            InterruptionDialog         cancelInterruptionDialog = new InterruptionDialog(TextProvider.Provide(TextCategory.INTERRUPTION_Cancel));
            IDialog <IMessageActivity> cancelInterruption       = cancelInterruptionDialog.Void <object, IMessageActivity>();

            task.Call(cancelInterruption, null);
            task.Reset();
        }
Exemplo n.º 25
0
        protected override async Task PostAsync(IActivity item, string state, CancellationToken token)
        {
            InterruptionDialog         helpInterruptionDialog = new InterruptionDialog(TextProvider.Provide(TextCategory.INTERRUPTION_Help));
            IDialog <IMessageActivity> helpInterruption       = helpInterruptionDialog.Void <object, IMessageActivity>();

            task.Call(helpInterruption, null);
            //await task.PollAsync(token);
        }
Exemplo n.º 26
0
 private async Task AskForAccurateInput(IDialogContext context)
 {
     await context.PostAsync(TextProvider.Provide(TextCategory.COMMON_AskingMoreAccurateInput));
 }
Exemplo n.º 27
0
 private async Task HelpMore(IDialogContext context)
 {
     await context.PostAsync(
         TextProvider.Provide(TextCategory.COMMON_HelpMore));
 }