Exemplo n.º 1
0
        public void WriteAggregateDamage(int RunId, int WeightingschemeId, double Damage, WeightingCombination[] WeightingCombinations)
        {
            if (!CalculateMeanForMonteCarlo && (RunId == -1))
            {
                return;
            }
            else if (!OutputAllMonteCarloRuns && (RunId > 0))
            {
                return;
            }

            if (m_AggregateDamageCsv != null)
            {
                int gas = (int)_gas;

                m_AggregateDamageCsv.WriteLine(
                    (OutputVerbal ? ScenarioName : ScenarioId.ToString()) +
                    ";" +
                    (OutputVerbal ? (gas == 0 ? "C" : gas == 1 ? "CH4" : gas == 2 ? "N2O" : gas == 3 ? "SF6" : "ERROR") : ((int)_gas).ToString()) +
                    ";" +
                    _emissionyear.ToString() +
                    ";" +
                    (OutputVerbal ? (RunId == 0 ? "Best guess" : RunId == -1 ? "Mean" : RunId.ToString()) : RunId.ToString()) +
                    ";" +
                    (OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString()) +
                    ";" +
                    Damage.ToString("f15")
                    );
            }
        }
 public void SetModel(ScenarioId scenario, int id, ScenarioPokemon model)
 {
     _model    = model;
     _scenario = scenario;
     _id       = id;
     RaiseAllPropertiesChanged();
 }
Exemplo n.º 3
0
        public void WriteMarginalDamage(int RunId, Damage i_Damage, int WeightingschemeId, double Weight, WeightingCombination[] WeightingCombinations)
        {
            if (m_YearRegionSectorWeightingSchemeCsv != null)
            {
                int gas = Convert.ToInt32(_gas);

                m_YearRegionSectorWeightingSchemeCsv.WriteLine(
                    (OutputVerbal ? ScenarioName : ScenarioId.ToString()) +
                    ";" +
                    (OutputVerbal ? (RunId == 0 ? "Best guess" : RunId == -1 ? "Mean" : RunId.ToString()) : RunId.ToString()) +
                    ";" +
                    (OutputVerbal ? (gas == 0 ? "C" : gas == 1 ? "CH4" : gas == 2 ? "N2O" : gas == 3 ? "SF6" : "ERROR") : ((int)_gas).ToString()) +
                    ";" +
                    _emissionyear.ToString() +
                    ";" +
                    (i_Damage.Year + 1950).ToString() +
                    ";" +
                    (OutputVerbal ? i_Damage.Region.ToString() : i_Damage.Region.ToString()) +
                    ";" +
                    (OutputVerbal ? Enum.GetName(typeof(Sector), i_Damage.Sector) : ((int)i_Damage.Sector).ToString()) +
                    ";" +
                    (OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString()) +
                    ";" +
                    (i_Damage.DamageValue * Weight).ToString("f15")
                    );
            }
        }
Exemplo n.º 4
0
 public static void Render(this IConsole console, ScenarioKingdom model, ScenarioId id)
 {
     console.WriteTitle($"{id} (Army Assignment)");
     foreach (var k in EnumUtil.GetValuesExceptDefaults <KingdomId>())
     {
         console.WriteProperty(k, model.GetArmy(k));
     }
 }
Exemplo n.º 5
0
 public static void Render(this IConsole console, ScenarioAppearPokemon model, ScenarioId id)
 {
     console.WriteTitle($"{id}");
     foreach (var pid in EnumUtil.GetValuesExceptDefaults <PokemonId>())
     {
         if (model.GetCanAppear(pid))
         {
             console.Output.WriteLine($"    {pid}");
         }
     }
 }
