public QuestionOptionModel Process(int PreviousQuestion, string OptionSelected)
 {
     try
     {
         var                      FeatureDictionary = dataRef.ReadAttributes();
         int                      i                = 0;
         List <string>            Options          = new List <string>();
         Dictionary <int, string> AnswerDictionary = new Dictionary <int, string>();
         AnswerDictionary.Add(PreviousQuestion, OptionSelected);
         for (i = PreviousQuestion + 1; i < FeatureDictionary.Count; i++)
         {
             var optionsTemp = dataRef.ReadData(FeatureDictionary, AnswerDictionary, i);
             if (optionsTemp.Count > 0)
             {
                 foreach (var option in optionsTemp)
                 {
                     Options.Add(option);
                 }
                 break;
             }
         }
         return(new QuestionOptionModel {
             Qusetion = FeatureDictionary[i], Options = Options
         });
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
0
        public List <string> GetAllSelectedItems(int Feature_No, string FeatureValue)
        {
            var    FeatureDictionary = dataref.ReadAttributes();
            string Feature;

            if (Feature_No == 0)
            {
                Feature = "FirstFeature";
            }
            else
            {
                try
                {
                    Feature = FeatureDictionary[Feature_No];
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            List <string> Selectedlist = new List <string>();

            if (!Feature.Equals(string.Empty) && !FeatureValue.Equals(string.Empty))
            {
                using (ChatBotDataModelDataContext dbcontext = new ChatBotDataModelDataContext())
                {
                    if (Feature.Equals("FirstFeature") && FeatureValue.Equals("FirstValue"))
                    {
                        var Selectedtems = dbcontext.ChatbotTable_s.Select("monitors_name");
                        foreach (var Item in Selectedtems)
                        {
                            Selectedlist.Add(Item.ToString());
                        }
                    }
                    else
                    {
                        var Selectedtems = dbcontext.ChatbotTable_s.Where(Feature + "=\"" + FeatureValue + "\"").Select("monitors_name");
                        foreach (var Item in Selectedtems)
                        {
                            Selectedlist.Add(Item.ToString());
                        }
                    }
                }
            }
            else
            {
                throw new ArgumentException("String Empty");
            }
            return(Selectedlist);
        }
示例#3
0
        public QuestionOptionModel Process(int PreviousQuestion, string OptionSelected)
        {
            try
            {
                var                      FeatureDictionary = dataRef.ReadAttributes();
                int                      i = 0;
                string                   Question;
                List <string>            Options          = new List <string>();
                Dictionary <int, string> AnswerDictionary = new Dictionary <int, string>();
                AnswerDictionary.Add(PreviousQuestion, OptionSelected);
                for (i = PreviousQuestion + 1; i < FeatureDictionary.Count; i++)
                {
                    var optionsTemp = dataRef.ReadData(FeatureDictionary, AnswerDictionary, i);
                    if (optionsTemp.Count > 0)
                    {
                        foreach (var option in optionsTemp)
                        {
                            Options.Add(option);
                        }
                        break;
                    }
                }
                if (Options.Contains("true") || Options.Contains("false"))
                {
                    Question = string.Format("Do you want {0} ?", FeatureDictionary[i].ToUpper());
                }
                else
                {
                    Question = string.Format("Choose from the following {0} options:", FeatureDictionary[i].ToUpper());
                }
                return(new QuestionOptionModel {
                    Qusetion = Question, Options = Options
                });
            }
            catch (Exception ex)
            {
#pragma warning disable S3445 // Exceptions should not be explicitly rethrown
                throw ex;
#pragma warning restore S3445 // Exceptions should not be explicitly rethrown
            }
        }
        public void ProcessChatBot()
        {
            var           FeaturesDictionary = DataRef.ReadAttributes();
            List <string> SelectedItems;

            //For Each Feature from 1st to Last Question
            for (int i = 1; i < FeaturesDictionary.Count() - 1; i++)
            {
                string input = "";
                var    list  = new List <string>();
                //For First Question Reading
                if (i == 1)
                {
                    var Options = DataRef.ReadData(FeaturesDictionary, null, i);
                    if (Options.Count() > 0)
                    {
                        foreach (var option in Options)
                        {
                            list.Add(option);
                        }
                        QuestionSelection(FeaturesDictionary, i, list);
                        int index = OptionsDisplay(Options);
                        LoggerRef.Write(string.Format("\n!!!! Or else Choose Default options!!!! \n{0}: {1}\n{2}: {3}\n{4}: {5}\n", ++index, DefaultFeatures.Display_Items, ++index, DefaultFeatures.Start_Again, ++index, DefaultFeatures.Exit_the_Application));
                        int option_choosen = OptionCheck(index);

                        //Display the Selected Items
                        if (option_choosen == list.Count() + 1)
                        {
                            SelectedItems = SelectionRef.GetAllSelectedItems("FirstFeature", "FirstValue");
                            DisplayItems(SelectedItems);
                            i = i - 1;
                        }

                        //Start Again from the Home
                        else if (option_choosen == list.Count() + 2)
                        {
                            i = StartAgain();
                        }

                        //Aborting the Application
                        else if (option_choosen == list.Count() + 3)
                        {
                            ExitApplication();
                            //return null;
                        }

                        //Storing the option for next question
                        else
                        {
                            AnswerDictionary.Add(i, list[option_choosen - 1]);
                        }
                    }
                }
                else
                {
                    var Options = DataRef.ReadData(FeaturesDictionary, AnswerDictionary, i);
                    if (Options.Count() > 0)
                    {
                        foreach (var option in Options)
                        {
                            list.Add(option);
                        }
                        QuestionSelection(FeaturesDictionary, i, list);
                        int index = OptionsDisplay(Options);
                        LoggerRef.Write(string.Format("\n\n!!!! Or else Choose Default options!!!! \n{0}: {1}\n{2}: {3}\n{4}: {5}\n{6}: {7}\n", ++index, DefaultFeatures.Display_Items, ++index, DefaultFeatures.Start_Again, ++index, DefaultFeatures.Back, ++index, DefaultFeatures.Exit_the_Application));
                        int option_choosen = OptionCheck(index);

                        //Display the Selected Items
                        if (option_choosen == list.Count() + 1)
                        {
                            SelectedItems = SelectionRef.GetAllSelectedItems(FeaturesDictionary[feature_no], AnswerDictionary[feature_no]);
                            DisplayItems(SelectedItems);
                            i = i - 1;
                        }

                        //Start Again from the Home
                        else if (option_choosen == list.Count() + 2)
                        {
                            i = StartAgain();
                        }

                        //Back to the previous question
                        else if (option_choosen == list.Count() + 3)
                        {
                            i = BackPropagation(feature_no);
                        }

                        //Aborting the Application
                        else if (option_choosen == list.Count() + 4)
                        {
                            ExitApplication();
                        }

                        //Storing the option for next question
                        else
                        {
                            AnswerDictionary.Add(i, list[option_choosen - 1]);
                            feature_no = i;
                        }
                    }
                }
            }
            SelectedItems = SelectionRef.GetAllSelectedItems(FeaturesDictionary[feature_no], AnswerDictionary[feature_no]);

            DisplayItems(SelectedItems);
            LoggerRef.Write("\n---------------------------------!!!!! Thank you for your Interaction !!!!!---------------------------------\n      ---------------------------------------!!!!! VISIT AGAIN !!!!!---------------------------------");
        }