Example #1
0
        private IForm <RegistrationQuery> BuildRegistrationForm()
        {
            OnCompletionAsyncDelegate <RegistrationQuery> processRegistration = async(context, state) =>
            {
                string waiting = await TranslatorHelper.TranslateSentenceAsync($"{Resources.Resource.Registration_WaitingForImage}", Settings.SpecificLanguage);

                await context.PostAsync(waiting);

                context.PrivateConversationData.SetValue(REGISTRATIONDATA, state);
            };

            RegistrationQueryAllText res = null;

            Task.Run(BuildAsync).ContinueWith((b) => { res = b.Result; }).Wait();

            return(new FormBuilder <RegistrationQuery>()
                   .Field(nameof(RegistrationQuery.Name), res.Name)
                   .Field(nameof(RegistrationQuery.Lastname), res.Lastname)
                   .Field(nameof(RegistrationQuery.Country), res.CountryText)
                   .Field(nameof(RegistrationQuery.LocationOfLost), res.LocationOfLost)
                   .Field(nameof(RegistrationQuery.DateOfLost), res.DateOfLost)
                   .Field(nameof(RegistrationQuery.ReportId), res.ReportId)
                   .Field(nameof(RegistrationQuery.ReportedBy), res.ReportedBy)
                   .Field(nameof(RegistrationQuery.Genre), res.GenreText)
                   .OnCompletion(processRegistration)
                   .Build());
        }
        public static IForm <FormSeguroViagem> SeguroBuildForm()
        {
            //Callback para final de formulário
            OnCompletionAsyncDelegate <FormSeguroViagem> processandoCalculo = async(context, state) =>
            {
                context.UserData.SetValue("DadosSeguroViagem", PopulateContextWithData(state));
                await context.PostAsync($"Aguarde um momento enquanto calculamos seu seguro.");
            };

            return(FormUtils.CreateCustomForm <FormSeguroViagem>()
                   .Field(nameof(TempOrigem), active: alwaysFalse)  //Precisa Incluir esse Field para ter visibilidade
                   .Field(nameof(TempDestino), active: alwaysFalse) //Precisa Incluir esse Field para ter visibilidade
                   .Field(nameof(TempIda), active: alwaysFalse)     //Precisa Incluir esse Field para ter visibilidade
                   .Field(nameof(TempVolta), active: alwaysFalse)   //Precisa Incluir esse Field para ter visibilidade
                   .Field(nameof(confirmaEstado), active: HasOrign)
                   .Field(nameof(notFoundEstado), active: IsOrignValid, validate: ValidateUF)
                   .Field(nameof(Origem), active: ConfirmedOrign, validate: ValidateUF)
                   .Field(nameof(confirmaPais), active: HasDestiny)
                   .Field(nameof(notFoundPais), active: IsDestinyValid, validate: ValidatePais)
                   .Field(nameof(Destino), active: ConfirmedDestiny, validate: ValidatePais)
                   .Field(nameof(PaisEuropeu), active: DestinoIsEurope)
                   .Field(nameof(confirmaDataPartida), active: ValidDataPartida)
                   .Field(nameof(DataPartidaErr), active: IsIdaValid, validate: ValidateStartDateErr)
                   .Field(nameof(DataPartida), active: ConfirmedDataPartida, validate: ValidateStartDate)
                   .Field(nameof(confirmaDataRetorno), active: ValidDataRetorno)
                   .Field(nameof(DataRetornoErr), active: IsVoltaValid, validate: ValidateEndDateErr)
                   .Field(nameof(DataRetorno), active: ConfirmedDataRetorno, validate: ValidateEndDate)
                   .Field(nameof(Menor70), validate: ValidateQtd)
                   .Field(nameof(Maior70), validate: ValidateQtd)
                   .Field(nameof(ViagemAventura))
                   .Field(nameof(MotivoDaViagem), validate: ValidateMotivoViagem)
                   .OnCompletion(processandoCalculo)
                   .Build());
        }
Example #3
0
        public static IForm <SearchOrder> BuildForm()
        {
            OnCompletionAsyncDelegate <SearchOrder> search = async(context, state) =>
            {
                //context.ConversationData.GetValue("A");


                var reply = context.MakeMessage();
                switch (state.Search)
                {
                case SearchType.WebSearch:  reply = await new BingSearch().Search(reply, state.SearchQuery);
                    break;

                case SearchType.ImageSearch:
                    reply = await new BingSearch().SearchImages(reply, state.SearchQuery);
                    break;

                case SearchType.Emotion:
                    reply = await new EmotionSearch().UploadAndDetectEmotions(state.SearchQuery);
                    break;

                default: reply = await new BingSearch().Search(reply, state.SearchQuery); break;
                }
                await context.PostAsync(reply);
            };

            return(new FormBuilder <SearchOrder>()
                   .Message("Welcome to the simple search bot!")
                   .Field(nameof(Search))

                   .OnCompletion(search)
                   .AddRemainingFields()
                   .Build());
        }
