Beispiel #1
0
 public bool DisplayBrowseItems(ZConnection connection,
     bool bTriggerSelChanged = false)
 {
     object[] pList = { connection, bTriggerSelChanged };
     return (bool)this.Invoke(
         new ZSearchForm.Delegate_DisplayBrowseItems(__DisplayBrowseItems), pList);
 }
Beispiel #2
0
        // 显示MessageBox()
        // 函数会自动判断,只有当前ZConnection才会显示出来
        bool __ShowMessageBox(ZConnection connection,
            string strText)
        {
            if (connection == this.GetCurrentZConnection())
            {
                MessageBox.Show(this, strText);
                return true;    // 被显示了
            }

            return false;   // 没有被显示
        }
Beispiel #3
0
        /*
        void LinkRecordsToListView(RecordCollection records)
        {
            this.CurrentRecords = records;

            if (this.CurrentRecords != null)
                this.listView_browse.VirtualListSize = this.CurrentRecords.Count;
            else
                this.listView_browse.VirtualListSize = 0;

            // 迫使刷新
            this.listView_browse.Invalidate();
        }*/

#if NOOOOOOOOOOOOOOOOOOOOO
        // 把存储在records结构中的信息填入listview
        // parameters:
        int FillRecordsToBrowseView(
            Stop stop,
            ZConnection connection,
            RecordCollection records,
            int nStart,
            int nCount,
            out string strError)
        {
            strError = "";

            if (records == null)
                return 0;

            if (nStart + nCount > records.Count)
            {
                strError = "nStart["+nStart.ToString()+"]和nCount["+nCount.ToString()+"]参数之和超出records集合的尺寸["+records.Count.ToString()+"]";
                return -1;
            }

            for (int i = nStart; i < nStart + nCount; i++)
            {
                Application.DoEvents();	// 出让界面控制权

                if (stop != null)
                {
                    if (stop.State != 0)
                    {
                        strError = "用户中断";
                        return -1;
                        // TODO: 中断后怎么办?似最后一条记录不代表Records中的最后了
                    }
                }

                DigitalPlatform.Z3950.Record record = records[i];

                ListViewItem item = new ListViewItem(
                    (nStart + i + 1).ToString(),
                    record.m_nDiagCondition == 0 ? BROWSE_TYPE_NORMAL : BROWSE_TYPE_DIAG);

                string strBrowseText = "";

                int nRet = 0;
                string[] cols = null;

                if (record.m_nDiagCondition != 0)
                {
                    strBrowseText = "诊断记录 condition=" + record.m_nDiagCondition.ToString() + "; addinfo=\"" + record.m_strAddInfo + "\"; diagSetOID=" + record.m_strDiagSetID;
                    goto DOADD;
                }
                else
                {
                    byte[] baRecord = record.m_baRecord;    //Encoding.ASCII.GetBytes(record.m_strRecord);

                    string strMARC = "";
                    string strMarcSyntaxOID = "";

                    // 可能为XML格式
                    if (record.m_strMarcSyntaxOID == "1.2.840.10003.5.109.10")
                    {
                        // 看根节点的名字空间,如果符合MARCXML, 就先转换为USMARC,否则,就直接根据名字空间找样式表加以转换
                        string strContent = Encoding.UTF8.GetString(baRecord);

                        string strNameSpaceUri = "";
                        nRet = GetRootNamespace(strContent,
                            out strNameSpaceUri,
                            out strError);
                        if (nRet == -1)
                        {
                            strBrowseText = strError;
                            goto DOADD;
                        }

                        if (strNameSpaceUri == Ns.usmarcxml)
                        {
                            string strOutMarcSyntax = "";
                            // 将MARCXML格式的xml记录转换为marc机内格式字符串
                            // parameters:
                            //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
                            //		strMarcSyntax	指示marc语法,如果=="",则自动识别
                            //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
                            nRet = MarcUtil.Xml2Marc(strContent,
                                true,
                                "usmarc",
                                out strOutMarcSyntax,
                                out strMARC,
                                out strError);
                            if (nRet == -1)
                            {
                                strBrowseText = strError;
                                goto DOADD;
                            }

                            strMarcSyntaxOID = "1.2.840.10003.5.10";

                            nRet = GetBrowseText(
                                strMarcSyntaxOID,
                                strMARC,
                                out strBrowseText,
                                out strError);
                            if (nRet == -1)
                                strBrowseText = strError;

                            goto DOADD;

                        }

                        cols = new string[1];
                        cols[0] = strContent;
                        goto DOADDCOLS;
                    }

                    strMarcSyntaxOID = record.m_strMarcSyntaxOID;

                    // ISO2709转换为机内格式
                    nRet = Marc8Encoding.ConvertByteArrayToMarcRecord(
                        baRecord,
                        connection.GetRecordsEncoding(this.MainForm, strMarcSyntaxOID),  // Encoding.GetEncoding(936),
                        true,
                        out strMARC,
                        out strError);
                    if (nRet < 0)
                    {
                        strBrowseText = strError;
                        goto DOADD;
                    }


                    if (connection.TargetInfo.DetectMarcSyntax == true)
                    {
                        // 探测MARC记录从属的格式:
                        // return:
                        //		-1	无法探测
                        //		1	UNIMARC	规则:包含200字段
                        //		10	USMARC	规则:包含008字段(innopac的UNIMARC格式也有一个奇怪的008)
                        nRet = DetectMARCSyntax(strMARC);
                        if (nRet == 1)
                            strMarcSyntaxOID = "1.2.840.10003.5.1";
                        else if (nRet == 10)
                            strMarcSyntaxOID = "1.2.840.10003.5.10";

                        // 把自动识别的结果保存下来
                        record.AutoDetectedMarcSyntaxOID = strMarcSyntaxOID;
                    }


                    nRet = GetBrowseText(
                        strMarcSyntaxOID,
                        strMARC,
                        out strBrowseText,
                        out strError);
                    if (nRet == -1)
                        strBrowseText = strError;


                }

            DOADD:
                cols = strBrowseText.Split(new char[] { '\t' });
            DOADDCOLS:
                for (int j = 0; j < cols.Length; j++)
                {
                    item.SubItems.Add(cols[j]);
                }

                item.Tag = record;
                this.listView_browse.Items.Add(item);
            }
            return 0;
        }
