Esempio n. 1
0
 public IActionResult GetChargedListByCustomerId(int customerId, string timeRange = "Today", int?pageIndex = 1, int?pageSize = 20)
 {
     try
     {
         var dtt = timeRange.ahDtUtil().TimeRange();
         var md  = _chargeSvr.GetChargeListPayedModelByCustomerId(customerId, dtt.Item1, dtt.Item2, pageIndex.Value, pageSize.Value)
                   .Select(m => new Models.ViewModel.PayedItem
         {
             CustomerId      = m.CustomerId.Value,
             CustomerName    = m.CustomerName,
             Gender          = m.Gender,
             TreatId         = m.TreatId,
             FeeTypeCode     = m.FeeTypeCode,
             FeeTypeCodeName = FeeTypes.ToName(m.FeeTypeCode),
             PayedTime       = m.PayedTime,
             PayId           = m.PayId,
             PayOrderId      = m.PayOrderId,
             TotalAmount     = m.TotalAmount,
             PayRemark       = m.PayRemark,
             TreatTime       = m.TreatTime
         });
         var rlt = MyDynamicResult(md);
         return(Ok(rlt));
     }
     catch (Exception ex) { return(Ok(MyDynamicResult(ex))); }
 }
Esempio n. 2
0
        public CommRuleGeneric(IModel ModelPortfolio, IAccountType AccountType, 
			string CommRuleName, FeeTypes FeeType, Fees.Calculations.CommCalc CommCalculation)
            : base(CommRuleName, FeeType, CommCalculation)
        {
            this.ModelPortfolio = ModelPortfolio;
            this.AccountType = AccountType;
        }
Esempio n. 3
0
        //undos the settings
        private void undoSettings()
        {
            lbWages.Items.Clear();
            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.Wage))
            {
                this.FeeValues[type] = this.Airline.Fees.getValue(type);
                lbWages.Items.Add(new QuickInfoValue(type.Name, createWageSlider(type)));
            }

            lbFees.Items.Clear();
            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.Fee).FindAll(f => GameObject.GetInstance().GameTime.Year >= f.FromYear))
            {
                this.FeeValues[type] = this.Airline.Fees.getValue(type);
                lbFees.Items.Add(new QuickInfoValue(type.Name, createWageSlider(type)));
            }
            lbFoodDrinks.Items.Clear();
            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.FoodDrinks))
            {
                this.FeeValues[type] = this.Airline.Fees.getValue(type);
                lbFoodDrinks.Items.Add(new QuickInfoValue(type.Name, createWageSlider(type)));
            }

            lbDiscounts.Items.Clear();
            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.Discount))
            {
                this.FeeValues[type] = this.Airline.Fees.getValue(type);
                lbDiscounts.Items.Add(new QuickInfoValue(type.Name, createDiscountSlider(type)));
            }
        }
Esempio n. 4
0
        //creates a dictionary of average employee discounts
        public static Dictionary <Airline, Double> GetEmployeeDiscounts()
        {
            Dictionary <Airline, Double> employeeDiscounts = new Dictionary <Airline, double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                double eDiscount = airline.Fees.getValue(FeeTypes.GetType("Employee Discount"));
                employeeDiscounts.Add(airline, eDiscount);
            }
            return(employeeDiscounts);
        }
Esempio n. 5
0
 public void MigrateFees()
 {
     if (IsNoShowFee)
     {
         FeeType = FeeTypes.NoShow;
     }
     if (IsCancellationFee)
     {
         FeeType = FeeTypes.Cancellation;
     }
 }
Esempio n. 6
0
        }         // ToString

        private OfferFee(
            FeeTypes feeType,
            decimal amount,
            decimal oneTimePartPct,
            decimal distributedPartPct
            )
        {
            Amount                 = amount;
            FeeType                = feeType;
            OneTimePartPercent     = oneTimePartPct;
            DistributedPartPercent = distributedPartPct;
        }         // constructor
Esempio n. 7
0
        //resets the fees
        public void resetFees()
        {
            this.Wages.Clear();
            this.Chargers.Clear();
            this.Fees.Clear();
            this.Discounts.Clear();

            FeeTypes.GetTypes(FeeType.eFeeType.Wage).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Wages.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));
            FeeTypes.GetTypes(FeeType.eFeeType.Discount).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Discounts.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));
            FeeTypes.GetTypes(FeeType.eFeeType.Fee).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Fees.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));
            FeeTypes.GetTypes(FeeType.eFeeType.FoodDrinks).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Chargers.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));
        }
Esempio n. 8
0
        private void SendFeesReceipt(Guid orderId, decimal feeAmount, FeeTypes feeType)
        {
            var order      = _orderDao.FindById(orderId);
            var account    = _accountDao.FindById(order.AccountId);
            var creditCard = _creditCardDao.FindById(account.DefaultCreditCard.GetValueOrDefault());

            if (feeType == FeeTypes.Cancellation)
            {
                _notificationService.SendCancellationFeesReceiptEmail(order.IBSOrderId ?? 0, Convert.ToDouble(feeAmount), creditCard.Last4Digits, account.Email, account.Language);
            }
            else if (feeType == FeeTypes.NoShow)
            {
                _notificationService.SendNoShowFeesReceiptEmail(order.IBSOrderId ?? 0, Convert.ToDouble(feeAmount), order.PickupAddress, creditCard.Last4Digits, account.Email, account.Language);
            }
        }
Esempio n. 9
0
        private static string GetFeeTypeText(FeeTypes feeType)
        {
            var titleText = string.Empty;

            try
            {
                titleText = GlobalDataAccessor.Instance.DesktopSession.ServiceFeeTypes.Find(f => f.Left == feeType).Right;
            }
            catch (System.ArgumentException)
            {
                titleText = "";
            }

            return(titleText);
        }
Esempio n. 10
0
        /// <summary>
        /// 更新预支付数据
        /// </summary>
        /// <param name="payOrderId"></param>
        /// <param name="payStatus"></param>
        /// <param name="payTime"></param>
        /// <returns></returns>
        private async Task <CHIS_Charge_PayPre> UpdatePayPreAsync(string payOrderId, string feeTypeCode, string payRmk = null, bool isCash = false, int payStatus = 1, DateTime?payTime = null, CHISEntitiesSqlServer db = null)
        {
            db = db ?? _db;
            if (payOrderId.IsEmpty())
            {
                throw new Exception("更新付款信息没有传入付款单号。");
            }
            if (!FeeTypes.IsValidFeeType(feeTypeCode))
            {
                throw new Exception("传入费用类型错误");
            }
            var finds = db.CHIS_Charge_PayPre.AsNoTracking().Where(u => u.PayOrderId == payOrderId);
            var count = finds.Count();

            if (count == 0)
            {
                throw new Exception("没有找到预付款信息数据");
            }
            if (count > 1)
            {
                throw new Exception("发现多个数据");
            }
            if (payTime == null)
            {
                payTime = DateTime.Now;
            }
            var m = finds.FirstOrDefault();

            if (m == null)
            {
                throw new Exception($"没有找到单号({payOrderId})的预付款信息。");
            }
            if (isCash)
            {
                if (!m.IsAllowedCashPay)
                {
                    throw new Exception("该订单不允许现金支付!");
                }
            }
            m.FeeTypeCode      = feeTypeCode;
            m.PayStatus        = payStatus;
            m.PayedSuccessTime = payTime;
            m.PayRemark        = m.PayRemark + payRmk;
            db.Update(m);
            await db.SaveChangesAsync();

            return(m);
        }
Esempio n. 11
0
        public OfferFee(
            FeeTypes feeType,
            decimal loanAmount,
            decimal?percentOfIssued,
            decimal?absoluteAmount,
            decimal oneTimePartPct,
            decimal distributedPartPct
            )
        {
            Amount                 = DetectAmount(loanAmount, percentOfIssued, absoluteAmount);
            FeeType                = feeType;
            OneTimePartPercent     = oneTimePartPct;
            DistributedPartPercent = distributedPartPct;

            ValidateParts();
        }         // constructor
Esempio n. 12
0
 private void AddFee(PawnLoan loan, FeeTypes feeType, FeeStates state, decimal value, bool waived)
 {
     loan.OriginalFees.Add(new Fee
     {
         FeeType        = feeType,
         CanBeProrated  = false,
         CanBeWaived    = false,
         FeeDate        = DateTime.MinValue,
         FeeRef         = 0,
         FeeRefType     = FeeRefTypes.PAWN,
         FeeState       = state,
         OriginalAmount = value,
         Prorated       = false,
         Tag            = string.Empty,
         Value          = value,
         Waived         = waived
     });
 }
Esempio n. 13
0
        public CommRuleSpecific(OrderActionTypes actionType, bool applyToAllAccounts, 
			IAccountType accountType, IModel modelPortfolio, 
			IAccount account, IInstrument instrument, ISecCategory ruleSecCategory,
			IExchange exchange, string commRuleName, FeeTypes feeType,
			CommRuleOpenClose openClose, CommRuleBuySell buySell,
			Fees.Calculations.CommCalc commCalculation)
            : base(commRuleName, feeType, commCalculation)
        {
            this.actionType = actionType;
            this.ApplyToAllAccounts = applyToAllAccounts;
            this.AccountType = accountType;
            this.ModelPortfolio = modelPortfolio;
            this.Account = account;
            this.Instrument = instrument;
            this.RuleSecCategory = ruleSecCategory;
            this.Exchange = exchange;
            this.OpenClose = openClose;
            this.BuySell = buySell;
        }
