Exemple #1
0
        /// <summary>
        /// 业务逻辑处理
        /// </summary>
        /// <returns>false:中断后面的方式执行并返回Error</returns>
        public override bool TakeAction()
        {
            _isSuccess = 1;

            var         cacheSet    = new ShareCacheStruct <UserFriends>();
            UserFriends userFriend  = cacheSet.FindKey(ContextUser.UserId, _friendID);
            UserFriends userFriend1 = cacheSet.FindKey(_friendID, ContextUser.UserId);

            if (userFriend == null)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St9104_NotFriendsUserID;
                return(false);
            }

            //Console.WriteLine("***" + userFriend1.UserID);
            //如果原来是好友 要将对方的状态改为关注 其他的直接删除
            if (userFriend.FriendType == FriendType.Friend)
            {
                cacheSet.Delete(userFriend);
                if (userFriend1 != null)
                {
                    userFriend1.FriendType = FriendType.Attention;
                }
            }
            else
            {
                cacheSet.Delete(userFriend);
            }

            return(true);
        }
 public static void Init()
 {
     foreach (var item in sConnectServerSet.FindAll(false))
     {
         sConnectServerSet.Delete(item);
     }
     foreach (var item in sRoomServerSet.FindAll(false))
     {
         sRoomServerSet.Delete(item);
     }
 }
Exemple #3
0
        public override bool TakeAction()
        {
            GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);

            if (member != null)
            {
                if (member.PostType == PostType.Member)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St6007_AuditPermissions;
                    return(false);
                }
                else
                {
                    var cacheSet = new ShareCacheStruct <UserApply>();
                    List <UserApply> userApplyArray = cacheSet.FindAll(m => m.GuildID == member.GuildID);
                    foreach (UserApply apply in userApplyArray)
                    {
                        List <GuildMember> gMemberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.UserID == apply.UserID);
                        if (gMemberArray.Count > 0)
                        {
                            cacheSet.Delete(apply);
                        }
                    }
                    applyArray = userApplyArray.GetPaging(pageIndex, pageSize, out pageCount);
                }
            }
            return(true);
        }
Exemple #4
0
 public override bool TakeAction()
 {
     var cacheSet = new ShareCacheStruct<UserFriends>();
     UserFriends userFriend = cacheSet.FindKey(ContextUser.UserID, friendID);
     UserFriends userFriend1 = cacheSet.FindKey(friendID, ContextUser.UserID);
     //如果原来是好友 要将对方的状态改为关注 其他的直接删除
     if (userFriend.FriendType == FriendType.Friend)
     {
         cacheSet.Delete(userFriend);
         userFriend1.FriendType = FriendType.Attention;
     }else
     {
         cacheSet.Delete(userFriend);
     }
    
     return true;
 }
        public override bool TakeAction()
        {
            int totalDate = (ConfigEnvSet.GetInt("UserQueue.GuildMemberDel") * 60 * 60);
            var memberSet = new ShareCacheStruct <GuildMember>();
            List <GuildMember> memberArray = memberSet.FindAll(m => m.GuildID == guildID);
            GuildMember        userMember  = memberSet.FindKey(guildID, ContextUser.UserID);

            if (userMember != null && userMember.PostType == PostType.Chairman && memberArray.Count > 1)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6010_Chairman;
                return(false);
            }
            if (userMember != null)
            {
                if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
                {
                    memberSet.Delete(userMember);
                    ContextUser.MercenariesID = string.Empty;
                    //ContextUser.Update();
                    CombatHelper.RemoveGuildAbility(ContextUser);
                }
                var       guildSet  = new ShareCacheStruct <UserGuild>();
                UserGuild guildInfo = guildSet.FindKey(guildID);
                if (guildInfo != null && userMember.PostType == PostType.Chairman && memberArray.Count <= 1)
                {
                    guildSet.Delete(guildInfo);
                }

                List <UserQueue> queueArray = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui);
                if (queueArray.Count > 0)
                {
                    UserQueue queue = queueArray[0];
                    queue.Timing        = DateTime.Now;
                    queue.TotalColdTime = totalDate;
                    queue.ColdTime      = totalDate;
                    //queue.Update();
                }
                else
                {
                    UserQueue userQueue = new UserQueue()
                    {
                        QueueID =
                            Guid.NewGuid().ToString(),
                        QueueName     = QueueType.TuiChuGongHui.ToString(),
                        QueueType     = QueueType.TuiChuGongHui,
                        TotalColdTime = totalDate,
                        ColdTime      = totalDate,
                        Timing        = DateTime.Now,
                        IsSuspend     = false,
                        UserID        = ContextUser.UserID
                    };
                    new PersonalCacheStruct <UserQueue>().Add(userQueue);
                }
            }
            return(true);
        }
