Exemple #1
0
        public static void ApproveClub(int clubID, bool approve)
        {
            var club = GetClubInfo(clubID);

            if (club != null)
            {
                club.IsActive   = approve;
                club.UpdateDate = DateTime.Now;

                if (approve)
                {
                    club.IsAppliable = true;
                }

                SaveClub(club);

                var uc = new UserClub();
                uc.ClubUid        = clubID;
                uc.JoinClubDate   = DateTime.Now;
                uc.FromDate       = DateTime.Now;
                uc.IsActive       = true;
                uc.Responsibility = (int)Responsibility.Manager;
                uc.Userid         = club.ManagerUid;
                uc.UserName       = club.ManagerUserName;

                SaveUserClub(uc);

                ClubSysPrivateMessage.SendMessage(clubID, string.Empty, ClubSysMessageType.ApproveClub);
            }
            else
            {
                throw new Exception("Club not exist.");
            }
        }
Exemple #2
0
        //internal static string SavePic(HttpPostedFile file)
        //{
        //    FileInfo fi = new FileInfo(file.FileName);

        //    string fileName = string.Format("{0}{1}", Guid.NewGuid().ToString(), fi.Extension);

        //    string fullPath = Path.Combine(ConfigGlobal.ClubLogoPath, fileName);

        //    file.SaveAs(fullPath);

        //    return fileName;
        //}

        public static void ApplyClub(string fullName, string shortName, string slogan, string desc, int creatorUid,
                                     string creatorUserName)
        {
            var club = new Club();

            club.FullName        = fullName;
            club.ShortName       = shortName;
            club.Slogan          = slogan;
            club.LogoName        = ConfigGlobal.DefaultClubLogoName;
            club.RankLevel       = ConfigGlobal.ClubDefaultRankLevel;
            club.RankScore       = 0;
            club.Description     = desc;
            club.CreatorUid      = creatorUid;
            club.CreatorUserName = creatorUserName;
            club.ManagerUid      = creatorUid;
            club.ManagerUserName = creatorUserName;
            club.CreateDate      = DateTime.Now;
            club.UpdateDate      = DateTime.Now;
            club.Fortune         = 0;
            club.MemberCredit    = 0;
            club.MemberFortune   = 0;
            club.MemberLoyalty   = 0;

            InsertClub(club);

            club = GetClubInfo(fullName);
            if (club != null)
            {
                ClubSysPrivateMessage.SendMessage(club.ID.Value, creatorUserName, ClubSysMessageType.ApplyClub);
            }
        }
Exemple #3
0
        public static void ApplyJoinClub(int userID, string userName, int clubID)
        {
            var ah = new ApplyHistory();

            ah.Userid    = userID;
            ah.UserName  = userName;
            ah.ClubUid   = clubID;
            ah.ApplyDate = DateTime.Now;

            ClubLogic.SaveApplyHistory(ah);

            ClubSysPrivateMessage.SendMessage(clubID, userName, ClubSysMessageType.ApplyJoinClub);
        }
Exemple #4
0
        public static void ApproveJoinClub(int applyHistoryId, bool approved, string operatorUserName)
        {
            var ah = ClubLogic.GetApplyHistory(applyHistoryId);

            ah.IsAccepted = approved;

            ClubLogic.SaveApplyHistory(ah);

            var ch = new ClubHistory();

            ch.ClubID           = ah.ClubUid;
            ch.ActionUserName   = ah.UserName;
            ch.OperatorUserName = operatorUserName;
            ch.ActionDate       = DateTime.Now;

            if (approved)
            {
                //insert user club
                var uc = new UserClub();

                uc.ClubUid        = ah.ClubUid;
                uc.JoinClubDate   = DateTime.Now;
                uc.FromDate       = DateTime.Now;
                uc.IsActive       = true;
                uc.Responsibility = (int)Responsibility.Member;
                uc.Userid         = ah.Userid;
                uc.UserName       = ah.UserName;

                ClubLogic.SaveUserClub(uc);

                ch.ActionType        = ClubHistoryActionType.JoinClub.ToString();
                ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.JoinClub, null);
            }
            else
            {
                ch.ActionType        = ClubHistoryActionType.RejectJoinClub.ToString();
                ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.RejectJoinClub, null);
            }

            ClubLogic.SaveClubHistory(ch);

            if (approved)
            {
                ClubSysPrivateMessage.SendMessage(ah.ClubUid, ah.UserName, ClubSysMessageType.ApproveJoinClub);
            }
            else
            {
                ClubSysPrivateMessage.SendMessage(ah.ClubUid, ah.UserName, ClubSysMessageType.RejectJoinClub);
            }
        }
