コード例 #1
0
        /// <summary>
        /// Method to check a valid price
        /// </summary>
        /// <param name="pRiceDec"></param>
        /// <param name="price"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        private bool IsValidPrice(short pRiceDec, decimal price, out ErrorMessage error)
        {
            //validate price
            error = new ErrorMessage();
            const double maxprice = 9999; //
            const double minprice = -9999;

            var pd = pRiceDec; // Price Decimals

            var fs = Convert.ToString(pd == 0 ? " " : "." + new string('9', pd));

            if (Conversion.Val(price) <= Conversion.Val(minprice + fs))
            {
                MessageType temp_VbStyle9 = (int)MessageType.Exclamation + MessageType.OkOnly;
                error.MessageStyle = new MessageStyle
                {
                    Message     = "Minimum price is 9999~Price error",
                    MessageType = temp_VbStyle9
                };
                error.StatusCode = HttpStatusCode.NotAcceptable;
                return(false);
            }
            if (Conversion.Val(price) > Conversion.Val(maxprice + fs))
            {
                var         store         = CacheManager.GetStoreInfo();
                short       offSet        = store?.OffSet ?? (short)0;
                MessageType temp_VbStyle9 = (int)MessageType.Exclamation + MessageType.OkOnly;
                error.MessageStyle = _resourceManager.CreateMessage(offSet, 11, 76, maxprice + fs, temp_VbStyle9);
                error.StatusCode   = HttpStatusCode.NotAcceptable;
                return(false);
            }
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Method to get reasons
        /// </summary>
        /// <param name="reasonType">Reason type</param>
        /// <returns>List of reasons</returns>
        public List <Return_Reason> GetReasons(ReasonType reasonType)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,ReasonManager,GetReasons,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var type    = (char)reasonType;
            var reasons = new List <Return_Reason>();
            var store   = CacheManager.GetStoreInfo();
            var offSet  = store?.OffSet ?? 0;

            if (type != '\0')
            {
                reasons = _reasonService.GetReasons(type);
            }
            if (reasons == null || reasons.Count == 0)
            {
                reasons = new List <Return_Reason>
                {
                    new Return_Reason
                    {
                        Description = _resourceManager.GetResString(offSet, 207), //"<No reasons defined>"
                        Reason      = "0"
                    }
                };
            }
            Performancelog.Debug($"End,ReasonManager,GetReasons,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(reasons);
        }
コード例 #3
0
        /// <summary>
        /// Method to set prepay from Fuel control
        /// </summary>
        /// <param name="pumpId">Pump Id</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="saleNumber">Sale number</param>
        /// <param name="prepayPriceType">Prpeay price type</param>
        /// <param name="error">Error</param>
        /// <returns>True or false</returns>
        public bool SetPrepayFromFc(short pumpId, int tillNumber, int saleNumber, string prepayPriceType,
                                    out ErrorMessage error)
        {
            error = new ErrorMessage();

            if (!TCPAgent.Instance.IsConnected)
            {
                var store  = CacheManager.GetStoreInfo();
                var offSet = store?.OffSet ?? 0;
                error.MessageStyle = _resourceManager.CreateMessage(offSet, 11, 60, null);
                return(false);
            }
            Variables.Pump[pumpId].PrepayInvoiceID = saleNumber;

            var response           = "";
            var strRemain          = "";
            var tempCommandRenamed = "Prp" + Strings.Right("0" + Convert.ToString(pumpId), 2) + Strings.Right("00000000" + Convert.ToString(Variables.Pump[pumpId].PrepayInvoiceID), 8) + prepayPriceType + (Variables.Pump[pumpId].PrepayAmount * 100).ToString("000000") + Strings.Right("000" + Convert.ToString(tillNumber), 3) + Strings.Right("0" + Convert.ToString(Variables.Pump[pumpId].PrepayPosition), 1);

            //var tcpAgent = new TCPAgent();
            TCPAgent.Instance.Send_TCP(ref tempCommandRenamed, true);
            var timeIN = (float)DateAndTime.Timer;

            while (!(DateAndTime.Timer - timeIN > Variables.gPumps.CommunicationTimeOut))
            {
                var strBuffer = Convert.ToString(TCPAgent.Instance.NewPortReading);
                if (string.IsNullOrEmpty(strBuffer))
                {
                    return(false);
                }
                WriteToLogFile("TCPAgent.PortReading: " + strBuffer + " from waiting Prp" + Strings.Right("0" + Convert.ToString(pumpId), 2));
                if (!string.IsNullOrEmpty(strBuffer))
                {
                    modStringPad.SplitResponse(strBuffer, "Prp" + Strings.Right("0" + Convert.ToString(pumpId), 2), ref response, ref strRemain); //strBuffer<>""
                    if (!string.IsNullOrEmpty(response))                                                                                          //got what we are waiting
                    {
                        TCPAgent.Instance.PortReading = strRemain;                                                                                //& ";" & TCPAgent.PortReading
                        WriteToLogFile("modify TCPAgent.PortReading from set Prepayment: " + strRemain);
                        break;
                    }
                }
                if (DateAndTime.Timer < timeIN)
                {
                    timeIN = (float)DateAndTime.Timer;
                }
                Variables.Sleep(100);
            }

            if (Strings.Left(response, 7) != "Prp" + Strings.Right("0" + Convert.ToString(pumpId), 2) + "OK")
            {
                var store  = CacheManager.GetStoreInfo();
                var offSet = store?.OffSet ?? 0;
                error.MessageStyle = _resourceManager.CreateMessage(offSet, 11, 60, null);
                return(false);
            }

            return(true);
        }
コード例 #4
0
        // Load all the promotions in the Promos collection. Can load a specified promo or all of them
        /// <summary>
        /// Method to load all promos
        /// </summary>
        /// <param name="optPromoId">PromoID</param>
        /// <returns>Promos</returns>
        public Promos Load_Promos(string optPromoId)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,PromoManager,Load_Promos,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");

            var promos = CacheManager.GetPromosForPromoId(optPromoId);

            if (promos != null && promos.Count != 0)
            {
                return(promos);
            }
            promos = new Promos();
            var store        = CacheManager.GetStoreInfo();
            var offSet       = store?.OffSet ?? 0;
            var none         = _resourceManager.GetResString(offSet, 347);
            var promoHeaders = _promoService.GetPromoHeadersForToday(optPromoId);

            foreach (var promoHeader in promoHeaders)
            {
                var promo      = promoHeader;
                var promoLines = new Promo_Lines();

                //promo.MaxLink = _promoService.GetMaxLink(promo.PromoID);
                //var noOfLinks = _promoService.GetNumberOfLinks(promo.PromoID);
                //foreach (var noOfLink in noOfLinks)
                //{
                //    if (noOfLink > 1)
                //    {
                //        promo.MultiLink = true;
                //        break;
                //    }
                //}

                var promoDetails = _promoService.GetPromoLines(promo.PromoID, none);
                foreach (var promoDetail in promoDetails)
                {
                    promoLines.AddLine(promoDetail, "");
                }
                promo.Promo_Lines = promoLines;
                promos.Add(promo, promo.PromoID);
            }
            Performancelog.Debug($"End,PromoManager,Load_Promos,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            CacheManager.AddPromos(optPromoId, promos);
            return(promos);
        }
コード例 #5
0
        /// <summary>
        /// Get a Valid GiveX Stockcode
        /// </summary>
        /// <param name="errorMessage">errorMessage</param>
        /// <returns>stock code</returns>
        public string GetValidGiveXStock(out ErrorMessage errorMessage)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,GivexManager,GetValidGiveXStock,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            errorMessage = new ErrorMessage();
            var stockCode = _givexService.GetValidGiveXStock();

            if (string.IsNullOrEmpty(stockCode))
            {
                var   store  = CacheManager.GetStoreInfo();
                short offSet = store?.OffSet ?? (short)0;
                errorMessage.MessageStyle = _resourceManager.CreateMessage(offSet, 12, 64, null, CriticalOkMessageType);
                errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;
                return(null);
            }
            Performancelog.Debug($"End,GivexManager,GetValidGiveXStock,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(stockCode);
        }
コード例 #6
0
        /// <summary>
        /// Method to get list of all messages
        /// </summary>
        /// <returns></returns>
        public List <MessageButton> GetMessages()
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,MessageManager,GetMessages,{string.Empty},{dateStart:hh.mm.ss.ffffff}");
            var store    = CacheManager.GetStoreInfo();
            var offSet   = store?.OffSet ?? 0;
            var messages = new List <MessageButton>
            {
                new MessageButton
                {
                    Index   = 0,
                    Caption = _resourceManager.GetResString(offSet, 1803),
                    Message = string.Empty
                }
            };

            messages.AddRange(_utilityService.GetAllMessageButtons());
            _performancelog.Debug($"End,MessageManager,GetMessages,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");

            return(messages);
        }