Exemple #6
0
        public override bool TakeAction()
        {
            int totalDate = (ConfigEnvSet.GetInt("UserQueue.GuildMemberDel") * 60 * 60);
            var memberSet = new ShareCacheStruct<GuildMember>();
            List<GuildMember> memberArray = memberSet.FindAll(m => m.GuildID == guildID);
            GuildMember userMember = memberSet.FindKey(guildID, ContextUser.UserID);
            if (userMember != null && userMember.PostType == PostType.Chairman && memberArray.Count > 1)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6010_Chairman;
                return false;
            }
            if (userMember != null)
            {
                if (!string.IsNullOrEmpty(ContextUser.MercenariesID))
                {
                    memberSet.Delete(userMember);
                    ContextUser.MercenariesID = string.Empty;
                    //ContextUser.Update();
                    CombatHelper.RemoveGuildAbility(ContextUser);
                }
                var guildSet = new ShareCacheStruct<UserGuild>();
                UserGuild guildInfo = guildSet.FindKey(guildID);
                if (guildInfo != null && userMember.PostType == PostType.Chairman && memberArray.Count <= 1)
                {
                    guildSet.Delete(guildInfo);
                }

                List<UserQueue> queueArray = new PersonalCacheStruct<UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.TuiChuGongHui);
                if (queueArray.Count > 0)
                {
                    UserQueue queue = queueArray[0];
                    queue.Timing = DateTime.Now;
                    queue.TotalColdTime = totalDate;
                    queue.ColdTime = totalDate;
                    //queue.Update();
                }
                else
                {
                    UserQueue userQueue = new UserQueue()
                    {
                        QueueID =
                            Guid.NewGuid().ToString(),
                        QueueName = QueueType.TuiChuGongHui.ToString(),
                        QueueType = QueueType.TuiChuGongHui,
                        TotalColdTime = totalDate,
                        ColdTime = totalDate,
                        Timing = DateTime.Now,
                        IsSuspend = false,
                        UserID = ContextUser.UserID
                    };
                    new PersonalCacheStruct<UserQueue>().Add(userQueue);
                }
            }
            return true;
        }
Exemple #7
0
        public override bool TakeAction()
        {
            var         cacheSet    = new ShareCacheStruct <UserFriends>();
            UserFriends userFriend  = cacheSet.FindKey(ContextUser.UserID, friendID);
            UserFriends userFriend1 = cacheSet.FindKey(friendID, ContextUser.UserID);

            //如果原来是好友 要将对方的状态改为关注 其他的直接删除
            if (userFriend.FriendType == FriendType.Friend)
            {
                cacheSet.Delete(userFriend);
                userFriend1.FriendType = FriendType.Attention;
            }
            else
            {
                cacheSet.Delete(userFriend);
            }

            return(true);
        }
 protected virtual void beforeDoRefresh()
 {
     if (_lst.Count > limitIndex)
     {
         var cache = new ShareCacheStruct <T>();
         for (int i = _lst.Count - 1; i > _lst.Count - delOneTime; i--)
         {
             cache.Delete(_lst[i]);
         }
     }
 }