Exemplo n.º 6
0
        public void WriteSummaryDamage(int WeightingschemeId, double bgDamage, IEnumerable <double> damages, WeightingCombination[] WeightingCombinations)
        {
            if (SummaryCsv != null)
            {
                int gas = (int)_gas;

                var stats = new DescriptiveStatistics(damages);

                var sortedDamages = damages.OrderBy(i => i).ToArray();

                double count = sortedDamages.Length;

                int skiptake0_001 = (int)(count * 0.001 / 2.0);
                int skiptake0_01  = (int)(count * 0.01 / 2.0);
                int skiptake0_05  = (int)(count * 0.05 / 2.0);

                var trimmedMean0_001 = sortedDamages.Skip(skiptake0_001).Take(sortedDamages.Length - 2 * skiptake0_001).Mean();

                var trimmedMean0_01 = sortedDamages.Skip(skiptake0_01).Take(sortedDamages.Length - 2 * skiptake0_01).Mean();

                var trimmedMean0_05 = sortedDamages.Skip(skiptake0_05).Take(sortedDamages.Length - 2 * skiptake0_05).Mean();


                SummaryCsv.WriteLine("{0};{1};{2};{3};{4:f15};{5:f15};{6:f15};{7:f15};{8:f15};{9:f15};{10:f15};{11:f15};{12:f15};{13:f15};{14:f15};{15:f15};{16:f15}",
                                     OutputVerbal ? ScenarioName : ScenarioId.ToString(),
                                     OutputVerbal ? (gas == 0 ? "C" : gas == 1 ? "CH4" : gas == 2 ? "N2O" : gas == 3 ? "SF6" : "ERROR") : ((int)_gas).ToString(),
                                     _emissionyear,
                                     OutputVerbal ? WeightingCombinations[WeightingschemeId].Name : WeightingschemeId.ToString(),
                                     bgDamage,
                                     stats.Mean,
                                     trimmedMean0_001,
                                     trimmedMean0_01,
                                     trimmedMean0_05,
                                     stats.Median,
                                     stats.StandardDeviation,
                                     stats.Variance,
                                     stats.Skewness,
                                     stats.Kurtosis,
                                     stats.Minimum,
                                     stats.Maximum,
                                     Math.Sqrt(stats.Variance) / Math.Sqrt(stats.Count)
                                     );
            }
        }