コード例 #7
0
        /// <summary>
        /// Method to basket undo
        /// </summary>
        /// <param name="pumpId">Pump Id</param>
        /// <param name="posId">Pos Id</param>
        /// <param name="gradeId">Grade Id</param>
        /// <param name="amount">Amount</param>
        /// <param name="up">Up</param>
        /// <param name="volume">Volume</param>
        /// <param name="stockCode">Stock code</param>
        /// <param name="mop">Mop</param>
        /// <param name="error">Error message</param>
        /// <returns>True or false</returns>
        public bool BasketUndo(short pumpId, short posId, short gradeId, float amount, float up, float volume,
                               string stockCode, byte mop, out ErrorMessage error)
        {
            float basketUndoTimeIn = 0;

            error = new ErrorMessage();
            if (!TCPAgent.Instance.IsConnected)
            {
                var store  = CacheManager.GetStoreInfo();
                var offSet = store?.OffSet ?? 0;
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, (38), 92, null, CriticalOkMessageType)
                };
                return(false);
            }


            if (DateAndTime.Timer - Variables.basketClick < Variables.basket_click_delay && (DateAndTime.Timer - Variables.basketClick) > 0)
            {
                return(false); //3 sec delay
            }

            if ((DateAndTime.Timer - basketUndoTimeIn < 2) && (DateAndTime.Timer - basketUndoTimeIn) > 0)
            {
                return(false);
            }

            if (basketUndoTimeIn > DateAndTime.Timer)
            {
                basketUndoTimeIn = 0; //reset on midnight
            }
            else
            {
                basketUndoTimeIn = (float)DateAndTime.Timer;
            }

            if (Variables.basketClick > DateAndTime.Timer)
            {
                Variables.basketClick = 0;
            }
            else
            {
                Variables.basketClick = (float)DateAndTime.Timer;
            }

            var response  = "";
            var strRemain = "";

            Variables.IsWaiting = true;
            string tempCommandRenamed = "Ist" + Strings.Right("0" + System.Convert.ToString(pumpId), 2) + System.Convert.ToString(mop) + System.Convert.ToString(posId) + Strings.Right("0000000" + System.Convert.ToString(amount * 1000), 8) + Strings.Right("00000000" + System.Convert.ToString(volume * 1000), 8);

            TCPAgent.Instance.Send_TCP(ref tempCommandRenamed, true);


            var timeIN = (float)DateAndTime.Timer;

            while (!(DateAndTime.Timer - timeIN > Variables.gPumps.CommunicationTimeOut))
            {
                var strBuffer = Convert.ToString(TCPAgent.Instance.NewPortReading);
                modStringPad.WriteToLogFile("TCPAgent.PortReading: " + strBuffer + " from waiting Ist" + Strings.Right("00" + System.Convert.ToString(pumpId), 2));
                if (!string.IsNullOrEmpty(strBuffer))
                {
                    modStringPad.SplitResponse(strBuffer, "Ist" + Strings.Right("00" + Convert.ToString(pumpId), 2), ref response, ref strRemain); //strBuffer<>""
                    if (!string.IsNullOrEmpty(response))                                                                                           //got what we are waiting
                    {
                        TCPAgent.Instance.PortReading = strRemain;                                                                                 //& ";" & TCPAgent.PortReading
                        WriteToLogFile("modify PortReading from BasketUndo: " + strRemain);
                        break;
                    }
                }
                if (DateAndTime.Timer < timeIN)
                {
                    timeIN = (float)DateAndTime.Timer;
                }
                Variables.Sleep(100);
            }
            if (Strings.Left(response, 8) == "Ist" + Strings.Right("00" + Convert.ToString(pumpId), 2) + "ERR")
            {
                Variables.IsWaiting = false;
                return(false);
            }

            if (Strings.Left(response, 7) != "Ist" + Strings.Right("00" + System.Convert.ToString(pumpId), 2) + "OK") //response is not IstERR or IstOK
            {
                string tempCommandRenamed2 = "ENDPOS";
                TCPAgent.Instance.Send_TCP(ref tempCommandRenamed2, true);
                Variables.IsWaiting = false;
                return(false);
            }

            Variables.gBasket[pumpId].AmountCurrent  = amount;
            Variables.gBasket[pumpId].VolumeCurrent  = volume;
            Variables.gBasket[pumpId].UPCurrent      = up;
            Variables.gBasket[pumpId].gradeIDCurr    = gradeId;
            Variables.gBasket[pumpId].PosIDCurr      = posId;
            Variables.gBasket[pumpId].CurrentFilled  = true;
            Variables.gBasket[pumpId].currMOP        = mop;
            Variables.gBasket[pumpId].Stock_Code_Cur = stockCode;
            Variables.IsWaiting = false;
            return(true);
        }
