Ejemplo n.º 1
0
 public ConfigForm(RecipeConfigEntity entity, bool?isEdit = true)
 {
     InitializeComponent();
     Entity    = entity;
     _isEdit   = isEdit;
     this.Text = isEdit == null ? "执行合并" : (isEdit.Value ? "修改配置" : "新增配置");
 }
Ejemplo n.º 2
0
 public ConfigForm()
 {
     Entity = new RecipeConfigEntity();
     InitializeComponent();
     this.Text = "新增配置";
     _isEdit   = false;
 }
Ejemplo n.º 3
0
        public string Save(RecipeConfigEntity entity)
        {
            var  list   = Get();
            bool repeat = false;

            if (entity.Id == Guid.Empty)
            {
                repeat = list.Any(p => p.Classify == entity.Classify && p.Name == entity.Name);
            }
            else
            {
                repeat = list.Any(p => p.Classify == entity.Classify && p.Name == entity.Name && p.Id != entity.Id);
            }
            if (repeat)
            {
                return("同一分类下,已经存在相关名称记录。");
            }
            if (entity.Id == Guid.Empty)
            {
                entity.Id = Guid.NewGuid();
            }
            else
            {
                var p = list.First(w => w.Id == entity.Id);
                list.Remove(p);
            }
            list.Add(entity);
            SaveData(list);
            return("");
        }
Ejemplo n.º 4
0
        public string Merge(RecipeConfigEntity entity)
        {
            FileInfo      fi = new FileInfo(entity.OutputConfigFile);
            DirectoryInfo di = new DirectoryInfo(entity.InputConfigFolder);

            if (!di.Exists)
            {
                return("输入目录不存在。");
            }
            if (!di.GetFiles("*.config").Any())
            {
                return("输入目录没有配置文件。");
            }
            var    name     = string.Format("{0}.recipe", Guid.NewGuid().ToString().Replace("-", ""));
            string fileName = string.Format("{0}{1}", ApplictionDataTemp, name);

            try
            {
                CreateRecipe(fileName, fi, di);
                ConfigMergeTools.Merge(name);
            }
            finally
            {
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
            }
            return("");
        }
Ejemplo n.º 5
0
        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            var row = dataGridView1.Rows[e.RowIndex];

            row.Selected = true;
            entity       = (RecipeConfigEntity)row.DataBoundItem;
            SetButtonEnable(true);
        }