Exemplo n.º 7
0
        public ClientVisitSaveDataModel(User user, ClientVisit clientVisit)
            : this(user)
        {
            VisitId                       = clientVisit.Id;
            ClientId                      = clientVisit.ClientId;
            VisitGroupId                  = clientVisit.VisitGroupId;
            SignatureFileName             = clientVisit.SignatureFileName ?? Guid.NewGuid().ToString();
            PhotoFileName                 = clientVisit.PhotoFileName ?? Guid.NewGuid().ToString();
            DeliveryCenterId              = clientVisit.DeliveryCenter.Id;
            ScenarioId                    = clientVisit.Scenario != null ? clientVisit.Scenario.Id : new long?();
            TemporaryPolicyDate           = clientVisit.TemporaryPolicyDate;
            TemporaryPolicyNumber         = clientVisit.TemporaryPolicyNumber;
            TemporaryPolicyExpirationDate = clientVisit.TemporaryPolicyExpirationDate;
            StatusId                      = clientVisit.Status.Id;
            StatusDate                    = clientVisit.StatusDate;
            StatusEnabled                 = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG);
            DisableAll                    = clientVisit.Status.Id == ClientVisitStatuses.AnswerPending.Id &&
                                            !(user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG));
            OldClientInfo           = new ClientVersionEditModel(clientVisit.OldClientInfo, EntityType.Old);
            NewClientInfo           = new ClientVersionEditModel(clientVisit.NewClientInfo, EntityType.New);
            OldDocument             = new DocumentModel(clientVisit.OldDocument, DocumentType.Old);
            NewDocument             = new DocumentModel(clientVisit.NewDocument, DocumentType.New);
            NewForeignDocument      = new DocumentModel(clientVisit.NewForeignDocument, DocumentType.NewForeign);
            OldForeignDocument      = new DocumentModel(clientVisit.OldForeignDocument, DocumentType.OldForeign);
            LivingAddress           = new AddressModel(clientVisit.LivingAddress, AddressType.Living);
            RegistrationAddress     = new AddressModel(clientVisit.RegistrationAddress, AddressType.Registration);
            RegistrationAddressDate = clientVisit.RegistrationAddressDate;
            OldPolicy                 = new PolicyInfoClientVisitSaveModel(clientVisit.OldPolicy, EntityType.Old);
            NewPolicy                 = new PolicyInfoClientVisitSaveModel(clientVisit.NewPolicy, EntityType.New);
            Registrator               = new UserModel(clientVisit.Registrator);
            Representative            = new RepresentativeEditModel(clientVisit.Representative);
            CarrierId                 = clientVisit.CarrierId;
            ApplicationMethodId       = clientVisit.ApplicationMethodId;
            Comment                   = clientVisit.Comment;
            GOZNAKDate                = clientVisit.GOZNAKDate;
            GOZNAKTypeId              = clientVisit.GOZNAKType != null ? clientVisit.GOZNAKType.Id : default(long?);
            ClientCategoryId          = clientVisit.ClientCategoryId == 0 ? new long() : clientVisit.ClientCategoryId;
            DeliveryPointId           = clientVisit.DeliveryPointId == 0 ? new long() : clientVisit.DeliveryPointId;
            ClientAcquisitionEmployee = clientVisit.ClientAcquisitionEmployee;
            ClientContacts            = clientVisit.ClientContacts;
            Phone          = clientVisit.Phone;
            Email          = clientVisit.Email;
            IssueDate      = clientVisit.IssueDate;
            UralsibCard    = clientVisit.UralsibCard;
            IsActual       = clientVisit.IsActual;
            Scenaries      = ReferencesProvider.GetReferences(Constants.ScenarioRef, user.Roles, DateTime.Now, null, true);
            DeliveryPoints = ReferencesProvider.GetReferences(Constants.DeliveryPointRef, user.Roles, DateTime.Now, null, true);
            ListClientAcquisitionEmployee = ReferencesProvider.GetListClientAcquisitionEmployee(null, true);
            PolicyBlanc = clientVisit.PolicyBlanc;

            if (ScenarioId != 0 && !Scenaries.Exists(item => item.Value == ScenarioId.ToString()))
            {
                Scenaries.Add(ReferencesProvider.GetReferences(Constants.ScenarioRef).FirstOrDefault(item => item.Value == ScenarioId.ToString()));
            }
            if (DeliveryPointId.HasValue && !DeliveryPoints.Exists(item => item.Value == DeliveryPointId.Value.ToString()))
            {
                DeliveryPoints.Add(ReferencesProvider.GetReferences(Constants.DeliveryPointRef).FirstOrDefault(item => item.Value == DeliveryPointId.Value.ToString()));
            }
            if (ClientCategoryId.HasValue && !UralsibClientCategories.Exists(item => item.Value == ClientCategoryId.Value.ToString()))
            {
                UralsibClientCategories.Add(ReferencesProvider.GetReferences(Constants.UralsibClientCategoryRef).FirstOrDefault(item => item.Value == ClientCategoryId.Value.ToString()));
            }
            IssueDateEnabled = (user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG)) ||
                               (StatusId == ClientVisitStatuses.PolicyReadyForClient.Id && user.Roles.Contains(Role.Registrator));
            IsReadyToFundSubmitRequestEnabled = user.Roles.Contains(Role.Administrator) || user.Roles.Contains(Role.OperatorSG);
            PolicyPartyNumber           = clientVisit.PolicyPartyNumber;
            FundResponseApplyingMessage = clientVisit.FundResponseApplyingMessage;
            IsReadyToFundSubmitRequest  = clientVisit.IsReadyToFundSubmitRequest;
            CreateDate       = clientVisit.CreateDate;
            UpdateDate       = clientVisit.UpdateDate;
            IsDifficultCase  = clientVisit.IsDifficultCase;
            AttachmentDate   = clientVisit.AttachmentDate;
            AttachmentTypeId = clientVisit.AttachmentType != null ? clientVisit.AttachmentType.Id : new long?();
            MedicalCentreId  = clientVisit.MedicalCentre != null ? clientVisit.MedicalCentre.Id : new long?();
        }
        public void savevalues()
        {
            int    x;
            string strSpcGrp     = "";
            string strDbhGrp     = "";
            string strMerchValue = "";
            string strChipValue  = "";
            string strWoodBin    = "";
            string strSql        = "";

            SQLite.ADO.DataMgr oDataMgr = null;
            if (!ReferenceProcessorScenarioForm.m_bUsingSqlite)
            {
                //
                //DELETE THE CURRENT SCENARIO RECORDS
                //
                m_oAdo.m_strSQL = "DELETE FROM scenario_tree_species_diam_dollar_values " +
                                  "WHERE TRIM(scenario_id)='" + this.ScenarioId.Trim() + "'";
                m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                //
                //DELETE THE WORK TABLE
                //
                if (m_oAdo.TableExist(m_oAdo.m_OleDbConnection, "spcgrp_dbhgrp"))
                {
                    m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, "DROP TABLE spcgrp_dbhgrp");
                }
                //
                //CREATE AND POPULATE WORK TABLE
                //
                m_oAdo.m_strSQL = "CREATE TABLE spcgrp_dbhgrp (" +
                                  "species_group INTEGER," +
                                  "species_label CHAR(50)," +
                                  "diam_group INTEGER," +
                                  "diam_class CHAR(15))";
                m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);

                foreach (ProcessorScenarioItem.SpcGroupItem objSpcGroup in ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oSpcGroupItem_Collection)
                {
                    foreach (ProcessorScenarioItem.TreeDiamGroupsItem objDiamGroup in ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oTreeDiamGroupsItem_Collection)
                    {
                        // INITIALIZE RECORDS IN WORK TABLE
                        m_oAdo.m_strSQL = "INSERT INTO spcgrp_dbhgrp (species_group,species_label, diam_group, diam_class) " +
                                          "VALUES (" + objSpcGroup.SpeciesGroup + ",'" + objSpcGroup.SpeciesGroupLabel + "'," +
                                          objDiamGroup.DiamGroup + ",'" + objDiamGroup.DiamClass + "')";
                        m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                        //
                        //INSERT SCENARIO RECORDS
                        //
                        m_oAdo.m_strSQL = "INSERT INTO scenario_tree_species_diam_dollar_values (scenario_id,species_group,diam_group) " +
                                          "VALUES ('" + ScenarioId.Trim() + "'," + objSpcGroup.SpeciesGroup + "," +
                                          objDiamGroup.DiamGroup + ")";
                        m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                    }
                }
            }
            else
            {
                oDataMgr = new SQLite.ADO.DataMgr();
                string strScenarioDB =
                    frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() +
                    "\\processor\\" + Tables.ProcessorScenarioRuleDefinitions.DefaultSqliteDbFile;
                oDataMgr.OpenConnection(oDataMgr.GetConnectionString(strScenarioDB));
                if (oDataMgr.m_intError != 0)
                {
                    m_intError = oDataMgr.m_intError;
                    m_strError = oDataMgr.m_strError;
                    oDataMgr   = null;
                    return;
                }
                m_intError = 0;
                m_strError = "";
                //
                //DELETE THE CURRENT SCENARIO RECORDS
                //
                oDataMgr.m_strSQL = "DELETE FROM scenario_tree_species_diam_dollar_values " +
                                    "WHERE TRIM(scenario_id)='" + this.ScenarioId.Trim() + "'";
                oDataMgr.SqlNonQuery(oDataMgr.m_Connection, oDataMgr.m_strSQL);
                //
                //DELETE THE WORK TABLE
                //
                if (oDataMgr.TableExist(oDataMgr.m_Connection, "spcgrp_dbhgrp"))
                {
                    oDataMgr.SqlNonQuery(oDataMgr.m_Connection, "DROP TABLE spcgrp_dbhgrp");
                }
                //
                //CREATE AND POPULATE WORK TABLE
                //
                oDataMgr.m_strSQL = "CREATE TABLE spcgrp_dbhgrp (" +
                                    "species_group INTEGER," +
                                    "species_label TEXT," +
                                    "diam_group INTEGER," +
                                    "diam_class TEXT)";
                oDataMgr.SqlNonQuery(oDataMgr.m_Connection, oDataMgr.m_strSQL);

                foreach (ProcessorScenarioItem.SpcGroupItem objSpcGroup in ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oSpcGroupItem_Collection)
                {
                    foreach (ProcessorScenarioItem.TreeDiamGroupsItem objDiamGroup in ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oTreeDiamGroupsItem_Collection)
                    {
                        // INITIALIZE RECORDS IN WORK TABLE
                        oDataMgr.m_strSQL = "INSERT INTO spcgrp_dbhgrp (species_group,species_label, diam_group, diam_class) " +
                                            "VALUES (" + objSpcGroup.SpeciesGroup + ",'" + objSpcGroup.SpeciesGroupLabel + "'," +
                                            objDiamGroup.DiamGroup + ",'" + objDiamGroup.DiamClass + "')";
                        oDataMgr.SqlNonQuery(oDataMgr.m_Connection, oDataMgr.m_strSQL);
                        //
                        //INSERT SCENARIO RECORDS
                        //
                        oDataMgr.m_strSQL = "INSERT INTO scenario_tree_species_diam_dollar_values (scenario_id,species_group,diam_group) " +
                                            "VALUES ('" + ScenarioId.Trim() + "'," + objSpcGroup.SpeciesGroup + "," +
                                            objDiamGroup.DiamGroup + ")";
                        oDataMgr.SqlNonQuery(oDataMgr.m_Connection, oDataMgr.m_strSQL);
                    }
                }
            }


            //
            //UPDATE SCENARIO RECORDS WITH MERCH AND CHIP VALUES
            //
            for (x = 0; x <= this.uc_processor_scenario_spc_dbh_group_value_collection1.Count - 1; x++)
            {
                strSpcGrp     = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).SpeciesGroup.Trim();
                strDbhGrp     = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).DbhGroup.Trim();
                strWoodBin    = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).GetWoodBin();
                strMerchValue = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).CubicFootDollarValue.Trim();
                strMerchValue = strMerchValue.Replace("$", "");
                strChipValue  = this.txtChipValue.Text.Trim();
                strChipValue  = strChipValue.Replace("$", "");

                if (!ReferenceProcessorScenarioForm.m_bUsingSqlite)
                {
                    strSql = "UPDATE scenario_tree_species_diam_dollar_values a " +
                             "INNER JOIN spcgrp_dbhgrp b " +
                             "ON  a.species_group=b.species_group AND " +
                             "a.diam_group=b.diam_group " +
                             "SET a.merch_value=" + strMerchValue + "," +
                             "a.chip_value=" + strChipValue + ", " +
                             "a.wood_bin='" + strWoodBin.Trim() + "' " +
                             "WHERE TRIM(a.scenario_id)='" + ScenarioId.Trim() + "' AND " +
                             "TRIM(b.species_label)='" + strSpcGrp + "' AND " +
                             "TRIM(b.diam_class)='" + strDbhGrp + "'";
                    m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, strSql);
                }
                else
                {
                    strSql = "UPDATE scenario_tree_species_diam_dollar_values " +
                             "SET merch_value = " + strMerchValue + "," +
                             "chip_value = " + strChipValue + "," +
                             "wood_bin = '" + strWoodBin.Trim() + "' WHERE EXISTS (" +
                             "SELECT * FROM spcgrp_dbhgrp " +
                             "WHERE scenario_tree_species_diam_dollar_values.species_group = spcgrp_dbhgrp.species_group " +
                             "AND scenario_tree_species_diam_dollar_values.diam_group = spcgrp_dbhgrp.diam_group " +
                             "AND TRIM(scenario_tree_species_diam_dollar_values.scenario_id) = '" + ScenarioId.Trim() + "' " +
                             "AND TRIM(spcgrp_dbhgrp.species_label) = '" + strSpcGrp + "' " +
                             "AND TRIM(spcgrp_dbhgrp.diam_class) = '" + strDbhGrp + "')";

                    oDataMgr.SqlNonQuery(oDataMgr.m_Connection, strSql);
                }

                uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).SaveValues();
            }
            this.m_strChipValueSave = this.txtChipValue.Text;
            if (ReferenceProcessorScenarioForm.m_bUsingSqlite)
            {
                //
                //DELETE THE WORK TABLE AND CLOSE CONNECTION
                //
                if (oDataMgr.TableExist(oDataMgr.m_Connection, "spcgrp_dbhgrp"))
                {
                    oDataMgr.SqlNonQuery(oDataMgr.m_Connection, "DROP TABLE spcgrp_dbhgrp");
                }
                m_intError = oDataMgr.m_intError;

                oDataMgr.CloseConnection(oDataMgr.m_Connection);
                oDataMgr = null;
            }
        }
