void FillBrowseList() { this.listView_browse.Items.Clear(); List <string> recpaths = StringUtil.SplitList(this.DupBiblioRecPathList); LibraryChannel channel = Program.MainForm.GetChannel(); try { // 获得书目记录 BrowseLoader loader = new BrowseLoader(); loader.Channel = channel; // loader.Stop = this.Progress; loader.Format = "id,xml,cols,timestamp"; loader.RecPaths = recpaths; int i = 0; foreach (DigitalPlatform.LibraryClient.localhost.Record biblio_item in loader) { ListViewItem item = null; if (biblio_item.RecordBody != null && biblio_item.RecordBody.Result != null && biblio_item.RecordBody.Result.ErrorCode != DigitalPlatform.LibraryClient.localhost.ErrorCodeValue.NoError) { item = Global.AppendNewLine( this.listView_browse, biblio_item.Path, new string[] { biblio_item.RecordBody.Result.ErrorString }); item.Tag = null; } else { item = Global.AppendNewLine( this.listView_browse, biblio_item.Path, biblio_item.Cols); ItemTag tag = new ItemTag(); tag.RecPath = biblio_item.Path; tag.Xml = biblio_item.RecordBody.Xml; tag.Timestamp = biblio_item.RecordBody.Timestamp; item.Tag = tag; } i++; } if (this.listView_browse.Items.Count > 0) { ListViewUtil.SelectLine(this.listView_browse.Items[0], true); } } finally { Program.MainForm.ReturnChannel(channel); } if (this.AutoSelectMode == true) { SortItems(); if (this.listView_browse.Items.Count > 0) { ListViewUtil.SelectLine(this.listView_browse.Items[0], true); if (this.MergeStyle == dp2Circulation.MergeStyle.None) { // 自动选择保留目标书目记录的方式 this.MergeStyle = MergeStyle.ReserveTargetBiblio; } if ((this.MergeStyle & dp2Circulation.MergeStyle.ReserveTargetBiblio) == dp2Circulation.MergeStyle.ReserveTargetBiblio) { this.Action = "mergeTo"; // useTargetBiblio } else { this.Action = "mergeToUseSourceBiblio"; } this.Close(); } } }
// 显示选择的目标记录、和源记录。源记录显示在左边 void DisplaySelectedRecord(ListViewItem item) { string strError = ""; int nRet = 0; string strXmlOrigin = this.OriginXml; string strXmlTarget = ""; if (item != null) { ItemTag tag = (ItemTag)item.Tag; if (tag != null) { strXmlTarget = tag.Xml; } } string strRecPathOrigin = this.OriginRecPath; string strRecPathTarget = ""; if (item != null) { strRecPathTarget = ListViewUtil.GetItemText(item, 0); } string strOriginMARC = ""; string strOriginFragmentXml = ""; if (string.IsNullOrEmpty(strXmlOrigin) == false) { string strOutMarcSyntax = ""; // 将XML格式转换为MARC格式 // 自动从数据记录中获得MARC语法 nRet = MarcUtil.Xml2Marc(strXmlOrigin, MarcUtil.Xml2MarcStyle.Warning | MarcUtil.Xml2MarcStyle.OutputFragmentXml, "", out strOutMarcSyntax, out strOriginMARC, out strOriginFragmentXml, out strError); if (nRet == -1) { strError = "XML转换到MARC记录时出错: " + strError; goto ERROR1; } } string strTargetMARC = ""; string strTargetFragmentXml = ""; if (string.IsNullOrEmpty(strXmlTarget) == false) { string strOutMarcSyntax = ""; // 将XML格式转换为MARC格式 // 自动从数据记录中获得MARC语法 nRet = MarcUtil.Xml2Marc(strXmlTarget, MarcUtil.Xml2MarcStyle.Warning | MarcUtil.Xml2MarcStyle.OutputFragmentXml, "", out strOutMarcSyntax, out strTargetMARC, out strTargetFragmentXml, out strError); if (nRet == -1) { strError = "XML转换到MARC记录时出错: " + strError; goto ERROR1; } } else { strTargetMARC = ""; } string strHtml2 = ""; #if NO if (string.IsNullOrEmpty(strOriginMARC) == false && string.IsNullOrEmpty(strTargetMARC) == false) #endif { string strTargetTitle = "目标: " + strRecPathTarget; // 创建展示两个 MARC 记录差异的 HTML 字符串 // return: // -1 出错 // 0 成功 nRet = MarcDiff.DiffHtml( "源", strOriginMARC, strOriginFragmentXml, "", strTargetTitle, strTargetMARC, strTargetFragmentXml, "", out strHtml2, out strError); if (nRet == -1) { goto ERROR1; } } { string strHtml = "<html>" + this.MarcHtmlHead + "<body>" + strHtml2 + "</body></html>"; this.webBrowser1.Stop(); Global.SetHtmlString(this.webBrowser1, strHtml, this.TempDir, "temp_biblio_dup_html"); } return; ERROR1: { string strHtml = "<html>" + this.MarcHtmlHead + "<body>" + HttpUtility.HtmlEncode(strError) + "</body></html>"; this.webBrowser1.Stop(); Global.SetHtmlString(this.webBrowser1, strHtml, this.TempDir, "temp_biblio_dup_html"); } }