Exemple #1
0
 /* For debugging purposes */
 public string GetBagStrRep()
 {
     return(handSets.BuildStrRep());
 }
        private async Task DecodeAndProcessIntentAsync(IDialogContext context)
        {
            int           handSetsLeft, handSetsNow = decoder.CurrentNumberofHandsetsLeft();
            string        featureText;
            StringBuilder sb = new StringBuilder("Debug from the DecodeIntent() method");

            if (CommonDialog.debugMessages)
            {
                await context.PostAsync("Beginning of DecodeAndProcessIntentAsync() method;");
            }
            decoder.LastOneWasNeed = false;
            if (smallDesc.TryGetValue(desiredFeature, out featureText))
            {
                decoder.FeatureOrNeedDesc = featureText;
            }
            else
            {
                decoder.FeatureOrNeedDesc = null;
            }
            if (CommonDialog.debugMessages)
            {
                await context.PostAsync("I'm going to call the decoder with " + desiredFeature.ToString());
            }
            handSetsLeft = decoder.DecodeIntent(desiredFeature, res, sb);
            if (CommonDialog.debugMessages)
            {
                await context.PostAsync("DEbugging info from DecodeIntent() : " + sb.ToString());
            }
            if (askingAboutFeaturePhones)
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync("I'm asking about feature phones");
                }
                RecoverContext();
                decoder.FeatureOrSmartPhoneDecision = true;
                askingAboutFeaturePhones            = false;
                handSetsLeft = decoder.DecodeIntent(desiredFeature, res);
            }
            else if (CommonDialog.debugMessages)
            {
                await context.PostAsync("I'm not asking about feature phones");
            }
            if (handSetsLeft == -1) // Plenty of feature phones
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync("DecodeIntent() returned -1, which means there are plenty of feature phones on the carousel, user needs to be asked more questions");
                }
                SaveContext();
                await AskAboutFeaturePhonesAsync(context);
            }
            else
            {
                if (CommonDialog.debugMessages)
                {
                    await context.PostAsync($"DEBUG : I have here {handSetsLeft} equipments left, bag contents = {handSetsBag.BuildStrRep()}, bag count = {handSetsBag.BagCount()}");
                }
                await UpdateUserAsync(context, handSetsLeft, handSetsNow);
            }
        }