コード例 #8
0
        /// <summary>
        /// Method to delete prepay from POS
        /// </summary>
        /// <param name="pumpId">Pump Id</param>
        /// <param name="showMessage">Show message or not</param>
        /// <param name="error">Error</param>
        /// <returns>True or false</returns>
        public bool DeletePrepayFromFc(short pumpId, bool showMessage, out ErrorMessage error)
        {
            error = new ErrorMessage();
            var store  = CacheManager.GetStoreInfo();
            var offSet = store?.OffSet ?? 0;

            if (!Variables.Pump[pumpId].IsPrepay && !Variables.Pump[pumpId].IsHoldPrepay)
            {
                return(false);
            }

            if (!TCPAgent.Instance.IsConnected)
            {
                if (showMessage)
                {
                    error = new ErrorMessage()
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 38, 19, null, CriticalOkMessageType)
                    };
                }
                return(false);
            }

            var response  = "";
            var strRemain = "";

            Variables.IsWaiting = true;

            var    timeIn             = (float)DateAndTime.Timer;
            string tempCommandRenamed = "Rpr" + Strings.Right("0" + Convert.ToString(pumpId), 2);

            TCPAgent.Instance.Send_TCP(ref tempCommandRenamed, true);

            while (!(DateAndTime.Timer - timeIn > Variables.gPumps.CommunicationTimeOut))
            {
                var strBuffer = Convert.ToString(TCPAgent.Instance.NewPortReading);
                WriteToLogFile("TCPAgent.PortReading: " + strBuffer + " from waiting Rpr" + Strings.Right("00" + Convert.ToString(pumpId), 2));
                if (!string.IsNullOrEmpty(strBuffer))
                {
                    modStringPad.SplitResponse(strBuffer, "Rpr" + Strings.Right("00" + Convert.ToString(pumpId), 2), ref response, ref strRemain); //strBuffer<>""
                    if (!string.IsNullOrEmpty(response))                                                                                           //got what we are waiting
                    {
                        TCPAgent.Instance.PortReading = strRemain;                                                                                 //& ";" & TCPAgent.PortReading
                        WriteToLogFile("modify PortReading from Deleting prepay: " + strRemain);
                        break;
                    }
                }
                if (DateAndTime.Timer < timeIn)
                {
                    timeIn = (float)DateAndTime.Timer;
                }
                Variables.Sleep(100);
            }

            if (Strings.Left(response, 8) == "Rpr" + Strings.Right("00" + Convert.ToString(pumpId), 2) + "ERR")
            {
                if (showMessage)
                {
                    error = new ErrorMessage()
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 38, 19, null, CriticalOkMessageType)
                    };
                }
                Variables.IsWaiting = false;
                return(false);
            }

            if (Strings.Left(response, 7) != "Rpr" + Strings.Right("00" + Convert.ToString(pumpId), 2) + "OK") //response is not RprERR or RprOK
            {
                if (showMessage)
                {
                    error = new ErrorMessage()
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 38, 19, null, CriticalOkMessageType)
                    };
                }
                string tempCommandRenamed2 = "ENDPOS";
                TCPAgent.Instance.Send_TCP(ref tempCommandRenamed2, false);
                Variables.IsWaiting = false;
                return(false);
            }
            Variables.IsWaiting = false;
            return(true);
        }
