Ejemplo n.º 1
0
        private static void UpdateToVersion2015_08_19(DAL db)
        {
            System.Collections.Generic.List<ColumnInfo> tavCols = db.GetTableInfo("TreeAuditValue");
            bool hasErrorMessageCol = false;
            foreach (ColumnInfo col in tavCols)
            {
                if (col.Name == "ErrorMessage")
                {
                    hasErrorMessageCol = true; break;
                }
            }

            try
            {
                db.BeginTransaction();
                if (!hasErrorMessageCol)
                {
                    db.AddField("TreeAuditValue", "ErrorMessage TEXT");
                }

                SetDatabaseVersion(db, "2015.08.19");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2015.08.19", e);
            }
        }
Ejemplo n.º 2
0
 private static void UpdateToVersion2014_08_20(DAL db)
 {
     try
     {
         db.BeginTransaction();
         db.AddField(Schema.VOLUMEEQUATION._NAME, "EvenOddSegment INTEGER Default 0");
         SetDatabaseVersion(db, "2014.08.20");
         db.CommitTransaction();
     }
     catch (Exception e)
     {
         db.RollbackTransaction();
         throw new SchemaUpdateException(db.DatabaseVersion, "2014.08.20", e);
     }
 }
Ejemplo n.º 3
0
        private static void UpdateToVersion2014_09_02(DAL db)
        {
            try
            {
                db.BeginTransaction();
                db.AddField(Schema.SAMPLEGROUP._NAME, "TallyMethod TEXT");
                SetDatabaseVersion(db, "2014.09.02");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();

                throw new SchemaUpdateException(db.DatabaseVersion, "2014.09.02", e);
            }
        }
Ejemplo n.º 4
0
 private static void UpdateToVersion2014_07_07(DAL db)
 {
     try
     {
         db.BeginTransaction();
         db.AddField("SampleGroup", "MinKPI INTEGER Default 0");
         db.AddField("SampleGroup", "MaxKPI INTEGER Default 0");
         SetDatabaseVersion(db, "2014.07.07");
         db.CommitTransaction();
     }
     catch (Exception e)
     {
         db.RollbackTransaction();
         throw new SchemaUpdateException(db.DatabaseVersion, "2014.07.07", e);
     }
 }
Ejemplo n.º 5
0
        private static void UpdateToVersion2014_07_17(DAL db)
        {
            try
            {
                db.BeginTransaction();
                //rebuild Volume Equation table (remove MinLogLengthSecondary, MaxLogLengthSecondary; Add int MerchModFlag)
                //                RebuildTable(db, "VolumeEquation",
                //                    @"
                //CREATE TABLE VolumeEquation (
                //				Species TEXT NOT NULL,
                //				PrimaryProduct TEXT NOT NULL,
                //				VolumeEquationNumber TEXT NOT NULL,
                //				StumpHeight REAL Default 0.0,
                //				TopDIBPrimary REAL Default 0.0,
                //				TopDIBSecondary REAL Default 0.0,
                //				CalcTotal INTEGER Default 0,
                //				CalcBoard INTEGER Default 0,
                //				CalcCubic INTEGER Default 0,
                //				CalcCord INTEGER Default 0,
                //				CalcTopwood INTEGER Default 0,
                //				CalcBiomass INTEGER Default 0,
                //				Trim REAL Default 0.0,
                //				SegmentationLogic INTEGER Default 0,
                //				MinLogLengthPrimary REAL Default 0.0,
                //				MaxLogLengthPrimary REAL Default 0.0,
                //				MinMerchLength REAL Default 0.0,
                //				Model TEXT,
                //				CommonSpeciesName TEXT,
                //				MerchModFlag INTEGER Default 0,
                //				UNIQUE (Species, PrimaryProduct, VolumeEquationNumber));
                //",
                // @"
                //                Species,
                //                PrimaryProduct,
                //                VolumeEquationNumber,
                //                StumpHeight,
                //                TopDIBPrimary,
                //                TopDIBSecondary,
                //                CalcTotal,
                //                CalcBoard,
                //                CalcCubic,
                //                CalcCord,
                //                CalcTopWood,
                //                CalcBiomass,
                //                Trim,
                //                SegmentationLogic,
                //                MinLogLengthPrimary,
                //                MaxLogLengthPrimary,
                //                MinMerchLength,
                //                Model,
                //                CommonSpeciesName");
                db.AddField("VolumeEquation", "MerchModFlag INTEGER Default 0");

                //rebuild TreeAuditValue Table ( remove error message field)
                //                RebuildTable(db, "TreeAuditValue",
                //                    @"
                //CREATE TABLE TreeAuditValue (
                //				TreeAuditValue_CN INTEGER PRIMARY KEY AUTOINCREMENT,
                //				Field TEXT NOT NULL,
                //				Min REAL Default 0.0,
                //				Max REAL Default 0.0,
                //				ValueSet TEXT,
                //				Required BOOLEAN Default 0);
                //",
                // @"
                //Field,
                //Min,
                //Max,
                //ValueSet,
                //Required");
                //Add ReconPlots
                db.AddField("SampleGroupStats", "ReconPlots INTEGER Default 0");
                //Add ReconTrees
                db.AddField("SampleGroupStats", "ReconTrees INTEGER Default 0");
                SetDatabaseVersion(db, "2014.07.17");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2014.07.17", e);
            }
        }
