/// <summary> /// 带事务的Update /// </summary> /// <param name="entity"></param> /// <param name="trans">The trans.</param> /// <returns></returns> /// <remarks>2016/7/29 15:49:15</remarks> public bool Update(TurntableManagerEntity entity, DbTransaction trans = null) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_TurntableManager_Update"); database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, entity.ManagerId); database.AddInParameter(commandWrapper, "@LuckyCoin", DbType.Int32, entity.LuckyCoin); database.AddInParameter(commandWrapper, "@GiveLuckyCoin", DbType.Int32, entity.GiveLuckyCoin); database.AddInParameter(commandWrapper, "@DayProduceLuckyCoin", DbType.Int32, entity.DayProduceLuckyCoin); database.AddInParameter(commandWrapper, "@TurntableType", DbType.Int32, entity.TurntableType); database.AddInParameter(commandWrapper, "@DetailsString", DbType.Binary, entity.DetailsString); database.AddInParameter(commandWrapper, "@ResetNumber", DbType.AnsiString, entity.ResetNumber); database.AddInParameter(commandWrapper, "@RefreshDate", DbType.Date, entity.RefreshDate); database.AddInParameter(commandWrapper, "@UpdateTime", DbType.DateTime, entity.UpdateTime); database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime); int results = 0; if (trans != null) { results = database.ExecuteNonQuery(commandWrapper, trans); } else { results = database.ExecuteNonQuery(commandWrapper); } entity.ManagerId = (System.Guid)database.GetParameterValue(commandWrapper, "@ManagerId"); return(Convert.ToBoolean(results)); }
/// <summary> /// 将IDataReader的当前记录读取到TurntableManagerEntity 对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> public TurntableManagerEntity LoadSingleRow(IDataReader reader) { var obj = new TurntableManagerEntity(); obj.ManagerId = (System.Guid)reader["ManagerId"]; obj.LuckyCoin = (System.Int32)reader["LuckyCoin"]; obj.GiveLuckyCoin = (System.Int32)reader["GiveLuckyCoin"]; obj.DayProduceLuckyCoin = (System.Int32)reader["DayProduceLuckyCoin"]; obj.TurntableType = (System.Int32)reader["TurntableType"]; obj.DetailsString = (System.Byte[])reader["DetailsString"]; obj.ResetNumber = (System.String)reader["ResetNumber"]; obj.RefreshDate = (System.DateTime)reader["RefreshDate"]; obj.UpdateTime = (System.DateTime)reader["UpdateTime"]; obj.RowTime = (System.DateTime)reader["RowTime"]; return(obj); }
/// <summary> /// GetById /// </summary> /// <param name="managerId">managerId</param> /// <returns>TurntableManagerEntity</returns> /// <remarks>2016/7/29 15:49:15</remarks> public TurntableManagerEntity GetById(System.Guid managerId) { var database = new SqlDatabase(this.ConnectionString); DbCommand commandWrapper = database.GetStoredProcCommand("P_TurntableManager_GetById"); database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, managerId); TurntableManagerEntity obj = null; using (IDataReader reader = database.ExecuteReader(commandWrapper)) { if (reader.Read()) { obj = LoadSingleRow(reader); } } return(obj); }
public TurntableFrame(Guid managerId) { var frame = TurntableManagerMgr.GetById(managerId); DateTime date = DateTime.Now; if (frame == null) { frame = new TurntableManagerEntity(managerId, 0, CacheFactory.TurntableCache.GiveLuckyCoin, CacheFactory.TurntableCache.DayProduceLuckyCoin, (int)EnumTurntableType.Bronze, new byte[0], "", date, date, date); TurntableManagerMgr.Insert(frame); } if (frame.RefreshDate != date.Date) { if (TurntableCore.Instance.IsActivity) { frame.GiveLuckyCoin = CacheFactory.TurntableCache.GiveLuckyCoin; frame.DayProduceLuckyCoin = CacheFactory.TurntableCache.DayProduceLuckyCoin; frame.ResetNumber = "1,0|2,0|3,0"; frame.RefreshDate = date.Date; isUpdate = true; } } _turntableManagerEntity = frame; AnalyseTurntable(); }
public static bool Update(TurntableManagerEntity turntableManagerEntity, DbTransaction trans = null, string zoneId = "") { var provider = new TurntableManagerProvider(zoneId); return(provider.Update(turntableManagerEntity, trans)); }