示例#1
0
        public EditSimulationStore(SimulationStore simulation)
        {
            _simulationID      = simulation.SimulationID;
            _simulationName    = simulation.SimulationName;
            _numberAssets      = simulation.TotalAssets;
            _numberYears       = simulation.Years;
            _estimatedRunTime  = simulation.EstimatedRunTime;
            _assetType         = simulation.Asset;
            _scopeFilter       = simulation.Jurisdiction;
            _scopeName         = simulation.ScopeDescription;
            _startDate         = simulation.StartDate.ToShortDateString();
            _budgetName        = simulation.BudgetName;
            _yearBudgetAmounts = SelectScenario.GetBudgetsByYear(simulation.SimulationID);
            _assetTypeOID      = simulation.AssetTypeOID;
            _totalBudget       = 0;
            _budgetOrder       = simulation.BudgetOrder;
            _inflationRate     = simulation.InflationRate;

            foreach (YearBudgetAmountStore yba in _yearBudgetAmounts)
            {
                _totalBudget += (int)yba.Amount;
            }
            _activities = SelectScenario.GetActivities(simulation.SimulationID, false);
            _targets    = SelectScenario.GetEditSimulationTargets(simulation.SimulationID);

            //Analysis type is a combination of AnalysisType and Budget Contraint
            // Budget Target = As Budget Permits
            // OCI Target
            // Until OCI or Budget Met
            // Unlimited
            _optimizationType = simulation.BudgetConstraint;
        }
示例#2
0
        private static void CopyInvestments(string simulationID, string newSimulationID)
        {
            DateTime        dateStart  = DateTime.Now;
            InvestmentStore investment = SelectScenario.GetInvestment(simulationID);

            using (SqlConnection connection = new SqlConnection(DB.ConnectionString))
            {
                try
                {
                    connection.Open();
                    string insert = "INSERT INTO " + DB.TablePrefix + "INVESTMENTS (SIMULATIONID,FIRSTYEAR,NUMBERYEARS,INFLATIONRATE,DISCOUNTRATE,BUDGETORDER,SIMULATION_START_DATE) VALUES"
                                    + "('" + newSimulationID + "','" + investment.FirstYear.ToString() + "','" + investment.NumberYear + "','" + investment.InflationRate.ToString() + "','" + investment.DiscountRate.ToString() + "','" + investment.BudgetOrder + "','" + investment.StartDate + "')";
                    SqlCommand cmd = new SqlCommand(insert, connection);
                    cmd.ExecuteNonQuery();

                    List <YearBudgetAmountStore> yearBudgets = SelectScenario.GetBudgetsByYear(simulationID);

                    foreach (YearBudgetAmountStore yearBudget in yearBudgets)
                    {
                        insert = "INSERT INTO " + DB.TablePrefix + "YEARLYINVESTMENT (SIMULATIONID,YEAR_,BUDGETNAME,AMOUNT) VALUES ('" + newSimulationID + "','" + yearBudget.Year.ToString() + "','" + yearBudget.Budget + "','" + yearBudget.Amount + "')";
                        cmd    = new SqlCommand(insert, connection);
                        cmd.ExecuteNonQuery();
                    }
                }
                catch
                {
                }
            }
        }