示例#1
0
文件: PrintHost.cs 项目: pxmarc/dp2
        //
        /// <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);
        }
示例#2
0
        // 
        /// <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);
        }