private void OK_Click(object sender, RoutedEventArgs e) { bool? isCopy = IsCopyRadio.IsChecked; string tem; if (isCopy.Value) { tem = "复制"; } else { tem = "更名或者移动"; } int successCount = 0; int falseCount = 0; var fileReplaceNameModels = filePagerPage.GetAllList <FileReplaceNameModel>(); if (fileReplaceNameModels.Count > 0) { if (MessageBoxCustom.MessageBoxShow("你将" + tem + fileReplaceNameModels.Count + " 个文件")) { foreach (FileReplaceNameModel model in fileReplaceNameModels) { WaitFormCustom.ShowCustom(); string path = model.FilePath; string saveName = model.NewFileName; string saveDir = Path.GetDirectoryName(saveName); if (saveDir == "") { model.Success = false; continue; } if (!Utils.CheckDirExists(saveDir)) { Directory.CreateDirectory(saveDir); } if (Utils.CheckFileExists(path)) { if (isCopy.Value) { File.Copy(path, saveName, true); } else { File.Move(path, saveName); } successCount++; model.Success = true; } else { model.Success = false; falseCount++; } } WaitFormCustom.CloseWaitForm("成功:" + successCount + " 个文件,失败:" + falseCount + " 个文件"); } } }
private void OK_Click(object sender, RoutedEventArgs e) { SaveRedis_Click(null, null); //执行替换 model.Files = filePagerPage.GetAllList(); if (Utils.CheckListExists(model.Files)) { WaitFormCustom.ShowCustom("运行中。。。"); ExcelWrite.ReplaceText(model, model.Files); WaitFormCustom.CloseWaitForm("完成"); } else { MessageBox.Show("没有选择任何的文件来替换"); } }
private void OK_Click(object sender, RoutedEventArgs e) { //Spire.Doc.Document document = new Spire.Doc.Document(); //document.LoadFromFile("d:/123.doc"); //document.SaveToFile("d:/123.doc"); SaveRedis_Click(null, null); //执行替换 var paths = addFilePage.GetAllList(); if (Utils.CheckListExists(paths)) { WaitFormCustom.ShowCustom("运行中。。。"); SpireDocUtils.ReplaceText(model.ReplaceViewModels, paths); WaitFormCustom.CloseWaitForm("完成"); } else { MessageBox.Show("没有选择任何的文件来替换"); } }
private void TableChange_Click(object sender, RoutedEventArgs e) { IList <FileNameCustom> files = addFileViewModel.Files; if (files.Count > 0) { string shpmjPath = FileUtils.SelectSingleExcelFile("选择shp面积表格"); if (shpmjPath == null || shpmjPath == "") { return; } string saveDir = FileManager.FileUtils.SeleFileDir("选择保存的文件夹"); if (saveDir == null || saveDir == "") { return; } WaitFormCustom.ShowCustom(); Dictionary <string, string> dkbmMJDic = ExcelManager.ExcelRead.ReadExcelToDic(shpmjPath, 0); foreach (FileNameCustom fileNameCustom in files) { bool flag = true; IList <JTCY> jTCies = JTCYCustom.ReadJTCYExcel(fileNameCustom.FilePath); IList <JTCY> hzs = JTCYCustom.ExtractHZs(jTCies); if (hzs == null) { return; } IList <DK> dks = DKCustom.ReadDKExcel(fileNameCustom.FilePath); string area; string dkbm; JTCYCustom.SetJTCY_DK(hzs, dks); foreach (JTCY hz in hzs) { hz.CBFBM = System.IO.Path.GetFileNameWithoutExtension(fileNameCustom.FilePath) + hz.CBFBM; } string zh = "512081" + System.IO.Path.GetFileNameWithoutExtension(fileNameCustom.FilePath).Substring(6, 8); foreach (DK dk in dks) { dkbm = dk.DKBM; if (MyUtils.Utils.IsStrNull(dkbm)) { MessageBox.Show("文件:" + fileNameCustom.FilePath + ",地块编码有为空"); flag = false; break; } if (dkbmMJDic.TryGetValue(zh + dkbm, out area)) { double areaMJ; if (double.TryParse(area, out areaMJ)) { dk.SCMJ = areaMJ.ToString("f2"); } } else { { MessageBox.Show("地块编码:" + zh + dkbm + ",在shp面积中没有找到"); flag = false; break; } } } if (hzs != null && flag) { //导出数据 fileNameCustom.IsSuccess = JTCYCustom.ExportBsicInformationExcel(hzs, saveDir); } } WaitFormCustom.CloseWaitForm(); } else { MessageBox.Show("你还没有添加任何文件!!!"); } }