Exemplo n.º 1
0
        internal static DocumentFileHelper[] GetOpenOrders(String cashierId, bool checkOrder)
        {
            if (orderDocuments == null)
            {
                orderDocuments = new List <DocumentFileHelper>();
            }

            orderDocuments = new List <DocumentFileHelper>();
            if (Data.Connector.FxClient.DirectoryExists(orderDataPath, 4500))
            {
                FileHelper[] orderFiles = null;
                orderFiles = Data.Connector.FxClient.GetFiles(orderDataPath, "sip*" + cashierId + ".dat", 10000);

                foreach (FileHelper orderFile in orderFiles)
                {
                    int orderId = 0;
                    DocumentFileHelper orderDocument = new DocumentFileHelper(orderFile);
                    if (Parser.TryInt(orderFile.Name.Substring(3, 4), out orderId) && orderFile.Name.Length > 14)
                    {
                        orderDocument.Id          = orderId;
                        orderDocument.salesPerson = CashRegister.DataConnector.FindCashierById(orderFile.Name.Substring(7, 4));
                        if (orderDocument.salesPerson != null)
                        {
                            orderDocuments.Add(orderDocument);
                        }
                    }
                }
            }

            return(orderDocuments.ToArray());
        }
Exemplo n.º 2
0
        internal static DocumentFileHelper[] GetOpenTables()
        {
            List <DocumentFileHelper> tableDocuments = new List <DocumentFileHelper>();

            if (Data.Connector.FxClient.DirectoryExists(PosConfiguration.ServerTablePath, 4500))
            {
                FileHelper[] tableFiles = null;
                tableFiles = Data.Connector.FxClient.GetFiles(PosConfiguration.ServerTablePath, "Masa1*" + ".dat", 10000);


                foreach (FileHelper tableFile in tableFiles)
                {
                    int tableId = 0;
                    DocumentFileHelper tableDocument = new DocumentFileHelper(tableFile);
                    if (Parser.TryInt(tableFile.Name.Substring(6, 3), out tableId))
                    {
                        tableDocument.Id = tableId;
                        //tableDocument.salesPerson = CashRegister.DataConnector.FindCashierById(tableFile.Name.Substring(6, 3));
                        //if (tableDocument.salesPerson != null)
                        tableDocuments.Add(tableDocument);
                    }
                }
            }

            return(tableDocuments.ToArray());
        }
Exemplo n.º 3
0
        public static void Start()
        {
            System.Threading.Thread.Sleep(200);
            DocumentFileHelper[] orders = null;
            int sleepTime = 500;

            if (!Parser.TryInt(PosConfiguration.Get("SleepTime"), out sleepTime))
            {
                sleepTime = 500;
            }

            while (true)
            {
                if (Chassis.Engine.Terminate)
                {
                    break;
                }

                try
                {
                    orders = DocumentFileHelper.GetOpenOrders();
                }
                catch (Exception ex)
                {
                    Debugger.Instance().AppendLine("Order Error: " + ex.Message);
                }
                if (orders != null && orders.Length > 0)
                {
                    try
                    {
                        AutoLoadOrders(orders);
                    }
                    catch (Exception ex)
                    {
                        Debugger.Instance().AppendLine("Order Error: " + ex.Message);
                    }
                }
                else
                {
                    DisplayAdapter.Instance().LedOff(Leds.Order);
                }

                Thread.Sleep(sleepTime);
                while (cr.State == null)
                {
                    Thread.Sleep(200); //I wish this had a comment
                }
            }
        }
Exemplo n.º 4
0
        internal static DocumentFileHelper[] GetOpenOrders(String cashierId, bool checkOrder)
        {
            if (orderDocuments == null)
            {
                orderDocuments = new List <DocumentFileHelper>();
            }

            if (cr.DataConnector.CurrentSettings.GetProgramOption(Setting.FastPaymentControl) == PosConfiguration.ON &&
                !checkOrder)
            {
                return(orderDocuments.ToArray());
            }

            orderDocuments = new List <DocumentFileHelper>();
            if (Data.Connector.FxClient.DirectoryExists(PosConfiguration.ServerOrderPath, 4500))
            {
                FileHelper[] orderFiles = null;
                orderFiles = Data.Connector.FxClient.GetFiles(PosConfiguration.ServerOrderPath, "sip*" + cashierId + ".dat", 10000);

                foreach (FileHelper orderFile in orderFiles)
                {
                    //if (cr.Printer.IsFiscal && orderFile.CreationTime < cr.LastZReportDate) continue;
                    int orderId = 0;
                    DocumentFileHelper orderDocument = new DocumentFileHelper(orderFile);
                    if (Parser.TryInt(orderFile.Name.Substring(3, 4), out orderId) && orderFile.Name.Length > 14)
                    {
                        orderDocument.Id          = orderId;
                        orderDocument.salesPerson = CashRegister.DataConnector.FindCashierById(orderFile.Name.Substring(7, 4));
                        if (orderDocument.salesPerson != null)
                        {
                            orderDocuments.Add(orderDocument);
                        }
                    }
                }
            }

            return(orderDocuments.ToArray());
        }
