コード例 #1
0
        // 构造operator子树
        // parameters:
        int BldOperator(BerNode param,
                        int nType,
                        string strToken)
        {
            BerNode subparam = null;

            // pSubparam = pParam->NewChildconstructedNode(1,ASN1_CONTEXT);
            // 此层似乎为多余的,试试此语句注释掉以后的效果
            // 2000/11/26 changed


            subparam = param /*pSubparam*/.NewChildConstructedNode(BerTree.z3950_Operator,
                                                                   ASN1_CONTEXT);

            if (nType == TYPE_WITHIN)
            {
                BuildWithin(subparam, strToken);
            }
            else if (nType == TYPE_NEAR)
            {
                BuildNear(subparam, strToken);
            }
            else
            {
                BuildGeneral(subparam, strToken, nType);
            }

            return(0);
        }
コード例 #2
0
        /*
         * 发生未捕获的界面线程异常:
         * Type: System.FormatException
         * Message: 輸入字串格式不正確。
         * Stack:
         * 於 System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
         * 於 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
         * 於 System.Int16.Parse(String s, NumberStyles style, NumberFormatInfo info)
         * 於 System.Convert.ToInt16(String value)
         * 於 DigitalPlatform.Z3950.PolandNode.HandleQuery(BerNode param, BerNode subparam, String strTerm, String strAttrType, String strAttrValue)
         * 於 DigitalPlatform.Z3950.PolandNode.BldAttributesPlusTerm(BerNode param, String strToken)
         * 於 DigitalPlatform.Z3950.PolandNode.BuildOperand(BerNode param, String strToken)
         * 於 DigitalPlatform.Z3950.PolandNode.HandleOperand(String strToken)
         * 於 DigitalPlatform.Z3950.PolandNode.ChangeRPNToTree()
         * 於 DigitalPlatform.Z3950.PolandNode.ChangeOrgToRPN()
         * 於 DigitalPlatform.Z3950.BerTree.make_type_1(String strQuery, Encoding queryTermEncoding, BerNode subroot)
         * 於 DigitalPlatform.Z3950.BerTree.SearchRequest(SEARCH_REQUEST struSearch_request, Byte[]& baPackage)
         * 於 dp2Catalog.ZConnection.DoSearchAsync()
         * 於 dp2Catalog.ZConnection.ZConnection_InitialComplete(Object sender, EventArgs e)
         * 於 dp2Catalog.ZConnection.BeginCommands(List`1 commands)
         * 於 dp2Catalog.ZSearchForm.DoSearchOneServer(TreeNode nodeServerOrDatabase, String& strError)
         * 於 dp2Catalog.ZSearchForm.DoSearch()
         * 於 dp2Catalog.ZSearchForm.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.ContainerControl.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.SplitContainer.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.ContainerControl.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.SplitContainer.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.ContainerControl.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.SplitContainer.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.ContainerControl.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.Control.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.TextBoxBase.ProcessDialogKey(Keys keyData)
         * 於 System.Windows.Forms.Control.PreProcessMessage(Message& msg)
         * 於 System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg)
         * 於 System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)
         *
         * */
        // new version
        // 处理term或AttributesList
        // parameters:
        void HandleQuery(BerNode param,
                         BerNode subparam,
                         string strTerm,
                         string strAttrType,
                         string strAttrValue)
        {
            BerNode seq = null;

            seq = subparam.NewChildConstructedNode(
                ASN1_SEQUENCE,
                ASN1_UNIVERSAL);

            // 处理term、attributeType或attributeValue

            //    处理attributeType
            try
            {
                Int16 i = Convert.ToInt16(strAttrType);

                seq.NewChildIntegerNode(BerTree.z3950_AttributeType,
                                        ASN1_CONTEXT,
                                        BitConverter.GetBytes(i));
            }
            catch (Exception ex)
            {
                throw new Exception("strAttrType = '" + strAttrType + "' 应为数字。", ex);
            }

            //		处理attributeValue
            try
            {
                Int16 i = Convert.ToInt16(strAttrValue);
                seq.NewChildIntegerNode(BerTree.z3950_AttributeValue,
                                        ASN1_CONTEXT,
                                        BitConverter.GetBytes(i));
            }
            catch (Exception ex)
            {
                throw new Exception("strAttrValue = '" + strAttrValue + "' 应为数字。", ex);
            }
            // TODO: 为何这里被调用了两次?

            // term
            {
                BerNode tempnode = param.NewChildCharNode(BerTree.z3950_Term, //	处理term
                                                          ASN1_CONTEXT,
                                                                              //Encoding.GetEncoding(936).GetBytes(strTerm));
                                                          this.m_queryTermEncoding.GetBytes(strTerm));
                tempnode.m_strDebugInfo = "term [" + strTerm + "]";
            }

            // return 0;
        }