Esempio n. 14
0
        /*-------------------------------------------------------------------------------------------------------------------------------------------
         * -------------------------------------------------------------------------------------------------------------------------------------------
         * ------------------------------------------END OF CUSTOMER HAPPINESS METHODS-------------------------------------------------------------*/

        //creates dictionary of average employee wages
        public static Dictionary <Airline, Double> GetEmployeeWages()
        {
            Dictionary <Airline, Double> employeeWages = new Dictionary <Airline, Double>();

            foreach (Airline airline in Airlines.GetAllAirlines())
            {
                double sWage           = airline.Fees.getValue(FeeTypes.GetType("Support Wage"));
                double mWage           = airline.Fees.getValue(FeeTypes.GetType("Maintenance Wage"));
                double pWage           = airline.Fees.getValue(FeeTypes.GetType("Pilot Base Salary"));      // *airline.Pilots.Count();
                double cWage           = airline.Fees.getValue(FeeTypes.GetType("Cabin Wage"));
                double iWage           = airline.Fees.getValue(FeeTypes.GetType("Instructor Base Salary")); // *PilotModel.FlightSchool.MaxNumberOfInstructors;
                int    cabinCrew       = airline.Routes.Where(r => r.Type == AirlinerModel.RouteModel.Route.RouteType.Passenger || r.Type == AirlinerModel.RouteModel.Route.RouteType.Mixed).Sum(r => ((PassengerRoute)r).getTotalCabinCrew());
                int    serviceCrew     = airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(airline)).Where(a => a.EmployeeType == AirportModel.AirportFacility.EmployeeTypes.Support).Sum(a => a.NumberOfEmployees);
                int    maintenanceCrew = airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(airline)).Where(a => a.EmployeeType == AirportModel.AirportFacility.EmployeeTypes.Maintenance).Sum(a => a.NumberOfEmployees);
                double averageWage     = ((sWage * serviceCrew) + (mWage * maintenanceCrew) + pWage + iWage + (cWage * cabinCrew)) / 5;

                averageWage = (sWage + mWage + pWage + cWage + iWage) / 5;

                employeeWages.Add(airline, averageWage);
            }
            return(employeeWages);
        }
Esempio n. 15
0
        /// <summary>
        /// 更新Paypere和更新Pay 并写入日志
        /// </summary>
        /// <param name="payOrderId"></param>
        public async Task UpdatePayedAsync(string payOrderId, string feeTypeCode, string payRmk, bool isCash, int opId, string opMan)
        {
            _db.BeginTransaction();
            try
            {
                if (!FeeTypes.IsValidFeeType(feeTypeCode))
                {
                    throw new Exception("传入费用类型错误");
                }
                if (_db.CHIS_Charge_Pay.Where(m => m.PayOrderId == payOrderId).Count() > 0)
                {
                    throw new SuccessedException("该订单已经支付过了");
                }
                var paypre = await UpdatePayPreAsync(payOrderId, feeTypeCode, payRmk, isCash, db : _db);

                if (paypre.PayStatus == 1)
                {
                    await UpdatePayAsync(paypre, opId, opMan);

                    await _logger.WriteSUCCESSAsync("ChargePayService", "UpdatePayed", "支付成功:" + payOrderId, opId, opMan, payOrderId);
                }
                _db.CommitTran();
            }
            catch (Exception ex)
            {
                _db.RollbackTran();

                //如果是历史成功了,则直接抛出历史成功错误
                if (ex is SuccessedException)
                {
                    throw ex;
                }
                //否则记录错误
                await _logger.WriteErrorAsync("ChargePayService", "UpdatePayed", ex, opId, opMan);

                throw ex;
            }
        }
Esempio n. 16
0
        private bool PropertyCost(wy_wx_pay Order)
        {
            _log.LogInformation($"【wy_pay_record】准备更新:{Order.RECORD_ID}");
            FeeTypes type = CommonFiled.EnumFeeTypes(Order.FEE_TYPES);
            var      Res  = this._order.UpdateRecoredJFZT(new wy_pay_record()
            {
                RECORD_ID = Order.RECORD_ID,
                JFZT      = 1,
                JFRQ      = Order.PAY_TIME,
                PAY_WAY   = 1,
                JFJE      = (Order.TOTAL_FEE / 100.00)
            });

            if (Res > 0)
            {
                _log.LogInformation($"【wy_pay_record】更新成功:{Order.RECORD_ID}");
            }
            else
            {
                _log.LogError($"【wy_pay_record】更新失败:{Order.RECORD_ID},订单:{Order.ID}");
                return(false);
            }
            return(true);
        }
Esempio n. 17
0
        public void ReactToPaymentFailure(Guid orderId, int?ibsOrderId, decimal amount, string transactionId, DateTime?transactionDate, FeeTypes feeType, Guid creditCardId)
        {
            Update(new CreditCardDeactivated()
            {
                CreditCardId = creditCardId
            });

            Update(new OverduePaymentLogged
            {
                OrderId         = orderId,
                IBSOrderId      = ibsOrderId,
                CreditCardId    = creditCardId,
                Amount          = amount,
                TransactionId   = transactionId,
                TransactionDate = transactionDate,
                FeeType         = feeType
            });
        }
Esempio n. 18
0
        //saves a game
        public static void SaveGame(string name)
        {
            Stopwatch sw = new Stopwatch();

            sw.Start();

            SaveObject so = new SaveObject();

            Parallel.Invoke(() =>
            {
                so.airportsList           = new List <Airport>();
                so.airportsfromstringList = new List <string>();

                var airportsInUse = Airports.GetAllAirports().Where(a => Airlines.GetAllAirlines().Exists(al => al.Airports.Contains(a)) || a.hasAirlineFacility());
                so.airportsList.AddRange(airportsInUse);

                foreach (Airport airport in Airports.GetAirports(a => !airportsInUse.Contains(a)))
                {
                    so.airportsfromstringList.Add(airport.Profile.IATACode);
                }
            }, () =>
            {
                so.airlinesList = new List <Airline>();
                so.airlinesList.AddRange(Airlines.GetAllAirlines());
            }, () =>
            {
                so.airlinersList = new List <Airliner>();
                so.airlinersList.AddRange(Airliners.GetAllAirliners().Where(a => a.Airline != null));
            }, () =>
            {
                so.calendaritemsList = new List <CalendarItem>();
                so.calendaritemsList.AddRange(CalendarItems.GetCalendarItems());
            }, () =>
            {
                so.configurationList = new List <Configuration>();
                so.configurationList.AddRange(Configurations.GetConfigurations());
            }, () =>
            {
                so.eventsList = new List <RandomEvent>();
                so.eventsList.AddRange(RandomEvents.GetEvents());
            }, () =>
            {
                so.allianceList = new List <Alliance>();
                so.allianceList.AddRange(Alliances.GetAlliances());
            }, () =>
            {
                so.Airportfacilitieslist = new List <AirportFacility>();
                so.Airportfacilitieslist.AddRange(AirportFacilities.GetFacilities());
            }, () =>
            {
                so.feeTypeslist = new List <FeeType>();
                so.feeTypeslist.AddRange(FeeTypes.GetTypes());
            }, () =>
            {
                so.advertisementTypeslist = new List <AdvertisementType>();
                so.advertisementTypeslist.AddRange(AdvertisementTypes.GetTypes());
            }, () =>
            {
                so.airlinerfacilitieslist = new List <AirlinerFacility>();
                so.airlinerfacilitieslist.AddRange(AirlinerFacilities.GetAllFacilities());
            }, () =>
            {
                so.routefacilitieslist = new List <RouteFacility>();
                so.routefacilitieslist.AddRange(RouteFacilities.GetAllFacilities());
            }, () =>
            {
                so.instance = GameObject.GetInstance();
                so.settings = Settings.GetInstance();
            }, () =>
            {
                so.airlinefacilitieslist = new List <AirlineFacility>();
                so.airlinefacilitieslist.AddRange(AirlineFacilities.GetFacilities());
            });

            string fileName = AppSettings.getCommonApplicationDataPath() + "\\saves\\" + name + ".sav";

            FileSerializer.Serialize(fileName, so);

            sw.Stop();
            Console.WriteLine("Saving: {0} ms", sw.ElapsedMilliseconds);



            //Clearing stats because there is no need for saving those.
            if (name != "autosave")
            {
                Airports.GetAllAirports().ForEach(a => a.clearDestinationPassengerStatistics());
                Airports.GetAllAirports().ForEach(a => a.clearDestinationCargoStatistics());
                AirlineHelpers.ClearRoutesStatistics();
                AirlineHelpers.ClearAirlinesStatistics();
                AirportHelpers.ClearAirportStatistics();
            }

            /*
             * SaveObject so = new SaveObject();
             * Parallel.Invoke(() =>
             * {
             *  so.airportsList = new List<Airport>();
             *  so.airportsList.AddRange(Airports.GetAllAirports());
             * }, () =>
             * {
             *  so.airlinesList = new List<Airline>();
             *  so.airlinesList.AddRange(Airlines.GetAllAirlines());
             * }, () =>
             * {
             *  so.airlinersList = new List<Airliner>();
             *  so.airlinersList.AddRange(Airliners.GetAllAirliners());
             * }, () =>
             * {
             *  so.calendaritemsList = new List<CalendarItem>();
             *  so.calendaritemsList.AddRange(CalendarItems.GetCalendarItems());
             * }, () =>
             * {
             *  so.configurationList = new List<Configuration>();
             *  so.configurationList.AddRange(Configurations.GetConfigurations());
             * }, () =>
             * {
             *  so.eventsList = new List<RandomEvent>();
             *  so.eventsList.AddRange(RandomEvents.GetEvents());
             * }, () =>
             * {
             *  so.allianceList = new List<Alliance>();
             *  so.allianceList.AddRange(Alliances.GetAlliances());
             * }, () =>
             * {
             *  so.Airportfacilitieslist = new List<AirportFacility>();
             *  so.Airportfacilitieslist.AddRange(AirportFacilities.GetFacilities());
             * }, () =>
             * {
             *  so.feeTypeslist = new List<FeeType>();
             *  so.feeTypeslist.AddRange(FeeTypes.GetTypes());
             * }, () =>
             * {
             *  so.advertisementTypeslist = new List<AdvertisementType>();
             *  so.advertisementTypeslist.AddRange(AdvertisementTypes.GetTypes());
             * }, () =>
             * {
             *  so.airlinerfacilitieslist = new List<AirlinerFacility>();
             *  so.airlinerfacilitieslist.AddRange(AirlinerFacilities.GetAllFacilities());
             * }, () =>
             * {
             *  so.routefacilitieslist = new List<RouteFacility>();
             *  so.routefacilitieslist.AddRange(RouteFacilities.GetAllFacilities());
             * }, () =>
             * {
             *  so.instance = GameObject.GetInstance();
             *  so.settings = Settings.GetInstance();
             *  so.savetype = "039";
             *  so.saveversionnumber = 1;
             * });
             */
            /*
             * DataContractSerializer serializer = new DataContractSerializer(typeof(SaveObject), null, Int32.MaxValue, false, true, null);
             *
             * using (Stream stream = new FileStream(fileName, FileMode.Create))
             * {
             *  using (DeflateStream compress = new DeflateStream(stream, CompressionLevel.Fastest))
             *  {
             *      serializer.WriteObject(compress, so);
             *  }
             * }
             */
        }