Exemplo n.º 9
0
 public override int GetHashCode()
 {
     return(ScenarioId != null ? ScenarioId.GetHashCode() : 0);
 }
Exemplo n.º 10
0
 protected bool Equals(MatchResult other)
 {
     return(ScenarioId.Equals(other.ScenarioId));
 }
        public void savevalues()
        {
            int    x;
            string strSpcGrp     = "";
            string strDbhGrp     = "";
            string strMerchValue = "";
            string strChipValue  = "";
            string strWoodBin    = "";
            string strFields     = "scenario_id,species_group,diam_group,wood_bin,merch_value,chip_value";
            string strValues     = "";

            //
            //DELETE THE CURRENT SCENARIO RECORDS
            //
            m_oAdo.m_strSQL = "DELETE FROM scenario_tree_species_diam_dollar_values " +
                              "WHERE TRIM(scenario_id)='" + this.ScenarioId.Trim() + "'";
            m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
            //
            //DELETE THE WORK TABLE
            //
            if (m_oAdo.TableExist(m_oAdo.m_OleDbConnection, "spcgrp_dbhgrp"))
            {
                m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, "DROP TABLE spcgrp_dbhgrp");
            }
            //
            //CREATE AND POPULATE WORK TABLE
            //
            m_oAdo.m_strSQL = "CREATE TABLE spcgrp_dbhgrp (" +
                              "species_group INTEGER," +
                              "species_label CHAR(50)," +
                              "diam_group INTEGER," +
                              "diam_class CHAR(15))";
            m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);

            foreach (ProcessorScenarioItem.SpcGroupItem objSpcGroup in ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oSpcGroupItem_Collection)
            {
                foreach (ProcessorScenarioItem.TreeDiamGroupsItem objDiamGroup in ReferenceProcessorScenarioForm.m_oProcessorScenarioItem.m_oTreeDiamGroupsItem_Collection)
                {
                    // INITIALIZE RECORDS IN WORK TABLE
                    m_oAdo.m_strSQL = "INSERT INTO spcgrp_dbhgrp (species_group,species_label, diam_group, diam_class) " +
                                      "VALUES (" + objSpcGroup.SpeciesGroup + ",'" + objSpcGroup.SpeciesGroupLabel + "'," +
                                      objDiamGroup.DiamGroup + ",'" + objDiamGroup.DiamClass + "')";
                    m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                    //
                    //INSERT SCENARIO RECORDS
                    //
                    m_oAdo.m_strSQL = "INSERT INTO scenario_tree_species_diam_dollar_values (scenario_id,species_group,diam_group) " +
                                      "VALUES ('" + ScenarioId.Trim() + "'," + objSpcGroup.SpeciesGroup + "," +
                                      objDiamGroup.DiamGroup + ")";
                    m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                }
            }

            //
            //UPDATE SCENARIO RECORDS WITH MERCH AND CHIP VALUES
            //
            for (x = 0; x <= this.uc_processor_scenario_spc_dbh_group_value_collection1.Count - 1; x++)
            {
                strValues     = "";
                strSpcGrp     = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).SpeciesGroup.Trim();
                strDbhGrp     = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).DbhGroup.Trim();
                strWoodBin    = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).GetWoodBin();
                strMerchValue = uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).CubicFootDollarValue.Trim();
                strMerchValue = strMerchValue.Replace("$", "");
                strChipValue  = this.txtChipValue.Text.Trim();
                strChipValue  = strChipValue.Replace("$", "");

                m_oAdo.m_strSQL = "UPDATE scenario_tree_species_diam_dollar_values a " +
                                  "INNER JOIN spcgrp_dbhgrp b " +
                                  "ON  a.species_group=b.species_group AND " +
                                  "a.diam_group=b.diam_group " +
                                  "SET a.merch_value=" + strMerchValue + "," +
                                  "a.chip_value=" + strChipValue + ", " +
                                  "a.wood_bin='" + strWoodBin.Trim() + "' " +
                                  "WHERE TRIM(a.scenario_id)='" + ScenarioId.Trim() + "' AND " +
                                  "TRIM(b.species_label)='" + strSpcGrp + "' AND " +
                                  "TRIM(b.diam_class)='" + strDbhGrp + "'";


                m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                uc_processor_scenario_spc_dbh_group_value_collection1.Item(x).SaveValues();
            }
            this.m_strChipValueSave = this.txtChipValue.Text;
        }
        public void savevalues()
        {
            m_intError = 0;
            m_strError = "";

            int    x;
            string strValues = "";
            string strFields = "scenario_id," +
                               "EscalatorOperatingCosts_Cycle2," +
                               "EscalatorOperatingCosts_Cycle3," +
                               "EscalatorOperatingCosts_Cycle4," +
                               "EscalatorMerchWoodRevenue_Cycle2," +
                               "EscalatorMerchWoodRevenue_Cycle3," +
                               "EscalatorMerchWoodRevenue_Cycle4," +
                               "EscalatorEnergyWoodRevenue_Cycle2," +
                               "EscalatorEnergyWoodRevenue_Cycle3," +
                               "EscalatorEnergyWoodRevenue_Cycle4";


            try
            {
                //
                //DELETE THE CURRENT SCENARIO RECORDS
                //
                m_oAdo.m_strSQL = "DELETE FROM scenario_cost_revenue_escalators " +
                                  "WHERE TRIM(scenario_id)='" + this.ScenarioId.Trim() + "'";
                m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                //
                //scenario id
                //
                strValues = "'" + ScenarioId.Trim() + "',";
                //
                //Operating Cost Cycle1
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value1.Cycle1.Trim() + ",";
                //
                //Operating Cost Cycle2
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value1.Cycle2.Trim() + ",";
                //
                //Operating Cost Cycle3
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value1.Cycle3.Trim() + ",";
                //
                //Merch Wood Revenue Cycle1
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value2.Cycle1.Trim() + ",";
                //
                //Merch Wood Revenue Cycle2
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value2.Cycle2.Trim() + ",";
                //
                //Merch Wood Revenue Cycle3
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value2.Cycle3.Trim() + ",";
                //
                //Energy Wood Revenue Cycle1
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value3.Cycle1.Trim() + ",";
                //
                //Energy Wood Revenue Cycle2
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value3.Cycle2.Trim() + ",";
                //
                //Energy Wood Revenue Cycle3
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value3.Cycle3.Trim();

                m_oAdo.m_strSQL = Queries.GetInsertSQL(strFields, strValues, "scenario_cost_revenue_escalators");
                m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);

                this.uc_processor_scenario_escalators_value1.SaveValues();
                this.uc_processor_scenario_escalators_value2.SaveValues();
                this.uc_processor_scenario_escalators_value3.SaveValues();
            }
            catch (Exception e)
            {
                m_intError = -1;
                m_strError = e.Message;
            }
        }