Example #4
0
        public static IForm <SandwichOrder> BuildForm()
        {
            OnCompletionAsyncDelegate <SandwichOrder> processOrder = async(context, state) =>
            {
                await context.PostAsync("We are currently processing your sandwich. We will message you the status.");
            };

            return(new FormBuilder <SandwichOrder>()
                   .Message("Welcome to the sandwich order bot!")
                   .Field(nameof(Sandwich))
                   .Field(nameof(Length))
                   .Field(nameof(Bread))
                   .Field(nameof(Cheese))
                   .Field(nameof(Toppings))
                   .Message("For sandwich toppings you have selected {Toppings}.")
                   .Field(nameof(SandwichOrder.Sauces))
                   .Field(new FieldReflector <SandwichOrder>(nameof(Specials))
                          .SetType(null)
                          .SetActive((state) => state.Length == LengthOptions.FootLong)
                          .SetDefine(async(state, field) =>
            {
                field
                .AddDescription("cookie", "Free cookie")
                .AddTerms("cookie", "cookie", "free cookie")
                .AddDescription("drink", "Free large drink")
                .AddTerms("drink", "drink", "free drink");
                return true;
            }))
                   .Confirm(async(state) =>
            {
                var cost = 0.0;
                switch (state.Length)
                {
                case LengthOptions.SixInch: cost = 5.0; break;

                case LengthOptions.FootLong: cost = 6.50; break;
                }
                return new PromptAttribute($"Total for your sandwich is ${cost:F2} is that ok?");
            })
                   .Field(nameof(SandwichOrder.DeliveryAddress),
                          validate: async(state, response) =>
            {
                var result = new ValidateResult {
                    IsValid = true, Value = response
                };
                var address = (response as string).Trim();
                if (address.Length > 0 && address[0] < '0' || address[0] > '9')
                {
                    result.Feedback = "Address must start with a number.";
                    result.IsValid = false;
                }
                return result;
            })
                   .Field(nameof(SandwichOrder.DeliveryTime), "What time do you want your sandwich delivered? {||}")
                   .Confirm("Do you want to order your {Length} {Sandwich} on {Bread} {&Bread} with {[{Cheese} {Toppings} {Sauces}]} to be sent to {DeliveryAddress} {?at {DeliveryTime:t}}?")
                   .AddRemainingFields()
                   .Message("Thanks for ordering a sandwich!")
                   .OnCompletionAsync(processOrder)
                   .Build());
        }
Example #5
0
        private IForm <HotelsQuery> BuildHotelsForm()
        {
            OnCompletionAsyncDelegate <HotelsQuery> processHotelsSearch = async(context, state) =>
            {
                var message = "Searching for hotels";
                var speech  = @"<speak version=""1.0"" xml:lang=""en-US"">Searching for hotels";
                if (!string.IsNullOrEmpty(state.Destination))
                {
                    state.Destination = state.Destination.Capitalize();
                    message          += $" in { state.Destination}...";
                    speech           += $" in { state.Destination}...";
                }
                else if (!string.IsNullOrEmpty(state.AirportCode))
                {
                    message += $" near {state.AirportCode.ToUpperInvariant()} airport...";
                    speech  += $@" near<break time=""100ms""/>{SSMLHelper.SayAs("characters",state.AirportCode.ToUpperInvariant())} <break time=""200ms""/>airport";
                }
                speech += "</speak>";

                var response = context.MakeMessage();
                response.Summary   = message;
                response.Speak     = speech;
                response.InputHint = InputHints.IgnoringInput;
                await context.PostAsync(response);
            };

            return(new FormBuilder <HotelsQuery>()
                   .Field(nameof(HotelsQuery.Destination), (state) => string.IsNullOrEmpty(state.AirportCode))
                   .Field(nameof(HotelsQuery.AirportCode), (state) => string.IsNullOrEmpty(state.Destination))
                   .OnCompletion(processHotelsSearch)
                   .Build());
        }
