Beispiel #1
0
        // 创建打印内容
        /// <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;
            }

        }
Beispiel #2
0
        // 创建打印内容并打印出来
        /// <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);
                }
            }
        }
Beispiel #3
0
        // 
        /// <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);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        // 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;
        }
Beispiel #6
0
        // 
        /// <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);
        }