int PrepareMarcFilter(
            string strFilterFileContent,
            out MyFilterDocument filter,
            out string strError)
        {
            filter = new MyFilterDocument();

            filter.HostForm    = this;
            filter.strOtherDef = "RegisterBarcodeDlg HostForm = null;";

            filter.strPreInitial  = " MyFilterDocument doc = (MyFilterDocument)this.Document;\r\n";
            filter.strPreInitial += " HostForm = ("
                                    + "RegisterBarcodeDlg" + ")doc.HostForm;\r\n";

            // filter.Load(strFilterFileName);
            filter.LoadContent(strFilterFileContent);

            string strCode = "";    // c#代码

            int nRet = filter.BuildScriptFile(out strCode,
                                              out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            string[] saAddRef1 =
            {
                Environment.CurrentDirectory + "\\digitalplatform.marcdom.dll",
                Environment.CurrentDirectory + "\\digitalplatform.marckernel.dll",
                Environment.CurrentDirectory + "\\digitalplatform.rms.client.dll",
                Environment.CurrentDirectory + "\\digitalplatform.library.dll",
                Environment.CurrentDirectory + "\\digitalplatform.dll",
                Environment.CurrentDirectory + "\\digitalplatform.Text.dll",
                Environment.CurrentDirectory + "\\digitalplatform.IO.dll",
                Environment.CurrentDirectory + "\\digitalplatform.Xml.dll",
                Environment.CurrentDirectory + "\\Interop.SHDocVw.dll",
                Environment.CurrentDirectory + "\\dp2rms.exe",
                /*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);
        }
Exemple #2
0
        int PrepareMarcFilter(
            string strFilterFileContent,
            out MyFilterDocument filter,
            out string strError)
        {
            filter = new MyFilterDocument();

            filter.HostForm = this;
            filter.strOtherDef = "RegisterBarcodeDlg HostForm = null;";

            filter.strPreInitial = " MyFilterDocument doc = (MyFilterDocument)this.Document;\r\n";
            filter.strPreInitial += " HostForm = ("
                + "RegisterBarcodeDlg" + ")doc.HostForm;\r\n";

            // filter.Load(strFilterFileName);
            filter.LoadContent(strFilterFileContent);

            string strCode = "";    // c#代码

            int nRet = filter.BuildScriptFile(out strCode,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            string[] saAddRef1 = {
										 Environment.CurrentDirectory + "\\digitalplatform.marcdom.dll",
										 Environment.CurrentDirectory + "\\digitalplatform.marckernel.dll",
										 Environment.CurrentDirectory + "\\digitalplatform.rms.client.dll",
										 Environment.CurrentDirectory + "\\digitalplatform.library.dll",
										 Environment.CurrentDirectory + "\\digitalplatform.dll",
										 Environment.CurrentDirectory + "\\digitalplatform.Text.dll",
										 Environment.CurrentDirectory + "\\digitalplatform.IO.dll",
										 Environment.CurrentDirectory + "\\digitalplatform.Xml.dll",
										 Environment.CurrentDirectory + "\\Interop.SHDocVw.dll",
										 Environment.CurrentDirectory + "\\dp2rms.exe",
										 /*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;
        }
        int LoadBiblioRecord(
            string strBiblioRecPath,
            out string strError)
        {
            strError           = "";
            this.BiblioRecPath = strBiblioRecPath;

            string strMarcXml = "";

            byte[] baTimeStamp = null;

            int nRet = this.SearchPanel.GetRecord(
                this.ServerUrl,
                this.BiblioRecPath,
                out strMarcXml,
                out baTimeStamp,
                out strError);

            if (nRet == -1)
            {
                goto ERROR1;
            }

            // 转换为MARC格式

            string strOutMarcSyntax = "";
            string strMarc          = "";

            // 将MARCXML格式的xml记录转换为marc机内格式字符串
            // parameters:
            //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
            //		strMarcSyntax	指示marc语法,如果=="",则自动识别
            //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
            nRet = MarcUtil.Xml2Marc(strMarcXml,
                                     true,
                                     "", // this.CurMarcSyntax,
                                     out strOutMarcSyntax,
                                     out strMarc,
                                     out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (this.filter == null)
            {
                string strCfgFilePath = this.BiblioDbName + "/cfgs/html.fltx";
                string strContent     = "";
                // 获得配置文件
                // return:
                //		-1	error
                //		0	not found
                //		1	found
                nRet = this.SearchPanel.GetCfgFile(
                    this.ServerUrl,
                    strCfgFilePath,
                    out strContent,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }
                if (nRet == 0)
                {
                    strError = "在服务器 " + this.ServerUrl + " 上没有找到配置文件 '" + strCfgFilePath + "' ,因此只能以MARC工作单格式显示书目信息...";
                    string strText = strMarc.Replace((char)31, '^');
                    strText         = strText.Replace(new string((char)30, 1), "<br/>");
                    this.HtmlString = strText;
                    goto ERROR1;
                }


                MyFilterDocument tempfilter = null;

                nRet = PrepareMarcFilter(
                    strContent,
                    //Environment.CurrentDirectory + "\\marc.fltx",
                    out tempfilter,
                    out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                this.filter = tempfilter;
            }

            this.ResultString = "";

            // 触发filter中的Record相关动作
            nRet = this.filter.DoRecord(
                null,
                strMarc,
                0,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            this.HtmlString = this.ResultString;

            // 装载册信息
            nRet = LoadItems(this.BiblioRecPath,
                             out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            return(0);

ERROR1:
            return(-1);
        }
Exemple #4
0
        int LoadBiblioRecord(
            string strBiblioRecPath,
            out string strError)
        {
            strError = "";
            this.BiblioRecPath = strBiblioRecPath;

            string strMarcXml = "";
            byte[] baTimeStamp = null;

            int nRet = this.SearchPanel.GetRecord(
                this.ServerUrl,
                this.BiblioRecPath,
                out strMarcXml,
                out baTimeStamp,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            // 转换为MARC格式

            string strOutMarcSyntax = "";
            string strMarc = "";
            // 将MARCXML格式的xml记录转换为marc机内格式字符串
            // parameters:
            //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
            //		strMarcSyntax	指示marc语法,如果=="",则自动识别
            //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
            nRet = MarcUtil.Xml2Marc(strMarcXml,
                true,
                "", // this.CurMarcSyntax,
                out strOutMarcSyntax,
                out strMarc,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            if (this.filter == null)
            {
                string strCfgFilePath = this.BiblioDbName + "/cfgs/html.fltx";
                string strContent = "";
                // 获得配置文件
                // return:
                //		-1	error
                //		0	not found
                //		1	found
                nRet = this.SearchPanel.GetCfgFile(
                    this.ServerUrl,
                    strCfgFilePath,
                    out strContent,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;
                if (nRet == 0)
                {
                    strError = "在服务器 " + this.ServerUrl + " 上没有找到配置文件 '" + strCfgFilePath + "' ,因此只能以MARC工作单格式显示书目信息...";
                    string strText = strMarc.Replace((char)31, '^');
                    strText = strText.Replace(new string((char)30, 1), "<br/>");
                    this.HtmlString = strText;
                    goto ERROR1;
                }


                MyFilterDocument tempfilter = null;

                nRet = PrepareMarcFilter(
                    strContent,
                    //Environment.CurrentDirectory + "\\marc.fltx",
                    out tempfilter,
                    out strError);
                if (nRet == -1)
                    goto ERROR1;

                this.filter = tempfilter;
            }

            this.ResultString = "";

            // 触发filter中的Record相关动作
            nRet = this.filter.DoRecord(
                null,
                strMarc,
                0,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            this.HtmlString = this.ResultString;

            // 装载册信息
            nRet = LoadItems(this.BiblioRecPath,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            return 0;

        ERROR1:
            return -1;
        }