Пример #1
0
        // 检索册信息过程中,处理结果集中每条记录的回调函数
        void SearchItems_BrowseRecord(object sender, BrowseRecordEventArgs e)
        {
            ResPath respath = new ResPath(e.FullPath);

            XmlDocument tempdom = null;

            byte[] baTimeStamp = null;
            string strError    = "";

            int nRet = this.SearchPanel.GetRecord(
                respath.Url,
                respath.Path,
                out tempdom,
                out baTimeStamp,
                out strError);

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

            BookItem item = new BookItem(respath.Path, tempdom);

            item.Timestamp = baTimeStamp;
            this.Items.Add(item);

            item.AddToListView(this.listView_items);

            return;

ERROR1:
            MessageBox.Show(this, strError);
        }
Пример #2
0
 void SearchPanel_BrowseRecord(object sender, BrowseRecordEventArgs e)
 {
     this.browseWindow.NewLine(e.FullPath,
                               e.Cols);
 }
Пример #3
0
        void BrowseRecordNoColsCallBack(object sender, BrowseRecordEventArgs e)
        {
            string strError = "";

            if (e.FullPath == this.RecordFullPath)
                return;	// 当前记录自己并不要装入浏览窗

            int nRet = FillList(
                e.FullPath,
                this.m_hit,
                this.m_strWeightList,
                /*
                this.m_strSearchStyle,
				this.m_nCurWeight,
				this.m_nThreshold,
				this.m_strSearchReason,
                 * */
                out strError);
            if (nRet == -1)
            {
                e.Cancel = true;
                e.ErrorInfo = strError;
            }
        }
Пример #4
0
        void BrowseRecordColsCallBack(object sender, BrowseRecordEventArgs e)
        {
            ListViewUtil.EnsureColumns(this.listView_browse,
                3 + e.Cols.Length,
                200);

            ListViewItem item = (ListViewItem)this.m_tableItem[ResPath.GetReverseRecordPath(e.FullPath)];
            if (item == null)
            {
                e.Cancel = true;
                e.ErrorInfo = "路径为 '" + e.FullPath + "' 的事项在listview中不存在...";
                return;
            }


            for (int j = 0; j < e.Cols.Length; j++)
            {
                ListViewUtil.ChangeItemText(item,
                    j + 3,
                    e.Cols[j]);
            }
        }
Пример #5
0
        /// <summary>
        /// 获取浏览记录。触发事件的版本
        /// </summary>
        /// <param name="fullpaths">若干记录全路径</param>
        /// <param name="bReverse">fullpaths中路径是否为反转形式</param>
        /// <param name="strStyle">检索风格</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1	error;0	not found;1	found</returns>
        public int GetBrowseRecord(string[] fullpaths,
                                   bool bReverse,
                                   string strStyle,
                                   out string strError)
        {
            strError = "";
            int nRet = 0;

            int nIndex = 0;

            ArrayList aTempPath   = new ArrayList();
            ArrayList aTempRecord = new ArrayList();
            string    strLastUrl  = "";

            for (int i = 0; i <= fullpaths.Length; i++)
            {
                bool    bPush   = false;
                ResPath respath = null;

                if (i < fullpaths.Length)
                {
                    string strFullPath = fullpaths[i];

                    if (bReverse == true)
                    {
                        strFullPath = ResPath.GetRegularRecordPath(strFullPath);
                    }

                    respath = new ResPath(strFullPath);

                    if (respath.Url != strLastUrl ||
                        aTempPath.Count >= 5)           // 最大5条为一批。减少用户等待感
                    {
                        bPush = true;
                    }
                }
                else
                {
                    bPush = true;
                }

                if (bPush == true && aTempPath.Count > 0)
                {
                    string[] temppaths = new string[aTempPath.Count];
                    for (int j = 0; j < temppaths.Length; j++)
                    {
                        temppaths[j] = (string)aTempPath[j];
                    }
                    nRet = GetBrowseRecord(
                        strLastUrl,
                        temppaths,
                        strStyle,
                        out aTempRecord,
                        out strError);
                    if (nRet == -1)
                    {
                        return(-1);
                    }

                    // 触发事件
                    if (this.BrowseRecord != null)
                    {
                        for (int j = 0; j < aTempRecord.Count; j++)
                        {
                            BrowseRecordEventArgs e = new BrowseRecordEventArgs();
                            e.SearchCount = 0;
                            e.Index       = nIndex++;
                            e.FullPath    = strLastUrl + "?" + temppaths[j];
                            e.Cols        = (string[])aTempRecord[j];
                            this.BrowseRecord(this, e);
                            if (e.Cancel == true)
                            {
                                if (e.ErrorInfo == "")
                                {
                                    strError = "用户中断";
                                }
                                else
                                {
                                    strError = e.ErrorInfo;
                                }
                                return(-2);
                            }
                        }
                    }

                    aTempRecord.Clear();

                    aTempPath.Clear();
                }


                if (i < fullpaths.Length)
                {
                    aTempPath.Add(respath.Path);

                    strLastUrl = respath.Url;
                }
            } // end of for

            return(0);
        }
