Exemplo n.º 1
0
        private void FrmEconomyDialog_Load(object sender, EventArgs e)
        {
            IList <Economy> list = new List <Economy>();

            list.Add(economy);
            vGridControl1.DataSource = list;

            edlist.Clear();
            EconomyData ed = new EconomyData();

            ed.S1 = 2001;
            ed.S2 = 10000;
            edlist.Add(ed);

            ed    = new EconomyData();
            ed.S1 = 2002;
            ed.S2 = 20000;
            edlist.Add(ed);

            ed    = new EconomyData();
            ed.S1 = 2003;
            ed.S2 = 30000;
            edlist.Add(ed);

            vGridControl2.DataSource = edlist;
        }
Exemplo n.º 2
0
        private static void CreateSubEconomyTiers()
        {
            var shaperbases = new Dictionary <string, ItemList <FilterEconomy.Model.NinjaItem> >();
            var elderbases  = new Dictionary <string, ItemList <FilterEconomy.Model.NinjaItem> >();
            var otherbases  = new Dictionary <string, ItemList <FilterEconomy.Model.NinjaItem> >();

            foreach (var items in EconomyData.EconomyTierlistOverview["basetypes"])
            {
                var shapergroup = items.Value.Where(x => x.Variant == "Shaper").ToList();
                if (shapergroup.Count != 0)
                {
                    shaperbases.Add(items.Key, new ItemList <NinjaItem>());
                    shaperbases[items.Key].AddRange((shapergroup));
                }

                var eldegroup = items.Value.Where(x => x.Variant == "Elder").ToList();
                if (eldegroup.Count != 0)
                {
                    elderbases.Add(items.Key, new ItemList <NinjaItem>());
                    elderbases[items.Key].AddRange((eldegroup));
                }

                var othergroup = items.Value.Where(x => x.Variant != "Shaper" && x.Variant != "Elder").ToList();
                if (othergroup.Count != 0)
                {
                    otherbases.Add(items.Key, new ItemList <NinjaItem>());
                    otherbases[items.Key].AddRange((othergroup));
                }
            }

            EconomyData.AddToDictionary("rare->shaper", shaperbases);
            EconomyData.AddToDictionary("rare->elder", elderbases);
            EconomyData.AddToDictionary("generalcrafting", otherbases);
        }
Exemplo n.º 3
0
        //载入电量数据
        private void simpleButton5_Click(object sender, EventArgs e)
        {
            FormLoadForecastDataDSH frm = new FormLoadForecastDataDSH(2);

            frm.ProjectUID = MIS.ProgUID;
            if (frm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            DataRow row = frm.ROW;

            lis.Clear();
            int zhuanhuan = 1;

            if (row["Title"].ToString().IndexOf("亿") != -1)
            {
                zhuanhuan = 10000;
            }
            for (int i = 0; i < s4; i++)
            {
                EconomyData ed = new EconomyData();
                ed.S1 = s1 + i;
                double tempdoub = Convert.ToDouble(row["y" + (s1 + i)].ToString());
                tempdoub = tempdoub * zhuanhuan;
                ed.S2    = Math.Round(tempdoub, 2);
                lis.Add(ed);
            }
            gridControl1.DataSource = lis;
            gridControl1.RefreshDataSource();
        }
Exemplo n.º 4
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            if (textEdit2.Text == "")
            {
                textEdit2.Text = "0";
            }

            if (textEdit1.Text == "")
            {
                textEdit1.Text = "0";
            }

            lis.Clear();
            double v2 = 1;
            double c2 = 0;

            for (int i = 0; i < s4; i++)
            {
                EconomyData ed = new EconomyData();
                ed.S1 = s1 + i;
                double tempdouble = Math.Pow(double.Parse(textEdit2.Text), i) * double.Parse(textEdit1.Text);
                ed.S2 = Math.Round(tempdouble, 2);
                lis.Add(ed);
            }
            gridControl1.DataSource = lis;
            gridControl1.RefreshDataSource();
        }
Exemplo n.º 5
0
    public void GetAllData()
    {
        //Store
        StoreName = StoreManager.StoreName;

        StoreColor = new ColorSave
        {
            R = StoreManager.StoreColor.r,
            G = StoreManager.StoreColor.g,
            B = StoreManager.StoreColor.b,
            A = StoreManager.StoreColor.a
        };

        Money      = StoreManager.Singleton.Money;
        DaysPlayed = StoreManager.Singleton.TotalDaysPlayed;
        Popularity = StoreManager.Singleton.StorePopularity;

        TimesBillsWerePaid = StoreManager.Singleton.TimesBillsWerePaid;

        Day    = StoreManager.Singleton.Day;
        Year   = StoreManager.Singleton.Year;
        Season = StoreManager.Singleton.CurrentSeason;

        StoreTimeHours   = StoreManager.Singleton.StoreTime.Hours;
        StoreTimeMinutes = StoreManager.Singleton.StoreTime.Minutes;

        InventoryItems.Clear();
        InventoryItems.AddRange(StoreManager.Singleton.Inventory.ToArray());

        //Store Objects
        StoreObjectSaves.Clear();
        foreach (var so in StoreObjectManager.Singleton.StoreObjects)
        {
            StoreObjectSave newSo = new StoreObjectSave();
            newSo.PositionX = so.transform.position.x;
            newSo.PositionY = so.transform.position.y;
            newSo.PositionZ = so.transform.position.z;

            newSo.RotationX = so.transform.rotation.eulerAngles.x;
            newSo.RotationY = so.transform.rotation.eulerAngles.y;
            newSo.RotationZ = so.transform.rotation.eulerAngles.z;

            newSo.NameOFloorTileParent = so.transform.parent.name;

            newSo.ContainedStockItem = so.GetComponent <ItemStockContainer>().InventoryItem;

            StoreObjectSaves.Add(newSo);
        }

        //Economy
        EconomyDataSave = new EconomyData(EconomyManager.Singleton.TopCategory, EconomyManager.Singleton.SecondCategory, EconomyManager.Singleton.ThirdCategory, EconomyManager.Singleton.DaysSinceLastChange, EconomyManager.Singleton.CurrentWeather);

        //Upgrades
        StoreUpgrades.Clear();
        foreach (var upgrade in StoreManager.Singleton.ActiveUpgrades)
        {
            StoreUpgrades.Add(upgrade);
        }
    }
        public void InMemoryDatabaseTests_GetEconomyDataForPlayer_NewPlayerNoMoney()
        {
            IDatabase database = new InMemoryDatabase();

            EconomyData data = database.GetEconomyDataForPlayer("mock1");

            Assert.AreEqual(0ul, data.Money);
        }
Exemplo n.º 7
0
    static void NewEconomyData()
    {
        EconomyData data = ScriptableObject.CreateInstance <EconomyData>();

        AssetDatabase.CreateAsset(data, "Assets/_EconomyData.asset");
        AssetDatabase.Refresh();
        AssetDatabase.SaveAssets();
    }
Exemplo n.º 8
0
        public void AddItemForPlayer(string id, Item item)
        {
            EconomyData data = GetEconomyDataForPlayer(id);

            lock (dataLock)
            {
                data.Items.Add(item);
            }
        }
Exemplo n.º 9
0
        public Item GetItemForPlayer(string id, uint index)
        {
            EconomyData data = GetEconomyDataForPlayer(id);

            if (index > data.Items.Count - 1)
            {
                return(null);
            }

            return(data.Items[(int)index]);
        }
Exemplo n.º 10
0
        public void GetMoneyEvent([FromSource] Player player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            EconomyData data = this.database.GetEconomyDataForPlayer(PlayerHandler.GetPlayerId(player));

            TriggerClientEvent(player, Events.GetMoneyEventClient, data.Money);
        }
Exemplo n.º 11
0
        public bool AddMoneyForPlayer(string id, ulong amount)
        {
            EconomyData data = GetEconomyDataForPlayer(id);

            lock (dataLock)
            {
                data.Money += amount;
            }

            return(true);
        }
Exemplo n.º 12
0
 private void simpleButton4_Click(object sender, EventArgs e)
 {
     li.Clear();
     for (int i = 0; i < s2; i++)
     {
         EconomyData ed = new EconomyData();
         ed.S1 = s1 + i;
         ed.S2 = GetNum(s1 + i);// 0;
         ed.S3 = 0;
         li.Add(ed);
         gridControl2.DataSource = li;
         gridControl2.RefreshDataSource();
     }
 }
        public void InMemoryDatabaseTests_GetEconomyDataForPlayer_Payday()
        {
            IDatabase database = new InMemoryDatabase();

            EconomyData data = database.GetEconomyDataForPlayer("mock1");

            Assert.AreEqual(0ul, data.Money);

            database.UpdateMoneyForAllPlayers(5);

            data = database.GetEconomyDataForPlayer("mock1");

            Assert.AreEqual(5ul, data.Money);
        }