コード例 #3
0
        // 当算子为AttributesPlusTerm时
        // parameters:
        // return:
        //		NULL
        //		其他
        int BldAttributesPlusTerm(BerNode param,
                                  string strToken)
        {
            BerNode subparam = null;
            // string strQuery = "";
            int    three        = 3;
            string strTerm      = "";
            string strAttrType  = "";
            string strAttrValue = "";

            param = param.NewChildConstructedNode(BerTree.z3950_AttributesPlusTerm,
                                                  ASN1_CONTEXT);
            subparam = param.NewChildConstructedNode(
                BerTree.z3950_AttributeList,
                ASN1_CONTEXT);

            DivideToken(strToken,
                        out strTerm,
                        out strAttrType,
                        out strAttrValue);

            // 缺省值
            if (strAttrType == "")
            {
                strAttrType = "1";
            }
            if (strAttrValue == "")
            {
                strAttrValue = "4";
            }

            /*
             * strMessage.Format("term[%s] attrtype[%s] attrvalue[%s]",
             *  strTerm,
             *  strAttrType,
             *  strAttrValue);
             */
            try
            {
                HandleQuery(param,
                            subparam,
                            strTerm,
                            strAttrType,
                            strAttrValue);
            }
            catch (Exception ex)
            {
                throw new Exception("BldAttributesPlusTerm() 处理 token '" + strToken + "' 过程中出现异常", ex);
            }

            if (strToken.IndexOf('/', 0) == -1)
            {
                BerNode seq = null;
                seq = subparam.NewChildConstructedNode(
                    ASN1_SEQUENCE,
                    ASN1_UNIVERSAL);
                // TRACE("pSeq->m_uTag=%d",pSeq->m_uTag);
                seq.NewChildIntegerNode(BerTree.z3950_AttributeType,
                                        ASN1_CONTEXT,
                                        BitConverter.GetBytes((Int16)three)); /* position */
                // 一样?
                seq.NewChildIntegerNode(BerTree.z3950_AttributeValue,
                                        ASN1_CONTEXT,
                                        BitConverter.GetBytes((Int16)three)); /* position */
            }

            return(0);
        }
コード例 #4
0
ファイル: Session.cs プロジェクト: renyh1013/dp2
        // 构造NamePlusRecord子树
        // parameters:
        //      node    NamePlusRecord的容器节点。也就是Present Response的根节点
        public void BuildNamePlusRecord(BerNode node)
        {
            if (this.m_external == null
                && this.m_surrogateDiagnostic == null)
                throw new Exception("m_external 和 m_surrogateDiagnostic 不能同时为空");

            if (this.m_external != null
                && this.m_surrogateDiagnostic != null)
                throw new Exception("m_external 和 m_surrogateDiagnostic 不能同时为非空。只能有一个为空");


            BerNode pSequence = node.NewChildConstructedNode(
                BerNode.ASN1_SEQUENCE,    // 16
                BerNode.ASN1_UNIVERSAL);

            // 数据库名
            pSequence.NewChildCharNode(0,
                BerNode.ASN1_CONTEXT,   // ASN1_PRIMITIVE, BUG!!!
                Encoding.UTF8.GetBytes(this.m_strDatabaseName));

            // record(一条记录)
            BerNode nodeRecord = pSequence.NewChildConstructedNode(
                1,
                BerNode.ASN1_CONTEXT);


            if (this.m_external != null)
            {
                // extenal
                BerNode nodeRetrievalRecord = nodeRecord.NewChildConstructedNode(
                    1,
                    BerNode.ASN1_CONTEXT);

                // real extenal!
                BerNode nodeExternal = nodeRetrievalRecord.NewChildConstructedNode(
                    8,  // UNI_EXTERNAL
                    BerNode.ASN1_UNIVERSAL);

                // TODO: 和前一条重复的库名和marc syntax oid可以省略?

                Debug.Assert(String.IsNullOrEmpty(this.m_external.m_strDirectRefenerce) == false, "");

                nodeExternal.NewChildOIDsNode(6,   // UNI_OBJECTIDENTIFIER,
                    BerNode.ASN1_UNIVERSAL,
                    this.m_external.m_strDirectRefenerce);

                // 1 条 MARC 记录
                nodeExternal.NewChildCharNode(1,
                    BerNode.ASN1_CONTEXT,
                    this.m_external.m_octectAligned);
            }

            // 如果获得MARC记录出错,则这里要创建SurrogateDiagnostic record
            if (this.m_surrogateDiagnostic != null)
            {
                BerNode nodeSurrogateDiag = nodeRecord.NewChildConstructedNode(
                    2,
                    BerNode.ASN1_CONTEXT);

                BerNode nodeDiagRoot = nodeSurrogateDiag.NewChildConstructedNode(
                    BerNode.ASN1_SEQUENCE, // sequence
                    BerNode.ASN1_UNIVERSAL);

                this.m_surrogateDiagnostic.BuildBer(nodeDiagRoot);

                /*
                nodeDiagRoot.NewChildOIDsNode(6,
                    BerNode.ASN1_UNIVERSAL,
                    this.m_surrogateDiagnostic.m_strDiagSetID);   // "1.2.840.10003.4.1"

                nodeDiagRoot.NewChildIntegerNode(2,
                    BerNode.ASN1_UNIVERSAL,
                    BitConverter.GetBytes((long)this.m_surrogateDiagnostic.m_nDiagCondition));

                if (String.IsNullOrEmpty(this.m_surrogateDiagnostic.m_strAddInfo) == false)
                {
                    nodeDiagRoot.NewChildCharNode(26,
                        BerNode.ASN1_UNIVERSAL,
                        Encoding.UTF8.GetBytes(this.m_surrogateDiagnostic.m_strAddInfo));
                }
                 * */


            }

        }