Пример #1
0
        private void OnStartOfSimulation(object sender, EventArgs e)
        {
            // determine resource type from name
            TransmuteResourceType = resources.FindResourceType <ResourceBaseWithTransactions, IResourceType>(this, TransmuteResourceTypeName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore);

            if (TransmuteResourceType != null)
            {
                ResourceGroup = (TransmuteResourceType as IModel).Parent as ResourceBaseWithTransactions;

                var shortfallResourceType = (TransmuteResourceType as IModel).FindAncestor <IResourceType>();
                shortfallPacketSize   = (Parent as Transmutation).TransmutationPacketSize;
                shortfallWholePackets = (Parent as Transmutation).UseWholePackets;

                // get pricing of shortfall resource
                if (shortfallResourceType != null && TransmuteStyle == TransmuteStyle.UsePricing)
                {
                    shortfallPricing      = shortfallResourceType.Price(PurchaseOrSalePricingStyleType.Purchase);
                    shortfallPacketSize   = shortfallPricing.PacketSize;
                    shortfallWholePackets = shortfallPricing.UseWholePackets;

                    // get pricing of transmute resource
                    if (!(TransmuteResourceType is FinanceType))
                    {
                        transmutePricing = TransmuteResourceType.Price(PurchaseOrSalePricingStyleType.Sale);
                        if (FinanceTypeForTransactionsName != "No transactions")
                        {
                            // link to first bank account
                            financeType = resources.FindResourceType <Finance, FinanceType>(this, FinanceTypeForTransactionsName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportWarning);
                        }
                    }
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 添加点券
        /// </summary>
        /// <param name="bond"></param>
        /// <param name="eType"></param>
        /// <param name="des"></param>
        /// <returns></returns>
        public bool AddBond(int bond, FinanceType ft, string remark = null)
        {
            if (bond != 0)
            {
                BsonDocument modified = PlayerAccess.Instance.SafeUpdate(_id, "Bond", bond);
                if (modified == null)
                {
                    return false;
                }
                long newBond = Convert.ToInt64(modified["Bond"]);
                this.Bond = newBond;
                Variant v = new Variant(2);
                v.Add("Bond", this.Bond);

                this.UpdataActorR(v);
                //写日志
                PayLog log = new PayLog(ServerLogger.zoneid, Actiontype.Bond);
                log.modifyfee = bond;
                log.totalfee = newBond;
                log.toopenid = UserID;
                log.touid = PID;
                log.reserve_1 = (int)ft;
                log.remark = remark;
                this.WriteLog(log);
            }
            return true;
        }
        public IActionResult CreateFinanceType([FromBody] FinanceType financeType)
        {
            if (financeType == null)
            {
                return(Json(new Message {
                    code = 1, type = "error", message = "Dados inválidos na requisição."
                }));
            }
            if (_accountRepo.UserExists(financeType.id))
            {
                return(Json(new Message {
                    code = 2, type = "error", message = "UserID não encontrado."
                }));
            }
            var id = _financesRepo.CreateFinanceType(financeType);

            if (id == 0)
            {
                return(Json(new Message {
                    code = 3, type = "error", message = "Erro de banco de dados."
                }));
            }
            financeType.id = id;
            return(Json(new Message {
                code = financeType.id, type = "FinanceType", message = financeType.name
            }));
        }
Пример #4
0
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     // get bank account object to use
     bankAccount = Resources.GetResourceItem(this, AccountName, OnMissingResourceActionTypes.ReportWarning, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;
     // get resource type to sell
     resourceToSell = Resources.GetResourceItem(this, ResourceTypeName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as IResourceType;
 }
Пример #5
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            // locate FeedType resource
            bool resourceAvailable = false;

            bankType = Resources.GetResourceItem("Finances", BankAccountName, out resourceAvailable) as FinanceType;
        }
Пример #6
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            this.InitialiseHerd(false, true);
            IEnumerable <Ruminant> testherd = this.CurrentHerd(true);

            // check if finance is available and warn if not supplying bank account.
            if (Resources.ResourceItemsExist <Finance>())
            {
                if (BankAccountName == "")
                {
                    Summary.WriteWarning(this, $"No bank account has been specified in [a={this.Name}] while Finances are available in the simulation. No financial transactions will be recorded for the purchase and sale of animals.");
                }
            }
            if (BankAccountName != "")
            {
                bankAccount = Resources.FindResourceType <Finance, FinanceType>(this, BankAccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop);
            }

            // get trucking settings
            trucking = this.FindAllChildren <TruckingSettings>().FirstOrDefault() as TruckingSettings;

            // check if pricing is present
            if (bankAccount != null)
            {
                var breeds = HerdResource.Herd.Where(a => a.BreedParams.Breed == this.PredictedHerdBreed).GroupBy(a => a.HerdName);
                foreach (var herd in breeds)
                {
                    if (!herd.FirstOrDefault().BreedParams.PricingAvailable())
                    {
                        Summary.WriteWarning(this, String.Format("No pricing schedule has been provided for herd [r={0}]. No financial transactions will be recorded for activity [a={1}]", herd.Key, this.Name));
                    }
                }
            }
        }
Пример #7
0
        private void OnSimulationCommencing(object sender, EventArgs e)
        {
            bool foundGrowCrop = FindParentGrowCrop();

            if (!foundGrowCrop)
            {
                Summary.WriteWarning(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
                throw new ApsimXException(this, String.Format("Unable to find a parent IATGrowCrop anywhere above ({0}).", this.Name));
            }

            grandParentCropLand = (IATCropLand)parentGrowCrop.Parent;

            // get finance resource
            Finance finance = Resources.FinanceResource();

            if (finance != null)
            {
                bankAccount = Resources.GetResourceItem(this, typeof(Finance), AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;
            }

            // get labour specifications
            labour = Apsim.Children(this, typeof(LabourFilterGroupSpecified)).Cast <LabourFilterGroupSpecified>().ToList();
            if (labour == null)
            {
                labour = new List <LabourFilterGroupSpecified>();
            }

            costDate = CostDateFromHarvestDate();
        }
Пример #8
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // get bank account object to use
            bankAccount = Resources.FindResourceType <Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.ReportWarning, OnMissingResourceActionTypes.ReportErrorAndStop);
            // get resource type to sell
            resourceToSell = Resources.FindResourceType <ResourceBaseWithTransactions, IResourceType>(this, ResourceTypeName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop);
            // find market if present
            Market market = Resources.FoundMarket;

            // find a suitable store to place resource
            if (market != null)
            {
                resourceToPlace = market.Resources.LinkToMarketResourceType(resourceToSell as CLEMResourceTypeBase) as IResourceType;
            }

            if (resourceToPlace != null)
            {
                price = resourceToPlace.Price(PurchaseOrSalePricingStyleType.Purchase);
            }

            if (price is null && resourceToSell.Price(PurchaseOrSalePricingStyleType.Sale) != null)
            {
                price = resourceToSell.Price(PurchaseOrSalePricingStyleType.Sale);
            }
        }
Пример #9
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            this.InitialiseHerd(false, true);

            bankAccount = Resources.GetResourceItem(this, typeof(Finance), BankAccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;

            // get labour specifications
            labour = Apsim.Children(this, typeof(LabourFilterGroupSpecified)).Cast <LabourFilterGroupSpecified>().ToList(); //  this.Children.Where(a => a.GetType() == typeof(LabourFilterGroupSpecified)).Cast<LabourFilterGroupSpecified>().ToList();
            if (labour == null)
            {
                labour = new List <LabourFilterGroupSpecified>();
            }

            // get trucking settings
            trucking = Apsim.Children(this, typeof(TruckingSettings)).FirstOrDefault() as TruckingSettings;

            // check if pricing is present
            if (bankAccount != null)
            {
                RuminantHerd ruminantHerd = Resources.RuminantHerd();
                var          breeds       = ruminantHerd.Herd.Where(a => a.BreedParams.Breed == this.PredictedHerdBreed).GroupBy(a => a.HerdName);
                foreach (var herd in breeds)
                {
                    if (!herd.FirstOrDefault().BreedParams.PricingAvailable())
                    {
                        Summary.WriteWarning(this, String.Format("No pricing schedule has been provided for herd ({0}). No transactions will be recorded for activity ({1}).", herd.Key, this.Name));
                    }
                }
            }
        }
Пример #10
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // activity is performed in CLEMStartOfTimestep not default CLEMGetResources
            this.AllocationStyle = ResourceAllocationStyle.Manual;

            bankAccount = Resources.GetResourceItem(this, AccountName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;
        }
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            people      = Resources.Labour();
            food        = Resources.HumanFoodStore();
            bankAccount = Resources.GetResourceItem(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore) as FinanceType;

            Market = FindMarket();
        }
Пример #12
0
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     BankAccount    = Resources.FindResourceType <Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop);
     managingParent = FindAncestor <CropActivityManageProduct>();
     if (managingParent != null)
     {
         relatesToResourceName = managingParent.StoreItemName;
     }
 }