Exemplo n.º 14
0
        public async Task Payday()
        {
            foreach (var player in this.Players)
            {
                string      id          = PlayerHandler.GetPlayerId(player);
                EconomyData economyData = this.database.GetEconomyDataForPlayer(id);
                Job         playerJob   = economyData.Job;
                UInt64      money       = playerJob.pay;
                this.database.AddMoneyForPlayer(id, money);

                PlayerHandler.Announce(player, $"You just got paid ${money}.");
            }

            await Delay(PayDayInterval);
        }
Exemplo n.º 15
0
        public bool DeductMoneyForPlayer(string id, UInt64 amount)
        {
            EconomyData data = GetEconomyDataForPlayer(id);

            if (data.Money < amount)
            {
                return(false);
            }

            lock (dataLock)
            {
                data.Money -= amount;
            }

            return(true);
        }
Exemplo n.º 16
0
        private void btnCancel_Click(object sender, EventArgs e)
        {
            int years  = economy.S20;
            int counts = economy.S21;

            if (edlist.Count > 0)
            {
                edlist.Clear();
            }
            for (int i = 0; i < counts; i++)
            {
                EconomyData ed = new EconomyData();
                ed.S1 = years + i;
                edlist.Add(ed);
            }
            vGridControl2.Refresh();
        }
Exemplo n.º 17
0
    public SettlementEconomy(SettlementShell shell, EconomyData data)
    {
        shell.Economy        = this;
        Inventory            = data.Inventory;
        UsePerTick           = data.UsePerTick;
        RawProductionPerTick = data.RawProductionPerTick;
        ProductionAbility    = data.ProductionAbility;
        DesiredItemStock     = data.DesiredItemStock;
        EconomicProduction   = data.EconomicProduction;

        RequiredImports = new Dictionary <EconomicItem, int>();
        // DesiredImports = new Dictionary<EconomicItem, int>();
        Surplus            = new Dictionary <EconomicItem, int>();
        SurlusByExportType = new Dictionary <EconomicItemType, Dictionary <EconomicItem, int> >();
        SurplusByTypeCount = new Dictionary <EconomicItemType, int>();

        CurrentActiveGroups = new List <EntityGroup>();
    }
Exemplo n.º 18
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (simpleButton2.Text == "下一步" && simpleButton1.Visible)
            {
                if (li.Count == 0)
                {
                    li.Clear();
                    for (int i = 0; i < s2; i++)
                    {
                        EconomyData ed = new EconomyData();
                        ed.S1 = s1 + i;
                        ed.S2 = 0;
                        ed.S3 = 0;
                        li.Add(ed);
                        gridControl2.DataSource = li;
                        gridControl2.RefreshDataSource();
                    }
                }
                else
                {
                    gridControl2.DataSource = li;
                    gridControl2.RefreshDataSource();
                }



                label22.Visible       = true;
                groupBox1.Visible     = true;
                groupBox2.Visible     = false;
                this.Text             = "参数设置-向导1";
                simpleButton2.Text    = "下一步";
                simpleButton1.Visible = false;
            }
            if (this.Text == "参数设置-向导3")
            {
                label30.Text       = "";
                groupBox1.Visible  = false;
                groupBox3.Visible  = true;
                groupBox2.Visible  = false;
                simpleButton2.Text = "下一步";
                this.Text          = "参数设置-向导2";
                //InitPicData();
            }
        }
Exemplo n.º 19
0
        private void HandleEconomyDataRequest(AgentCircuit circuit)
        {
            SceneInterface scene;
            ViewerAgent    agent;

            try
            {
                scene = circuit.Scene;
                if (scene == null)
                {
                    return;
                }
                agent = circuit.Agent;
            }
            catch
            {
                return;
            }
            var ei = scene.EconomyData;
            var ed = new EconomyData();

            if (ei != null)
            {
                ed.ObjectCapacity          = ei.ObjectCapacity;
                ed.ObjectCount             = ei.ObjectCount;
                ed.PriceEnergyUnit         = ei.PriceEnergyUnit;
                ed.PriceGroupCreate        = ei.PriceGroupCreate;
                ed.PriceObjectClaim        = ei.PriceObjectClaim;
                ed.PriceObjectRent         = ei.PriceObjectRent;
                ed.PriceObjectScaleFactor  = ei.PriceObjectScaleFactor;
                ed.PriceParcelClaim        = ei.PriceParcelClaim;
                ed.PriceParcelClaimFactor  = ei.PriceParcelClaimFactor;
                ed.PriceParcelRent         = ei.PriceParcelRent;
                ed.PricePublicObjectDecay  = ei.PricePublicObjectDecay;
                ed.PricePublicObjectDelete = ei.PricePublicObjectDelete;
                ed.PriceRentLight          = ei.PriceRentLight;
                ed.PriceUpload             = ei.PriceUpload;
                ed.TeleportMinPrice        = ei.TeleportMinPrice;
                ed.TeleportPriceExponent   = ei.TeleportPriceExponent;
            }
            agent.SendMessageAlways(ed, scene.ID);
        }
Exemplo n.º 20
0
        public EconomyData GetEconomyData()
        {
            EconomyData edata = new EconomyData();

            edata.ObjectCapacity          = ObjectCapacity;
            edata.ObjectCount             = ObjectCount;
            edata.PriceEnergyUnit         = PriceEnergyUnit;
            edata.PriceGroupCreate        = PriceGroupCreate;
            edata.PriceObjectClaim        = PriceObjectClaim;
            edata.PriceObjectRent         = PriceObjectRent;
            edata.PriceObjectScaleFactor  = PriceObjectScaleFactor;
            edata.PriceParcelClaim        = PriceParcelClaim;
            edata.PriceParcelClaimFactor  = PriceParcelClaimFactor;
            edata.PriceParcelRent         = PriceParcelRent;
            edata.PricePublicObjectDecay  = PricePublicObjectDecay;
            edata.PricePublicObjectDelete = PricePublicObjectDelete;
            edata.PriceRentLight          = PriceRentLight;
            edata.PriceUpload             = PriceUpload;
            edata.TeleportMinPrice        = TeleportMinPrice;
            return(edata);
        }