Exemple #5
0
        public static bool LeaveClub(int userID, int clubID, bool isKicked, string kickUserName)
        {
            var uc = ClubLogic.GetActiveUserClub(userID, clubID);

            if (uc != null)
            {
                uc.ToDate   = DateTime.Now;
                uc.IsActive = false;

                if (uc.Responsibility == (int)Responsibility.Manager)
                {
                    return(false);
                }

                ClubLogic.SaveUserClub(uc);

                var ch = new ClubHistory();
                ch.ClubID         = clubID;
                ch.ActionUserName = uc.UserName;

                if (isKicked)
                {
                    ch.ActionType        = ClubHistoryActionType.MandatoryLeaveClub.ToString();
                    ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(
                        ClubHistoryActionType.MandatoryLeaveClub, null);
                    ch.OperatorUserName = kickUserName;
                }
                else
                {
                    ch.ActionType        = ClubHistoryActionType.LeaveClub.ToString();
                    ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.LeaveClub, null);
                    ch.OperatorUserName  = uc.UserName;
                }

                ClubLogic.SaveClubHistory(ch);

                if (isKicked)
                {
                    ClubSysPrivateMessage.SendMessage(clubID, uc.UserName, ClubSysMessageType.MandatoryLeaveClub);
                }
                else
                {
                    ClubSysPrivateMessage.SendMessage(clubID, uc.UserName, ClubSysMessageType.LeaveClub);
                }

                return(true);
            }
            return(false);
        }
Exemple #6
0
        public static void TransferMemberExtcredit(int clubID, int fromUserID, int toUserID, float extCredit,
                                                   int extCreditType)
        {
            //UserClub ucFrom = ClubLogic.GetActiveUserClub(fromUserID, clubID);
            //UserClub ucTo = ClubLogic.GetActiveUserClub(toUserID, clubID);

            var userFrom = Users.GetUserInfo(fromUserID);
            var userTo   = Users.GetUserInfo(toUserID);

            if (fromUserID != toUserID)
            {
                if (extCredit > Users.GetUserExtCredits(fromUserID, extCreditType))
                {
                    throw new Exception("Insufficient Founds");
                }

                var list = ClubLogic.GetUserManagedClubs(fromUserID);
                if (list == null || list.Count <= 0)
                {
                    throw new Exception("No privilege of tranfer");
                }

                // Transfer Logic

                Users.UpdateUserExtCredits(fromUserID, extCreditType, -extCredit);
                Users.UpdateUserExtCredits(toUserID, extCreditType, extCredit);

                // Club History Log & SMS

                var ch = new ClubHistory();
                ch.ClubID            = clubID;
                ch.ActionUserName    = userTo.Username.Trim();
                ch.ActionType        = ClubHistoryActionType.TransferExtcredit.ToString();
                ch.ActionDescription = ClubLogic.BuildClubHistoryActionDesc(ClubHistoryActionType.TransferExtcredit,
                                                                            userTo.Username.Trim(), extCredit.ToString(), "枪手币");
                ch.OperatorUserName = userFrom.Username.Trim();

                ClubLogic.SaveClubHistory(ch);

                ClubSysPrivateMessage.SendMessage(clubID, userTo.Username.Trim(), ClubSysMessageType.TransferExtcredit,
                                                  userFrom.Username.Trim(), extCredit.ToString("N0"), "枪手币");
            }
            else
            {
                throw new Exception("Can't transfer to yourself");
            }
        }