/// <summary> /// 检查运行器 /// </summary> /// <param name="form"></param> /// <returns></returns> public static void RunCheckerXlsx(CheckeCallbackArgv argv) { if (argv == null) { throw new Exception("Run xlsx form argv is null."); } if (argv.OnRunChanged != null) { argv.OnRunChanged("=================检查开始================="); } OptionsForm optionForm = DataMemory.GetOptionsFrom(); if (optionForm.XlsxSrcPath.Length <= 0) { return; } if (!Directory.Exists(optionForm.XlsxSrcPath)) { return; } string[] files = Directory.GetFiles(optionForm.XlsxSrcPath, "*.xlsx", SearchOption.AllDirectories); if (files.Length <= 0) { return; } // 注意xlsx文件命名规则: 标号_英文名_中文名 foreach (string file in files) { string fileName = string.Empty; string xlsxOutExtName = Path.GetFileNameWithoutExtension(file); string xlsxWithExtName = Path.GetFileName(file); string[] xlsxNameArray = xlsxOutExtName.Split('_'); if (xlsxNameArray.Length <= 1) { if (argv.OnRunChanged != null) { argv.OnRunChanged(string.Format("{0} name error", xlsxWithExtName)); } } else { if (argv.OnRunChanged != null) { argv.OnRunChanged(string.Format("{0} ok", xlsxWithExtName)); } } Thread.Sleep(10); } if (argv.OnRunChanged != null) { argv.OnRunChanged("=================检查完毕================="); } }
/// <summary> /// 检查用户输入信息 /// </summary> public static string ParseCheckerUserInput() { string error = null; OptionsForm optionForm = DataMemory.GetOptionsFrom(); if (optionForm == null) { error = "工具底层异常,请程序检查!"; } else if (string.IsNullOrEmpty(optionForm.XlsxSrcPath)) { error = "Xlsx表格路径不能为空!"; } return(error); }
/// <summary> /// 处理导出选项参数前事件 /// </summary> /// <param name="form"></param> /// <returns></returns> public static void BeforeExporterOptionForm() { DataMemory.SetExportTotalCount(0); OptionsForm optionForm = DataMemory.GetOptionsFrom(); List <ExportType> typeList = DataMemory.GetOptionsFromTypes(); if (typeList.Count <= 0) { return; } if (optionForm.XlsxSrcPath.Length <= 0) { return; } if (optionForm.XlsxDstPath.Length <= 0) { return; } if (!Directory.Exists(optionForm.XlsxSrcPath)) { return; } string[] files = Directory.GetFiles(optionForm.XlsxSrcPath, "*.xlsx", SearchOption.AllDirectories); if (files.Length <= 0) { return; } int count = 0; foreach (string srcFile in files) { string fileName = string.Empty; string xlsxName = Path.GetFileNameWithoutExtension(srcFile); fileName = xlsxName; foreach (ExportType type in typeList) { string outFileName = string.Format("{0}.{1}", fileName, type); string dstFile = Path.Combine(optionForm.XlsxDstPath, outFileName); Options option = Options.ConvertToOption(srcFile, dstFile, type); DataMemory.SetExportOption(type, option); count++; } } DataMemory.SetExportTotalCount(count); }
/// <summary> /// 检查用户输入信息 /// </summary> public static string ParseExportUserInput() { string error = ParseCheckerUserInput(); if (!string.IsNullOrEmpty(error)) { return(error); } OptionsForm optionForm = DataMemory.GetOptionsFrom(); if (string.IsNullOrEmpty(optionForm.XlsxDstPath)) { error = "文本导出路径不能为空!"; } else if (optionForm.ExporterList.Count <= 0) { error = "请至少选择一种导出类型!"; } return(error); }
private static string GetExporterPath(ExportType type) { return(string.Format("{0}/{1}", DataMemory.GetOptionsFrom().XlsxDstPath, type.ToString())); }