Esempio n. 1
0
    private PrintStatus printStats;                             // 출력 상태


    // 초기화
    private void Awake()
    {
        printEachTextRoutine = PrintEachText();

        currentText = "";
        printStats  = PrintStatus.Nothing;
    }
        /// <summary>
        /// Prints a message based on PrintStatus.
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="p"></param>
        public static void PrintMessage(string msg, PrintStatus p)
        {
            switch (p)
            {
            case PrintStatus.Error:
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("[! ! !] ERROR: " + msg);
                Console.ResetColor();
                break;
            }

            case PrintStatus.Warning:
            {
                Console.ForegroundColor = ConsoleColor.DarkYellow;
                Console.WriteLine("[! ! !] WARNING: " + msg);
                Console.ResetColor();
                break;
            }

            case PrintStatus.Normal:
            {
                Console.WriteLine("[>] " + msg);
                break;
            }
            }
        }
 // private string strClassName = ConfigurationManager.AppSettings["RandCode"];
 /// <summary>
 /// 多线程打印
 /// </summary>
 /// <param name="printType"></param>
 /// <param name="data"></param>
 /// <param name="clientNo"></param>
 public void ThreadPrint(PrintStatus printType, PrintData data, string clientNo)
 {
     ThreadPrintType = printType;
     ThreadPrintData = data;
     ThreadClientNo  = clientNo;
     printThread     = new System.Threading.Thread(new System.Threading.ThreadStart(Print));
     printThread.Start();
 }
        /// <summary>
        /// 执行打印操作
        /// </summary>
        /// <param name="_PrintType"></param>
        /// <param name="data"></param>
        public void Print(PrintStatus printType, PrintData data, string clientNo)
        {
            SeatManage.EnumType.Printer printerStatus = PrintStatusHandle();
            TerminalInfoV2 term = SeatManage.Bll.TerminalOperatorService.GetTeminalSetting(clientNo);

            if (printerStatus == SeatManage.EnumType.Printer.NoPaper)
            {
                if (term.PrinterStatus == true)
                {
                    term.PrinterStatus  = false;
                    term.LastPrintTimes = term.PrintedTimes;
                    term.PrintedTimes   = 0;
                    SeatManage.Bll.TerminalOperatorService.UpdateTeminalSetting(term);
                }
                if (PrinterException != null)
                {
                    PrinterException(SeatManage.EnumType.Printer.NoPaper);
                }
                return;
            }
            else if (printerStatus == SeatManage.EnumType.Printer.Normal)
            {
                term.PrinterStatus            = true;
                term.DeviceSetting.IsAnyPaper = true;
            }

            _PrintType = printType;
            printData  = data;
            XmlDocument doc = new XmlDocument();//原模板

            doc.LoadXml(GetPrintTemplate());
            PrintDocument pd = new PrintDocument();                   //打印操作的对象

            pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); //设置边距
            switch (PrintType)
            {
            //根据凭条的类型,在模板前增加【预约】或【等待】字样的节点
            case PrintStatus.General:
                newDoc = doc;
                break;

            case PrintStatus.Book:
                newDoc = InsertXmlNode(PrintStatus.Book, doc);
                break;

            case PrintStatus.Wait:
                newDoc = InsertXmlNode(PrintStatus.Wait, doc);
                break;
            }
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
            pd.Print();
            term.PrintedTimes++;
            SeatManage.Bll.TerminalOperatorService.UpdateTeminalSetting(term);
        }
        /// <summary>
        /// 执行打印操作
        /// </summary>
        /// <param name="_PrintType"></param>
        /// <param name="data"></param>
        public void Print()
        {
            Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                Printer printerStatus = PrintStatusHandle();
                TerminalInfoV2 term   = TerminalOperatorService.GetTeminalSetting(ThreadClientNo);
                if (printerStatus == Printer.NoPaper)
                {
                    if (term.PrinterStatus)
                    {
                        term.PrinterStatus  = false;
                        term.LastPrintTimes = term.PrintedTimes;
                        term.PrintedTimes   = 0;
                        TerminalOperatorService.UpdateTeminalSetting(term);
                    }
                    if (PrinterException != null)
                    {
                        PrinterException(Printer.NoPaper);
                    }
                    return;
                }
                if (printerStatus == Printer.Normal)
                {
                    term.PrinterStatus            = true;
                    term.DeviceSetting.IsAnyPaper = true;
                }

                _PrintType      = ThreadPrintType;
                printData       = ThreadPrintData;
                XmlDocument doc = new XmlDocument();                      //原模板
                doc.LoadXml(GetPrintTemplate());
                PrintDocument pd = new PrintDocument();                   //打印操作的对象
                pd.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); //设置边距
                switch (PrintType)
                {
                //根据凭条的类型,在模板前增加【预约】或【等待】字样的节点
                case PrintStatus.General:
                    newDoc = doc;
                    break;

                case PrintStatus.Book:
                    newDoc = InsertXmlNode(PrintStatus.Book, doc);
                    break;

                case PrintStatus.Wait:
                    newDoc = InsertXmlNode(PrintStatus.Wait, doc);
                    break;
                }
                pd.PrintPage += pd_PrintPage;
                pd.Print();
                term.PrintedTimes++;
                TerminalOperatorService.UpdateTeminalSetting(term);
            }));
        }
