Example #1
0
 public static List <RemoteMachine> Load(IniFile iniFile, string type, string kongge)
 {
     string[] infos = iniFile.ReadAllSectionNames();
     if (infos != null)
     {
         List <RemoteMachine> macs = new List <RemoteMachine>();
         foreach (string info in infos)
         {
             string        section = info.Substring(7, info.Length - 8);
             RemoteMachine mac     = RemoteMachine.Load(section, iniFile);
             //如果类型=选择类型,显示列表之中添加
             if (type == "默认")
             {
                 macs.Add(mac);
             }
             else
             if (mac.Type == type)
             {
                 macs.Add(mac);
             }
         }
         return(macs);
     }
     return(null);
 }
Example #2
0
        private void RemoteNew_Load(object sender, EventArgs e)
        {
            if (this.mac == null)
            {
                btnDel.Visible = false;
                this.mac       = new RemoteMachine()
                {
                    RedirectDrives = true
                };
            }
            else
            {
                btnDel.Visible   = true;
                tTagName.Enabled = false;

                tTagName.Text               = mac.DesktopName;
                tServerName.Text            = mac.Server;
                tDomain.Text                = mac.Domain;
                tUserName.Text              = mac.UserName;
                tPasswprd.Text              = mac.Password;
                checkBoxDrives.Checked      = mac.RedirectDrives;
                checkBoxRemote.Checked      = mac.RemoteAble;
                checkBoxShowProcess.Checked = mac.ShowProcess;
                checkBoxShowService.Checked = mac.ShowService;
            }
        }
Example #3
0
        public static void Save(RemoteMachine machine, IniFile iniFile)
        {
            string section = string.Format("Remote({0})", machine.DesktopName);

            iniFile.WriteString(section, "WWW", machine.WWW);
            iniFile.WriteString(section, "DesktopName", machine.DesktopName);
            iniFile.WriteString(section, "Server", machine.Server);
            iniFile.WriteString(section, "UserName", machine.UserName);
            iniFile.WriteString(section, "Password", machine.Password);
        }
Example #4
0
 private void SetRdpClientProperties(RemoteMachine machine)
 {
     rdpc.Server   = machine.Server;
     rdpc.UserName = machine.UserName;
     rdpc.Domain   = machine.Domain;
     if (!string.IsNullOrEmpty(machine.Password))
     {
         rdpc.AdvancedSettings5.ClearTextPassword = machine.Password;
     }
     rdpc.AdvancedSettings5.RedirectDrives   = machine.RedirectDrives;
     rdpc.AdvancedSettings5.RedirectPrinters = machine.RedirectPrinters;
     rdpc.AdvancedSettings5.RedirectPorts    = machine.RedirectPorts;
     rdpc.ColorDepth = (int)machine.ColorDepth;
     rdpc.Dock       = DockStyle.Fill;
 }
Example #5
0
        public static RemoteMachine Load(string desktopName, IniFile iniFile)
        {
            string        section = string.Format("Remote({0})", desktopName);
            RemoteMachine mac     = new RemoteMachine();

            mac.DesktopName = desktopName;
            mac.WWW         = iniFile.ReadString(section, "WWW", "");
            mac.Server      = iniFile.ReadString(section, "Server", "");
            mac.UserName    = iniFile.ReadString(section, "UserName", "");
            mac.Password    = iniFile.ReadString(section, "Password", "");
            //委托使用0.1秒无响应自动跳过
            //mac= CallWithTimeout(ServerState, mac, 100);
            //ServerState(mac);
            return(mac);
        }
Example #6
0
        public WMIForm(RemoteMachine machine)
        {
            InitializeComponent();
            Text         = string.Format("【WMI】{0}", machine.DesktopName);
            this.Machine = machine;
            ConnectionOptions options = null;

            if (this.Machine.Server != "." && this.Machine.UserName != null && this.Machine.UserName.Length > 0)
            {
                options          = new ConnectionOptions();
                options.Username = this.Machine.UserName;
                options.Password = this.Machine.Password;
                //options.Authority = "ntlmdomain:DOMAIN";
            }
            this.scope = new ManagementScope("\\\\" + this.Machine.Server + "\\root\\cimv2", options);
        }
Example #7
0
 public static List <RemoteMachine> Load(IniFile iniFile)
 {
     string[] infos = iniFile.ReadAllSectionNames();
     if (infos != null)
     {
         List <RemoteMachine> macs = new List <RemoteMachine>();
         foreach (string info in infos)
         {
             string        section = info.Substring(7, info.Length - 8);
             RemoteMachine mac     = RemoteMachine.Load(section, iniFile);
             macs.Add(mac);
         }
         return(macs);
     }
     return(null);
 }
Example #8
0
        private void LoadIni(string path)
        {
            inipath = path;
            ini     = new IniFile(path);
            macs    = RemoteMachine.Load(ini);
            iRemoteDesktop.DropDownItems.Clear();
            iRemoteProcess.DropDownItems.Clear();
            iRemoteService.DropDownItems.Clear();
            iRemoteWMI.DropDownItems.Clear();
            iEdit.DropDownItems.Clear();

            if (macs != null)
            {
                foreach (RemoteMachine mac in macs)
                {
                    ToolStripMenuItem edit = new ToolStripMenuItem(mac.DesktopName);
                    edit.Tag    = mac;
                    edit.Click += edit_Click;
                    iEdit.DropDownItems.Add(edit);
                    ToolStripMenuItem wmi = new ToolStripMenuItem(mac.DesktopName);
                    wmi.Tag = mac;
                    iRemoteWMI.DropDownItems.Add(wmi);
                    wmi.Click += wmi_Click;
                    if (mac.RemoteAble)
                    {
                        ToolStripMenuItem desktop = new ToolStripMenuItem(mac.DesktopName);
                        desktop.Tag = mac;
                        iRemoteDesktop.DropDownItems.Add(desktop);
                        desktop.Click += desktop_Click;
                    }
                    if (mac.ShowProcess)
                    {
                        ToolStripMenuItem process = new ToolStripMenuItem(mac.DesktopName);
                        process.Tag = mac;
                        iRemoteProcess.DropDownItems.Add(process);
                        process.Click += process_Click;
                    }
                    if (mac.ShowService)
                    {
                        ToolStripMenuItem service = new ToolStripMenuItem(mac.DesktopName);
                        service.Tag = mac;
                        iRemoteService.DropDownItems.Add(service);
                        service.Click += service_Click;
                    }
                }
            }
        }