Exemplo n.º 21
0
        //private void Del_Tz(DataRow dt)
        //{
        //    if (checkBox1.Checked)
        //    {
        //        for (int i = 0; i < gridView2.RowCount; i++)
        //        {
        //            if (dt["y" + gridView2.GetRowCellDisplayText(i,"S1")] != null)
        //            {
        //                double tempdoub = Convert.ToDouble(gridView2.GetRowCellDisplayText(i, "S2"));
        //                tempdoub+=Convert.ToDouble(dt["y"+gridView2.GetRowCellDisplayText(i,"S1")].ToString());
        //                gridView2.SetRowCellValue(i, "S2",tempdoub);
        //            }
        //        }
        //    }
        //    else
        //    {
        //        for (int i = 0; i < gridView2.RowCount; i++)
        //        {
        //            //if (dt["y" + gridView2.GetRowCellDisplayText(i, "S1")] != null)
        //            {
        //                double tempdoub = Convert.ToDouble(dt["y" + gridView2.GetRowCellDisplayText(i, "S1")].ToString());
        //                gridView2.SetRowCellValue(i, "S2", tempdoub);
        //            }
        //        }
        //    }
        //}

        private void simpleButton4_Click(object sender, EventArgs e)
        {
            FormForecastData ffs = new FormForecastData();

            //  ffs.Type = type;

            ffs.StartYear = s1;
            ffs.EndYear   = s1 + s4;
            if (ffs.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            Hashtable hs = ffs.HS;

            lis.Clear();

            if (hs.Count == 0)
            {
                return;
            }
            foreach (Ps_Forecast_Math de3 in hs.Values)
            {
                int zhuanhuan = 1;
                if (de3.Title.IndexOf("亿") != -1)
                {
                    zhuanhuan = 10000;
                }
                for (int i = 0; i < s4; i++)
                {
                    EconomyData ed = new EconomyData();
                    ed.S1 = s1 + i;
                    double tempdoub = Convert.ToDouble(de3.GetType().GetProperty("y" + (s1 + i)).GetValue(de3, null).ToString());
                    tempdoub = tempdoub * zhuanhuan;
                    ed.S2    = Math.Round(tempdoub, 2);
                    lis.Add(ed);
                }
                gridControl1.DataSource = lis;
                gridControl1.RefreshDataSource();
            }
        }
Exemplo n.º 22
0
        public void BuyItemEvent(uint index, [FromSource] Player player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            string       id           = PlayerHandler.GetPlayerId(player);
            EconomyData  playerData   = this.database.GetEconomyDataForPlayer(id);
            StoreListing storeListing = this.database.GetStoreListingData();

            if (index >= storeListing.Items.Count())
            {
                ErrorHandler.PlayerError(player, $"There is no item in the store for slot {index}");
                return;
            }

            StoreItem storeItem = storeListing.Items.ElementAt((int)index);

            if (storeItem.Price > playerData.Money)
            {
                ErrorHandler.PlayerError(player, $"You cannot afford {storeItem.Item.DisplayName}");
                return;
            }

            // Deduct money
            bool success = this.database.DeductMoneyForPlayer(id, storeItem.Price);

            if (success == false)
            {
                ErrorHandler.PlayerError(player, $"Error with database transaction, please retry purchase.");
                return;
            }

            // Give item
            this.database.AddItemForPlayer(id, ItemCloningFactory.Clone(storeItem.Item, player));

            TriggerClientEvent(player, Events.BuyItemEventClient, true, storeItem.Item.DisplayName);
        }
Exemplo n.º 23
0
        public void ListItemsEvent([FromSource] Player player)
        {
            if (player == null)
            {
                throw new ArgumentNullException(nameof(player));
            }

            EconomyData data = this.database.GetEconomyDataForPlayer(PlayerHandler.GetPlayerId(player));

            StringBuilder items = new StringBuilder();

            for (int i = 0; i < data.Items.Count; ++i)
            {
                items.AppendFormat("[{0}]: {1}", i, data.Items[i].DisplayName);

                if (i < data.Items.Count - 1)
                {
                    items.Append(", ");
                }
            }

            TriggerClientEvent(player, Events.ListItemsEventClient, items.ToString());
        }
Exemplo n.º 24
0
        private void InitCompute()
        {
            if (!Check1())
                return;

            try
            {
                eds.Clear();
                for (int i = 0; i < nianshu; i++)
                {
                    EconomyData ed = new EconomyData();
                    try
                    {
                        ed.S1 = int.Parse(fpSpread1.Sheets[8].GetValue(15, 1 + i).ToString());
                    }
                    catch { ed.S1 = 0; }
                    try
                    {
                        ed.S2 = double.Parse(fpSpread1.Sheets[8].GetValue(16, 1 + i).ToString());
                    }

                    catch { ed.S2 = 0; }
                    eds.Add(ed);
                }

            }

            catch { }

            try
            {
            SetEx1();
            SetEx2();
            SetEx3();
            SetEx4();
            SetEx5();
            SetEx6();
            SetEx7();
            SetEx8();
            fpSpread1.ActiveSheetIndex = 0;

            xiangmunian1 = xiangmujisuannian;
            lixinian1 = lixinian;
            nianshu1 = nianshu;
            }

            catch { }
        }
Exemplo n.º 25
0
        private void EditData()
        {
            nianshu1 = int.Parse(fpSpread1.Sheets[8].GetValue(10, 3).ToString());
            FrmEconomyGuideSH feg = new FrmEconomyGuideSH();
            feg.ProjectID = ProjectUID;
            if (nianshu1 == 0)
            {
                feg.ObjectList = new List<EconomyData>();
            }
            else
            {
                IList<EconomyData> i1 = new List<EconomyData>();
                for (int q = 0; q < nianshu1; q++)
                {
                    EconomyData ed11 = new EconomyData();
                    try
                    {
                        ed11.S1 = (int)fpSpread1.Sheets[8].GetValue(15, 1 + q);
                    }
                    catch { }
                    try
                    {
                        ed11.S2 = Convert.ToDouble(fpSpread1.Sheets[8].GetValue(16, 1 + q).ToString());
                    }
                    catch { }

                    try
                    {
                        ed11.S3 = Convert.ToDouble(fpSpread1.Sheets[8].GetValue(17, 1 + q).ToString());
                    }
                    catch { }
                    i1.Add(ed11);

                }
                feg.ObjectList = i1;

            }

            if (xiangmunian1 == 0)
            {
                feg.ObjectList1 = new List<EconomyData>();
            }
            else
            {
                IList<EconomyData> i2 = new List<EconomyData>();
                for (int w = 0; w < xiangmunian1; w++)
                {
                    EconomyData ed22 = new EconomyData();
                    try
                    {
                        ed22.S1 = kaishinian + w;
                    }
                    catch { }
                    try
                    {
                        ed22.S2 = (double)fpSpread1.Sheets[3].GetValue(3, 2 + w);
                    }
                    catch { }
                    try
                    {
                        ed22.S3 = Convert.ToDouble(fpSpread1.Sheets[8].GetValue(18, 1 + w).ToString());
                    }
                    catch { }
                    i2.Add(ed22);

                }
                feg.ObjectList1 = i2;
            }

            try
            {
                feg.S1 = int.Parse(fpSpread1.Sheets[8].GetValue(9, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S2 = int.Parse(fpSpread1.Sheets[8].GetValue(10, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S3 = int.Parse(fpSpread1.Sheets[8].GetValue(2, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S4 = int.Parse(fpSpread1.Sheets[8].GetValue(13, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S5 = double.Parse(fpSpread1.Sheets[8].GetValue(3, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S6 = double.Parse(fpSpread1.Sheets[8].GetValue(12, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S7 = double.Parse(fpSpread1.Sheets[8].GetValue(8, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S8 = double.Parse(fpSpread1.Sheets[8].GetValue(4, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S9 = double.Parse(fpSpread1.Sheets[8].GetValue(8, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S10 = double.Parse(fpSpread1.Sheets[8].GetValue(9, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S11 = double.Parse(fpSpread1.Sheets[8].GetValue(10, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S12 = double.Parse(fpSpread1.Sheets[8].GetValue(14, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S13 = int.Parse(fpSpread1.Sheets[8].GetValue(14, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S14 = double.Parse(fpSpread1.Sheets[8].GetValue(5, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S15 = double.Parse(fpSpread1.Sheets[8].GetValue(6, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S16 = double.Parse(fpSpread1.Sheets[8].GetValue(7, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S17 = double.Parse(fpSpread1.Sheets[8].GetValue(11, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S18 = double.Parse(fpSpread1.Sheets[8].GetValue(12, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S19 = double.Parse(fpSpread1.Sheets[8].GetValue(13, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S20 = double.Parse(fpSpread1.Sheets[8].GetValue(2, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S21 = double.Parse(fpSpread1.Sheets[8].GetValue(3, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S22 = double.Parse(fpSpread1.Sheets[8].GetValue(4, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S23 = double.Parse(fpSpread1.Sheets[8].GetValue(5, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S24 = double.Parse(fpSpread1.Sheets[8].GetValue(6, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S25 = double.Parse(fpSpread1.Sheets[8].GetValue(7, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S26 = double.Parse(fpSpread1.Sheets[8].GetValue(11, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S31 = double.Parse(fpSpread1.Sheets[8].GetValue(19, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S32 = double.Parse(fpSpread1.Sheets[8].GetValue(20, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S33 = double.Parse(fpSpread1.Sheets[8].GetValue(21, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S34 = double.Parse(fpSpread1.Sheets[8].GetValue(22, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S35 = double.Parse(fpSpread1.Sheets[8].GetValue(19, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S36 = double.Parse(fpSpread1.Sheets[8].GetValue(20, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S37 = double.Parse(fpSpread1.Sheets[8].GetValue(21, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S38 = double.Parse(fpSpread1.Sheets[8].GetValue(22, 3).ToString());
            }
            catch
            { }

            try
            {
                feg.S39 = double.Parse(fpSpread1.Sheets[8].GetValue(23, 1).ToString());
            }
            catch
            { }

            try
            {
                feg.S40 = double.Parse(fpSpread1.Sheets[8].GetValue(23, 3).ToString());
            }
            catch
            { }

            fpSpread1.Sheets[7].Cells[14, 1].Text = "��������˰�Ӽ�(�����ڼ䣩";
            fpSpread1.Sheets[7].Cells[15, 1].Text = "��������˰�Ӽ�(������";

            try
            {
                fpSpread1.Sheets[7].Cells[16, 1].Text = "��λ���������ɱ����������ѣ�����˰��";
                fpSpread1.Sheets[7].Cells[17, 1].Text = "��λ���������ɱ����������ѣ���˰��";
                fpSpread1.Sheets[7].Cells[18, 1].Text = "��λ���������ɱ��������ѣ���˰��";
            }
            catch { }

            if (feg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream(bts);
                    fpSpread1.Open(ms);
                }
                catch{}

                fpSpread1.Sheets[8].SetValue(9, 3, feg.S1);
                fpSpread1.Sheets[8].SetValue(10, 3, feg.S2);
                fpSpread1.Sheets[8].SetValue(2, 1, feg.S3);
                fpSpread1.Sheets[8].SetValue(3, 1, feg.S5);
                fpSpread1.Sheets[8].SetValue(13, 3, feg.S4);
                fpSpread1.Sheets[8].SetValue(12, 3, feg.S6);
                fpSpread1.Sheets[8].SetValue(8, 3, feg.S7);
                fpSpread1.Sheets[8].SetValue(4, 1, feg.S8);
                fpSpread1.Sheets[8].SetValue(8, 1, feg.S9);
                fpSpread1.Sheets[8].SetValue(9, 1, feg.S10);
                fpSpread1.Sheets[8].SetValue(10, 1, feg.S11);
                fpSpread1.Sheets[8].SetValue(14, 3, feg.S12);
                fpSpread1.Sheets[8].SetValue(14, 1, feg.S13);
                fpSpread1.Sheets[8].SetValue(5, 1, feg.S14);
                fpSpread1.Sheets[8].SetValue(6, 1, feg.S15);
                fpSpread1.Sheets[8].SetValue(7, 1, feg.S16);
                fpSpread1.Sheets[8].SetValue(11, 1, feg.S17);
                fpSpread1.Sheets[8].SetValue(12, 1, feg.S18);
                fpSpread1.Sheets[8].SetValue(13, 1, feg.S19);
                fpSpread1.Sheets[8].SetValue(2, 3, feg.S20);
                fpSpread1.Sheets[8].SetValue(3, 3, feg.S21);
                fpSpread1.Sheets[8].SetValue(4, 3, feg.S22);
                fpSpread1.Sheets[8].SetValue(5, 3, feg.S23);
                fpSpread1.Sheets[8].SetValue(6, 3, feg.S24);
                fpSpread1.Sheets[8].SetValue(7, 3, feg.S25);
                fpSpread1.Sheets[8].SetValue(11, 3, feg.S26);

                try
                {
                    fpSpread1.Sheets[8].SetValue(19, 1, feg.S31);
                    fpSpread1.Sheets[8].SetValue(20, 1, feg.S32);
                    fpSpread1.Sheets[8].SetValue(21, 1, feg.S33);
                    fpSpread1.Sheets[8].SetValue(22, 1, feg.S34);
                    fpSpread1.Sheets[8].SetValue(19, 3, feg.S35);
                    fpSpread1.Sheets[8].SetValue(20, 3, feg.S36);
                    fpSpread1.Sheets[8].SetValue(21, 3, feg.S37);
                    fpSpread1.Sheets[8].SetValue(22, 3, feg.S38);
                    fpSpread1.Sheets[8].SetValue(23, 1, feg.S39);
                    fpSpread1.Sheets[8].SetValue(23, 3, feg.S40);
                }
                catch { }

                IList<EconomyData> li = new List<EconomyData>();
                li = feg.ObjectList;

                InitList(li);
                InitList1(feg.ObjectList1);
                InitCompute();

                InitCom1();
                InitCom2();

                InitList1(feg.ObjectList1);

                InitComputeFY();

            }
        }
Exemplo n.º 26
0
        private void InitComputeFY()
        {
            int y = int.Parse(fpSpread1.Sheets[8].GetValue(10, 3).ToString()); //����

            int gz = int.Parse(fpSpread1.Sheets[8].GetValue(20, 1).ToString()); //����
            int dy = int.Parse(fpSpread1.Sheets[8].GetValue(23, 1).ToString()); //��Ա

            double jycb = double.Parse(fpSpread1.Sheets[8].GetValue(8, 3).ToString()); //�ɱ�
            double cl = double.Parse(fpSpread1.Sheets[8].GetValue(22, 1).ToString());
            double wh = double.Parse(fpSpread1.Sheets[8].GetValue(19, 3).ToString());
            double bx = double.Parse(fpSpread1.Sheets[8].GetValue(20, 3).ToString());
            double qt = double.Parse(fpSpread1.Sheets[8].GetValue(21, 3).ToString());

            double xs = double.Parse(fpSpread1.Sheets[8].GetValue(19, 1).ToString());
            double gdj = double.Parse(fpSpread1.Sheets[8].GetValue(23, 3).ToString());

            double fl = double.Parse(fpSpread1.Sheets[8].GetValue(21, 1).ToString());

            double cbzh = 0;//�ɱ��ۺ�
            double dlcbzh = 0;//�����ɱ��ۺ�
            double ygcbzh = 0;//Ա���ɱ��ۺ�
            ygcbzh = gz * dy * (1 + fl);

            double lxsum=cl+wh+bx+qt;//���ñ����ܺ�

            double sds = 0;//����˰

            double ws = 0;//����

            ws = xs * gdj;

            double[,] d = new double[y, y];
            double[] e = new double[y];
            double[] f = new double[y];

            IList<EconomyData> i1 = new List<EconomyData>();
            double tzsum = 0;//��Ͷ��
            for (int q = 0; q < y; q++)
            {
                EconomyData ed11 = new EconomyData();
                try
                {
                    ed11.S1 = (int)fpSpread1.Sheets[8].GetValue(15, 1 + q);
                }
                catch { }
                try
                {
                    ed11.S2 = Convert.ToDouble(fpSpread1.Sheets[8].GetValue(16, 1 + q).ToString());
                }
                catch { }

                try
                {
                    ed11.S3 = Convert.ToDouble(fpSpread1.Sheets[8].GetValue(17, 1 + q).ToString());
                }
                catch { }
                tzsum += ed11.S2;
                i1.Add(ed11);
            }

            IList<EconomyData> i2 = new List<EconomyData>();
            double dlsum = 0;//�ܵ���
            for (int w = 0; w < y; w++)
            {
                EconomyData ed22 = new EconomyData();
                try
                {
                    ed22.S1 = kaishinian + w;
                }
                catch { }
                try
                {
                    ed22.S2 = (double)fpSpread1.Sheets[3].GetValue(3, 2 + w);
                }
                catch { }

                try
                {
                    ed22.S3 = Convert.ToDouble(fpSpread1.Sheets[8].GetValue(18, 1 + w).ToString());
                }
                catch { }

                dlsum += ed22.S3;
                i2.Add(ed22);
            }

            for (int i = 0; i < y; i++)
            {
                double d2 = i1[i].S2;
                for (int j = i; j < y; j++)
                {
                    if (i == j)
                    {
                        d[i, j] = d2 * lxsum;
                    }
                    else
                    {
                        d[i, j] = d2 * (lxsum+jycb);
                    }

                    dlcbzh += d[i, j];
                }
            }

            cbzh = dlcbzh + ygcbzh*y/10000;

            for (int i = 3; i < 3 + y - 1; i++)
            {
                double d1 = 0;
                if (fpSpread1.Sheets[6].Cells[6, i].Text != "")
                    d1 = double.Parse(fpSpread1.Sheets[6].Cells[6, i].Text);

                double d2 = 0;
                if (fpSpread1.Sheets[6].Cells[9, i].Text != "")
                    d2 = double.Parse(fpSpread1.Sheets[6].Cells[9, i].Text);

                double d3 = 0;
                if (fpSpread1.Sheets[6].Cells[9, i].Text != "")
                    d3 = double.Parse(fpSpread1.Sheets[6].Cells[10, i].Text);

                double d4 = 0;
                if (fpSpread1.Sheets[6].Cells[9, i].Text != "")
                    d4 = double.Parse(fpSpread1.Sheets[6].Cells[12, i].Text);

                sds += d1 + d2 + d3 + d4;
            }

            double m1 = 0;
            double m2 = 0;
            double m3 = 0;

            m1 = cbzh*1000 / dlsum ;
            m2 = (cbzh + sds) * 1000 / dlsum;
            m3 = m2 + ws;

            fpSpread1.Sheets[7].Cells[16, 3].Value = m1.ToString("n2");
            fpSpread1.Sheets[7].Cells[17, 3].Value = m2.ToString("n2");
            fpSpread1.Sheets[7].Cells[18, 3].Value = m3.ToString("n2");
        }
Exemplo n.º 27
0
        //private void Del_Tz(DataRow dt)
        //{
        //    if (checkBox1.Checked)
        //    {
        //        for (int i = 0; i < gridView2.RowCount; i++)
        //        {
        //            if (dt["y" + gridView2.GetRowCellDisplayText(i,"S1")] != null)
        //            {
        //                double tempdoub = Convert.ToDouble(gridView2.GetRowCellDisplayText(i, "S2"));
        //                tempdoub+=Convert.ToDouble(dt["y"+gridView2.GetRowCellDisplayText(i,"S1")].ToString());
        //                gridView2.SetRowCellValue(i, "S2",tempdoub);
        //            }
        //        }
        //    }
        //    else
        //    {
        //        for (int i = 0; i < gridView2.RowCount; i++)
        //        {
        //            //if (dt["y" + gridView2.GetRowCellDisplayText(i, "S1")] != null)
        //            {
        //                double tempdoub = Convert.ToDouble(dt["y" + gridView2.GetRowCellDisplayText(i, "S1")].ToString());
        //                gridView2.SetRowCellValue(i, "S2", tempdoub);
        //            }
        //        }
        //    }
        //}
        private void simpleButton4_Click(object sender, EventArgs e)
        {
            FormForecastData ffs = new FormForecastData();
            //  ffs.Type = type;

            ffs.StartYear = s1;
            ffs.EndYear = s1+s4;
            if (ffs.ShowDialog() != DialogResult.OK)
                return;
            Hashtable hs = ffs.HS;

            lis.Clear();

            if (hs.Count == 0)
                return;
            foreach (Ps_Forecast_Math de3 in hs.Values)
                {
                    int zhuanhuan = 1;
                    if (de3.Title.IndexOf("��")!=-1)
                    {
                        zhuanhuan = 10000;
                    }
                   for (int i = 0; i < s4; i++)
                        {
                            EconomyData ed = new EconomyData();
                            ed.S1 = s1 + i;
                            double tempdoub = Convert.ToDouble(de3.GetType().GetProperty("y" + (s1 + i)).GetValue(de3, null).ToString());
                            tempdoub = tempdoub * zhuanhuan;
                       ed.S2 = Math.Round(tempdoub, 2);
                            lis.Add(ed);

                         }
                        gridControl1.DataSource = lis;
                        gridControl1.RefreshDataSource();
             }
        }
Exemplo n.º 28
0
        private void simpleButton3_Click(object sender, EventArgs e)
        {
            if (textEdit2.Text == "")
                textEdit2.Text = "0";

            if (textEdit1.Text == "")
                textEdit1.Text = "0";

            lis.Clear();
            double v2 = 1;
            double c2 = 0;
            for (int i = 0; i < s4; i++)
            {
                EconomyData ed = new EconomyData();
                ed.S1 = s1 + i;
                double tempdouble = Math.Pow(double.Parse(textEdit2.Text), i) * double.Parse(textEdit1.Text);
                ed.S2 = Math.Round(tempdouble, 2);
                lis.Add(ed);

            }
             gridControl1.DataSource = lis;
             gridControl1.RefreshDataSource();
        }
Exemplo n.º 29
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {
            //��������-��1
            if (this.Text == "��������-��3")
            {
                foreach (EconomyData es1 in lis)
                {
                    if (es1.S2 == 0)
                    {
                        MsgBox.Show("�����۵���Ϊ0����ݣ����������룡");
                        return;
                    }
                }

                if (li.Count == 0)
                {
                    MessageBox.Show("Ͷ�ʽ��ûѡ��");
                    return;
                }

                if (lis.Count == 0)
                {
                    MessageBox.Show("�۵���û��ѡ��");
                    return;
                }

                DialogResult = DialogResult.OK;
            }

            if (simpleButton2.Text == "��һ��" && simpleButton1.Visible)
            {
                foreach (EconomyData es in li)
                {
                    if (es.S2 == 0)
                    {
                        MsgBox.Show("����Ͷ�ʽ��Ϊ0����ݣ����������룡");
                        return;
                    }
                }

                groupBox1.Visible = false;
                groupBox3.Visible = false;
                groupBox2.Visible = true;
                this.Text = "��������-��3";
                simpleButton2.Text = "���";

                if (lis.Count == 0)
                {
                    lis.Clear();
                    for (int i = 0; i < s4; i++)
                    {
                        EconomyData ed = new EconomyData();
                        ed.S1 = s1 + i;
                        ed.S2 = 0;
                        lis.Add(ed);
                        gridControl1.DataSource = lis;
                        gridControl1.RefreshDataSource();
                    }
                }
                else
                {
                    gridControl1.DataSource = lis;
                    gridControl1.RefreshDataSource();
                }

                label30.Text = "���ݻ�׼���۵������۵����������۵�����";
            }

            if (simpleButton2.Text == "��һ��" && !simpleButton1.Visible)
            {

                if (t1.Text == "" || t1.Text == "0")
                {
                    MsgBox.Show("��ʼ�������δ���룡");
                    return;
                }

                if (t2.Text == "" || t2.Text == "0")
                {
                    MsgBox.Show("��������δ���룡");
                    return;
                }

                if (t3.Text == "" || t3.Text == "0")
                {
                    MsgBox.Show("������δ���룡");
                    return;
                }

                if (t4.Text == "" || t4.Text == "0")
                {
                    MsgBox.Show("��Ŀ������δ���룡");
                    return;
                }

                if (int.Parse(t4.Text) > 50)
                {
                    MsgBox.Show("��Ŀ������̫�󣬲�Ҫ����50��");
                    return;

                }

                if (int.Parse(t2.Text) + int.Parse(t3.Text) > int.Parse(t4.Text))
                {
                    MsgBox.Show("��Ŀ������Ӧ�ô��ڵ��ڻ����ںͽ�������֮��");
                    return;

                }

                if (t13.Text == "" || t13.Text == "0")
                {
                    MsgBox.Show("����ϵ��δ���룡");
                    return;
                }

                label28.Text = "";
                groupBox1.Visible = false;
                groupBox2.Visible = false;
                groupBox3.Visible = true;
                this.Text = "��������-��2";

                try
                {
                    if (s1 != int.Parse(t1.Text))
                        isCompute = true;
                }
                catch { }

                try
                {

                    s1 = int.Parse(t1.Text);
                }
                catch { }

                try
                {
                    if (s2 != int.Parse(t2.Text))
                        isCompute = true;
                }
                catch { }

                try
                {
                    s2 = int.Parse(t2.Text);
                }
                catch { }

                try
                {
                    s3 = int.Parse(t3.Text);
                }
                catch { }

                try
                {
                    s4 = int.Parse(t4.Text);
                }
                catch { }

                try
                {
                    s5 = double.Parse(t5.Text);
                }
                catch { }

                //try
                //{
                //    s6 = double.Parse(t6.Text);
                //}
                //catch { }

                try
                {
                    s7 = double.Parse(t7.Text);
                }
                catch { }

                try
                {
                    s8 = double.Parse(t8.Text);
                }
                catch { }

                try
                {
                    s9 = double.Parse(t9.Text);
                }
                catch { }

                try
                {
                    s10 = double.Parse(t10.Text);
                }
                catch { }

                try
                {
                    s11 = double.Parse(t11.Text);
                }
                catch { }

                try
                {
                    s12 = double.Parse(t12.Text);
                }
                catch { }

                try
                {
                    s13 = int.Parse(t13.Text);
                }
                catch { }

                try
                {
                    s14 = double.Parse(t14.Text);
                }
                catch { }

                try
                {
                    s15 = double.Parse(t15.Text);
                }
                catch { }

                try
                {
                    s16 = double.Parse(t16.Text);
                }
                catch { }

                try
                {
                    s17 = double.Parse(t17.Text);
                }
                catch { }

                try
                {
                    s18 = double.Parse(t18.Text);
                }
                catch { }

                try
                {
                    s19 = double.Parse(t19.Text);
                }
                catch { }

                try
                {
                    s20 = double.Parse(t20.Text);
                }
                catch { }

                try
                {
                    s21 = double.Parse(t21.Text);
                }
                catch { }

                try
                {
                    s22 = double.Parse(t22.Text);
                }
                catch { }

                try
                {
                    s23 = double.Parse(t23.Text);
                }
                catch { }

                try
                {
                    s24 = double.Parse(t24.Text);
                }
                catch { }

                try
                {
                    s25 = double.Parse(t25.Text);
                }
                catch { }

                try
                {
                    s31 = double.Parse(textEdit3.Text);
                }
                catch { }

                try
                {
                    s32 = double.Parse(textEdit4.Text);
                }
                catch { }

                try
                {
                    s33 = double.Parse(textEdit5.Text);
                }
                catch { }

                try
                {
                    s34 = double.Parse(textEdit6.Text);
                }
                catch { }

                try
                {
                    s35 = double.Parse(textEdit7.Text);
                }
                catch { }

                try
                {
                    s36 = double.Parse(textEdit8.Text);
                }
                catch { }

                try
                {
                    s37 = double.Parse(textEdit9.Text);
                }
                catch { }

                try
                {
                    s38 = double.Parse(textEdit10.Text);
                }
                catch { }
                try
                {
                    s39 = double.Parse(textEdit11.Text);
                }
                catch { }

                try
                {
                    s40 = double.Parse(textEdit12.Text);
                }
                catch { }

                simpleButton1.Visible = true;

                if (li.Count == 0)
                {
                    li.Clear();
                    for (int i = 0; i < s2; i++)
                    {
                        EconomyData ed = new EconomyData();
                        ed.S1 = s1 + i;
                        ed.S2 = 0;
                        ed.S3 = 0;
                        li.Add(ed);
                        gridControl2.DataSource = li;
                        gridControl2.RefreshDataSource();
                    }
                }
                else
                {
                    gridControl2.DataSource = li;
                    gridControl2.RefreshDataSource();
                }

            }
        }
Exemplo n.º 30
0
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            if (simpleButton2.Text == "��һ��" && simpleButton1.Visible)
            {

                if (li.Count == 0)
                {
                    li.Clear();
                    for (int i = 0; i < s2; i++)
                    {
                        EconomyData ed = new EconomyData();
                        ed.S1 = s1 + i;
                        ed.S2 = 0;
                        ed.S3 = 0;
                        li.Add(ed);
                        gridControl2.DataSource = li;
                        gridControl2.RefreshDataSource();
                    }
                }
                else
                {
                    gridControl2.DataSource = li;
                    gridControl2.RefreshDataSource();
                }

                label22.Visible = true;
                groupBox1.Visible = true;
                groupBox2.Visible = false;
                this.Text = "��������-��1";
                simpleButton2.Text = "��һ��";
                simpleButton1.Visible = false;
            }
            if (this.Text == "��������-��3")
            {
                label30.Text = "";
                groupBox1.Visible = false;
                groupBox3.Visible = true;
                groupBox2.Visible = false;
                simpleButton2.Text = "��һ��";
                this.Text = "��������-��2";
                //InitPicData();
            }
        }
Exemplo n.º 31
0
        //�����������
        private void simpleButton5_Click(object sender, EventArgs e)
        {
            FormLoadForecastDataDSH frm = new FormLoadForecastDataDSH(2);
            frm.ProjectUID = MIS.ProgUID;
            if (frm.ShowDialog() != DialogResult.OK)
                return;
            DataRow row = frm.ROW;
            lis.Clear();
            int zhuanhuan = 1;
            if (row["Title"].ToString().IndexOf("��") != -1)
            {
                zhuanhuan = 10000;
            }
            for (int i = 0; i < s4; i++)
            {
                EconomyData ed = new EconomyData();
                ed.S1 = s1 + i;
                double tempdoub = Convert.ToDouble(row["y" + (s1 + i)].ToString());
                tempdoub = tempdoub * zhuanhuan;
                ed.S2 = Math.Round(tempdoub, 2);
                lis.Add(ed);

            }
            gridControl1.DataSource = lis;
            gridControl1.RefreshDataSource();
        }
Exemplo n.º 32
0
 private void simpleButton4_Click(object sender, EventArgs e)
 {
     li.Clear();
     for (int i = 0; i < s2; i++)
     {
         EconomyData ed = new EconomyData();
         ed.S1 = s1 + i;
         ed.S2 = GetNum(s1 + i);// 0;
         ed.S3 = 0;
         li.Add(ed);
         gridControl2.DataSource = li;
         gridControl2.RefreshDataSource();
     }
 }
Exemplo n.º 33
0
        private void simpleButton2_Click(object sender, EventArgs e)
        {//参数设置-向导1
            if (this.Text == "参数设置-向导3")
            {
                foreach (EconomyData es1 in lis)
                {
                    if (es1.S2 == 0)
                    {
                        MsgBox.Show("存在售电量为0的年份,请重新输入!");
                        return;
                    }
                }


                if (li.Count == 0)
                {
                    MessageBox.Show("投资金额没选择");
                    return;
                }

                if (lis.Count == 0)
                {
                    MessageBox.Show("售电量没有选择");
                    return;
                }

                DialogResult = DialogResult.OK;
            }

            if (simpleButton2.Text == "下一步" && simpleButton1.Visible)
            {
                foreach (EconomyData es in li)
                {
                    if (es.S2 == 0)
                    {
                        MsgBox.Show("存在投资金额为0的年份,请重新输入!");
                        return;
                    }
                }



                groupBox1.Visible  = false;
                groupBox3.Visible  = false;
                groupBox2.Visible  = true;
                this.Text          = "参数设置-向导3";
                simpleButton2.Text = "完成";

                if (lis.Count == 0)
                {
                    lis.Clear();
                    for (int i = 0; i < s4; i++)
                    {
                        EconomyData ed = new EconomyData();
                        ed.S1 = s1 + i;
                        ed.S2 = 0;
                        lis.Add(ed);
                        gridControl1.DataSource = lis;
                        gridControl1.RefreshDataSource();
                    }
                }
                else
                {
                    gridControl1.DataSource = lis;
                    gridControl1.RefreshDataSource();
                }

                label30.Text = "根据基准年售电量和售电率来计算售电量。";
            }

            if (simpleButton2.Text == "下一步" && !simpleButton1.Visible)
            {
                if (t1.Text == "" || t1.Text == "0")
                {
                    MsgBox.Show("开始建设年度未输入!");
                    return;
                }

                if (t2.Text == "" || t2.Text == "0")
                {
                    MsgBox.Show("建设年限未输入!");
                    return;
                }

                if (t3.Text == "" || t3.Text == "0")
                {
                    MsgBox.Show("还贷期未输入!");
                    return;
                }

                if (t4.Text == "" || t4.Text == "0")
                {
                    MsgBox.Show("项目计算期未输入!");
                    return;
                }


                if (int.Parse(t4.Text) > 50)
                {
                    MsgBox.Show("项目计算期太大,不要超过50年");
                    return;
                }

                if (int.Parse(t2.Text) + int.Parse(t3.Text) > int.Parse(t4.Text))
                {
                    MsgBox.Show("项目计算期应该大于等于还贷期和建设年限之和");
                    return;
                }



                if (t13.Text == "" || t13.Text == "0")
                {
                    MsgBox.Show("还贷系数未输入!");
                    return;
                }



                label28.Text      = "";
                groupBox1.Visible = false;
                groupBox2.Visible = false;
                groupBox3.Visible = true;
                this.Text         = "参数设置-向导2";



                try
                {
                    if (s1 != int.Parse(t1.Text))
                    {
                        isCompute = true;
                    }
                }
                catch { }



                try
                {
                    s1 = int.Parse(t1.Text);
                }
                catch { }


                try
                {
                    if (s2 != int.Parse(t2.Text))
                    {
                        isCompute = true;
                    }
                }
                catch { }

                try
                {
                    s2 = int.Parse(t2.Text);
                }
                catch { }

                try
                {
                    s3 = int.Parse(t3.Text);
                }
                catch { }

                try
                {
                    s4 = int.Parse(t4.Text);
                }
                catch { }

                try
                {
                    s5 = double.Parse(t5.Text);
                }
                catch { }

                //try
                //{
                //    s6 = double.Parse(t6.Text);
                //}
                //catch { }

                try
                {
                    s7 = double.Parse(t7.Text);
                }
                catch { }

                try
                {
                    s8 = double.Parse(t8.Text);
                }
                catch { }

                try
                {
                    s9 = double.Parse(t9.Text);
                }
                catch { }

                try
                {
                    s10 = double.Parse(t10.Text);
                }
                catch { }

                try
                {
                    s11 = double.Parse(t11.Text);
                }
                catch { }

                try
                {
                    s12 = double.Parse(t12.Text);
                }
                catch { }

                try
                {
                    s13 = int.Parse(t13.Text);
                }
                catch { }

                try
                {
                    s14 = double.Parse(t14.Text);
                }
                catch { }

                try
                {
                    s15 = double.Parse(t15.Text);
                }
                catch { }

                try
                {
                    s16 = double.Parse(t16.Text);
                }
                catch { }

                try
                {
                    s17 = double.Parse(t17.Text);
                }
                catch { }

                try
                {
                    s18 = double.Parse(t18.Text);
                }
                catch { }

                try
                {
                    s19 = double.Parse(t19.Text);
                }
                catch { }

                try
                {
                    s20 = double.Parse(t20.Text);
                }
                catch { }

                try
                {
                    s21 = double.Parse(t21.Text);
                }
                catch { }

                try
                {
                    s22 = double.Parse(t22.Text);
                }
                catch { }

                try
                {
                    s23 = double.Parse(t23.Text);
                }
                catch { }

                try
                {
                    s24 = double.Parse(t24.Text);
                }
                catch { }

                try
                {
                    s25 = double.Parse(t25.Text);
                }
                catch { }



                try
                {
                    s31 = double.Parse(textEdit3.Text);
                }
                catch { }

                try
                {
                    s32 = double.Parse(textEdit4.Text);
                }
                catch { }

                try
                {
                    s33 = double.Parse(textEdit5.Text);
                }
                catch { }

                try
                {
                    s34 = double.Parse(textEdit6.Text);
                }
                catch { }

                try
                {
                    s35 = double.Parse(textEdit7.Text);
                }
                catch { }

                try
                {
                    s36 = double.Parse(textEdit8.Text);
                }
                catch { }

                try
                {
                    s37 = double.Parse(textEdit9.Text);
                }
                catch { }

                try
                {
                    s38 = double.Parse(textEdit10.Text);
                }
                catch { }
                try
                {
                    s39 = double.Parse(textEdit11.Text);
                }
                catch { }


                try
                {
                    s40 = double.Parse(textEdit12.Text);
                }
                catch { }


                simpleButton1.Visible = true;


                if (li.Count == 0)
                {
                    li.Clear();
                    for (int i = 0; i < s2; i++)
                    {
                        EconomyData ed = new EconomyData();
                        ed.S1 = s1 + i;
                        ed.S2 = 0;
                        ed.S3 = 0;
                        li.Add(ed);
                        gridControl2.DataSource = li;
                        gridControl2.RefreshDataSource();
                    }
                }
                else
                {
                    gridControl2.DataSource = li;
                    gridControl2.RefreshDataSource();
                }
            }
        }
Exemplo n.º 34
0
    /// <summary>
    /// Calculates the economic item production per tick for this village based on the resources in the eclcosed chunks
    /// Adds building plans based on these production amounts
    /// Calculates the economic items used per tick
    /// Calculates the start inventory, and the desired amounts to keep in the inventory
    /// </summary>
    /// <param name="settlementResources"></param>
    /// <param name="shell"></param>
    private void GenerateVillageEconomy(Dictionary <ChunkResource, float> settlementResources, SettlementShell shell)
    {
        List <BuildingPlan> reqBuildings = new List <BuildingPlan>();

        //A measure of how much of each resource is produced per tick
        Dictionary <EconomicItem, int> producePerTick = new Dictionary <EconomicItem, int>();

        //How much of each item is used per tick
        Dictionary <EconomicItem, int> usePerTick = new Dictionary <EconomicItem, int>();

        EconomicInventory economicInventory = new EconomicInventory();
        Dictionary <EconomicItem, int> DesiredInventoryAmounts = new Dictionary <EconomicItem, int>();

        //Villages only take raw production (of farms and wood)

        if (settlementResources.TryGetValue(ChunkResource.wheatFarm, out float v) && v > 1)
        {
            reqBuildings.Add(Building.WHEATFARM);
            foreach (EconomicItem it in ChunkResource.wheatFarm.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v * 10);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.vegetableFarm, out float v0) && v0 > 1)
        {
            reqBuildings.Add(Building.VEGFARM);
            foreach (EconomicItem it in ChunkResource.vegetableFarm.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v * 10);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.silkFarm, out float v1) && v1 > 1)
        {
            reqBuildings.Add(Building.SILKFARM);
            foreach (EconomicItem it in ChunkResource.silkFarm.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v1 * 4);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.cattleFarm, out float v2) && v2 > 1)
        {
            reqBuildings.Add(Building.CATTLEFARM);
            foreach (EconomicItem it in ChunkResource.cattleFarm.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v2);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.sheepFarm, out float v3) && v3 > 1)
        {
            reqBuildings.Add(Building.SHEEPFARM);
            foreach (EconomicItem it in ChunkResource.sheepFarm.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v3);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.wood, out float v4) && v4 > 1)
        {
            reqBuildings.Add(Building.WOODCUTTER);
            foreach (EconomicItem it in ChunkResource.wood.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v4);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.ironOre, out float v5) && v5 > 1)
        {
            reqBuildings.Add(Building.IRONMINE);
            foreach (EconomicItem it in ChunkResource.ironOre.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v5);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.silverOre, out float v6) && v6 > 1)
        {
            reqBuildings.Add(Building.SILVERMINE);
            foreach (EconomicItem it in ChunkResource.silverOre.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v6);
            }
        }
        if (settlementResources.TryGetValue(ChunkResource.goldOre, out float v7) && v7 > 1)
        {
            reqBuildings.Add(Building.GOLDMINE);
            foreach (EconomicItem it in ChunkResource.goldOre.GetEconomicItem())
            {
                if (!producePerTick.ContainsKey(it))
                {
                    producePerTick.Add(it, 0);
                }
                producePerTick[it] += ((int)v7);
            }
        }
        usePerTick.Add(Economy.Bread, 5);
        usePerTick.Add(Economy.Vegetables, 5);
        usePerTick.Add(Economy.Clothes, 1);

        //Calculates the amount
        foreach (KeyValuePair <EconomicItem, int> kvp in usePerTick)
        {
            DesiredInventoryAmounts.Add(kvp.Key, kvp.Value * Economy.KEEP_IN_INVENTORY_MULT);
            economicInventory.AddItem(kvp.Key, DesiredInventoryAmounts[kvp.Key]);
        }
        shell.RequiredBuildings = reqBuildings;


        EconomyData data = new EconomyData();

        data.Inventory            = economicInventory;
        data.UsePerTick           = usePerTick;
        data.RawProductionPerTick = producePerTick;
        data.DesiredItemStock     = DesiredInventoryAmounts;
        data.EconomicProduction   = new Dictionary <EconomicProduction, int>();

        SettlementEconomy econ = new SettlementEconomy(shell, data);
    }
Exemplo n.º 35
0
        public static void PerformMainRoutine(string req)
        {
            // 0) Cleanup
            EconomyData?.Clean();
            ItemInfoData?.Clean();
            TierListFacade?.Clean();
            FilterAccessFacade?.Clean();

            BaseTypeDataProvider.Initialize();
            EconomyData        = EconomyRequestFacade.GetInstance();
            TierListFacade     = TierListFacade.GetInstance();
            FilterAccessFacade = FilterAccessFacade.GetInstance();
            ItemInfoData       = ItemInformationFacade.GetInstance();

            // 0) Get Current League information etc

            EconomyData.RequestPoeLeagueInfo();

            if (!EconomyData.IsLeagueActive())
            {
                LoggingFacade.LogWarning("No Active League detected!");
            }

            var requestedLeagueName = EconomyData.GetActiveLeagueName();

            // 1) Acquire Data

            var localMode = Environment.GetEnvironmentVariable("localMode", EnvironmentVariableTarget.Process) ?? "true";

            // string body = new StreamReader(req.Body).ReadToEnd();
            // var repoName = GetReqParams(req, data, "repoName", "NeverSink-EconomyUpdated-Filter");
            // var leagueType = GetReqParams(req, data.leagueType, "leagueType", "tmpstandard");

            dynamic data = JsonConvert.DeserializeObject(req);

            string leagueType = data.leagueType ?? "tmpstandard";
            string repoName   = data.repoName ?? "NeverSink-EconomyUpdated-Filter";

            string league = requestedLeagueName; //GetReqParams(req, data, "currentLeague", "Metamorph");

            LoggingFacade.LogInfo($"[CONFIG] leagueType: {leagueType}");
            LoggingFacade.LogInfo($"[CONFIG] league: {league}");
            LoggingFacade.LogInfo($"[CONFIG] repoName: {repoName}");
            LoggingFacade.LogInfo($"[CONFIG] localMode: {localMode}");

            FilterPolishConfig.ApplicationExecutionMode = ExecutionMode.Function;

            if (localMode == "true")
            {
                FilterPolishConfig.ActiveRequestMode = RequestType.Dynamic;
            }
            else
            {
                FilterPolishConfig.ActiveRequestMode = RequestType.ForceOnline;
            }

            DataFiles = new DataFileRequestFacade();
            LoggingFacade.LogInfo($"[CONFIG] FileRequestFacade Created!");

            FileRequestResult dataRes = DataFiles.GetAllFiles(league, leagueType);

            // 3) Parse filter
            FilterAccessFacade.PrimaryFilter = new Filter(DataFiles.SeedFilter);
            var newVersion = FilterAccessFacade.PrimaryFilter.GetHeaderMetaData("VERSION") + "." + DateTime.Now.Year + "." + DateTime.Now.DayOfYear + "." + DateTime.Now.Hour;

            FilterAccessFacade.PrimaryFilter.SetHeaderMetaData("VERSION", newVersion);

            LoggingFacade.LogInfo($"[CONFIG] version: {newVersion}");
            LoggingFacade.LogInfo($"[DEBUG] FileRequestResult: {dataRes.ToString()}");
            LoggingFacade.LogInfo($"[DEBUG] League Active: {EconomyData.IsLeagueActive().ToString()}");

            // null check the ecoData in case of disabled/early leagues
            if (dataRes == FileRequestResult.Success)
            {
                // 4) Load tier list information and enrichment procedures
                var tiers = FilterAccessFacade.PrimaryFilter.ExtractTiers(FilterPolishConfig.FilterTierLists);
                TierListFacade.TierListData = tiers;
                EconomyData.CreateSubEconomyTiers();

                ConcreteEnrichmentProcedures.Initialize();
                EconomyData.EnrichAll(EnrichmentProcedureConfiguration.PriorityEnrichmentProcedures);
                FilterPolishUtil.FilterPolishConfig.AdjustPricingInformation();
                EconomyData.EnrichAll(EnrichmentProcedureConfiguration.EnrichmentProcedures);

                // EconomyData.PerformClassAbstractionProcedures();

                TierListFacade.TierListData.Values.ToList().ForEach(x => x.ReEvaluate());

                // 5) Generate Suggestions
                var economyTieringSystem = new ConcreteEconomyRules();
                economyTieringSystem.GenerateSuggestions();

                // 6) Apply suggestions
                TierListFacade.ApplyAllSuggestions();
            }

            // 7) Generate changelogs
            // todo

            LoggingFacade.LogInfo($"[DEBUG] Seedfiler regeneration done. Starting publishing...");

            // 8) Generate and Upload Filters
            new FilterPublisher(FilterAccessFacade.PrimaryFilter, repoName, leagueType).Run(dataRes);
        }
Exemplo n.º 36
0
    private void GenerateTownEconomy(Dictionary <ChunkResource, float> settlementResources, SettlementShell shell)
    {
        List <BuildingPlan> reqBuildings = new List <BuildingPlan>();

        //A measure of how much of each resource is produced per tick
        Dictionary <EconomicItem, int> rawProductionPerTick = new Dictionary <EconomicItem, int>();
        //A measure of how much can be produced by industry
        Dictionary <EconomicProduction, int> productionPerTick = new Dictionary <EconomicProduction, int>();
        //How much of each item is used per tick (excluding economy)
        Dictionary <EconomicItem, int> usePerTick = new Dictionary <EconomicItem, int>();

        EconomicInventory economicInventory         = new EconomicInventory();
        Dictionary <EconomicItem, int> desiredStock = new Dictionary <EconomicItem, int>();

        usePerTick.Add(Economy.Bread, 15);
        usePerTick.Add(Economy.Vegetables, 10);
        usePerTick.Add(Economy.Clothes, 3);
        //Use a small amount of weapons and armour per tick
        usePerTick.Add(Economy.LeatherArmour, 1);
        usePerTick.Add(Economy.IronWeapons, 1);
        SettlementProductionAbility productionAbility = new SettlementProductionAbility();



        //All towns will have a bakery, this will produce bread from wheat
        reqBuildings.Add(Building.BAKERY);
        productionPerTick.Add(Economy.WheatToBread, 50);
        economicInventory.AddItem(Economy.Wheat, 500);
        productionAbility.HasButcher = true;
        productionPerTick.Add(Economy.CowToBeef, 5);
        productionPerTick.Add(Economy.SheepToMutton, 5);

        //If we are in a forrest, then the town till cut wood & make into planks
        if (settlementResources.TryGetValue(ChunkResource.wood, out float v) && v > 1)
        {
            reqBuildings.Add(Building.WOODCUTTER);
            reqBuildings.Add(Building.LUMBERMILL);
            int rawProduce = (int)v * 2;
            rawProductionPerTick.Add(ChunkResource.wood.GetEconomicItem()[0], rawProduce);
            //Takes 1 log and make 3 planks
            //We set the production such that it wished to import as much wood as possible
            productionPerTick.Add(Economy.WoodLogToPlank, (int)(rawProduce * GenRan.Random(2, 4)));
            productionAbility.HasLumberMill = true;
        }
        bool hasSmelt = false;

        if (settlementResources.TryGetValue(ChunkResource.ironOre, out float v1) && v1 > 1)
        {
            hasSmelt = true;
            reqBuildings.Add(Building.SMELTER);
            reqBuildings.Add(Building.BLACKSMITH);

            //We add some planks to start so we can produce weapons from start
            economicInventory.AddItem(Economy.WoodPlank, 5000);


            rawProductionPerTick.Add(Economy.IronOre, (int)v1);
            productionAbility.HasSmelter = true;

            productionPerTick.Add(Economy.Iron_OreToBar, (int)(v1 * GenRan.Random(2, 4)));
            productionPerTick.Add(Economy.IronToWeapon, 3);
            productionPerTick.Add(Economy.LeatherToArmour, 3);
        }
        if (settlementResources.TryGetValue(ChunkResource.silverOre, out float v2) && v2 > 1)
        {
            if (!hasSmelt)
            {
                reqBuildings.Add(Building.SMELTER);
            }
            rawProductionPerTick.Add(Economy.SilverOre, (int)v2);
            productionAbility.HasSmelter = true;

            productionPerTick.Add(Economy.Silver_OreToBar, (int)(v2 * GenRan.Random(2, 4)));
        }
        if (settlementResources.TryGetValue(ChunkResource.goldOre, out float v3) && v3 > 1)
        {
            if (!hasSmelt)
            {
                reqBuildings.Add(Building.SMELTER);
            }
            rawProductionPerTick.Add(Economy.GoldOre, (int)v3);
            productionAbility.HasSmelter = true;

            productionPerTick.Add(Economy.Gold_OreToBar, (int)(v3 * GenRan.Random(2, 4)));
        }
        //Calculates the amount
        foreach (KeyValuePair <EconomicItem, int> kvp in usePerTick)
        {
            int amount = kvp.Value * Economy.KEEP_IN_INVENTORY_MULT;
            desiredStock.Add(kvp.Key, amount);
            economicInventory.AddItem(kvp.Key, amount);
        }

        EconomyData data = new EconomyData();

        data.Inventory            = economicInventory;
        data.UsePerTick           = usePerTick;
        data.RawProductionPerTick = rawProductionPerTick;
        data.DesiredItemStock     = desiredStock;
        data.EconomicProduction   = new Dictionary <EconomicProduction, int>();
        data.ProductionAbility    = productionAbility;

        SettlementEconomy econ = new SettlementEconomy(shell, data);

        shell.RequiredBuildings = reqBuildings;

        //Set the economy
    }
Exemplo n.º 37
0
        public static void PerformMainRoutine()
        {
            // 0) Cleanup
            EconomyData?.Clean();
            ItemInfoData?.Clean();
            TierListFacade?.Clean();
            FilterAccessFacade?.Clean();

            EconomyData        = EconomyRequestFacade.GetInstance();
            TierListFacade     = TierListFacade.GetInstance();
            FilterAccessFacade = FilterAccessFacade.GetInstance();
            ItemInfoData       = ItemInformationFacade.GetInstance();

            // 0) Get Current League information etc
            // 1) Acquire Data
            var league    = Environment.GetEnvironmentVariable("ninjaLeague", EnvironmentVariableTarget.Process) ?? "tmpstandard";
            var localMode = Environment.GetEnvironmentVariable("localMode", EnvironmentVariableTarget.Process) ?? "true";

            if (localMode == "true")
            {
                FilterPolishConfig.ActiveRequestMode = RequestType.Dynamic;
            }
            else
            {
                FilterPolishConfig.ActiveRequestMode = RequestType.ForceOnline;
            }

            DataFiles = new DataFileRequestFacade();
            DataFiles.GetAllFiles(league);

            // 2) Test Data
            // todo

            // 3) Parse filter
            FilterAccessFacade.PrimaryFilter = new Filter(DataFiles.SeedFilter);

            // 4) Load ier list information and enrichment procedures
            var tiers = FilterAccessFacade.PrimaryFilter.ExtractTiers(FilterPolishConfig.FilterTierLists);

            TierListFacade.TierListData = tiers;
            CreateSubEconomyTiers();

            ConcreteEnrichmentProcedures.Initialize();
            EconomyData.EnrichAll(EnrichmentProcedureConfiguration.PriorityEnrichmentProcedures);
            FilterPolishUtil.FilterPolishConfig.AdjustPricingInformation();
            EconomyData.EnrichAll(EnrichmentProcedureConfiguration.EnrichmentProcedures);

            TierListFacade.TierListData.Values.ToList().ForEach(x => x.ReEvaluate());

            // 5) Generate Suggestions
            var economyTieringSystem = new ConcreteEconomyRules();

            economyTieringSystem.GenerateSuggestions();

            // 6) Apply suggestions
            TierListFacade.ApplyAllSuggestions();

            // 7) Generate changelogs
            // todo

            // 8) Generate and Upload Filters
            new FilterPublisher(FilterAccessFacade.PrimaryFilter).Run();
        }