private TemplateHandlerPrams CreateTemplateHandlerPrams() { TemplateHandlerPrams paPrams = new TemplateHandlerPrams(); string date = "2014,11,1"; var d = date.Split(','); var dateTime = new DateTime(int.Parse(d[0]), int.Parse(d[1]), int.Parse(d[2]), 3, 0, 0); paPrams.Date = dateTime; string fileDirPath = RPTPara.GetTemplateFilePath(); paPrams.TemplateFileName = Path.Combine(fileDirPath, "StructureMonthlyReport.docx"); Organization org = DataAccess.GetOrganizationInfo(15); paPrams.Organization = org; Structure structure = DataAccess.GetStructureInfo(3); paPrams.Structure = structure; var sb = new StringBuilder(100); sb.Append(paPrams.Structure.Name); var reportDate = paPrams.Date.AddMonths(-1); sb.Append("_月报表").AppendFormat("_{0}年{1}月", reportDate.Year.ToString(), reportDate.Month.ToString()); sb.Append(".docx"); var path = Path.Combine(Path.GetTempPath(), sb.ToString()); paPrams.FileFullName = path; return(paPrams); }
public OriginalDataReportHandle(TemplateHandlerPrams para) : base(para) { if (base.TemplateHandlerPrams.Structure != null) { structId = TemplateHandlerPrams.Structure.Id; factors = GetAllFactors(structId); sensors = this.GetAllSensors(factors); } }
public static string CallTemplateHandle(TemplateHandlerPrams para, string handleName) { const string method = "WriteFile"; string dependPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, DependPath)); string templateHandleRootDirPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, TemplateHandleRootDirPath)); string templateHandlePath = MonitorReportFile.GetTemplateHandlePath(templateHandleRootDirPath, handleName); var cp = new object[] { para }; CrossDomainCompiler.Call(templateHandlePath, dependPath, typeof(TemplateHandleBase), method, ref cp); return(para.FileFullName); }
/// <summary> /// 模板处理类所需参数转换 /// </summary> /// <param name="template">配置参数</param> /// <returns>处理类所需参数</returns> protected TemplateHandlerPrams GetHandlerPara(ReportTemplate template) { TemplateHandlerPrams retValue = new TemplateHandlerPrams(); retValue.Organization = this.organization; retValue.Structure = this.structure; retValue.Factor = DataAccess.GetFactorInfoById(template.FactorId); retValue.FileFullName = this.fileFullName; retValue.TemplateFileName = template.FullName; retValue.Date = this.createDate.Date.AddHours(getDataHour); return(retValue); }
public void TestPhSettlementWeeklyReport() { string template = "坪汉拱顶沉降监测周模板.xls"; string reportName = "坪汉沉降监测_周报表.xls"; string handleName = "PhSettlementWeeklyReport"; DateTime date = new DateTime(2015, 1, 19, 0, 0, 0, DateTimeKind.Local); int factorId = 40; // 拱顶沉降 int structId = 82; // 坪汉 int orgId = 48; TemplateHandlerPrams para = CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public void TestStructureMonthlyReportTemplateHandler() { string template = "StructureMonthlyReport.docx"; string reportName = "结构物(边坡)月报表.docx"; string handleName = "StructureMonthlyReportTemplateHandler"; DateTime date = new DateTime(2014, 11, 1, 0, 0, 0, DateTimeKind.Local); int factorId = -1; int structId = 3; int orgId = 15; TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public void TestPhCrackWeeklyReport() { string template = "PhCrackWeeklyReport.xls"; string reportName = "坪汉净空收敛监测_周报表(自定义模板).xls"; string handleName = "PhShouLianWeeklyReport"; DateTime date = new DateTime(2015, 1, 19, 0, 0, 0, DateTimeKind.Local); int factorId = 41; // 净空收敛 int structId = 82; // 坪汉 int orgId = 48; TemplateHandlerPrams para = CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public void TestCxDailyReport() { string template = "测斜监测日模板.xls"; string reportName = "测斜监测日报表.xls"; string handleName = "CxDailyReport"; DateTime date = new DateTime(2014, 8, 22, 0, 0, 0, DateTimeKind.Local); int factorId = 10; int structId = 4; int orgId = 12; TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public void TestGfmsDailyReport() { string template = "GfmsDailyReport.xls"; string reportName = "广佛城际轻轨基坑锚杆受力监测日报表.xls"; string handleName = "GfmsDailyReport"; DateTime date = new DateTime(2014, 12, 14, 0, 0, 0, DateTimeKind.Local); int factorId = 16; int structId = 62; int orgId = 38; TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public void TestDwySwDailyUnifyReport() { string template = "SwDailyReportNcdwy.xls"; string reportName = "动物园围护结构地下水位监测日报表.xls"; string handleName = "SwDailyUnifyReport"; DateTime date = new DateTime(2014, 5, 22, 0, 0, 0, DateTimeKind.Local); int factorId = 17; int structId = 72; int orgId = 22; TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public MonthReport(TemplateHandlerPrams param) : base(param) { try { //TemplateHandlerPrams = param; SensorProduct = DataAccess.GetProductInfo(param.Structure.Id, param.Factor.Id); SensorsId = GetSensorsByStrunctIdAndFactorId(param.Structure.Id, param.Factor.Id); Cdbh = GetCdbhByStructIdAndFactorId(TemplateHandlerPrams.Structure.Id, TemplateHandlerPrams.Factor.Id); } catch (Exception ex) { logger.Warn(ex.Message); } }
public void TestCjWeekReport() { string template = "沉降监测周模板.xls"; string reportName = "沉降监测周报表.xls"; string handleName = "CjWeekReport"; DateTime date = new DateTime(2014, 5, 22, 0, 0, 0, DateTimeKind.Local); int factorId = 11; int structId = 17; int orgId = 22; TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public void TestHsMonthReport() { string template = "水平位移监测月模板.xls"; string reportName = "水平位移监测月报表.xls"; string handleName = "HsMonthReport"; DateTime date = new DateTime(2015, 11, 22, 0, 0, 0, DateTimeKind.Local); int factorId = 9; int structId = 2; int orgId = 22; TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
/// <summary> /// 创建新报表 /// </summary> /// <returns>新报表信息</returns> protected override ReportTaskResult Create() { //ReportTaskResult result; Log.InfoFormat("开始生成【{0}】", ReportInfo.Name); string filePath = Path.GetDirectoryName(reportInfo.FullName); if (!Directory.Exists(filePath)) { if (!DirectoryHelper.CreateDirectory(filePath)) { Log.Error(string.Format("创建路径{0},失败", filePath)); return(CreateTaskResult(Result.Failed)); } } if (File.Exists(ReportInfo.FullName)) { if (!DeleteOldFile(reportInfo)) { Log.Info(string.Format("删除已有{0}失败,本次不生成新文件", reportInfo.FullName)); return(CreateTaskResult(Result.Failed)); } } Log.Debug("创建目录成功"); foreach (var template in ReportGroup.Templates) { TemplateHandlerPrams para = this.GetHandlerPara(template); var cp = new object[] { para }; try { string templateHandleRootDirPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, TemplateHandleRootDirPath)); string dependPath = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, DependPath)); string templateHandlePath = GetTemplateHandlePath(templateHandleRootDirPath, template.HandleName); Log.Debug("开始写文件"); CrossDomainCompiler.Call(templateHandlePath, dependPath, typeof(TemplateHandleBase), "WriteFile", ref cp); Log.Debug("写文件结束"); } catch (Exception e) { Log.Error(string.Format("{0}生成失败", ReportInfo.Name), e); DeleteWrongReport(this.fileFullName); return(CreateTaskResult(Result.Failed)); } } Log.InfoFormat("生成【{0}】成功", ReportInfo.Name); return(CreateTaskResult(Result.Successful)); }
private TemplateHandlerPrams CreateCrackTemplateHandlerPrams(string template, string fullName) { string fileDirPath = RPTPara.GetTemplateFilePath(); TemplateHandlerPrams paPrams = new TemplateHandlerPrams() { Date = new DateTime(2015, 1, 19, 0, 0, 0, DateTimeKind.Local), Factor = DataAccess.GetFactorInfoById(41), Structure = DataAccess.GetStructureInfo(82), Organization = DataAccess.GetOrganizationInfo(48), FileFullName = Path.Combine(Path.GetTempPath(), fullName), TemplateFileName = Path.Combine(fileDirPath, template) }; return(paPrams); }
public void TestXwzxWeekReport() { string fileDirPath = RPTPara.GetTemplateFilePath(); string template = "GfMonthlyReport.docx"; string reportName = "广佛新闻中心周报.docx"; string handleName = "StructureWeekReportTemplateHandler"; DateTime date = new DateTime(2015, 2, 9, 0, 0, 0, DateTimeKind.Local); int factorId = -1; int structId = 62; int orgId = 38; TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); }
public DailyReport(TemplateHandlerPrams para, int identification) : base(para) { try { SensorProduct = DataAccess.GetProductInfo(TemplateHandlerPrams.Structure.Id, TemplateHandlerPrams.Factor.Id); SensorsId = GetAnchorSensorsByStrunctIdAndFactorId(TemplateHandlerPrams.Structure.Id, TemplateHandlerPrams.Factor.Id, identification); Cdbh = GetAnchorCdbhByStructIdAndFactorId(TemplateHandlerPrams.Structure.Id, TemplateHandlerPrams.Factor.Id, identification); } catch (Exception ex) { logger.Warn(ex.Message); } }
public static TemplateHandlerPrams CreateTemplateHandlerPrams(DateTime date, int factorId, int structId, int orgId, string template, string reportName) { string fileDirPath = RPTPara.GetTemplateFilePath(); TemplateHandlerPrams paPrams = new TemplateHandlerPrams() { Date = date, Factor = DataAccess.GetFactorInfoById(factorId), Structure = DataAccess.GetStructureInfo(structId), // Organization = DataAccess.GetOrganizationInfo(orgId), Organization = new Organization { Id = orgId, Name = "组织名称", SystemName = "系统名称" }, FileFullName = Path.Combine(Path.GetTempPath(), reportName), TemplateFileName = Path.Combine(fileDirPath, template) }; return(paPrams); }
public void TestCjDailyReport() { string template = "沉降监测日模板.xls"; string reportName = "沉降监测日报表.xls"; string handleName = "CjDailyReport"; DateTime date = new DateTime(2014, 5, 22, 0, 0, 0, DateTimeKind.Local); int factorId = 11; int structId = 17; int orgId = 12; try { TemplateHandlerPrams para = TestPinghanReport.CreateTemplateHandlerPrams(date, factorId, structId, orgId, template, reportName); string reportFullName = TestPinghanReport.CallTemplateHandle(para, handleName); Assert.IsTrue(File.Exists(reportFullName)); } catch (Exception e) { throw e; } }
public CjDailyReport(TemplateHandlerPrams param) : base(param) { }
public VsMonthReport(TemplateHandlerPrams param) : base(param) { }
public HsWeekReport(TemplateHandlerPrams param) : base(param) { }
public GfmsDailyReport(TemplateHandlerPrams param) : base(param, 2) { }
private decimal limit = 500;// 预警值 public SwDailyUnifyReport(TemplateHandlerPrams param) : base(param) { }
public TemplateHandleBase(TemplateHandlerPrams para) { this.TemplateHandlerPrams = para; }
public StructureMonthlyReportTemplateHandler(TemplateHandlerPrams para) : base(para) { }
public StructureWeekReportTemplateHandler(TemplateHandlerPrams para) : base(para) { }
public PhSettlementWeeklyReport(TemplateHandlerPrams para) : base(para) { Init(); PingHanReport.CheckParamValid(structId, factorId, template, logger); }