public int PrepareMarcFilter( string strFilterFileName, out LoanFilterDocument filter, out string strError) { strError = ""; // 看看是否有现成可用的对象 filter = (LoanFilterDocument)this.Filters.GetFilter(strFilterFileName); if (filter != null) return 1; // 新创建 filter = new LoanFilterDocument(); filter.strOtherDef = "FilterHost Host = null;"; filter.strPreInitial = " LoanFilterDocument doc = (LoanFilterDocument)this.Document;\r\n"; filter.strPreInitial += " Host = (" + "FilterHost" + ")doc.FilterHost;\r\n"; try { filter.Load(strFilterFileName); } catch (Exception ex) { strError = ExceptionUtil.GetAutoText(ex); return -1; } string strCode = ""; // c#代码 int nRet = filter.BuildScriptFile(out strCode, out strError); if (nRet == -1) return -1; try { string[] saRef2 = filter.GetRefs(); filter.Assembly = this.AssemblyCache.GetObject(strFilterFileName, () => { string strError1 = ""; string[] saAddRef1 = { // 2011/9/3 增加 "system.dll", "system.drawing.dll", "system.web.dll", "system.xml.dll", "System.Runtime.Serialization.dll", this.BinDir + "\\digitalplatform.marcdom.dll", this.BinDir + "\\digitalplatform.marckernel.dll", this.BinDir + "\\digitalplatform.libraryserver.dll", this.BinDir + "\\digitalplatform.dll", this.BinDir + "\\digitalplatform.Text.dll", this.BinDir + "\\digitalplatform.IO.dll", this.BinDir + "\\digitalplatform.Xml.dll", this.BinDir + "\\digitalplatform.script.dll", this.BinDir + "\\digitalplatform.marcquery.dll", }; string strWarning = ""; // string strLibPaths = ""; string[] saRef = StringUtil.Append(saRef2, saAddRef1); #if NO string[] saRef = new string[saRef2.Length + saAddRef1.Length]; Array.Copy(saRef2, saRef, saRef2.Length); Array.Copy(saAddRef1, 0, saRef, saRef2.Length, saAddRef1.Length); #endif Assembly assembly1 = null; // 创建Script的Assembly // 本函数内对saRef不再进行宏替换 nRet = ScriptManager.CreateAssembly_1(strCode, saRef, "", // strLibPaths, out assembly1, out strError1, out strWarning); if (nRet == -2) throw new Exception(strError1); if (nRet == -1) { if (strWarning == "") throw new Exception(strError1); } return assembly1; }); } catch (Exception ex) { strError = ex.Message; return -1; } return 0; }
public int PrepareMarcFilter( string strFilterFileName, out LoanFilterDocument filter, out string strError) { strError = ""; // 看看是否有现成可用的对象 filter = (LoanFilterDocument)this.Filters.GetFilter(strFilterFileName); if (filter != null) { return(1); } // 新创建 filter = new LoanFilterDocument(); filter.strOtherDef = "FilterHost Host = null;"; filter.strPreInitial = " LoanFilterDocument doc = (LoanFilterDocument)this.Document;\r\n"; filter.strPreInitial += " Host = (" + "FilterHost" + ")doc.FilterHost;\r\n"; try { filter.Load(strFilterFileName); } catch (Exception ex) { strError = ExceptionUtil.GetAutoText(ex); return(-1); } string strCode = ""; // c#代码 int nRet = filter.BuildScriptFile(out strCode, out strError); if (nRet == -1) { return(-1); } try { string[] saRef2 = filter.GetRefs(); filter.Assembly = this.AssemblyCache.GetObject(strFilterFileName, () => { string strError1 = ""; string[] saAddRef1 = { // 2011/9/3 增加 "system.dll", "system.drawing.dll", "system.web.dll", "system.xml.dll", "System.Runtime.Serialization.dll", this.BinDir + "\\digitalplatform.marcdom.dll", this.BinDir + "\\digitalplatform.marckernel.dll", this.BinDir + "\\digitalplatform.libraryserver.dll", this.BinDir + "\\digitalplatform.dll", this.BinDir + "\\digitalplatform.Text.dll", this.BinDir + "\\digitalplatform.IO.dll", this.BinDir + "\\digitalplatform.Xml.dll", this.BinDir + "\\digitalplatform.script.dll", this.BinDir + "\\digitalplatform.marcquery.dll", }; string strWarning = ""; // string strLibPaths = ""; string[] saRef = StringUtil.Append(saRef2, saAddRef1); #if NO string[] saRef = new string[saRef2.Length + saAddRef1.Length]; Array.Copy(saRef2, saRef, saRef2.Length); Array.Copy(saAddRef1, 0, saRef, saRef2.Length, saAddRef1.Length); #endif Assembly assembly1 = null; // 创建Script的Assembly // 本函数内对saRef不再进行宏替换 nRet = ScriptManager.CreateAssembly_1(strCode, saRef, "", // strLibPaths, out assembly1, out strError1, out strWarning); if (nRet == -2) { throw new Exception(strError1); } if (nRet == -1) { if (strWarning == "") { throw new Exception(strError1); } } return(assembly1); }); } catch (Exception ex) { strError = ex.Message; return(-1); } return(0); }
// 将种记录数据从XML格式转换为HTML格式 // parameters: // strBiblioXml XML记录,或者 MARC 记录 // strSyntax MARC格式 usmarc/unimarc。如果strBiblioXml 第一字符为 '<' 则本参数可以为空 public int ConvertBiblioXmlToHtml( string strFilterFileName, string strBiblioXml, string strSyntax, string strRecPath, out string strBiblio, out string strError) { strBiblio = ""; strError = ""; int nRet = 0; LibraryApplication app = this; FilterHost host = new FilterHost(); host.RecPath = strRecPath; host.App = this; string strMarc = ""; if (string.IsNullOrEmpty(strBiblioXml) == false && strBiblioXml[0] == '<') { // 如果必要,转换为MARC格式,调用filter // string strOutMarcSyntax = ""; // 将MARCXML格式的xml记录转换为marc机内格式字符串 // parameters: // bWarning ==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换 // strMarcSyntax 指示marc语法,如果=="",则自动识别 // strOutMarcSyntax out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值 nRet = MarcUtil.Xml2Marc(strBiblioXml, true, "", // this.CurMarcSyntax, out strSyntax, out strMarc, out strError); if (nRet == -1) { goto ERROR1; } } else { strMarc = strBiblioXml; } LoanFilterDocument filter = null; nRet = app.PrepareMarcFilter( // host, strFilterFileName, out filter, out strError); if (nRet == -1) { goto ERROR1; } filter.FilterHost = host; try { nRet = filter.DoRecord(null, strMarc, strSyntax, 0, out strError); if (nRet == -1) { goto ERROR1; } strBiblio = host.ResultString; } catch (Exception ex) { strError = "filter.DoRecord error: " + ExceptionUtil.GetDebugText(ex); return(-1); } finally { // 2012/3/28 filter.FilterHost = null; // 脱钩 // 归还对象 app.Filters.SetFilter(strFilterFileName, filter); } return(0); ERROR1: return(-1); }
public int PrepareMarcFilter( // FilterHost host, string strFilterFileName, out LoanFilterDocument filter, out string strError) { strError = ""; // 看看是否有现成可用的对象 filter = (LoanFilterDocument)this.Filters.GetFilter(strFilterFileName); if (filter != null) { // filter.FilterHost = host; return 1; } // 新创建 // string strFilterFileContent = ""; filter = new LoanFilterDocument(); // filter.FilterHost = host; filter.strOtherDef = "FilterHost Host = null;"; filter.strPreInitial = " LoanFilterDocument doc = (LoanFilterDocument)this.Document;\r\n"; filter.strPreInitial += " Host = (" + "FilterHost" + ")doc.FilterHost;\r\n"; try { filter.Load(strFilterFileName); } catch (Exception ex) { strError = ex.Message; return -1; } string strCode = ""; // c#代码 int nRet = filter.BuildScriptFile(out strCode, out strError); if (nRet == -1) goto ERROR1; string[] saAddRef1 = { // 2011/9/3 增加 "system.dll", "system.drawing.dll", "system.web.dll", "system.xml.dll", "System.Runtime.Serialization.dll", this.BinDir + "\\digitalplatform.marcdom.dll", this.BinDir + "\\digitalplatform.marckernel.dll", this.BinDir + "\\digitalplatform.libraryserver.dll", this.BinDir + "\\digitalplatform.dll", this.BinDir + "\\digitalplatform.Text.dll", this.BinDir + "\\digitalplatform.IO.dll", this.BinDir + "\\digitalplatform.Xml.dll", this.BinDir + "\\digitalplatform.script.dll", this.BinDir + "\\digitalplatform.marcquery.dll", /*strMainCsDllName*/ }; Assembly assembly = null; string strWarning = ""; string strLibPaths = ""; string[] saRef2 = filter.GetRefs(); string[] saRef = new string[saRef2.Length + saAddRef1.Length]; Array.Copy(saRef2, saRef, saRef2.Length); Array.Copy(saAddRef1, 0, saRef, saRef2.Length, saAddRef1.Length); // 创建Script的Assembly // 本函数内对saRef不再进行宏替换 nRet = ScriptManager.CreateAssembly_1(strCode, saRef, strLibPaths, out assembly, out strError, out strWarning); if (nRet == -2) goto ERROR1; if (nRet == -1) { if (strWarning == "") { goto ERROR1; } // MessageBox.Show(this, strWarning); } filter.Assembly = assembly; return 0; ERROR1: return -1; }