Esempio n. 19
0
        //creates the wage panel
        private StackPanel createWagesPanel()
        {
            StackPanel panelWagesFee = new StackPanel();

            TextBlock txtHeaderFoods = new TextBlock();

            txtHeaderFoods.Uid = "1002";
            //txtHeaderFoods.Margin = new Thickness(0, 5, 0, 0);
            txtHeaderFoods.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeaderFoods.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeaderFoods.FontWeight = FontWeights.Bold;
            txtHeaderFoods.Text       = Translator.GetInstance().GetString("PageAirlineWages", txtHeaderFoods.Uid);

            panelWagesFee.Children.Add(txtHeaderFoods);

            lbFoodDrinks = new ListBox();
            lbFoodDrinks.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbFoodDrinks.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.FoodDrinks))
            {
                lbFoodDrinks.Items.Add(new QuickInfoValue(type.Name, createWageSlider(type)));
            }

            panelWagesFee.Children.Add(lbFoodDrinks);

            TextBlock txtHeaderFees = new TextBlock();

            txtHeaderFees.Uid    = "1003";
            txtHeaderFees.Margin = new Thickness(0, 5, 0, 0);
            txtHeaderFees.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeaderFees.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeaderFees.FontWeight = FontWeights.Bold;
            txtHeaderFees.Text       = Translator.GetInstance().GetString("PageAirlineWages", txtHeaderFees.Uid);

            panelWagesFee.Children.Add(txtHeaderFees);

            lbFees = new ListBox();
            lbFees.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbFees.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.Fee).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year))
            {
                lbFees.Items.Add(new QuickInfoValue(type.Name, createWageSlider(type)));
            }

            panelWagesFee.Children.Add(lbFees);

            TextBlock txtHeaderDiscounts = new TextBlock();

            txtHeaderDiscounts.Uid    = "1015";
            txtHeaderDiscounts.Margin = new Thickness(0, 5, 0, 0);
            txtHeaderDiscounts.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeaderDiscounts.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeaderDiscounts.FontWeight = FontWeights.Bold;
            txtHeaderDiscounts.Text       = Translator.GetInstance().GetString("PageAirlineWages", txtHeaderDiscounts.Uid);

            panelWagesFee.Children.Add(txtHeaderDiscounts);

            lbDiscounts = new ListBox();
            lbDiscounts.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbDiscounts.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.Discount).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year))
            {
                lbDiscounts.Items.Add(new QuickInfoValue(type.Name, createDiscountSlider(type)));
            }

            panelWagesFee.Children.Add(lbDiscounts);

            panelWagesFee.Children.Add(createButtonsPanel());

            return(panelWagesFee);
        }
Esempio n. 20
0
        //creates the employees panel
        private StackPanel createEmployeesPanel()
        {
            StackPanel panelEmployees = new StackPanel();

            TextBlock txtHeaderWages = new TextBlock();

            txtHeaderWages.Uid    = "1001";
            txtHeaderWages.Margin = new Thickness(0, 0, 0, 0);
            txtHeaderWages.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeaderWages.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeaderWages.FontWeight = FontWeights.Bold;
            txtHeaderWages.Text       = Translator.GetInstance().GetString("PageAirlineWages", txtHeaderWages.Uid);

            panelEmployees.Children.Add(txtHeaderWages);

            lbWages = new ListBox();
            lbWages.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbWages.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");

            foreach (FeeType type in FeeTypes.GetTypes(FeeType.eFeeType.Wage))
            {
                lbWages.Items.Add(new QuickInfoValue(type.Name, createWageSlider(type)));
            }
            panelEmployees.Children.Add(lbWages);

            TextBlock txtEmployeesHeader = new TextBlock();

            txtEmployeesHeader.Uid    = "1005";
            txtEmployeesHeader.Margin = new Thickness(0, 5, 0, 0);
            txtEmployeesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtEmployeesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtEmployeesHeader.FontWeight = FontWeights.Bold;
            txtEmployeesHeader.Text       = Translator.GetInstance().GetString("PageAirlineWages", txtEmployeesHeader.Uid);

            panelEmployees.Children.Add(txtEmployeesHeader);

            ListBox lbEmployees = new ListBox();

            lbEmployees.ItemContainerStyleSelector = new ListBoxItemStyleSelector();
            lbEmployees.ItemTemplate = this.Resources["EmployeeItem"] as DataTemplate;

            int cockpitCrew = this.Airline.Pilots.Count;//this.Airline.Fleet.Sum(f => f.Airliner.Type.CockpitCrew);

            //var list = (from r in this.Airline.Fleet.SelectMany(f => f.Routes) select r);

            int cabinCrew = this.Airline.Routes.Where(r => r.Type == Route.RouteType.Passenger).Sum(r => ((PassengerRoute)r).getTotalCabinCrew());

            int serviceCrew     = this.Airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(this.Airline)).Where(a => a.EmployeeType == AirportFacility.EmployeeTypes.Support).Sum(a => a.NumberOfEmployees);
            int maintenanceCrew = this.Airline.Airports.SelectMany(a => a.getCurrentAirportFacilities(this.Airline)).Where(a => a.EmployeeType == AirportFacility.EmployeeTypes.Maintenance).Sum(a => a.NumberOfEmployees);

            lbEmployees.Items.Add(new KeyValuePair <string, int>(Translator.GetInstance().GetString("PageAirlineWages", "1009"), cockpitCrew));
            lbEmployees.Items.Add(new KeyValuePair <string, int>(Translator.GetInstance().GetString("PageAirlineWages", "1010"), cabinCrew));
            lbEmployees.Items.Add(new KeyValuePair <string, int>(Translator.GetInstance().GetString("PageAirlineWages", "1011"), serviceCrew));
            lbEmployees.Items.Add(new KeyValuePair <string, int>(Translator.GetInstance().GetString("PageAirlineWages", "1012"), maintenanceCrew));

            panelEmployees.Children.Add(lbEmployees);

            panelEmployees.Children.Add(createButtonsPanel());

            return(panelEmployees);
        }