Example #6
0
        public static IForm <TravelRequestForm> BuildForm()
        {
            OnCompletionAsyncDelegate <TravelRequestForm> wrapUpRequest = async(context, state) =>
            {
                string wrapUpMessage = "Your Travel Request from " + state.DepartureCity + " to " + state.DepartureCity + "is saved";

                var msg = context.MakeMessage();
                msg.Text = wrapUpMessage;

                await context.PostAsync(msg);
            };

            return(new FormBuilder <TravelRequestForm>()
                   .Message("Welecome to Travel Bot. Please choose an option")
                   .Field(nameof(ModeOfTravel))
                   .Field(nameof(Options))
                   .Field(nameof(DepartureCity))
                   .Field(nameof(DestinationCity))
                   .Field(nameof(TravelDate))
                   // .Field(new FieldReflector<TravelRequestForm>(nameof(TravelDate))
                   //.SetNext(SetNextAfterTravelDate))
                   .Field(nameof(ReturnDate), state => (state.Options == TravelOptions.Return))
                   .Field(nameof(DepartureCity2), state => (state.Options == TravelOptions.TwoWay))
                   .Field(nameof(DestinationCity2), state => (state.Options == TravelOptions.TwoWay))
                   .Field(nameof(TravelDate2), state => (state.Options == TravelOptions.TwoWay))
                   .Field(nameof(IsHotelRequired))

                   .Confirm("Do you confirm your selection ? {*}")
                   .OnCompletion(wrapUpRequest)
                   .Build());
        }
        private IForm <HotelsQuery> GetProjectsForm()
        {
            OnCompletionAsyncDelegate <HotelsQuery> processHotelsSearch = async(context, state) =>
            {
                await context.PostAsync($"Ok.Taking you to Jenkins Build.Just Hold on!!");


                var message    = context.MakeMessage();
                var attachment = GetJenkinsBuild();
                message.Attachments.Add(attachment);
                await context.PostAsync(message);

                // this.ShowOptionsEnd(context);

                // await context.PostAsync($"Want to check status of execution?");
                // await context.SayAsync($"Want to check status of execution?");
                //context.EndConversation(EndOfConversationCodes.CompletedSuccessfully);
                //await this.ShowJobSuites(context);
            };

            return(new FormBuilder <HotelsQuery>()
                   //    .Field(nameof(HotelsQuery.TestsuiteName))
                   //    .Message("Loading Test Suites in {TestsuiteName}")
                   //    .AddRemainingFields()
                   .OnCompletion(processHotelsSearch)
                   .Build());
        }
Example #8
0
        private IForm <FlightsQuery> BuildFlightsForm()
        {
            OnCompletionAsyncDelegate <FlightsQuery> processflightsSearch = async(context, state) =>
            {
                var searchMessage = context.MakeMessage();
                var message       = $"One moment. I'm searching for the best credit cards to cover for the round trip flights from {state.Origin} to {state.Destination} " +
                                    $"departing {state.DepartDate.ToString("MMMM dd, yyyy")} and returning {state.ReturnDate.ToString("MMMM dd, yyyy")}...";
                searchMessage.Text  = message;
                searchMessage.Speak = message;
                await context.PostAsync(searchMessage);
            };

            return(new FormBuilder <FlightsQuery>()
                   .Field(nameof(FlightsQuery.Destination))
                   .Field(nameof(FlightsQuery.Origin))
                   .Field(nameof(FlightsQuery.DepartDate))
                   .Field(nameof(FlightsQuery.ReturnDate),
                          validate: async(state, response) =>
            {
                var result = new ValidateResult {
                    IsValid = true, Value = response
                };
                if (state.DepartDate > (DateTime)response)
                {
                    result.IsValid = false;
                    result.Feedback = "Return date can't be before departure date.";
                }
                return result;
            })
                   .AddRemainingFields()
                   .OnCompletion(processflightsSearch)
                   .Build());
        }
Example #9
0
        public static IForm <FlightSearchForm> BuildForm()
        {
            OnCompletionAsyncDelegate <FlightSearchForm> saveFlightSearchParams = async(context, form) =>
            {
                string searchingMessage = "Starting the search for your next trip!";
                await context.PostAsync(searchingMessage);

                context.PrivateConversationData.SetValue <bool>("SearchParamsComplete", true);
                context.PrivateConversationData.SetValue <string>("firstName", form.firstName);
                context.PrivateConversationData.SetValue <string>("lastName", form.lastName);
                context.PrivateConversationData.SetValue <string>("emailAddress", form.emailAddress);
                context.PrivateConversationData.SetValue <string>("departureCity", form.departureCity);
                context.PrivateConversationData.SetValue <string>("departureDate", form.departureDate);
                context.PrivateConversationData.SetValue <string>("arrivalCity", form.arrivalCity);
                context.PrivateConversationData.SetValue <string>("maxBudget", form.maxBudget);
                await context.PostAsync("Your search parameters are all set!");
            };

            return(new FormBuilder <FlightSearchForm>()
                   .Message("Great. Let's start planning your next trip!")
                   .Field(nameof(firstName))
                   .Field(nameof(lastName))
                   .Field(nameof(emailAddress))
                   .Field(nameof(departureCity))
                   .Field(nameof(departureDate))
                   .Field(nameof(arrivalCity))
                   .Field(nameof(maxBudget))
                   .OnCompletion(saveFlightSearchParams)
                   .Build());
        }