Пример #13
0
        public void SetBankData(FinanceType bank)
        {
            // Find the balance and interest
            double balance  = Convert.ToDouble(FindFirst(Source, "Cash_balance").Value);
            double interest = Convert.ToDouble(FindFirst(Source, "Int_rate").Value);

            bank.OpeningBalance      = balance;
            bank.InterestRateCharged = interest;
        }
        public long CreateFinanceType(FinanceType financeType)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("INSERT INTO lpc_g1_app.finance_types(name_finance_type, user_id) ")
            .Append("values (@name_finance_type, @user_id); ")
            .Append("SELECT last_insert_id(); ");
            MySqlCommand command = new MySqlCommand();

            command.Parameters.AddWithValue("@name_finance_type", financeType.name);
            command.Parameters.AddWithValue("@user_id", financeType.id);
            command.CommandText = sb.ToString();
            return((long)conn.ExecuteCommandScalar(command));
        }
Пример #15
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // get bank account object to use
            bankAccount = Resources.GetResourceItem(this, typeof(Finance), AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;
            // get resource type to sell
            var resourceGroup = Resources.GetResourceByName(ResourceGroupName);

            resourceToSell = Resources.GetResourceItem(this, resourceGroup.GetType(), ResourceTypeName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop) as IResourceType;
            // get labour required for sale
            Labour = Apsim.Children(this, typeof(LabourFilterGroupUnit)).Cast <LabourFilterGroupUnit>().ToList(); //  this.Children.Where(a => a.GetType() == typeof(LabourFilterGroupSpecified)).Cast<LabourFilterGroupSpecified>().ToList();
            if (Labour == null)
            {
                Labour = new List <LabourFilterGroupUnit>();
            }
        }