コード例 #9
0
        /// <summary>
        /// Deactivate Givex Card
        /// </summary>
        /// <param name="givexCardNumber">givexCardNumber</param>
        /// <param name="givexPrice">givexPrice</param>
        /// <param name="userCode">userCode</param>
        /// <param name="tillNumber">tillNumber</param>
        /// <param name="saleNumber">saleNumber</param>
        /// <param name="stockCode">stockCode</param>
        /// <param name="givexReceipt">Givex receipt</param>
        /// <param name="errorMessage">errorMessage</param>
        /// <returns>Sale</returns>
        public Sale DeactivateGivexCard(string givexCardNumber, decimal givexPrice, string userCode,
                                        int tillNumber, int saleNumber, string stockCode, out Report givexReceipt, out ErrorMessage errorMessage)
        {
            var dateStart = DateTime.Now;

            Performancelog.Debug($"Start,GivexManager,DeactivateGivexCard,{string.Empty},{DateTime.Now:hh.mm.ss.ffffff}");
            givexReceipt = null;
            var sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage);

            if (!string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
            {
                return(null);
            }
            var firstOrDefault = sale.Sale_Lines.FirstOrDefault(x => x.Gift_Num == givexCardNumber);

            if (firstOrDefault == null)
            {
                var   store  = CacheManager.GetStoreInfo();
                short offSet = store?.OffSet ?? (short)0;
                errorMessage.MessageStyle = _resourceManager.CreateMessage(offSet, 32, 93, null, CriticalOkMessageType);
                errorMessage.StatusCode   = HttpStatusCode.NotAcceptable;
                return(null);
            }

            short lineNumber = firstOrDefault.Line_Num;// _saleService.GetSaleLineFromDbTemp(givexCardNumber);

            var saleLine = sale.Sale_Lines[lineNumber];

            var newLine = _saleLineManager.CreateNewSaleLine();


            var amount = saleLine.Amount;
            var refNum = saleLine.Serial_No;

            if (!IsValidPrice(2, givexPrice, out errorMessage))
            {
                return(null);
            }
            GiveXReceiptType givex;

            if (_givexClientManager.DeactivateGiveX(givexCardNumber.Trim(), amount, saleNumber, refNum, userCode, out errorMessage, out givex))
            {
                givexReceipt = _receiptManager.Print_GiveX_Receipt(givex);

                sale = _saleManager.GetCurrentSale(saleNumber, tillNumber, 0, userCode, out errorMessage);
                if (string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
                {
                    _saleLineManager.SetPluCode(ref sale, ref newLine, stockCode, out errorMessage);
                    if (string.IsNullOrEmpty(errorMessage.MessageStyle.Message))
                    {
                        newLine.Line_Num      = (short)(sale.Sale_Lines.Count + 1);
                        newLine.Regular_Price = Conversion.Val(0 - amount);

                        _saleLineManager.SetPrice(ref newLine, Conversion.Val(0 - amount));

                        newLine.Gift_Num = givexCardNumber.Trim();
                        _saleManager.Add_a_Line(ref sale, newLine, userCode, tillNumber, out errorMessage, true);

                        //Update Sale object in Cache
                        CacheManager.AddCurrentSaleForTill(tillNumber, saleNumber, sale);
                    }
                }
            }


            Performancelog.Debug($"End,GivexManager,DeactivateGivexCard,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
            return(sale);
        }
コード例 #10
0
        /// <summary>
        /// Add update tier level
        /// </summary>
        /// <param name="pumpIds"></param>
        /// <param name="tierId"></param>
        /// <param name="levelId"></param>
        /// <param name="error"></param>
        /// <returns></returns>
        public TierLevelResponse AddUpdateTierLevel(List <int> pumpIds, int tierId, int levelId, out ErrorMessage error)
        {
            error = new ErrorMessage();
            var result = new TierLevelResponse
            {
                Tiers  = GetAllTiers(),
                Levels = GetAllLevels()
            };

            object i;
            string tierLevel    = "";
            bool   pumpSelected = false;
            var    store        = CacheManager.GetStoreInfo();
            var    offSet       = store?.OffSet ?? 0;
            float  timeIn       = 0;

            for (i = 1; (int)i <= (int)Variables.gPumps.PumpsCount; i = (int)i + 1)
            {
                if (tierId == 0)
                {
                    //        MsgBox ("Please select Tier!") '21
                    //MsgBoxStyle temp_VbStyle = (int)MsgBoxStyle.OkOnly + MsgBoxStyle.Critical;
                    //Chaps_Main.DisplayMessage(this, (short)21, temp_VbStyle, null, (byte)0);
                    error = new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 44, 21, null, CriticalOkMessageType)
                    };
                    return(null);
                }
                if (levelId == 0)
                {
                    //        MsgBox ("Please select Level!") '22
                    //MsgBoxStyle temp_VbStyle2 = (int)MsgBoxStyle.OkOnly + MsgBoxStyle.Critical;
                    //Chaps_Main.DisplayMessage(this, (short)22, temp_VbStyle2, null, (byte)0);
                    error = new ErrorMessage
                    {
                        MessageStyle = _resourceManager.CreateMessage(offSet, 44, 22, null, CriticalOkMessageType)
                    };
                    return(null);
                }

                switch (tierId + levelId.ToString())
                {
                case "11":
                    tierLevel = "0";
                    break;

                case "12":
                    tierLevel = "1";
                    break;

                case "21":
                    tierLevel = "2";
                    break;

                case "22":
                    tierLevel = "3";
                    break;
                }

                if (pumpIds.Contains((int)i))
                {
                    pumpSelected = true;
                    //lblinformation.Caption = "Setting in Process... Please Wait..." 'Resource.DisplayCaption(lblinformation.Tag, Me.Tag, , 2) '24-4
                    //lblinformation.Text = Chaps_Main.Resource.DisplayCaption(System.Convert.ToInt16(lblinformation.Tag), System.Convert.ToInt16(this.Tag), null, (short)4); //24-4
                    result.PageCaption = _resourceManager.CreateCaption(offSet, 24, 44, null, 4);

                    if (TCPAgent.Instance.PortOpened)
                    {
                        var response  = "";
                        var strRemain = "";


                        var cmd = "STL" + Strings.Right("00" + System.Convert.ToString(i), 2) + tierLevel;
                        TCPAgent.Instance.Send_TCP(ref cmd, true);
                        if (timeIn > DateAndTime.Timer)
                        {
                            timeIn = 0; //reset on midnight
                        }
                        else
                        {
                            timeIn = (float)DateAndTime.Timer;
                        }

                        while (!(DateAndTime.Timer - timeIn > Variables.gPumps.CommunicationTimeOut))
                        {
                            var strBuffer = System.Convert.ToString(TCPAgent.Instance.NewPortReading);
                            WriteToLogFile("TCPAgent.PortReading: " + strBuffer + " from waiting STL" + Strings.Right("00" + System.Convert.ToString(i), 2));
                            if (!string.IsNullOrEmpty(strBuffer))
                            {
                                modStringPad.SplitResponse(strBuffer, "STL" + Strings.Right("00" + System.Convert.ToString(i), 2), ref response, ref strRemain); //strBuffer<>""
                                if (!string.IsNullOrEmpty(response))                                                                                             //got what we are waiting
                                {
                                    TCPAgent.Instance.PortReading = strRemain;                                                                                   //& ";" & TCPAgent.PortReading
                                    WriteToLogFile("modify TCPAgent.PortReading from Get Totalizer: " + strRemain);
                                    break;
                                }
                            }
                            Variables.Sleep(100);
                            if (DateAndTime.Timer < timeIn)
                            {
                                timeIn = (float)DateAndTime.Timer;
                            }
                        }


                        if (Strings.Left(response, 7) != "STL" + Strings.Right("00" + System.Convert.ToString(i), 2) + "OK")
                        {
                            string tempCommandRenamed = "ENDPOS";
                            TCPAgent.Instance.Send_TCP(ref tempCommandRenamed, true);
                            //  lblinformation.Caption = "Setting TierLevel failed !" 'Resource.DisplayCaption(lblinformation.Tag, Me.Tag, , 2) '24-3
                            //(System.Convert.ToInt16(lblinformation.Tag), System.Convert.ToInt16(this.Tag), null, (short)3); //24-3
                            result.PageCaption = _resourceManager.CreateCaption(offSet, 24, 44, null, 3);
                            return(result);
                        }


                        _fuelPumpService.UpdateTierLevelForPump((int)i, tierId, levelId);



                        Variables.gPumps.get_Pump(System.Convert.ToByte(i)).TierID = (byte)tierId;

                        Variables.gPumps.get_Pump(System.Convert.ToByte(i)).LevelID = (byte)levelId;


                        if (Variables.Pump[(int)i].cashUP == null)
                        {
                            Variables.Pump[(int)i].cashUP = new float[10];
                        }

                        if (Variables.Pump[(int)i].creditUP == null)
                        {
                            Variables.Pump[(int)i].creditUP = new float[10];
                        }

                        if (Variables.Pump[(int)i].Stock_Code == null)
                        {
                            Variables.Pump[(int)i].Stock_Code = new string[10];
                        }


                        short j;
                        for (j = 1; j <= Variables.gPumps.get_PositionsCount(System.Convert.ToByte(i)); j++)
                        {
                            Variables.Pump[(int)i].cashUP[j] = Variables.gPumps.get_FuelPrice(System.Convert.ToByte(Variables.gPumps.get_Assignment(System.Convert.ToByte(i), (byte)j).GradeID), (byte)(Conversion.Val(tierId)), (byte)(Conversion.Val(levelId))).CashPrice;

                            Variables.Pump[(int)i].creditUP[j] = Variables.gPumps.get_FuelPrice(System.Convert.ToByte(Variables.gPumps.get_Assignment(System.Convert.ToByte(i), (byte)j).GradeID), (byte)(Conversion.Val(tierId)), (byte)(Conversion.Val(levelId))).CreditPrice;
                        }
                    }
                    else
                    {
                        //            lblinformation.Caption = "Please select pump and corresponding Tier/Level, then press 'SET TO PUMP' button to set!"  '24-1
                        //lblinformation.Text = Chaps_Main.Resource.DisplayCaption(System.Convert.ToInt16(lblinformation.Tag), System.Convert.ToInt16(this.Tag), null, (short)1); //24-1
                        result.PageCaption    = _resourceManager.CreateCaption(offSet, 24, 44, null, 1);
                        result.PumpTierLevels = GetPumpsTierLevel();
                        //MsgBox "No TCP connection to Host !!!", vbCritical
                        //MsgBoxStyle temp_VbStyle3 = (int)MsgBoxStyle.OkOnly + MsgBoxStyle.Critical;
                        //Chaps_Main.DisplayMessage(this, (short)92, temp_VbStyle3, null, (byte)0);
                        error.MessageStyle = new MessageStyle
                        {
                            Message     = _resourceManager.GetResString(offSet, 3892),
                            MessageType = MessageType.OkOnly
                        };
                        return(result);
                    }
                }
            }

            if (!pumpSelected) //if no pump is selected
            {
                //    MsgBox ("Please select Pump!") '23
                //Chaps_Main.DisplayMessage(this, (short)23, temp_VbStyle4, null, (byte)0);
                error = new ErrorMessage
                {
                    MessageStyle = _resourceManager.CreateMessage(offSet, 44, 23, null, CriticalOkMessageType)
                };
                //    lblinformation.Caption = "Please select pump and corresponding Tier/Level, then press 'SET TO PUMP' button to set!" '24-1
                //lblinformation.Text = Chaps_Main.Resource.DisplayCaption(System.Convert.ToInt16(lblinformation.Tag), System.Convert.ToInt16(this.Tag), null, (short)1); //24-1
                result.PageCaption    = _resourceManager.CreateCaption(offSet, 24, 44, null, 1);
                result.PumpTierLevels = GetPumpsTierLevel();
                return(result);
            }
            //    lblinformation.Caption = "Setting TierLevel is Done successfully !" 'Resource.DisplayCaption(lblinformation.Tag, Me.Tag, , 2) '24-2
            //lblinformation.Text = Chaps_Main.Resource.DisplayCaption(System.Convert.ToInt16(lblinformation.Tag), System.Convert.ToInt16(this.Tag), null, (short)2); //24-2
            result.PageCaption    = _resourceManager.CreateCaption(offSet, 24, 44, null, 2);
            result.PumpTierLevels = GetPumpsTierLevel();
            return(result);
        }