Beispiel #4
0
        void Stop_OnEndLoop(object sender, EndLoopEventArgs e)
        {
            lock (this)
            {
                this.m_nCompleteServerCount++;
            }

            ZConnection connection = this.ZConnections.FindZConnection((Stop)sender);
            int nResultCount = Math.Max(0, connection.ResultCount);
            this.m_nTotalHitCount += nResultCount;

            this.m_connectionDir.ResultCount = this.m_nTotalHitCount;
            this.m_connectionDir.ShowQueryResultInfo("命中结果总数: " + this.m_nTotalHitCount.ToString()
                + (this.m_nCompleteServerCount == this.m_nServerCount ? "" : "..."));

            this.m_stopDir.SetMessage("正在检索。已完成检索的服务器数 " + this.m_nCompleteServerCount.ToString() + " (参与检索服务器总数 " + this.m_nServerCount.ToString() + ")...");

            // 最后一次OnEnd触发
            if (this.m_nCompleteServerCount == this.m_nServerCount)
            {
                this.m_connectionDir.EnableControls(true);

                this.m_stopDir.EndLoop();
                this.m_stopDir.OnStop -= new StopEventHandler(m_stopDir_OnStop);
                // this.m_stopDir.Initial("");

                // 收尾
                this.m_connectionDir = null;
                this.m_stopDir = null;
                this.m_nTotalHitCount = 0;
                this.m_nCompleteServerCount = 0;
                this.m_nServerCount = 0;

                // 解挂全部事件
                for (int i = 0; i < this.m_stops.Count; i++)
                {
                    Stop stop = this.m_stops[i];

                    stop.OnBeginLoop -= new BeginLoopEventHandler(Stop_OnBeginLoop);
                    stop.OnEndLoop -= new EndLoopEventHandler(Stop_OnEndLoop);
                }

                this.m_stops.Clear();
            }
        }
Beispiel #5
0
        // 结果集追加到listview中
        // parameters:
        //      records 当前新获得一批记录。需要追加到connection的Records中
        int FillRecordsToBrowseView(
            Stop stop,
            ZConnection connection,
            RecordCollection records,
            out string strError)
        {

            Debug.Assert(connection == this.GetCurrentZConnection(), "不是当前connection,装入listview会破坏界面");

            strError = "";
            if (connection.Records == null)
                connection.Records = new RecordCollection();

            int nExistCount = connection.Records.Count;
            Debug.Assert(this.listView_browse.Items.Count == nExistCount, "");

            // 加入新的一批
            connection.Records.AddRange(records);

            int nRet = FillRecordsToBrowseView(
                stop,
                connection,
                connection.Records,
                nExistCount,
                records.Count,
                out strError);
            if (nRet == -1)
                return -1;

            return 0;
        }
Beispiel #6
0
        public int NextBatch(ZConnection connection)
        {
            string strError = "";
            int nRet = 0;

            // 新装入一批记录
            int nCount = Math.Min(connection.TargetInfo.PresentPerBatchCount,
                connection.ResultCount - this.listView_browse.Items.Count);

            if (nCount <= 0)
            {
                // 没有必要么
                strError = "命中结果已经全部获取完毕。";
                goto ERROR1;
            }

            // ZConnection connection = this.GetCurrentZConnection();

            connection.Stop.OnStop += new StopEventHandler(this.DoStop);
            connection.Stop.SetMessage("从服务器装入记录 ...");
            connection.Stop.BeginLoop();

            EnableControls(false);

            this.Update();
            this.MainForm.Update();

            try
            {

                string strElementSetName = ZTargetControl.GetLeftValue(this.comboBox_elementSetName.Text);  // this.CurrentTargetInfo.DefaultElementSetName;

                if (strElementSetName == "B"
                    && connection.TargetInfo.FirstFull == true)
                    strElementSetName = "F";

                RecordCollection records = null;

                nRet = DoPresent(
                    connection,
                    connection.TargetInfo.DefaultResultSetName,
                    this.listView_browse.Items.Count, // nStart,
                    nCount, // nCount,
                    strElementSetName,    // "F" strElementSetName,
                    ZTargetControl.GetLeftValue(this.comboBox_recordSyntax.Text), // this.CurrentTargetInfo.PreferredRecordSyntax,
                    out records,
                    out strError);
                if (nRet == -1)
                {
                    strError = "从 " + this.listView_browse.Items.Count.ToString()
                        + " 开始装入新的一批记录时出错:" + strError;
                    goto ERROR1;
                }
                else
                {
                    nRet = FillRecordsToBrowseView(
                        connection.Stop,
                        connection,
                        records,
                        out strError);
                    if (nRet == -1)
                        goto ERROR1;
                }
            }
            finally
            {
                connection.Stop.EndLoop();
                connection.Stop.OnStop -= new StopEventHandler(this.DoStop);
                connection.Stop.Initial("");

                EnableControls(true);
            }

            return 0;
        ERROR1:
            MessageBox.Show(this, strError);
            return -1;
        }
