示例#1
0
        public override int VerifyItem(
    LibraryHost host,
    string strAction,
    XmlDocument itemdom,
    out string strError)
        {
            strError = "";

            // 执行函数
            try
            {
                return host.VerifyIssue(strAction,
                    itemdom,
                    out strError);
            }
            catch (Exception ex)
            {
                strError = "执行脚本函数 '" + "VerifyIssue" + "' 时出错:" + ex.Message;
                return -1;
            }

            return 0;
        }
示例#2
0
        // 执行脚本函数VerifyBarcode
        // parameters:
        //      host    如果为空,则函数内部会 new 一个此类型的对象;如果不为空,则直接使用
        //      strLibraryCodeList  当前操作者管辖的馆代码列表 2014/9/27
        // return:
        //      -2  not found script
        //      -1  出错
        //      0   成功
        public int DoVerifyBarcodeScriptFunction(
            LibraryHost host,
            string strLibraryCodeList,
            string strBarcode,
            out int nResultValue,
            out string strError)
        {
            strError = "";
            nResultValue = -1;

            if (this.m_strAssemblyLibraryHostError != "")
            {
                strError = this.m_strAssemblyLibraryHostError;
                return -1;
            }

            if (this.m_assemblyLibraryHost == null)
            {
                strError = "未定义<script>脚本代码,无法校验条码号。";
                return -2;
            }

            Type hostEntryClassType = ScriptManager.GetDerivedClassType(
                this.m_assemblyLibraryHost,
                "DigitalPlatform.LibraryServer.LibraryHost");
            if (hostEntryClassType == null)
            {
                strError = "<script>脚本中未找到DigitalPlatform.LibraryServer.LibraryHost类的派生类,无法校验条码号。";
                return -2;
            }

            // 迟绑定技术。从assembly中实时寻找特定名字的函数
            // TODO: 如果两个版本的函数都定义了,会发生什么?
            MethodInfo mi = hostEntryClassType.GetMethod("VerifyBarcode");
            if (mi == null)
            {
                strError = "<script>脚本中DigitalPlatform.LibraryServer.LibraryHost类的派生类中,没有提供int VerifyBarcode(string strBarcode, out string strError)函数,因此无法校验条码号。";
                return -2;
            }

            if (host == null)
            {
                host = (LibraryHost)hostEntryClassType.InvokeMember(null,
                    BindingFlags.DeclaredOnly |
                    BindingFlags.Public | BindingFlags.NonPublic |
                    BindingFlags.Instance | BindingFlags.CreateInstance, null, null,
                    null);
                if (host == null)
                {
                    strError = "创建DigitalPlatform.LibraryServer.LibraryHost类的派生类的对象(构造函数)失败。";
                    return -1;
                }

                host.App = this;
            }

            ParameterInfo[] parameters = mi.GetParameters();

            // 执行函数
            try
            {
                if (parameters.Length == 2)
                {
                    object[] args = new object[2];
                    args[0] = strBarcode;
                    args[1] = strError;
                    nResultValue = (int)mi.Invoke(host,
                         BindingFlags.DeclaredOnly |
                         BindingFlags.Public | BindingFlags.NonPublic |
                         BindingFlags.Instance | BindingFlags.InvokeMethod,
                         null,
                         args,
                         null);

                    // 取出out参数值
                    strError = (string)args[1];
                }
                else if (parameters.Length == 3)
                {
                    object[] args = new object[3];
                    args[0] = strLibraryCodeList;
                    args[1] = strBarcode;
                    args[2] = strError;
                    nResultValue = (int)mi.Invoke(host,
                         BindingFlags.DeclaredOnly |
                         BindingFlags.Public | BindingFlags.NonPublic |
                         BindingFlags.Instance | BindingFlags.InvokeMethod,
                         null,
                         args,
                         null);

                    // 取出out参数值
                    strError = (string)args[2];
                }
                else
                {
                    strError = "脚本函数 VerifyBarcode() 的参数个数不正确,应该为 2 或者 3 个";
                    return -1;
                }
            }
            catch (Exception ex)
            {
                strError = "执行脚本函数'" + "VerifyBarcode" + "'出错:" + ExceptionUtil.GetDebugText(ex);
                return -1;
            }

            return 0;
        }
示例#3
0
        // return:
        //      -1  调用出错
        //      0   校验正确
        //      1   校验发现错误
        public virtual int VerifyItem(
            LibraryHost host,
            string strAction,
            XmlDocument itemdom,
            out string strError)
        {
            strError = "";

            return 0;
        }
示例#4
0
        public override int VerifyItem(
LibraryHost host,
string strAction,
XmlDocument itemdom,
out string strError)
        {
            strError = "";

            // 执行函数
            try
            {
                return host.VerifyComment(strAction,
                    itemdom,
                    out strError);
            }
            catch (Exception ex)
            {
                strError = "执行脚本函数 '" + "VerifyComment" + "' 时出错:" + ExceptionUtil.GetDebugText(ex);
                return -1;
            }

            return 0;
        }