Exemplo n.º 1
0
 void AddIntimacy(FriendManagerEntity entity, int intimacy)
 {
     if (entity.DayIntimacy < _friendDayIntimacyMax)
     {
         entity.Intimacy    += intimacy;
         entity.DayIntimacy += intimacy;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// GetById
        /// </summary>
        /// <param name="idx">idx</param>
        /// <returns>FriendManagerEntity</returns>
        /// <remarks>2016/6/14 19:35:20</remarks>
        public FriendManagerEntity GetById(System.Int32 idx)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("P_FriendManager_GetById");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, idx);


            FriendManagerEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Exemplo n.º 3
0
        /// <summary>
        /// GetOne
        /// </summary>
        /// <param name="managerId">managerId</param>
        /// <param name="friendId">friendId</param>
        /// <returns>FriendManagerEntity</returns>
        /// <remarks>2016/6/14 19:35:21</remarks>
        public FriendManagerEntity GetOne(System.Guid managerId, System.Guid friendId)
        {
            var database = new SqlDatabase(this.ConnectionString);

            DbCommand commandWrapper = database.GetStoredProcCommand("C_Friend_GetOne");

            database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, managerId);
            database.AddInParameter(commandWrapper, "@FriendId", DbType.Guid, friendId);


            FriendManagerEntity obj = null;

            using (IDataReader reader = database.ExecuteReader(commandWrapper))
            {
                if (reader.Read())
                {
                    obj = LoadSingleRow(reader);
                }
            }
            return(obj);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 将IDataReader的当前记录读取到FriendManagerEntity 对象
        /// </summary>
        /// <param name="reader"></param>
        /// <returns></returns>
        public FriendManagerEntity LoadSingleRow(IDataReader reader)
        {
            var obj = new FriendManagerEntity();

            obj.Idx               = (System.Int32)reader["Idx"];
            obj.ManagerId         = (System.Guid)reader["ManagerId"];
            obj.FriendId          = (System.Guid)reader["FriendId"];
            obj.Intimacy          = (System.Int32)reader["Intimacy"];
            obj.DayIntimacy       = (System.Int32)reader["DayIntimacy"];
            obj.HelpTrainCount    = (System.Int32)reader["HelpTrainCount"];
            obj.DayHelpTrainCount = (System.Int32)reader["DayHelpTrainCount"];
            obj.DayOpenBoxCount   = (System.Int32)reader["DayOpenBoxCount"];
            obj.MatchCount        = (System.Int32)reader["MatchCount"];
            obj.DayMatchCount     = (System.Int32)reader["DayMatchCount"];
            obj.RecordDate        = (System.DateTime)reader["RecordDate"];
            obj.Status            = (System.Int32)reader["Status"];
            obj.RowTime           = (System.DateTime)reader["RowTime"];
            obj.RowVersion        = (System.Byte[])reader["RowVersion"];
            obj.OpenBoxTime       = (System.DateTime)reader["OpenBoxTime"];

            return(obj);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 带事务的Update
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="trans">The trans.</param>
        /// <returns></returns>
        /// <remarks>2016/6/14 19:35:21</remarks>
        public bool Update(FriendManagerEntity entity, DbTransaction trans = null)
        {
            var       database       = new SqlDatabase(this.ConnectionString);
            DbCommand commandWrapper = database.GetStoredProcCommand("dbo.P_FriendManager_Update");

            database.AddInParameter(commandWrapper, "@Idx", DbType.Int32, entity.Idx);
            database.AddInParameter(commandWrapper, "@ManagerId", DbType.Guid, entity.ManagerId);
            database.AddInParameter(commandWrapper, "@FriendId", DbType.Guid, entity.FriendId);
            database.AddInParameter(commandWrapper, "@Intimacy", DbType.Int32, entity.Intimacy);
            database.AddInParameter(commandWrapper, "@DayIntimacy", DbType.Int32, entity.DayIntimacy);
            database.AddInParameter(commandWrapper, "@HelpTrainCount", DbType.Int32, entity.HelpTrainCount);
            database.AddInParameter(commandWrapper, "@DayHelpTrainCount", DbType.Int32, entity.DayHelpTrainCount);
            database.AddInParameter(commandWrapper, "@DayOpenBoxCount", DbType.Int32, entity.DayOpenBoxCount);
            database.AddInParameter(commandWrapper, "@MatchCount", DbType.Int32, entity.MatchCount);
            database.AddInParameter(commandWrapper, "@DayMatchCount", DbType.Int32, entity.DayMatchCount);
            database.AddInParameter(commandWrapper, "@RecordDate", DbType.DateTime, entity.RecordDate);
            database.AddInParameter(commandWrapper, "@Status", DbType.Int32, entity.Status);
            database.AddInParameter(commandWrapper, "@RowTime", DbType.DateTime, entity.RowTime);
            database.AddInParameter(commandWrapper, "@RowVersion", DbType.Binary, entity.RowVersion);
            database.AddInParameter(commandWrapper, "@OpenBoxTime", DbType.DateTime, entity.OpenBoxTime);


            int results = 0;

            if (trans != null)
            {
                results = database.ExecuteNonQuery(commandWrapper, trans);
            }
            else
            {
                results = database.ExecuteNonQuery(commandWrapper);
            }

            entity.Idx = (System.Int32)database.GetParameterValue(commandWrapper, "@Idx");

            return(Convert.ToBoolean(results));
        }
Exemplo n.º 6
0
 public void AddFriendMatchIntimacy(FriendManagerEntity entity)
 {
     AddIntimacy(entity, _friendMatchIntimacyCount);
     entity.DayMatchCount++;
 }
Exemplo n.º 7
0
 public void AddHelpTrainIntimacy(FriendManagerEntity entity)
 {
     AddIntimacy(entity, _friendHelpIntimacyCount);
     entity.DayHelpTrainCount++;
 }
Exemplo n.º 8
0
        public static bool Update(FriendManagerEntity friendManagerEntity, DbTransaction trans = null, string zoneId = "")
        {
            var provider = new FriendManagerProvider(zoneId);

            return(provider.Update(friendManagerEntity, trans));
        }
Exemplo n.º 9
0
        //public static MessageCode CreateMatchTourAsyn(Guid matchId, Guid homeId, int stageId, bool hasTask, MatchThread.MatchCallback callback, bool isElite = false, int guideTaskRecordId = 0)// bool isMopUp,
        //{
        //    var stateObj = new TourMatchData(matchId, homeId, Guid.Empty, stageId);
        //    stateObj.GuideTaskRecordId = guideTaskRecordId;
        //    stateObj.HasTask = hasTask;
        //    if (isElite)
        //    {
        //        var elite = CacheFactory.TourdicCache.GetTourElite(stageId);
        //        if (elite == null)
        //        {
        //            return MessageCode.TourStageNotExists;
        //        }
        //        else
        //        {
        //            stateObj.Away.ManagerId = elite.NpcId;
        //            stateObj.MatchType = (int)EnumMatchType.TourElite;
        //        }
        //    }
        //    else
        //    {
        //        var stage = CacheFactory.TourdicCache.GetStage(stageId);
        //        if (stage == null)
        //        {
        //            return MessageCode.TourStageNotExists;
        //        }
        //        else
        //        {
        //            if (guideTaskRecordId > 0)
        //                stateObj.IsGuide = true;
        //            stateObj.Away.ManagerId = stage.NpcId;
        //        }
        //    }
        //    return CreateMatchAsyn(stateObj, callback);
        //}

        //public static MessageCode CreateMatchChallengeAsyn(Guid matchId, Guid homeId,int buff,WorldchallengeRecordEntity recordEntity, bool hasTask, MatchThread.MatchCallback callback)
        //{
        //    var stateObj = new WChallengeMatchData(matchId, homeId, recordEntity.NpcId);
        //    stateObj.HasTask = hasTask;
        //    stateObj.WorldchallengeRecord = recordEntity;
        //    stateObj.Home.BuffScale = buff;
        //    return CreateMatchAsyn(stateObj, callback);
        //}

        public static MessageCode CreateMatchFriendAsyn(Guid matchId, Guid managerId, Guid awayId, FriendManagerEntity friendManager, MatchThread.MatchCallback callback)
        {
            var stateObj = new FriendMatchData(matchId, managerId, awayId);

            stateObj.HasTask      = false;
            stateObj.FriendRecord = friendManager;
            return(CreateMatchAsyn(stateObj, callback));
        }