public AppVersioning GetVersion(AppVersioning appVersion) { using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource()) using (OleDbCommand command = new OleDbCommand()) { command.CommandType = CommandType.Text; command.CommandText = " SELECT * " + " FROM `app_versioning` " + " WHERE major = @major " + " AND minor = @minor " + " AND patch = @patch " + " AND `releaseversion` = @rversion "; command.Parameters.AddWithValue("@major", appVersion.GetMajor()); command.Parameters.AddWithValue("@minor", appVersion.GetMinor()); command.Parameters.AddWithValue("@patch", appVersion.GetPatch()); command.Parameters.AddWithValue("@rversion", appVersion.GetReleaseCycle()); command.Connection = conn; conn.Open(); using (OleDbDataReader reader = command.ExecuteReader()) { while (reader.Read()) { return(GetModel(reader)); } } } return(null); }
public int InsertAppVersioning(AppVersioning appVersion) { int modified = 0; using (OleDbConnection conn = DatabaseConnectionFactory.GetDataSource()) using (OleDbCommand command = new OleDbCommand()) { command.CommandType = CommandType.Text; command.CommandText = " INSERT INTO `app_versioning` " + " (`major`, `minor`, `patch`, `releaseversion`, `remarks`, `datetimeapplied`) " + " VALUES(@major, @minor, @patch, @releaseversion, @remarks, @datetimeapplied); "; command.Connection = conn; command.Parameters.AddWithValue("@major", appVersion.GetMajor()); command.Parameters.AddWithValue("@minor", appVersion.GetMinor()); command.Parameters.AddWithValue("@patch", appVersion.GetPatch()); command.Parameters.AddWithValue("@releaseversion", appVersion.GetReleaseCycle()); command.Parameters.AddWithValue("@remarks", appVersion.GetRemarks()); command.Parameters.AddWithValue("@datetimeapplied", appVersion.GetDateTimeApplied().ToString()); conn.Open(); OleDbTransaction transaction = conn.BeginTransaction(); command.Transaction = transaction; int result = command.ExecuteNonQuery(); if (result < 0) { transaction.Rollback(); throw new Exception(ResourcesUtils.GetMessage("lot_dao_impl_msg14")); } else { transaction.Commit(); modified = base.GetLastInsertedID(command); } } return(modified); }
private void UpdateFor1008() { //version 1.0.0.8 update AppVersioningSetup appVersion = new AppVersioningSetup() { Major = 1, Minor = 0, Patch = 0, ReleaseVersion = "8", DateTimeApplied = DateTime.Now, Remarks = ResourcesUtils.GetMessage("app_ver_1008_remarks") }; AppVersioning appVersionInDB = AppVersioningDaoObj.GetVersion(appVersion); if (appVersionInDB == null) { RaiseNewEntryEvent(appVersion); LotterySequenceGeneratorSetup genModel = new LotterySequenceGeneratorSetup(); genModel.SeqGenCode = (int)GeneratorType.DRAW_RESULT_WIN_COUNT_PREDICTION_FAST_TREE_REGRESSION; genModel.Description = ResourcesUtils.GetMessage("app_ver_1008_pick_gen_desc"); lotteryDataServicesObj.InsertLotterySequenceGenerator(genModel); AppVersioningDaoObj.InsertAppVersioning(appVersion); } else { RaiseSkippedVersionEvent(appVersion); } }