Ejemplo n.º 6
0
        private static void UpdateToVersion2014_06_04(DAL db)
        {
            try
            {
                db.BeginTransaction();
                db.AddField("Sale", "LogGradingEnabled BOOLEAN Default 0");

                SetDatabaseVersion(db, "2014.06.04");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2014.06.04", e);
            }
        }
Ejemplo n.º 7
0
 private static void UpdateToVersion2014_07_02(DAL db)
 {
     try
     {
         db.BeginTransaction();
         db.AddField("LogStock", "BoardUtil REAL Default 0.0");
         db.AddField("LogStock", "CubicUtil REAL Default 0.0");
         SetDatabaseVersion(db, "2014.07.02");
         db.CommitTransaction();
     }
     catch (Exception e)
     {
         db.RollbackTransaction();
         throw new SchemaUpdateException(db.DatabaseVersion, "2014.07.02", e);
     }
 }
Ejemplo n.º 8
0
        private static void UpdateToVersion2013_10_29(DAL db)
        {
            try
            {
                db.BeginTransaction();

                db.AddField("Tree", "HiddenPrimary REAL Default 0.0");
                SetDatabaseVersion(db, "2013.10.29");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2013.10.29", e);
            }
        }
Ejemplo n.º 9
0
        private static void UpdateToVersion2014_03_12(DAL db)
        {
            try
            {
                db.BeginTransaction();
                db.AddField("SampleGroup", "SampleSelectorType TEXT");
                db.AddField("SampleGroup", "SampleSelectorState TEXT");

                RebuildTable(db, "CountTree",
                @"CREATE TABLE CountTree (
                CountTree_CN INTEGER PRIMARY KEY AUTOINCREMENT,
                SampleGroup_CN INTEGER REFERENCES SampleGroup NOT NULL,
                CuttingUnit_CN INTEGER REFERENCES CuttingUnit NOT NULL,
                Tally_CN INTEGER REFERENCES Tally,
                TreeDefaultValue_CN INTEGER REFERENCES TreeDefaultValue,
                Component_CN INTEGER REFERENCES Component,
                TreeCount INTEGER Default 0,
                SumKPI INTEGER Default 0,
                CreatedBy TEXT NOT NULL,
                CreatedDate DATETIME,
                ModifiedBy TEXT,
                ModifiedDate DATETIME,
                UNIQUE (SampleGroup_CN, CuttingUnit_CN, TreeDefaultValue_CN, Component_CN));",
                "CountTree_CN, SampleGroup_CN, CuttingUnit_CN, Tally_CN, TreeDefaultValue_CN, Component_CN, TreeCount, SumKPI, CreatedBy, CreatedDate, ModifiedBy, ModifiedDate");

                SetDatabaseVersion(db, "2014.03.12");

                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2014.03.12", e);
            }
        }
Ejemplo n.º 10
0
        private static void UpdateToVersion2013_08_29(DAL db)
        {
            try
            {
                db.BeginTransaction();
                db.AddField("Stratum", "KZ3PPNT INTEGER Default 0");

                SetDatabaseVersion(db, "2013.08.29");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2013.08.29", e);
            }
        }
