Exemple #1
0
        public bool MSRSuspendedAuth()
        {
            if (msgSaved != null)
            {
                //check for correct nozzle
                bool   found        = false;
                double discount     = 0;
                string discounttype = "";
                foreach (MyProductItem item in msgSaved.ProductsList)
                {
                    if (item.Code == ProductCode)
                    {
                        discount     = item.Discount;
                        discounttype = item.DiscountType;
                        found        = true;
                        break;
                    }
                }
                if (!found)
                {
                    AddToLogList(MsgLogType.MSRWrongProduct, "", 0, "", 0, "");
                    return(false);
                }

                dd         = new DeviceData();
                dd.bCPass  = false;
                dd.cardnum = msgSaved.carddata;
                dd.limit   = msgSaved.Limit;
                dd.plate   = msgSaved.DriverName;
                dd.type    = "Money";
                MobileRes  = "None";
                CPassTry   = 0;
                MsgID++;
                //find the product discount
                found = false;
                MyProductItem itemfound = null;
                foreach (MyProductItem item in msgSaved.ProductsList)
                {
                    if (item.Code == ProductCode)
                    {
                        found     = true;
                        itemfound = item;
                        break;
                    }
                }
                if (found)
                {
                    //check  for discount
                    if (itemfound.DiscountType == "%")
                    {
                        UpdatePPVPrecent(itemfound.Discount);
                        (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "%";
                    }
                    else
                    {
                        UpdatePPVAbs(itemfound.Discount);
                        (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "c";
                    }
                }
                MSRTimer.Start();
                return(true);
            }
            return(false);
        }
Exemple #2
0
        private void ShowMSRProgress(MSRStatusData msg)
        {
            Thread.BeginCriticalRegion();

            try
            {
                if (msg.status == -1)
                {
                    AddToLogList(MsgLogType.MSRCommError, "", 0, "", 0, msg.carddata);
                    return;
                }


                if ((ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code) && msg.msg == MsgLogType.MSRWrongProduct) //we are in wash?
                {
                    if (ProductCode == conf.Wash1Code)
                    {
                        Wash1Clicked(); //simulate relese
                    }
                    else
                    {
                        Wash2Clicked();
                    }
                }

                if (msg.msg != MsgLogType.MSRAuth) //just update the status
                {
                    AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata);
                    msgSaved = null;
                    return;
                }

                if (ProductCode == conf.Wash1Code || ProductCode == conf.Wash2Code) //we are in wash?
                {
                    AnimationPhase = 2;
                    WashInProgress = true;
                    AnimationTimer.Start();
                    WashPlayer.PlayLooping();
                    (MainPage.Document.GetElementById("Plate")).InnerHtml = "Welcome " + msg.DriverName;
                    lastamount = 490;  //wash price
                    lastvol    = 0;
                    bool          found     = false;
                    MyProductItem itemfound = null;
                    foreach (MyProductItem item in msg.ProductsList)
                    {
                        if (item.Code == ProductCode)
                        {
                            found     = true;
                            itemfound = item;
                            break;
                        }
                    }
                    if (found)
                    {
                        //check discount
                        if (itemfound.DiscountType == "%")
                        {
                            lastamount = lastamount * (1 - itemfound.Discount / 100);
                            (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "%";
                        }
                        else
                        {
                            lastamount = lastamount - itemfound.Discount;
                            (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "c";
                        }
                    }
                    return;
                }

                //we got authorization check if pump is ready

                switch (ps)
                {
                case PumpStatus.Idle:
                    AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata);
                    AddToLogList(MsgLogType.MSRSSelectProduct, "", 0, "", 0, "");
                    //save auth data
                    msgSaved = msg;

                    break;

                case PumpStatus.Call:
                    AddToLogList(msg.msg, msg.ErrorDesc, 1, msg.DriverName, msg.Limit, msg.carddata);
                    if (msg.msg == MsgLogType.MSRAuth)
                    {
                        dd         = new DeviceData();
                        dd.bCPass  = false;
                        dd.cardnum = msg.carddata;
                        dd.limit   = msg.Limit;
                        dd.plate   = msg.DriverName;
                        dd.type    = msg.LimitType;
                        dd.bCPass  = msg.CPassRequired;
                        MobileRes  = "None";
                        CPassTry   = 0;
                        MsgID++;
                        //find the product discount
                        bool          found     = false;
                        MyProductItem itemfound = null;
                        foreach (MyProductItem item in msg.ProductsList)
                        {
                            if (item.Code == ProductCode)
                            {
                                found     = true;
                                itemfound = item;
                                break;
                            }
                        }
                        if (found)
                        {
                            //check limit type
                            if (itemfound.DiscountType == "%")
                            {
                                UpdatePPVPrecent(itemfound.Discount);
                                (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "%";
                            }
                            else
                            {
                                UpdatePPVAbs(itemfound.Discount);
                                (MainPage.Document.GetElementById("Discount")).InnerHtml = "Discount " + itemfound.Discount.ToString("00") + "c";
                            }
                        }

                        MSRTimer.Start();
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                //  MessageBox.Show(ex.Message);
            }
            finally
            {
                Thread.EndCriticalRegion();
            }
        }