Пример #1
0
        private void OnPrinterPaperReady()
        {
            if (currentPaperStatus != PaperStatus.Ready)
            {
                //Dispatcher.BeginInvoke(new Action(() =>
                //{
                //    StatusTextBlock.Text = "Printer Paper Ready.";
                //    StatusTextBlock.Foreground = new SolidColorBrush(Colors.Blue);
                //})
                //);
            }

            currentPaperStatus = PaperStatus.Ready;
        }
Пример #2
0
        private void OnPrinterPaperEmpty()
        {
            if (currentPaperStatus != PaperStatus.Empty)
            {
                Dispatcher.BeginInvoke(new Action(() =>
                {
                    StatusTextBlock.Text       = "Printer Paper Empty.";
                    StatusTextBlock.Foreground = new SolidColorBrush(Colors.Red);
                })
                                       );
            }

            currentPaperStatus = PaperStatus.Empty;
        }
Пример #3
0
        /// <summary>
        /// Sample : Starting monitoring printer.
        /// </summary>
        public void Connect()
        {
            try
            {
                if (port == null)
                {
                    // Your printer PortName and PortSettings.
                    string portName     = SharedInformationManager.GetSelectedPortName();
                    string portSettings = SharedInformationManager.GetSelectedPortStrrings();

                    port = Factory.I.GetPort(portName, portSettings, 10000);

                    // First, clear barcode reader buffer.
                    ClearBarcodeReaderBuffer();
                }
            }
            catch (PortException) // Port open is failed.
            {
                DidConnectFailed();

                return;
            }

            try
            {
                if (monitoringPrinterThread == null || monitoringPrinterThread.ThreadState == ThreadState.Stopped)
                {
                    monitoringPrinterThread              = new Thread(MonitoringPrinter);
                    monitoringPrinterThread.Name         = "MonitoringPrinterThread";
                    monitoringPrinterThread.IsBackground = true;
                    monitoringPrinterThread.Start();
                }
            }
            catch (Exception) // Start monitoring printer thread is failure.
            {
                DidConnectFailed();
            }

            currentPrinterStatus       = PrinterStatus.Invalid;
            currentPaperStatus         = PaperStatus.Invalid;
            currentCoverStatus         = CoverStatus.Invalid;
            currentCashDrawerStatus    = CashDrawerStatus.Invalid;
            currentBarcodeReaderStatus = Communication.PeripheralStatus.Invalid;
        }
Пример #4
0
        public List <Paper> TrackMyPaper(int userId)
        {
            List <Paper> papers     = new List <Paper>();
            string       queryPaper = "SELECT * FROM papers PAP inner join "
                                      + " (SELECT PaperId, StatusId, UserID, `Status`, CreatedBy, CreatedDatetime FROM PaperStatus "
                                      + " ) AA ON AA.PaperID = PAP.PaperId "
                                      + " WHERE AA.StatusID = ( "
                                      + " SELECT MAX(StatusID) FROM PaperStatus WHERE PAPERID = AA.PaPerID) AND PAP.IsActive = 1 AND PAP.UserId = ?userId";


            MySqlCommand cmd = new MySqlCommand();

            cmd.Parameters.Add(new MySqlParameter("?UserID", userId));

            using (MySqlConnection con = new MySqlConnection(DBConnection.ConnectionString))
            {
                cmd.Connection = con;
                con.Open();
                cmd.CommandText = queryPaper;
                var reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    Paper       objPaper = new Paper();
                    PaperStatus status   = new PaperStatus();
                    objPaper.PaperId         = Convert.ToInt32(reader["PaperId"]);
                    objPaper.MainTitle       = reader["MainTitle"].ToString();
                    objPaper.Tags            = Convert.ToString(reader["Tags"]);
                    objPaper.ShortDesc       = reader["ShortDesc"].ToString();
                    objPaper.CreatedBy       = reader["CreatedBy"].ToString();
                    objPaper.CreatedDateTime = Convert.ToDateTime(reader["CreatedDateTime"].ToString());

                    status.PaperId  = objPaper.PaperId;
                    status.StatusID = Convert.ToInt32(reader["StatusId"].ToString());
                    status.Status   = reader["Status"].ToString();

                    objPaper.Status = status;

                    papers.Add(objPaper);
                }

                return(papers);
            }
        }
        /// <summary>
        /// Sample : Starting monitoring printer.
        /// </summary>
        public void Connect()
        {
            try
            {
                if (port == null)
                {
                    // Your printer PortName and PortSettings.
                    string portName     = SharedInformationManager.SelectedPortName;
                    string portSettings = SharedInformationManager.SelectedPortSettings;

                    port = Factory.I.GetPort(portName, portSettings, 10000);
                }
            }
            catch (PortException) // Port open is failed.
            {
                DidConnectFailed();

                return;
            }

            try
            {
                if (monitoringPrinterThread == null || monitoringPrinterThread.ThreadState == ThreadState.Stopped)
                {
                    monitoringPrinterThread              = new Thread(MonitoringPrinter);
                    monitoringPrinterThread.Name         = "MonitoringPrinterThread";
                    monitoringPrinterThread.IsBackground = true;
                    monitoringPrinterThread.Start();
                }
            }
            catch (Exception) // Start monitoring printer thread is failure.
            {
                DidConnectFailed();
            }

            currentPrinterStatus = PrinterStatus.Invalid;
            currentPaperStatus   = PaperStatus.Invalid;
            currentCoverStatus   = CoverStatus.Invalid;
        }
Пример #6
0
 public string PaperStatusInString(int statusID)
 {
     return(PaperStatus.Convert(statusID));
 }