public void Load(Rdl.Runtime.RuntimeBase rtb, string report) { _doc.LoadXml(report); parse(_doc.DocumentElement); Rtb = rtb; //LoadDefaults(); }
private void Compile(string assemplyPath, string reportName) { // Set up the compiler CompilerParameters cp = new CompilerParameters(); cp.GenerateExecutable = false; if (assemplyPath != null && assemplyPath != string.Empty) { cp.OutputAssembly = assemplyPath; cp.GenerateInMemory = false; cp.IncludeDebugInformation = true; } else { cp.GenerateInMemory = true; } cp.TreatWarningsAsErrors = false; cp.ReferencedAssemblies.Add("System.Xml.dll"); LoadModule(cp, "RdlEngine.dll"); foreach (string codeModule in _codeModules) { LoadModule(cp, codeModule); } // Replace the aggregate function calls with deletage calls. //int ct = _functions.Count; //for (int i = 0; i < ct; i++) // _functions[i] = ReplaceAggregatesWithDelegates(_functions[i]); // Build the source code for the named functions. string addFns = string.Empty; string functions = string.Empty; for (int i = 0; i < _functions.Count; i++) { addFns += " AddFunction( AddressOf fn_" + i.ToString() + " )\n"; functions += _functions[i] + "\n"; } string source = Rdl.RdlResource.RuntimeCode; source = source.Replace(@"' Add Functions", addFns); source = source.Replace(@"' Functions", functions); if (reportName != null && reportName != string.Empty) { source = source.Replace(@"RunTimeReportName", reportName); } if (!cp.GenerateInMemory) { string tempName = Path.Combine(Path.GetTempPath(), "Rdl.Runtime." + reportName + ".resources"); ResourceWriter rw = new ResourceWriter(new FileStream(tempName, FileMode.Create)); rw.AddResource("ReportSource", _doc.InnerXml); rw.Close(); cp.EmbeddedResources.Add(tempName); } if (_code != null) { source += "\nnamespace Rdl.Runtime\n" + " Public Class Code\n" + _code + "\n" + " end class\n" + "end namespace\n"; } // Compile the runtime source CodeDomProvider provider = new VBCodeProvider(); CompilerResults cr = provider.CompileAssemblyFromSource(cp, new string[] { source }); // Delete the temporary resources. foreach (string s in cp.EmbeddedResources) { System.IO.File.Delete(s); } if (cr.Errors.Count > 0) { throw new CompileException(cr.Output, cr.Errors); } if (cp.GenerateInMemory) { // Get a reference to a RunTimeBase object. Assembly CodeAssembly = cr.CompiledAssembly; Type ty = CodeAssembly.GetType("Rdl.Runtime.RunTimeReportName"); Rtb = (Rdl.Runtime.RuntimeBase)Activator.CreateInstance(ty, new object[] { this }); //LoadDefaults(); } }