示例#1
0
        public static Transporter Parse(XElement xml)
        {
            if (xml == null || xml.Name != strTransporter) { return null; }
            var result = new Transporter();
            result.Goods = xml.Element(strGoods).Value;
            var ipNode = xml.Element(strIp);
            if (ipNode != null) { result.Ip = ipNode.Value; }
            var usernameNode = xml.Element(strUsername);
            if (usernameNode != null) { result.Username = usernameNode.Value; }
            var passwordNode = xml.Element(strPassword);
            if (passwordNode != null) { result.Password = passwordNode.Value; }//Utility.Decrypt(passwordNode.Value); }

            return result;
        }
 private void btnBrowseDest_Click(object sender, EventArgs e)
 {
     if (this.selectFolder.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         var dest = new Transporter()
         {
             Goods = this.selectFolder.SelectedPath,
             Ip = string.Empty,
             Password = string.Empty,
             Username = string.Empty
         };
         this.txtDest.Tag = dest;
         this.txtDest.Text = dest.Goods;//.ToString();
     }
 }
 private void btnBrowseSource_Click(object sender, EventArgs e)
 {
     if (this.selectSourceFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         var source = new Transporter()
         {
             Goods = this.selectSourceFile.FileName,
             Ip = string.Empty,
             Password = string.Empty,
             Username = string.Empty
         };
         this.txtSource.Tag = source;
         this.txtSource.Text = source.Goods;//.ToString();
     }
 }
 private void btnOK_Click(object sender, EventArgs e)
 {
     var node = treeView1.SelectedNode;
     if (node == null)
     { MessageBox.Show("请选择一个结点!"); return; }
     var content = node.Tag as NetworkNode;
     if (content == null)
     { MessageBox.Show("没有绑定 NetworkNode 对象!"); return; }
     IPAddress ip = null;
     if (!IPAddress.TryParse(txtIP.Text, out ip))
     { MessageBox.Show("IP地址非法,请重新输入!"); return; }
     var result = new DeployLib.Transporter();
     var dir = new DirectoryInfo(content.Fullname);
     result.Goods = dir.FullName.Substring(dir.Root.FullName.Length - 2);// content.ShareName;// dir.FullName.Substring(dir.Root.FullName.Length);
     result.Ip = txtIP.Text; lastIp = txtIP.Text;
     result.Username = txtUsername.Text; lastUsername = txtUsername.Text;
     result.Password = txtPassword.Text; lastPassword = txtPassword.Text;
     this.SelectedPath = result;
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
 }