コード例 #1
0
        /// <summary>
        /// 导出方法
        /// </summary>
        /// <param name="bo"></param>
        private void Export(object bo)
        {
            ExcelHelper.ExcelHelper ExcelExport = new ExcelHelper.ExcelHelper();
            DataSet ds = new DataSet();

            Percent = 0;
            try
            {
                SaveParameter sp = (SaveParameter)bo;
                if (sp.PARAM != null)
                {
                    BaseService bs  = new BaseService();
                    DataTable   dt1 = bs.GetDataTableToParamID(sp.PARAM);
                    ds.Tables.Add(dt1);
                    ExcelExport.ExprotExcel(dt1.TableName, sp.TempName, ds, sp.UserName);
                    State = 2;
                }
                // 指标甄核规则-导入模板下载
                if (sp.PARAMGP != null)
                {
                    BaseService bs_gp = new BaseService();
                    DataTable   dt1   = bs_gp.GetDataTableToParamID(sp.PARAMGP);
                    ds.Tables.Add(dt1);
                    ExcelExport.ExprotExcel(dt1.TableName, sp.TempName, ds, sp.UserName);
                    State = 2;
                }
                // 导出采集报表 Author:彭皓 2017-4-14
                if (sp.Ds != null)
                {
                    foreach (string tempname in sp.TempNames)
                    {
                        ExcelExport.ExportExcel(tempname, sp.Ds, sp.dicAuditRules, sp.UserName);
                        FileLog.WriteLog("测试(" + tempname + ")");
                    }
                    State = 2;
                    FileLog.WriteLog("测试(success):SaveExcel.State=" + State);
                }
            }
            catch (Exception e)
            {
                FileLog.WriteLog("Error:调用CMDI.Service.SaveExcel/Export()方法。" + e);
                ErrorTime = DateTime.Now;
                Percent   = 0;
                State     = 3;
                FileLog.WriteLog("测试(catch):SaveExcel.State=" + State);
            }
            finally
            {
                FinishTime = DateTime.Now;
                FileLog.WriteLog("测试(finally):SaveExcel.State=" + State);
            }
        }
コード例 #2
0
        /// <summary>
        /// 导出方法
        /// </summary>
        /// <param name="bo"></param>
        private void MoreExport(object bo)
        {
            ExcelHelper.ExcelHelper ExcelExport = new ExcelHelper.ExcelHelper();
            DataSet ds = new DataSet();

            Percent = 0;
            try
            {
                SaveParameter1 sp = (SaveParameter1)bo;
                if (sp.PARAM != null)
                {
                    BaseService bs = new BaseService();

                    foreach (Dictionary <string, Newtonsoft.Json.Linq.JArray> a in sp.PARAM)
                    {
                        DataTable dt1 = bs.GetDataTableToParamID(a);
                        ds.Tables.Add(dt1);
                    }
                    ExcelExport.ExprotExcel("", sp.TempName, ds, sp.UserName);
                    State = 2;
                }
            }
            catch (Exception e)
            {
                FileLog.WriteLog("Error:调用CMDI.Service.SaveExcel/Export()方法。" + e.Message);
                ErrorTime = DateTime.Now;
                Percent   = 0;
            }
            finally
            {
                FinishTime = DateTime.Now;
            }
        }