Exemple #9
0
        public override bool TakeAction()
        {
            var cacheSet = new ShareCacheStruct<UserApply>();
            UserApply apply = cacheSet.FindKey(guildID, ContextUser.UserID);
            if (apply != null)
            {
                cacheSet.Delete(apply);
            }

            return true;
        }
Exemple #10
0
        public override bool TakeAction()
        {
            var       cacheSet = new ShareCacheStruct <UserApply>();
            UserApply apply    = cacheSet.FindKey(guildID, ContextUser.UserID);

            if (apply != null)
            {
                cacheSet.Delete(apply);
            }

            return(true);
        }
Exemple #11
0
 public override bool TakeAction()
 {
     var cacheSet = new ShareCacheStruct<UserApply>();
     List<UserApply> applyArray = cacheSet.FindAll(m => m.GuildID==guildID);
     if (applyArray.Count > 0)
     {
         foreach (UserApply apply in applyArray)
         {
             cacheSet.Delete(apply);
         }
     }
     return true;
 }
Exemple #12
0
        public override bool TakeAction()
        {
            GameUser    gameUser      = new PersonalCacheStruct <GameUser>().FindKey(memberID);
            var         guildCacheSet = new ShareCacheStruct <GuildMember>();
            GuildMember member        = guildCacheSet.FindKey(guildID, memberID);

            if (member != null)
            {
                if (string.IsNullOrEmpty(gameUser.MercenariesID))
                {
                    return(false);
                }
                guildCacheSet.Delete(member);
                //gameUser.UserLocation = Location.City;
                gameUser.MercenariesID = string.Empty;
                //gameUser.Update();
                CombatHelper.RemoveGuildAbility(gameUser);
            }
            int totalDate = (ConfigEnvSet.GetInt("UserQueue.GuildMemberDel") * 60 * 60);
            List <UserQueue> queueArray = new PersonalCacheStruct <UserQueue>().FindAll(memberID, m => m.QueueType == QueueType.TuiChuGongHui);

            if (queueArray.Count > 0)
            {
                //new UserQueue().ReLoadUser(memberID);
                queueArray = new PersonalCacheStruct <UserQueue>().FindAll(memberID, m => m.QueueType == QueueType.TuiChuGongHui);
            }
            if (queueArray.Count > 0)
            {
                UserQueue queue = queueArray[0];
                queue.Timing        = DateTime.Now;
                queue.TotalColdTime = totalDate;
                queue.ColdTime      = totalDate;
                //queue.Update();
            }
            else
            {
                UserQueue userQueue = new UserQueue()
                {
                    QueueID       = Guid.NewGuid().ToString(),
                    QueueName     = QueueType.TuiChuGongHui.ToString(),
                    QueueType     = QueueType.TuiChuGongHui,
                    TotalColdTime = totalDate,
                    ColdTime      = totalDate,
                    Timing        = DateTime.Now,
                    IsSuspend     = false,
                    UserID        = ContextUser.UserID
                };
                new PersonalCacheStruct <UserQueue>().Add(userQueue);
            }
            return(true);
        }
