// return: // -1 error // 0 未能推送 // 1 已经推送 internal int PushCurrentToQueue(out string strError) { strError = ""; if (this.PrintInfo.HasContent() == false) { strError = "当前没有内容,不必推送"; return(0); // 当前没有内容的就不必推送 } if (this.PrintInfo.PrintedCount != 0) { strError = "当前内容已存在于“已打印队列”中"; return(0); } while (this.UnprintInfos.Count >= this.MaxUnprintInfos) { this.UnprintInfos.RemoveAt(0); } this.UnprintInfos.Add(this.PrintInfo); this.PrintInfo = new PrintInfo(); strError = "当前内容被推送到“未打印队列”中"; return(1); }
private void listView_unprint_list_SelectedIndexChanged(object sender, EventArgs e) { if (this.listView_unprint_list.SelectedIndices.Count == 0) { this.textBox_unprint_oneContent.Text = ""; this.button_unprint_print.Enabled = false; } else { this.button_unprint_print.Enabled = true; PrintInfo info = (PrintInfo)listView_unprint_list.SelectedItems[0].Tag; string strFormat = ""; string strText = ""; this.MainForm.OperHistory.GetPrintContent(info, out strText, out strFormat); this.textBox_unprint_oneContent.Text = strText; if (strFormat == "html") { this.textBox_unprint_oneContent.EnableHtml = true; } else { this.textBox_unprint_oneContent.EnableHtml = false; } } }
// /// <summary> /// 每一次借完成后触发一次 /// </summary> /// <param name="sender">事件触发者</param> /// <param name="e">事件参数</param> public virtual void OnBorrowed(object sender, BorrowedEventArgs e) { if (e.ReaderBarcode != this.PrintInfo.CurrentReaderBarcode) { // 前面积累的打印信息,推送到相应的队列中,便于随时挑选出来进行重新打印 if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderBarcode) == false && this.PrintInfo.HasContent() == true ) { if (this.PrintInfo.PrintedCount == 0) { while (this.UnprintInfos.Count >= this.MaxUnprintInfos) { this.UnprintInfos.RemoveAt(0); } this.UnprintInfos.Add(this.PrintInfo); } else { while (this.PrintedInfos.Count >= this.MaxPrintedInfos) { this.PrintedInfos.RemoveAt(0); } this.PrintedInfos.Add(this.PrintInfo); } } this.PrintInfo = new PrintInfo(); } this.PrintInfo.CurrentReaderBarcode = e.ReaderBarcode; if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderSummary) == true) { this.PrintInfo.CurrentReaderSummary = e.ReaderSummary; } this.PrintInfo.PrintedCount = 0; // 把打印次数清为0,表示内容已经变化,新版本(增补后的)内容尚未打印 BorrowItemInfo info = new BorrowItemInfo(); info.OperName = e.OperName; info.ItemBarcode = e.ItemBarcode; info.BiblioSummary = e.BiblioSummary; info.LatestReturnDate = e.LatestReturnDate; info.Period = e.Period; info.BorrowCount = e.BorrowCount; info.TimeSpan = e.TimeSpan; info.BorrowOperator = e.BorrowOperator; this.PrintInfo.BorrowItems.Add(info); }
private void button_unprint_print_Click(object sender, EventArgs e) { if (this.listView_unprint_list.SelectedIndices.Count == 0) { MessageBox.Show(this, "尚未选定要打印的事项"); return; } foreach (ListViewItem item in this.listView_unprint_list.SelectedItems) { PrintInfo info = (PrintInfo)item.Tag; this.MainForm.OperHistory.Print(info); } }
// /// <summary> /// 每一次交罚金完成后触发一次 /// </summary> /// <param name="sender">事件触发者</param> /// <param name="e">事件参数</param> public virtual void OnAmerced(object sender, AmercedEventArgs e) { if (e.ReaderBarcode != this.PrintInfo.CurrentReaderBarcode) { // 前面积累的打印信息,推送到相应的队列中,便于随时挑选出来进行重新打印 if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderBarcode) == false && this.PrintInfo.HasContent() == true ) { if (this.PrintInfo.PrintedCount == 0) { while (this.UnprintInfos.Count >= this.MaxUnprintInfos) { this.UnprintInfos.RemoveAt(0); } this.UnprintInfos.Add(this.PrintInfo); } else { while (this.PrintedInfos.Count >= this.MaxPrintedInfos) { this.PrintedInfos.RemoveAt(0); } this.PrintedInfos.Add(this.PrintInfo); } } this.PrintInfo = new PrintInfo(); } this.PrintInfo.CurrentReaderBarcode = e.ReaderBarcode; if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderSummary) == true) { this.PrintInfo.CurrentReaderSummary = e.ReaderSummary; } this.PrintInfo.PrintedCount = 0; // 把打印次数清为0,表示内容已经变化,新版本(增补后的)内容尚未打印 this.PrintInfo.OverdueItems.AddRange(e.OverdueInfos); }
void FillUnprintList() { this.listView_unprint_list.Items.Clear(); if (this.MainForm.OperHistory.PrintHostObj == null) { return; } for (int i = 0; i < this.MainForm.OperHistory.PrintHostObj.UnprintInfos.Count; i++) { PrintInfo info = this.MainForm.OperHistory.PrintHostObj.UnprintInfos[i]; ListViewItem item = new ListViewItem(); item.Text = info.CurrentReaderBarcode; item.SubItems.Add(info.CreateTime.ToString()); item.Tag = info; this.listView_unprint_list.Items.Add(item); } }
// 创建打印内容 /// <summary> /// 要创建打印内容时被触发 /// </summary> /// <param name="info">打印信息</param> /// <param name="strResultString">结果字符串</param> /// <param name="strResultFormat">结果字符串的格式</param> public void GetPrintContent(PrintInfo info, out string strResultString, out string strResultFormat) { strResultString = ""; strResultFormat = ""; // 运行Script代码 if (this.PrintAssembly != null) { PrintEventArgs e = new PrintEventArgs(); e.PrintInfo = info; e.Action = "create"; this.PrintHostObj.MainForm = this.MainForm; this.PrintHostObj.Assembly = this.PrintAssembly; try { this.PrintHostObj.OnPrint(this, e); } catch (Exception ex) { string strErrorInfo = "<br/>单据打印脚本运行时出错: " + HttpUtility.HtmlEncode(ExceptionUtil.GetDebugText(ex)); AppendHtml(strErrorInfo); } strResultString = e.ResultString; strResultFormat = e.ResultFormat; } }
// 创建打印内容并打印出来 /// <summary> /// 打印时被触发 /// </summary> /// <param name="info">打印信息</param> public void Print(PrintInfo info) { // 运行Script代码 if (this.PrintAssembly != null) { PrintEventArgs e = new PrintEventArgs(); e.PrintInfo = info; e.Action = "print"; this.PrintHostObj.MainForm = this.MainForm; this.PrintHostObj.Assembly = this.PrintAssembly; try { this.PrintHostObj.OnPrint(this, e); } catch (Exception ex) { string strErrorInfo = "<br/>单据打印脚本运行时出错: " + HttpUtility.HtmlEncode(ExceptionUtil.GetDebugText(ex)); AppendHtml(strErrorInfo); } } }
// /// <summary> /// 每一次还完成后触发一次 /// </summary> /// <param name="sender">事件触发者</param> /// <param name="e">事件参数</param> public virtual void OnReturned(object sender, ReturnedEventArgs e) { if (e.ReaderBarcode != this.PrintInfo.CurrentReaderBarcode) { // 前面积累的打印信息,推送到相应的队列中,便于随时挑选出来进行重新打印 if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderBarcode) == false && this.PrintInfo.HasContent() == true ) { if (this.PrintInfo.PrintedCount == 0) { while (this.UnprintInfos.Count >= this.MaxUnprintInfos) { this.UnprintInfos.RemoveAt(0); } this.UnprintInfos.Add(this.PrintInfo); } else { while (this.PrintedInfos.Count >= this.MaxPrintedInfos) { this.PrintedInfos.RemoveAt(0); } this.PrintedInfos.Add(this.PrintInfo); } } this.PrintInfo = new PrintInfo(); } this.PrintInfo.CurrentReaderBarcode = e.ReaderBarcode; if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderSummary) == true) { this.PrintInfo.CurrentReaderSummary = e.ReaderSummary; } this.PrintInfo.PrintedCount = 0; // 把打印次数清为0,表示内容已经变化,新版本(增补后的)内容尚未打印 // 对借阅事项进行查重 bool bFoundDup = false; for (int i = 0; i < this.PrintInfo.BorrowItems.Count; i++) { BorrowItemInfo borrow = this.PrintInfo.BorrowItems[i]; if (borrow.ItemBarcode == e.ItemBarcode) { this.PrintInfo.BorrowItems.RemoveAt(i); bFoundDup = true; break; } } if (bFoundDup == true) { return; } ReturnItemInfo info = new ReturnItemInfo(); info.OperName = e.OperName; info.ItemBarcode = e.ItemBarcode; info.BiblioSummary = e.BiblioSummary; info.BorrowDate = e.BorrowDate; info.LatestReturnDate = e.LatestReturnDate; info.Period = e.Period; info.BorrowCount = e.BorrowCount; info.TimeSpan = e.TimeSpan; info.BorrowOperator = e.BorrowOperator; info.ReturnOperator = e.ReturnOperator; string strError = ""; int nRet = info.BuildOverdueItems(e.OverdueString, out strError); if (nRet == -1) { throw new Exception("BuildOverdueItems error: " + strError); } this.PrintInfo.ReturnItems.Add(info); }
// /// <summary> /// 每一次交罚金完成后触发一次 /// </summary> /// <param name="sender">事件触发者</param> /// <param name="e">事件参数</param> public virtual void OnAmerced(object sender, AmercedEventArgs e) { if (e.ReaderBarcode != this.PrintInfo.CurrentReaderBarcode) { // 前面积累的打印信息,推送到相应的队列中,便于随时挑选出来进行重新打印 if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderBarcode) == false && this.PrintInfo.HasContent() == true ) { if (this.PrintInfo.PrintedCount == 0) { while (this.UnprintInfos.Count >= this.MaxUnprintInfos) this.UnprintInfos.RemoveAt(0); this.UnprintInfos.Add(this.PrintInfo); } else { while (this.PrintedInfos.Count >= this.MaxPrintedInfos) this.PrintedInfos.RemoveAt(0); this.PrintedInfos.Add(this.PrintInfo); } } this.PrintInfo = new PrintInfo(); } this.PrintInfo.CurrentReaderBarcode = e.ReaderBarcode; if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderSummary) == true) this.PrintInfo.CurrentReaderSummary = e.ReaderSummary; this.PrintInfo.PrintedCount = 0; // 把打印次数清为0,表示内容已经变化,新版本(增补后的)内容尚未打印 this.PrintInfo.OverdueItems.AddRange(e.OverdueInfos); }
// /// <summary> /// 每一次还完成后触发一次 /// </summary> /// <param name="sender">事件触发者</param> /// <param name="e">事件参数</param> public virtual void OnReturned(object sender, ReturnedEventArgs e) { if (e.ReaderBarcode != this.PrintInfo.CurrentReaderBarcode) { // 前面积累的打印信息,推送到相应的队列中,便于随时挑选出来进行重新打印 if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderBarcode) == false && this.PrintInfo.HasContent() == true ) { if (this.PrintInfo.PrintedCount == 0) { while (this.UnprintInfos.Count >= this.MaxUnprintInfos) this.UnprintInfos.RemoveAt(0); this.UnprintInfos.Add(this.PrintInfo); } else { while (this.PrintedInfos.Count >= this.MaxPrintedInfos) this.PrintedInfos.RemoveAt(0); this.PrintedInfos.Add(this.PrintInfo); } } this.PrintInfo = new PrintInfo(); } this.PrintInfo.CurrentReaderBarcode = e.ReaderBarcode; if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderSummary) == true) this.PrintInfo.CurrentReaderSummary = e.ReaderSummary; this.PrintInfo.PrintedCount = 0; // 把打印次数清为0,表示内容已经变化,新版本(增补后的)内容尚未打印 // 对借阅事项进行查重 bool bFoundDup = false; for (int i = 0; i < this.PrintInfo.BorrowItems.Count; i++) { BorrowItemInfo borrow = this.PrintInfo.BorrowItems[i]; if (borrow.ItemBarcode == e.ItemBarcode) { this.PrintInfo.BorrowItems.RemoveAt(i); bFoundDup = true; break; } } if (bFoundDup == true) return; ReturnItemInfo info = new ReturnItemInfo(); info.OperName = e.OperName; info.ItemBarcode = e.ItemBarcode; info.BiblioSummary = e.BiblioSummary; info.BorrowDate = e.BorrowDate; info.LatestReturnDate = e.LatestReturnDate; info.Period = e.Period; info.BorrowCount = e.BorrowCount; info.TimeSpan = e.TimeSpan; info.BorrowOperator = e.BorrowOperator; info.ReturnOperator = e.ReturnOperator; string strError = ""; int nRet = info.BuildOverdueItems(e.OverdueString, out strError); if (nRet == -1) throw new Exception("BuildOverdueItems error: " + strError); this.PrintInfo.ReturnItems.Add(info); }
// return: // -1 error // 0 未能推送 // 1 已经推送 internal int PushCurrentToQueue(out string strError) { strError = ""; if (this.PrintInfo.HasContent() == false) { strError = "当前没有内容,不必推送"; return 0; // 当前没有内容的就不必推送 } if (this.PrintInfo.PrintedCount != 0) { strError = "当前内容已存在于“已打印队列”中"; return 0; } while (this.UnprintInfos.Count >= this.MaxUnprintInfos) this.UnprintInfos.RemoveAt(0); this.UnprintInfos.Add(this.PrintInfo); this.PrintInfo = new PrintInfo(); strError = "当前内容被推送到“未打印队列”中"; return 1; }
// /// <summary> /// 每一次借完成后触发一次 /// </summary> /// <param name="sender">事件触发者</param> /// <param name="e">事件参数</param> public virtual void OnBorrowed(object sender, BorrowedEventArgs e) { if (e.ReaderBarcode != this.PrintInfo.CurrentReaderBarcode) { // 前面积累的打印信息,推送到相应的队列中,便于随时挑选出来进行重新打印 if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderBarcode) == false && this.PrintInfo.HasContent() == true ) { if (this.PrintInfo.PrintedCount == 0) { while (this.UnprintInfos.Count >= this.MaxUnprintInfos) this.UnprintInfos.RemoveAt(0); this.UnprintInfos.Add(this.PrintInfo); } else { while (this.PrintedInfos.Count >= this.MaxPrintedInfos) this.PrintedInfos.RemoveAt(0); this.PrintedInfos.Add(this.PrintInfo); } } this.PrintInfo = new PrintInfo(); } this.PrintInfo.CurrentReaderBarcode = e.ReaderBarcode; if (String.IsNullOrEmpty(this.PrintInfo.CurrentReaderSummary) == true) this.PrintInfo.CurrentReaderSummary = e.ReaderSummary; this.PrintInfo.PrintedCount = 0; // 把打印次数清为0,表示内容已经变化,新版本(增补后的)内容尚未打印 BorrowItemInfo info = new BorrowItemInfo(); info.OperName = e.OperName; info.ItemBarcode = e.ItemBarcode; info.BiblioSummary = e.BiblioSummary; info.LatestReturnDate = e.LatestReturnDate; info.Period = e.Period; info.BorrowCount = e.BorrowCount; info.TimeSpan = e.TimeSpan; info.BorrowOperator = e.BorrowOperator; this.PrintInfo.BorrowItems.Add(info); }