예제 #1
0
        public bool SaveWishRecord(int wishWeek, KuaFuRoleMiniData from, int wishType, string wishTxt, int toDbCoupleId, KuaFuRoleMiniData toMan, KuaFuRoleMiniData toWife)
        {
            bool result;

            try
            {
                string sql = string.Format("INSERT INTO t_couple_wish_wish_log(`week`,`from_rid`,`from_zoneid`,`from_rname`,`to_couple_id`,`to_man_rid`,`to_man_zoneid`,`to_man_rname`,`to_wife_rid`,`to_wife_zoneid`,`to_wife_rname`,`time`,`wish_txt`,`wish_type`) VALUES({0},{1},{2},'{3}',{4},{5},{6},'{7}',{8},{9},'{10}','{11}','{12}',{13});", new object[]
                {
                    wishWeek,
                    from.RoleId,
                    from.ZoneId,
                    from.RoleName,
                    toDbCoupleId,
                    toMan.RoleId,
                    toMan.ZoneId,
                    toMan.RoleName,
                    toWife.RoleId,
                    toWife.ZoneId,
                    toWife.RoleName,
                    TimeUtil.NowDateTime().ToString("yyyy-MM-dd HH:mm:ss"),
                    wishTxt,
                    wishType
                });
                DbHelperMySQL.ExecuteSql(sql);
                result = true;
            }
            catch (Exception ex)
            {
                LogManager.WriteException(ex.Message);
                result = false;
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 增加缓存的祝福记录
        /// </summary>
        /// <param name="from"></param>
        /// <param name="wishType"></param>
        /// <param name="wishTxt"></param>
        /// <param name="toMan"></param>
        /// <param name="toWife"></param>
        private void AddCachedWishOther(KuaFuRoleMiniData from, int wishType, string wishTxt, KuaFuRoleMiniData toMan, KuaFuRoleMiniData toWife)
        {
            lock (Mutex)
            {
                Queue <CoupleWishWishRecordData> fromRecords = null;
                if (RoleWishRecords.TryGetValue(from.RoleId, out fromRecords))
                {
                    var rec = new CoupleWishWishRecordData();
                    rec.FromRole    = from;
                    rec.TargetRoles = new List <KuaFuRoleMiniData>();
                    if (toMan.RoleId != from.RoleId)
                    {
                        rec.TargetRoles.Add(toMan);
                    }
                    if (toWife.RoleId != from.RoleId)
                    {
                        rec.TargetRoles.Add(toWife);
                    }
                    rec.WishType = wishType;
                    rec.WishTxt  = wishTxt;

                    fromRecords.Enqueue(rec);
                    while (fromRecords.Count > CoupleWishConsts.MaxWishRecordNum)
                    {
                        fromRecords.Dequeue();
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// 增加缓存的被祝福记录
        /// </summary>
        /// <param name="from"></param>
        /// <param name="wishType"></param>
        /// <param name="wishTxt"></param>
        /// <param name="toMan"></param>
        /// <param name="toWife"></param>
        private void AddCachedBeWished(KuaFuRoleMiniData to, KuaFuRoleMiniData toSpouse, int wishType, string wishTxt, KuaFuRoleMiniData from)
        {
            lock (Mutex)
            {
                if (to.RoleId == from.RoleId)
                {
                    return;
                }

                Queue <CoupleWishWishRecordData> toRecords = null;
                if (RoleWishRecords.TryGetValue(to.RoleId, out toRecords))
                {
                    var rec = new CoupleWishWishRecordData();
                    rec.FromRole    = from;
                    rec.TargetRoles = new List <KuaFuRoleMiniData>();
                    rec.TargetRoles.Add(to);
                    if (toSpouse.RoleId != from.RoleId)
                    {
                        rec.TargetRoles.Add(toSpouse);
                    }
                    rec.WishType = wishType;
                    rec.WishTxt  = wishTxt;

                    toRecords.Enqueue(rec);
                    while (toRecords.Count > CoupleWishConsts.MaxWishRecordNum)
                    {
                        toRecords.Dequeue();
                    }
                }
            }
        }
예제 #4
0
 public void AddWishRecord(KuaFuRoleMiniData from, int wishType, string wishTxt, int toDbCoupleId, KuaFuRoleMiniData toMan, KuaFuRoleMiniData toWife)
 {
     lock (this.Mutex)
     {
         if (this.Persistence.SaveWishRecord(this.ThisWeek, from, wishType, wishTxt, toDbCoupleId, toMan, toWife))
         {
             this.AddCachedWishOther(from, wishType, wishTxt, toMan, toWife);
             this.AddCachedBeWished(toMan, toWife, wishType, wishTxt, from);
             this.AddCachedBeWished(toWife, toMan, wishType, wishTxt, from);
         }
     }
 }