Exemple #13
0
        public override bool TakeAction()
        {
            GameUser gameUser = new GameDataCacheSet<GameUser>().FindKey(memberID);
            var guildCacheSet = new ShareCacheStruct<GuildMember>();
            GuildMember member = guildCacheSet.FindKey(guildID, memberID);
            if (member != null)
            {
                if (string.IsNullOrEmpty(gameUser.MercenariesID))
                {
                    return false;
                }
                guildCacheSet.Delete(member);
                //gameUser.UserLocation = Location.City;
                gameUser.MercenariesID = string.Empty;
                //gameUser.Update();
                CombatHelper.RemoveGuildAbility(gameUser);
            }
            int totalDate = (ConfigEnvSet.GetInt("UserQueue.GuildMemberDel") * 60 * 60);
            List<UserQueue> queueArray = new GameDataCacheSet<UserQueue>().FindAll(memberID, m => m.QueueType == QueueType.TuiChuGongHui);
            if (queueArray.Count > 0)
            {
                //new UserQueue().ReLoadUser(memberID);
                queueArray = new GameDataCacheSet<UserQueue>().FindAll(memberID, m => m.QueueType == QueueType.TuiChuGongHui);
            }
            if (queueArray.Count > 0)
            {
                UserQueue queue = queueArray[0];
                queue.Timing = DateTime.Now;
                queue.TotalColdTime = totalDate;
                queue.ColdTime = totalDate;
                //queue.Update();
            }
            else
            {
                UserQueue userQueue = new UserQueue()
                {
                    QueueID = Guid.NewGuid().ToString(),
                    QueueName = QueueType.TuiChuGongHui.ToString(),
                    QueueType = QueueType.TuiChuGongHui,
                    TotalColdTime = totalDate,
                    ColdTime = totalDate,
                    Timing = DateTime.Now,
                    IsSuspend = false,
                    UserID = ContextUser.UserID
                };
                new GameDataCacheSet<UserQueue>().Add(userQueue);

            }
            return true;
        }
Exemple #14
0
        public override bool TakeAction()
        {
            var cacheSet = new ShareCacheStruct <UserApply>();
            List <UserApply> applyArray = cacheSet.FindAll(m => m.GuildID == guildID);

            if (applyArray.Count > 0)
            {
                foreach (UserApply apply in applyArray)
                {
                    cacheSet.Delete(apply);
                }
            }
            return(true);
        }
Exemple #15
0
 void doAdd_delById(string parm)
 {
     string[] ids = parm.Split(',');
     for (int i = 0; i < ids.Length; ++i)
     {
         var         urCache = new ShareCacheStruct <UserRanking>();
         int         id      = int.Parse(ids[i]);
         UserRanking ur      = urCache.FindKey(id);
         if (ur != null)
         {
             urCache.Delete(ur);             // delete form cache and redis.
         }
     }
     RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString());
 }
Exemple #16
0
 public void SendNotice(GameNotice notice, bool isRemove)
 {
     try
     {
         var        cacheSet   = new ShareCacheStruct <GameNotice>();
         GameNotice gameNotice = cacheSet.FindKey(notice.NoticeID);
         if (isRemove)
         {
             if (gameNotice != null)
             {
                 cacheSet.Delete(gameNotice);
             }
         }
         else
         {
             if (gameNotice == null)
             {
                 gameNotice          = new GameNotice();
                 gameNotice.NoticeID = Guid.NewGuid().ToString();
                 cacheSet.Add(gameNotice);
                 gameNotice = cacheSet.FindKey(gameNotice.NoticeID);
             }
             gameNotice.Title       = notice.Title;
             gameNotice.Content     = notice.Content;
             gameNotice.ExpiryDate  = notice.ExpiryDate;
             gameNotice.IsTop       = notice.IsTop;
             gameNotice.IsBroadcast = notice.IsBroadcast;
             gameNotice.Creater     = notice.Creater;
             gameNotice.CreateDate  = notice.CreateDate;
             gameNotice.NoticeType  = notice.NoticeType;
             if (gameNotice.IsBroadcast)
             {
                 var broadcastService = new TjxBroadcastService(null);
                 var msg = broadcastService.Create(NoticeType.System, gameNotice.Content);
                 broadcastService.Send(msg);
             }
         }
     }
     catch (Exception ex)
     {
         new BaseLog().SaveLog("保存公告出错:", ex);
         throw;
     }
 }