Exemplo n.º 13
0
        public void savevalues()
        {
            m_intError = 0;
            m_strError = "";

            string strValues = "";
            string strFields = "scenario_id," +
                               "EscalatorOperatingCosts_Cycle2," +
                               "EscalatorOperatingCosts_Cycle3," +
                               "EscalatorOperatingCosts_Cycle4," +
                               "EscalatorMerchWoodRevenue_Cycle2," +
                               "EscalatorMerchWoodRevenue_Cycle3," +
                               "EscalatorMerchWoodRevenue_Cycle4," +
                               "EscalatorEnergyWoodRevenue_Cycle2," +
                               "EscalatorEnergyWoodRevenue_Cycle3," +
                               "EscalatorEnergyWoodRevenue_Cycle4";


            try
            {
                SQLite.ADO.DataMgr oDataMgr = null;
                //
                //DELETE THE CURRENT SCENARIO RECORDS
                //
                if (!ReferenceProcessorScenarioForm.m_bUsingSqlite)
                {
                    m_oAdo.m_strSQL = "DELETE FROM scenario_cost_revenue_escalators " +
                                      "WHERE TRIM(scenario_id)='" + this.ScenarioId.Trim() + "'";
                    m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                }
                else
                {
                    oDataMgr = new SQLite.ADO.DataMgr();
                    string strScenarioDB =
                        frmMain.g_oFrmMain.frmProject.uc_project1.txtRootDirectory.Text.Trim() +
                        "\\processor\\" + Tables.ProcessorScenarioRuleDefinitions.DefaultSqliteDbFile;
                    oDataMgr.OpenConnection(oDataMgr.GetConnectionString(strScenarioDB));
                    if (oDataMgr.m_intError != 0)
                    {
                        m_intError = oDataMgr.m_intError;
                        m_strError = oDataMgr.m_strError;
                        oDataMgr   = null;
                        return;
                    }
                    oDataMgr.m_strSQL = "DELETE FROM scenario_cost_revenue_escalators " +
                                        "WHERE TRIM(scenario_id)='" + this.ScenarioId.Trim() + "'";
                    oDataMgr.SqlNonQuery(oDataMgr.m_Connection, oDataMgr.m_strSQL);
                }

                //
                //scenario id
                //
                strValues = "'" + ScenarioId.Trim() + "',";
                //
                //Operating Cost Cycle1
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value1.Cycle1.Trim() + ",";
                //
                //Operating Cost Cycle2
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value1.Cycle2.Trim() + ",";
                //
                //Operating Cost Cycle3
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value1.Cycle3.Trim() + ",";
                //
                //Merch Wood Revenue Cycle1
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value2.Cycle1.Trim() + ",";
                //
                //Merch Wood Revenue Cycle2
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value2.Cycle2.Trim() + ",";
                //
                //Merch Wood Revenue Cycle3
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value2.Cycle3.Trim() + ",";
                //
                //Energy Wood Revenue Cycle1
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value3.Cycle1.Trim() + ",";
                //
                //Energy Wood Revenue Cycle2
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value3.Cycle2.Trim() + ",";
                //
                //Energy Wood Revenue Cycle3
                //
                strValues = strValues + this.uc_processor_scenario_escalators_value3.Cycle3.Trim();

                if (!ReferenceProcessorScenarioForm.m_bUsingSqlite)
                {
                    m_oAdo.m_strSQL = Queries.GetInsertSQL(strFields, strValues, "scenario_cost_revenue_escalators");
                    m_oAdo.SqlNonQuery(m_oAdo.m_OleDbConnection, m_oAdo.m_strSQL);
                }
                else
                {
                    oDataMgr.m_strSQL = Queries.GetInsertSQL(strFields, strValues, "scenario_cost_revenue_escalators");
                    oDataMgr.SqlNonQuery(oDataMgr.m_Connection, oDataMgr.m_strSQL);
                    m_intError = oDataMgr.m_intError;

                    oDataMgr.CloseConnection(oDataMgr.m_Connection);
                    oDataMgr = null;
                }

                this.uc_processor_scenario_escalators_value1.SaveValues();
                this.uc_processor_scenario_escalators_value2.SaveValues();
                this.uc_processor_scenario_escalators_value3.SaveValues();
            }
            catch (Exception e)
            {
                m_intError = -1;
                m_strError = e.Message;
            }
        }