Пример #16
0
        /// <summary>
        /// 添加晶币
        /// </summary>
        /// <param name="coin"></param>
        /// <param name="ft"></param>
        /// <returns></returns>
        public bool AddCoin(int coin, FinanceType ft, string remark = null)
        {
            BsonDocument modified = PlayerAccess.Instance.UpdateFinance(_id, coin);
            if (modified == null)
            {
                return false;
            }
            Int64 newCoin = Convert.ToInt64(modified["Coin"]);
            this.Coin = newCoin;

            if (coin == 0)
            {
                //更新值
                return true;
            }

            if (coin < 0)
            {
                this.GCE = Convert.ToInt64(modified["GCE"]);
            }
            else
            {
                this.GCI = Convert.ToInt64(modified["GCI"]);
            }
            Variant v = new Variant(2);
            v.Add("Coin", this.Coin);
            UpdataActorR(v);
            //写日志
            PayLog log = new PayLog(ServerLogger.zoneid, Actiontype.Consumption);
            log.modifycoin = coin;
            log.totalcoin = newCoin;
            log.toopenid = UserID;
            log.touid = PID;
            log.reserve_1 = (int)ft;
            log.remark = remark;
            this.WriteLog(log);
            if (coin > 0)
            {
                this.FinishNote(FinishCommand.MaxMoney, coin, 0);
            }
            else
            {
                //发送消费通知
                UserNote note2 = new UserNote(this, SocialCommand.ConsumeCoin, new object[] { coin, ft });
                Sinan.Observer.Notifier.Instance.Publish(note2);
            }
            return true;
        }