Пример #6
0
 void BrowseRecordCallBack(object sender, BrowseRecordEventArgs e)
 {
     string strError = "";
     int nRet = FillList(
         this.CurrentNode,
         e.FullPath,
         out strError);
     if (nRet == -1)
     {
         e.Cancel = true;
         e.ErrorInfo = strError;
     }
 }
Пример #7
0
        /// <summary>
        /// 检索并获取浏览结果
        /// </summary>
        /// <param name="strServerUrl">服务器URL。如果==""或者==null,表示用this.ServerUrl</param>
        /// <param name="strQueryXml"></param>
        /// <param name="bGetBrowseCols">是否要获得浏览列</param>
        /// <param name="strError"></param>
        /// <returns>-2	用户中断;-1	一般错误;0	未命中;	>=1	正常结束,返回命中条数</returns>
        public long SearchAndBrowse(
            string strServerUrl,
            string strQueryXml,
            bool bGetBrowseCols,
            out string strError)
        {
            strError = "";

            if (strServerUrl == null || strServerUrl == null)
            {
                strServerUrl = this.ServerUrl;
            }

            RmsChannel channelSave = channel;


            channel = Channels.GetChannel(strServerUrl);
            if (channel == null)
            {
                strError = "get channel error";
                return(-1);
            }

            try
            {
                // 检索
                long lRet = channel.DoSearch(strQueryXml,
                                             "default",
                                             "", // strOuputStyle
                                             out strError);
                if (lRet == -1)
                {
                    return(-1);
                }

                if (lRet == 0)
                {
                    return(0);
                }

                // 循环获取结果
                long nHitCount = lRet;
                long nStart    = 0;
                long nCount    = 10;
                long nIndex    = 0;

                for (; ;)
                {
                    Application.DoEvents();     // 出让界面控制权

                    if (stop != null)
                    {
                        if (stop.State != 0)
                        {
                            strError = "用户中断";
                            return(-2);
                        }
                    }

                    List <string> aPath = null;
                    ArrayList     aLine = null;
                    if (bGetBrowseCols == false)
                    {
                        lRet = channel.DoGetSearchResult(
                            "default",
                            nStart,
                            nCount,
                            "zh",
                            this.stop,
                            out aPath,
                            out strError);
                    }
                    else
                    {
                        lRet = channel.DoGetSearchFullResult(
                            "default",
                            nStart,
                            nCount,
                            "zh",
                            this.stop,
                            out aLine,
                            out strError);
                    }
                    if (lRet == -1)
                    {
                        strError = "获取检索结果时出错: " + strError;
                        return(-1);
                    }

                    if (bGetBrowseCols == false)
                    {
                        nStart += aPath.Count;
                    }
                    else
                    {
                        nStart += aLine.Count;
                    }


                    // 触发事件
                    if (this.BrowseRecord != null)
                    {
                        int nThisCount = 0;

                        if (bGetBrowseCols == false)
                        {
                            nThisCount = aPath.Count;
                        }
                        else
                        {
                            nThisCount = aLine.Count;
                        }


                        for (int j = 0; j < nThisCount; j++)
                        {
                            BrowseRecordEventArgs e = new BrowseRecordEventArgs();
                            e.SearchCount = nHitCount;
                            e.Index       = nIndex++;
                            if (bGetBrowseCols == false)
                            {
                                e.FullPath = strServerUrl + "?" + (string)aPath[j];
                            }
                            else
                            {
                                string[] cols = (string[])aLine[j];
                                e.FullPath = strServerUrl + "?" + cols[0];
                                // 丢掉第一列
                                e.Cols = new string[Math.Max(cols.Length - 1, 0)];
                                Array.Copy(cols, 1, e.Cols, 0, cols.Length - 1);
                            }
                            this.BrowseRecord(this, e);
                            if (e.Cancel == true)
                            {
                                if (e.ErrorInfo == "")
                                {
                                    strError = "用户中断";
                                }
                                else
                                {
                                    strError = e.ErrorInfo;
                                }
                                return(-2);
                            }
                        }
                    }



                    if (nStart >= nHitCount)
                    {
                        break;
                    }

                    // 2006/9/24 add 防止nStart + nCount越界
                    if (nStart + nCount > nHitCount)
                    {
                        nCount = nHitCount - nStart;
                    }
                    else
                    {
                        nCount = 10;
                    }
                }


                return(nHitCount);
            }
            finally
            {
                channel = channelSave;
            }
        }