Example #10
0
        private IForm <OutlookEvent> BuildOutlookEventForm()
        {
            OnCompletionAsyncDelegate <OutlookEvent> processOutlookEventCreate = async(context, state) =>
            {
                using (var scope = WebApiApplication.Container.BeginLifetimeScope())
                {
                    IEventService service = scope.Resolve <IEventService>(new TypedParameter(typeof(IDialogContext), context));
                    Event         @event  = new Event()
                    {
                        Subject = state.Subject,
                        Start   = new DateTimeTimeZone()
                        {
                            DateTime = state.Start.ToString(), TimeZone = "Tokyo Standard Time"
                        },
                        IsAllDay = state.IsAllDay,
                        End      = state.IsAllDay ? null : new DateTimeTimeZone()
                        {
                            DateTime = state.Start.AddHours(state.Hours).ToString(), TimeZone = "Tokyo Standard Time"
                        },
                        Body = new ItemBody()
                        {
                            Content = state.Description, ContentType = BodyType.Text
                        }
                    };
                    await service.CreateEvent(@event);
                }
            };

            return(new FormBuilder <OutlookEvent>()
                   .Message("Creating an event.")
                   .AddRemainingFields() // add all (remaing) fields to the form.
                   .OnCompletion(processOutlookEventCreate)
                   .Build());
        }
Example #11
0
        public static IForm <RegistrationForm> BuildForm()
        {
            OnCompletionAsyncDelegate <RegistrationForm> processOrder = async(context, state) =>
            {
                var personalData = new PersonalData
                {
                    Email          = state.Email,
                    FirstName      = state.FirstName,
                    Interests      = state.Interests,
                    IsAccepted     = state.IsAccepted,
                    LastName       = state.LastName,
                    PhoneNumber    = state.PhoneNumber,
                    Specialization = state.Specialization,
                    Year           = state.Year
                };
                DataProviderService.Instance.SetUserData(context.Activity.From.Id, personalData);
                var reply = context.MakeMessage();
                reply.Text = "Сейчас сделаю для тебя билет, приноси его с собой на мастер класс!";
                await context.PostAsync(reply);
            };

            return(new FormBuilder <RegistrationForm>()
                   .Message("Регистрация")
                   .AddRemainingFields()
                   .OnCompletion(processOrder)
                   .Build());
        }
Example #12
0
        public static IForm <ShiftStatusDialog> BuildForm()
        {
            OnCompletionAsyncDelegate <ShiftStatusDialog> processOrder = async(context, state) =>
            {
                // context.PrivateConversationData.SetValue<string>(
                // "List", state.List.ToString());
                context.PrivateConversationData.SetValue <string>(
                    "EmployeeNumber", EmpData);
                context.PrivateConversationData.SetValue <string>(
                    "Shifts", state.Shift.ToString());
                context.PrivateConversationData.SetValue <string>(
                    "Month", state.Month.ToString());
                // Tell the user that the form is complete
                string strResponse = BookTimeSheet(EmpCodeFromUser, state.Month.ToString(), state.Shift.ToString());
                await context.PostAsync(" Your !!" + strResponse);

                // await context.PostAsync("Glad you asked!!We will help to do your admin activites quickly and recommended best for you");
                await context.PostAsync("Thanks for using EPMSbot !");

                await context.PostAsync("Say 'hi' to initiate conversation");
            };

            return(new FormBuilder <ShiftStatusDialog>()
                   .Field(nameof(ShiftStatusDialog.Shift))
                   .Field(nameof(ShiftStatusDialog.Month))
                   .OnCompletion(processOrder)
                   .AddRemainingFields()
                   .Confirm("Please confirm your shift details \r\n Shift : {Shift} \r\n  Month : {Month} \r\n{||}")
                   .Build());
        }
Example #13
0
        public static IForm <ViewMeetingRoomForm> BuildForm()
        {
            var result = false;

            OnCompletionAsyncDelegate <ViewMeetingRoomForm> processOrder = async(context, state) =>
            {
                ShowBookings(context, state, out result);

                if (result)
                {
                    //await context.PostAsync("Thanks for using our service");
                    //await context.PostAsync("Bye!! ;-)");
                }
                else
                {
                    await context.PostAsync("Has no reservation!!!!!");

                    //await context.PostAsync("Thanks for using our service");
                    //await context.PostAsync("Bye!! ;-)");
                }
            };

            return(new FormBuilder <ViewMeetingRoomForm>()
                   .Message("Let's see that we found...")
                   .Field(nameof(StartDate))
                   .Field(nameof(NameRoom))
                   .Build());
        }