Esempio n. 21
0
        public static string GetFeeName(FeeTypes FeeType)
        {
            string feeTypeDesc = "";

            switch (FeeType)
            {
            case FeeTypes.ADMINISTRATIVE:
                feeTypeDesc = "Administrative Fee";
                break;

            case FeeTypes.GUNLOCK:
                feeTypeDesc = "Gun Lock Fee";
                break;

            case FeeTypes.FIREARM:
                feeTypeDesc = "Firearm Fee";
                break;

            case FeeTypes.LOST_TICKET:
                feeTypeDesc = "Lost Ticket Fee";
                break;

            case FeeTypes.LATE:
                feeTypeDesc = "Late Fee";
                break;

            case FeeTypes.AUTOEXTEND:
                feeTypeDesc = "Auto Extend Fee";
                break;

            case FeeTypes.CITY:
                feeTypeDesc = "City Fee";
                break;

            case FeeTypes.INITIAL:
                feeTypeDesc = "Initial Fee";
                break;

            case FeeTypes.LOAN:
                feeTypeDesc = "Loan Fee";
                break;

            case FeeTypes.ORIGIN:
                feeTypeDesc = "Origination Fee";
                break;

            case FeeTypes.MAILER_CHARGE:
                feeTypeDesc = "PFI Mailer Fee";
                break;

            case FeeTypes.PREPAID_CITY:
                feeTypeDesc = "Prepaid City Fee";
                break;

            case FeeTypes.SETUP:
                feeTypeDesc = "Setup Fee";
                break;

            case FeeTypes.STORAGE:
                feeTypeDesc = "Storage Fee";
                break;

            case FeeTypes.INTEREST:
                feeTypeDesc = "Interest Fee";
                break;

            case FeeTypes.SERVICE:
                feeTypeDesc = "Service Fee";
                break;
            }
            return(feeTypeDesc);
        }
Esempio n. 22
0
        public PanelPilot(PagePilots parent, Pilot pilot)
        {
            this.ParentPage = parent;
            this.Pilot      = pilot;

            InitializeComponent();

            StackPanel panelPilot = new StackPanel();

            TextBlock txtHeader = new TextBlock();

            txtHeader.Uid = "1001";
            txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2");
            txtHeader.FontWeight = FontWeights.Bold;
            txtHeader.Text       = Translator.GetInstance().GetString("PanelPilot", txtHeader.Uid);

            panelPilot.Children.Add(txtHeader);

            ListBox lbPilotInformation = new ListBox();

            lbPilotInformation.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem");
            lbPilotInformation.ItemContainerStyleSelector = new ListBoxItemStyleSelector();

            lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1002"), UICreator.CreateTextBlock(this.Pilot.Profile.Name)));
            lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1003"), UICreator.CreateTextBlock(this.Pilot.Profile.Birthdate.ToShortDateString())));
            lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1004"), UICreator.CreateTownPanel(this.Pilot.Profile.Town)));

            ContentControl lblFlag = new ContentControl();

            lblFlag.SetResourceReference(ContentControl.ContentTemplateProperty, "CountryFlagLongItem");
            lblFlag.Content = new CountryCurrentCountryConverter().Convert(this.Pilot.Profile.Town.Country);

            lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1005"), lblFlag));

            lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1006"), UICreator.CreateTextBlock(this.Pilot.EducationTime.ToShortDateString())));
            lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1007"), UICreator.CreateTextBlock(this.Pilot.Rating.ToString())));
            // lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1008"), UICreator.CreateTextBlock(string.Format("{0:C}", ((int)this.Pilot.Rating) * 1000))));

            double pilotBasePrice = GameObject.GetInstance().HumanAirline.Fees.getValue(FeeTypes.GetType("Pilot Base Salary"));//GeneralHelpers.GetInflationPrice(133.53);<

            lbPilotInformation.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelPilot", "1008"), UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(((int)this.Pilot.Rating) * pilotBasePrice).ToString())));

            panelPilot.Children.Add(lbPilotInformation);

            panelPilot.Children.Add(createButtonsPanel());

            this.Content = panelPilot;
        }
Esempio n. 23
0
        public AirlineMVVM(Airline airline)
        {
            this.Airline = airline;

            this.Alliance = this.Airline.Alliances.Count == 0 ? null : this.Airline.Alliances[0];

            this.DeliveredFleet = new ObservableCollection <FleetAirliner>();
            foreach (FleetAirliner airliner in this.Airline.Fleet.FindAll(a => a.Airliner.BuiltDate <= GameObject.GetInstance().GameTime))
            {
                this.DeliveredFleet.Add(airliner);
            }

            this.OrderedFleet = this.Airline.Fleet.FindAll(a => a.Airliner.BuiltDate > GameObject.GetInstance().GameTime);
            this.Finances     = new ObservableCollection <AirlineFinanceMVVM>();
            this.LoanRate     = GeneralHelpers.GetAirlineLoanRate(this.Airline);

            this.Loans              = new ObservableCollection <LoanMVVM>();
            this.Pilots             = new ObservableCollection <PilotMVVM>();
            this.Wages              = new ObservableCollection <AirlineFeeMVVM>();
            this.Discounts          = new ObservableCollection <AirlineFeeMVVM>();
            this.Facilities         = new ObservableCollection <AirlineFacilityMVVM>();
            this.TrainingFacilities = new ObservableCollection <AirlineFacilityMVVM>();
            this.Fees            = new ObservableCollection <AirlineFeeMVVM>();
            this.Chargers        = new ObservableCollection <AirlineFeeMVVM>();
            this.Subsidiaries    = new ObservableCollection <SubsidiaryAirline>();
            this.Insurances      = new ObservableCollection <AirlineInsurance>();
            this.Advertisements  = new ObservableCollection <AirlineAdvertisementMVVM>();
            this.Destinations    = new ObservableCollection <AirlineDestinationMVVM>();
            this.AirlineAirlines = new ObservableCollection <Airline>();
            this.FundsAirlines   = new ObservableCollection <Airline>();
            this.Routes          = new List <AirlineRouteMVVM>();
            this.Codeshares      = new ObservableCollection <Airline>();
            this.Cooperations    = new List <CooperationMVVM>();

            this.Airline.Routes.ForEach(r => this.Routes.Add(new AirlineRouteMVVM(r)));
            this.Airline.Loans.FindAll(l => l.IsActive).ForEach(l => this.Loans.Add(new LoanMVVM(l, this.Airline)));
            this.Airline.Pilots.ForEach(p => this.Pilots.Add(new PilotMVVM(p)));

            this.UnassignedPilots = this.Pilots.Count(p => p.Pilot.Airliner == null);
            this.PilotsToRetire   = this.Pilots.Count(p => p.Pilot.Profile.Age == Pilot.RetirementAge - 1);

            FeeTypes.GetTypes(FeeType.eFeeType.Wage).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Wages.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));
            FeeTypes.GetTypes(FeeType.eFeeType.Discount).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Discounts.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));

            FeeTypes.GetTypes(FeeType.eFeeType.FoodDrinks).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Chargers.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));

            FeeTypes.GetTypes(FeeType.eFeeType.Fee).FindAll(f => f.FromYear <= GameObject.GetInstance().GameTime.Year).ForEach(f => this.Fees.Add(new AirlineFeeMVVM(f, this.Airline.Fees.getValue(f))));

            this.Airline.Subsidiaries.ForEach(s => this.Subsidiaries.Add(s));
            this.Airline.InsurancePolicies.ForEach(i => this.Insurances.Add(i));
            this.Airline.Codeshares.ForEach(c => this.Codeshares.Add(c.Airline1 == this.Airline ? c.Airline2 : c.Airline1));

            foreach (Airport airport in this.Airline.Airports)
            {
                foreach (Cooperation cooperation in airport.Cooperations.Where(c => c.Airline == this.Airline))
                {
                    this.Cooperations.Add(new CooperationMVVM(airport, cooperation));
                }
            }

            setValues();

            this.Colors = new List <PropertyInfo>();

            foreach (PropertyInfo c in typeof(Colors).GetProperties())
            {
                this.Colors.Add(c);
            }

            foreach (Airport airport in this.Airline.Airports.OrderByDescending(a => this.Airline.Airports[0] == a).ThenBy(a => a.Profile.Name))
            {
                this.Destinations.Add(new AirlineDestinationMVVM(airport, airport.hasHub(this.Airline)));
            }

            double buyingPrice = this.Airline.getValue() * 1000000 * 1.10;

            this.IsBuyable = !this.Airline.IsHuman && GameObject.GetInstance().HumanAirline.Money > buyingPrice;

            this.ActiveQuantity  = new List <AirlinerQuantityMVVM>();
            this.OrderedQuantity = new List <AirlinerQuantityMVVM>();

            var fleet = new List <FleetAirliner>(this.Airline.Fleet);

            foreach (FleetAirliner airliner in fleet)
            {
                if (airliner.Airliner.BuiltDate > GameObject.GetInstance().GameTime)
                {
                    if (this.OrderedQuantity.Any(o => o.Type == airliner.Airliner.Type))
                    {
                        this.OrderedQuantity.First(o => o.Type == airliner.Airliner.Type).Quantity++;
                    }
                    else
                    {
                        this.OrderedQuantity.Add(new AirlinerQuantityMVVM(airliner.Airliner.Type, 1));
                    }
                }
                else
                {
                    if (this.ActiveQuantity.Any(o => o.Type == airliner.Airliner.Type))
                    {
                        this.ActiveQuantity.First(o => o.Type == airliner.Airliner.Type).Quantity++;
                    }
                    else
                    {
                        this.ActiveQuantity.Add(new AirlinerQuantityMVVM(airliner.Airliner.Type, 1));
                    }
                }
            }

            this.HasAlliance = this.Alliance != null || this.Codeshares.Count > 0;
        }