Exemple #17
0
        string delUserRanking(string parm)
        {
            doAdd_black(parm);
            List <UserRanking> lst     = RankingFactorNew.Singleton().get <UserRanking>(typeof(RankingScore).ToString());
            List <UserRanking> delList = new List <UserRanking>();

            if (null != lst && lst.Count != 0)
            {
                string [] ids = parm.Split(',');
                for (int i = 0; i < ids.Length; ++i)
                {
                    int id = int.Parse(ids[i]) - 1;
                    if (id >= lst.Count)
                    {
                        continue;
                    }

                    delList.Add(lst[id]);
                }
            }
            else
            {
                return("排行榜正在更新或为空");
            }
            if (delList.Count > 0)
            {
                var cache = new ShareCacheStruct <UserRanking>();
                resultSTR = "删除的玩家数据:{";
                foreach (var v in delList)
                {
                    cache.Delete(v);
                    resultSTR += v.UserName + ":" + v.Score + ",";
                }
                resultSTR += "}";

                RankingFactorNew.Singleton().Refresh <UserRanking>(typeof(RankingScore).ToString());
            }
            else
            {
                resultSTR = "要删除的数据不存在";
            }
            return(resultSTR);
        }
Exemple #18
0
        /// <summary>
        /// 增加仇敌
        /// </summary>
        /// <param name="user"></param>
        /// <param name="toUser"></param>
        private static void AddFoe(GameUser user, GameUser toUser)
        {
            var cacheSet      = new ShareCacheStruct <UserFriends>();
            var friends       = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.Friend);
            var choudiFriends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);

            if (friends == null && choudiFriends == null)
            {
                var list = cacheSet.FindAll(s => s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);
                if (list.Count >= 50)
                {
                    list.QuickSort((x, y) =>
                    {
                        if (x == null && y == null)
                        {
                            return(0);
                        }
                        if (x != null && y == null)
                        {
                            return(1);
                        }
                        if (x == null)
                        {
                            return(-1);
                        }
                        return((x.FightTime).CompareTo(y.FightTime));
                    });
                    int count = list.Count - 49 + 1;
                    for (int i = 0; i < count; i++)
                    {
                        cacheSet.Delete(list[i]);
                    }
                }
                var userFriends = new UserFriends();
                userFriends.UserID     = toUser.UserID;
                userFriends.FriendID   = user.UserID;
                userFriends.FightTime  = DateTime.Now;
                userFriends.FriendType = FriendType.ChouDi;
                userFriends.ChatTime   = DateTime.Now;
                cacheSet.Add(userFriends);
            }
        }
Exemple #19
0
        public void RemoveeCache()
        {
            var watch = Stopwatch.StartNew();
            var cache = new ShareCacheStruct <ChildData>();
            int key   = (int)cache.GetNextNo();
            var data  = cache.FindKey(key);

            if (data == null)
            {
                data = new ChildData()
                {
                    ChildId = key, Age = 20
                };
                Assert.IsTrue(cache.Add(data), "add cache faild.");
            }
            Assert.IsTrue(cache.Delete(data), "delete cache faild");
            cache.UnLoad();
            data = cache.FindKey(key);
            Assert.IsTrue(data == null, "delete cache faild.");
            WaitEnd(watch);
        }
Exemple #20
0
        void doAdd_delByIndex(string parm)
        {
            string[] p            = parm.Split(',');
            int      rankingIndex = int.Parse(p[0]) - 1;

            UserRanking ur = RankingFactorNew.Singleton().getRankingData <UserRanking, RankingScore>(rankingIndex);

            if (null != ur)
            {
                var cache = new ShareCacheStruct <UserRanking>();
                cache.Delete(ur);

                var      cachePersonal = new PersonalCacheStruct <GameUser>();
                GameUser gu            = cachePersonal.FindKey(ur.UserID.ToString());

                var           black = new ShareCacheStruct <BlackListData>();
                BlackListData bld   = UR2BLD(gu);
                black.AddOrUpdate(bld);
            }
            processSort("ranking");
        }
