Пример #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            RequestWindowFeature(WindowFeatures.NoTitle);

            // Create your application here

            SetContentView(Resource.Layout.Finance);

            FindViewById <Button>(Resource.Id.faCloseB).Click += (sender, e) => {
                Finish();
            };

            var pharmacyUUID = Intent.GetStringExtra("UUID");

            if (string.IsNullOrEmpty(pharmacyUUID))
            {
                return;
            }


            Pharmacy = MainDatabase.GetPharmacy(pharmacyUUID);
            FindViewById <TextView>(Resource.Id.faInfoTV).Text = string.Format("ПРОДАЖИ: {0}", Pharmacy.GetName());

            //				var date1 = FindViewById<TextView>(Resource.Id.htiDate1);
            //				date1.Text = DateTimeOffset.Now.Date.ToString("dd.MM.yy");
            //
            //				var date2 = FindViewById<TextView>(Resource.Id.htiDate2);
            //				date2.Text = DateTimeOffset.Now.Date.AddDays(7).Date.ToString("dd.MM.yy");
            //
            Content    = FindViewById <LinearLayout>(Resource.Id.faContentLL);
            Table      = FindViewById <LinearLayout>(Resource.Id.faTable);
            TableBySKU = FindViewById <LinearLayout>(Resource.Id.faTableBySKU);

            var add      = FindViewById <ImageView>(Resource.Id.faAdd);
            var isCanAdd = Intent.GetBooleanExtra(C_IS_CAN_ADD, true);

            if (isCanAdd)
            {
                add.Click += (sender, e) => {
                    //Toast.MakeText(this, "ADD BUTTON CLICKED", ToastLength.Short).Show();
                    Console.WriteLine("Event {0} was called", "faAdd_Click");
                    FragmentTransaction fragmentTransaction = FragmentManager.BeginTransaction();

                    var prev = FragmentManager.FindFragmentByTag(FinanceDialog.TAG);
                    if (prev != null)
                    {
                        fragmentTransaction.Remove(prev);
                    }
                    fragmentTransaction.AddToBackStack(null);

                    var financeDialog = new FinanceDialog(Pharmacy);
                    financeDialog.Show(fragmentTransaction, FinanceDialog.TAG);
                    financeDialog.AfterSaved += (caller, arguments) => {
                        Console.WriteLine("Event {0} was called. FinanceDatas count {1}", "AfterSaved", arguments.FinanceDatas.Count);

                        //Table.RemoveAllViews();

                        RefreshView();
                        //MainDatabase.SaveItems(arguments.FinanceDatas);
                        //SetValues(arguments.FinanceDatas);
                    };
                };
            }
            else
            {
                add.Visibility = ViewStates.Gone;
            }

            var switcher = FindViewById <ViewSwitcher>(Resource.Id.faSwitchViewTypeVS);
            var sw       = FindViewById <ImageView>(Resource.Id.faSwitchIV);

            sw.Click += (sender, e) => {
                switcher.ShowNext();
            };
        }