Beispiel #7
0
        // return:
        //		-1	error
        //		0	fail
        //		1	succeed
        int DoSearch(
            ZConnection connection,
            string strQuery,
            Encoding queryTermEncoding,
            string[] dbnames,
            string strResultSetName,
            out int nResultCount,
            out string strError)
        {
            strError = "";

            BerTree tree = new BerTree();
            SEARCH_REQUEST struSearch_request = new SEARCH_REQUEST();
            byte[] baPackage = null;
            int nRet;
            int nRecvLen;
            //int nMax;
            //int i;



            // -->
            BerTree tree1 = new BerTree();
            int nTotlen = 0;


            nResultCount = 0;

            struSearch_request.m_dbnames = dbnames;

            Debug.Assert(struSearch_request.m_dbnames.Length != 0, "");

            struSearch_request.m_strReferenceId = this.CurrentRefID;
            struSearch_request.m_lSmallSetUpperBound = 0;
            struSearch_request.m_lLargeSetLowerBound = 1;
            struSearch_request.m_lMediumSetPresentNumber = 0;
            struSearch_request.m_nReplaceIndicator = 1;
            struSearch_request.m_strResultSetName = strResultSetName;   // "default";
            struSearch_request.m_strSmallSetElementSetNames = "";
            struSearch_request.m_strMediumSetElementSetNames = "";
            struSearch_request.m_strPreferredRecordSyntax = ZTargetControl.GetLeftValue(this.comboBox_recordSyntax.Text);    //  this.CurrentTargetInfo.PreferredRecordSyntax;   // BerTree.MARC_SYNTAX;
            struSearch_request.m_strQuery = strQuery;
            struSearch_request.m_nQuery_type = 1;
            struSearch_request.m_queryTermEncoding = queryTermEncoding;
           

            // m_search_response.m_lErrorCode = 0;

            nRet = tree.SearchRequest(struSearch_request,
                out baPackage);

            if (nRet == -1)
            {
                strError = "CBERTree::SearchRequest() fail!";
                return -1;
            }
#if NOTCPIP
	if (m_hSocket == INVALID_SOCKET) {
		strError = "socket已经关闭!";
		return -1;
	}
#endif


            #if DUMPTOFILE
            string strBinFile = this.MainForm.DataDir + "\\searchrequest.bin";
            File.Delete(strBinFile);
            DumpPackage(strBinFile,
                baPackage);
            string strLogFile = this.MainForm.DataDir + "\\searchrequest.txt";
            File.Delete(strLogFile);
            tree.m_RootNode.DumpToFile(strLogFile);
            #endif



            nRet = CheckConnect(
                connection,
                out strError);
            if (nRet == -1)
                return -1;

            /*
            nRet = this.ZChannel.SendTcpPackage(
                baPackage,
                baPackage.Length,
                out strError);
            if (nRet == -1 || nRet == 1)
            {
                // CloseZAssociation();
                return -1;
            }
            //AfxMessageBox("发送成功");


            baPackage = null;
            nRet = this.ZChannel.RecvTcpPackage(
                        out baPackage,
                        out nRecvLen,
                        out strError);
            if (nRet == -1)
            {
                // CloseZAssociation();
                return -1;
            }
             * */

            byte [] baOutPackage = null;
            nRet = connection.ZChannel.SendAndRecv(
                baPackage,
                out baOutPackage,
                out nRecvLen,
                out strError);
            if (nRet == -1)
                return -1;

#if DEBUG
            if (nRet == 0)
            {
                Debug.Assert(strError == "", "");
            }
#endif

#if DUPMTOFILE
	DeleteFile("searchresponse.bin");
	DumpPackage("searchresponse.bin",
				(char *)baOutPackage.GetData(),
				baOutPackage.GetSize());
#endif

            tree1.m_RootNode.BuildPartTree(baOutPackage,
                0,
                baOutPackage.Length,
                out nTotlen);

            SEARCH_RESPONSE search_response = new SEARCH_RESPONSE();
            nRet = BerTree.GetInfo_SearchResponse(tree1.GetAPDuRoot(),
                                   ref search_response,
                                   true,
                                   out strError);
            if (nRet == -1)
                return -1;

#if DUMPTOFILE
	DeleteFile("SearchResponse.txt"); 
	tree1.m_RootNode.DumpDebugInfoToFile("SearchResponse.txt");
#endif
            /*
	nRet = FitDebugInfo_SearchResponse(&tree1,
							  strError);
	if (nRet == -1) {
		AfxMessageBox(strError);
		return;
	}
	*/
            nResultCount = (int)search_response.m_lResultCount;

            if (search_response.m_nSearchStatus != 0)	// 不一定是1
                return 1;

            strError = "Search Fail: diagRecords:\r\n" + search_response.m_diagRecords.GetMessage();
            return 0;	// search fail
        }
Beispiel #8
0
        /*
发生未捕获的异常: 
Type: System.ObjectDisposedException
Message: 無法存取已處置的物件。
物件名稱: 'ZSearchForm'。
Stack:
於 System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
於 System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
於 dp2Catalog.ZSearchForm.ShowQueryResultInfo(ZConnection connection, String strText)
於 dp2Catalog.ZConnection.ShowQueryResultInfo(String strText)
於 dp2Catalog.ZConnection.ZConnection_CommandsComplete(Object sender, EventArgs e)
於 dp2Catalog.ZConnection.ZConnection_PresentComplete(Object sender, EventArgs e)
於 dp2Catalog.ZConnection.ZChannel_present_SendRecvComplete(Object sender, EventArgs e)
於 DigitalPlatform.Z3950.ZChannel.RecvCallback(IAsyncResult ar)
於 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
於 System.Net.ContextAwareResult.CompleteCallback(Object state)
於 System.Threading.ExecutionContext.runTryCode(Object userData)
於 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
於 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
於 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
於 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
於 System.Net.ContextAwareResult.Complete(IntPtr userToken)
於 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
於 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
於 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
         * */
        /*
操作类型 crashReport -- 异常报告 
主题 dp2catalog 
发送者 xxx 
媒体类型 text 
内容 发生未捕获的异常: 
Type: System.InvalidOperationException
Message: 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
Stack:
在 System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle)
在 System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
在 System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
在 dp2Catalog.ZSearchForm.ShowQueryResultInfo(ZConnection connection, String strText)
在 dp2Catalog.ZConnection.ShowQueryResultInfo(String strText)
在 dp2Catalog.ZConnection.ZConnection_CommandsComplete(Object sender, EventArgs e)
在 dp2Catalog.ZConnection.ZChannel_ConnectComplete(Object sender, EventArgs e)
在 DigitalPlatform.Z3950.ZChannel.ConnectCallback(IAsyncResult ar)
在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
在 System.Net.ContextAwareResult.CompleteCallback(Object state)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
在 System.Net.LazyAsyncResult.InvokeCallback(Object result)
在 System.Net.Sockets.Socket.MultipleAddressConnectCallback(IAsyncResult result)
在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)


dp2Catalog 版本: dp2Catalog, Version=2.4.5701.40614, Culture=neutral, PublicKeyToken=null
操作系统:Microsoft Windows NT 6.1.7600.0 
操作时间 2015/8/20 14:22:46 (Thu, 20 Aug 2015 14:22:46 +0800) 
前端地址 xxx 经由 http://dp2003.com/dp2library 

         * */
        public bool ShowQueryResultInfo(ZConnection connection,
           string strText)
        {
            if (this.IsDisposed == true
                || this.IsHandleCreated == false)   // 2015/8/21
                return false;

            try
            {
                object[] pList = { connection, strText };
                return (bool)this.Invoke(
                    new ZSearchForm.Delegate_ShowQueryResultInfo(__ShowQueryResultInfo), pList);
            }
            catch
            {
                // 2015/10/24
                // TODO: 这是没办法的应急方法。最好还是重新设计窗口 closing 时的停止检索机制,然后把这里的 catch 放开
                return false;
            }
        }