Example #14
0
        public static IForm <CustomerForm> BuildForm()
        {
            OnCompletionAsyncDelegate <CustomerForm> processOrder = async(context, state) =>
            {
                await context.PostAsync($" The actual information is \n* Status:  ");
            };
            CultureInfo ci = new CultureInfo("en");

            Thread.CurrentThread.CurrentCulture   = ci;
            Thread.CurrentThread.CurrentUICulture = ci;
            FormBuilder <CustomerForm> form = new FormBuilder <CustomerForm>();

            return(form.Message("Fill the information for register you, please")
                   .Field(nameof(customerId))
                   .Field(nameof(firstName))
                   .Field(nameof(middleName))
                   .Field(nameof(phoneNumber))
                   .Field(nameof(email))
                   .Field(nameof(male))

                   .Confirm("Are you selected the follow information: \n*   customerId: {customerId} \n* " +
                            "FirstName: {firstName}  \n* MiddleName:{middleName} \n* Phone Number: {phoneNumber} \n* Email: {email} " +
                            "\n* Male: {male}?"
                            + "(yes/no)")
                   .AddRemainingFields()
                   .Message("The process for create the customer has been started!")
                   .OnCompletion(processOrder)
                   .Build());
        }
        public static IForm <FlightQuery2> BuildForm()
        {
            OnCompletionAsyncDelegate <FlightQuery2> processOrder = async(context, state) =>
            {
                await Task.Run(() =>
                {
                    state.QueryDate = DateTime.Now;
                    var data        = AirportData.GetFlightByAirline(state.Airline);
                    if (data == null || data.Count > 0)
                    {
                        var item     = data[0];
                        state.Result = $"AFSKEY:{item.AFSKEY}, FLIGHT_NO : {item.FLIGHT_NO}, LEG:{item.LEG}, LEG_DESCRIPTION:{item.LEG_DESCRIPTION}, SCHEDULED:{item.SCHEDULED}, ESTIMATED :{item.ESTIMATED}, ACTUAL:{item.ACTUAL}, CATEGORY_CODE :{item.CATEGORY_CODE}, CATEGORY_NAME : {item.CATEGORY_NAME}, REMARK_CODE:{item.REMARK_CODE}, REMARK_DESC_ENG:{item.REMARK_DESC_ENG}, REMARK_DESC_IND:{item.REMARK_DESC_IND},TERMINAL_ID:{item.TERMINAL_ID}, GATE_CODE : {item.GATE_CODE}, GATE_OPEN_TIME : {item.GATE_OPEN_TIME}, GATE_CLOSE_TIME : {item.GATE_CLOSE_TIME}, STATION1 :{item.STATION1}, STATION1_DESC : {item.STATION1_DESC}, STATION2 :{item.STATION2}, STATION2_DESC : {item.STATION2_DESC}";
                    }
                    else
                    {
                        state.Result = $"Data is not found. Please try again..";
                    }
                });
            };
            var builder = new FormBuilder <FlightQuery2>(false);
            var form    = builder
                          .Field(nameof(Airline))
                          .OnCompletion(processOrder)
                          .Build();

            return(form);
        }
Example #16
0
        public static IForm <TagTrackerQuery> BuildForm()
        {
            OnCompletionAsyncDelegate <TagTrackerQuery> processOrder = async(context, state) =>
            {
                await Task.Run(() =>
                {
                    state.QueryDate = DateTime.Now;
                    var data        = SampleData.GetTagByCode(state.TagCode);
                    if (data != null)
                    {
                        state.Results = data;
                    }
                    else
                    {
                        state.Results = null;
                    }
                }
                               );
            };
            var builder = new FormBuilder <TagTrackerQuery>(false);
            var form    = builder
                          .Field(nameof(TagCode))
                          .OnCompletion(processOrder)
                          .Build();

            return(form);
        }
        public static IForm <BatterySelector> BuildForm()
        {
            OnCompletionAsyncDelegate <BatterySelector> processOrder = async(context, state) =>
            {
                string tmpmodel       = state.mmodel;
                string tmpmake        = state.mmake;
                string tmpyear        = state.myear;
                string tmpmliter      = state.mliter;
                string tmpreturn      = String.Empty;
                string tmpaftermarkey = state.maftermarket;
                tmpreturn = getbatteryInfo(tmpmodel, tmpmake, tmpyear, tmpmliter, tmpaftermarkey);

                if (tmpreturn == string.Empty || tmpreturn == "")
                {
                    tmpreturn = "Oops we couldn't find a battery for your request please try again";
                }

                await context.PostAsync("Then we would recommend " + tmpreturn + " Have a great day!");
            };


            return(new FormBuilder <BatterySelector>()
                   .Message("Hi welcome to optima, how can I help you?")
                   .Message("Please Select the options below to find your battery.")
                   .Field(nameof(BatterySelector.mmake))
                   .Field(nameof(BatterySelector.mmodel))
                   .Field(nameof(BatterySelector.myear))
                   .Field(nameof(BatterySelector.mliter))
                   .Field(nameof(BatterySelector.maftermarket))
                   .Confirm("The below battery options you have selection {mmake} {mmodel} {myear} {mliter} with aftermarket accessories {maftermarket}?")
                   .OnCompletion(processOrder)
                   //.Message("Thanks for selecting the battery and have a great day!")
                   .Build());
        }
