Ejemplo n.º 1
0
        // 默认的请求处理过程。应可以被重新指定
        // 下级函数,例如处理 Initialize Search Present 的函数,还可以被重新指定
        public async Task <byte[]> DefaultProcessRequest(ZServerChannel channel,
                                                         BerTree request)
        {
            BerNode root = request.GetAPDuRoot();

            switch (root.m_uTag)
            {
            case BerTree.z3950_initRequest:
                if (this.ProcessInitialize == null)
                {
                    return(await DefaultProcessInitialize(channel, request).ConfigureAwait(false));      // 2018/10/10 add configure
                }
                else
                {
                    ProcessInitializeEventArgs e = new ProcessInitializeEventArgs();
                    e.Request = request;
                    this.ProcessInitialize(channel, e);
                    return(e.Response);
                }
                break;

            case BerTree.z3950_searchRequest:
                if (this.ProcessSearch == null)
                {
                    return(await DefaultProcessSearch(channel, request).ConfigureAwait(false));    // 2018/10/10 add configure
                }
                else
                {
                    ProcessSearchEventArgs e = new ProcessSearchEventArgs();
                    e.Request = request;
                    this.ProcessSearch(channel, e);
                    return(e.Response);
                }
                break;

            case BerTree.z3950_presentRequest:
                if (this.ProcessPresent == null)
                {
                    return(await DefaultProcessPresent(channel, request).ConfigureAwait(false));    // 2018/10/10 add configure
                }
                else
                {
                    ProcessPresentEventArgs e = new ProcessPresentEventArgs();
                    e.Request = request;
                    this.ProcessPresent(channel, e);
                    return(e.Response);
                }
                break;
            }

            return(new byte[0]);
            // TODO 如果将来嫌日志中记载 BerNode Dump 结果体积太大,Dump 结果可以考虑不进入日志
            //string text = JsonConvert.SerializeObject(root, Formatting.Indented);
            //throw new UnknownApduException(string.Format("无法识别的 APDU tag[{0}]\r\nBerNode={1}", root.m_uTag, text));
        }
Ejemplo n.º 2
0
        // 默认的请求处理过程。应可以被重新指定
        // 下级函数,例如处理 Initialize Search Present 的函数,还可以被重新指定
        public async Task <byte[]> DefaultProcessRequest(ZServerChannel channel,
                                                         BerTree request)
        {
            BerNode root = request.GetAPDuRoot();

            switch (root.m_uTag)
            {
            case BerTree.z3950_initRequest:
                if (this.ProcessInitialize == null)
                {
                    return(await DefaultProcessInitialize(channel, request));
                }
                else
                {
                    ProcessInitializeEventArgs e = new ProcessInitializeEventArgs();
                    e.Request = request;
                    this.ProcessInitialize(channel, e);
                    return(e.Response);
                }
                break;

            case BerTree.z3950_searchRequest:
                if (this.ProcessSearch == null)
                {
                    return(await DefaultProcessSearch(channel, request));
                }
                else
                {
                    ProcessSearchEventArgs e = new ProcessSearchEventArgs();
                    e.Request = request;
                    this.ProcessSearch(channel, e);
                    return(e.Response);
                }
                break;

            case BerTree.z3950_presentRequest:
                if (this.ProcessPresent == null)
                {
                    return(await DefaultProcessPresent(channel, request));
                }
                else
                {
                    ProcessPresentEventArgs e = new ProcessPresentEventArgs();
                    e.Request = request;
                    this.ProcessPresent(channel, e);
                    return(e.Response);
                }
                break;
            }
            return(new byte[0]);
        }