Exemple #1
0
		private void start_btn_Click(object sender, EventArgs e)
		{
			if (this.sync_local_dir == string.Empty)
			{
				this.Print("请选择本地目录");
				return;
			}
			string text = this.ipBox.Text;
			if (string.IsNullOrEmpty(text))
			{
				this.Print("请填写FTP地址");
				return;
			}
			string text2 = this.portBox.Text;
			if (string.IsNullOrEmpty(text2))
			{
				text2 = "21";
			}
			string text3 = this.user_name_box.Text;
			string text4 = this.password_box.Text;
			string text5 = this.remote_dir.Text;
			if (string.IsNullOrEmpty(text5))
			{
				text5 = "/";
			}
			this.client = new SyncClient(text, text2, text3, text4, this.sync_local_dir, null, text5, this.deleteRemoteCheckBox.Checked);
			SyncClient expr_B6 = this.client;
			expr_B6.PrintEventHandler = (SyncClient.PrintLog)Delegate.Remove(expr_B6.PrintEventHandler, new SyncClient.PrintLog(this.Print));
			SyncClient expr_DD = this.client;
			expr_DD.PrintEventHandler = (SyncClient.PrintLog)Delegate.Combine(expr_DD.PrintEventHandler, new SyncClient.PrintLog(this.Print));
			int sync_interval_seconds = 10;
			if (int.TryParse(this.intervalBox.Text, out sync_interval_seconds))
			{
				if (!this.client.Start(sync_interval_seconds))
				{
					this.Print("启动失败,请检查FTP地址是否正确!");
				}
			}
			else
			{
				this.Print("请填写正确的同步间隔!");
			}
			this.deleteRemoteCheckBox.Enabled = false;
			this.ipBox.Enabled = false;
			this.portBox.Enabled = false;
			this.user_name_box.Enabled = false;
			this.password_box.Enabled = false;
			this.intervalBox.Enabled = false;
			this.local_choose.Enabled = false;
			this.remote_dir.Enabled = false;
			this.start_btn.Enabled = false;
			this.stop_btn.Enabled = true;
		}
Exemple #2
0
        private void start_btn_Click(object sender, EventArgs e)
        {
            if (sync_local_dir == string.Empty)
            {
                MessageBox.Show("请选择本地目录");
                return;
            }

            string address = this.ipBox.Text;
            if (string.IsNullOrEmpty(address))
            {
                MessageBox.Show("请填写FTP地址");
                return;
            }

            string port = this.portBox.Text;
            if (string.IsNullOrEmpty(port))
            {
                port = "21";
            }

            string user_name = this.user_name_box.Text;
            string passsword = this.password_box.Text;

            string remote_dir = this.remote_dir.Text;
            if (string.IsNullOrEmpty(remote_dir))
            {
                remote_dir = "/";
            }

            client = new SyncClient(address, port, user_name,
                                                passsword,
                                                this.sync_local_dir, null,
                                                remote_dir, this.deleteRemoteCheckBox.Checked);

            client.PrintEventHandler -= Print;
            client.PrintEventHandler += Print;

            int interval = 10;
            if (int.TryParse(this.intervalBox.Text, out interval))
            {
                if (!client.Start(interval))
                {
                    MessageBox.Show("启动失败,请检查FTP地址是否正确!");
                }
            }
            else
            {
                MessageBox.Show("请填写正确的同步间隔!");
            }

            this.deleteRemoteCheckBox.Enabled = false;
            this.ipBox.Enabled = false;
            this.portBox.Enabled = false;
            this.user_name_box.Enabled = false;
            this.password_box.Enabled = false;
            this.intervalBox.Enabled = false;
            this.local_choose.Enabled = false;
            this.remote_dir.Enabled = false;

            this.start_btn.Enabled = false;
            this.stop_btn.Enabled = true;

            //保存配置 TODO

        }