Esempio n. 6
0
    // 텍스트 한글자씩 출력 코루틴
    private IEnumerator PrintEachText()
    {
        for (int i = 0; i < currentText.Length; i++)
        {
            uiText.text += currentText[i];

            yield return(new WaitForSeconds(printDelay));
        }

        // 상태 초기화
        printStats = PrintStatus.Done;
    }
        /// <summary>
        /// 解析打印模板中的标签
        /// </summary>
        /// <param name="mark">标签</param>
        /// <returns></returns>
        string PrintTemplateMark(string mark, PrintStatus printType)
        {
            switch (mark)
            {
            case "#SecCardNo#":
                //判断凭条是否为等待,是则打印原来的读者学号
                if (printType == PrintStatus.Wait)
                {
                    return(printData.SecCardNo);
                }
                else
                {
                    return(null);
                }

            case "#ReadingRoomName#":
                return(printData.ReadingRoomName);   //阅览室名称

            case "#SeatNo#":
                return(printData.SeatNo);   //座位号

            case "#StuName#":
                return(printData.ReaderName);   //学生姓名

            case "#CardNo#":
                return(printData.CardNo);   //学号

            case "#DateTime#":
                return(string.Format("{0}月{1}日 {2}", printData.EnterTime.Month, printData.EnterTime.Day, printData.EnterTime.ToLongTimeString())); //printData.EnterTime.Month+.ToString().Replace('-', '/');//进入时间

            case "#EndDateTime#":                                                                                                                  //等待结束时间
                if (printType == PrintStatus.Wait)
                {
                    return(string.Format("{0}月{1}日 {2}", printData.WaitEndDateTime.Month, printData.WaitEndDateTime.Day, printData.WaitEndDateTime.ToLongTimeString())); printData.WaitEndDateTime.ToString().Replace('-', '/');
                }
                else
                {
                    return(null);
                }

            case "#RandNo#":    //其他(随机码或者其他,需要在接口中实现)
                throw new Exception("暂未实现");
                break;
            }
            return("");
        }