Exemplo n.º 14
0
 public static void Render(this IConsole console, ScenarioWarrior scenarioWarrior, ScenarioId scenarioId, int scenarioWarriorId)
 {
     console.WriteTitle($"Scenario = {scenarioId}, Entry = {scenarioWarriorId}");
     console.WriteProperty("Warrior", scenarioWarrior.Warrior);
     console.WriteProperty("Class", scenarioWarrior.Class);
     console.WriteProperty("Army", scenarioWarrior.Army);
     console.WriteProperty("Kingdom", scenarioWarrior.Kingdom);
     console.WriteProperty("Scenario Pokemon", string.Join(", ",
                                                           Enumerable.Range(0, 8)
                                                           .Select(i => scenarioWarrior.ScenarioPokemonIsDefault(i) ? "<default>" : scenarioWarrior.GetScenarioPokemon(i).ToString()))
                           );
 }
Exemplo n.º 15
0
 public static void Render(this IConsole console, ScenarioPokemon scenarioPokemon, ScenarioId scenarioId, int scenarioPokemonId)
 {
     console.WriteTitle($"Scenario = {scenarioId}, Entry = {scenarioPokemonId}");
     console.WriteProperty("Pokemon", scenarioPokemon.Pokemon.ToString());
     console.WriteProperty("Ability", scenarioPokemon.Ability.ToString());
     console.WriteProperty("IVs", $"Hp {scenarioPokemon.HpIv} / Atk {scenarioPokemon.AtkIv} / Def {scenarioPokemon.DefIv} / Spe {scenarioPokemon.SpeIv}");
     console.WriteProperty("Init Exp", $"{scenarioPokemon.Exp} (Approx. Link = {Math.Round(Core.Services.LinkCalculator.CalculateLink(scenarioPokemon.Exp))}%)");
 }