Esempio n. 24
0
        //更新到收款表
        private async Task <bool> UpdatePayAsync(CHIS_Charge_PayPre payPre, int opId, string opMan)
        {
            if (payPre.PayStatus == 0)
            {
                throw new Exception("该笔支付订单没有支付成功,请确认。");
            }
            var db = _db;

            db.BeginTransaction();
            try
            {
                var formed = db.CHIS_Charge_PayPre_Detail_Formed.AsNoTracking().Where(m => m.PayPreID == payPre.Id).ToList();   //成药
                var herb   = db.CHIS_Charge_PayPre_Detail_Herb.AsNoTracking().Where(m => m.PayPreID == payPre.Id).ToList();     //中药
                var extras = db.CHIS_Charge_PayPre_Detail_ExtraFee.AsNoTracking().Where(m => m.PayPreId == payPre.Id).ToList(); //附加费

                var find = db.CHIS_Charge_Pay.AsNoTracking().Where(m => m.PayOrderId == payPre.PayOrderId);
                if (find.Count() > 0)
                {
                    throw new PayException(PayExceptionType.PayedFinishAndSuccess, "该支付订单已经存在,已经支付,无需重复。");
                }
                //添加主表
                #region 添加主表

                var debuglog = _env.IsDevelopment() ? "[测试]" : "";

                var pay = (await db.CHIS_Charge_Pay.AddAsync(new CHIS_Charge_Pay
                {
                    TotalAmount = payPre.TotalAmount,
                    TreatId = payPre.treatId,
                    FeeTypeCode = payPre.FeeTypeCode,
                    PayedTime = payPre.PayedSuccessTime ?? DateTime.Now,
                    PayOrderId = payPre.PayOrderId,
                    StationId = payPre.StationId,
                    PayRemark = payPre.PayRemark + debuglog,
                    sysOpId = opId,
                    sysOpMan = opMan,
                    sysOpTime = DateTime.Now
                })).Entity;
                await db.SaveChangesAsync();

                #endregion


                //添加从表
                #region 添加一般从表
                //------------- 成药 ------------------------------
                foreach (var mm in formed)
                {
                    await db.CHIS_Charge_Pay_Detail_Formed.AddAsync(new CHIS_Charge_Pay_Detail_Formed
                    {
                        Amount         = mm.Amount,
                        PrescriptionNo = mm.PrescriptionNo,
                        TreatId        = mm.TreatId,
                        UnitId         = mm.UnitID,
                        Quantity       = mm.Quantity,
                        Price          = mm.Price,
                        PayId          = pay.PayId,
                        DoctorAdviceId = mm.DoctorAdviceId
                    });

                    //更新医嘱缴费状态
                    var ma = db.CHIS_DoctorAdvice_Formed.FirstOrDefault(m => m.PrescriptionNo == mm.PrescriptionNo);
                    if (ma == null)
                    {
                        throw new Exception("没有发现医嘱信息");
                    }
                    ma.ChargeStatus = (short)ChargeStatus.Payed;//设置为已经缴费
                }

                // ------------ 中药 -------------------------------
                foreach (var mm in herb)
                {
                    await db.CHIS_Charge_Pay_Detail_Herb.AddAsync(new CHIS_Charge_Pay_Detail_Herb
                    {
                        Amount         = mm.Amount,
                        PrescriptionNo = mm.PrescriptionNo,
                        TreatId        = mm.TreatId,
                        UnitID         = mm.UnitID,
                        Quantity       = mm.Quantity,
                        Price          = mm.Price,
                        PayId          = pay.PayId,
                        PayOrderId     = pay.PayOrderId,
                        DoctorAdviceId = mm.DoctorAdviceId
                    });

                    //更新医嘱缴费状态
                    var ma = db.CHIS_DoctorAdvice_Herbs.FirstOrDefault(m => m.PrescriptionNo == mm.PrescriptionNo);
                    if (ma == null)
                    {
                        throw new Exception("没有发现医嘱信息");
                    }
                    ma.ChargeStatus = (short)ChargeStatus.Payed;//设置为已经缴费
                }

                #endregion

                #region 添加附加费从表
                foreach (var mm in extras)
                {
                    await db.CHIS_Charge_Pay_Detail_ExtraFee.AddAsync(new CHIS_Charge_Pay_Detail_ExtraFee
                    {
                        DoctorExtraFeeId = mm.DoctorExtraFeeId,
                        ExtraFeeAmount   = mm.ExtraFeeAmount,
                        ExtraFeeTypeId   = mm.ExtraFeeTypeId,
                        PayId            = pay.PayId
                    });
                }
                await db.SaveChangesAsync();

                #endregion

                var treat = _treatSvr.FindTreat(pay.TreatId);
                treat.NeedPayAmount = 0;
                await db.SaveChangesAsync();

                db.CommitTran();

                //操作成功则赠送积分信息
                if (payPre.FeeTypeCode == FeeTypes.AliPay_QR ||
                    payPre.FeeTypeCode == FeeTypes.WeChat_H5 ||
                    payPre.FeeTypeCode == FeeTypes.WeChat_Pub ||
                    payPre.FeeTypeCode == FeeTypes.WeChat_QR)
                {
                    _pointsService.ChangePoints(new Models.InputModel.PointsDetailInputModel
                    {
                        CustomerId  = treat.CustomerId,
                        Description = FeeTypes.ToName(payPre.FeeTypeCode) + $"支付赠送(消费{pay.TotalAmount})",
                        Points      = (int)(payPre.TotalAmount * 100)
                    });
                }

                _logger.WriteSUCCESS($"订单支付更新数据成功:{payPre.PayOrderId}", opId, opMan);
            }
            catch (Exception ex)
            {
                db.RollbackTran();
                _logger.WriteError(ex, opId, opMan);
                throw ex;
            }
            return(true);
        }
Esempio n. 25
0
        /// <summary>
        /// 已经支付了
        /// </summary>
        /// <param name="dt0"></param>
        /// <param name="dt1"></param>
        /// <param name="stationId"></param>
        /// <param name="doctorId"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public Ass.Mvc.PageListInfo <PayedItem> GetChargeListPayedModel(string searchText, bool bAllClinic, DateTime dt0, DateTime dt1, int stationId, int?doctorId = null, int?registOpId = null, int pageIndex = 1, int pageSize = 20)
        {
            var f = _db.vwCHIS_Charge_Pay.AsNoTracking().Join(
                _db.vwCHIS_DoctorTreat, a => a.TreatId, g => g.TreatId, (a, g) => new
            {
                a.DoctorId,
                a.StationId,
                a.TreatTime,
                g.RegistOpId,
                a.CustomerId,
                a.CustomerName,
                a.CustomerMobile,
                a.Gender,
                a.PayedTime,
                a.PayOrderId,
                a.PayId,
                a.TotalAmount,
                a.TreatId,
                a.FeeTypeCode,
                a.PayRemark
            });

            f = f.Where(m => m.StationId == stationId && m.TreatTime >= dt0 && m.TreatTime < dt1);

            if (registOpId.HasValue)
            {
                f = f.Where(m => m.RegistOpId == registOpId);
            }
            else if (doctorId > 0 && !bAllClinic)
            {
                f = f.Where(m => m.DoctorId == doctorId);
            }

            if (searchText.IsNotEmpty())
            {
                var tp = searchText.GetStringType();
                if (tp.IsMobile)
                {
                    f = f.Where(m => m.CustomerMobile == tp.String);
                }
                else
                {
                    f = f.Where(m => m.CustomerName.Contains(searchText));
                }
            }
            var find = f.Select(m => new PayedItem
            {
                CustomerId      = m.CustomerId.Value,
                CustomerName    = m.CustomerName,
                Gender          = m.Gender,
                TreatTime       = m.TreatTime,
                TreatId         = m.TreatId,
                PayedTime       = m.PayedTime,
                PayOrderId      = m.PayOrderId,
                PayId           = m.PayId,
                TotalAmount     = m.TotalAmount,
                PayRemark       = m.PayRemark,
                FeeTypeCode     = m.FeeTypeCode,
                FeeTypeCodeName = FeeTypes.ToName(m.FeeTypeCode)
            });

            var total = find.Count();
            var list  = find.OrderByDescending(m => m.PayedTime).Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
            //获取图片
            var pics = _cusSvr.GetCustomersImage(list.Select(m => m.CustomerId).ToList());

            foreach (var item in list)
            {
                item.CustomerPic = pics.FirstOrDefault(m => m.CustomerId == item.CustomerId)?.PicUrl;
            }

            return(new Ass.Mvc.PageListInfo <PayedItem>()
            {
                PageSize = pageSize,
                RecordTotal = total,
                PageIndex = pageIndex,
                DataList = list
            });
        }
        public static DataSet GetFeeCalculations(
            string calcName, FeeTypes feeType, 
            B4F.TotalGiro.ApplicationLayer.UC.AccountFinderAdapter.AccountGuiStatus activeStatus, 
            string propertyList)
        {
            DataSet ds = null;
            IDalSession session = NHSessionFactory.CreateSession();
            Hashtable parameters = new Hashtable();

            if (!string.IsNullOrEmpty(calcName))
                parameters.Add("calcName", Util.PrepareNamedParameterWithWildcard(calcName, MatchModes.Anywhere));
            if (feeType > 0)
                parameters.Add("feeType", feeType);
            if (activeStatus != B4F.TotalGiro.ApplicationLayer.UC.AccountFinderAdapter.AccountGuiStatus.All)
                parameters.Add("isActive", (activeStatus == B4F.TotalGiro.ApplicationLayer.UC.AccountFinderAdapter.AccountGuiStatus.Active));
            IManagementCompany comp = LoginMapper.GetCurrentManagmentCompany(session);
            if (comp == null)
                throw new ApplicationException("Not good");
            else if (!comp.IsStichting)
                parameters.Add("managementCompanyID", comp.Key);

            List<IFeeCalc> calculations = session.GetTypedListByNamedQuery<IFeeCalc>(
                "B4F.TotalGiro.Fees.FeeCalculations.FeeCalculations",
                parameters);

            ds = DataSetBuilder.CreateDataSetFromBusinessObjectList(
                calculations,
                propertyList);

            session.Close();
            return ds;
        }