Example #18
0
        private IForm <HotelsQuery> BuildHotelsForm()
        {
            OnCompletionAsyncDelegate <HotelsQuery> processHotelsSearch = async(context, state) =>
            {
                //await context.PostAsync($"Ok. Searching for Hotels in {state.Destination} from {state.CheckIn.ToString("MM/dd")} to {state.CheckIn.AddDays(state.Nights).ToString("MM/dd")}...");

                Weather weather = new Weather();
                //string temperature = weather.getTemperature(state.Destination).ToString();
                //string maxtemp = weather.getMaxTemperature(state.Destination).ToString();
                //string mintemp = weather.getMinTemperature(state.Destination).ToString();
                //string humidity = weather.getHumidity(state.Destination).ToString();
                //string weather1 = weather.getWeather(state.Destination);

                //await context.PostAsync($"Today's weather condition in {state.Destination} is listed below. Temperature: {temperature}F    Maximum Temperature: {maxtemp}F     Minimum Temperature: {mintemp}F     Humidity:{humidity}%    Weather:{weather1}.");


                await context.PostAsync("");
            };

            return(new FormBuilder <HotelsQuery>()
                   .Field(nameof(HotelsQuery.Destination))
                   .Field(nameof(HotelsQuery.CheckIn))
                   .Field(nameof(HotelsQuery.Nights))
                   //.Field(nameof(HotelsQuery.myoptions))
                   .OnCompletion(processHotelsSearch)
                   .Build());
        }
Example #19
0
        private IForm <Account> BuildForm()
        {
            IForm <Account> form;
            OnCompletionAsyncDelegate <Account> processLoanSuspension = async(context, state) =>
            {
                await context.PostAsync("account created");
            };

            var builder = new FormBuilder <Account>()
                          .Field(nameof(Account.Email), (state) => string.IsNullOrEmpty(state.Email))
                          .Field(nameof(Account.ConfirmEmail))
                          .Field(nameof(Account.Password))
                          .Field(nameof(Account.ConfirmPassword))
                          .Field(nameof(Account.SecurityQuestion))
                          .Field(nameof(Account.Answer))
                          .Field(nameof(Account.title))
                          .Field(nameof(Account.FirstName))
                          .Field(nameof(Account.LastName))
                          .Field(nameof(Account.Address))
                          .Field(nameof(Account.MobileNumber))
                          .Confirm("Do you want to proceed with account creation")
                          .OnCompletion(processLoanSuspension);

            builder.Configuration.DefaultPrompt.ChoiceStyle = ChoiceStyleOptions.Auto;
            form = builder.Build();
            return(form);
        }