Ejemplo n.º 11
0
        private static void UpdateToVersion2013_08_02(DAL db)
        {
            try
            {
                db.BeginTransaction();

                db.AddField("Sale", "DefaultUOM TEXT");

                string command = "DROP TABLE LogFieldSetupDefault;";
                db.Execute(command);
                command = @"CREATE TABLE LogFieldSetupDefault (
                            LogFieldSetupDefault_CN INTEGER PRIMARY KEY AUTOINCREMENT,
                            Field TEXT NOT NULL,
                            FieldName TEXT,
                            FieldOrder INTEGER Default 0,
                            ColumnType TEXT,
                            Heading TEXT,
                            Width REAL Default 0.0,
                            Format TEXT,
                            Behavior TEXT,
                            UNIQUE (Field));";
                db.Execute(command);

                SetDatabaseVersion(db, "2013.08.02");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2013.08.02", e);
            }
        }
Ejemplo n.º 12
0
        private static void UpdateToVersion2013_06_12(DAL db)
        {
            try
            {
                db.BeginTransaction();

                db.AddField("ErrorLog", "Program TEXT");

                //modify globals table, making Block & Key Unique
                string command = @"CREATE TABLE TempGlobals (
                        Block TEXT,
                        Key TEXT,
                        Value TEXT,
                        UNIQUE (Block, Key));";

                db.Execute(command);

                command = "INSERT OR IGNORE INTO TempGlobals (Block, Key, Value) SELECT Block, Key, Value FROM Globals;";
                db.Execute(command);

                command = "DROP TABLE Globals;";
                db.Execute(command);

                command = "ALTER TABLE TempGlobals RENAME TO Globals;";
                db.Execute(command);

                command = "UPDATE CountTree SET TreeDefaultValue_CN = NULL WHERE TreeDefaultValue_CN = 0;";
                db.Execute(command);

                SetDatabaseVersion(db, "2013.06.12");

                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2013.06.12", e);
            }
        }
Ejemplo n.º 13
0
        private static void UpdateToVersion2013_05_30(DAL db)
        {
            try
            {
                db.BeginTransaction();

                RebuildTable(db, "Plot",
                    @"CREATE TABLE Plot (
                        Plot_CN INTEGER PRIMARY KEY AUTOINCREMENT,
                        Stratum_CN INTEGER REFERENCES Stratum NOT NULL,
                        CuttingUnit_CN INTEGER REFERENCES CuttingUnit NOT NULL,
                        PlotNumber INTEGER NOT NULL,
                        IsEmpty TEXT,
                        Slope REAL Default 0.0,
                        KPI REAL Default 0.0,
                        Aspect REAL Default 0.0,
                        Remarks TEXT,
                        XCoordinate REAL Default 0.0,
                        YCoordinate REAL Default 0.0,
                        ZCoordinate REAL Default 0.0,
                        MetaData TEXT,
                        Blob BLOB,
                        CreatedBy TEXT NOT NULL,
                        CreatedDate DATETIME,
                        ModifiedBy TEXT,
                        ModifiedDate DATETIME,
                        UNIQUE (Stratum_CN, CuttingUnit_CN, PlotNumber));",
                    "PlotNumber, IsEmpty, Slope, KPI, Aspect, Remarks, XCoordinate, YCoordinate," +
                    "ZCoordinate, MetaData, Blob, Stratum_CN, CuttingUnit_CN, CreatedBy, " +
                    "CreatedDate, ModifiedBy, ModifiedDate");

                db.AddField("CuttingUnit", "TallyHistory TEXT");

                SetDatabaseVersion(db, "2013.05.30");
                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2013.05.30", e);
            }
        }
Ejemplo n.º 14
0
        public static void UpdateToVersion2015_08_03(DAL db)
        {
            try
            {
                db.BeginTransaction();
                db.AddField("Plot", "Plot_GUID TEXT");
                db.AddField("Tree", "Tree_GUID TEXT");
                db.AddField("Log", "Log_GUID TEXT");
                db.AddField("Stem", "Stem_GUID TEXT");
                db.AddField("TreeEstimate", "TreeEstimate_GUID");

                SetDatabaseVersion(db, "2015.08.03");

                db.CommitTransaction();
            }
            catch (Exception e)
            {
                db.RollbackTransaction();
                throw new SchemaUpdateException(db.DatabaseVersion, "2015.08.03", e);
            }
        }