Esempio n. 27
0
        //simulates the landing of a flight
        private static void SimulateLanding(FleetAirliner airliner)
        {
            DateTime landingTime = airliner.CurrentFlight.FlightTime.Add(MathHelpers.GetFlightTime(airliner.CurrentFlight.Entry.DepartureAirport.Profile.Coordinates.convertToGeoCoordinate(), airliner.CurrentFlight.Entry.Destination.Airport.Profile.Coordinates.convertToGeoCoordinate(), airliner.Airliner.Type));
            double   fdistance   = MathHelpers.GetDistance(airliner.CurrentFlight.getDepartureAirport(), airliner.CurrentFlight.Entry.Destination.Airport);


            TimeSpan flighttime            = landingTime.Subtract(airliner.CurrentFlight.FlightTime);
            double   groundTaxPerPassenger = 5;

            double tax = 0;

            if (airliner.CurrentFlight.Entry.Destination.Airport.Profile.Country != airliner.CurrentFlight.getDepartureAirport().Profile.Country)
            {
                tax = 2 * tax;
            }

            double ticketsIncome = 0;
            double feesIncome    = 0;
            double mealExpenses  = 0;
            double fuelExpenses  = 0;

            if (airliner.CurrentFlight.isPassengerFlight())
            {
                tax          = groundTaxPerPassenger * airliner.CurrentFlight.getTotalPassengers();
                fuelExpenses = FleetAirlinerHelpers.GetFuelExpenses(airliner, fdistance);

                foreach (FlightAirlinerClass fac in airliner.CurrentFlight.Classes)
                {
                    ticketsIncome += fac.Passengers * ((PassengerRoute)airliner.CurrentFlight.Entry.TimeTable.Route).getRouteAirlinerClass(fac.AirlinerClass.Type).FarePrice;
                }

                FeeType employeeDiscountType = FeeTypes.GetType("Employee Discount");
                double  employeesDiscount    = airliner.Airliner.Airline.Fees.getValue(employeeDiscountType);

                double totalDiscount = ticketsIncome * (employeeDiscountType.Percentage / 100.0) * (employeesDiscount / 100.0);
                ticketsIncome = ticketsIncome - totalDiscount;

                foreach (FeeType feeType in FeeTypes.GetTypes(FeeType.eFeeType.Fee))
                {
                    if (GameObject.GetInstance().GameTime.Year >= feeType.FromYear)
                    {
                        foreach (FlightAirlinerClass fac in airliner.CurrentFlight.Classes)
                        {
                            double percent  = 0.10;
                            double maxValue = Convert.ToDouble(feeType.Percentage) * (1 + percent);
                            double minValue = Convert.ToDouble(feeType.Percentage) * (1 - percent);

                            double value = Convert.ToDouble(rnd.Next((int)minValue, (int)maxValue)) / 100;

                            feesIncome += fac.Passengers * value * airliner.Airliner.Airline.Fees.getValue(feeType);
                        }
                    }
                }

                foreach (FlightAirlinerClass fac in airliner.CurrentFlight.Classes)
                {
                    foreach (RouteFacility facility in ((PassengerRoute)airliner.CurrentFlight.Entry.TimeTable.Route).getRouteAirlinerClass(fac.AirlinerClass.Type).getFacilities())
                    {
                        if (facility.EType == RouteFacility.ExpenseType.Fixed)
                        {
                            mealExpenses += fac.Passengers * facility.ExpensePerPassenger;
                        }
                        else
                        {
                            FeeType feeType  = facility.FeeType;
                            double  percent  = 0.10;
                            double  maxValue = Convert.ToDouble(feeType.Percentage) * (1 + percent);
                            double  minValue = Convert.ToDouble(feeType.Percentage) * (1 - percent);

                            double value = Convert.ToDouble(rnd.Next((int)minValue, (int)maxValue)) / 100;

                            mealExpenses -= fac.Passengers * value * airliner.Airliner.Airline.Fees.getValue(feeType);
                        }
                    }
                }
            }
            if (airliner.CurrentFlight.isCargoFlight())
            {
                tax          = groundTaxPerPassenger * airliner.CurrentFlight.Cargo;
                fuelExpenses = FleetAirlinerHelpers.GetFuelExpenses(airliner, fdistance);

                ticketsIncome = airliner.CurrentFlight.Cargo * airliner.CurrentFlight.getCargoPrice();
            }


            Airport dest = airliner.CurrentFlight.Entry.Destination.Airport;
            Airport dept = airliner.CurrentFlight.Entry.DepartureAirport;

            double dist = MathHelpers.GetDistance(dest.Profile.Coordinates.convertToGeoCoordinate(), dept.Profile.Coordinates.convertToGeoCoordinate());

            double expenses = fuelExpenses + dest.getLandingFee() + tax;

            if (double.IsNaN(expenses))
            {
                expenses = 0;
            }

            if (double.IsNaN(ticketsIncome) || ticketsIncome < 0)
            {
                ticketsIncome = 0;
            }

            FleetAirlinerHelpers.SetFlightStats(airliner);

            long airportIncome = Convert.ToInt64(dest.getLandingFee());

            dest.Income += airportIncome;

            Airline airline = airliner.Airliner.Airline;

            var agreements = airline.Codeshares.Where(c => c.Airline1 == airline || c.Type == CodeshareAgreement.CodeshareType.Both_Ways);

            foreach (CodeshareAgreement agreement in agreements)
            {
                var tAirline = agreement.Airline1 == airline ? agreement.Airline2 : agreement.Airline1;

                double agreementIncome = ticketsIncome * (CodeshareAgreement.TicketSalePercent / 100);

                AirlineHelpers.AddAirlineInvoice(tAirline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Tickets, agreementIncome);
            }

            AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Flight_Expenses, -expenses);
            AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Tickets, ticketsIncome);
            AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.OnFlight_Income, -mealExpenses);
            AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Fees, feesIncome);

            airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Flight_Expenses, -expenses));
            airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Tickets, ticketsIncome));
            airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.OnFlight_Income, -mealExpenses));
            airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Fees, feesIncome));

            double wages = 0;

            if (airliner.CurrentFlight.isPassengerFlight())
            {
                int cabinCrew = ((AirlinerPassengerType)airliner.Airliner.Type).CabinCrew;

                wages = cabinCrew * flighttime.TotalHours * airliner.Airliner.Airline.Fees.getValue(FeeTypes.GetType("Cabin Wage"));// +(airliner.CurrentFlight.Entry.TimeTable.Route.getTotalCabinCrew() * airliner.Airliner.Airline.Fees.getValue(FeeTypes.GetType("Cabin kilometer rate")) * fdistance) + (airliner.Airliner.Type.CockpitCrew * airliner.Airliner.Airline.Fees.getValue(FeeTypes.GetType("Cockpit kilometer rate")) * fdistance);
                //wages
                AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.Wages, -wages);

                HolidayYearEvent holiday = HolidayYear.GetHoliday(airline.Profile.Country, GameObject.GetInstance().GameTime);

                if (holiday != null && (holiday.Holiday.Travel == Holiday.TravelType.Both || holiday.Holiday.Travel == Holiday.TravelType.Normal))
                {
                    wages = wages * 1.50;
                }

                airliner.CurrentFlight.Entry.TimeTable.Route.addRouteInvoice(new Invoice(GameObject.GetInstance().GameTime, Invoice.InvoiceType.Wages, -wages));

                CreatePassengersHappiness(airliner);
            }


            airliner.Statistics.addStatisticsValue(GameObject.GetInstance().GameTime.Year, StatisticsTypes.GetStatisticsType("Airliner_Income"), ticketsIncome - expenses - mealExpenses + feesIncome - wages);

            airliner.Airliner.Flown += fdistance;

            if (airliner.CurrentFlight.isPassengerFlight())
            {
                foreach (Cooperation cooperation in airliner.CurrentFlight.Entry.Destination.Airport.Cooperations.Where(c => c.Airline == airline))
                {
                    double incomePerPax = MathHelpers.GetRandomDoubleNumber(cooperation.Type.IncomePerPax * 0.9, cooperation.Type.IncomePerPax * 1.1);

                    double incomeFromCooperation = Convert.ToDouble(airliner.CurrentFlight.getTotalPassengers()) * incomePerPax;

                    AirlineHelpers.AddAirlineInvoice(airline, GameObject.GetInstance().GameTime, Invoice.InvoiceType.OnFlight_Income, incomeFromCooperation);
                }
            }



            if (airliner.Airliner.Airline.IsHuman && Settings.GetInstance().MailsOnLandings)
            {
                GameObject.GetInstance().NewsBox.addNews(new News(News.NewsType.Flight_News, GameObject.GetInstance().GameTime, string.Format("{0} landed", airliner.Name), string.Format("Your airliner [LI airliner={0}] has landed in [LI airport={1}], {2} with {3} passengers.\nThe airliner flow from [LI airport={4}], {5}", new object[] { airliner.Airliner.TailNumber, dest.Profile.IATACode, dest.Profile.Country.Name, airliner.CurrentFlight.getTotalPassengers(), dept.Profile.IATACode, dept.Profile.Country.Name })));
            }

            if (airliner.CurrentFlight is StopoverFlight && !((StopoverFlight)airliner.CurrentFlight).IsLastTrip)
            {
                SimulateFlight(airliner.CurrentFlight.Entry);
            }
            else
            {
                airliner.CurrentFlight = null;
            }
        }