Пример #17
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // get bank account object to use
            bankAccount = Resources.FindResourceType<Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.ReportWarning, OnMissingResourceActionTypes.ReportErrorAndStop);
            // get resource type to buy
            resourceToBuy = Resources.FindResourceType<ResourceBaseWithTransactions, IResourceType>(this, ResourceTypeName, OnMissingResourceActionTypes.ReportErrorAndStop, OnMissingResourceActionTypes.ReportErrorAndStop);

            // get pricing
            if((resourceToBuy as CLEMResourceTypeBase).MarketStoreExists)
                if ((resourceToBuy as CLEMResourceTypeBase).EquivalentMarketStore.PricingExists(PurchaseOrSalePricingStyleType.Sale))
                    price = (resourceToBuy as CLEMResourceTypeBase).EquivalentMarketStore.Price(PurchaseOrSalePricingStyleType.Sale);

            // no market price found... look in local resources and allow 0 price if not found
            if(price is null)
                price = resourceToBuy.Price(PurchaseOrSalePricingStyleType.Purchase);
        }
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            // get bank account object to use if provided
            if (AccountName != "No financial implications")
            {
                bankAccount = Resources.FindResourceType <Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore);
            }

            // get reader
            Model parentZone = this.FindAllAncestors <Zone>().FirstOrDefault();

            if (parentZone != null)
            {
                fileResource = parentZone.FindAllChildren <FileResource>(ResourceDataReader).FirstOrDefault() as FileResource;
            }
        }
        private void OnEndOfMonth(object sender, EventArgs e)
        {
            FinanceType bankAccount = Resources.FinanceResource().GetFirst() as FinanceType;

            // make interest payments on bank accounts
            foreach (FinanceType accnt in Resources.FinanceResource().Children.Where(a => a.GetType() == typeof(FinanceType)))
            {
                if (accnt.Balance > 0)
                {
                    bankAccount.Add(accnt.Balance * accnt.InterestRatePaid / 1200, this.Name, "InterestPaid");
                }
                else
                {
                    bankAccount.Remove(Math.Abs(accnt.Balance) * accnt.InterestRateCharged / 1200, this.Name, "InterestCharged");
                }
            }
        }
Пример #20
0
        private void OnWFAnimalBuy(object sender, EventArgs e)
        {
            RuminantHerd ruminantHerd = Resources.RuminantHerd();

            Finance     Accounts    = Resources.FinanceResource() as Finance;
            FinanceType bankAccount = Accounts.GetFirst() as FinanceType;

            var newRequests = ruminantHerd.PurchaseIndividuals.Where(a => a.BreedParams.Breed == BreedName).ToList();

            foreach (var newgroup in newRequests.GroupBy(a => a.SaleFlag))
            {
                double fundsAvailable = 100000000;
                if (bankAccount != null)
                {
                    fundsAvailable = bankAccount.FundsAvailable;
                }
                double cost = 0;
                foreach (var newind in newgroup)
                {
                    double value = 0;
                    if (newgroup.Key == Common.HerdChangeReason.SirePurchase)
                    {
                        value = BreedingSirePrice;
                    }
                    else
                    {
                        RuminantValue getvalue = PriceList.Where(a => a.Age < newind.Age).OrderBy(a => a.Age).LastOrDefault();
                        value = getvalue.PurchaseValue * ((getvalue.Style == Common.PricingStyleType.perKg) ? newind.Weight : 1.0);
                    }
                    if (cost + value <= fundsAvailable)
                    {
                        ruminantHerd.AddRuminant(newind);
                        cost += value;
                    }
                    else
                    {
                        break;
                    }
                }
                if (bankAccount != null)
                {
                    bankAccount.Remove(cost, this.Name, newgroup.Key.ToString());
                }
            }
        }
Пример #21
0
        private void OnStartOfSimulation(object sender, EventArgs e)
        {
            // get herd for transmutating
            ResourceGroup             = resources.FindResourceGroup <RuminantHerd>();
            TransmuteResourceTypeName = ResourceGroup.Name;
            shortfallPacketSize       = (Parent as Transmutation).TransmutationPacketSize;
            shortfallWholePackets     = (Parent as Transmutation).UseWholePackets;
            groupings = ResourceGroup.FindAllChildren <RuminantGroup>();

            var shortfallResourceType = this.FindAncestor <IResourceType>();

            if (shortfallResourceType != null && TransmuteStyle == TransmuteStyle.UsePricing)
            {
                shortfallPricing = shortfallResourceType.Price(PurchaseOrSalePricingStyleType.Purchase);
                if (FinanceTypeForTransactionsName != "No transactions")
                {
                    // link to first bank account
                    financeType = resources.FindResourceType <Finance, FinanceType>(this, FinanceTypeForTransactionsName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportWarning);
                }
            }
        }
Пример #22
0
 /// <summary>
 /// Creates a new instance by an ID
 /// </summary>
 /// <param name="id"></param>
 /// <remarks></remarks>
 public YID(string id)
 {
     if (id.IsNullOrWhiteSpace()) throw new ArgumentNullException("id", "The ID is NULL.");
     mID = id.Trim().ToUpper();
     if (this.ID.StartsWith("^")) this.Type = FinanceType.Index;
 }
