Exemplo n.º 1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            var pipeline = new Pipeline();
            pipeline.Name = cobEndpoints.Text;
            pipeline.Path = txtLocalPath.Text;
            pipeline.Save();

            RefreshGrid();
            RefreshSelectedPipeline(pipeline);
        }
Exemplo n.º 2
0
 private void RefreshSelectedPipeline(Pipeline pipeline = null)
 {
     if (pipeline != null)
     {
         foreach (DataGridViewRow row in grdPipelines.Rows)
         {
             var item = (Pipeline)row.DataBoundItem;
             row.Selected = item.Id == pipeline.Id;
         }
     }
     pipeline = GetSelectedPipeline();
     if (pipeline == null)
     {
         btnDelete.Enabled = false;
         btnEdit.Enabled = false;
         btnEnable.Enabled = false;
     }
     else
     {
         btnDelete.Enabled = true;
         btnEdit.Enabled = true;
         btnEnable.Enabled = true;
         btnEnable.Text = pipeline.Disabled ? "Enable" : "Disable";
     }
 }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        static List<Data.Pipeline> fetchPipelinesFromMem()
        {
            var pipelines = new List<Data.Pipeline>();
            var apipeline = new Data.Pipeline();
            apipeline.Name = "baidu_endpoint";
            //apipeline.Path = "D:\\backup\\neso\\cleanup\\photo";
            apipeline.Path = "D:\\CouldSync\\test\\source2";
            apipeline.Providers = "{}";
            pipelines.Add(apipeline);

            apipeline = new Data.Pipeline();
            apipeline.Name = "local_endpoint";
            apipeline.Path = "D:\\CouldSync\\test\\source2";
            apipeline.Providers = "{}";
            pipelines.Add(apipeline);
            return pipelines;
        }
Exemplo n.º 5
0
 public void SetPipeline(Pipeline pipeline)
 {
     this.pipeline = pipeline;
     var config = DynamicJsonParser.Parse(pipeline.Providers);
     RefreshPipelines(config);
 }