Пример #8
0
        /// <summary>
        /// 获取浏览记录。触发事件的版本
        /// </summary>
        /// <param name="fullpaths">若干记录全路径</param>
        /// <param name="bReverse">fullpaths中路径是否为反转形式</param>
        /// <param name="strStyle">检索风格</param>
        /// <param name="strError">返回出错信息</param>
        /// <returns>-1	error;0	not found;1	found</returns>
		public int GetBrowseRecord(string [] fullpaths,
			bool bReverse,
			string strStyle,
			out string strError)
		{
			strError = "";
			int nRet = 0;

			int nIndex = 0;

			ArrayList aTempPath = new ArrayList();
			ArrayList aTempRecord = new ArrayList();
			string strLastUrl = "";
			for(int i=0;i<=fullpaths.Length;i++)
			{
				bool bPush = false;
				ResPath respath = null;

				if (i<fullpaths.Length)
				{
					string strFullPath = fullpaths[i];

					if (bReverse == true)
						strFullPath = ResPath.GetRegularRecordPath(strFullPath);

					respath = new ResPath(strFullPath);

					if ( respath.Url != strLastUrl 
						|| aTempPath.Count >= 5)	// 最大5条为一批。减少用户等待感
						bPush = true;

				}
				else 
				{
					bPush = true;
				}

				if ( bPush == true && aTempPath.Count > 0)
				{
							
					string [] temppaths = new string[aTempPath.Count];
					for(int j=0;j<temppaths.Length;j++)
					{
						temppaths[j] = (string)aTempPath[j];
					}
					nRet = GetBrowseRecord(
						strLastUrl,
						temppaths,
						strStyle,
						out aTempRecord,
						out strError);
					if (nRet == -1)
						return -1;

					// 触发事件
					if (this.BrowseRecord != null)
					{
						
						for(int j=0;j<aTempRecord.Count;j++)
						{
							BrowseRecordEventArgs e = new BrowseRecordEventArgs();
							e.SearchCount = 0;
							e.Index = nIndex ++;
							e.FullPath = strLastUrl + "?" + temppaths[j];
							e.Cols = (string[])aTempRecord[j];
							this.BrowseRecord(this, e);
							if (e.Cancel == true)
							{
								if (e.ErrorInfo == "")
									strError = "用户中断";
								else
									strError = e.ErrorInfo;
								return -2;
							}
						}
					}

					aTempRecord.Clear();

					aTempPath.Clear();
				}


				if (i<fullpaths.Length)
				{
					aTempPath.Add(respath.Path);

					strLastUrl = respath.Url;
				}

			} // end of for

			return 0;

		}