Esempio n. 28
0
        private PreAuthorizePaymentResponse PreauthorizePaymentIfNecessary(Guid orderId, decimal totalFeeAmount, FeeTypes feeType, string companyKey = null)
        {
            // Check payment instead of PreAuth setting, because we do not preauth in the cases of future bookings
            var paymentInfo = _paymentDao.FindByOrderId(orderId, companyKey);

            if (paymentInfo != null)
            {
                // Already preauthorized on create order, do nothing
                return(new PreAuthorizePaymentResponse {
                    IsSuccessful = true
                });
            }

            var orderDetail = _orderDao.FindById(orderId);

            if (orderDetail == null)
            {
                return(new PreAuthorizePaymentResponse
                {
                    IsSuccessful = false,
                    Message = "Order not found"
                });
            }

            var account = _accountDao.FindById(orderDetail.AccountId);

            // Fees are collected by the local company
            var result = _paymentService.PreAuthorize(null, orderId, account, totalFeeAmount);

            if (result.IsSuccessful)
            {
                // Wait for OrderPaymentDetail to be created
                Thread.Sleep(500);
            }
            else if (result.IsDeclined)
            {
                // Deactivate credit card if it was declined
                _commandBus.Send(new ReactToPaymentFailure
                {
                    AccountId       = orderDetail.AccountId,
                    OrderId         = orderId,
                    IBSOrderId      = orderDetail.IBSOrderId,
                    CreditCardId    = account.DefaultCreditCard.GetValueOrDefault(),
                    OverdueAmount   = totalFeeAmount,
                    TransactionId   = result.TransactionId,
                    TransactionDate = result.TransactionDate,
                    FeeType         = feeType
                });
            }

            return(result);
        }
Esempio n. 29
0
 public Fee(DateTime assignTime, decimal amount, FeeTypes feeType)
 {
     AssignTime = assignTime;
     Amount     = amount;
     FeeType    = feeType;
 }         // constructor
Esempio n. 30
0
        private CommitPreauthorizedPaymentResponse CommitPayment(decimal totalFeeAmount, decimal bookingFees, Guid orderId, FeeTypes feeType, string companyKey = null)
        {
            var orderDetail = _orderDao.FindById(orderId);

            if (orderDetail == null)
            {
                throw new Exception("Order not found");
            }

            if (orderDetail.IBSOrderId == null)
            {
                throw new Exception("Order has no IBSOrderId");
            }

            var account = _accountDao.FindById(orderDetail.AccountId);

            var paymentDetail = _paymentDao.FindByOrderId(orderId, companyKey);

            if (paymentDetail == null)
            {
                throw new Exception("Payment not found");
            }

            var paymentProviderServiceResponse = new CommitPreauthorizedPaymentResponse
            {
                TransactionId = paymentDetail.TransactionId
            };

            try
            {
                var message = string.Empty;

                if (paymentDetail.IsCompleted)
                {
                    message = "Order already paid or payment currently processing";
                }
                else
                {
                    if (totalFeeAmount > 0)
                    {
                        // Fees are collected by the local company
                        paymentProviderServiceResponse = _paymentService.CommitPayment(null, orderId, account, paymentDetail.PreAuthorizedAmount, totalFeeAmount, totalFeeAmount, 0, paymentDetail.TransactionId);
                        message = paymentProviderServiceResponse.Message;
                    }
                    else
                    {
                        // void preauth if it exists
                        _paymentService.VoidPreAuthorization(null, orderId);

                        paymentProviderServiceResponse.IsSuccessful = true;
                    }
                }

                if (paymentProviderServiceResponse.IsSuccessful)
                {
                    // Payment completed

                    var fareObject = FareHelper.GetFareFromAmountInclTax(Convert.ToDouble(totalFeeAmount), _serverSettings.ServerData.VATIsEnabled ? _serverSettings.ServerData.VATPercentage : 0);

                    _commandBus.Send(new CaptureCreditCardPayment
                    {
                        AccountId         = account.Id,
                        PaymentId         = paymentDetail.PaymentId,
                        Provider          = _paymentService.ProviderType(companyKey, orderDetail.Id),
                        TotalAmount       = totalFeeAmount,
                        MeterAmount       = Convert.ToDecimal(fareObject.AmountExclTax),
                        TipAmount         = Convert.ToDecimal(0),
                        TaxAmount         = Convert.ToDecimal(fareObject.TaxAmount),
                        AuthorizationCode = paymentProviderServiceResponse.AuthorizationCode,
                        TransactionId     = paymentProviderServiceResponse.TransactionId,
                        FeeType           = feeType,
                        BookingFees       = bookingFees
                    });
                }
                else
                {
                    // Void PreAuth because commit failed
                    _paymentService.VoidPreAuthorization(null, orderId);

                    // Payment error
                    _commandBus.Send(new LogCreditCardError
                    {
                        PaymentId = paymentDetail.PaymentId,
                        Reason    = message
                    });

                    if (paymentProviderServiceResponse.IsDeclined)
                    {
                        _commandBus.Send(new ReactToPaymentFailure
                        {
                            AccountId       = account.Id,
                            OrderId         = orderId,
                            IBSOrderId      = orderDetail.IBSOrderId,
                            CreditCardId    = account.DefaultCreditCard.GetValueOrDefault(),
                            OverdueAmount   = totalFeeAmount,
                            TransactionId   = paymentProviderServiceResponse.TransactionId,
                            TransactionDate = paymentProviderServiceResponse.TransactionDate,
                            FeeType         = feeType
                        });
                    }
                }

                return(new CommitPreauthorizedPaymentResponse
                {
                    AuthorizationCode = paymentProviderServiceResponse.AuthorizationCode,
                    TransactionId = paymentProviderServiceResponse.TransactionId,
                    IsSuccessful = paymentProviderServiceResponse.IsSuccessful,
                    Message = paymentProviderServiceResponse.IsSuccessful ? "Success" : message
                });
            }
            catch (Exception e)
            {
                _logger.LogMessage("Error during fee payment " + e);
                _logger.LogError(e);

                return(new CommitPreauthorizedPaymentResponse
                {
                    IsSuccessful = false,
                    TransactionId = paymentProviderServiceResponse.TransactionId,
                    Message = e.Message
                });
            }
        }
