Ejemplo n.º 1
0
Archivo: MyForm.cs Proyecto: gvhung/dp2
        // 创建MARC格式记录的浏览格式
        // paramters:
        //      strMARC MARC机内格式
        public int BuildMarcBrowseText(
            string strMarcSyntax,
            string strMARC,
            out string strBrowseText,
            out string strColumnTitles,
            out string strError)
        {
            strBrowseText   = "";
            strError        = "";
            strColumnTitles = "";

            FilterHost host = new FilterHost();

            host.ID       = "";
            host.MainForm = this.MainForm;

            BrowseFilterDocument filter = null;

            string strFilterFileName = Path.Combine(this.MainForm.DataDir, strMarcSyntax.Replace(".", "_") + "_cfgs\\marc_browse.fltx");

            int nRet = this.PrepareMarcFilter(
                host,
                strFilterFileName,
                out filter,
                out strError);

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

            try
            {
                nRet = filter.DoRecord(null,
                                       strMARC,
                                       0,
                                       out strError);
                if (nRet == -1)
                {
                    goto ERROR1;
                }

                strBrowseText   = host.ResultString;
                strColumnTitles = host.ColumnTitles;
            }
            finally
            {
                // 归还对象
                filter.FilterHost = null;   // 2016/1/23
                this.MainForm.Filters.SetFilter(strFilterFileName, filter);
            }

            return(0);

ERROR1:
            return(-1);
        }
Ejemplo n.º 2
0
        public int PrepareMarcFilter(
FilterHost host,
string strFilterFileName,
out BrowseFilterDocument filter,
out string strError)
        {
            strError = "";

            // 看看是否有现成可用的对象
            filter = (BrowseFilterDocument)this.MainForm.Filters.GetFilter(strFilterFileName);

            if (filter != null)
            {
                filter.FilterHost = host;
                return 1;
            }

            // 新创建
            // string strFilterFileContent = "";

            filter = new BrowseFilterDocument();

            filter.FilterHost = host;
            filter.strOtherDef = "FilterHost Host = null;";

            filter.strPreInitial = " BrowseFilterDocument doc = (BrowseFilterDocument)this.Document;\r\n";
            filter.strPreInitial += " Host = ("
                + "FilterHost" + ")doc.FilterHost;\r\n";

            // filter.Load(strFilterFileName);

            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 strBinDir = Environment.CurrentDirectory;

            string[] saAddRef1 = {
										 strBinDir + "\\digitalplatform.marcdom.dll",
										 // this.BinDir + "\\digitalplatform.marckernel.dll",
										 // this.BinDir + "\\digitalplatform.libraryserver.dll",
										 strBinDir + "\\digitalplatform.dll",
										 strBinDir + "\\digitalplatform.Text.dll",
										 strBinDir + "\\digitalplatform.IO.dll",
										 strBinDir + "\\digitalplatform.Xml.dll",
										 strBinDir + "\\dp2circulation.exe" };

            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
            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;
        }
Ejemplo n.º 3
0
        // 创建MARC格式记录的浏览格式
        // paramters:
        //      strMARC MARC机内格式
        public int BuildMarcBrowseText(
            string strMarcSyntax,
            string strMARC,
            out string strBrowseText,
            out string strError)
        {
            strBrowseText = "";
            strError = "";

            FilterHost host = new FilterHost();
            host.ID = "";
            host.MainForm = this.MainForm;

            BrowseFilterDocument filter = null;

            string strFilterFileName = Path.Combine(this.MainForm.DataDir, strMarcSyntax.Replace(".", "_") + "_cfgs\\marc_browse.fltx");

            int nRet = this.PrepareMarcFilter(
                host,
                strFilterFileName,
                out filter,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            try
            {
                nRet = filter.DoRecord(null,
        strMARC,
        0,
        out strError);
                if (nRet == -1)
                    goto ERROR1;

                strBrowseText = host.ResultString;

            }
            finally
            {
                // 归还对象
                this.MainForm.Filters.SetFilter(strFilterFileName, filter);
            }

            return 0;
        ERROR1:
            return -1;
        }
Ejemplo n.º 4
0
Archivo: MyForm.cs Proyecto: gvhung/dp2
        public int PrepareMarcFilter(
            FilterHost host,
            string strFilterFileName,
            out BrowseFilterDocument filter,
            out string strError)
        {
            strError = "";

            // 看看是否有现成可用的对象
            filter = (BrowseFilterDocument)this.MainForm.Filters.GetFilter(strFilterFileName);

            if (filter != null)
            {
                filter.FilterHost = host;
                return(1);
            }

            // 新创建
            // string strFilterFileContent = "";

            filter = new BrowseFilterDocument();

            filter.FilterHost  = host;
            filter.strOtherDef = "FilterHost Host = null;";

            filter.strPreInitial  = " BrowseFilterDocument doc = (BrowseFilterDocument)this.Document;\r\n";
            filter.strPreInitial += " Host = ("
                                    + "FilterHost" + ")doc.FilterHost;\r\n";

            // filter.Load(strFilterFileName);

            try
            {
                filter.Load(strFilterFileName);
            }
            catch (Exception ex)
            {
                strError = "MyForm filter.Load() exception: " + ExceptionUtil.GetAutoText(ex);
                return(-1);
            }

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

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

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

            string strBinDir = Environment.CurrentDirectory;

            string[] saAddRef1 =
            {
                strBinDir + "\\digitalplatform.marcdom.dll",
                // this.BinDir + "\\digitalplatform.marckernel.dll",
                // this.BinDir + "\\digitalplatform.libraryserver.dll",
                strBinDir + "\\digitalplatform.dll",
                strBinDir + "\\digitalplatform.Text.dll",
                strBinDir + "\\digitalplatform.IO.dll",
                strBinDir + "\\digitalplatform.Xml.dll",
                strBinDir + "\\dp2circulation.exe"
            };

            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
            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);
        }