Пример #23
0
 internal YID(System.Resources.WorldMarketIndex orig, WorldMarket wm)
     : this(orig.ID)
 {
     this.Name = orig.Name;
     this.Type = FinanceType.Index;
     this.StockExchange = wm.GetStockExchangeFromID(orig.StockExchange);
     if (this.StockExchange == null) throw new ArgumentException("The stock exchange ID could not be found.", "StockExchangeID");
     this.StockExchange.Indices.Add(this);
 }
Пример #24
0
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     people      = Resources.GetResourceGroupByType(typeof(Labour)) as Labour;
     food        = Resources.GetResourceGroupByType(typeof(HumanFoodStore)) as HumanFoodStore;
     bankAccount = Resources.GetResourceItem(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore) as FinanceType;
 }
Пример #25
0
 /// <summary>
 /// 战绩
 /// </summary>
 /// <param name="fightvalue">变更量</param>
 /// <param name="fb"></param>
 /// <returns></returns>
 public bool AddFightValue(int fightvalue, bool check, FinanceType fb, string remark = null)
 {
     if (fightvalue != 0)
     {
         BsonDocument modified = PlayerAccess.Instance.SafeUpdate(_id, "FightValue", fightvalue, check);
         if (modified == null)
         {
             return false;
         }
         this.FightValue = Convert.ToInt32(modified["FightValue"]);
         Variant v = new Variant(2);
         v.Add("FightValue", this.FightValue);
         this.UpdataActorR(v);
         return true;
     }
     return true;
 }
Пример #26
0
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     this.InitialiseHerd(true, true);
     bankAccount = Resources.FindResourceType <Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportWarning);
 }
Пример #27
0
        /// <summary>
        /// 失去经验
        /// </summary>
        /// <param name="b">百分比</param>
        public void LostExperience(double b, FinanceType eType, string remark = null)
        {
            if (b > 0 && b <= 1.0)
            {
                int experience = (int)(m_exp * b);
                if (experience > 0)
                {
                    m_exp -= experience;
                    Variant v = new Variant(2);
                    v["JingYan"] = new MVPair(this.m_maxExp, this.m_exp);
                    UpdataActorR(v);

                    PlayerAccess.Instance.Save(this);

                    PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.RoleExp);
                    log.level = m_level;
                    log.modifyexp = -experience;
                    log.totalexp = m_exp;
                    log.reserve_1 = (int)eType;
                    log.remark = remark;
                    this.WriteLog(log);
                }
            }
        }
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     people      = Resources.FindResourceGroup <Labour>();
     food        = Resources.FindResourceGroup <HumanFoodStore>();
     bankAccount = Resources.FindResourceType <Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore);
 }
Пример #29
0
        /// <summary>
        /// 提取技能或放生得到经验
        /// </summary>
        /// <param name="player">角色</param>
        /// <param name="id">宠物唯一标识</param>
        /// <param name="petsid">宠物</param>
        /// <param name="ft">操作方式</param>
        /// <param name="pl">宠物所有位置</param>
        /// <param name="gs">操作</param>
        public static void PetExp(PlayerBusiness player, string id, string petsid, FinanceType ft, GoodsSource gs, int pl,int level)
        {
            GameConfig gc = GameConfigAccess.Instance.FindOneById(petsid);
            if (gc == null)
                return;

            Variant v = gc.Value;
            if (v == null)
                return;

            //角色得到经验
            int p1exp = v.GetIntOrDefault("P1exp");
            //宠物取得经验
            int p2exp = v.GetIntOrDefault("P2exp");

            if (p1exp > 0)
            {
                player.AddExperience(p1exp, ft);
            }

            if (p2exp > 0 && player.Pet != null)
            {
                player.AddPetExp(player.Pet, p2exp, true, (int)ft);
            }

            player.AddLog(Actiontype.PetRemove, petsid, level, gs, id, pl);
        }
Пример #30
0
 /// <summary>
 /// 添加感恩值
 /// </summary>
 /// <param name="owe"></param>
 /// <param name="eType"></param>
 /// <param name="des"></param>
 /// <returns></returns>
 public bool AddOwe(int owe, FinanceType ft, string remark = null)
 {
     BsonDocument modified = PlayerAccess.Instance.SafeUpdate(_id, "Owe", owe);
     if (modified == null)
     {
         return false;
     }
     this.Owe = Convert.ToInt32(modified["Owe"]);
     Variant v = new Variant(2);
     v.Add("Owe", this.Owe);
     this.UpdataActorR(v);
     return true;
 }
