public async Task Greeting(IDialogContext context, LuisResult result)
        {
            var reply = context.MakeMessage();

            reply.Text = Interactions.Greeting(StateHelper.GetUser(context).Name);
            await context.PostAsync(reply);

            context.Done(new CODE(DIALOG_CODE.DONE));
        }
示例#2
0
        public static string SaveAccountInfo(List <InputData> fields, IDialogContext context)
        {
            User user = StateHelper.GetUser(context);

            string fail = "";

            foreach (InputData f in fields)
            {
                switch (f.attribute)
                {
                case name_field:
                    if (f.value != "")
                    {
                        user.Name = f.value;
                    }
                    break;

                case email_field:
                    if (f.value != "")
                    {
                        try
                        {
                            var m = new MailAddress(f.value);

                            if (f.value != StateHelper.GetUser(context).Email&& UserController.getUserByEmail(f.value) != null)
                            {
                                fail += "O email que inseriu já está associado a uma outra conversa.\n";
                            }

                            user.Email = f.value;
                        }
                        catch
                        {
                            fail += "O email não está no correcto formato (exemplo: [email protected]). ";
                        }
                    }
                    break;

                case gender_field:
                    user.Gender = f.value;
                    break;

                case client_id_field:
                    if (f.value != "")
                    {
                        user.CustomerCard = f.value;
                    }
                    break;
                }
            }

            UserController.SetUserInfo(user.Id, user.Country, user.Name, user.Email, user.CustomerCard, user.Gender);
            StateHelper.SetUser(context, user);
            return(fail);
        }
示例#3
0
        public async Task LoginStart(IDialogContext context, List <InputData> data)
        {
            var fail_text = AccountLogic.Login(data, context);

            if (fail_text != "")
            {
                await context.PostAsync(fail_text);
            }

            state = State.INIT;
            string msg = StateHelper.GetUser(context).Name + " agora já me lembro de você!";
            await Interactions.SendMessage(context, msg, 0, 2000);

            await Interactions.SendMessage(context, "Existe alguma questão em que lhe possa ser útil? Com o menu principal é mais fácil mostrar-lhe as áreas em que o posso ajudar.", 0, 2000);

            context.Call(new MenuDialog(MenuDialog.State.INIT), ResumeAfterDialogCall);
        }
示例#4
0
        public async Task RegisterSave(IDialogContext context, List <InputData> data)
        {
            await Interactions.SendMessage(context, "Estou a analizar os seus dados ...", 0, 0);

            string fail_text = AccountLogic.Register(data, context);

            if (fail_text != "")
            {
                await context.PostAsync(fail_text);
            }
            else
            {
                await Interactions.SendMessage(context, Interactions.Register(StateHelper.GetUser(context)), 0, 2000);
            }

            state = State.INIT;

            await Interactions.SendMessage(context, "Existe alguma questão em que lhe possa ser útil? Com o menu principal é mais fácil mostrar-lhe as áreas em que o posso ajudar.", 0, 3000);

            context.Call(new MenuDialog(MenuDialog.State.INIT), ResumeAfterDialogCall);
        }
示例#5
0
        /*
         * UI Cards
         */

        public static void SetAccountCardFields(JToken card, IDialogContext context, bool edit_card)
        {
            User user          = StateHelper.GetUser(context);
            var  customer_card = user.CustomerCard;
            var  info_tag      = "text";

            if (customer_card == "")
            {
                customer_card = "Desconhecido";
            }

            if (edit_card)
            {
                info_tag = "value";
            }

            GetAccountCardSection(card, CardField.NAME)[info_tag]          = user.Name;
            GetAccountCardSection(card, CardField.CLIENT_NUMBER)[info_tag] = user.CustomerCard;
            GetAccountCardSection(card, CardField.GENDER)[info_tag]        = user.Gender;
            GetAccountCardSection(card, CardField.EMAIL)[info_tag]         = user.Email;
        }
示例#6
0
        public static string Register(List <InputData> fields, IDialogContext context)
        {
            string fail = "";

            string name   = "";
            string email  = "";
            string card   = "";
            string gender = "";

            foreach (InputData f in fields)
            {
                switch (f.attribute)
                {
                case name_field:
                    if (f.value != "")
                    {
                        name = f.value;
                    }
                    else
                    {
                        fail += "Preciso que me diga o seu nome.\n";
                    }
                    break;

                case email_field:
                    if (f.value != "")
                    {
                        try
                        {
                            var m = new MailAddress(f.value);
                            email = f.value;
                        }
                        catch
                        {
                            fail += "O email não está no formato correcto (exemplo: [email protected]).\n";
                        }
                    }
                    else
                    {
                        fail += "Por favor insira o seu email. Com ele irei conseguir identificá-lo melhor.\n";
                    }
                    break;

                case gender_field:
                    gender = f.value;
                    break;

                case client_id_field:
                    if (f.value != "")
                    {
                        card = f.value;
                    }
                    break;
                }
            }

            if (email != StateHelper.GetUser(context).Email&& UserController.getUserByEmail(email) != null && email != "")
            {
                fail += "O email que inseriu já está associado a uma outra conversa.\n";
            }
            else
            {
                Random r = new Random();
                UserController.CreateUser(email, name, (r.Next(25) + 1).ToString(), gender);
                User u = UserController.getUserByEmail(email);
                ContextController.CreateContext(u);
                CRMController.AddCustomer(u);

                if (card != "0")
                {
                    UserController.SetCustomerCard(u, card);
                    u.CustomerCard = card;
                }

                StateHelper.SetUser(context, u);
            }
            return(fail);
        }