private void btnNew_Click(object sender, EventArgs e) { Farm farm = new Farm(); farm.Name = txtName.Text.Trim(); farm.Provider = cobProvider.SelectedValue.ToString(); farm.Save(); RefreshGrid(); RefreshSelectedFarm(farm); }
private void btnOK_Click(object sender, EventArgs e) { // load parameters var localPath = txtLocalPath.Text; var farm = cobCloudProvider.SelectedValue.ToString(); var cloudPath = txtCloudPath.Text; var is7Z = chb7Z.Checked; var _7zPswd = txt7ZPswd.Text; //validation if (!Directory.Exists(localPath)) { MessageBox.Show("Local path is invalid."); } //generate json data if (farm.Equals("baidu", StringComparison.OrdinalIgnoreCase)) { Farm f = new Farm(); f.Provider = farm; f.Name = "Baidu@" + DateTime.Now.ToString("yyyy-MM-dd hh:mm"); f.Save(); farm = f.Id.ToString(); } object farmProvider = new { type = "farm", farm = farm, path = cloudPath }; if (is7Z) { farmProvider = new { type = "7ZProvider", password = _7zPswd, provider = farmProvider }; } string pipelineConfig = JsonHelper.Serialize(new { provider1 = new { type = "HDProvider", path = localPath }, provider2 = farmProvider }); if (pipeline == null) { pipeline = new Pipeline(); pipeline.Disabled = false; } pipeline.Providers = pipelineConfig; pipeline.Name = localPath; pipeline.Save(); Close(); }
private void RefreshSelectedFarm(Farm farm = null) { if (farm != null) { foreach (DataGridViewRow row in grdFarms.Rows) { var item = (Farm)row.DataBoundItem; row.Selected = item.Id == farm.Id; } } farm = GetSelectedFarm(); if (farm == null) { txtName.Text = string.Empty; btnDelete.Enabled = false; btnUpdate.Enabled = false; btnAuth.Enabled = false; } else { txtName.Text = farm.Name; btnDelete.Enabled = true; btnUpdate.Enabled = true; btnAuth.Enabled = true; } }