Пример #31
0
 /// <summary>
 /// Sets the data for a FinanceType model using IAT data
 /// </summary>
 /// <param name="bank">The base model</param>
 public void SetBankData(FinanceType bank)
 {
     bank.Name                = "Bank";
     bank.OpeningBalance      = Overheads.GetData <double>(12, 0);
     bank.InterestRateCharged = Overheads.GetData <double>(11, 0);
 }
Пример #32
0
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     // locate BankType resource
     bankType = Resources.GetResourceItem(this, typeof(Finance), BankAccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore) as FinanceType;
 }
Пример #33
0
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     BankAccount = resources.FindResourceType <Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop);
 }
Пример #34
0
        private void OnWFAnimalSell(object sender, EventArgs e)
        {
            RuminantHerd ruminantHerd = Resources.RuminantHerd();

            Finance     Accounts    = Resources.FinanceResource() as Finance;
            FinanceType bankAccount = Accounts.GetFirst() as FinanceType;

            int    trucks     = 0;
            double saleValue  = 0;
            double saleWeight = 0;
            int    head       = 0;

            // get current untrucked list of animals flagged for sale
            List <Ruminant> herd = ruminantHerd.Herd.Where(a => a.SaleFlag != Common.HerdChangeReason.None & a.Breed == BreedName).OrderByDescending(a => a.Weight).ToList();

            // if sale herd > min loads before allowing sale
            if (herd.Select(a => a.Weight / 450.0).Sum() / Number450kgPerTruck >= MinimumTrucksBeforeSelling)
            {
                // while truck to fill
                while (herd.Select(a => a.Weight / 450.0).Sum() / Number450kgPerTruck > MinimumLoadBeforeSelling)
                {
                    bool nonloaded = true;
                    trucks++;
                    double load450kgs = 0;
                    // while truck below carrying capacity load individuals
                    foreach (var ind in herd)
                    {
                        if (load450kgs + (ind.Weight / 450.0) <= Number450kgPerTruck)
                        {
                            nonloaded = false;
                            head++;
                            load450kgs += ind.Weight / 450.0;
                            RuminantValue getvalue = PriceList.Where(a => a.Age < ind.Age).OrderBy(a => a.Age).LastOrDefault();
                            saleValue  += getvalue.SellValue * ((getvalue.Style == Common.PricingStyleType.perKg) ? ind.Weight : 1.0);
                            saleWeight += ind.Weight;
                            ruminantHerd.RemoveRuminant(ind);
                        }
                    }
                    if (nonloaded)
                    {
                        Summary.WriteWarning(this, String.Format("There was a problem loading the sale truck as sale individuals did not meet the loading criteria for breed {0}", BreedName));
                        break;
                    }
                    herd = ruminantHerd.Herd.Where(a => a.SaleFlag != Common.HerdChangeReason.None & a.Breed == BreedName).OrderByDescending(a => a.Weight).ToList();
                }

                if (trucks > 0 & bankAccount != null)
                {
                    // calculate transport costs
                    double transportCost = trucks * DistanceToMarket * CostPerKmTrucking;
                    bankAccount.Remove(transportCost, this.Name, "Transport");
                    // calculate MLA fees
                    double mlaCost = head * MLAFees;
                    bankAccount.Remove(mlaCost, this.Name, "R&DFee");
                    // calculate yard fees
                    double yardCost = head * YardFees;
                    bankAccount.Remove(yardCost, this.Name, "YardCosts");
                    // calculate commission
                    double commissionCost = saleValue * SalesCommission;
                    bankAccount.Remove(commissionCost, this.Name, "SalesCommission");

                    // add and remove from bank
                    bankAccount.Add(saleValue, this.Name, "Sales");
                }
            }
        }
Пример #35
0
        /// <summary>
        /// 添加游戏币
        /// </summary>
        /// <param name="score"></param>
        /// <param name="ft"></param>
        /// <returns></returns>
        public bool AddScore(int score, FinanceType ft, string remark = null)
        {
            if (score != 0)
            {
                BsonDocument modified = PlayerAccess.Instance.SafeUpdate(_id, "Score", score);
                if (modified == null)
                {
                    return false;
                }
                Int64 newScore = Convert.ToInt64(modified["Score"]);
                this.Score = newScore;
                Variant v = new Variant(2);
                v.Add("Score", this.Score);
                this.UpdataActorR(v);
                //写日志
                PayLog log = new PayLog(ServerLogger.zoneid, Actiontype.Score);
                log.modifyfee = score;
                //log.modifycoin = coin;
                //log.totalcoin = this.Coin;
                log.totalfee = newScore;
                log.toopenid = UserID;
                log.touid = PID;
                log.reserve_1 = (int)ft;
                log.remark = remark;
                this.WriteLog(log);

                if (score > 0)
                {
                    this.FinishNote(FinishCommand.MaxMoney, 0, score);
                }
            }
            return true;
        }