Esempio n. 8
0
        public PrintStatus DoPrntiJob(string IP, Int32 por, string Path)
        {
            IPAddress  IpAddress = IPAddress.Parse(IP);
            IPEndPoint endpoint  = new(IpAddress, por);
            Socket     socket    = new(endpoint.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            socket.Connect(endpoint);
            ESC         CMD    = new ESC();
            PrintStatus status = 0;
            //  var buffer = new ArrayList();
            NetworkStream networkStream = new NetworkStream(socket, true);

            try
            {
                //Créez une instance de StreamReader pour lire à partir d'un fichier
                using (StreamReader sr = new StreamReader(Path))
                {
                    string line;

                    // Lire les lignes du fichier jusqu'à la fin.
                    int i = 0;

                    while ((line = sr.ReadLine()) != null)
                    {
                        i++;
                        // Console.WriteLine(line + '\n');
                        var line2 = System.Text.Encoding.UTF8.GetBytes(line + '\n');
                        // byte[] dataTobePrinted = (byte[])buffer[i - 1];

                        networkStream.Write(line2, 0, line2.Length);
                        if (line.Contains(";"))
                        {
                            networkStream.Write(System.Text.Encoding.UTF8.GetBytes(CMD.GotoStartPosition), 0, CMD.GotoStartPosition.Length);
                        }
                    }
                    networkStream.Write(System.Text.Encoding.UTF8.GetBytes(CMD.GotoStoCutPosition), 0, CMD.GotoStartPosition.Length);
                }
            }
            catch (Exception e)
            {
                status = PrintStatus.FAILED;
                //Console.WriteLine("Le fichier n'a pas pu être lu.");
                //Console.WriteLine(e.Message);
            }
            return(status);
        }
Esempio n. 9
0
 private void PrintMaster_StatusRequest(PrintStatus arg, UInt32 CurrentPosition, UInt32 MaxPosition, PrintStatusTimeArgs TimeArgs)
 {
     if (InvokeRequired)
     {
         var d = new PrintStatusEventHandler(PrintMaster_StatusRequest);
         Invoke(d, arg, CurrentPosition, MaxPosition, TimeArgs);
     }
     else
     {
         progressBar1.Maximum  = (int)MaxPosition;
         progressBar1.Value    = (int)CurrentPosition;
         label_spendTme.Text   = string.Format(TB.L.Phrase["Form_PrintMaster.TimeSpend"], TimeArgs.SecondsSpend);
         label_leftTime.Text   = string.Format(TB.L.Phrase["Form_PrintMaster.EstimatedTime"], TimeArgs.SecondsLeft);
         label_speed.Text      = string.Format(TB.L.Phrase["Form_PrintMaster.Speed"], TimeArgs.Speed);
         label_progress.Text   = string.Format(TB.L.Phrase["Form_PrintMaster.Progress"], CurrentPosition, MaxPosition);
         label_percentage.Text = string.Format(TB.L.Phrase["Form_PrintMaster.Percentage"], (float)CurrentPosition / MaxPosition * 100f);
     }
 }
Esempio n. 10
0
        private void SetStatus(PrintStatus status)
        {
            if (lblStatus.InvokeRequired)
            {
                var d = new SetStatusDelegate(SetStatus);
                lblStatus.Invoke(d, new object[] { status });
            }
            else
            {
                checkRemoveBorder.Enabled = status == PrintStatus.DONE;
                // comboColorPalette.Enabled = status == PrintStatus.DONE;
                // checkInvertPalette.Enabled = status == PrintStatus.DONE;
                comboMagnify.Enabled = status == PrintStatus.DONE;
                btnSave.Enabled      = status == PrintStatus.DONE;

                lblStatus.Text = string.Format("Status: {0}", status.ToString());
            }
        }
        /// <summary>
        /// 根据凭条类型插入凭条头
        /// </summary>
        /// <param name="printType"></param>
        private XmlDocument InsertXmlNode(PrintStatus printType, XmlDocument doc)
        {
            XmlDocument tempDoc = doc;

            XmlNode root     = tempDoc.SelectSingleNode("//Print");//找出根节点
            XmlNode tempNode = null;

            try
            {
                tempNode = tempDoc.SelectNodes("//Print/Content")[0];//找到节点第一项
            }
            catch
            {
                throw new Exception("打印凭条失败,解析模板错误:" + PrintTemplate);
            }
            if (tempNode != null)
            {
                XmlElement newNode = tempDoc.CreateElement("Content");//创建一个新的节点,并且把该节点插入到内容头
                switch (printType)
                {
                case PrintStatus.Book:
                    newNode.InnerText = "预约";
                    break;

                case PrintStatus.Wait:
                    newNode.InnerText = "等待";
                    break;
                }
                newNode.SetAttribute("font", "宋体");
                newNode.SetAttribute("size", "9");
                newNode.SetAttribute("bold", "Y");
                root.InsertBefore(newNode, tempNode);
            }
            else
            {
                throw new Exception("打印凭条失败,解析模板错误:" + PrintTemplate);
            }
            return(tempDoc);
        }
Esempio n. 12
0
    // 출력 스킵
    private bool SkipPrint()
    {
        // 출력중인 텍스트 스킵
        StopCoroutine(printEachTextRoutine);
        uiText.text = currentText;

        // 큐에 텍스트가 남아있으면
        if (textQueue.Count > 0)
        {
            // 상태 초기화
            printStats = PrintStatus.Done;

            return(true);
        }
        // 큐가 비어있으면
        else
        {
            // 출력 종료
            EndPrint();

            return(false);
        }
    }
Esempio n. 13
0
    // 텍스트 출력
    private bool PrintText()
    {
        // 큐에 텍스트가 남아있으면
        if (textQueue.Count > 0)
        {
            // 텍스트 초기화
            uiText.text = "";

            // 큐에 있는 새로운 텍스트 출력
            currentText          = textQueue.Dequeue();
            printEachTextRoutine = PrintEachText();
            StartCoroutine(printEachTextRoutine);

            // 상태 초기화
            printStats = PrintStatus.Printing;

            return(true);
        }
        // 큐가 비어있으면
        else
        {
            return(false);
        }
    }
Esempio n. 14
0
 private void RaiseStatusRequest(PrintStatus arg, UInt32 CurrentPosition, UInt32 MaxPosition, PrintStatusTimeArgs TimeArgs)
 {
     StatusRequest?.Invoke(arg, CurrentPosition, MaxPosition, TimeArgs);
 }
Esempio n. 15
0
 public void TmThreadPrint(PrintStatus printMode, object sender, string key, int printFlg, AbstractJobConfig jobConfig, IData data, bool previewFlg)
 {
     this.mPrintMode = printMode;
     this.mSender = sender;
     this.mKey = key;
     this.mPrintFlg = printFlg;
     this.mJobConfig = jobConfig;
     this.mData = data;
     this.mPreviewFlg = previewFlg;
     this.ThreadTimer();
 }
Esempio n. 16
0
 static void BackUpPrintInfo(PrintStatus status, object state)
 {
     Console.WriteLine("Backup job: {0} PrintStatus: {1}", state.ToString(), status);
 }
Esempio n. 17
0
 static void GetPrintInfo(PrintStatus status, object state)
 {
     Console.WriteLine("{0} Print Status = {1}", state.ToString(), status);
 }
Esempio n. 18
0
 public PrintStatusChangedEventArgs(PrintStatus newStatus)
 {
     TimeStamp = DateTime.Now;
     NewStatus = newStatus;
 }
Esempio n. 19
0
 // 출력 종료
 private void EndPrint()
 {
     // 상태 초기화
     printStats = PrintStatus.Nothing;
 }