public Engine(Env env) { Logger.debug("开始运算报表,首先取数......"); _report = env.ReportDefine; _cells = new CellExt1(env); _cells.read(_report.Cells); }
private void prepareEnv(string args, Env env, ReportDefine rd) { var collection = new Hashtable(); if (!string.IsNullOrEmpty(args)) { string[] arrayItem = args.Split(new[] { '&' }); for (int i = 0, length = arrayItem.Length; i < length; i++) { string item = arrayItem[i]; if ((item != null) && (item.Trim().Length > 0)) { string[] arrayVar = arrayItem[i].Split(new[] { '=' }); if (arrayVar.Length == 2) { string key = arrayVar[0]; string src = arrayVar[1]; if ((src != null) && (src.Trim().Length != 0)) { SupportClass.PutElement(collection, key, Escape.unescape(src)); } } } } } preapareArgs(rd, collection, env); prepareDataSource(rd.DataSetConfigs.getDataSourceNames(), env); }
public string calcStr(HttpRequest req) { string message = ""; string sContent = ""; Env env = null; ReportDefine rd = null; XmlDocument document = method_5(req); sContent = document.DocumentElement.ChildNodes.Item(0).InnerXml; try { rd = new ReportDefine(sContent, 1); env = new Env(rd) { Request = req, Session = _sessionState }; prepareEnv(document.DocumentElement.ChildNodes.Item(1).InnerText, env, rd); Engine engine = new Engine(env); message = engine.calc().exportToHTML(null, 1f, -1, req, false); } catch (Exception exception) { message = exception.Message; } finally { method_9(env); } return(message); }
private Report method_4(string fileName, HttpRequest request, string args) { Report report = null; string key = request["cacheid"]; if ((key != null) && (key.Trim().Length > 0)) { report = (Report)CachedReportPool.get(key); } if (report == null) { Env env = null; try { ReportDefine rd = null; if (request["fromdb"] != "yes") { rd = new ReportDefine(fileName); } else { string content = ToDatabase.Load(request, _operator, request["spath"]); if (content == "") { throw new Exception("从数据库中读出的报表内容为空"); } rd = new ReportDefine(content, 1); } env = new Env(rd) { Request = request, Session = _sessionState }; prepareEnv(args, env, rd); report = new Engine(env).calc(); } catch (FileNotFoundException exception) { throw exception; } catch (Exception exception2) { throw exception2; } finally { method_9(env); } } method_6(request["pageset"], report); return(report); }
private void method_0(ReportDefine rd) { Args arguments = rd.Arguments; string[] argumentNames = arguments.ArgumentNames; ParamsMap = new StringMap(argumentNames.Length); for (int i = 0; i < argumentNames.Length; i++) { Arg arg = arguments[i]; object obj3 = ArgDataType.getProperData(int.Parse(arg.type), arg.value_Renamed); ParamsMap[argumentNames[i]] = obj3; } MacrosMap = rd.Macros; SubRptList = rd.SubReports; }
public Env(ReportDefine rd) { Connections = new StringMap(5); Charsets = new StringMap(5); dbTypeMap = new StringMap(5); transSqls = new StringMap(5); encodingMap = new StringMap(5); //stringMap_5 = new StringMap(5); DataSetsMap = new StringMap(3); bool_2 = true; CoverUserDataSet = false; ServletContext = null; dateTimeFactory = null; idictionary = null; reportDefine = rd; method_0(rd); }
public virtual void putMacros(ReportDefine rd) { putMacros((IDictionary)rd.Macros); }
public string genHtmlFile(HttpRequest req, string sXml) { var builder = new StringBuilder(); Report report = null; var document = new XmlDocument(); if (sXml == null) { document = method_5(req); } else { document.LoadXml(sXml); } string exptype = Tools.getXPathValue(document.DocumentElement, "/root/paths/exptype"); string fromdb = Tools.getXPathValue(document.DocumentElement, "/root/paths/fromdb"); string gen = Tools.getXPathValue(document.DocumentElement, "/root/paths/gen"); string orderpageno = Tools.getXPathValue(document.DocumentElement, "/root/paths/orderpageno"); gen = PathTool.getRealPath(req, FileAction.basePath + gen); int num4 = 0; int num2 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Count; for (int i = 0; i < num2; i++) { string sFileName = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(0).InnerText; builder.Append("<reportfile><name>" + sFileName + "</name>"); if (fromdb != "yes") { sFileName = PathTool.getRealPath(req, FileAction.basePath + sFileName); } string str2 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(1).InnerText; Env env = null; try { ReportDefine rd = null; if (fromdb == "yes") { string sContent = ToDatabase.Load(req, _operator, sFileName); if (sContent == "") { throw new Exception("从数据库中读出的报表内容为空"); } rd = new ReportDefine(sContent, 1); } else { rd = new ReportDefine(sFileName); } env = new Env(rd) { Request = req, Session = _sessionState }; Hashtable collection = new Hashtable(); XmlNode node = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(2); int num7 = node.ChildNodes.Count; for (int j = 0; j < num7; j++) { string key = node.ChildNodes.Item(j).ChildNodes.Item(0).InnerText; string newValue = Escape.unescape(node.ChildNodes.Item(j).ChildNodes.Item(1).InnerText); if (((key != null) && (key.Trim().Length > 0)) && ((newValue != null) && (newValue.Trim().Length > 0))) { if (!(key == "e_setdataset") && !(key == "e_setparammacro")) { SupportClass.PutElement(collection, key, newValue); } else { env.setParameter(key, newValue); } } } float num5 = 1f; try { num5 = Convert.ToSingle(document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(3).InnerText); } catch (Exception) { } preapareArgs(rd, collection, env); prepareDataSource(rd.DataSetConfigs.getDataSourceNames(), env); report = new Engine(env).calc(); string str7 = ""; try { str7 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(4).InnerText; } catch (Exception) { } string str9 = ""; try { str9 = document.DocumentElement.ChildNodes.Item(0).ChildNodes.Item(i).ChildNodes.Item(5).InnerText; } catch (Exception) { } method_6(str9, report); string sFile = gen + str2 + "." + exptype; int num3 = 1; switch (exptype) { case "htm": if (str2.Length == 0) { str2 = method_11(); method_13(gen); } num3 = method_1(report, gen, str2, num5, num4, str7); break; case "pdf": report.exportToPDF(sFile); break; default: if (exptype != "xls") { if (!(exptype == "xlt")) { if (exptype == "*") { num3 = method_1(report, gen, str2, num5, num4, str7); sFile = gen + str2 + ".pdf"; report.exportToPDF(sFile); sFile = gen + str2 + ".xls"; report.exportToExcel(sFile, false); sFile = gen + str2 + ".xlt"; report.exportToExcel(sFile, true); } } else { report.exportToExcel(sFile, true); } } else { report.exportToExcel(sFile, false); } break; } if ((orderpageno != null) && (orderpageno == "yes")) { num4 += num3; } builder.Append("<pages>" + Convert.ToString(num3) + "</pages><errmsg></errmsg>"); } catch (Exception exception) { builder.Append("<pages>0</pages><errmsg>" + exception.Message + "</errmsg>"); } finally { method_9(env); } builder.Append("<genname>" + str2 + "</genname>"); builder.Append(method_2(report)); builder.Append("</reportfile>"); } return(builder.ToString()); }
private void preapareArgs(ReportDefine reportDefine_0, Hashtable hashtable_0, Env env_0) { Args arguments = reportDefine_0.Arguments; if (arguments.size() > 0) { int num2 = arguments.size(); for (int i = 0; i < num2; i++) { Arg arg = arguments[i]; string val = null; if (hashtable_0 != null) { val = (string)hashtable_0[arg.enName]; } if (((val == null) && (arg.value_Renamed != null)) && (arg.value_Renamed.Trim().Length > 0)) { val = arg.value_Renamed; } int num3 = int.Parse(arg.type); object paramValue = null; try { paramValue = ArgDataType.getProperData(num3, val); } catch (Exception) { throw new Exception(new StringBuilder("参数\"").Append(arg.chName).Append("\"的值").Append(val).Append("与其类型不匹配!").ToString().ToString()); } env_0.putParam(arg.enName, paramValue); _builder.Append("<arg><name>" + arg.enName + "</name><value>" + Convert.ToString(paramValue) + "</value></arg>"); } } StringMap macros = reportDefine_0.Macros; if ((macros != null) && (macros.Count > 0)) { IEnumerator enumerator = new SupportClass.SetSupport(macros.Keys).GetEnumerator(); while (enumerator.MoveNext()) { string current = (string)enumerator.Current; string str4 = null; if (hashtable_0 != null) { str4 = (string)hashtable_0[current]; } if (str4 == null) { str4 = (string)macros[current]; } _builder.Append("<macro><name>" + current + "</name><value>" + str4 + "</value></macro>"); env_0.putMacro(current, str4); } } string str = null; string rootPath = null; if (env_0.Request == null) { str = env_0.getParameter("e_setparammacro"); rootPath = FileAction.rootPath; } else { str = env_0.Request["e_setparammacro"]; rootPath = env_0.Request.PhysicalApplicationPath; } if ((str != null) && (str.Length > 0)) { Type type = Assembly.LoadFrom(rootPath + @"bin\LoadEbiao.dll").GetType("LoadEbiao.IParamMacro"); if (type != null) { object[] args = new object[0]; object obj2 = Activator.CreateInstance(type, args); BindingFlags invokeAttr = BindingFlags.Public | BindingFlags.Instance; object[] parameters = new object[] { env_0 }; try { type.GetMethod("setParams").Invoke(obj2, invokeAttr, Type.DefaultBinder, parameters, null); } catch (Exception exception) { throw new Exception(exception.InnerException.Message); } try { type.GetMethod("setMacros").Invoke(obj2, invokeAttr, Type.DefaultBinder, parameters, null); } catch (Exception exception2) { throw new Exception(exception2.InnerException.Message); } } } }