Example #9
0
        public static void Save(RemoteMachine machine, IniFile iniFile)
        {
            string section = string.Format("Remote({0})", machine.DesktopName);

            iniFile.WriteString(section, "DesktopName", machine.DesktopName);
            iniFile.WriteString(section, "Server", machine.Server);
            iniFile.WriteString(section, "UserName", machine.UserName);
            iniFile.WriteString(section, "Domain", machine.Domain);
            iniFile.WriteString(section, "Password", machine.Password);
            iniFile.WriteInt(section, "RemoteAble", machine.RemoteAble ? 1 : 0);
            iniFile.WriteInt(section, "ShowProcess", machine.ShowProcess ? 1 : 0);
            iniFile.WriteInt(section, "ShowService", machine.ShowService ? 1 : 0);
            iniFile.WriteInt(section, "RedirectDrives", machine.RedirectDrives ? 1 : 0);
            iniFile.WriteInt(section, "RedirectPrinters", machine.RedirectPrinters ? 1 : 0);
            iniFile.WriteInt(section, "RedirectPorts", machine.RedirectPorts ? 1 : 0);
            iniFile.WriteInt(section, "ColorDepth", (int)machine.ColorDepth);
        }
Example #10
0
        private void wmi_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;

            if (item != null)
            {
                try
                {
                    RemoteMachine mac = item.Tag as RemoteMachine;
                    WMIForm       wmi = new WMIForm(mac);
                    wmi.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                }
            }
        }
Example #11
0
        public static RemoteMachine Load(string desktopName, IniFile iniFile)
        {
            string        section = string.Format("Remote({0})", desktopName);
            RemoteMachine mac     = new RemoteMachine();

            mac.DesktopName      = desktopName;
            mac.Server           = iniFile.ReadString(section, "Server", "");
            mac.UserName         = iniFile.ReadString(section, "UserName", "");
            mac.Domain           = iniFile.ReadString(section, "Domain", "");
            mac.Password         = iniFile.ReadString(section, "Password", "");
            mac.RemoteAble       = iniFile.ReadInt(section, "RemoteAble", 0) == 1;
            mac.ShowProcess      = iniFile.ReadInt(section, "ShowProcess", 0) == 1;
            mac.ShowService      = iniFile.ReadInt(section, "ShowService", 0) == 1;
            mac.RedirectDrives   = iniFile.ReadInt(section, "RedirectDrives", 0) == 1;
            mac.RedirectPrinters = iniFile.ReadInt(section, "RedirectPrinters", 0) == 1;
            mac.RedirectPorts    = iniFile.ReadInt(section, "RedirectPorts", 0) == 1;
            mac.ColorDepth       = (Colors)iniFile.ReadInt(section, "ColorDepth", 0);
            return(mac);
        }
Example #12
0
        private void desktop_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;

            if (item != null)
            {
                try
                {
                    RemoteMachine mac = item.Tag as RemoteMachine;
                    using (DesktopForm df = new DesktopForm(mac))
                    {
                        df.ShowDialog();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                }
            }
        }
Example #13
0
        public ProcessForm(RemoteMachine machine)
        {
            InitializeComponent();
            Text                 = string.Format("【进程】{0}", machine.DesktopName);
            this.Machine         = machine;
            this.path            = "\\\\" + this.Machine.Server + "\\root\\cimv2:Win32_Process";
            this.managementClass = new ManagementClass(this.path);
            ConnectionOptions options = null;

            if (this.Machine.Server != "." && this.Machine.UserName != null && this.Machine.UserName.Length > 0)
            {
                options          = new ConnectionOptions();
                options.Username = this.Machine.UserName;
                options.Password = this.Machine.Password;
                //options.EnablePrivileges = true;
                //options.Impersonation = ImpersonationLevel.Impersonate;
                //options.Authority = "ntlmdomain:domain";
            }
            this.scope = new ManagementScope("\\\\" + this.Machine.Server + "\\root\\cimv2", options);
            this.managementClass.Scope = this.scope;
        }
Example #14
0
        private void edit_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem item = sender as ToolStripMenuItem;

            if (item != null)
            {
                try
                {
                    RemoteMachine mac = item.Tag as RemoteMachine;
                    using (RemoteNew _new = new RemoteNew(this.ini, mac))
                    {
                        if (_new.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                        {
                            LoadIni(inipath);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "警告", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                }
            }
        }
Example #15
0
 public RemoteNew(IniFile ini, RemoteMachine mac)
 {
     InitializeComponent();
     this.ini = ini;
     this.mac = mac;
 }
Example #16
0
 public DesktopForm(RemoteMachine machine)
 {
     InitializeComponent();
     Text         = string.Format("【远程】{0}", machine.DesktopName);
     this.Machine = machine;
 }