Exemplo n.º 1
0
        protected void rptCard_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "SetCurrent")
            {
                var userNumID = int.Parse(e.CommandArgument.ToString());

                var un = PlayerStrip.GetUserNumber(userNumID);

                if (un.UserID == CurrentUserID && un.IsActive && !un.IsInUse)
                {
                    PlayerStrip.UpdatePlayerCurrentNum(CurrentUserID, userNumID);

                    var script = "alert('球衣已被换上'); window.location.href = window.location.href;";
                    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "SetCurrentSucceed", script, true);
                }
                else
                {
                    var script = "alert('您不能换上该球衣');";
                    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "SetCurrentFailed", script, true);
                }
            }
            else if (e.CommandName == "CancelCurrent")
            {
                var userNumID = int.Parse(e.CommandArgument.ToString());

                var un = PlayerStrip.GetUserNumber(userNumID);

                if (un.UserID == CurrentUserID && un.IsActive && un.IsInUse)
                {
                    PlayerStrip.RemovePlayerCurrentNum(CurrentUserID, userNumID);

                    var script = "alert('球衣已被换下'); window.location.href = window.location.href;";
                    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "SetCurrentSucceed", script, true);
                }
                else
                {
                    var script = "alert('您不能换下该球衣');";
                    Page.ClientScript.RegisterClientScriptBlock(typeof(string), "SetCurrentFailed", script, true);
                }
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (userid != -1)
                {
                    if (Request.Form["FusionResult"] == "start")
                    {
                        responseResult = userid.ToString();
                    }
                    else
                    {
                        //get request info
                        var leftCardID   = Request.Form["LeftCardID"];
                        var rightCardID  = Request.Form["RightCardID"];
                        var fusionResult = Request.Form["FusionResult"];
                        var authKey      = Request.Form["AuthKey"];

                        if (!string.IsNullOrEmpty(leftCardID) && !string.IsNullOrEmpty(rightCardID) &&
                            !string.IsNullOrEmpty(fusionResult) && !string.IsNullOrEmpty(authKey))
                        {
                            int card1, card2, result;

                            if (int.TryParse(leftCardID, out card1) && int.TryParse(rightCardID, out card2) &&
                                int.TryParse(fusionResult, out result))
                            {
                                if (ValidateAuthKey(card1.ToString(), card2.ToString(), userid.ToString(), authKey))
                                {
                                    var un1 = PlayerStrip.GetUserNumber(card1);
                                    var un2 = PlayerStrip.GetUserNumber(card2);

                                    if (un1 != null && un2 != null && un1.UserID == userid && un2.UserID == userid)
                                    {
                                        if (!un1.IsActive && !un2.IsActive &&
                                            un1.ArsenalPlayerGuid.Value == un2.ArsenalPlayerGuid.Value)
                                        {
                                            //rule 1 -- two inactive cards of same player

                                            if (fusionResult == "1")
                                            {
                                                //remove two cards and insert 1 video

                                                UserVideo.ConsolidateCards(userid, username, card1, card2);
                                                PlayerLog.LogHistory(userid, username,
                                                                     PlayerHistoryType.ConsolidateCards,
                                                                     new ConsolidateCardsDesc(un1, un2).Generate());

                                                responseResult = "1";
                                            }
                                        }
                                        else if (un1.IsActive != un2.IsActive)
                                        {
                                            //rule 2 -- one active card and one inactive card

                                            if (fusionResult == "2")
                                            {
                                                //remove two cards and insert 1 video

                                                UserVideo.ConsolidateCards(userid, username, card1, card2);
                                                PlayerLog.LogHistory(userid, username,
                                                                     PlayerHistoryType.ConsolidateCards,
                                                                     new ConsolidateCardsDesc(un1, un2).Generate());

                                                responseResult = "1";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            Response.Write("ServerMessage=" + responseResult);
        }
Exemplo n.º 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (ClubID > 0)
            {
                //output club info

                var club = ClubLogic.GetClubInfo(ClubID);

                if (club != null)
                {
                    var ra = new RankAlgorithm(club);

                    var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    xmlContent.AppendFormat("<RankChart ClubID=\"{0}\" RankPoint=\"{1}\">", club.ID, club.RankScore);
                    xmlContent.AppendFormat("<RankItem name=\"会员数\" value=\"{0}\" />", ra.MemberCountRank);
                    xmlContent.AppendFormat("<RankItem name=\"总财富\" value=\"{0}\" />", ra.ClubFortuneRank);
                    xmlContent.AppendFormat("<RankItem name=\"总积分\" value=\"{0}\" />", ra.MemberCreditRank);
                    xmlContent.AppendFormat("<RankItem name=\"总RP值\" value=\"{0}\" />", ra.MemberRPRank);
                    xmlContent.AppendFormat("<RankItem name=\"装备数\" value=\"{0}\" /></RankChart>",
                                            ra.MemberEquipmentRank);
                    Response.Write(xmlContent.ToString());
                }
            }
            else if (UserID > 0)
            {
                //output player info and public video info

                var player = PlayerStrip.GetPlayerInfo(UserID);

                if (player != null)
                {
                    var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    var playerLv   = player.Shirt;

                    if (player.Shorts < playerLv)
                    {
                        playerLv = player.Shorts;
                    }

                    if (player.Sock < playerLv)
                    {
                        playerLv = player.Sock;
                    }

                    xmlContent.AppendFormat("<UserItems username=\"{0}\" userid=\"{1}\" userlv=\"{2}\" ",
                                            player.UserName, player.UserID,
                                            ((playerLv > ConfigGlobal.PlayerMaxLv) ? ConfigGlobal.PlayerMaxLv + "+" : playerLv.ToString()));
                    var CardCount     = PlayerStrip.GetMyNumbers(UserID).Count;
                    var VideoCount    = UserVideo.GetUserVideosByUserID(UserID).Count;
                    var InactiveCount =
                        PlayerStrip.GetMyNumbers(UserID)
                        .FindAll(delegate(Card c) { return(!c.ArsenalPlayerGuid.HasValue); })
                        .Count;

                    xmlContent.AppendFormat(
                        "ShirtCount=\"{0}\" ShortsCount=\"{1}\" SockCount=\"{2}\" CardCount=\"{3}\" VideoCount=\"{4}\">",
                        player.Shirt, player.Shorts, player.Sock, CardCount - InactiveCount, VideoCount + InactiveCount);

                    xmlContent.AppendFormat("<UserVideo>");

                    //DataView dv = Service.UserVideo.GetUserPublicVideo(UserID);
                    var list = UserVideo.GetUserVideosByUserID(UserID)
                               .FindAll(delegate(UserVideo uv) { return(uv.IsPublic); });

                    foreach (var uv in list)
                    {
                        object _value;

                        var v = Video.Cache.Load(uv.VideoGuid);

                        if (v != null)
                        {
                            var p = Player.Cache.Load(v.GoalPlayerGuid.Value);

                            if (p != null)
                            {
                                xmlContent.Append("<VideoItem ");

                                // build UserVideo xml info
                                foreach (
                                    var properInfo in
                                    uv.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                                {
                                    // remove the property VideoGuid of UserVideo
                                    if (!properInfo.Name.Equals("VideoGuid"))
                                    {
                                        _value = properInfo.GetValue(uv, null);
                                        if (_value == null)
                                        {
                                            _value = string.Empty;
                                        }

                                        xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                                HttpUtility.HtmlAttributeEncode(_value.ToString()));
                                    }
                                }

                                // build ArsenalVideo xml info
                                foreach (
                                    var properInfo in
                                    v.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                                {
                                    _value = properInfo.GetValue(v, null);
                                    if (_value == null)
                                    {
                                        _value = string.Empty;
                                    }

                                    xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                            HttpUtility.HtmlAttributeEncode(_value.ToString()));
                                }

                                // build ArsenalPlayer xml info
                                foreach (
                                    var properInfo in
                                    p.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                                {
                                    _value = properInfo.GetValue(p, null);
                                    if (_value == null)
                                    {
                                        _value = string.Empty;
                                    }

                                    xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                            HttpUtility.HtmlAttributeEncode(_value.ToString()));
                                }

                                xmlContent.Append("></VideoItem>");
                            }
                        }
                    }

                    xmlContent.Append("</UserVideo>");

                    xmlContent.Append("<UserCard>");
                    var cards = PlayerStrip.GetMyNumbers(UserID);
                    cards.RemoveAll(delegate(Card un) { return(!un.ArsenalPlayerGuid.HasValue); });

                    foreach (var c in cards)
                    {
                        xmlContent.Append("<CardItem ");
                        xmlContent.AppendFormat("UserNumberID=\"{0}\" IsActive=\"{1}\" ", c.ID, c.IsActive);

                        var    p = Player.Cache.Load(c.ArsenalPlayerGuid.Value);
                        object _value;

                        foreach (
                            var properInfo in p.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                        {
                            _value = properInfo.GetValue(p, null);
                            if (_value == null)
                            {
                                _value = string.Empty;
                            }

                            xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                    HttpUtility.HtmlAttributeEncode(_value.ToString()));
                        }

                        xmlContent.Append("></CardItem>");
                    }
                    xmlContent.Append("</UserCard>");

                    xmlContent.Append("</UserItems>");

                    Response.Write(xmlContent.ToString());
                }
            }
            else if (PlayerGuid != null)
            {
                //output arsenal player info

                //DataRow rowInfo = Arsenal_Player.Cache.GetInfo(new Guid(PlayerGuid));
                var    p = Player.Cache.Load(new Guid(PlayerGuid));
                object _value;

                if (p != null)
                {
                    var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    xmlContent.Append("<PlayerInfo ");

                    foreach (var properInfo in p.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                    {
                        _value = properInfo.GetValue(p, null);
                        if (_value == null)
                        {
                            _value = string.Empty;
                        }

                        xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                HttpUtility.HtmlAttributeEncode(_value.ToString()));
                    }

                    xmlContent.Append("></PlayerInfo>");

                    Response.Write(xmlContent.ToString());
                }
            }
            else if (CardID > 0)
            {
                var c = PlayerStrip.GetUserNumber(CardID);

                if (c != null)
                {
                    //output arsenal player info
                    if (c.ArsenalPlayerGuid.HasValue)
                    {
                        //DataRow rowInfo = Arsenal_Player.Cache.GetInfo(c.ArsenalPlayerGuid.Value);
                        var    p = Player.Cache.Load(c.ArsenalPlayerGuid.Value);
                        object _value;

                        if (p != null)
                        {
                            var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                            xmlContent.AppendFormat("<CardInfo CardID=\"{0}\" ", CardID);

                            foreach (
                                var properInfo in p.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
                                )
                            {
                                _value = properInfo.GetValue(p, null);
                                if (_value == null)
                                {
                                    _value = string.Empty;
                                }

                                xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                        HttpUtility.HtmlAttributeEncode(_value.ToString()));
                            }

                            xmlContent.Append("></CardInfo>");

                            Response.Write(xmlContent.ToString());
                        }
                    }
                    else
                    {
                        var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        xmlContent.AppendFormat("<CardInfo CardID=\"{0}\" Legend=\"True\" />", CardID);
                        Response.Write(xmlContent.ToString());
                    }
                }
            }
            else if (UserVideoID > 0)
            {
                //output video info
                //DataRow rowInfo = Service.UserVideo.GetVideoInfoByUserVideoID(UserVideoID);
                try
                {
                    var uv = new UserVideo();
                    uv.UserVideoID = UserVideoID;
                    uv.Select();

                    object _value;

                    var v = Video.Cache.Load(uv.VideoGuid);

                    if (v != null)
                    {
                        var p = Player.Cache.Load(v.GoalPlayerGuid.Value);

                        if (p != null)
                        {
                            var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                            xmlContent.Append("<VideoInfo ");

                            // build UserVideo xml info
                            foreach (
                                var properInfo in
                                uv.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                            {
                                // remove the property VideoGuid of UserVideo
                                if (!properInfo.Name.Equals("VideoGuid"))
                                {
                                    _value = properInfo.GetValue(uv, null);
                                    if (_value == null)
                                    {
                                        _value = string.Empty;
                                    }

                                    xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                            HttpUtility.HtmlAttributeEncode(_value.ToString()));
                                }
                            }

                            // build ArsenalVideo xml info
                            foreach (
                                var properInfo in v.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
                                )
                            {
                                _value = properInfo.GetValue(v, null);
                                if (_value == null)
                                {
                                    _value = string.Empty;
                                }

                                xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                        HttpUtility.HtmlAttributeEncode(_value.ToString()));
                            }

                            // build ArsenalPlayer xml info
                            foreach (
                                var properInfo in p.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance)
                                )
                            {
                                _value = properInfo.GetValue(p, null);
                                if (_value == null)
                                {
                                    _value = string.Empty;
                                }

                                xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                        HttpUtility.HtmlAttributeEncode(_value.ToString()));
                            }

                            xmlContent.Append("></VideoInfo>");

                            Response.Write(xmlContent.ToString());
                        }
                    }
                }
                catch
                {
                }
            }
            else if (VideoGuid != null)
            {
                //DataRow rowInfo = Service.UserVideo.GetVideoInfoByVideoGuid(new Guid(VideoGuid));
                object _value;

                var v = Video.Cache.Load(new Guid(VideoGuid));

                if (v != null)
                {
                    var p = Player.Cache.Load(v.GoalPlayerGuid.Value);

                    if (p != null)
                    {
                        var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                        xmlContent.Append("<VideoInfo ");

                        // build ArsenalVideo xml info
                        foreach (
                            var properInfo in v.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                        {
                            _value = properInfo.GetValue(v, null);
                            if (_value == null)
                            {
                                _value = string.Empty;
                            }

                            xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                    HttpUtility.HtmlAttributeEncode(_value.ToString()));
                        }

                        // build ArsenalPlayer xml info
                        foreach (
                            var properInfo in p.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
                        {
                            _value = properInfo.GetValue(p, null);
                            if (_value == null)
                            {
                                _value = string.Empty;
                            }

                            xmlContent.AppendFormat("{0}=\"{1}\" ", properInfo.Name,
                                                    HttpUtility.HtmlAttributeEncode(_value.ToString()));
                        }

                        xmlContent.Append("></VideoInfo>");

                        Response.Write(xmlContent.ToString());
                    }
                }
            }
            else if (CurrArsenalPlayer)
            {
                var list = Player.Cache.PlayerList.FindAll(p => !p.IsLegend && !p.IsLoan && p.SquadNumber >= 0);

                list.Sort((p1, p2) => p1.SquadNumber - p2.SquadNumber);

                var xmlContent = new StringBuilder("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                xmlContent.Append("<CurrArsenalPlayer>");

                foreach (var p in list)
                {
                    xmlContent.AppendFormat(
                        "<PlayerInfo Guid=\"{0}\" DisplayName=\"{1}\" SquadNumber=\"{2}\" FaceURL=\"{3}\" />", p.ID,
                        p.DisplayName, p.SquadNumber, p.FaceURL);
                }
                xmlContent.Append("</CurrArsenalPlayer>");

                Response.Write(xmlContent.ToString());
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var result       = "false";
            var returnURL    = string.Empty;
            var responseText = string.Empty;

            using (var conn = ConfigGlobal.SQLConnectionStrings)
            {
                conn.Open();
                var trans = conn.BeginTransaction();

                try
                {
                    if (userid != -1)
                    {
                        if (Request.Form["CardID"] != null)
                        {
                            var unID    = -1;
                            var authKey = Request.Form["AuthKey"];

                            if (int.TryParse(Request.Form["CardID"], out unID))
                            {
                                if (PlayerStrip.ValidateAuthKey(unID.ToString(), string.Empty, authKey))
                                {
                                    if (PlayerStrip.CheckUserNumActiveCondition(userid, unID))
                                    {
                                        var un = PlayerStrip.GetUserNumber(unID);

                                        if (un.ArsenalPlayerGuid.HasValue)
                                        {
                                            //normal player card
                                            PlayerStrip.SetCardAcitve(userid, unID);

                                            PlayerLog.LogHistory(userid, username, PlayerHistoryType.ActivateCard,
                                                                 new ActivateCardDesc(un).Generate());

                                            result = "true";
                                        }
                                        else
                                        {
                                            //video card
                                            var guid = UserVideo.GetRandomVideo(userid, 1, 3, true);

                                            if (!guid.HasValue)
                                            {
                                                throw new Exception("No Video Available.");
                                            }

                                            var uv = new Entity.UserVideo();

                                            uv.UserID     = userid;
                                            uv.UserName   = username;
                                            uv.VideoGuid  = guid.Value;
                                            uv.ActiveDate = DateTime.Now;
                                            uv.UserDesc   = string.Empty;
                                            uv.IsPublic   = false;

                                            uv.Insert(trans);

                                            trans.Commit();

                                            PlayerStrip.ActiveVideoCost(userid, unID);

                                            returnURL = Player.Cache.Load(
                                                Video.Cache.Load(guid.Value).GoalPlayerGuid.Value).PhotoURL;

                                            PlayerLog.LogHistory(userid, username, PlayerHistoryType.ActivateVideo,
                                                                 new ActivateVideoDesc(un).Generate());

                                            if (string.IsNullOrEmpty(returnURL))
                                            {
                                                result = "full";
                                            }
                                            else
                                            {
                                                result = "video";
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch
                {
                    trans.Rollback();

                    result = "error";
                }

                //conn.Close();
            }

            if (!string.IsNullOrEmpty(returnURL))
            {
                responseText = $"ServerMessage={result}&PhotoURL={returnURL}";
            }
            else
            {
                responseText = $"ServerMessage={result}";
            }

            Response.Write(responseText);
        }