Example #20
0
        private IForm <HotelSearchQuery> BuildHotelsForm()
        {
            OnCompletionAsyncDelegate <HotelSearchQuery> processHotelsSearch = async(context, state) =>
            {
                var message = "Searching for ";
                if (!string.IsNullOrEmpty(state.Market))
                {
                    message += $"hotels in {state.Market} ";
                }
                else if (!string.IsNullOrEmpty(state.Property))
                {
                    message += $"rooms in {state.Property} ";
                }
                message += $"checkin {state.CheckinDate} and checkout {state.CheckoutDate} ...";
                await context.PostAsync(message);
            };

            return(new FormBuilder <HotelSearchQuery>()
                   .Field(nameof(HotelSearchQuery.Market), (state) => string.IsNullOrEmpty(state.Property))
                   .Field(nameof(HotelSearchQuery.Property), (state) => string.IsNullOrEmpty(state.Market))
                   .Field(nameof(HotelSearchQuery.CheckinDate))
                   .Field(nameof(HotelSearchQuery.CheckoutDate))
                   .OnCompletion(processHotelsSearch)
                   .Build());
        }
        public static IForm <Cakes> BuildForm()
        {
            OnCompletionAsyncDelegate <Cakes> processOrder = async(context, state) =>
            {
                context.UserData.SetValue(Str.cStrGetName, true);
                context.UserData.SetValue(Str.cStrName, string.Empty);

                await context.PostAsync($"{Str.cStrProcessingReq} {Validate.DeliverType}");
            };

            return(new FormBuilder <Cakes>()
                   .Field(nameof(Quantity))

                   .Message(Str.cStrWhen)
                   .Field(nameof(When),
                          validate: async(state, value) =>
            {
                return await Task.Run(() =>
                {
                    string v = value.ToString();

                    return Validate.ValidateType(state, value.ToString(), Str.DeliverTypes);
                });
            })

                   .OnCompletion(processOrder)
                   .Build());
        }
        public IForm <ConferenceSearch> BuildForm()
        {
            OnCompletionAsyncDelegate <ConferenceSearch> processConferenceSearch = async(ctx, state) =>
            {
                var message = "Searching for conferences";
                if (state.Language.HasValue)
                {
                    message += $" in {state.Language}...";
                }
                if (state.City.HasValue)
                {
                    message += $" in city: {state.City}";
                }
                if (!string.IsNullOrWhiteSpace(state.Title))
                {
                    message += $" title:  {string.Join(",", state.Title)}...";
                }
                await ctx.PostAsync(message);
            };

            return(new FormBuilder <ConferenceSearch>()
                   .Field(nameof(ConferenceSearch.Language), (state) => !state.Language.HasValue)
                   .Field(nameof(ConferenceSearch.City), (state) => !state.City.HasValue)
                   .Field(nameof(ConferenceSearch.Title), (state) => string.IsNullOrWhiteSpace(state.Title))
                   .OnCompletion(processConferenceSearch)
                   .Build());
        }
        public static IForm <FacilityQuery> BuildForm()
        {
            OnCompletionAsyncDelegate <FacilityQuery> processOrder = async(context, state) =>
            {
                await Task.Run(() =>
                {
                    state.QueryDate = DateTime.Now;
                    var data        = AirportData.GetFacilityByCategory(state.FacilityType.ToString(), string.IsNullOrEmpty(state.Name)? null : state.Name);
                    if (data != null && data.Count > 0)
                    {
                        state.Results = data;
                    }
                    else
                    {
                        state.Results = null;
                    }
                }
                               );
            };
            var builder = new FormBuilder <FacilityQuery>(false);
            var form    = builder
                          .Field(nameof(FacilityType))
                          .Field(nameof(Name))
                          .OnCompletion(processOrder)
                          .Build();

            return(form);
        }
    public static IForm <ImagesForm> BuildForm()
    {
        OnCompletionAsyncDelegate <ImagesForm> onFormCompleted = async(context, state) =>
        {
            var botAccount  = new ChannelAccount(name: $"{ConfigurationManager.AppSettings["BotId"]}", id: $"{ConfigurationManager.AppSettings["BotEmail"]}".ToLower());
            var userAccount = new ChannelAccount(name: "Name", id: $"{ConfigurationManager.AppSettings["UserEmail"]}");
            MicrosoftAppCredentials.TrustServiceUrl(@"https://email.botframework.com/", DateTime.MaxValue);
            var connector      = new ConnectorClient(new Uri("https://email.botframework.com/"));
            var conversationId = await connector.Conversations.CreateDirectConversationAsync(botAccount, userAccount);

            IMessageActivity message = Activity.CreateMessageActivity();
            message.From         = botAccount;
            message.Recipient    = userAccount;
            message.Conversation = new ConversationAccount(id: conversationId.Id);
            var myfile = state.file_attachment;
            message.Attachments = new List <Attachment>();
            message.Attachments.Add(myfile);
            try
            {
                await connector.Conversations.SendToConversationAsync((Activity)message);
            }
            catch (ErrorResponseException e)
            {
                Console.WriteLine("Error: ", e.StackTrace);
            }


            var resumeSize = await RetrieveAttachmentSizeAsync(state.file_attachment);
        };

        return(new FormBuilder <ImagesForm>()
               .Message("Welcome")
               .OnCompletion(onFormCompleted)
               .Build());
    }
Example #25
0
        private IForm <ProjectsQuery> BuildProjectsForm()
        {
            OnCompletionAsyncDelegate <ProjectsQuery> processProjectsSearch = async(context, state) =>
            {
                var message = "Searching for projects";
                if (!string.IsNullOrEmpty(state.SchoolName))
                {
                    message += $" in {state.SchoolName}...";
                }
                if (!string.IsNullOrEmpty(state.LLW))
                {
                    message += $" in {state.LLW}...";
                }
                else if (!string.IsNullOrEmpty(state.Borough))
                {
                    message += $" near {state.Borough.ToUpperInvariant()} ";
                }
                else if (!string.IsNullOrEmpty(state.BuildingId))
                {
                    message += $" near {state.BuildingId.ToUpperInvariant()} ";
                }

                await context.PostAsync(message);
            };

            return(new FormBuilder <ProjectsQuery>()
                   .Field(nameof(ProjectsQuery.SchoolName), (state) => string.IsNullOrEmpty(state.Borough))
                   .Field(nameof(ProjectsQuery.Borough), (state) => string.IsNullOrEmpty(state.SchoolName))
                   .OnCompletion(processProjectsSearch)
                   .Build());
        }
