void prop_GetColumnTitles(object sender, GetColumnTitlesEventArgs e) { if (e.DbName == "<blank>") { e.ColumnTitles = new ColumnPropertyCollection(); e.ColumnTitles.Add("检索点"); e.ColumnTitles.Add("数量"); return; } if (e.DbName.IndexOf("@") == -1) { e.ColumnTitles = Program.MainForm.GetBrowseColumnProperties(e.DbName); } else { string strFormat = ""; if (this.m_biblioTable != null) { BiblioInfo info = this.m_biblioTable[e.DbName] as BiblioInfo; if (info != null) { strFormat = info.Format; } } e.ColumnTitles = new ColumnPropertyCollection(); string strColumnTitles = (string)_browseTitleTable[strFormat]; List <string> titles = StringUtil.SplitList(strColumnTitles, '\t'); foreach (string s in titles) { ColumnProperty property = new ColumnProperty(s); e.ColumnTitles.Add(property); } } }
void OnLoadDetail() { if (this.OpenDetail == null) { return; } if (this.listView_records.SelectedItems.Count == 0) { return; } DoStop(); string strError = ""; // string[] paths = new string[this.listView_records.SelectedItems.Count]; List <string> path_list = new List <string>(); List <BiblioInfo> biblioInfo_list = new List <BiblioInfo>(); //int i = 0; foreach (ListViewItem item in this.listView_records.SelectedItems) { string strPath = item.Text; if (strPath.IndexOf("@") == -1) { path_list.Add(strPath); } else { BiblioInfo info = m_biblioTable[strPath] as BiblioInfo; if (info == null) { strError = "路径为 '" + strPath + "' 的事项在 m_biblioTable 中没有找到"; goto ERROR1; } biblioInfo_list.Add(info); } // paths[i++] = strPath; } OpenDetailEventArgs args = new OpenDetailEventArgs(); string[] paths = new string[path_list.Count]; path_list.CopyTo(paths); args.Paths = paths; args.BiblioInfos = biblioInfo_list; args.OpenNew = true; #if NO this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; #endif DoOpenDetail(args); return; ERROR1: MessageBox.Show(this, strError); }
/* * private void listView_records_DoubleClick(object sender, EventArgs e) * { * OnLoadDetail(); * * this.DialogResult = DialogResult.OK; * this.Close(); * } */ /// <summary> /// 装入第一条记录到详细窗 /// </summary> /// <param name="bCloseWindow">是否顺便关闭本窗口</param> public void LoadFirstDetail(bool bCloseWindow) { if (this.listView_records.Items.Count == 0) { return; } string strError = ""; string strPath = this.listView_records.Items[0].Text; if (strPath.IndexOf("@") == -1) { string[] paths = new string[1]; paths[0] = strPath; OpenDetailEventArgs args = new OpenDetailEventArgs(); args.Paths = paths; args.OpenNew = false; #if NO this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; #endif DoOpenDetail(args); } else { BiblioInfo info = m_biblioTable[strPath] as BiblioInfo; if (info == null) { strError = "路径为 '" + strPath + "' 的事项在 m_biblioTable 中没有找到"; goto ERROR1; } OpenDetailEventArgs args = new OpenDetailEventArgs(); args.Paths = null; args.BiblioInfos = new List <BiblioInfo>(); args.BiblioInfos.Add(info); args.OpenNew = false; #if NO this.listView_records.Enabled = false; this.OpenDetail(this, args); this.listView_records.Enabled = true; #endif DoOpenDetail(args); } if (bCloseWindow == true) { this.DialogResult = DialogResult.OK; this.Close(); } return; ERROR1: MessageBox.Show(this, strError); }
// parameters: // biblioRecPathList 按照出现先后的顺序存储书目记录路径 // groupTable 书目记录路径 --> List<string> (册记录路径列表) // return: // -1 出错 // 0 中断处理 // 1 正常结束处理 public static int Dump( LibraryChannel channel, Stop stop, string strDbType, List <string> biblioRecPathList, Hashtable groupTable, Delegate_biblioPrepared biblioPrepared, Delegate_itemPrepared itemPrepared, Delegate_biblioDone biblioDone, Delegate_idle idle, out string strError) { strError = ""; int nRet = 0; foreach (string strBiblioRecPath in biblioRecPathList) { // Application.DoEvents(); if (idle != null) { if (idle() == false) { strError = "中断处理"; return(0); } } if (stop != null && stop.State != 0) { strError = "用户中断"; return(0); } string[] results = null; byte[] baTimestamp = null; stop.SetMessage("正在获取书目记录 " + strBiblioRecPath); long lRet = channel.GetBiblioInfos( stop, strBiblioRecPath, "", new string[] { "xml" }, // formats out results, out baTimestamp, out strError); if (lRet == 0) { return(-1); } if (lRet == -1) { return(-1); } if (results == null || results.Length == 0) { strError = "GetBiblioInfos() results error"; return(-1); } string strXml = results[0]; BiblioInfo biblio_info = new BiblioInfo(); biblio_info.RecPath = strBiblioRecPath; biblio_info.OldXml = strXml; biblio_info.Timestamp = baTimestamp; if (biblioPrepared != null) { if (biblioPrepared(biblio_info) == false) { strError = "中断处理"; return(0); } } List <string> item_recpaths = (List <string>)groupTable[strBiblioRecPath]; foreach (string item_recpath in item_recpaths) { // 获得一条记录 //return: // -1 出错 // 0 没有找到 // 1 找到 nRet = GetRecord( channel, stop, strDbType, item_recpath, out string strItemXml, out byte[] baItemTimestamp, out strError); if (nRet == -1) { return(-1); } #if NO XmlDocument item_dom = new XmlDocument(); item_dom.LoadXml(strItemXml); #endif BiblioInfo item_info = new BiblioInfo(); item_info.RecPath = item_recpath; item_info.Timestamp = baItemTimestamp; item_info.OldXml = strItemXml; // DomUtil.RemoveEmptyElements(item_dom.DocumentElement); if (itemPrepared != null) { if (itemPrepared(biblio_info, item_info) == false) { strError = "中断处理"; return(0); } } } if (biblioDone != null) { if (biblioDone(biblio_info) == false) { strError = "中断处理"; return(0); } } } return(1); }
// 装载数据 public override bool LoadData() { string strError = ""; int nRet = 0; BiblioInfo info = this.BiblioInfo; string strRecPath = this.BiblioInfo.RecPath; if (string.IsNullOrEmpty(info.OldXml) == true) { lock (syncRoot) { channel = this.Container.MainForm.GetChannel(); } try { // 显示 正在处理 this.HTML = GetWaitingHtml("正在获取书目记录 " + strRecPath); ShowData(); string[] results = null; byte[] baTimestamp = null; // 获得书目记录 channel.Timeout = new TimeSpan(0, 0, 5); long lRet = channel.GetBiblioInfos( Stop, strRecPath, "", new string[] { "xml" }, // formats out results, out baTimestamp, out strError); if (lRet == 0) { nRet = -1; strError = "获取书目记录 " + strRecPath + " 时出错: " + strError; } else if (lRet == -1) { nRet = -1; strError = "获取书目记录 " + strRecPath + " 时出错: " + strError; } else { if (results == null || results.Length == 0) { strError = "results error"; throw new Exception(strError); } // TODO: 对 BiblioInfo 的成员进行操作的时候,是否要 lock 一下对象? string strXml = results[0]; info.OldXml = strXml; info.Timestamp = baTimestamp; info.RecPath = strRecPath; } } finally { LibraryChannel temp_channel = channel; lock (syncRoot) { channel = null; } this.Container.MainForm.ReturnChannel(temp_channel); } } string strXml1 = ""; string strHtml2 = ""; string strXml2 = ""; if (nRet == -1) { strHtml2 = HttpUtility.HtmlEncode(strError); } else { nRet = BiblioSearchForm.GetXmlHtml(info, out strXml1, out strXml2, out strHtml2, out strError); if (nRet == -1) { throw new Exception(strError); } } this.HTML = "<html>" + this.Container.MainForm.GetMarcHtmlHeadString(true) + "<body>" + strHtml2 + EntityForm.GetTimestampHtml(info.Timestamp) + "</body></html>"; this.XML = BiblioSearchForm.MergeXml(strXml1, strXml2); return(true); }
// 装载数据 public override bool LoadData() { string strError = ""; int nRet = 0; BiblioInfo info = this.BiblioInfo; string strRecPath = this.BiblioInfo.RecPath; if (string.IsNullOrEmpty(info.OldXml) == true) { lock (syncRoot) { channel = Program.MainForm.GetChannel(); } try { // 显示 正在处理 this.HTML = GetWaitingHtml("正在获取 " + this.DbType + " 记录 " + strRecPath); ShowData(); byte [] baTimestamp = null; string strOutputRecPath = ""; string strBiblio = ""; string strBiblioRecPath = ""; string strXml = ""; // 获得记录 channel.Timeout = new TimeSpan(0, 0, 5); long lRet = 0; if (this.DbType == "item") { lRet = channel.GetItemInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "order") { lRet = channel.GetOrderInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "issue") { lRet = channel.GetIssueInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "comment") { lRet = channel.GetCommentInfo( this.Stop, "@path:" + strRecPath, "xml", out strXml, out strOutputRecPath, out baTimestamp, "", out strBiblio, out strBiblioRecPath, out strError); } else if (this.DbType == "patron") { string[] results = null; // 获得读者记录 lRet = channel.GetReaderInfo( this.Stop, "@path:" + strRecPath, "xml", out results, out strOutputRecPath, out baTimestamp, out strError); if (lRet == 1) { if (results == null || results.Length == 0) { strError = "results error"; nRet = -1; } else { strXml = results[0]; } } } else { lRet = -1; strError = "无法识别的 DbType '" + this.DbType + "'"; } if (lRet == 0) { nRet = -1; strError = "获取记录 " + strRecPath + " 时出错: " + strError; } else if (lRet == -1) { nRet = -1; strError = "获取记录 " + strRecPath + " 时出错: " + strError; } else { info.OldXml = strXml; info.Timestamp = baTimestamp; info.RecPath = strRecPath; } } finally { LibraryChannel temp_channel = channel; lock (syncRoot) { channel = null; } Program.MainForm.ReturnChannel(temp_channel); } } string strXml1 = ""; string strHtml2 = ""; if (nRet == -1) { strHtml2 = HttpUtility.HtmlEncode(strError); } else { nRet = ItemSearchForm.GetXmlHtml(info, out strXml1, out strHtml2, out strError); if (nRet == -1) { throw new Exception(strError); } } this.HTML = "<html>" + Program.MainForm.GetMarcHtmlHeadString(true) + "<body>" + strHtml2 + EntityForm.GetTimestampHtml(info.Timestamp) + "</body></html>"; this.XML = strXml1; return(true); }