コード例 #11
0
        /// <summary>
        /// Method to save a message
        /// </summary>
        /// <param name="message">Message</param>
        /// <param name="tillNumber">Till number</param>
        /// <param name="userCode">User code</param>
        /// <param name="error">Error</param>
        public void SaveMessage(MessageButton message, int tillNumber, string userCode,
                                out ErrorMessage error)
        {
            var dateStart = DateTime.Now;

            _performancelog.Debug($"Start,MessageManager,SaveMessage,{string.Empty},{dateStart:hh.mm.ss.ffffff}");

            error = new ErrorMessage();
            var till = _tillService.GetTill(tillNumber);

            if (till == null)
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message = "Till does not exists"
                    },
                    StatusCode = System.Net.HttpStatusCode.NotFound
                };
                return;
            }
            if (string.IsNullOrEmpty(message.Message))
            {
                error = new ErrorMessage
                {
                    MessageStyle = new MessageStyle
                    {
                        Message     = "Message cannot be empty",
                        MessageType = MessageType.OkOnly
                    },
                    StatusCode = System.Net.HttpStatusCode.NotFound
                };
                return;
            }
            if (message.Index != 0)
            {
                var originalMessage = _utilityService.GetMessageByButtonId(message.Index);
                if (originalMessage == null || originalMessage.Message != message.Message)
                {
                    error = new ErrorMessage
                    {
                        MessageStyle = new MessageStyle
                        {
                            Message     = "Request is invalid",
                            MessageType = MessageType.OkOnly
                        },
                        StatusCode = System.Net.HttpStatusCode.NotFound
                    };
                    return;
                }
                message.Caption = originalMessage.Caption;
            }
            else
            {
                var store  = CacheManager.GetStoreInfo();
                var offSet = store?.OffSet ?? 0;
                message.Caption = _resourceManager.GetResString(offSet, 1803);
            }
            _utilityService.SaveMessageButton(message, till, userCode);
            _performancelog.Debug($"End,MessageManager,SaveMessage,{DateTime.Now.Subtract(dateStart).TotalMilliseconds},{DateTime.Now:hh.mm.ss.ffffff}");
        }