Exemple #1
0
        /// <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);
        }