Exemple #21
0
        void doDelete()
        {
            var    urCatch  = new ShareCacheStruct <UserRanking>();
            string paramStr = requestPack.param;

            string[] arrStr = paramStr.Split(',');
            if (arrStr[0] == "byName")
            {
                //  var deleteLst = urCatch.FindAll(o => o.UserName.Contains(arrStr[1]));
                //  foreach (UserRanking ur in deleteLst)
                //  {
                //      urCatch.Delete(ur);
                //  }
            }
            else if (arrStr[0] == "byScore")
            {
                var deleteLst = urCatch.FindAll(o => o.Score > int.Parse(arrStr[1]));
                System.Console.WriteLine("deleteLst Count:{0}", deleteLst.Count);
                foreach (UserRanking ur in deleteLst)
                {
                    urCatch.Delete(ur);
                }
            }
        }
Exemple #22
0
        string processDelete(string parm)
        {
            string info = "";

            string[] p            = parm.Split(',');
            string   deleteWhitch = p[0];
            int      deleteIndex  = int.Parse(p[1]) - 1;

            if ("ranking" == deleteWhitch)
            {
                UserRanking ur = RankingFactorNew.Singleton().getRankingData <UserRanking, RankingScore>(deleteIndex);
                if (ur == null)
                {
                    info = "没有找到要删除的数据";
                }
                else
                {
                    var cache = new ShareCacheStruct <UserRanking>();
                    cache.Delete(ur);
                    info = "删除数据成功";
                }
            }
            return(info);
        }
Exemple #23
0
        string processDelete(string parm)
        {
            string info = "";
            string[] p = parm.Split(',');
            string deleteWhitch = p[0];
            int deleteIndex = int.Parse(p[1]);

            if("ranking"==deleteWhitch)
            {
                  UserRanking ur =   RankingFactorNew.Singleton().getRankingData<UserRanking, RankingScore>(deleteIndex);
                  if(ur==null)
                  {
                      info = "没有找到要删除的数据";
                  }
                  else
                  {
                      var cache = new ShareCacheStruct<UserRanking>();
                      cache.Delete(ur);
                      info = "删除数据成功";
                  }
            }
            return info;
        }
Exemple #24
0
        string delUserRanking(string parm)
        {
            doAdd_black(parm);
            List<UserRanking> lst = RankingFactorNew.Singleton().get<UserRanking>(typeof(RankingScore).ToString());
            List<UserRanking> delList = new List<UserRanking>();
            if(null != lst && lst.Count!=0)
            {
                string []ids = parm.Split(',');
                for(int i=0; i<ids.Length; ++i)
                {
                    int id = int.Parse(ids[i]) - 1;
                    if (id >= lst.Count) continue;

                    delList.Add(lst[id]);
                }
            }
            else
            {
                return "排行榜正在更新或为空";
            }
            if(delList.Count>0)
            {
                var cache = new ShareCacheStruct<UserRanking>();
                resultSTR = "删除的玩家数据:{";
                foreach (var v in delList)
                {
                    cache.Delete(v);
                    resultSTR += v.UserName + ":" + v.Score + ",";
                }
                resultSTR += "}";

                RankingFactorNew.Singleton().Refresh<UserRanking>(typeof(RankingScore).ToString());
            }
            else
            {
                resultSTR = "要删除的数据不存在";
            }
            return resultSTR;
        }