Esempio n. 31
0
        public PageAirlineWages(Airline airline)
        {
            InitializeComponent();

            this.Airline = airline;

            this.FeeValues = new Dictionary <FeeType, double>();

            FeeTypes.GetTypes().ForEach(f => this.FeeValues.Add(f, this.Airline.Fees.getValue(f)));

            StackPanel panelWagesAndEmployees = new StackPanel();

            WrapPanel panelMenuButtons = new WrapPanel();

            panelWagesAndEmployees.Children.Add(panelMenuButtons);

            ucSelectButton sbWages = new ucSelectButton();

            sbWages.Uid        = "1004";
            sbWages.Content    = Translator.GetInstance().GetString("PageAirlineWages", sbWages.Uid);
            sbWages.IsSelected = true;
            sbWages.Click     += new RoutedEventHandler(sbWages_Click);
            panelMenuButtons.Children.Add(sbWages);

            ucSelectButton sbEmployees = new ucSelectButton();

            sbEmployees.Uid     = "1005";
            sbEmployees.Content = Translator.GetInstance().GetString("PageAirlineWages", sbEmployees.Uid);
            sbEmployees.Click  += new RoutedEventHandler(sbEmployees_Click);
            panelMenuButtons.Children.Add(sbEmployees);

            ucSelectButton sbService = new ucSelectButton();

            sbService.Uid     = "1006";
            sbService.Content = Translator.GetInstance().GetString("PageAirlineWages", sbService.Uid);
            sbService.Click  += new RoutedEventHandler(sbService_Click);
            panelMenuButtons.Children.Add(sbService);

            ucSelectButton sbAirlineService = new ucSelectButton();

            sbAirlineService.Uid     = "1007";
            sbAirlineService.Content = Translator.GetInstance().GetString("PageAirlineWages", sbAirlineService.Uid);
            sbAirlineService.Click  += new RoutedEventHandler(sbAirlineService_Click);
            panelMenuButtons.Children.Add(sbAirlineService);

            ucSelectButton sbAdvertisement = new ucSelectButton();

            sbAdvertisement.Uid     = "1008";
            sbAdvertisement.Content = Translator.GetInstance().GetString("PageAirlineWages", sbAdvertisement.Uid);
            sbAdvertisement.Click  += new RoutedEventHandler(sbAdvertisement_Click);
            panelMenuButtons.Children.Add(sbAdvertisement);

            ucSelectButton sbPolicies = new ucSelectButton();

            sbPolicies.Uid     = "1016";
            sbPolicies.Content = Translator.GetInstance().GetString("PageAirlineWages", sbPolicies.Uid);
            sbPolicies.Click  += new RoutedEventHandler(sbPolicies_Click);
            panelMenuButtons.Children.Add(sbPolicies);

            panelWages = createWagesPanel();
            panelWagesAndEmployees.Children.Add(panelWages);

            panelEmployees            = createEmployeesPanel();
            panelEmployees.Visibility = System.Windows.Visibility.Collapsed;
            panelWagesAndEmployees.Children.Add(panelEmployees);

            panelInflightServices            = createInflightServicesPanel();
            panelInflightServices.Visibility = System.Windows.Visibility.Collapsed;
            panelWagesAndEmployees.Children.Add(panelInflightServices);

            panelAirlineServices            = createAirlineServicesPanel();
            panelAirlineServices.Visibility = System.Windows.Visibility.Collapsed;
            panelWagesAndEmployees.Children.Add(panelAirlineServices);

            panelAdvertisement            = createAdvertisementPanel();
            panelAdvertisement.Visibility = System.Windows.Visibility.Collapsed;
            panelWagesAndEmployees.Children.Add(panelAdvertisement);

            panelAirlinePolicies            = createPoliciesPanel();
            panelAirlinePolicies.Visibility = System.Windows.Visibility.Collapsed;
            panelWagesAndEmployees.Children.Add(panelAirlinePolicies);

            this.Content = panelWagesAndEmployees;
        }
Esempio n. 32
0
        public static string MchName(FeeTypes type)
        {
            string mId = MchId(type);

            return(MchName(mId));
        }
Esempio n. 33
0
 /// <summary>
 /// Retrieves a <b>FeeType</b> object in the system.
 /// </summary>
 /// <param name="session">An instance of the Data Access Library (see class <see cref="B4F.TotalGiro.DAL.NHSession">NHSession</see>).</param>
 /// <returns>A <b>FeeType</b> object in the system.</returns>
 public static FeeType GetFeeType(IDalSession session, FeeTypes key)
 {
     List<ICriterion> expressions = new List<ICriterion>();
     expressions.Add(Expression.Eq("key", (int)key));
     IList result = session.GetList(typeof(FeeType), expressions);
     if ((result != null) && (result.Count > 0))
         return (FeeType)result[0];
     else
         return null;
 }
Esempio n. 34
0
        //loads a game
        public static void LoadGame(string file)
        {
            string fileName = AppSettings.getCommonApplicationDataPath() + "\\saves\\" + file + ".sav";

            SaveObject deserializedSaveObject = FileSerializer.Deserialize <SaveObject>(fileName);

            /*
             *
             * DataContractSerializer serializer = new DataContractSerializer(typeof(SaveObject));
             * SaveObject deserializedSaveObject;
             * string loading;
             * int version;
             *
             * using (FileStream stream = new FileStream(fileName, FileMode.Open))
             * {
             * using (DeflateStream decompress = new DeflateStream(stream, CompressionMode.Decompress))
             * {
             *     deserializedSaveObject = (SaveObject)serializer.ReadObject(decompress);
             * }
             * }
             *
             * loading = deserializedSaveObject.savetype;
             * version = deserializedSaveObject.saveversionnumber;
             */
            //Parrarel for loading the game
            Parallel.Invoke(() =>
            {
                Airlines.Clear();

                foreach (Airline airline in deserializedSaveObject.airlinesList)
                {
                    Airlines.AddAirline(airline);
                }
            },
                            () =>
            {
                Setup.LoadAirports();

                var airports = Airports.GetAllAirports();

                Airports.Clear();

                foreach (Airport airport in deserializedSaveObject.airportsList)
                {
                    airport.Statics = new AirportStatics(airport);
                    Airports.AddAirport(airport);
                }

                foreach (string iata in deserializedSaveObject.airportsfromstringList)
                {
                    Airport airport = airports.FirstOrDefault(a => a.Profile.IATACode == iata);

                    if (airport != null)
                    {
                        Airports.AddAirport(airport);
                    }
                }
            },
                            () =>
            {
                Airliners.Clear();

                foreach (Airliner airliner in deserializedSaveObject.airlinersList)
                {
                    Airliners.AddAirliner(airliner);
                }
            },
                            () =>
            {
                CalendarItems.Clear();

                foreach (CalendarItem item in deserializedSaveObject.calendaritemsList)
                {
                    CalendarItems.AddCalendarItem(item);
                }
            },
                            () =>
            {
                Configurations.Clear();

                foreach (Configuration configuration in deserializedSaveObject.configurationList)
                {
                    Configurations.AddConfiguration(configuration);
                }
            },
                            () =>
            {
                RandomEvents.Clear();

                foreach (RandomEvent e in deserializedSaveObject.eventsList)
                {
                    RandomEvents.AddEvent(e);
                }
            },
                            () =>
            {
                Alliances.Clear();

                foreach (Alliance alliance in deserializedSaveObject.allianceList)
                {
                    Alliances.AddAlliance(alliance);
                }
            },
                            () =>
            {
                AirportFacilities.Clear();

                foreach (AirportFacility facility in deserializedSaveObject.Airportfacilitieslist)
                {
                    AirportFacilities.AddFacility(facility);
                }
            },
                            () =>
            {
                FeeTypes.Clear();

                foreach (FeeType type in deserializedSaveObject.feeTypeslist)
                {
                    FeeTypes.AddType(type);
                }
            },
                            () =>
            {
                AdvertisementTypes.Clear();

                foreach (AdvertisementType addtype in deserializedSaveObject.advertisementTypeslist)
                {
                    AdvertisementTypes.AddAdvertisementType(addtype);
                }
            },
                            () =>
            {
                AirlinerFacilities.Clear();

                foreach (AirlinerFacility airlinerfas in deserializedSaveObject.airlinerfacilitieslist)
                {
                    AirlinerFacilities.AddFacility(airlinerfas);
                }
            },
                            () =>
            {
                RouteFacilities.Clear();

                foreach (RouteFacility routefas in deserializedSaveObject.routefacilitieslist)
                {
                    RouteFacilities.AddFacility(routefas);
                }
            },
                            () =>
            {
                GameObject.SetInstance(deserializedSaveObject.instance);
                Settings.SetInstance(deserializedSaveObject.settings);
            },
                            () =>
            {
                if (deserializedSaveObject.airlinefacilitieslist != null)
                {
                    AirlineFacilities.Clear();

                    foreach (AirlineFacility airlinefac in deserializedSaveObject.airlinefacilitieslist)
                    {
                        AirlineFacilities.AddFacility(airlinefac);
                    }
                }
            }); //close parallel.invoke

            //for 0.3.9.2 and the issue with no saved facilities on a route classes
            var emptyRouteClassesFacilities = Configurations.GetConfigurations(Configuration.ConfigurationType.Routeclasses).SelectMany(c => ((RouteClassesConfiguration)c).Classes.Where(cl => cl.Facilities == null));

            foreach (RouteClassConfiguration rClassConfiguration in emptyRouteClassesFacilities)
            {
                rClassConfiguration.Facilities = new List <RouteFacility>();
            }

            Setup.SetupLoadedGame();
            //Maybe this helps? But i doubt this is the best way
            Action action = () =>
            {
                Stopwatch swPax = new Stopwatch();
                swPax.Start();

                PassengerHelpers.CreateDestinationDemand();

                //Console.WriteLine("Demand have been created in {0} ms.", swPax.ElapsedMilliseconds);
                swPax.Stop();
            };

            //create some pilots for the game
            int pilotsPool = 100 * Airlines.GetAllAirlines().Count;

            GeneralHelpers.CreatePilots(pilotsPool);
            int instructorsPool = 75 * Airlines.GetAllAirlines().Count;

            GeneralHelpers.CreateInstructors(instructorsPool);

            //creates some airliners for the game
            AirlinerHelpers.CreateStartUpAirliners();

            //Start the game paused
            GameObjectWorker.GetInstance().startPaused();

            //Task is needed this unlocks the game agian.
            Task.Factory.StartNew(action);
        }