protected void CopyTemplateData(DAL templateDB) { // _database.Execute(@" //DELETE FROM TreeDefaultValue; //DELETE FROM TreeAuditValue; //DELETE FROM TreeDefaultValueTreeAuditValue;");//ensure that these tables are clean _database.BeginTransaction(); try { foreach (TreeDefaultValueDO tdv in templateDB.From<TreeDefaultValueDO>().Query()) { _database.Insert(tdv, OnConflictOption.Replace); } foreach (TreeAuditValueDO tav in templateDB.From<TreeAuditValueDO>().Query()) { _database.Insert(tav, OnConflictOption.Replace); } foreach (TreeDefaultValueTreeAuditValueDO map in templateDB.From<TreeDefaultValueTreeAuditValueDO>().Query()) { _database.Insert(map, OnConflictOption.Replace); } foreach (ReportsDO rpt in templateDB.From<ReportsDO>().Query()) { _database.Insert(rpt, OnConflictOption.Replace); } var crusemethods = templateDB.From<CruiseMethodsDO>(); if (this.Sale.Purpose == "Recon") { crusemethods.Where("Code = 'FIX' OR Code = 'PNT'"); } foreach (CruiseMethodsDO cm in crusemethods.Query()) { _database.Insert(cm, OnConflictOption.Ignore); } foreach (VolumeEquationDO ve in templateDB.From<VolumeEquationDO>().Query()) { _database.Insert(ve, OnConflictOption.Ignore); } foreach (TreeFieldSetupDefaultDO tf in templateDB.From<TreeFieldSetupDefaultDO>().Query()) { _database.Insert(tf, OnConflictOption.Ignore); } foreach (LogFieldSetupDefaultDO lf in templateDB.From<LogFieldSetupDefaultDO>().Query()) { _database.Insert(lf, OnConflictOption.Ignore); } _database.CommitTransaction(); } catch { _database.RollbackTransaction(); throw; } TreeDefaults = _database.From<TreeDefaultValueDO>().Read().ToList(); //_database.DirectCopy(templateDB, CruiseDAL.Schema.VOLUMEEQUATION._NAME, null, OnConflictOption.Ignore); //_database.DirectCopy(templateDB, CruiseDAL.Schema.TREEFIELDSETUPDEFAULT._NAME, null, OnConflictOption.Ignore); //_database.DirectCopy(templateDB, CruiseDAL.Schema.LOGFIELDSETUPDEFAULT._NAME, null, OnConflictOption.Ignore); //_database.DirectCopy(templateDB, CruiseDAL.Schema.TALLY._NAME, null, OnConflictOption.Ignore); }
public DataObject ReadSingleRow(DAL source, long rowid) { switch (this.ClientTableName) { case "Tree": { return source.From<TreeDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "Log": { return source.From<LogDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "Stem": { return source.From<StemDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "Plot": { return source.From<PlotDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "CountTree": { return source.From<CountTreeDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "CuttingUnit": { return source.From<CuttingUnitDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "Stratum": { return source.From<StratumDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "CuttingUnitStratum": { return source.From<CuttingUnitStratumDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "SampleGroup": { return source.From<SampleGroupDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "SampleGroupTreeDefaultValue": { return source.From<SampleGroupTreeDefaultValueDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } case "TreeDefaultValue": { return source.From<TreeDefaultValueDO>().Where("rowid = ?").Query(rowid).FirstOrDefault(); } default: { throw new NotImplementedException(); } } }
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); } }