Пример #9
0
        /// <summary>
        /// 检索并获取浏览结果
        /// </summary>
        /// <param name="strServerUrl">服务器URL。如果==""或者==null,表示用this.ServerUrl</param>
        /// <param name="strQueryXml"></param>
        /// <param name="bGetBrowseCols">是否要获得浏览列</param>
        /// <param name="strError"></param>
        /// <returns>-2	用户中断;-1	一般错误;0	未命中;	>=1	正常结束,返回命中条数</returns>
		public long SearchAndBrowse(
			string strServerUrl,
			string strQueryXml,
            bool bGetBrowseCols,
			out string strError)
		{
			strError = "";
			
			if (strServerUrl == null || strServerUrl == null)
				strServerUrl = this.ServerUrl;

			RmsChannel channelSave = channel;


			channel = Channels.GetChannel(strServerUrl);
			if (channel == null)
			{
				strError = "get channel error";
				return -1;
			}

			try 
			{

				// 检索
				long lRet = channel.DoSearch(strQueryXml,
                    "default",
                    "", // strOuputStyle
                    out strError);
				if (lRet == -1) 
					return -1;

				if (lRet == 0) 
					return 0;

				// 循环获取结果
				long nHitCount = lRet;
				long nStart = 0;
				long nCount = 10;
				long nIndex = 0;

				for(;;)
				{
					Application.DoEvents();	// 出让界面控制权

					if (stop != null) 
					{
						if (stop.State != 0)
						{
							strError = "用户中断";
							return -2;
						}
					}

					List<string> aPath = null;
                    ArrayList aLine = null;
                    if (bGetBrowseCols == false)
                    {
                        lRet = channel.DoGetSearchResult(
                    "default",
                            nStart,
                            nCount,
                            "zh",
                            this.stop,
                            out aPath,
                            out strError);
                    }
                    else
                    {
                        lRet = channel.DoGetSearchFullResult(
                    "default",
                            nStart,
                            nCount,
                            "zh",
                            this.stop,
                            out aLine,
                            out strError);
                    }
					if (lRet == -1) 
					{
						strError = "获取检索结果时出错: " + strError;
						return -1;
					}

                    if (bGetBrowseCols == false)
					    nStart += aPath.Count;
                    else
                        nStart += aLine.Count;


					// 触发事件
					if (this.BrowseRecord != null)
					{
                        int nThisCount = 0;

                        if (bGetBrowseCols == false)
                            nThisCount = aPath.Count;
                        else
                            nThisCount = aLine.Count;


                        for (int j = 0; j < nThisCount; j++)
						{
							BrowseRecordEventArgs e = new BrowseRecordEventArgs();
							e.SearchCount = nHitCount;
							e.Index = nIndex ++;
                            if (bGetBrowseCols == false)
                            {
                                e.FullPath = strServerUrl + "?" + (string)aPath[j];
                            }
                            else
                            {
                                string[] cols = (string[])aLine[j];
                                e.FullPath = strServerUrl + "?" + cols[0];
                                // 丢掉第一列
                                e.Cols = new string[Math.Max(cols.Length - 1, 0)];
                                Array.Copy(cols, 1, e.Cols, 0, cols.Length - 1);
                            }
							this.BrowseRecord(this, e);
							if (e.Cancel == true)
							{
								if (e.ErrorInfo == "")
									strError = "用户中断";
								else
									strError = e.ErrorInfo;
								return -2;
							}
						}
					}



					if (nStart >= nHitCount)
						break;

                    // 2006/9/24 add 防止nStart + nCount越界
                    if (nStart + nCount > nHitCount)
                        nCount = nHitCount - nStart;
                    else
                        nCount = 10;

				}


				return nHitCount;
			}
			finally 
			{
				channel = channelSave;
			}

		}
Пример #10
0
 void SearchPanel_BrowseRecord(object sender, BrowseRecordEventArgs e)
 {
     this.browseWindow.NewLine(e.FullPath,
         e.Cols);
 }
Пример #11
0
        // 检索册信息过程中,处理结果集中每条记录的回调函数
        void SearchItems_BrowseRecord(object sender, BrowseRecordEventArgs e)
        {
            ResPath respath = new ResPath(e.FullPath);

            XmlDocument tempdom = null;
            byte[] baTimeStamp = null;
            string strError = "";

            int nRet = this.SearchPanel.GetRecord(
                respath.Url,
                respath.Path,
                out tempdom,
                out baTimeStamp,
                out strError);
            if (nRet == -1)
                goto ERROR1;

            BookItem item = new BookItem(respath.Path, tempdom);

            item.Timestamp = baTimeStamp;
            this.Items.Add(item);

            item.AddToListView(this.listView_items);

            return;
        ERROR1:
            MessageBox.Show(this, strError);
        }