Пример #36
0
        /// <summary>
        /// 添加玩家经验
        /// </summary>
        /// <param name="experience">经验值</param>
        /// <param name="eType"></param>
        /// <param name="des"></param>
        /// <returns></returns>
        public int AddExperience(int experience, FinanceType eType, string remark = null)
        {
            if (experience <= 0)
            {
                return 0;
            }
            int upLev = 0;
            int curExp = Interlocked.Add(ref m_exp, experience);
            if (curExp >= m_maxExp)
            {
                upLev = UpLevel();
                if (upLev > 0)
                {
                    UserNote note = new UserNote(this, TaskCommand.PlayerActivation, new object[] { upLev, this.Level });
                    Notifier.Instance.Publish(note);
                    //成就执行
                    this.FinishNote(FinishCommand.RoleUpLev, upLev);
                    //通知场景上的玩家
                    Variant v = new Variant(2);
                    v["ID"] = this.ID;
                    v["Level"] = this.m_level;
                    this.CallAll(ClientCommand.UpdateActorR, v);
                    //获取技能
                    NewSkill(upLev);
                }
            }
            else
            {
                Variant v = new Variant(2);
                v["JingYan"] = new MVPair(this.m_maxExp, this.m_exp);
                UpdataActorR(v);
            }
            PlayerAccess.Instance.Save(this);

            PlayerLog log = new PlayerLog(ServerLogger.zoneid, Actiontype.RoleExp);
            log.level = m_level;
            log.modifyexp = experience;
            log.totalexp = curExp;
            log.reserve_1 = (int)eType;
            log.remark = remark;
            this.WriteLog(log);
            return upLev;
        }
Пример #37
0
        private void OnCLEMInitialiseActivity(object sender, EventArgs e)
        {
            people      = Resources.FindResourceGroup <Labour>();
            food        = Resources.FindResourceGroup <HumanFoodStore>();
            bankAccount = Resources.FindResourceType <Finance, FinanceType>(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore);

            Market = food.FindAncestor <ResourcesHolder>().FoundMarket;

            resourcesHolder = base.Resources;
            // if market is present point to market to find the resource
            if (Market != null)
            {
                resourcesHolder = Market.FindChild <ResourcesHolder>();
            }

            // set the food store linked in any TargetPurchase if target proportion set > 0
            // check that all purchase resources have transmutation or recalulate the proportion
            var targetPurchases = this.FindAllChildren <LabourActivityFeedTargetPurchase>().Where(a => a.TargetProportion > 0).ToList();

            if (targetPurchases.Any())
            {
                double checkPropAvailable = 0;
                double totPropAvailable   = 0;
                bool   adjusted           = false;
                foreach (var item in targetPurchases)
                {
                    checkPropAvailable += item.TargetProportion;
                    item.FoodStore      = resourcesHolder.FindResourceType <HumanFoodStore, HumanFoodStoreType>(this, item.FoodStoreName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.Ignore);
                    if (item.FoodStore.TransmutationDefined)
                    {
                        totPropAvailable         += item.TargetProportion;
                        item.ProportionToPurchase = item.TargetProportion;
                    }
                    else
                    {
                        string warn = $"The HumanFoodStoreType [r={item.FoodStore.FullPath}] does not have a Transmutation required to be a LabourActivityFeedTargetPurchase [a={item.FullPath}] of [a={this.FullPath}]{Environment.NewLine}This HumanFoodStore will not be allocated and the remaining purchase proportions have been adjusted";
                        Warnings.CheckAndWrite(warn, Summary, this, MessageType.Warning);
                        adjusted = true;
                        item.ProportionToPurchase = 0;
                    }
                }

                if (Math.Abs(1 - checkPropAvailable) < 0.0001)
                {
                    if (!adjusted)
                    {
                        string warn = $"The TargetProportions provided for [a=LabourActivityFeedTargetPurchase] provided for [a={this.FullPath}] do not sum to 1.{Environment.NewLine}These purchase proportions have been adjusted";
                        Warnings.CheckAndWrite(warn, Summary, this, MessageType.Warning);
                    }
                    adjusted = true;
                }

                // recalculate proportions to buy based on transmuation of resource allowed
                if (adjusted)
                {
                    foreach (var item in targetPurchases.Where(a => a.FoodStore.TransmutationDefined))
                    {
                        item.ProportionToPurchase = item.TargetProportion / totPropAvailable;
                    }
                }
            }
        }