Beispiel #9
0
        // parameters:
        //      strResultInfo   [out]返回说明初始化结果的文字
        int DoInitial(
            ZConnection connection,
            out string strResultInfo,
            out string strError)
        {
            strResultInfo = "";
            strError = "";

            byte[] baPackage = null;
            BerTree tree = new BerTree();
            INIT_REQUEST struInit_request = new INIT_REQUEST();
            int nRet;
            int nRecvLen;

            TargetInfo targetinfo = connection.TargetInfo;

            if (connection.ZChannel.Initialized == true)
            {
                strError = "Already Initialized";
                goto ERROR1;
            }

            struInit_request.m_strReferenceId = this.CurrentRefID;  //  "0";!!!
            struInit_request.m_strOptions = "yynnnnnnnnnnnnnnnn";   // "yyynynnyynynnnyn";

            struInit_request.m_lPreferredMessageSize = 0x100000; ////16384;
            struInit_request.m_lExceptionalRecordSize = 0x100000;

            if (String.IsNullOrEmpty(targetinfo.UserName) == false)
            {
                struInit_request.m_strID = targetinfo.UserName;
                struInit_request.m_strPassword = targetinfo.Password;
                struInit_request.m_strGroupID = targetinfo.GroupID;
                struInit_request.m_nAuthenticationMethod = targetinfo.AuthenticationMethod;
            }
            else
            {
                struInit_request.m_strID = "";
                struInit_request.m_strPassword = "";
                struInit_request.m_strGroupID = "";
                struInit_request.m_nAuthenticationMethod = -1;
            }

            /*
            struInit_request.m_strImplementationId = "81";    // "81";
            struInit_request.m_strImplementationVersion = "2.0.3 WIN32 Debug";
            struInit_request.m_strImplementationName = "Index Data/YAZ";
             * */

            struInit_request.m_strImplementationId = "DigitalPlatform";
            struInit_request.m_strImplementationVersion = "1.1.0";
            struInit_request.m_strImplementationName = "dp2Catalog";

            if (targetinfo.CharNegoUTF8 == true)
            {
                struInit_request.m_charNego = new CharsetNeogatiation();
                struInit_request.m_charNego.EncodingLevelOID = CharsetNeogatiation.Utf8OID; //  "1.0.10646.1.0.8";   // utf-8
                struInit_request.m_charNego.RecordsInSelectedCharsets = (targetinfo.CharNegoRecordsUTF8 == true ? 1 : 0);
            }

            nRet = tree.InitRequest(struInit_request,
                   targetinfo.DefaultQueryTermEncoding,
                    out baPackage);
            if (nRet == -1)
            {
                strError = "CBERTree::InitRequest() fail!";
                goto ERROR1;
            }

            if (connection.ZChannel.Connected == false)
            {
                strError = "socket尚未连接或者已经被关闭";
                goto ERROR1;
            }


#if DUMPTOFILE
	DeleteFile("initrequest.bin");
	DumpPackage("initrequest.bin",
				(char *)baPackage.GetData(),
				baPackage.GetSize());
	DeleteFile ("initrequest.txt");
	tree.m_RootNode.DumpToFile("initrequest.txt");
#endif

            /*
            nRet = this.ZChannel.SendTcpPackage(
                baPackage,
                baPackage.Length,
                out strError);
            if (nRet == -1 || nRet == 1)
            {
                // CloseZAssociation();
                return -1;
            }

            baPackage = null;
            nRet = this.ZChannel.RecvTcpPackage(
                        out baPackage,
                        out nRecvLen,
                        out strError);
            if (nRet == -1)
            {
                // CloseZAssociation();
                return -1;
            }
             * */

            byte[] baOutPackage = null;
            nRet = connection.ZChannel.SendAndRecv(
                baPackage,
                out baOutPackage,
                out nRecvLen,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }



#if DUMPTOFILE
	DeleteFile("initresponse.bin");
	DumpPackage("initresponse.bin",
				(char *)baOutPackage.GetData(),
				baOutPackage.GetSize());
#endif

            ////////////////////////////////////////////////////////////////
            BerTree tree1 = new BerTree();
            int nTotlen = 0;

            tree1.m_RootNode.BuildPartTree(baOutPackage,
                0,
                baOutPackage.Length,
                out nTotlen);


#if DUMPTOFILE
	DeleteFile("InitResponse.txt"); 
	tree1.m_RootNode.DumpDebugInfoToFile("InitResponse.txt");
#endif

            /*
	nRet = FitDebugInfo_InitResponse(&tree1,
							  strError);
	if (nRet == -1) {
		return -1;
	}
	*/


            INIT_RESPONSE init_response = new INIT_RESPONSE();
            nRet = BerTree.GetInfo_InitResponse(tree1.GetAPDuRoot(),
                                 ref init_response,
                                 out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            if (targetinfo.IgnoreReferenceID == false)
            {
                // 2007/11/2。可以帮助发现旧版本dp2zserver的错误
                if (struInit_request.m_strReferenceId != init_response.m_strReferenceId)
                {
                    strError = "请求的 reference id [" + struInit_request.m_strReferenceId + "] 和 响应的 reference id [" + init_response.m_strReferenceId + "] 不一致!";
                    goto ERROR1;
                }
            }


            if (init_response.m_nResult != 0)
            {
                strError = "Initial OK";
            }
            else
            {
                strError = "Initial被拒绝。\r\n\r\n错误码 ["
                    + init_response.m_lErrorCode.ToString()
                    + "]\r\n错误消息["
                    + init_response.m_strErrorMessage + "]";

                strResultInfo = ZConnection.BuildInitialResultInfo(init_response);
                return -1;
            }

            /*
	this->m_init_strOption = init_response.m_strOptions;
	this->m_init_lPreferredMessageSize = init_response.m_lPreferredMessageSize;
	this->m_init_lExceptionalRecordSize = init_response.m_lExceptionalRecordSize;
	this->m_init_nResult = init_response.m_nResult;
             * */

            connection.ZChannel.Initialized = true;

            // 字符集协商
            if (init_response.m_charNego != null
                && BerTree.GetBit(init_response.m_strOptions, 17) == true)
            {
                if (init_response.m_charNego.EncodingLevelOID == CharsetNeogatiation.Utf8OID)
                {
                    // 临时修改检索词的编码方式。
                    // 但是还无法反映到PropertyDialog上。最好能反馈。
                    targetinfo.DefaultQueryTermEncoding = Encoding.UTF8;
                    targetinfo.Changed = true;

                    if (init_response.m_charNego.RecordsInSelectedCharsets == 1)
                        connection.ForcedRecordsEncoding = Encoding.UTF8;
                }
            }

            strResultInfo = ZConnection.BuildInitialResultInfo(init_response);

            return 0;
        ERROR1:
            strResultInfo = strError;
            return -1;
        }
Beispiel #10
0
        // 发送数据前检查连接
        int CheckConnect(
            ZConnection connection,
            out string strError)
        {
            strError = "";
            int nRet = 0;

            if (connection.ZChannel.DataAvailable == true)
            {
                string strMessage = "";
                // 处理Server可能发来的Close
                // return:
                //      -1  error
                //      0   不是Close
                //      1   是Close,已经迫使ZChannel处于尚未初始化状态
                nRet = CheckServerCloseRequest(
                    connection,
                    out strMessage,
                    out strError);
                if (nRet == -1)
                    return -1;
                if (nRet == 1)
                {
                    nRet = connection.ZChannel.NewConnectSocket(connection.TargetInfo.HostName,
                        connection.TargetInfo.Port,
                        out strError);
                    if (nRet == -1)
                        return -1;

                    connection.TargetInfo.OnlineServerIcon(true);

                    string strInitialResultInfo = "";
                    nRet = this.DoInitial(
                        connection,
                        // connection.TargetInfo,
                        out strInitialResultInfo,
                        out strError);
                    if (nRet == -1)
                    {
                        connection.TargetInfo.OnlineServerIcon(false);
                        return -1;
                    }

                    // 设置当前树上已经选择的节点的扩展信息
                    nRet = ZTargetControl.SetCurrentTargetExtraInfo(
                        this.zTargetControl1.SelectedNode,
                        strInitialResultInfo,
                        out strError);
                    if (nRet == -1)
                        return -1;

                }
            }

            return 0;
        }
Beispiel #11
0
        // 发送原始包
        // parameters:
        //      strResultInfo   [out]返回说明初始化结果的文字
        int DoSendOriginPackage(
            ZConnection connection,
            byte [] baPackage,
            out string strError)
        {
            strError = "";

            TargetInfo targetinfo = connection.TargetInfo;
            /*
            if (connection.ZChannel.Initialized == true)
            {
                strError = "Already Initialized";
                goto ERROR1;
            }*/

            if (connection.ZChannel.Connected == false)
            {
                strError = "socket尚未连接或者已经被关闭";
                goto ERROR1;
            }


            byte[] baOutPackage = null;
            int nRecvLen = 0;
            int nRet = connection.ZChannel.SendAndRecv(
                baPackage,
                out baOutPackage,
                out nRecvLen,
                out strError);
            if (nRet == -1)
            {
                goto ERROR1;
            }

            return 0;
        ERROR1:
            return -1;
        }
Beispiel #12
0
        // 处理Server可能发来的Close
        // return:
        //      -1  error
        //      0   不是Close
        //      1   是Close,已经迫使ZChannel处于尚未初始化状态
        int CheckServerCloseRequest(
            ZConnection connection,
            out string strMessage,
            out string strError)
        {
            strMessage = "";
            strError = "";

            if (connection.ZChannel.DataAvailable == false)
                return 0;

            int nRecvLen = 0;
            byte [] baPackage = null;
            int nRet = connection.ZChannel.RecvTcpPackage(
                        out baPackage,
                        out nRecvLen,
                        out strError);
            if (nRet == -1)
                return -1;

            BerTree tree1 = new BerTree();
            int nTotlen = 0;

            tree1.m_RootNode.BuildPartTree(baPackage,
                0,
                baPackage.Length,
                out nTotlen);

            if (tree1.GetAPDuRoot().m_uTag != BerTree.z3950_close)
            {
                // 不是Close
                return 0;
            }

            CLOSE_REQUEST closeStruct = new CLOSE_REQUEST();
            nRet = BerTree.GetInfo_closeRequest(
                tree1.GetAPDuRoot(),
                ref closeStruct,
                out strError);
            if (nRet == -1)
                return -1;

            strMessage = closeStruct.m_strDiagnosticInformation;

            /*
            this.ZChannel.CloseSocket();
            this.ZChannel.Initialized = false;  // 迫使重新初始化
            if (this.CurrentTargetInfo != null)
                this.CurrentTargetInfo.OfflineServerIcon();
             * */
            connection.CloseConnection();

            return 1;
        }
Beispiel #13
0
        // 清除以往的(已经获取到前端)结果集信息和相应的显示
        // thread:
        //      界面线程
        void ClearResultInfo(ZConnection connection)
        {
            ZConnection current_connection = this.GetCurrentZConnection();

            connection.ResultCount = -2;    // 表示正在检索

            if (connection.Records != null)
                connection.Records.Clear();

            // this.listView_browse.Items.Clear();
            if (connection.VirtualItems != null)
            {
                connection.VirtualItems.Clear();

                if (current_connection == connection)
                    LinkRecordsToListView(connection.VirtualItems); // listview是公用的
            }

            /*
            if (current_connection == connection)
            {
                this.textBox_resultInfo.Text = "";  // 这个textbox是公用的
            }
             * */
            if (current_connection == connection)
            {
                ShowQueryResultInfo(connection, "");
            }
           
        }
Beispiel #14
0
 public bool ShowMessageBox(ZConnection connection,
    string strText)
 {
     object[] pList = { connection, strText };
     if (this.IsDisposed == true)
         return false; // 防止窗口关闭后这里抛出异常 2014/5/15
     return (bool)this.Invoke(
         new ZSearchForm.Delegate_ShowMessageBox(__ShowMessageBox), pList);
 }
Beispiel #15
0
        // 获得记录
        // 确保一定可以获得nCount个
        int DoPresent(
            ZConnection connection,
            string strResultSetName,
            int nStart,
            int nCount,
            string strElementSetName,
            string strPreferredRecordSyntax,
            out RecordCollection records,
            out string strError)
        {
            records = new RecordCollection();
            if (nCount == 0)
            {
                strError = "nCount为0";
                return 0;
            }

            int nGeted = 0;
            for (; ; )
            {
                RecordCollection temprecords = null;
                int nRet = DoOncePresent(
                    connection,
                    strResultSetName,
                    nStart + nGeted,
                    nCount - nGeted,
                    strElementSetName,
                    strPreferredRecordSyntax,
                    out temprecords,
                    out strError);
                if (nRet == -1)
                    return -1;
                if (temprecords == null)
                    break;

                nGeted += temprecords.Count;
                if (temprecords.Count > 0)
                    records.AddRange(temprecords);

                if (nGeted >= nCount || temprecords.Count == 0)
                    break;
            }

            return 0;
        }
Beispiel #16
0
        // 显示查询结果信息,在检索式的下部textbox中
        // 函数会自动判断,只有当前ZConnection才会显示出来
        bool __ShowQueryResultInfo(ZConnection connection,
            string strText)
        {
            // 修改treenode节点上的命中数显示
            ZTargetControl.SetNodeResultCount(connection.TreeNode,
                connection.ResultCount);

            if (connection == this.GetCurrentZConnection())
            {
                this.textBox_resultInfo.Text = strText;
                return true;    // 被显示了
            }

            return false;   // 没有被显示
        }
Beispiel #17
0
        // 获得记录
        // 不确保一定可以获得nCount个
        // parameters:
        //		nStart	开始记录(从0计算)
        int DoOncePresent(
            ZConnection connection,
            string strResultSetName,
            int nStart,
            int nCount,
            string strElementSetName,
            string strPreferredRecordSyntax,
            out RecordCollection records,
            out string strError)
        {
            records = null;
            strError = "";

            if (nCount == 0)
            {
                strError = "nCount为0";
                return 0;
            }


            BerTree tree = new BerTree();
            PRESENT_REQUEST struPresent_request = new PRESENT_REQUEST();
            byte[] baPackage = null;
            int nRet;
            int nRecvLen;

            // -->
            BerTree tree1 = new BerTree();
            int nTotlen = 0;

            struPresent_request.m_strReferenceId = this.CurrentRefID;
            struPresent_request.m_strResultSetName = strResultSetName; // "default";
            struPresent_request.m_lResultSetStartPoint = nStart + 1;
            struPresent_request.m_lNumberOfRecordsRequested = nCount;
            struPresent_request.m_strElementSetNames = strElementSetName;
            struPresent_request.m_strPreferredRecordSyntax = strPreferredRecordSyntax;

            nRet = tree.PresentRequest(struPresent_request,
                                     out baPackage);
            if (nRet == -1)
            {
                strError = "CBERTree::PresentRequest() fail!";
                return -1;
            }


#if DUMPTOFILE
	DeleteFile("presentrequest.bin");
	DumpPackage("presentrequest.bin",
		(char *)baPackage.GetData(),
		baPackage.GetSize());
	DeleteFile ("presentrequest.txt");
	tree.m_RootNode.DumpToFile("presentrequest.txt");
#endif

            nRet = CheckConnect(
                connection,
                out strError);
            if (nRet == -1)
                return -1;

            /*
            nRet = this.ZChannel.SendTcpPackage(
                baPackage,
                baPackage.Length,
                out strError);
            if (nRet == -1 || nRet == 1)
            {
                // CloseZAssociation();
                return -1;
            }

            //////////////


            baPackage = null;
            nRet = this.ZChannel.RecvTcpPackage(
                        out baPackage,
                        out nRecvLen,
                        out strError);
            if (nRet == -1)
            {
                // CloseZAssociation();
                goto ERROR1;
            }
             * */

            byte [] baOutPackage = null;
            nRet = connection.ZChannel.SendAndRecv(
                baPackage,
                out baOutPackage,
                out nRecvLen,
                out strError);
            if (nRet == -1)
                return -1;

#if DUMPTOFILE	
	DeleteFile("presendresponse.bin");
	DumpPackage("presentresponse.bin",
				(char *)baPackage.GetData(),
				baPackage.GetSize());
#endif


            tree1.m_RootNode.BuildPartTree(baOutPackage,
                0,
                baOutPackage.Length,
                out nTotlen);

#if DUMPTOFILE
	DeleteFile("PresentResponse.txt"); 
	tree1.m_RootNode.DumpDebugInfoToFile("PresentResponse.txt");
#endif

            SEARCH_RESPONSE search_response = new SEARCH_RESPONSE();
            nRet = BerTree.GetInfo_PresentResponse(tree1.GetAPDuRoot(),
                                   ref search_response,
                                   out records,
                                   true,
                                   out strError);
            if (nRet == -1)
                goto ERROR1;

            /*
            nRet = FitDebugInfo_PresentResponse(&tree1,
                                      strError);
            if (nRet == -1) {
                goto ERROR1;
            }

            DeleteFile("PresentResponse.txt"); 
            tree1.m_RootNode.DumpDebugInfoToFile("PresentResponse.txt");
            */


            if (search_response.m_diagRecords.Count != 0)
            {
                /*
                string strDiagText;
                string strAddInfo;

                nRet = GetDiagTextByNumber("bib1diag.txt",
                                m_search_response.m_nDiagCondition,
                                strDiagText,
                                strAddInfo,
                                strError);
                if (nRet == -1) {
                    if (this->m_bAllowMessageBox)
                        AfxMessageBox(strError);
                    return -1;
                }
                if (strDiagText.GetLength())
                    strError = strDiagText;
                else
                    strError.Format("diag condition[%d] diag set id[%s]",
                    m_search_response.m_nDiagCondition,
                    m_search_response.m_strDiagSetID);
                 * */
                strError = "error diagRecords:\r\n\r\n---\r\n" + search_response.m_diagRecords.GetMessage();
                return -1;
            }

            return 0;
        ERROR1:
            return -1;
        }
Beispiel #18
0
        // 根据不同格式自动创建浏览格式
        public int BuildBrowseText(
            ZConnection connection,
            DigitalPlatform.Z3950.Record record,
            string strStyle,
            out string strBrowseText,
            out int nImageIndex,
            out string strError)
        {
            strBrowseText = "";
            strError = "";
            int nRet = 0;

            nImageIndex = BROWSE_TYPE_NORMAL;

            if (record.m_nDiagCondition != 0)
            {
                strBrowseText = "诊断记录 condition=" + record.m_nDiagCondition.ToString() + "; addinfo=\"" + record.m_strAddInfo + "\"; diagSetOID=" + record.m_strDiagSetID;
                nImageIndex = BROWSE_TYPE_DIAG;
                return 0;
            }

            string strElementSetName = record.m_strElementSetName;

            if (strElementSetName == "B")
                nImageIndex = BROWSE_TYPE_BRIEF;
            else if (strElementSetName == "F")
                nImageIndex = BROWSE_TYPE_FULL;

            Encoding currrentEncoding = connection.GetRecordsEncoding(
                this.MainForm,
                record.m_strSyntaxOID);

            string strSytaxOID = record.m_strSyntaxOID;
            string strData = currrentEncoding.GetString(record.m_baRecord);

            // string strOutFormat = "";
            string strMARC = "";    // 暂存MARC机内格式数据

            // 如果为XML格式
            if (record.m_strSyntaxOID == "1.2.840.10003.5.109.10")
            {
                // 如果偏向MARC
                if (StringUtil.IsInList("marc", strStyle) == true)
                {
                    // 看根节点的名字空间,如果符合MARCXML, 就先转换为USMARC,否则,就直接根据名字空间找样式表加以转换
                    string strNameSpaceUri = "";
                    nRet = GetRootNamespace(strData,
                        out strNameSpaceUri,
                        out strError);
                    if (nRet == -1)
                    {
                        // 取根节点的名字空间时出错
                        return -1;
                    }

                    if (strNameSpaceUri == Ns.usmarcxml)
                    {
                        string strOutMarcSyntax = "";

                        // 将MARCXML格式的xml记录转换为marc机内格式字符串
                        // parameters:
                        //		bWarning	==true, 警告后继续转换,不严格对待错误; = false, 非常严格对待错误,遇到错误后不继续转换
                        //		strMarcSyntax	指示marc语法,如果=="",则自动识别
                        //		strOutMarcSyntax	out参数,返回marc,如果strMarcSyntax == "",返回找到marc语法,否则返回与输入参数strMarcSyntax相同的值
                        nRet = MarcUtil.Xml2Marc(strData,
                            true,
                            "usmarc",
                            out strOutMarcSyntax,
                            out strMARC,
                            out strError);
                        if (nRet == -1)
                        {
                            // XML转换为MARC时出错
                            return -1;
                        }

                        // strOutFormat = "marc";
                        strSytaxOID = "1.2.840.10003.5.10";
                        goto DO_BROWSE;
                    }

                }

                // 不是MARCXML格式
                // strOutFormat = "xml";
                goto DO_BROWSE;
            }

            // SUTRS
            if (record.m_strSyntaxOID == "1.2.840.10003.5.101")
            {
                // strOutFormat = "sutrs";
                goto DO_BROWSE;
            }

            if (record.m_strSyntaxOID == "1.2.840.10003.5.1"    // unimarc
                || record.m_strSyntaxOID == "1.2.840.10003.5.10")  // usmarc
            {
                // ISO2709转换为机内格式
                nRet = Marc8Encoding.ConvertByteArrayToMarcRecord(
                    record.m_baRecord,
                    connection.GetRecordsEncoding(this.MainForm, record.m_strSyntaxOID),  // Encoding.GetEncoding(936),
                    true,
                    out strMARC,
                    out strError);
                if (nRet < 0)
                {
                    return -1;
                }

                // 如果需要自动探测MARC记录从属的格式:
                if (connection.TargetInfo.DetectMarcSyntax == true)
                {
                    // return:
                    //		-1	无法探测
                    //		1	UNIMARC	规则:包含200字段
                    //		10	USMARC	规则:包含008字段(innopac的UNIMARC格式也有一个奇怪的008)
                    nRet = ZSearchForm.DetectMARCSyntax(strMARC);
                    if (nRet == 1)
                        strSytaxOID = "1.2.840.10003.5.1";
                    else if (nRet == 10)
                        strSytaxOID = "1.2.840.10003.5.10";

                    // 把自动识别的结果保存下来
                    record.AutoDetectedSyntaxOID = strSytaxOID;
                }

                // strOutFormat = "marc";
                goto DO_BROWSE;
            }

            // 不能识别的格式。原样放置
            strBrowseText = strData;
            return 0;

        DO_BROWSE:

            if (strSytaxOID == "1.2.840.10003.5.1"    // unimarc
                || strSytaxOID == "1.2.840.10003.5.10")  // usmarc
            {
                return BuildMarcBrowseText(
                strSytaxOID,
                strMARC,
                out strBrowseText,
                out strError);
            }

            // XML还暂时没有转换办法
            strBrowseText = strData;
            return 0;
        }
Beispiel #19
0
 // 根据connection是否为当前connection,决定是否执行
 // Enable/Disable检索式控件的操作
 void __EnableQueryControl(
     ZConnection connection,
     bool bEnable)
 {
     ZConnection cur_connection = this.GetCurrentZConnection();
     if (cur_connection == connection)
     {
         EnableQueryControl(bEnable);
     }
 }
Beispiel #20
0
        public void GetNextAllBatch(ZConnection connection)
        {
            if (/*this.listView_browse.Items.Count*/
                connection.Records.Count
                >= connection.ResultCount)
            {
                MessageBox.Show(this, "已经获得了全部命中记录");
                return;
            }


            /*
            while(
                connection.Records.Count < connection.ResultCount )
            {
                connection.NextBatch(true);
            }
             * */
            connection.NextAllBatch(true);
        }
Beispiel #21
0
     public void EnableQueryControl(
 ZConnection connection,
 bool bEnable)
     {
         object[] pList = { connection, bEnable };
         this.Invoke(
             new ZSearchForm.Delegate_EnableQueryControl(__EnableQueryControl), pList);
     }
Beispiel #22
0
        void SaveListViewSelectedToVirtual(ZConnection connection)
        {
            // 保存listview中的选定事项
            for (int i = 0; i < this.listView_browse.Items.Count; i++)
            {
                ListViewItem item = this.listView_browse.Items[i];

                connection.VirtualItems[i].Selected = item.Selected;
            }
        }
Beispiel #23
0
        // 显示当前新获得的浏览记录
        // 函数会自动判断,只有当前ZConnection才会显示出来
        bool __DisplayBrowseItems(ZConnection connection,
            bool bTriggerSelChanged = false)
        {
            bool bRet = false;  // 没有被显示
            if (connection != null
                && connection == this.GetCurrentZConnection())
            {
                LinkRecordsToListView(connection.VirtualItems);
                bRet = true;    // 被显示了
            }

            if (bTriggerSelChanged == true)
            {
                listView_browse_SelectedIndexChanged(null, null);
            }

            return bRet;   
        }
Beispiel #24
0
        // 检索一个服务器或者目录
        // 这是包装后可以外部调用的版本 -- 检索当前目标树上选定的节点
        public int DoSearch()
        {
            string strError = "";
            int nRet = 0;

            this._processing++;
            try
            {
                TreeNode node = this.zTargetControl1.SelectedNode;
                if (ZTargetControl.IsServerType(node) == true
                    || ZTargetControl.IsDatabaseType(node) == true)
                {
                    // return:
                    //      -2  尚未输入检索词
                    //      -1  一般错误
                    //      0   成功启动检索
                    nRet = DoSearchOneServer(
                        node,
                        out strError);
                    if (nRet == -1 || nRet == -2)
                        goto ERROR1;
                }
                else
                {
                    Debug.Assert(ZTargetControl.IsDirType(node) == true, "");

                    if (this.m_stops.Count != 0)
                    {
                        // TODO: 是否需要提示出哪个目录正在进行群检?
                        strError = "当前正在进行着群检,不允许多次启动群检";
                        goto ERROR1;
                    }

                    ZConnection connection = this.GetCurrentZConnection();

                    // 获得共同的检索式
                    connection.QueryXml = this.queryControl1.GetContent(true);
                    if (String.IsNullOrEmpty(connection.QueryXml) == true)
                    {
                        strError = "尚未输入检索式";
                        goto ERROR1;
                    }

                    // 准备工作
                    this.m_nTotalHitCount = 0;
                    this.m_nCompleteServerCount = 0;
                    this.m_nServerCount = 0;

                    this.m_stopDir = connection.Stop;
                    this.m_connectionDir = connection;
                    this.m_stops.Clear();
                    this.m_bStartGroupSearch = false;

                    node.Expand();

                    /*
                    lock (this)
                    {
                    } 
                     * */

#if NOOOOOOOOOOOOO
                this.m_stopDir.OnStop += new StopEventHandler(m_stopDir_OnStop);
                    this.m_stopDir.SetMessage("开始检索 ...");

                    this.m_stopDir.BeginLoop();
                    this.m_connectionDir.EnableControls(false);
#endif


                    List<ZConnection> connections = new List<ZConnection>();

                    nRet = PrepareSearchOneDir(node,
                        connection.QueryXml,
                        ref connections,
                        out strError);
                    if (nRet == -1 || this.m_stops.Count == 0)
                    {
#if NOOOOOOOOOOOOOO
                    lock (this)
                    {
                        this.m_connectionDir.EnableControls(true);
                        this.m_stopDir.EndLoop();
                        this.m_stopDir.OnStop -= new StopEventHandler(m_stopDir_OnStop);
                        this.m_stopDir.Initial("");

                        // 解挂全部事件
                        for (int i = 0; i < this.m_stops.Count; i++)
                        {
                            Stop stop = this.m_stops[i];

                            stop.OnBeginLoop -= new BeginLoopEventHandler(Stop_OnBeginLoop);
                            stop.OnEndLoop -= new EndLoopEventHandler(Stop_OnEndLoop);
                        }

                        this.m_stops.Clear();
                    }
#endif
                        goto ERROR1;
                    }

                    this.m_nServerCount = this.m_stops.Count;

                    // 启动检索
                    for (int i = 0; i < connections.Count; i++)
                    {
                        ZConnection temp = connections[i];
#if THREAD_POOLING
                        List<string> commands = new List<string>();
                        commands.Add("search");
                        commands.Add("present");

                        temp.SetSearchParameters(
                temp.QueryString,
                temp.TargetInfo.DefaultQueryTermEncoding,
                temp.TargetInfo.DbNames,
                temp.TargetInfo.DefaultResultSetName);

                        temp.SetPresentParameters(
                temp.TargetInfo.DefaultResultSetName,
                0, // nStart,
                temp.TargetInfo.PresentPerBatchCount, // nCount,
                temp.TargetInfo.PresentPerBatchCount,   // 推荐的每次数量
                temp.DefaultElementSetName,    // "F" strElementSetName,
                temp.PreferredRecordSyntax,
                true);

                        temp.BeginCommands(commands);

#else
                    temp.Search();
#endif
                    }
                }

                return 0;
            }
            finally
            {
                this._processing--;
            }
        ERROR1:
            // 这里的报错,是在界面线程的报错
            try // 防止最后退出时报错
            {
                MessageBox.Show(this, strError);
                this.queryControl1.Focus();
            }
            catch
            {
            }
            return -1;
        }
Beispiel #25
0
        /*
操作类型 crashReport -- 异常报告 
主题 dp2catalog 
发送者 xxx 
媒体类型 text 
内容 发生未捕获的异常: 
Type: System.InvalidOperationException
Message: 在创建窗口句柄之前,不能在控件上调用 Invoke 或 BeginInvoke。
Stack:
在 System.Windows.Forms.Control.WaitForWaitHandle(WaitHandle waitHandle)
在 System.Windows.Forms.Control.MarshaledInvoke(Control caller, Delegate method, Object[] args, Boolean synchronous)
在 System.Windows.Forms.Control.Invoke(Delegate method, Object[] args)
在 dp2Catalog.ZSearchForm.ShowQueryResultInfo(ZConnection connection, String strText)
在 dp2Catalog.ZConnection.ShowQueryResultInfo(String strText)
在 dp2Catalog.ZConnection.ZConnection_CommandsComplete(Object sender, EventArgs e)
在 dp2Catalog.ZConnection.ZChannel_ConnectComplete(Object sender, EventArgs e)
在 DigitalPlatform.Z3950.ZChannel.ConnectCallback(IAsyncResult ar)
在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
在 System.Net.ContextAwareResult.CompleteCallback(Object state)
在 System.Threading.ExecutionContext.runTryCode(Object userData)
在 System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
在 System.Net.LazyAsyncResult.InvokeCallback(Object result)
在 System.Net.Sockets.Socket.MultipleAddressConnectCallback(IAsyncResult result)
在 System.Net.LazyAsyncResult.Complete(IntPtr userToken)
在 System.Net.ContextAwareResult.Complete(IntPtr userToken)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)


dp2Catalog 版本: dp2Catalog, Version=2.4.5701.40614, Culture=neutral, PublicKeyToken=null
操作系统:Microsoft Windows NT 6.1.7600.0 
操作时间 2015/8/20 14:22:46 (Thu, 20 Aug 2015 14:22:46 +0800) 
前端地址 xxx 经由 http://dp2003.com/dp2library 

         * */
        public bool ShowQueryResultInfo(ZConnection connection,
           string strText)
        {
            if (this.IsDisposed == true
                || this.IsHandleCreated == false)   // 2015/8/21
                return false;

            object[] pList = { connection, strText };
            return (bool)this.Invoke(
                new ZSearchForm.Delegate_ShowQueryResultInfo(__ShowQueryResultInfo), pList);
        }