Пример #1
0
        private IEnumerable <SuperPNR> GetAllBookingPaidRepository(bool chkFlight, bool chkHotel, bool chkAddOnBook, string superPNRNo = null)
        {
            IQueryable <PaymentOrder> paymentOrders = null;

            if (superPNRNo == null)
            {
                paymentOrders = PaymentCheck.DBQuery.GetOrdersRHI(MayFlowerDB);
            }
            else
            {
                paymentOrders = PaymentCheck.DBQuery.GetOrdersRHI(MayFlowerDB, superPNRNo);
            }

            List <Task <RequeryStatus.Requery> > paymentResultList = new List <Task <RequeryStatus.Requery> >();

            foreach (var item in paymentOrders)
            {
                if (item.PaymentMethodCode.ToLower().StartsWith("ipa"))
                {
                    if (string.IsNullOrWhiteSpace(item.Ipay88RefNo))
                    {
                        InformationCaution = InformationCaution ?? new List <string>();
                        InformationCaution.Add(string.Format("PaymentOrders PaymentID {0} :- {1}", item.PaymentID, "Ref No is NULL cannot requery."));
                        item.RequeryStatusCode = "ERR";
                    }
                    else
                    {
                        paymentResultList.Add(PaymentCheck.ServiceQuery.IPAY88
                                              .CheckPaymentPAIDAsync(item, item.SuperPNROrder.SuperPNRID, item.SuperPNROrder.SuperPNR.SuperPNRNo));
                    }
                }
                else if (item.PaymentMethodCode.ToLower().StartsWith("ady"))
                {
                    if (string.IsNullOrWhiteSpace(item.Ipay88RefNo))
                    {
                        InformationCaution = InformationCaution ?? new List <string>();
                        InformationCaution.Add(string.Format("PaymentOrders PaymentID {0} :- {1}", item.PaymentID, "Ref No is NULL cannot requery."));
                        item.RequeryStatusCode = "ERR";
                    }
                    else
                    {
                        paymentResultList.Add(PaymentCheck.ServiceQuery.ADYEN
                                              .CheckPaymentPAIDAsync(item, item.SuperPNROrder.SuperPNRID, item.SuperPNROrder.SuperPNR.SuperPNRNo));
                    }
                }
            }

            var paymentResult = Task.WhenAll(paymentResultList).ConfigureAwait(false).GetAwaiter().GetResult();

            if (paymentResult != null && paymentResult.Length > 0)
            {
                List <ItemCheck> itemBookStatus = new List <ItemCheck>();

                foreach (var item in paymentResult)
                {
                    itemBookStatus = itemBookStatus.Union(PaymentStatusRequeryHandler(paymentOrders, item, chkFlight, chkHotel, chkAddOnBook, superPNRNo)).ToList();
                }

                foreach (var item in itemBookStatus)
                {
                    bool validFlight        = (!item.Flight.HasValue || (item.Flight.HasValue && item.Flight.Value == ItemCheck.ItemStatus.CON));
                    bool validHotel         = (!item.Hotel.HasValue || (item.Hotel.HasValue && item.Hotel.Value == ItemCheck.ItemStatus.CON));
                    bool validInsurance     = (!item.Insurance.HasValue || (item.Insurance.HasValue && item.Insurance.Value == ItemCheck.ItemStatus.CON));
                    bool validEventProducts = (!item.EventProducts.HasValue || (item.EventProducts.HasValue && item.EventProducts.Value == ItemCheck.ItemStatus.CON));

                    if (validFlight && validHotel && validInsurance && validEventProducts)
                    {
                        if (item.InformationCaution != null && item.InformationCaution.Any(x => x.Contains("Passed 7 days for capture")))
                        {
                        }
                        else
                        {
                            yield return(item.SuperPNR);
                        }
                    }
                }

                var msg = itemBookStatus.Where(x => x.InformationCaution != null).SelectMany(x => x.InformationCaution);

                if (msg != null && msg.Count() > 0)
                {
                    InformationCaution = InformationCaution ?? new List <string>();
                    InformationCaution.AddRange(msg);
                    InformationCaution = InformationCaution.Distinct().OrderBy(x => x).ToList();
                }
            }
        }
