/// <summary> /// 初始化基本数据 /// </summary> private void InitData() { this.replaceSetting = userSettingBLL.GetFileReplaceSetting() ?? new DataLayer.Model.FileReplaceSetting(); fileBLL.Clear(); this.InitCurrentRuleList(); //初始化用户默认配置 this.txtOutPutPath.Text = this.replaceSetting.OutPutPath; this.txtFileFirstName.Text = this.replaceSetting.PrefixName; this.txtFileLastName.Text = this.replaceSetting.SuffixName; if (this.replaceSetting.IsKeepDataFormat.HasValue) { this.ckExcelOptionIsKeepDataFormat.Checked = this.replaceSetting.IsKeepDataFormat.Value; } if (this.replaceSetting.IsKeepFormula.HasValue) { this.ckExcelOptionIsKeepFormula.Checked = this.replaceSetting.IsKeepFormula.Value; } this.toolStripStatusLabel2.Text = new Model.DoState().ToString(); //文件选项 this.comboxWordFileFormat.Properties.Items.Add("默认"); XCLNetTools.Enum.EnumHelper.GetList(typeof(CommonHelper.CommonEnum.WordFileToFormatEnum)).ForEach(k => { this.comboxWordFileFormat.Properties.Items.Add(k.Text); }); this.comboxWordFileFormat.SelectedIndex = 0; this.comboxExcelFileFormat.Properties.Items.Add("默认"); XCLNetTools.Enum.EnumHelper.GetList(typeof(CommonHelper.CommonEnum.ExcelFileToFormatEnum)).ForEach(k => { this.comboxExcelFileFormat.Properties.Items.Add(k.Text); }); this.comboxExcelFileFormat.SelectedIndex = 0; }
public RuleConfigSelectBox(Index mainForm = null) { _mainForm = mainForm; InitializeComponent(); this.InitRuleConfigGrid(); this.ckIsFileName.Checked = true; this.tabPageAdd.PageVisible = false; this.fileReplaceSetting = userSettingBLL.GetFileReplaceSetting(); }
/// <summary> /// 初始化基本数据 /// </summary> private void InitData() { this.replaceSetting = userSettingBLL.GetFileReplaceSetting() ?? new DataLayer.Model.FileReplaceSetting(); fileBLL.Clear(); this.InitCurrentRuleList(); //初始化用户默认配置 this.txtOutPutPath.Text = this.replaceSetting.OutPutPath; this.txtFileFirstName.Text = this.replaceSetting.PrefixName; this.txtFileLastName.Text = this.replaceSetting.SuffixName; if (this.replaceSetting.IsKeepDataFormat.HasValue) { this.ckExcelOptionIsKeepDataFormat.Checked = this.replaceSetting.IsKeepDataFormat.Value; } if (this.replaceSetting.IsKeepFormula.HasValue) { this.ckExcelOptionIsKeepFormula.Checked = this.replaceSetting.IsKeepFormula.Value; } this.toolStripStatusLabel2.Text = new Model.DoState().ToString(); }
private void btnSelectOK_Click(object sender, System.EventArgs e) { var model = userSettingBLL.GetFirstModel(); if (null == model) { model = new DataLayer.Model.UserSetting(); } DataLayer.Model.FileReplaceSetting setting = null; if (!string.IsNullOrEmpty(model.FileReplaceSetting)) { setting = XCLNetTools.Serialize.JSON.DeSerialize<DataLayer.Model.FileReplaceSetting>(model.FileReplaceSetting); } if (null == setting) { setting = new DataLayer.Model.FileReplaceSetting(); } //获取已选行 setting.RuleConfigIds = new List<int>(); var selectedRows = this.dataGridRuleConfig.SelectedRows; if (null != selectedRows && selectedRows.Count > 0) { for (int i = 0; i < selectedRows.Count; i++) { var currentData = selectedRows[i].DataBoundItem as DataLayer.Model.FileReplace_RuleConfig; if (null != currentData) { setting.RuleConfigIds.Add(currentData.RuleConfigID); } } } model.FileReplaceSetting = XCLNetTools.Serialize.JSON.Serialize(setting); userSettingBLL.Add(model); //刷新父窗体数据 if (null != _mainForm) { _mainForm.InitCurrentRuleList(); } this.Close(); }
/// <summary> /// 选好了 /// </summary> private void btnSelectOK_Click(object sender, System.EventArgs e) { var model = userSettingBLL.GetFirstModel(); if (null == model) { model = new DataLayer.Model.UserSetting(); } DataLayer.Model.FileReplaceSetting setting = null; if (!string.IsNullOrEmpty(model.FileReplaceSetting)) { setting = XCLNetTools.Serialize.JSON.DeSerialize <DataLayer.Model.FileReplaceSetting>(model.FileReplaceSetting); } if (null == setting) { setting = new DataLayer.Model.FileReplaceSetting(); } //获取已选行 setting.RuleConfigIds = new List <int>(); var selectedRows = this.dataGridRuleConfig.GetSelectedRows(); if (null != selectedRows && selectedRows.Length > 0) { for (int i = 0; i < selectedRows.Length; i++) { var currentData = this.dataGridRuleConfig.GetDataRow(selectedRows[i]); if (null != currentData) { setting.RuleConfigIds.Add(XCLNetTools.Common.DataTypeConvert.ToInt(currentData["RuleConfigID"])); } } } model.FileReplaceSetting = XCLNetTools.Serialize.JSON.Serialize(setting); userSettingBLL.Add(model); this.Close(); }
/// <summary> /// 执行 /// </summary> private void btnSave_Click(object sender, EventArgs e) { var lst = this.fileBLL.GetAllList(); #region 合法性验证 if (null == lst || lst.Count == 0) { MessageBox.Show("请先选择待处理的文件!"); return; } if (!string.IsNullOrEmpty(this.txtOutPutPath.Text)) { if (XCLNetTools.FileHandler.FileDirectory.DirectoryExists(this.txtOutPutPath.Text)) { //检查是否有文件 if (!XCLNetTools.FileHandler.FileDirectory.IsEmpty(this.txtOutPutPath.Text)) { if (MessageBox.Show("您指定的输出目录不是空目录,是否继续?", "系统提示", MessageBoxButtons.YesNo) == DialogResult.No) { return; } } } else { if (!XCLNetTools.FileHandler.FileDirectory.MakeDirectory(this.txtOutPutPath.Text)) { MessageBox.Show("输出目录不存在,请选择有效的输出目录!"); return; } } } if (!lst.Exists(k => !k.IsDone)) { MessageBox.Show("文件都已处理,请重新打开要处理的文件!"); return; } #endregion 合法性验证 #region 将选项保存至配置文件中 var config = this.userSettingBLL.GetFirstModel() ?? new DataLayer.Model.UserSetting(); this.ReplaceSetting = this.ReplaceSetting ?? new DataLayer.Model.FileReplaceSetting(); this.ReplaceSetting.OutPutPath = this.txtOutPutPath.Text; this.ReplaceSetting.PrefixName = this.txtFileFirstName.Text; this.ReplaceSetting.SuffixName = this.txtFileLastName.Text; config.FileReplaceSetting = XCLNetTools.Serialize.JSON.Serialize(this.ReplaceSetting); this.userSettingBLL.Add(config); #endregion 将选项保存至配置文件中 #region 任务处理 this.btnSave.Enabled = false; Model.DoState doState = new Model.DoState(); doState.SumCount = lst.Count; foreach (var m in lst) { Delegate_DoIt dg = new Delegate_DoIt(this.DoIt); IAsyncResult result = dg.BeginInvoke(m, new AsyncCallback(this.GetResultCallBack), doState); } #endregion 任务处理 }