Example #1
0
        static void nlpCMDAsync()
        {
            NLP              nLP  = new NLP();
            Process          p    = new Process();
            ProcessStartInfo info = new ProcessStartInfo();

            info.FileName = "cmd.exe";
            info.RedirectStandardInput = true;
            info.UseShellExecute       = false;

            p.StartInfo = info;
            p.Start();
            string comanddd = "";

            //  Console.WriteLine("Mamun");



            using (StreamWriter sw = p.StandardInput)
            {
                CMD cmd = new CMD();
                while (true)
                {
                    comanddd = Console.ReadLine();

                    string[] splitString = comanddd.Split("#");
                    //   Console.WriteLine(splitString.Length.ToString());



                    //await Task.Run(() =>
                    //{
                    try
                    {
                        cmd = JsonConvert.DeserializeObject <CMD>(GetStringAsync(splitString[0].Trim()).Result);
                        //  Console.WriteLine(cmd.tasks);
                        comanddd = cmd.tasks;
                    }
                    catch (Exception)
                    {
                        comanddd = nLP.getAnswer(comanddd);
                        // throw;
                    }

                    //});

                    //  Console.WriteLine(comanddd);

                    //   if (comanddd == null) {
                    if (splitString.Length > 1)
                    {
                        comanddd = "";
                        comanddd = nLP.getAnswer(splitString[0].Trim());
                        // comanddd = CMDCALL(splitString[0].Trim());
                        //  comanddd = cmd.tasks;
                        comanddd = comanddd.Trim() + " " + splitString[1].Trim();
                    }
                    else
                    {
                        //  comanddd = cmd.tasks;
                        comanddd = nLP.getAnswer(comanddd);
                    }
                    //  }
                    // Console.ReadLine();
                    if (sw.BaseStream.CanWrite)
                    {
                        sw.WriteLine(comanddd);
                        //  sw.WriteLine("mkdir Debdas");
                        //p.WaitForExit();
                    }
                }
            }
        }