Пример #2
0
        public async Task CheckUpdatePendingPayment(bool chkFlight, bool chkHotel, bool chkAddOnBook, string superPNRNo = null)
        {
            IQueryable <PaymentOrder> paymentOrders = null;

            if (superPNRNo == null)
            {
                paymentOrders = PaymentCheck.DBQuery.GetPaymentsPEND(MayFlowerDB);
            }
            else
            {
                paymentOrders = PaymentCheck.DBQuery.GetPaymentsPEND(MayFlowerDB, superPNRNo);
            }

            List <Task <RequeryStatus.Requery> > paymentResultList = new List <Task <RequeryStatus.Requery> >();

            foreach (var item in paymentOrders.Where(x => x.PaymentMethodCode.ToLower() != "sc").Take(40))
            {
                if (item.PaymentMethodCode.ToLower().StartsWith("ipa"))
                {
                    if (string.IsNullOrWhiteSpace(item.Ipay88RefNo))
                    {
                        InformationCaution = InformationCaution ?? new List <string>();
                        InformationCaution.Add(string.Format("PaymentOrders PaymentID {0} :- {1}", item.PaymentID, "Ref No is NULL cannot requery."));
                        item.RequeryStatusCode = "ERR";
                    }
                    else
                    {
                        paymentResultList.Add(PaymentCheck.ServiceQuery.IPAY88
                                              .CheckPaymentPAIDAsync(item, item.SuperPNROrder.SuperPNRID, item.SuperPNROrder.SuperPNR.SuperPNRNo));
                    }
                }
                else if (item.PaymentMethodCode.ToLower().StartsWith("ady"))
                {
                    if (string.IsNullOrWhiteSpace(item.Ipay88RefNo))
                    {
                        InformationCaution = InformationCaution ?? new List <string>();
                        InformationCaution.Add(string.Format("PaymentOrders PaymentID {0} :- {1}", item.PaymentID, "Ref No is NULL cannot requery."));
                        item.RequeryStatusCode = "ERR";
                    }
                    else
                    {
                        paymentResultList.Add(PaymentCheck.ServiceQuery.ADYEN
                                              .CheckPaymentPAIDAsync(item, item.SuperPNROrder.SuperPNRID, item.SuperPNROrder.SuperPNR.SuperPNRNo));
                    }
                }
                else if (item.PaymentMethodCode.ToLower() == "tw")
                {
                    paymentResultList.Add(PaymentCheck.StoreQuery.TravelWallet
                                          .CheckPaymentPAIDAsync(item, item.SuperPNROrder.SuperPNRID, item.SuperPNROrder.SuperPNR.SuperPNRNo, MayFlowerDB));
                }
            }

            //var paymentResult = await Task.WhenAll(paymentResultList);
            List <ItemCheck> itemBookStatus = new List <ItemCheck>();

            while (paymentResultList.Count > 0)
            {
                var itemTsk = await Task.WhenAny(paymentResultList);

                var item = await itemTsk;

                if (item != null)
                {
                    itemBookStatus = itemBookStatus.Union(PaymentStatusRequeryHandler(paymentOrders, item, chkFlight, chkHotel, chkAddOnBook, superPNRNo)).ToList();

                    var msg = itemBookStatus.Where(x => x.InformationCaution != null).SelectMany(x => x.InformationCaution);

                    if (msg != null && msg.Count() > 0)
                    {
                        InformationCaution = InformationCaution ?? new List <string>();
                        InformationCaution.AddRange(msg);
                        InformationCaution = InformationCaution.Distinct().OrderBy(x => x).ToList();
                    }
                }

                paymentResultList.Remove(itemTsk);
            }
        }