예제 #1
0
        public static void Update(DAL db)
        {
            //PatchSureToMeasure(db);

            if (db.DatabaseVersion == "2013.05.28" || db.DatabaseVersion == "Unknown")
            {
                UpdateToVersion2013_05_30(db);
            }

            if (db.DatabaseVersion == "2013.05.30")
            {
                UpdateToVersion2013_06_12(db);
            }

            if (db.DatabaseVersion == "2013.06.12" || db.DatabaseVersion == "2013.06.13")
            {
                UpdateToVersion2013_06_17(db);
            }

            if (db.DatabaseVersion == "2013.06.17" || db.DatabaseVersion == "2013.06.18")
            {
                UpdateToVersion2013_06_19(db);
            }

            if (db.DatabaseVersion == "2013.06.19")
            {
                UpdateVersion2013_06_19(db);
                UpdateToVersion2013_08_02(db);
            }

            if (db.DatabaseVersion == "2013.08.02")
            {
                UpdateToVersion2013_08_29(db);
            }

            if (db.DatabaseVersion == "2013.08.29")
            {
                UpdateToVersion2013_10_29(db);
            }

            if (db.DatabaseVersion == "2013.10.29")
            {
                UpdateToVersion2013_11_01(db);
            }

            if (db.DatabaseVersion == "2013.11.01")
            {
                UpdateToVersion2013_11_22(db);
            }

            if (db.DatabaseVersion == "2013.11.22")
            {
                UpdateToVersion2014_01_21(db);
            }
            if (db.DatabaseVersion == "2014.01.21")
            {
                UpdateToVersion2014_03_12(db);
            }
            if (db.DatabaseVersion == "2014.03.12")
            {
                UpdateToVersion2014_06_04(db);
            }
            if (db.DatabaseVersion == "2014.06.04")
            {
                UpdateToVersion2014_07_02(db);
            }
            if (db.DatabaseVersion == "2014.07.02")
            {
                UpdateToVersion2014_07_07(db);
            }
            if (db.DatabaseVersion == "2014.07.07")
            {
                UpdateToVersion2014_07_17(db);
            }
            if (db.DatabaseVersion == "2014.07.17")
            {
                UpdateToVersion2014_07_24(db);
            }
            if (db.DatabaseVersion == "2014.07.24")
            {
                UpdateToVersion2014_08_20(db);
            }
            if (db.DatabaseVersion == "2014.08.20")
            {
                UpdateToVersion2014_09_02(db);
            }
            if (db.DatabaseVersion == "2014.09.02")
            {
                UpdateToVersion2014_10_01(db);
            }
            if (db.DatabaseVersion == "2014.10.01" || db.DatabaseVersion == "2015.01.05")
            {
                UpdateToVersion2015_04_28(db);
            }

            if (db.DatabaseVersion == "2015.04.28")
            {
                UpdateToVersion2015_08_03(db);
            }

            if (db.DatabaseVersion == "2015.06.01")
            {
                SetDatabaseVersion(db, "2015.08.03");
            }

            if (db.DatabaseVersion == "2015.08.03")
            {
                UpdateToVersion2015_08_19(db);
            }
            if (db.DatabaseVersion == "2015.08.19")
            {
                UpdateToVersion2015_09_01(db);
            }
            if (db.DatabaseVersion == "2015.09.01"
                || db.DatabaseVersion == "2.0.0"
                || db.DatabaseVersion == "2.1.0")
            {
                UpdateTo_2_1_1(db);
            }
            if (db.DatabaseVersion == "2.1.1")
            {
                UpdateTo_2_1_2(db);
            }

            if (db.HasForeignKeyErrors(TREEDEFAULTVALUETREEAUDITVALUE._NAME))
            {
                try
                {
                    db.BeginTransaction();
                    db.Execute("DELETE FROM TreeDefaultValueTreeAuditValue WHERE TreeDefaultValue_CN NOT IN (Select TreeDefaultValue_CN FROM TreeDefaultValue);");
                    db.Execute("DELETE FROM TreeDefaultValueTreeAuditValue WHERE TreeAuditValue_CN NOT IN (SELECT TreeAuditValue_CN FROM TreeAuditValue);");
                    db.CommitTransaction();
                }
                catch
                {
                    db.RollbackTransaction();
                }
            }

            foreach (ErrorLogDO el in db.From<ErrorLogDO>().Where("CN_Number != 0").Query())
            {
                InsureErrorLogEntry(db, el);
            }
        }