Esempio n. 1
0
        protected void UIThread()
        {
            var client = new RdpClient.RdpClient();

            manager = new SessionManager();
            manager.RdpClient = client;
            manager.CurrentLogger = EventLog.WriteEntry;
            manager.LoadSettings();
            manager.Start();

            Application.Run();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var uiThread = new Thread(UIThread);
            uiThread.SetApartmentState(ApartmentState.STA);
            uiThread.Start();

            while (true)
            {
                var line = Console.In.ReadLine();

                if (line == "quit")
                {
                    break;
                }
                if (line.StartsWith("connect "))
                {
                    var connArg = line.Split(new char[] { ' ' });
                    var host = connArg[1];
                    var user = connArg[2];
                    var pass = connArg[3];
                    int port = 0;
                    if (connArg.Length > 4)
                    {
                        port = int.Parse(connArg[4]);
                    }
                    Console.WriteLine("connect to {0}:{1}", host, port);
                    client.Connect(host, port, user, pass);
                    continue;
                }
                if (line.StartsWith("close"))
                {
                    client.Disconnect();
                    continue;
                }
                if (line.StartsWith("exec "))
                {
                    var connArg = line.Split(new char[] { ' ' });
                    var cmdline = connArg[1];
                    var user = connArg[2];
                    var pass = connArg[3];

                    var mng = new SessionManager();
                    mng.RdpClient = client;
                    mng.CurrentLogger = Console.WriteLine;
                    mng.CheckAndExec(null, cmdline, user, pass);
                    continue;
                }
                if (line.StartsWith("config"))
                {
                    var mng = new SessionManager();
                    mng.SaveSettings();
                }
                if (line.StartsWith("load"))
                {
                    var mng = new SessionManager();
                    mng.LoadSettings();
                }
            }

            Application.Exit();
            uiThread.Join();
        }