Пример #2
0
        public ActiveLeadDialog(
            UserProfileDialog userProfileDialog,
            FinanceDialog financeDialog,
            VehicleProfileDialog vehicleProfileDialog,
            ValueTradeInDialog valueTradeInDialog,
            SimpleInventoryDialog inventoryDialog,
            ICardFactory <BasicDetails> profileFactory,
            ICardFactory <FinancingDetails> financeFactory,
            ICardFactory <TradeInDetails> tradeinFactory,
            ICardFactory <VehicleProfileDetails> vehicleFactory,
            ADSBotServices botServices)
            : base(nameof(ActiveLeadDialog))
        {
            Services = botServices;

            var rootDialog = new AdaptiveDialog(nameof(AdaptiveDialog))
            {
                Generator = new TemplateEngineLanguageGenerator(),
                Triggers  = new List <OnCondition>()
                {
                    new OnCustomEvent(Constants.Event_Help)
                    {
                        Actions = new List <Dialog>()
                        {
                            new SetProperty()
                            {
                                Property = "conversation.seen_help",
                                Value    = "true"
                            },
                            new ChoiceInput()
                            {
                                Prompt = new ActivityTemplate("I want to provide you with the best service possible! " +
                                                              "Just select one of the easy-click options below, or " +
                                                              "type a request directly into the text box."),
                                AlwaysPrompt = true,
                                Property     = "conversation.interest",
                                Choices      = new ChoiceSet(Constants.HelpOptions.Select(o => new Choice(o)).ToList())
                            },
                            new IfCondition()
                            {
                                Condition = "conversation.interest != null",
                                Actions   = new List <Dialog>()
                                {
                                    new EmitEvent(Constants.Event_Interest)
                                }
                            },
                        }
                    },
                    new OnCustomEvent(Constants.Event_Interest)
                    {
                        Condition = "conversation.interest != null",
                        Actions   = new List <Dialog>()
                        {
                            new IfCondition()
                            {
                                Condition = "user.UserProfile.IsRegistered",
                                Actions   = new List <Dialog>()
                                {
                                    new SwitchCondition()
                                    {
                                        Condition = "conversation.interest",
                                        Cases     = new List <Case>()
                                        {
                                            new Case()
                                            {
                                                Value   = Constants.INTEREST_Financing,
                                                Actions = new List <Dialog>()
                                                {
                                                    new EmitEvent(Constants.Event_Card, "'financing'")
                                                }
                                            },
                                            new Case()
                                            {
                                                Value   = Constants.INTEREST_Identify,
                                                Actions = new List <Dialog>()
                                                {
                                                    new EmitEvent(Constants.Event_Card, "'vehicle'")
                                                }
                                            },
                                            new Case()
                                            {
                                                Value   = Constants.INTEREST_TradeIn,
                                                Actions = new List <Dialog>()
                                                {
                                                    new EmitEvent(Constants.Event_Card, "'tradein'")
                                                }
                                            },
                                            new Case()
                                            {
                                                Value   = Constants.INTEREST_Inventory,
                                                Actions = new List <Dialog>()
                                                {
                                                    new EmitEvent(Constants.Event_Card, "'inventory'")
                                                }
                                            }
                                        }
                                    }
                                },
                                ElseActions = new List <Dialog>()
                                {
                                    new SetProperty()
                                    {
                                        Property = "conversation.residual_interest",
                                        Value    = "conversation.interest"
                                    },
                                    new DeleteProperty()
                                    {
                                        Property = "conversation.interest"
                                    },
                                    new EmitEvent(Constants.Event_Card, "'profile'")
                                }
                            },
                            //Delete the property so we don't loop forever
                            new DeleteProperty()
                            {
                                Property = "conversation.interest"
                            }
                        }
                    },
                    new OnCustomEvent(Constants.Event_Cancel)
                    {
                        Actions = new List <Dialog>()
                        {
                            //  when the user cancels we need to check where they were so that we can transition smoothly.
                            //  what if they weren't in a dialog? What if they've typed 'cancel' twice in a row?
                            new EmitEvent(Constants.Event_Help, bubble: true),
                            new CancelAllDialogs(),
                        }
                    },
                    new OnCustomEvent(Constants.Event_Card)
                    {
                        Actions = new List <Dialog>()
                        {
                            new SetProperty()
                            {
                                Property = "conversation.busy",
                                Value    = "true"
                            },
                            new SwitchCondition()
                            {
                                Condition = "toLower(turn.dialogEvent.value)",
                                Cases     = new List <Case>()
                                {
                                    //Just copied from below as a quick fix, ideally this would all be in the financing dialog itself.
                                    new Case("profile")
                                    {
                                        Actions = new List <Dialog>()
                                        {
                                            new BeginDialog(userProfileDialog.Id)
                                        }
                                    },
                                    new Case("financing")
                                    {
                                        Actions = new List <Dialog>()
                                        {
                                            new BeginDialog(financeDialog.Id)
                                        }
                                    },
                                    new Case("vehicle")
                                    {
                                        Actions = new List <Dialog>()
                                        {
                                            new BeginDialog(vehicleProfileDialog.Id)
                                        }
                                    },
                                    new Case("tradein")
                                    {
                                        Actions = new List <Dialog>()
                                        {
                                            new BeginDialog(valueTradeInDialog.Id)
                                        }
                                    },
                                    new Case("inventory")
                                    {
                                        Actions = new List <Dialog>()
                                        {
                                            new BeginDialog(inventoryDialog.Id)
                                        }
                                    },
                                },
                                Default = new List <Dialog>()
                                {
                                    new SendActivity("I'm sorry, I can't handle that request yet. :("),
                                    new EmitEvent(Constants.Event_Help, bubble: true)
                                }
                            },
                            new SetProperty()
                            {
                                Property = "conversation.busy",
                                Value    = "false"
                            },
                            new IfCondition()
                            {
                                Condition = "conversation.residual_interest != null",
                                Actions   = new List <Dialog>()
                                {
                                    new SetProperty()
                                    {
                                        Property = "conversation.interest",
                                        Value    = "conversation.residual_interest"
                                    },
                                    new DeleteProperty()
                                    {
                                        Property = "conversation.residual_interest"
                                    },
                                    new EmitEvent(Constants.Event_Interest)
                                },
                                ElseActions = new List <Dialog>()
                                {
                                    new DeleteProperty()
                                    {
                                        Property = "conversation.interest"
                                    },
                                    new EmitEvent(Constants.Event_Help)
                                }
                            },
                        }
                    },

                    new OnBeginDialog()
                    {
                        Actions = new List <Dialog>()
                        {
#if DEBUG
                            new TraceActivity()
                            {
                                Name = "OnBeginDialog"
                            },
#endif
                            new CodeAction(async(context, _) => {
                                await Services.SetUserProfileAsync(await Services.GetUserProfileAsync(context.Context), context);
                                return(new DialogTurnResult(DialogTurnStatus.Complete));
                            }),
                            new EmitEvent(Constants.Event_Help),
                        }
                    },
                    new OnMessageActivity()
                    {
                        Actions = new List <Dialog>()
                        {
#if DEBUG
                            new TraceActivity("OnMessageActivity")
                            {
                                Name = "OnMessageActivity"
                            },
#endif
                            new CodeAction(async(context, _) => {
                                await Services.SetUserProfileAsync(await Services.GetUserProfileAsync(context.Context), context);
                                return(new DialogTurnResult(DialogTurnStatus.Complete));
                            }),
                            new CodeAction(PrimaryHandler)
                        }
                    }
                }
            };

            CardFactories.Add(profileFactory);
            CardFactories.Add(financeFactory);
            CardFactories.Add(tradeinFactory);
            CardFactories.Add(vehicleFactory);

            AddDialog(rootDialog);

            AddDialog(userProfileDialog);
            AddDialog(financeDialog);
            AddDialog(vehicleProfileDialog);
            AddDialog(valueTradeInDialog);
            AddDialog(inventoryDialog);
        }