Exemple #25
0
        public override bool TakeAction()
        {
            GuildMember member = new ShareCacheStruct<GuildMember>().FindKey(guildID, ContextUser.UserID);
            if (member != null && member.PostType == PostType.Member)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6007_AuditPermissions;
                return false;
            }

            List<GuildMember> memberArray = new ShareCacheStruct<GuildMember>().FindAll(m => m.GuildID == guildID);
            UserGuild guildInfo = new ShareCacheStruct<UserGuild>().FindKey(guildID);
            if (guildInfo != null)
            {
                GuildLvInfo guildLvInfo = new ShareCacheStruct<GuildLvInfo>().FindKey(guildInfo.GuildLv);
                if (guildLvInfo != null)
                {
                    int maxPeople = MathUtils.Addition(guildInfo.AddMember, guildLvInfo.MaxPeople);
                    if (memberArray.Count > 0 && memberArray.Count >= maxPeople)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St6019_GuildMaxPeople;
                        return false;
                    }
                }
            }
            GameUser userInfo = UserCacheGlobal.CheckLoadUser(memberID);
            if (userInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return false;

            }
            var memberList = new ShareCacheStruct<GuildMember>().FindAll(s => s.UserID == memberID);
            if (memberList.Count > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6019_AddGuild;
                return false;
            }

            GuildMember gMember = new GuildMember()
            {
                GuildID = guildID,
                UserID = memberID,
                PostType = PostType.Member,
                Contribution = 0,
                TotalContribution = 0,
                IncenseNum = 0,
                DevilNum = 0,
                IsDevil = 0,
                InsertDate = DateTime.Now
            };
            new ShareCacheStruct<GuildMember>().Add(gMember);
            userInfo.MercenariesID = guildID;
            CombatHelper.LoadGuildAbility(userInfo.UserID); //加载公会技能

            var cacheSet = new ShareCacheStruct<UserApply>();
            List<UserApply> appliesArray = cacheSet.FindAll(m => m.UserID == memberID);
            foreach (UserApply apply in appliesArray)
            {
                cacheSet.Delete(apply);
            }

            return true;
        }
Exemple #26
0
        public override bool TakeAction()
        {
            GuildMember member = new ShareCacheStruct <GuildMember>().FindKey(guildID, ContextUser.UserID);

            if (member != null && member.PostType == PostType.Member)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6007_AuditPermissions;
                return(false);
            }

            List <GuildMember> memberArray = new ShareCacheStruct <GuildMember>().FindAll(m => m.GuildID == guildID);
            UserGuild          guildInfo   = new ShareCacheStruct <UserGuild>().FindKey(guildID);

            if (guildInfo != null)
            {
                GuildLvInfo guildLvInfo = new ShareCacheStruct <GuildLvInfo>().FindKey(guildInfo.GuildLv);
                if (guildLvInfo != null)
                {
                    int maxPeople = MathUtils.Addition(guildInfo.AddMember, guildLvInfo.MaxPeople);
                    if (memberArray.Count > 0 && memberArray.Count >= maxPeople)
                    {
                        ErrorCode = LanguageManager.GetLang().ErrorCode;
                        ErrorInfo = LanguageManager.GetLang().St6019_GuildMaxPeople;
                        return(false);
                    }
                }
            }
            GameUser userInfo = UserCacheGlobal.CheckLoadUser(memberID);

            if (userInfo == null)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            var memberList = new ShareCacheStruct <GuildMember>().FindAll(s => s.UserID == memberID);

            if (memberList.Count > 0)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St6019_AddGuild;
                return(false);
            }

            GuildMember gMember = new GuildMember()
            {
                GuildID           = guildID,
                UserID            = memberID,
                PostType          = PostType.Member,
                Contribution      = 0,
                TotalContribution = 0,
                IncenseNum        = 0,
                DevilNum          = 0,
                IsDevil           = 0,
                InsertDate        = DateTime.Now
            };

            new ShareCacheStruct <GuildMember>().Add(gMember);
            userInfo.MercenariesID = guildID;
            CombatHelper.LoadGuildAbility(userInfo.UserID); //加载公会技能

            var cacheSet = new ShareCacheStruct <UserApply>();
            List <UserApply> appliesArray = cacheSet.FindAll(m => m.UserID == memberID);

            foreach (UserApply apply in appliesArray)
            {
                cacheSet.Delete(apply);
            }

            return(true);
        }