Пример #38
0
 /// <summary>
 /// 添加星力
 /// </summary>
 /// <param name="starPower"></param>
 /// <param name="ft"></param>
 /// <param name="des"></param>
 /// <returns></returns>
 public bool AddStarPower(int starPower, FinanceType ft, string remark = null)
 {
     if (starPower != 0)
     {
         BsonDocument modified = PlayerAccess.Instance.SafeUpdate(_id, "StarPower", starPower);
         if (modified == null)
         {
             return false;
         }
         this.StarPower = Convert.ToInt32(modified["StarPower"]);
         Variant v = new Variant(2);
         v.Add("StarPower", this.StarPower);
         this.UpdataActorR(v);
     }
     return true;
 }
Пример #39
0
 private void OnCLEMInitialiseActivity(object sender, EventArgs e)
 {
     bankAccount = Resources.GetResourceItem(this, AccountName, OnMissingResourceActionTypes.Ignore, OnMissingResourceActionTypes.ReportErrorAndStop) as FinanceType;
 }
Пример #40
0
        public bool FillOutForm(string Year, string Make, string Model, string BodyType, FinanceType FinanceType, Use Use)
        {
            dayStrings = new List <string>();
            bool driverInfoPageExist;

            SelectElement sltYear = driver.FindSelectElementWhenPopulated(By.Id("vehicleYear"), 30);

            sltYear.SelectByText(Year);

            SelectElement sltMake = driver.FindSelectElementWhenPopulated(By.Id("vehicleMake"), 30);

            sltMake.SelectByText(Make);

            SelectElement sltModel = driver.FindSelectElementWhenPopulated(By.Id("vehicleModel"), 30);

            sltModel.SelectByText(Model);

            try
            {
                SelectElement sltBody = driver.FindSelectElementWhenPopulated(By.Id("bodyStyles"), 30);
                sltBody.SelectByText(BodyType);
            }
            catch (Exception) {}


            System.Threading.Thread.Sleep(500);


            switch (FinanceType)
            {
            case FinanceType.Owned:
                owned.Click();
                break;

            case FinanceType.Financed:
                financed.Click();
                break;

            case FinanceType.Leased:
                Leased.Click();
                break;

            default:
                break;
            }

            SelectElement annualMileageSlt;
            SelectElement daysDrivenSlt;
            SelectElement businessUseSlt;


            switch (Use)
            {
            case Use.Commute:
                Commute.Click();
                //System.Threading.Thread.Sleep(3000);

                daysDrivenSlt = driver.FindSelectElementWhenPopulated(By.Id("daysDriven"), 30);
                IList <IWebElement> days; days = daysDrivenSlt.Options;
                foreach (var day in days)
                {
                    dayStrings.Add(day.GetAttribute("value").ToString());
                }



                daysDrivenSlt.SelectByValue("5");
                milesDriven.SendKeys("15");

                annualMileageSlt = driver.FindSelectElementWhenPopulated(By.Id("annualMileage"), 30);
                annualMileageSlt.SelectByText("12,001 - 15,000");



                break;

            case Use.Pleasure:
                Pleasure.Click();


                annualMileageSlt = driver.FindSelectElementWhenPopulated(By.Id("annualMileage"), 30);

                IList <IWebElement> miles = annualMileageSlt.Options;
                annualMileageSlt.SelectByText("12,001 - 15,000");
                break;

            case Use.Business:
                Business.Click();

                businessUseSlt = driver.FindSelectElementWhenPopulated(By.Id("typeOfBusinessUse"), 30);
                businessUseSlt.SelectByText("Clergy");
                annualMileageSlt = driver.FindSelectElementWhenPopulated(By.Id("annualMileage"), 30);
                annualMileageSlt.SelectByText("12,001 - 15,000");
                break;

            default:
                break;
            }


            Submit.Click();


            try
            {
                wait.Until(ExpectedConditions.ElementExists(By.Id("maritalStatus")));
                driverInfoPageExist = true;
            }
            catch (Exception e)
            {
                driverInfoPageExist = false;
            }

            //IWebElement radioBtnOwnership = this.RbOwned;
            //IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;
            //executor.ExecuteScript("arguments[0].click();", radioBtnOwnership);

            return(driverInfoPageExist);
        }