Exemplo n.º 5
0
        public static void Start()
        {
            System.Threading.Thread.Sleep(200);
            DocumentFileHelper[] orders = null;
            int sleepTime = 5000;

            if (!Parser.TryInt(PosConfiguration.Get("SleepTime"), out sleepTime))
            {
                sleepTime = 5000;
            }

#if (!WindowsCE)
            tcpOrder = new TcpOrder();
#endif
            while (true)
            {
                if (Chassis.Engine.Terminate)
                {
                    break;
                }
                try
                {
                    CheckDataMessage();
                    cr.DataConnector.TransferOfflineData();

                    if (!isConnectionUp)
                    {
                        //CheckDataMessage() didnt throw exception
                        //means backoffice has become online
                        CashRegister.Log.Info("Network up");
                        isConnectionUp = true;
                        OnNetworkUp();
                    }
                }
                catch (BackOfficeUnavailableException bue)
                {
                    CashRegister.Log.Info("ARKA OFÝSE ULAÞILAMIYOR : " + bue.Message);
                    if (isConnectionUp)
                    {
                        isConnectionUp = false;
                        CashRegister.Log.Info("Network down");
                        if (OnNetworkDown != null)
                        {
                            OnNetworkDown();
                        }
                    }
                }
                catch (Exception e)
                {
                    cr.Log.Error("{0} on BackgroundWorker", e.GetType().ToString());
                }


                if (isConnectionUp)
                {
                    DisplayAdapter.Instance().LedOn(Leds.Online);
                }
                else
                {
                    DisplayAdapter.Instance().LedOff(Leds.Online);
                    DisplayAdapter.Instance().LedOff(Leds.Order);
                }

                try
                {
                    if (isConnectionUp && cr.DataConnector.CurrentSettings.GetProgramOption(Setting.FastPaymentControl) == PosConfiguration.ON)
                    {
                        orders = DocumentFileHelper.GetOpenOrders();
                    }
                    else if (orders != null)
                    {
                        orders = null;
                    }
                }
                catch (Exception ex)
                {
                    Debugger.Instance().AppendLine("Order Error: " + ex.Message);
                }
                if (orders != null && orders.Length > 0)
                {
                    DisplayAdapter.Instance().LedOn(Leds.Order);

                    if (PosConfiguration.Get("AutoOrderKey") == GetAutoOrderKey())
                    {
                        try
                        {
                            AutoLoadOrders(orders);
                        }
                        catch (Exception ex)
                        {
                            DisplayAdapter.Instance().LedOff(Leds.Order);
                            Debugger.Instance().AppendLine("Order Error: " + ex.Message);
                        }
                    }
                }
                else
                {
                    DisplayAdapter.Instance().LedOff(Leds.Order);
                }

                Thread.Sleep(sleepTime);
                while (cr.State == null)
                {
                    Thread.Sleep(200); //I wish this had a comment
                }
                TimeSpan ts = DateTime.Now - CashRegisterInput.lastKeyPressed;
                if (cr.State.IsIdle && cr.Document.IsEmpty)
                {
                    if (inactivityTimeout > 0 && ts.TotalSeconds > inactivityTimeout)
                    {
                        if (cr.State is States.Start && cr.CurrentCashier != null)
                        {
                            cr.Log.Info("Timeout occurred - logging out cashier id {0}.", cr.CurrentCashier.Id);
                            cr.State = States.Login.Instance();
                        }
                        //if (cr.IsDesktopWindows)
                        //    DisplayAdapter.Customer.ShowAdvertisement();
                        DisplayAdapter.Instance().Inactive = true;
                    }
                    //if (serverRequestQueue.Count == 0 && DisplayAdapter.Instance().Inactive)
                    //{
                    //    if (cr.DataConnector.CurrentSettings.IdleMessage.Length > 0)
                    //        DisplayAdapter.Customer.ShowAdvertisement();
                    //}
                    CheckMessageQueue();
                }
                else if (inactivityTimeout > 0 && ts.TotalSeconds > inactivityTimeout && cr.CurrentCashier != null)
                {
                    cr.Log.Info("Timeout occurred - logging out cashier id {0}.", cr.CurrentCashier.Id);
                    cr.State = States.Login.Instance();
                }
            }
        }