Exemple #27
0
 public override bool TakeAction()
 {
     GuildMember member = new ShareCacheStruct<GuildMember>().FindKey(ContextUser.MercenariesID, ContextUser.UserID);
     if (member != null)
     {
         if (member.PostType == PostType.Member)
         {
             ErrorCode = LanguageManager.GetLang().ErrorCode;
             ErrorInfo = LanguageManager.GetLang().St6007_AuditPermissions;
             return false;
         }
         else
         {
             var cacheSet = new ShareCacheStruct<UserApply>();
             List<UserApply> userApplyArray = cacheSet.FindAll(m => m.GuildID == member.GuildID);
             foreach (UserApply apply in userApplyArray)
             {
                 List<GuildMember> gMemberArray = new ShareCacheStruct<GuildMember>().FindAll(m => m.UserID == apply.UserID);
                 if (gMemberArray.Count > 0)
                 {
                     cacheSet.Delete(apply);
                 }
             }
             applyArray = userApplyArray.GetPaging(pageIndex, pageSize, out pageCount);
         }
     }
     return true;
 }
Exemple #28
0
 /// <summary>
 /// 增加仇敌
 /// </summary>
 /// <param name="user"></param>
 /// <param name="toUser"></param>
 private static void AddFoe(GameUser user, GameUser toUser)
 {
     var cacheSet = new ShareCacheStruct<UserFriends>();
     var friends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.Friend);
     var choudiFriends = cacheSet.Find(s => s.FriendID == user.UserID && s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);
     if (friends == null && choudiFriends == null)
     {
         var list = cacheSet.FindAll(s => s.UserID == toUser.UserID && s.FriendType == FriendType.ChouDi);
         if (list.Count >= 50)
         {
             list.QuickSort((x, y) =>
             {
                 if (x == null && y == null) return 0;
                 if (x != null && y == null) return 1;
                 if (x == null) return -1;
                 return (x.FightTime).CompareTo(y.FightTime);
             });
             int count = list.Count - 49 + 1;
             for (int i = 0; i < count; i++)
             {
                 cacheSet.Delete(list[i]);
             }
         }
         var userFriends = new UserFriends();
         userFriends.UserID = toUser.UserID;
         userFriends.FriendID = user.UserID;
         userFriends.FightTime = DateTime.Now;
         userFriends.FriendType = FriendType.ChouDi;
         userFriends.ChatTime = DateTime.Now;
         cacheSet.Add(userFriends, GameEnvironment.CacheGlobalPeriod);
     }
 }
        public void SendNotice(GameNotice notice, bool isRemove)
        {
            try
            {
                var cacheSet = new ShareCacheStruct<GameNotice>();
                GameNotice gameNotice = cacheSet.FindKey(notice.NoticeID);
                if (isRemove)
                {
                    if (gameNotice != null)
                    {
                        cacheSet.Delete(gameNotice);
                    }
                }
                else
                {
                    if (gameNotice == null)
                    {
                        gameNotice = new GameNotice();
                        gameNotice.NoticeID = Guid.NewGuid().ToString();
                        cacheSet.Add(gameNotice);
                        gameNotice = cacheSet.FindKey(gameNotice.NoticeID);
                    }
                    gameNotice.Title = notice.Title;
                    gameNotice.Content = notice.Content;
                    gameNotice.ExpiryDate = notice.ExpiryDate;
                    gameNotice.IsTop = notice.IsTop;
                    gameNotice.IsBroadcast = notice.IsBroadcast;
                    gameNotice.Creater = notice.Creater;
                    gameNotice.CreateDate = notice.CreateDate;
                    gameNotice.NoticeType = notice.NoticeType;
                    if (gameNotice.IsBroadcast)
                    {
                        var broadcastService = new TjxBroadcastService(null);
                        var msg = broadcastService.Create(NoticeType.System, gameNotice.Content);
                        broadcastService.Send(msg);
                    }

                }
            }
            catch (Exception ex)
            {
                new BaseLog().SaveLog("保存公告出错:", ex);
                throw;
            }
        }