Beispiel #1
0
        private void Init_02(string csvEntier)
        {
            string[] cmdCsv = csvEntier
                              .Split(m_sep1, StringSplitOptions.RemoveEmptyEntries)
                              .Where(x => !string.IsNullOrEmpty(x)).ToArray();

            this.m_lesMenuLignes = new List <MenuLigne>();

            if (m_startMenu != 0)
            {
                m_lesMenuLignes.Add(new MenuLigne("Back", "Back"));
            }

            foreach (string cmd in cmdCsv)
            {
                if (string.IsNullOrWhiteSpace(cmd))
                {
                    continue;
                }

                //try
                //{

                string[] uneLigne = cmd.Split(SEP2);

                MenuLigne ml;


                if (m_startMenu == 0)
                {
                    // menu principal de selection de mainHost vers menu bash
                    ml = new MenuLigne(uneLigne[0], uneLigne[0]);
                }
                else if (m_startMenu == 1)
                {
                    // menu bash
                    ml = new MenuLigne(uneLigne[0], uneLigne[1]);
                }
                else
                {
                    // menu bash
                    ml = new MenuLigne(uneLigne[0], uneLigne[1]);
                }

                m_lesMenuLignes.Add(ml);

                //}
                //catch
                //{
                //    // ignored
                //}
            }

            Console.WriteLine(" nombre de menuLigne : ");
            Console.WriteLine(MenuLignes.Count);
        }
Beispiel #2
0
        public void ExecCmd(string cmdUser)
        {
            if (this.m_startMenu == 0)
            {
                this.m_startMenu = 1;
            }

            if ("Back".Equals(cmdUser))
            {
                this.m_startMenu = 0;
            }

            if (this.m_startMenu == 0)
            {
                Init_02(GetStringFromUrl(m_url_Menu_Host));
                this.m_startMenu = 1;
            }
            else if (this.m_startMenu == 1)
            {
                this.m_targetHost = cmdUser;

                MenuLigne menuLigne = MenuLignes.Find(x => x.TitreCmd == cmdUser);

                if (menuLigne != null)
                {
                    Uri    uri     = new Uri(m_mainHost + URL_GET_BASH + m_targetHost);
                    string reponce = GetStringFromUrl(uri);

                    if (!reponce.StartsWith("<br />\n<font size='1'>"))
                    {
                        // pas d'erreur
                        Init_02(reponce);
                    }
                    else
                    {
                        // erreur
                        Init_02("");
                    }
                }

                this.m_startMenu = 2;
            }
            else
            {
                MenuLigne menuLigne = MenuLignes.Find(x => x.TitreCmd == cmdUser);

                if (menuLigne != null)
                {
                    Uri uri = new Uri(m_mainHost + URL_EXEC_BASH + m_targetHost + "&option=" + cmdUser);
                    GetStringFromUrl(uri);
                }
            }

            Console.WriteLine(" fin ExecCmd " + cmdUser);
        }