コード例 #1
0
        public static string GetBookingNumberAndManageBooking(CheckOutData data)
        {
            try
            {
                CurrencyManager currencyManager = new CurrencyManager();
                var             BaseCur         = ConfigurationSettings.AppSettings["BaseCur"];

                double ExcahngeRate = currencyManager.GetCurrencyConversion(BaseCur, data.Currency, data.Sid);
                data.SellPrice = Math.Round(data.SellPrice * ExcahngeRate, 3);
                string BookingNum = null;
                BookingNum = BookingRepo.checkbookingnumberavailability(data.Sid);
                if (BookingNum == null)
                {
                    BookingNum = "";


                    BookingNum = BookingRepo.GetBookingNumber(data.Sid, data.Src, data.Pid);

                    if (BookingNum != null)
                    {
                        var tasks        = new List <Task>();
                        var tokenSource1 = new CancellationTokenSource();
                        var tokenSource2 = new CancellationTokenSource();
                        var token1       = tokenSource1.Token;
                        var token2       = tokenSource2.Token;

                        tasks.Add(Task.Factory.StartNew(() =>
                        {
                            data = fillAllTrivellers(data);
                            BookingRepo.SaveBookingResult(data, BookingNum);
                        }
                                                        , token1));
                        //tasks.Add(Task.Factory.StartNew(() =>
                        //{
                        //    SearchstatisticDA searchstatistic = new SearchstatisticDA();
                        //searchstatistic.AddMetaSearchStatistic(data, BookingNum);
                        //}
                        //            , token2));
                        //call save Delivary*****************
                        Task.WaitAll(tasks.ToArray());
                    }

                    return(BookingNum);
                }

                else
                {
                    BookingRepo.EditBookingPaxes(data, BookingNum);

                    return(BookingNum);
                }
            }
            catch (Exception ex)
            {
                LoggingHelper.WriteToFile("SaveBookingController/Errors/", "SaveBookingController" + "BLL" + data.Sid, ex.InnerException?.Message, ex.Message + ex.StackTrace);

                return(null);
            }
        }