Beispiel #1
0
        // 将读者记录数据从XML格式转换为HTML格式
        // parameters:
        //      strRecPath  读者记录路径 2009/10/18
        //      strLibraryCode  读者记录所从属的读者库的馆代码
        //      strResultType  细节格式。为了 '|' 间隔的若干名称字符串
        public int ConvertReaderXmlToHtml(
            SessionInfo sessioninfo,
            string strCsFileName,
            string strRefFileName,
            string strLibraryCode,
            string strXml,
            string strRecPath,
            OperType opertype,
            string[] saBorrowedItemBarcode,
            string strCurrentItemBarcode,
            string strResultType,
            out string strResult,
            out string strError)
        {
            strResult = "";
            strError  = "";
            int nRet = 0;

            // TODO: ParseTwoPart
            string strSubType = "";

            nRet = strResultType.IndexOf(":");
            if (nRet != -1)
            {
                strSubType = strResultType.Substring(nRet + 1).Trim();
            }

            LibraryApplication app = this;

            // 转换为html格式
            Assembly assembly = null;

            nRet = app.GetXml2HtmlAssembly(
                strCsFileName,
                strRefFileName,
                app.BinDir,
                out assembly,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            // 得到Assembly中Converter派生类Type
            Type entryClassType = ScriptManager.GetDerivedClassType(
                assembly,
                "DigitalPlatform.LibraryServer.ReaderConverter");

            if (entryClassType == null)
            {
                strError = "从DigitalPlatform.LibraryServer.ReaderConverter派生的类 type entry not found";
                goto ERROR1;
            }

            // new一个Converter派生对象
            ReaderConverter obj = (ReaderConverter)entryClassType.InvokeMember(null,
                                                                               BindingFlags.DeclaredOnly |
                                                                               BindingFlags.Public | BindingFlags.NonPublic |
                                                                               BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                                                                               null);

            // 为Converter派生类设置参数
            // obj.MainForm = this;
            obj.BorrowedItemBarcodes = saBorrowedItemBarcode;
            obj.CurrentItemBarcode   = strCurrentItemBarcode;
            obj.OperType             = opertype;
            obj.App         = app;
            obj.SessionInfo = sessioninfo;
            obj.RecPath     = strRecPath;
            obj.LibraryCode = strLibraryCode;   // 2012/9/8
            obj.Formats     = strSubType.Replace("|", ",");

            // 调用关键函数Convert
            try
            {
                strResult = obj.Convert(strXml);
            }
            catch (Exception ex)
            {
                strError = "脚本执行时抛出异常: " + ExceptionUtil.GetDebugText(ex);
                goto ERROR1;
            }

            return(0);

ERROR1:
            return(-1);
        }
Beispiel #2
0
        // 将一般库记录数据从XML格式转换为HTML格式
        // parameters:
        //      strRecPath  记录路径。用途是为了给宿主对象的RecPath成员赋值  // 2009/10/18
        // return:
        //      -2  基类为ReaderConverter
        public int ConvertRecordXmlToHtml(
            string strCsFileName,
            string strRefFileName,
            string strXml,
            string strRecPath,
            out string strResult,
            out string strError)
        {
            strResult = "";
            strError  = "";

            LibraryApplication app = this;

            // 转换为html格式
            Assembly assembly = null;
            int      nRet     = app.GetXml2HtmlAssembly(
                strCsFileName,
                strRefFileName,
                app.BinDir,
                out assembly,
                out strError);

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

            // 得到Assembly中RecordConverter派生类Type
            Type entryClassType = ScriptManager.GetDerivedClassType(
                assembly,
                "DigitalPlatform.LibraryServer.RecordConverter");

            if (entryClassType == null)
            {
                // 当没有找到RecordConverter的派生类时,
                // 继续从代码中找一下有没有ReaderConverter的派生类,如果有,则返回-2,这样函数返回后就为调主多提供了一点信息,便于后面继续处理
                entryClassType = ScriptManager.GetDerivedClassType(
                    assembly,
                    "DigitalPlatform.LibraryServer.ReaderConverter");
                if (entryClassType == null)
                {
                    strError = "从DigitalPlatform.LibraryServer.RecordConverter派生的类 type entry not found";
                    goto ERROR1;
                }

                return(-2);
            }

            // new一个RecordConverter派生对象
            RecordConverter obj = (RecordConverter)entryClassType.InvokeMember(null,
                                                                               BindingFlags.DeclaredOnly |
                                                                               BindingFlags.Public | BindingFlags.NonPublic |
                                                                               BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                                                                               null);

            // 为RecordConverter派生类设置参数
            obj.App     = app;
            obj.RecPath = strRecPath;


            // 调用关键函数Convert
            try
            {
                strResult = obj.Convert(strXml);
            }
            catch (Exception ex)
            {
                strError = "脚本执行时抛出异常: " + ExceptionUtil.GetDebugText(ex);
                goto ERROR1;
            }

            return(0);

ERROR1:
            return(-1);
        }