// parameters: // strAction 动作。为"new" "change" "delete" "onlydeletebiblio"之一。"delete"在删除书目记录的同时,会自动删除下属的实体记录。不过要求实体均未被借出才能删除。 // return: // -2 登录不成功 // -1 出错 // 0 成功 public static int UpdateRecord( DigitalPlatform.Stop stop, string strUrl, string strAuthString, string strAction, string strRecPath, string strFormat, string strRecord, string strTimestamp, out string strOutputRecPath, out string strOutputTimestamp, out string strError) { strError = ""; strOutputRecPath = ""; strOutputTimestamp = ""; EndpointAddress address = new EndpointAddress(strUrl); UnionCatalogServiceClient client = new UnionCatalogServiceClient(CreateBasicHttpBinding0(), address); try { IAsyncResult soapresult = client.BeginUpdateRecord( strAuthString, strAction, strRecPath, strFormat, strRecord, strTimestamp, null, null); for (; ; ) { bool bRet = DoIdle(stop); // 出让控制权,避免CPU资源耗费过度 if (bRet == true) { strError = "用户中断"; return -1; } if (soapresult.IsCompleted) break; } return client.EndUpdateRecord( out strOutputRecPath, out strOutputTimestamp, out strError, soapresult); } catch (Exception ex) { strError = ConvertWebError(ex, strUrl); return -1; } }
public SearchResultLoader(RmsChannel channel, DigitalPlatform.Stop stop, string resultsetName, string formatList, string lang = "zh") { this.Channel = channel; this.Stop = stop; this.ResultSetName = resultsetName; this.FormatList = formatList; this.Lang = lang; }
public DirItemLoader(LibraryChannel channel, DigitalPlatform.Stop stop, string path, string style, string lang = "zh") { this.Channel = channel; this.Stop = stop; this.Path = path; this.Style = style; this.Lang = lang; }
private void dpTable1_PaintRegion(object sender, DigitalPlatform.CommonControl.PaintRegionArgs e) { if (e.Action == "query") { e.Height = BAR_HEIGHT + TOP_BLANK; DpCell cell = e.Item as DpCell; DpRow row = cell.Container; int index = this.dpTable1.Rows.IndexOf(row); if (index == -1) { Debug.Assert(false, ""); return; } if (index >= this.PatronSummaries.Count) { Debug.Assert(false, ""); return; } PatronSummary summary = this.PatronSummaries[index]; if (summary != null) cell.Tag = summary; return; } // paint { DpCell cell = e.Item as DpCell; if (cell == null) { Debug.Assert(false, ""); return; } PatronSummary summary = cell.Tag as PatronSummary; if (summary == null) { Debug.Assert(false, ""); return; } ColorSummaryControl.DoPaint(e.pe.Graphics, e.X, e.Y + TOP_BLANK, new Size(e.Width, e.Height - TOP_BLANK), summary.ColorList); } }
// 内部调用 // return: // -2 strID验证失败 // -1 出错 // 0 成功 public static int SplitHanzi( DigitalPlatform.Stop stop, GcatServiceClient client, string strID, string strText, out string [] tokens, out string strError) { strError = ""; tokens = null; try { IAsyncResult soapresult = client.BeginSplitHanzi( strID, strText, null, null); for (; ; ) { bool bRet = DoIdle(stop); // 出让控制权,避免CPU资源耗费过度 if (bRet == true) { strError = "用户中断"; return -1; } if (soapresult.IsCompleted) break; } return client.EndSplitHanzi( out tokens, out strError, soapresult); } catch (Exception ex) { strError = ConvertWebError(ex, client.Endpoint.Address.Uri.ToString()); return -1; } }
void qrRecognitionControl1_Catched(object sender, DigitalPlatform.Drawing.CatchedEventArgs e) { if (string.IsNullOrEmpty(e.Text) == true) return; int nHitCount = 0; // 匹配的次数 if ((this.m_inputType & InputType.QR) == InputType.QR) { if ((e.BarcodeFormat & ZXing.BarcodeFormat.QR_CODE) != 0) nHitCount++; } // 检查是否属于 PQR 二维码 if ((this.m_inputType & InputType.PQR) == InputType.PQR) { if ((e.BarcodeFormat & ZXing.BarcodeFormat.QR_CODE) != 0 && StringUtil.HasHead(e.Text, "PQR:") == true) nHitCount++; } // 检查是否属于 ISBN 一维码 if ((this.m_inputType & InputType.EAN_BARCODE) == InputType.EAN_BARCODE) { if ((e.BarcodeFormat & ZXing.BarcodeFormat.EAN_13) != 0 /* && IsbnSplitter.IsIsbn13(e.Text) == true */) nHitCount++; } // 检查是否属于普通一维码 if ((this.m_inputType & InputType.NORMAL_BARCODE) == InputType.NORMAL_BARCODE) { if ((e.BarcodeFormat & ZXing.BarcodeFormat.All_1D) > 0) nHitCount++; } if (nHitCount > 0) { // SendKeys.Send(e.Text + "\r"); Invoke(new Action<string>(SendKey), e.Text + "\r"); } else { // TODO: 警告 } }
// 包装后的版本 public static int SplitHanzi( DigitalPlatform.Stop stop, string strUrl, string strID, string strText, out string[] tokens, out string strError) { GcatServiceClient client = CreateChannel(strUrl); try { return SplitHanzi(stop, client, strID, strText, out tokens, out strError); } finally { client.Close(); } }
// 异步版本,可以中断 // return: // -3 需要回答问题 // -2 尚未登录(info.UserID为空) // -1 出错 // 0 成功 public int GetNumber( DigitalPlatform.Stop stop, string strAuthor, bool bSelectPinyin, bool bSelectEntry, bool bOutputDebugInfo, out string strNumber, out string strDebugInfo, out string strError) { strNumber = ""; strDebugInfo = ""; strError = ""; REDO: ws.GetNumberCompleted +=new GetNumberCompletedEventHandler(ws_GetNumberCompleted); try { this.eventComplete.Reset(); ws.GetNumberAsync(strAuthor, bSelectPinyin, bSelectEntry, bOutputDebugInfo); while (true) { Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { strError = "用户中断1"; return -1; } } bool bRet = this.eventComplete.WaitOne(10, true); if (bRet == true) break; } } finally { ws.GetNumberCompleted -= new GetNumberCompletedEventHandler(ws_GetNumberCompleted); } GetNumberCompletedEventArgs e = (GetNumberCompletedEventArgs)this.resultParam; if (e.Error != null) { strError = e.Error.Message; return -1; } if (e.Cancelled == true) strError = "用户中断2"; else strError = e.strError; strNumber = e.strNumber; strDebugInfo = e.strDebugInfo; if (e.Result == -2) { if (DoNotLogin(ref strError) == 1) goto REDO; } return e.Result; }
// 获得一条MARC/XML记录 // return: // -1 error 包括not found // 0 found // 1 为诊断记录 public int GetOneRecord( string strStyle, int nTest, // 暂时使用 string strPathParam, // int index, string strParameters, // bool bHilightBrowseLine, out string strSavePath, out string strRecord, out string strXmlFragment, out string strOutStyle, out byte[] baTimestamp, out long lVersion, out DigitalPlatform.Z3950.Record record, out Encoding currrentEncoding, out LoginInfo logininfo, out string strError) { strXmlFragment = ""; strRecord = ""; record = null; strError = ""; currrentEncoding = Encoding.UTF8; // this.CurrentEncoding; baTimestamp = null; strSavePath = ""; strOutStyle = "marc"; logininfo = new LoginInfo(); lVersion = 0; int nRet = 0; if (strStyle != "marc" && strStyle != "xml") { strError = "dp2SearchForm只支持获取MARC格式记录和xml格式记录,不支持 '" + strStyle + "' 格式的记录"; return -1; } int index = -1; string strPath = ""; string strDirection = ""; nRet = Global.ParsePathParam(strPathParam, out index, out strPath, out strDirection, out strError); if (nRet == -1) return -1; ListViewItem curItem = null; if (index == -1) { // 找到 Item 行 curItem = ListViewUtil.FindItem(this.listView_browse, strPath, 0); if (curItem == null) { strError = "路径为 '" + strPath + "' 的事项在列表中没有找到"; return -1; } index = this.listView_browse.Items.IndexOf(curItem); // strDirection 方向。为 prev/next/current之一。current可以缺省。 if (strDirection == "prev") { if (index == 0) { strError = "到头"; return -1; } index--; } else if (strDirection == "next") { index++; } } { REDO: if (index >= this.listView_browse.Items.Count) { if (this.m_nCurrentPageNo >= this.m_nTotalPages - 1) { strError = "越过结果集尾部"; return -1; } nRet = DoGetNextBatch(out strError); if (nRet == -1) return -1; WaitSearchFinish(); goto REDO; } curItem = this.listView_browse.Items[index]; } bool bHilightBrowseLine = StringUtil.IsInList("hilight_browse_line", strParameters); bool bForceFullElementSet = StringUtil.IsInList("force_full", strParameters); if (bHilightBrowseLine == true) { // 修改listview中事项的选定状态 for (int i = 0; i < this.listView_browse.SelectedItems.Count; i++) { this.listView_browse.SelectedItems[i].Selected = false; } curItem.Selected = true; curItem.EnsureVisible(); } strPath = curItem.Text; ItemInfo info = (ItemInfo)curItem.Tag; if (bForceFullElementSet == true && info.EelementSet != "F") { // 需要重新装载这一条记录 List<ListViewItem> items = new List<ListViewItem>(); items.Add(curItem); #if NO // 观察和上次操作间隔的时间。保证大于一秒 TimeSpan delta = DateTime.Now - m_timeLastReload; if (delta < new TimeSpan(0,0,1)) Thread.Sleep(1000); #endif int nRedoCount = 0; REDO_RELOAD: m_bErrorBox = false; nRet = ReloadItems(items, 0, "F", out strError); m_timeLastReload = DateTime.Now; if (nRet == -1) { return -1; } bool bError = WaitSearchFinish(); if (bError == true && this.m_exception != null && this.m_exception is WebException) { WebException ex = this.m_exception as WebException; if (ex.Status == WebExceptionStatus.ProtocolError) { // 重做 if (nRedoCount < 2) { nRedoCount++; Thread.Sleep(1000); goto REDO_RELOAD; } // 询问是否重做 DialogResult result = MessageBox.Show(this, "重新装载时发生错误:\r\n\r\n" + strError + "\r\n\r\n是否重试?\r\n\r\n(Yes: 重试; No: 中断操作", "AmazonSearchForm", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == System.Windows.Forms.DialogResult.Yes) { Thread.Sleep(1000); goto REDO_RELOAD; } return -1; } } info = (ItemInfo)curItem.Tag; } record = new DigitalPlatform.Z3950.Record(); record.m_baRecord = Encoding.UTF8.GetBytes(info.Xml); record.m_strDBName = m_searchParameters != null ? m_searchParameters["SearchIndex"] : ""; record.m_strSyntaxOID = info.PreferSyntaxOID; // ??? record.m_strElementSetName = info.EelementSet; // B F strSavePath = this.CurrentProtocol + ":" + strPath; string strOutputPath = ""; { string strContent = info.Xml; if (strStyle == "marc") { // TODO: 转换为MARC nRet = ConvertXmlToMarc( record.m_strSyntaxOID, strContent, out strRecord, out strError); if (nRet == -1) return -1; strOutStyle = "marc"; if (string.IsNullOrEmpty(record.m_strSyntaxOID) == true) record.m_strSyntaxOID = "1.2.840.10003.5.1"; // UNIMARC return 0; } // 不是MARCXML格式 strRecord = strContent; strOutStyle = "xml"; return 0; } /* return GetOneRecord( true, strStyle, strPath, "", out strRecord, out strXmlFragment, out strOutputPath, out strOutStyle, out baTimestamp, out record, out currrentEncoding, out strError); * */ return 0; }
// 初始化 // parameters: // userRightsDom 用户记录的dom对象。将直接引用这个对象 public void Initial(ServerCollection servers, RmsChannelCollection channels, DigitalPlatform.StopManager stopManager, string serverUrl, XmlDocument UserRightsDom) { this.Servers = servers; this.Channels = channels; this.stopManager = stopManager; this.ServerUrl = serverUrl; this.UserRightsDom = UserRightsDom; // 直接引用外界的dom对象 // 用服务器端获得的信息填充树 Cursor save = this.Cursor; this.Cursor = Cursors.WaitCursor; FillAll(null); InitialRightsParam(); this.Cursor = save; this.m_bChanged = false; }
protected void BiblioSearchControl1_Search(object sender, DigitalPlatform.OPAC.Web.SearchEventArgs e) { if (WebUtil.PrepareEnvironment(this, ref app, ref sessioninfo) == false) return; string strError = ""; string strResultSetNamePrefix = "opac_base"; string strResultSetName = GetResultSetName(strResultSetNamePrefix); sessioninfo.Channel.Idle += new IdleEventHandler(channel_Idle); try { long lRet = sessioninfo.Channel.Search( null, e.QueryXml, strResultSetName, "", // strOutputStyle out strError); if (lRet == -1) goto ERROR1; // not found if (lRet == 0) { this.ViewResultsetControl1.ResultSetName = ""; this.ViewResultsetControl1.Visible = false; strError = "没有找到"; goto ERROR1; } e.ErrorInfo = string.Format( this.BiblioSearchControl1.GetString("hit_records_number"), lRet.ToString()); // e.ErrorInfo = "命中记录 " +lRet.ToString()+ " 条"; /* this.BrowseSearchResultControl1.Clear(); this.BrowseSearchResultControl1.Visible = true; this.BrowseSearchResultControl1.ResultSetName = strResultSetName; this.BrowseSearchResultControl1.ResultCount = (int)lRet; this.BrowseSearchResultControl1.StartIndex = 0; // 2008/12/15 * */ this.ViewResultsetControl1.Visible = true; this.ViewResultsetControl1.ResultSetName = strResultSetName; this.ViewResultsetControl1.ResultCount = (int)lRet; this.ViewResultsetControl1.StartIndex = 0; this.resultsetname.Value = strResultSetName; } finally { sessioninfo.Channel.Idle -= new IdleEventHandler(channel_Idle); } return; ERROR1: e.ErrorInfo = strError; this.ViewResultsetControl1.ResultSetName = ""; this.ViewResultsetControl1.ResultCount = 0; this.resultsetname.Value = ""; }
// TODO: 是否检查流通信息,需要可以通过参数控制 // 检索书目记录下属的事项记录,返回少量必要的信息,可以提供后面实做删除时使用 // parameters: // strStyle return_record_xml 要在DeleteEntityInfo结构中返回OldRecord内容 // check_circulation_info 检查是否具有流通信息。如果具有则会报错 2012/12/19 把缺省行为变为此参数 // 当包含 limit: 时,定义最多取得记录的个数。例如希望最多取得 10 条,可以定义 limit:10 // return: // -1 error // 0 not exist item dbname // 1 exist item dbname public int SearchChildItems(RmsChannel channel, string strBiblioRecPath, string strStyle, DigitalPlatform.LibraryServer.LibraryApplication.Delegate_checkRecord procCheckRecord, object param, out long lHitCount, out List<DeleteEntityInfo> entityinfos, out string strError) { strError = ""; lHitCount = 0; entityinfos = new List<DeleteEntityInfo>(); int nRet = 0; bool bReturnRecordXml = StringUtil.IsInList("return_record_xml", strStyle); bool bCheckCirculationInfo = StringUtil.IsInList("check_circulation_info", strStyle); bool bOnlyGetCount = StringUtil.IsInList("only_getcount", strStyle); string strLimit = StringUtil.GetParameterByPrefix(strStyle, "limit", ":"); string strBiblioDbName = ResPath.GetDbName(strBiblioRecPath); string strBiblioRecId = ResPath.GetRecordId(strBiblioRecPath); // 获得书目库对应的事项库名 string strItemDbName = ""; nRet = this.GetItemDbName(strBiblioDbName, out strItemDbName, out strError); if (nRet == -1) goto ERROR1; if (String.IsNullOrEmpty(strItemDbName) == true) return 0; // 检索实体库中全部从属于特定id的记录 string strQueryXml = "<target list='" + StringUtil.GetXmlStringSimple(strItemDbName + ":" + "父记录") + "'><item><word>" + strBiblioRecId + "</word><match>exact</match><relation>=</relation><dataType>string</dataType><maxCount>-1</maxCount></item><lang>" + "zh" + "</lang></target>"; long lRet = channel.DoSearch(strQueryXml, "entities", "", // strOuputStyle out strError); if (lRet == -1) goto ERROR1; if (lRet == 0) { strError = "没有找到属于书目记录 '" + strBiblioRecPath + "' 的任何" + this.ItemName + "记录"; return 0; } lHitCount = lRet; // 仅返回命中条数 if (bOnlyGetCount == true) return 0; int nResultCount = (int)lRet; int nMaxCount = 10000; if (nResultCount > nMaxCount) { strError = "命中" + this.ItemName + "记录数 " + nResultCount.ToString() + " 超过 " + nMaxCount.ToString() + ", 暂时不支持针对它们的删除操作"; goto ERROR1; } string strColumnStyle = "id,xml,timestamp"; int nLimit = -1; if (string.IsNullOrEmpty(strLimit) == false) Int32.TryParse(strLimit, out nLimit); int nStart = 0; int nPerCount = 100; if (nLimit != -1 && nPerCount > nLimit) nPerCount = nLimit; for (; ; ) { #if NO List<string> aPath = null; lRet = channel.DoGetSearchResult( "entities", nStart, nPerCount, "zh", null, out aPath, out strError); if (lRet == -1) goto ERROR1; if (aPath.Count == 0) { strError = "aPath.Count == 0"; goto ERROR1; } #endif Record[] searchresults = null; lRet = channel.DoGetSearchResult( "entities", nStart, nPerCount, strColumnStyle, "zh", null, out searchresults, out strError); if (lRet == -1) goto ERROR1; if (searchresults == null) { strError = "searchresults == null"; goto ERROR1; } if (searchresults.Length == 0) { strError = "searchresults.Length == 0"; goto ERROR1; } // 获得每条记录 // for (int i = 0; i < aPath.Count; i++) int i = 0; foreach (Record record in searchresults) { string strMetaData = ""; string strXml = ""; byte[] timestamp = null; string strOutputPath = ""; DeleteEntityInfo entityinfo = new DeleteEntityInfo(); if (record.RecordBody == null || string.IsNullOrEmpty(record.RecordBody.Xml) == true) { // TODO: 这里需要改造为直接从结果集中获取 xml,timestamp lRet = channel.GetRes(record.Path, out strXml, out strMetaData, out timestamp, out strOutputPath, out strError); if (lRet == -1) { if (channel.ErrorCode == ChannelErrorCode.NotFound) continue; strError = "获取" + this.ItemName + "记录 '" + record.Path + "' 时发生错误: " + strError; goto ERROR1; // goto CONTINUE; } } else { strXml = record.RecordBody.Xml; strOutputPath = record.Path; timestamp = record.RecordBody.Timestamp; } entityinfo.RecPath = strOutputPath; entityinfo.OldTimestamp = timestamp; if (bReturnRecordXml == true) entityinfo.OldRecord = strXml; if (bCheckCirculationInfo == true || procCheckRecord != null) { // 检查是否有借阅信息 // 把记录装入DOM XmlDocument domExist = new XmlDocument(); try { domExist.LoadXml(strXml); } catch (Exception ex) { strError = this.ItemName + "记录 '" + record.Path + "' 装载进入DOM时发生错误: " + ex.Message; goto ERROR1; } // 2016/11/15 if (procCheckRecord != null) { nRet = procCheckRecord( nStart + i, strOutputPath, domExist, timestamp, param, out strError); if (nRet != 0) return nRet; } /* entityinfo.ItemBarcode = DomUtil.GetElementText(domExist.DocumentElement, "barcode"); * */ // TODO: 在日志恢复阶段调用本函数时,是否还有必要检查是否具有流通信息?似乎这时应强制删除为好 // 观察已经存在的记录是否有流通信息 // return: // -1 出错 // 0 没有 // 1 有。报错信息在strError中 nRet = this.HasCirculationInfo(domExist, out strError); if (nRet == -1) goto ERROR1; if (nRet == 1) { strError = "拟删除的" + this.ItemName + "记录 '" + entityinfo.RecPath + "' 中" + strError + "(此种情况可能不限于这一条),不能删除。因此全部删除操作均被放弃。"; goto ERROR1; } } // CONTINUE: entityinfos.Add(entityinfo); i++; } nStart += searchresults.Length; if (nStart >= nResultCount) break; if (nLimit != -1 && nStart >= nLimit) break; } return 1; ERROR1: return -1; }
public void Initial(ServerCollection servers, RmsChannelCollection channels, DigitalPlatform.StopManager stopManager, string serverUrl, string strCfgFilePath) { this.Servers = servers; this.Channels = channels; this.stopManager = stopManager; this.ServerUrl = serverUrl; this.Path = strCfgFilePath; // this.textBox_path.Text = this.ServerUrl + "?" + this.Path; }
public void Initial(ServerCollection servers, RmsChannelCollection channels, DigitalPlatform.StopManager stopManager, string serverUrl, string strDatabaseObject) { this.Servers = servers; this.Channels = channels; this.stopManager = stopManager; this.ServerUrl = serverUrl; this.textBox_databaseObject.Text = strDatabaseObject; }
private void treeView_res_OnSetMenu(object sender, DigitalPlatform.GUI.GuiAppendMenuEventArgs e) { Debug.Assert(e.ContextMenu != null, "e不能为null"); int nNodeType = -1; TreeNode node = this.treeView_res.SelectedNode; if (node != null) nNodeType = node.ImageIndex; MenuItem menuItem = new MenuItem("-"); e.ContextMenu.MenuItems.Add(menuItem); // 帐户管理 menuItem = new MenuItem("帐户(&A)..."); menuItem.Click += new System.EventHandler(this.menuItem_accountManagement_Click); e.ContextMenu.MenuItems.Add(menuItem); // 新建帐户 menuItem = new MenuItem("新帐户(&N)..."); menuItem.Click += new System.EventHandler(this.menuItem_newAccount_Click); e.ContextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("-"); e.ContextMenu.MenuItems.Add(menuItem); // 配置数据库 menuItem = new MenuItem("数据库(&M)..."); menuItem.Click += new System.EventHandler(this.menuItem_databaseManagement_Click); if (nNodeType != ResTree.RESTYPE_DB) menuItem.Enabled = false; e.ContextMenu.MenuItems.Add(menuItem); // 新建数据库 menuItem = new MenuItem("新建数据库(&N)..."); menuItem.Click += new System.EventHandler(this.menuItem_newDatabase_Click); e.ContextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("-"); e.ContextMenu.MenuItems.Add(menuItem); // 删除数据库 menuItem = new MenuItem("删除数据库(&D)"); menuItem.Click += new System.EventHandler(this.menuItem_deleteObject_Click); if (nNodeType != ResTree.RESTYPE_DB && nNodeType != ResTree.RESTYPE_FILE && nNodeType != ResTree.RESTYPE_FOLDER) menuItem.Enabled = false; if (nNodeType != ResTree.RESTYPE_DB) menuItem.Text = "删除对象(&D)"; e.ContextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("-"); e.ContextMenu.MenuItems.Add(menuItem); #if NO // 关联本地目录 menuItem = new MenuItem("关联本地目录(&L)..."); menuItem.Click += new System.EventHandler(this.menuItem_linkLocalDir_Click); e.ContextMenu.MenuItems.Add(menuItem); menuItem = new MenuItem("-"); e.ContextMenu.MenuItems.Add(menuItem); #endif // 输出模板 menuItem = new MenuItem("导出模板(&E)..."); menuItem.Click += new System.EventHandler(this.menuItem_exportTemplate_Click); e.ContextMenu.MenuItems.Add(menuItem); // 导入模板 menuItem = new MenuItem("导入模板(&I)..."); menuItem.Click += new System.EventHandler(this.menuItem_importTemplate_Click); e.ContextMenu.MenuItems.Add(menuItem); }
// 下载资源,保存到备份文件 public static int WriteResToBackupFile( IWin32Window owner, Stream outputfile, string strXmlRecPath, string[] res_ids, RmsChannel channel, DigitalPlatform.Stop stop, out string strError) { strError = ""; long lRet; for (int i = 0; i < res_ids.Length; i++) { Application.DoEvents(); // 出让界面控制权 if (stop.State != 0) { DialogResult result = MessageBox.Show(owner, "确实要中断当前批处理操作?", "dp2batch", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { strError = "用户中断"; return -1; } else { stop.Continue(); } } string strID = res_ids[i].Trim(); if (strID == "") continue; string strResPath = strXmlRecPath + "/object/" + strID; string strMetaData; if (stop != null) stop.SetMessage("正在下载 " + strResPath); long lResStart = 0; // 写res的头。 // 如果不能预先确知整个res的长度,可以用随便一个lTotalLength值调用本函数, // 但是需要记忆下函数所返回的lStart,最后调用EndWriteResToBackupFile()。 // 如果能预先确知整个res的长度,则最后不必调用EndWriteResToBackupFile() lRet = Backup.BeginWriteResToBackupFile( outputfile, 0, // 未知 out lResStart); byte[] baOutputTimeStamp = null; string strOutputPath; REDO_GETRES: lRet = channel.GetRes(strResPath, (Stream)null, // 故意不获取资源体 stop, "metadata,timestamp,outputpath", null, out strMetaData, // 但是要获得metadata out baOutputTimeStamp, out strOutputPath, out strError); if (lRet == -1) { // TODO: 允许重试 DialogResult redo_result = MessageBox.Show(owner, "获取记录 '" + strResPath + "' 时出现错误: " + strError + "\r\n\r\n重试,还是中断当前批处理操作?\r\n(Retry 重试;Cancel 中断批处理)", "dp2batch", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (redo_result == DialogResult.Cancel) return -1; goto REDO_GETRES; } byte[] timestamp = baOutputTimeStamp; ResPath respath = new ResPath(); respath.Url = channel.Url; respath.Path = strOutputPath; // strResPath; // strMetaData还要加入资源id? ExportUtil.ChangeMetaData(ref strMetaData, strID, null, null, null, respath.FullPath, ByteArray.GetHexTimeStampString(baOutputTimeStamp)); lRet = Backup.WriteResMetadataToBackupFile(outputfile, strMetaData); if (lRet == -1) return -1; long lBodyStart = 0; // 写res body的头。 // 如果不能预先确知body的长度,可以用随便一个lBodyLength值调用本函数, // 但是需要记忆下函数所返回的lBodyStart,最后调用EndWriteResBodyToBackupFile()。 // 如果能预先确知body的长度,则最后不必调用EndWriteResBodyToBackupFile() lRet = Backup.BeginWriteResBodyToBackupFile( outputfile, 0, // 未知 out lBodyStart); if (lRet == -1) return -1; if (stop != null) stop.SetMessage("正在下载 " + strResPath + " 的数据体"); REDO_GETRES_1: lRet = channel.GetRes(strResPath, outputfile, stop, "content,data,timestamp", //"content,data,timestamp" timestamp, out strMetaData, out baOutputTimeStamp, out strOutputPath, out strError); if (lRet == -1) { if (channel.ErrorCode == ChannelErrorCode.EmptyRecord) { // 空记录 } else { // TODO: 允许重试 DialogResult redo_result = MessageBox.Show(owner, "获取记录 '" + strResPath + "' 时出现错误: " + strError + "\r\n\r\n重试,还是中断当前批处理操作?\r\n(Retry 重试;Cancel 中断批处理)", "dp2batch", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (redo_result == DialogResult.Cancel) return -1; goto REDO_GETRES_1; } } long lBodyLength = outputfile.Position - lBodyStart - 8; // res body收尾 lRet = Backup.EndWriteResBodyToBackupFile( outputfile, lBodyLength, lBodyStart); if (lRet == -1) return -1; long lTotalLength = outputfile.Position - lResStart - 8; lRet = Backup.EndWriteResToBackupFile( outputfile, lTotalLength, lResStart); if (lRet == -1) return -1; } /* if (stop != null) stop.SetMessage("保存资源到备份文件全部完成"); */ return 0; }
// GCAT通道登录 旧的方式 public void gcat_channel_BeforeLogin(object sender, DigitalPlatform.GcatClient.BeforeLoginEventArgs e) { string strUserName = (string)this.DetailForm.MainForm.ParamTable["author_number_account_username"]; string strPassword = (string)this.DetailForm.MainForm.ParamTable["author_number_account_password"]; if (String.IsNullOrEmpty(strUserName) == true) { strUserName = "******"; strPassword = ""; } // 直接试探 if (!(e.UserName == strUserName && e.Failed == true) && strUserName != "") { e.UserName = strUserName; e.Password = strPassword; return; } LoginDlg dlg = new LoginDlg(); GuiUtil.SetControlFont(dlg, this.DetailForm.MainForm.Font); if (e.Failed == true) dlg.textBox_comment.Text = "登录失败。加著者号码功能需要重新登录"; else dlg.textBox_comment.Text = "加著者号码功能需要登录"; dlg.textBox_serverAddr.Text = e.GcatServerUrl; dlg.textBox_userName.Text = strUserName; dlg.textBox_password.Text = strPassword; dlg.checkBox_savePassword.Checked = true; dlg.textBox_serverAddr.Enabled = false; dlg.TopMost = true; // 2009/11/12 因为ShowDialog(null),为了防止对话框被放在非顶部 dlg.ShowDialog(null); if (dlg.DialogResult != DialogResult.OK) { e.Cancel = true; // 2009/11/12 如果缺这一句,会造成Cancel后仍然重新弹出登录对话框 return; } strUserName = dlg.textBox_userName.Text; strPassword = dlg.textBox_password.Text; e.UserName = strUserName; e.Password = strPassword; this.DetailForm.MainForm.ParamTable["author_number_account_username"] = strUserName; this.DetailForm.MainForm.ParamTable["author_number_account_password"] = strPassword; }
private void dp2QueryControl1_GetList(object sender, DigitalPlatform.CommonControl.GetListEventArgs e) { // 获得所有数据库名 if (string.IsNullOrEmpty(e.Path) == true) { if (this.MainForm.BiblioDbProperties != null) { for (int i = 0; i < this.MainForm.BiblioDbProperties.Count; i++) { BiblioDbProperty property = this.MainForm.BiblioDbProperties[i]; e.Values.Add(property.DbName); } } } else { // 获得特定数据库的检索途径 // 每个库都一样 for (int i = 0; i < this.MainForm.BiblioDbFromInfos.Length; i++) { BiblioDbFromInfo info = this.MainForm.BiblioDbFromInfos[i]; e.Values.Add(info.Caption); // + "\t" + info.Style); } } }
// 获得一条MARC/XML记录 // return: // -1 error 包括not found // 0 found // 1 为诊断记录 public int GetOneRecord( string strStyle, int nTest, string strPathParam, string strParameters, // bool bHilightBrowseLine, out string strSavePath, out string strRecord, out string strXmlFragment, out string strOutStyle, out byte[] baTimestamp, out long lVersion, out DigitalPlatform.Z3950.Record record, out Encoding currrentEncoding, out LoginInfo logininfo, out string strError) { strXmlFragment = ""; strRecord = ""; record = null; strError = ""; currrentEncoding = this.CurrentEncoding; baTimestamp = null; strSavePath = ""; strOutStyle = "marc"; logininfo = new LoginInfo(); lVersion = 0; // 防止重入 if (m_bInSearch == true) { strError = "当前窗口正在被一个未结束的长操作使用,无法获得记录。请稍后再试。"; return -1; } if (strStyle != "marc" && strStyle != "xml") { strError = "DupForm只支持获取MARC格式记录和xml格式记录,不支持 '" + strStyle + "' 格式的记录"; return -1; } int nRet = 0; int index = -1; string strPath = ""; string strDirection = ""; nRet = Global.ParsePathParam(strPathParam, out index, out strPath, out strDirection, out strError); if (nRet == -1) return -1; if (index == -1) { strError = "暂时不支持没有 index 的用法"; return -1; } bool bHilightBrowseLine = StringUtil.IsInList("hilight_browse_line", strParameters); if (index >= this.listView_browse.Items.Count) { strError = "越过结果集尾部"; return -1; } ListViewItem curItem = this.listView_browse.Items[index]; if (bHilightBrowseLine == true) { // 修改listview中事项的选定状态 for (int i = 0; i < this.listView_browse.SelectedItems.Count; i++) { this.listView_browse.SelectedItems[i].Selected = false; } curItem.Selected = true; curItem.EnsureVisible(); } string strPurePath = curItem.Text; string strServerName = this.LibraryServerName; strPath = strPurePath + "@" + this.LibraryServerName; strSavePath = this.CurrentProtocol + ":" + strPath; // 拉上一个dp2检索窗,好办事 dp2SearchForm dp2_searchform = this.GetDp2SearchForm(); if (dp2_searchform == null) { strError = "没有打开的dp2检索窗,无法GetOneRecordSyntax()"; return -1; } // 获得server url string strServerUrl = dp2_searchform.GetServerUrl(strServerName); if (strServerUrl == null) { strError = "没有找到服务器名 '" + strServerName + "' 对应的URL"; return -1; } this.Channel = this.Channels.GetChannel(strServerUrl); stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在初始化浏览器组件 ..."); stop.BeginLoop(); this.Update(); this.MainForm.Update(); try { stop.SetMessage("正在装入书目记录 " + strPath + " ..."); string[] formats = null; formats = new string[1]; formats[0] = "xml"; string[] results = null; long lRet = Channel.GetBiblioInfos( stop, strPurePath, "", formats, out results, out baTimestamp, out strError); if (lRet == 0) { strError = "路径为 '" + strPath + "' 的书目记录没有找到 ..."; goto ERROR1; // not found } if (lRet == -1) goto ERROR1; // this.BiblioTimestamp = baTimestamp; if (results == null) { strError = "results == null"; goto ERROR1; } if (results.Length != formats.Length) { strError = "result.Length != formats.Length"; goto ERROR1; } string strXml = results[0]; if (strStyle == "marc") { string strMarcSyntax = ""; string strOutMarcSyntax = ""; // 从数据记录中获得MARC格式 nRet = MarcUtil.Xml2Marc(strXml, true, strMarcSyntax, out strOutMarcSyntax, out strRecord, out strError); if (nRet == -1) { strError = "XML转换到MARC记录时出错: " + strError; goto ERROR1; } // 获得书目以外的其它XML片断 nRet = dp2SearchForm.GetXmlFragment(strXml, out strXmlFragment, out strError); if (nRet == -1) goto ERROR1; } else { strRecord = strXml; strOutStyle = strStyle; } } finally { stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); } return 0; ERROR1: return -1; }
protected void BiblioSearchControl1_Search(object sender, DigitalPlatform.OPAC.Web.SearchEventArgs e) { if (WebUtil.PrepareEnvironment(this, ref app, ref sessioninfo) == false) return; string strError = ""; string strResultSetNamePrefix = Session.SessionID + "_opac_base"; // "opac_base"; string strResultSetName = GetResultSetName(strResultSetNamePrefix); LibraryChannel channel = sessioninfo.GetChannel(true); // sessioninfo.Channel. channel.Idle += new IdleEventHandler(channel_Idle); try { long lRet = // sessioninfo.Channel. channel.Search( null, e.QueryXml, strResultSetName, "", // strOutputStyle out strError); if (lRet == -1) goto ERROR1; #if FILTER app.SetFilterTask(strResultSetName, null); #endif if (app.SearchLog != null) { SearchLogItem log = new SearchLogItem(); log.IP = this.Request.UserHostAddress.ToString(); log.Query = e.QueryXml; log.Time = DateTime.UtcNow; log.HitCount = (int)lRet; log.Format = "searchcount"; app.SearchLog.AddLogItem(log); } // not found if (lRet == 0) { this.BrowseSearchResultControl1.Visible = false; #if FITLER this.filter.Visible = false; #endif strError = "没有找到"; goto ERROR1; } e.ErrorInfo = string.Format( this.BiblioSearchControl1.GetString("hit_records_number"), lRet.ToString()); // e.ErrorInfo = "命中记录 " +lRet.ToString()+ " 条"; this.BrowseSearchResultControl1.Clear(); this.BrowseSearchResultControl1.Visible = true; #if FILTER VisibleFilter(true); #endif this.BrowseSearchResultControl1.ResultSetName = strResultSetName; this.BrowseSearchResultControl1.ResultCount = (int)lRet; this.BrowseSearchResultControl1.StartIndex = 0; // 2008/12/15 #if FILTER this.filter.ResultSetName = strResultSetName; #endif } finally { //sessioninfo.Channel. channel.Idle -= new IdleEventHandler(channel_Idle); sessioninfo.ReturnChannel(channel); } return; ERROR1: e.ErrorInfo = strError; this.BrowseSearchResultControl1.ResultSetName = ""; this.BrowseSearchResultControl1.ResultCount = 0; #if FILTER this.filter.ResultSetName = ""; #endif }
private void treeView_objects_OnSetMenu(object sender, DigitalPlatform.GUI.GuiAppendMenuEventArgs e) { Debug.Assert(e.ContextMenu != null, "e不能为null"); MenuItem menuItem = new MenuItem("-"); e.ContextMenu.MenuItems.Add(menuItem); TreeNode node = this.treeView_objects.SelectedNode; string strText = "权限(&R)"; if (node == null || node.ImageIndex == ResTree.RESTYPE_DB) strText = "权限[数据库整体](&R)"; else strText = "权限[对象'"+node.Text+"'](&R)"; menuItem = new MenuItem(strText); menuItem.Click += new System.EventHandler(this.menu_quickSetRights_Click); e.ContextMenu.MenuItems.Add(menuItem); }
void Channel_BeforeLogin(object sender, DigitalPlatform.CirculationClient.BeforeLoginEventArgs e) { MainForm.Channel_BeforeLogin(this, e); }
/* void quickrights_GetTreeNodeByPath(object sender, GetTreeNodeByPathEventArgs e) { e.Node = TreeViewUtil.GetTreeNode(this.treeView_objects.Nodes[0], e.Path); } */ // treeview中一个对象已经被删除, 这里处理后续事情 private void treeView_objects_OnObjectDeleted(object sender, DigitalPlatform.rms.Client.OnObjectDeletedEventArgs e) { string strError = ""; int nRet = RemoveObjectFromCache(e.ObjectPath, out strError); if (nRet == -1) { MessageBox.Show(this, strError); return; } // this.m_rightsChanged.Remove(e.ObjectPath); }
void SetCheckList(DigitalPlatform.Text.SectionPropertyString.PropertyCollection pc) { PrepareTag(); string strCurCategory = this.SelectedCategory; if (String.IsNullOrEmpty(strCurCategory)) strCurCategory = "*"; for (int i = 0; i < m_pc.Count; i++) { Section section = m_pc[i]; // 析出名字 string strSectionName = section.Name; string strValues = section.ToString(); if (String.IsNullOrEmpty(strSectionName) == true) strSectionName = "this"; // 看看是否在可显示范围 if (strCurCategory == "*" || String.Compare(strCurCategory, strSectionName, true) == 0) { } else continue; for (int j = 0; j < section.Count; j++) { Item propertyItem = section[j]; ListViewItem item = LocateListItem(strSectionName, propertyItem.Value); if (item == null) { // 未定义的保留值 } else { if (item.Checked != true) { item.BackColor = CheckedBackColor; item.Checked = true; item.Tag = null; // 标记,表示本次触及到了 } else item.Tag = null; // 不用动 } } } // uncheck本次没有on的 for (int i = 0; i < this.listView_property.Items.Count; i++) { ListViewItem item = this.listView_property.Items[i]; if (item.Tag == null) { } else { if ((bool)item.Tag == false && item.Checked != false) { item.BackColor = UncheckedBackColor; item.Checked = false; } if ((bool)item.Tag == true && item.Checked != true) { item.BackColor = CheckedBackColor; item.Checked = true; } } } }
public int Initial(ServerCollection servers, RmsChannelCollection channels, DigitalPlatform.StopManager stopManager, string serverUrl, out string strError) { this.Servers = servers; this.Channels = channels; this.stopManager = stopManager; this.ServerUrl = serverUrl; strError = ""; int nRet = Fill(this.Lang, out strError); if (nRet == -1) return -1; return 0; }
internal void Channel_BeforeLogin(object sender, DigitalPlatform.LibraryClient.BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.textBox_server_userName.Text; e.Password = this.textBox_server_password.Text; e.Parameters += ",client=dp2catalog|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } e.Cancel = true; return; }
internal void Channel_BeforeLogin(object sender, DigitalPlatform.LibraryClient.BeforeLoginEventArgs e) { if (e.FirstTry == true) { e.UserName = this.SupervisorUserName; // "supervisor"; e.Password = this.DecryptPasssword(AppInfo.GetString( "default_account", "password", "")); string strLocation = "manager"; e.Parameters = "location=" + strLocation; e.Parameters += ",client=dp2libraryxe|" + Program.ClientVersion; if (String.IsNullOrEmpty(e.UserName) == false) return; // 立即返回, 以便作第一次 不出现 对话框的自动登录 } #if NO e.Cancel = true; e.ErrorInfo = "管理帐户无效"; #endif // IWin32Window owner = null; if (sender is IWin32Window) owner = (IWin32Window)sender; else owner = this; CirculationLoginDlg dlg = SetDefaultAccount( e.LibraryServerUrl, null, e.ErrorInfo, e.LoginFailCondition, owner); if (dlg == null) { e.Cancel = true; return; } e.UserName = dlg.UserName; e.Password = dlg.Password; e.SavePasswordShort = dlg.SavePasswordShort; e.Parameters = "location=" + dlg.OperLocation; #if NO if (dlg.IsReader == true) e.Parameters += ",type=reader"; // 2014/9/13 e.Parameters += ",mac=" + StringUtil.MakePathList(SerialCodeForm.GetMacAddress(), "|"); // 从序列号中获得 expire= 参数值 { string strExpire = GetExpireParam(); if (string.IsNullOrEmpty(strExpire) == false) e.Parameters += ",expire=" + strExpire; } // 2014/10/23 if (this.TestMode == true) e.Parameters += ",testmode=true"; #endif e.Parameters += ",client=dp2libraryxe|" + Program.ClientVersion; e.SavePasswordLong = dlg.SavePasswordLong; if (e.LibraryServerUrl != dlg.ServerUrl) { e.LibraryServerUrl = dlg.ServerUrl; // _expireVersionChecked = false; } }
private void MarcEditor_GetConfigFile(object sender, DigitalPlatform.Marc.GetConfigFileEventArgs e) { int nRet = 0; string strError = ""; if (String.IsNullOrEmpty(this.SavePath) == false) { string strProtocol = ""; string strPath = ""; // 分离出各个部分 nRet = Global.ParsePath(this.SavePath, out strProtocol, out strPath, out strError); if (nRet == -1) { strError = "解析路径 '" + this.SavePath + "' 字符串过程中发生错误: " + strError; goto ERROR1; } if (strProtocol != "dp2library") goto OTHER; dp2SearchForm dp2_searchform = this.GetDp2SearchForm(); if (dp2_searchform == null) { strError = "没有连接的或者打开的dp2检索窗,无法获取配置文件"; goto ERROR1; } string strServerName = ""; string strLocalPath = ""; // 解析记录路径。 // 记录路径为如下形态 "中文图书/1 @服务器" dp2SearchForm.ParseRecPath(strPath, out strServerName, out strLocalPath); if (string.Compare(strServerName, "mem", true) == 0 || string.Compare(strServerName, "file", true) == 0) goto OTHER; string strBiblioDbName = dp2SearchForm.GetDbName(strLocalPath); string strSyntax = ""; // 获得一个数据库的数据syntax // parameters: // stop 如果!=null,表示使用这个stop,它已经OnStop += // 如果==null,表示会自动使用this.stop,并自动OnStop+= // return: // -1 error // 0 not found // 1 found nRet = dp2_searchform.GetDbSyntax( null, strServerName, strBiblioDbName, out strSyntax, out strError); if (nRet == -1) { strError = "获取书目库 '" + strBiblioDbName + "的数据格式时发生错误: " + strError; goto ERROR1; } /* string strDefFilename = ""; if (strSyntax == "unimarc" || strSyntax == "usmarc") strDefFilename = "marcdef"; else { strError = "所选书目库 '" + strBiblioDbName + "' 不是MARC格式的数据库"; goto ERROR1; }*/ // 得到干净的文件名 string strCfgFileName = e.Path; nRet = strCfgFileName.IndexOf("#"); if (nRet != -1) { strCfgFileName = strCfgFileName.Substring(0, nRet); } // 然后获得cfgs/template配置文件 string strCfgFilePath = strBiblioDbName + "/cfgs/" + strCfgFileName + "@" + strServerName; string strCode = ""; byte[] baCfgOutputTimestamp = null; nRet = dp2_searchform.GetCfgFile( true, strCfgFilePath, out strCode, out baCfgOutputTimestamp, out strError); if (nRet == -1) goto ERROR1; e.Stream = new MemoryStream(Encoding.UTF8.GetBytes(strCode)); return; } OTHER: { string strCfgFileName = e.Path; nRet = strCfgFileName.IndexOf("#"); if (nRet != -1) { strCfgFileName = strCfgFileName.Substring(0, nRet); } string strMarcSyntaxOID = ""; strMarcSyntaxOID = this.GetCurrentMarcSyntaxOID(out strError); if (String.IsNullOrEmpty(strMarcSyntaxOID) == true) { e.ErrorInfo = "因为: " + strError + ",无法获得配置文件 '" + strCfgFileName + "'"; return; } string strPath = this.MainForm.DataDir + "\\" + strMarcSyntaxOID.Replace(".", "_") + "\\" + strCfgFileName; try { Stream s = File.OpenRead(strPath); e.Stream = s; } catch (Exception ex) { e.ErrorInfo = "文件 " + strPath + " 打开失败: " + ex.Message; } } return; ERROR1: e.ErrorInfo = strError; }
// marc编辑窗要从外部获得配置文件内容 private void MarcEditor_GetConfigFile(object sender, DigitalPlatform.Marc.GetConfigFileEventArgs e) { Debug.Assert(false, "改造后不要用这个事件接口"); if (String.IsNullOrEmpty(this.BiblioRecPath) == true) { e.ErrorInfo = "记录路径为空,无法获得配置文件"; return; } // 下载配置文件 // 得到干净的文件名 string strCfgFileName = e.Path; int nRet = strCfgFileName.IndexOf("#"); if (nRet != -1) { strCfgFileName = strCfgFileName.Substring(0, nRet); } string strBiblioDbName = Global.GetDbName(this.BiblioRecPath); string strContent = ""; string strError = ""; byte[] baCfgOutputTimestamp = null; // return: // -1 error // 0 not found // 1 found nRet = GetCfgFileContent(strBiblioDbName, strCfgFileName, out strContent, out baCfgOutputTimestamp, out strError); if (nRet == -1 || nRet == 0) { e.ErrorInfo = "获得配置文件 '" + strCfgFileName + "' 时出错:" + strError; } else { byte[] baContent = StringUtil.GetUtf8Bytes(strContent, true); MemoryStream stream = new MemoryStream(baContent); e.Stream = stream; } }
int m_nInGetCfgFile = 0; // 防止GetCfgFile()函数重入 2008/3/6 // marc编辑窗要从外部获得配置文件内容 private void MarcEditor_GetConfigFile(object sender, DigitalPlatform.Marc.GetConfigFileEventArgs e) { if (m_nInGetCfgFile > 0) { e.ErrorInfo = "MarcEditor_GetConfigFile() 重入了"; return; } if (String.IsNullOrEmpty(textBox_recPath.Text)) { e.ErrorInfo = "URL为空"; return; } // 下载配置文件 ResPath respath = new ResPath(textBox_recPath.Text); string strCfgFileName = e.Path; int nRet = strCfgFileName.IndexOf("#"); if (nRet != -1) { strCfgFileName = strCfgFileName.Substring(0, nRet); } string strPath = ResPath.GetDbName(respath.Path) + "/cfgs/" + strCfgFileName; // 使用Channel RmsChannel channelSave = channel; channel = Channels.GetChannel(respath.Url); Debug.Assert(channel != null, "Channels.GetChannel 异常"); m_nInGetCfgFile++; try { string strContent; string strError; stop.OnStop += new StopEventHandler(this.DoStop); stop.Initial("正在下载文件" + strPath); stop.BeginLoop(); byte[] baTimeStamp = null; string strMetaData; string strOutputPath; long lRet = channel.GetRes( MainForm.cfgCache, strPath, out strContent, out strMetaData, out baTimeStamp, out strOutputPath, out strError); stop.EndLoop(); stop.OnStop -= new StopEventHandler(this.DoStop); stop.Initial(""); if (lRet == -1) { if (channel.ErrorCode == ChannelErrorCode.NotFound) { e.ErrorInfo = ""; return; } e.ErrorInfo = "获得配置文件 '" + strPath + "' 时出错:" + strError; return; } else { byte[] baContent = StringUtil.GetUtf8Bytes(strContent, true); MemoryStream stream = new MemoryStream(baContent); e.Stream = stream; } } finally { channel = channelSave; m_nInGetCfgFile--; } }