Example #26
0
        public static IForm <LuggageQuery> BuildForm()
        {
            OnCompletionAsyncDelegate <LuggageQuery> processOrder = async(context, state) =>
            {
                await Task.Run(() =>
                {
                    state.QueryDate = DateTime.Now;
                    var data        = AirportData.GetLuggages(state.Airline, state.FlightNo);
                    if (data != null && data.Count > 0)
                    {
                        state.Results = data;
                    }
                    else
                    {
                        state.Results = null;
                    }
                }
                               );
            };
            var builder = new FormBuilder <LuggageQuery>(false);
            var form    = builder
                          .Field(nameof(Airline))
                          .Field(nameof(FlightNo))
                          .OnCompletion(processOrder)
                          .Build();

            return(form);
        }
Example #27
0
        public static IForm <ReportAPQuery> BuildForm()
        {
            OnCompletionAsyncDelegate <ReportAPQuery> processOrder = async(context, state) =>
            {
                await Task.Run(() =>
                {
                    state.QueryDate = DateTime.Now;
                    var data        = AirportData.GetReportByDate(state.StartDate, state.EndDate);
                    if (data != null && data.Count > 0)
                    {
                        state.Results = data;
                    }
                    else
                    {
                        state.Results = null;
                    }
                }
                               );
            };
            var builder = new FormBuilder <ReportAPQuery>(false);
            var form    = builder
                          .Field(nameof(StartDate))
                          .Field(nameof(EndDate))
                          .OnCompletion(processOrder)
                          .Build();

            return(form);
        }
Example #28
0
    public static IForm <BalanceForm> BuildForm()
    {
        OnCompletionAsyncDelegate <BalanceForm> wrapUpRequest = async
                                                                    (context, state) =>
        {
            //using (BotModelDataContext BotDb = new BotModelDataContext())
            //{
            //    //search in database

            //    string wrapUpMessage = "Dear " + house.Firstname + "," + "your  balance is " + house.Balance;
            //    await context.PostAsync(wrapUpMessage);
            //};

            //your code logic here

            var contractnumber = "";

            context.UserData.TryGetValue <string>("contract_number", out contractnumber);

            string wrapUpMessage = " Form completed! Your contract number is " + contractnumber;
            var    replymes      = context.MakeMessage();
            replymes.Text = wrapUpMessage;

            await context.PostAsync(replymes);
        };

        return(new FormBuilder <BalanceForm>()
               .Message("We have to ask you some information")
               .Field(new FieldReflector <BalanceForm>(nameof(contract)).SetActive(state => state.contract_number == null))
               .Field(nameof(your_other_field))
               .OnCompletion(wrapUpRequest)
               //.Confirm("Are you sure: Yes or No ")
               .Build());
    }
Example #29
0
        public static IForm <BookMeetingRoomForm> BuildForm()
        {
            var nameRoom = string.Empty;

            OnCompletionAsyncDelegate <BookMeetingRoomForm> processOrder = async(context, state) =>
            {
                SaveChangesfromBooking(context.Activity.From.Name, state, out nameRoom);

                await context.PostAsync("You did it....!!!!!");

                await context.PostAsync("You have the meeting Room: " + nameRoom);

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

            return(new FormBuilder <BookMeetingRoomForm>()
                   .Message("Let´s go to book a meeting room")
                   .Field(nameof(StartDate))
                   .Field(nameof(StartTime))
                   .Field(nameof(EndTime))
                   .Field(nameof(Attendant))
                   .Field(nameof(TypeRoom))
                   .OnCompletion(processOrder)
                   .AddRemainingFields()
                   .Build());
        }
Example #30
0
        private IForm <NameQuery> BuildNameForm()
        {
            OnCompletionAsyncDelegate <NameQuery> processNameSearch = async(context, state) =>
            {
                var message = "Hello to ";
                if (!string.IsNullOrEmpty(state.UserName))
                {
                    Name = state.UserName;
                    HasBeenIdentified = true;
                    message          += Name + " ";
                }
                if (!string.IsNullOrEmpty(state.Country))
                {
                    Country = state.Country;

                    message += "from " + Country;
                }

                await context.PostAsync(message);
            };

            return(new FormBuilder <NameQuery>()
                   //.Field(nameof(NameQuery.UserName), (state) => string.IsNullOrEmpty(state.UserName))
                   //.Field(nameof(NameQuery.Country), (state) => string.IsNullOrEmpty(state.Country))
                   .Field(nameof(NameQuery.UserName))
                   .Field(nameof(NameQuery.Country))
                   .OnCompletion(processNameSearch)
                   .Build());
        }