예제 #1
0
        /// <summary>
        /// 查询停车记录
        /// </summary>
        /// <returns></returns>
        public ActionResult GetParkingList(int status, bool number = false)
        {
            try
            {
                string auth = AppUserToken;

                if (auth.IsEmpty())
                {
                    //没有登录
                    //
                    return(RedirectToAction("Index", "ErrorPrompt", new { message = "用户登录失败" }));
                }
                else if (auth == "-1")
                {
                    return(RedirectToAction("Register", "ParkingPayment"));
                }
                int pageIndex = 1;
                int pageSize  = 35;

                ParkingList pklist = ParkingApi.bb(status, pageIndex, pageSize, auth);
                ParkingList pk     = JsonConvert.DeserializeObject <ParkingList>(JsonHelper.GetJsonString(pklist));
                return(View(pk));
            }
            catch (Exception e)
            {
                return(View());
            }
        }
예제 #2
0
        public ActionResult CXOrder(string orderid, int type)
        {
            try
            {
                string auth = AppUserToken;

                if (auth.IsEmpty())
                {
                    //没有登录
                    //
                    return(RedirectToAction("Index", "ErrorPrompt", new { message = "用户登录失败" }));
                }
                else if (auth == "-1")
                {
                    return(RedirectToAction("Register", "ParkingPayment"));
                }
                ParkingDetail pkd = ParkingApi.cc(orderid, type, auth);
                //Session[token]
                ParkingDetail pk = JsonConvert.DeserializeObject <ParkingDetail>(JsonHelper.GetJsonString(pkd));
                return(View(pk));
            }
            catch
            {
                return(View());
            }
        }
예제 #3
0
        public ActionResult ComputeNewParkingFee(string licensePlate, string parkingId)
        {
            string auth = AppUserToken;

            if (auth.IsEmpty())
            {
                //没有登录
                //
                return(RedirectToAction("Index", "ErrorPrompt", new { message = "用户登录失败" }));
            }
            else if (auth == "-1")
            {
                return(RedirectToAction("Register", "ParkingPayment"));
            }

            PresenceOrderList list = ParkingApi.GetPresenceOrder(auth);

            return(View(list));
        }
예제 #4
0
        private async Task StartGetRFCard()
        {
            CancellationTokenSource cancelTokenSource = new CancellationTokenSource();;
            CancellationToken       token             = cancelTokenSource.Token;

            await Task.Run(async() =>
            {
                TimerCallback tm             = new TimerCallback(TimeOutOperation);
                System.Threading.Timer timer = new System.Threading.Timer(tm, cancelTokenSource, 10000, 10000);
                byte res;
                while (!cancelTokenSource.Token.IsCancellationRequested)
                {
                    res = await rfidReader.GetRFCard(null);
                    if (res == 0x59)
                    {
                        timer.Change(Timeout.Infinite, Timeout.Infinite);
                        cardDetected = true;
                        ShowInfo("КАТРА ОБНАРУЖЕНА");
                        break;
                    }
                }
                if (!cardDetected)
                {
                    return;
                }
                //Несколько попыток чтения
                for (int i = 0; i < tryCount; i++)
                {
                    cardReadInfo = await GetId();
                    if (cardReadInfo.Item2 == 0x59)
                    {
                        ShowInfo("Подожите...");
                        await Task.Delay(3000);
                        cardReaded = true;
                        break;
                    }
                }
                if (!cardReaded)
                {
                    return;              //карта не прочитана
                }
                for (int i = 0; i < tryCount; i++)
                {
                    if (ParkingApi.CheckCard(cardReadInfo.Item1))
                    {
                        cardValid = true;
                        ShowInfo("КАТРА ЕСТЬ БАЗЕ");
                        await Task.Delay(1000);
                        break;
                    }
                }
                if (!cardValid)
                {
                    ShowInfo("КАТРЫ нет БАЗЕ");
                    await Task.Delay(1000);
                    return;
                }
                ;

                for (int i = 0; i < tryCount; i++)
                {
                    price = ParkingApi.Get_Price(cardReadInfo.Item1);
                    ShowInfo($"стоимость {price}");
                    await Task.Delay(1000);
                    inSumm = 0;
                    await Task.Delay(1000);
                    if (price > 0)
                    {
                        ShowInfo($"Внесите {price} руб.\n Внесено {inSumm} руб.");
                        billValidator.SetInhibit(false);

                        //токен отмены для жидания внесения денег
                        //cancelBillTokenSource = new CancellationTokenSource();
                        // таймер для окончания ожидания приема денег. не вечно же ждать
                        cancelBillAcceptSource   = new CancellationTokenSource();
                        TimerCallback tmBillWait = new TimerCallback(TimeOutBillWait);
                        timerBillWait            = new System.Threading.Timer(tmBillWait, cancelBillAcceptSource, 30000, 30000);
                        //запуск цикла приема денег

                        await WaitBills(cancelBillAcceptSource.Token);
                        if ((inSumm - price) >= 0)
                        {
                            var payment = ParkingApi.Payment(cardReadInfo.Item1, price, inSumm - price);
                            if (payment)
                            {
                                ShowInfo($"Платеж принят {payment.ToString()}");
                                await Task.Delay(1000);
                            }
                            else
                            {
                                ShowInfo($"Платеж не принят {payment.ToString()}");
                                await Task.Delay(1000);
                            }
                            //сдача
                            ShowInfo($"Сдача  {inSumm - price}");
                            if ((inSumm - price) > 0)
                            {
                                billValidator.DispenceBill(1, 1, 1, 2);
                            }
                            await Task.Delay(5000);
                        }
                        else
                        {
                            //если денег не достаточно и мы вывылились по таймауту то возвращаем деньги
                            //сдача
                            ShowInfo($"Сдача  {inSumm}");
                        }
                        await Task.Delay(1000);
                        break;
                    }
                }
                timer.Change(Timeout.Infinite, Timeout.Infinite);
            }
                           );
        }