/// <summary> /// 模拟创建检索点 /// </summary> /// <param name="strServerUrl">服务器URL。为什么要单给出这个URL,而不采用this.ServerUrl? 因为要模拟检索点的记录,其服务器URL常常和主服务器的URL不同。</param> /// <param name="strPath"></param> /// <param name="strXml"></param> /// <param name="aLine"></param> /// <param name="strError"></param> /// <returns>-1 一般出错;0 正常</returns> public int GetKeys( string strServerUrl, string strPath, string strXml, out List<AccessKeyInfo> aLine, out string strError) { strError = ""; aLine = null; if (String.IsNullOrEmpty(strServerUrl) == true) strServerUrl = this.ServerUrl; RmsChannel channelSave = channel; channel = Channels.GetChannel(strServerUrl); if (channel == null) { strError = "get channel error"; return -1; } try { long lRet = channel.DoGetKeys( strPath, strXml, "zh", // strLang // "", // strStyle null, // this.stop, out aLine, out strError); if (lRet == -1) { return -1; } return 0; } finally { channel = channelSave; } }
// 观察检索点 // parameters: // strRecordPath 记录路径。如果==null,表示直接用textBox_recPath中当前的内容作为路径 public void ViewAccessPoint(string strRecordPath) { if (strRecordPath == null || strRecordPath == "") strRecordPath = textBox_recPath.Text; if (strRecordPath == "") { MessageBox.Show(this, "必须指定好路径后, 才能模拟创建检索点"); return; } ResPath respath = new ResPath(strRecordPath); string strError; string strXml = ""; // 使用Channel RmsChannel channelSave = channel; channel = Channels.GetChannel(respath.Url); Debug.Assert(channel != null, "Channels.GetChannel 异常"); try { bool bHasUploadedFile = false; int nRet = GetXmlRecord(out strXml, out bHasUploadedFile, out strError); if (nRet == -1) { MessageBox.Show(this, strError); return; } } finally { channel = channelSave; } ViewAccessPointForm accessPointWindow = MainForm.TopViewAccessPointForm; if (accessPointWindow == null) { accessPointWindow = new ViewAccessPointForm(); // accessPointWindow.StartPosition = FormStartPosition.CenterScreen; accessPointWindow.Show(); accessPointWindow.MdiParent = MainForm; // MDI子窗口 } else accessPointWindow.Activate(); /* else { accessPointWindow.Focus(); if (accessPointWindow.WindowState == FormWindowState.Minimized) { accessPointWindow.WindowState = FormWindowState.Normal; } } */ /* if (accessPointWindow.Visible == false) { try // Close()过的窗口 { accessPointWindow.Show(); } catch (System.ObjectDisposedException) { accessPointWindow = new ViewAccessPointForm(); accessPointWindow.StartPosition = FormStartPosition.CenterScreen; accessPointWindow.Show(); } } */ // 使用Channel channelSave = channel; channel = Channels.GetChannel(respath.Url); Debug.Assert(channel != null, "Channels.GetChannel 异常"); try { stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在获取检索点 " + respath.FullPath); stop.BeginLoop(); EnableControlsInLoading(true); long lRet = channel.DoGetKeys( respath.Path, strXml, "zh", // "", accessPointWindow, stop, out strError); EnableControlsInLoading(false); stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); if (lRet == -1) { MessageBox.Show(this, "获取检索点失败,原因: "+strError); return; } // 设置标题 // ResPath respath = new ResPath(this.textBox_recPath.Text); accessPointWindow.Text = "观察检索点: " + respath.ReverseFullPath; } finally { channel = channelSave; } }
// 模拟创建检索点 // return: // -1 error // 0 succeed public int GetKeys( // RmsChannelCollection Channels, RmsChannel channel, string strPath, string strXml, out List<AccessKeyInfo> aLine, out string strError) { strError = ""; aLine = null; /* RmsChannel channel = Channels.GetChannel(this.WsUrl); if (channel == null) { strError = "get channel error"; return -1; } * */ Debug.Assert(channel != null, ""); long lRet = channel.DoGetKeys( strPath, strXml, "zh", // strLang // "", // strStyle null, // this.stop, out aLine, out strError); if (lRet == -1) { return -1; } return 0; }