示例#1
0
        public static string GetSignature(string url,
                                          out string noncestr, out string timestamp)
        {
            noncestr = WxPayApi.GenerateNonceStr();
            string jsapi_ticket = _jsapi_ticket.Ticket;

            timestamp = WxPayApi.GenerateTimeStamp();
            Dictionary <string, string> dictionary = new Dictionary <string, string>
            {
                { "noncestr", noncestr },
                { "jsapi_ticket", jsapi_ticket },
                { "timestamp", timestamp },
                { "url", url }
            };
            Dictionary <string, string> dictionaryAfterSort = dictionary.OrderBy(p => p.Key)
                                                              .ToDictionary(o => o.Key, p => p.Value);
            StringBuilder stringBuilder = new StringBuilder();

            foreach (var item in dictionaryAfterSort)
            {
                stringBuilder.Append(item.Key);
                stringBuilder.Append("=");
                stringBuilder.Append(item.Value);
                stringBuilder.Append("&");
            }
            stringBuilder.Remove(stringBuilder.Length - 1, 1);
            string signature = ToolsSecret.GetSHA1(stringBuilder.ToString());

            return(signature);
        }
示例#2
0
        public IActionResult LoginGame(string weixinName, string shareId, [FromServices] ILoginGame Ilogin)
        {
            // Ilogin.DaddPlayer = IstoreHouse.AddEntity<Player>; _playerService.AddPlayer
            Ilogin.DaddPlayer = _playerService.AddPlayer;
            //Ilogin.DgetPlayerByWeixianName = IstoreHouse.GetPlayerByName;
            Ilogin.DgetPlayerByWeixianName = _playerService.FindPlayerByName;

            if (shareId == null || shareId == "")
            {
                shareId = ToolsSecret.EncryptOpenId(ManagePlayer.GetOnlyInstance().WeixinName);
            }
            Player player = Ilogin.Login(weixinName, ToolsSecret.DecryptOpenId(shareId));

            if (player != null && base.player != null && base.player.WeixinName != player.WeixinName)
            {
                return(View("Index"));
            }
            //IstoreHouse.SaveChanges();
            SavePlayerInfoInSession(player);
            base.LoadPlayerInfo();
            Sigin(player);

            BuiderShareLink(player);
            return(RedirectToAction("RoomsList", "Rooms", new { Area = "Citys" }));
        }
示例#3
0
        private void BuiderShareLink(Player player)
        {
            StringBuilder url = new StringBuilder();

            url.Append(WxPayConfig.SiteName + "/Game/loginGame?weixinName=");
            url.Append(player.WeixinName);
            url.Append("&shareId=");
            url.Append(ToolsSecret.EncryptOpenId(player.IntroducerWeixinName));
            ViewBag.wxConfig    = new wxConfig(url.ToString());
            ViewBag.manager     = ManagePlayer.GetOnlyInstance();
            ViewBag.Player      = player;
            ViewBag.shareId     = ToolsSecret.EncryptOpenId(player.WeixinName);
            ViewBag.accesstoken = WxPayConfig._access_token.Access_token;
            ViewBag.jsToken     = WxPayConfig._jsapi_ticket.Ticket;
        }
示例#4
0
        public IActionResult Index(string state)
        {
            if (state != null && state != "")
            {
                Player player_ = _playerService.FindPlayerByName(ToolsSecret.DecryptOpenId(state));
                if (player_ != null)
                {
                    ViewBag.shareId = ToolsSecret.EncryptOpenId(player_.WeixinName);
                }
            }
            else
            {
                ViewBag.shareId = ToolsSecret.EncryptOpenId(ManagePlayer.GetOnlyInstance().WeixinName);
            }

            return(View("Index"));
        }
        protected IActionResult AllCityRooms()
        {
            List <IRoom> rooms_ = new List <IRoom>();

            foreach (var gameCity in CityGameController.GameCityList)
            {
                rooms_.AddRange(gameCity.Rooms);
            }
            ViewBag.manager = ManagePlayer.GetOnlyInstance();
            ViewBag.player  = player;

            StringBuilder url = new StringBuilder();

            url.Append(WxPayConfig.SiteName + "/Citys/Rooms/RoomsList");
            ViewBag.wxConfig    = new wxConfig(url.ToString());
            ViewBag.shareId     = ToolsSecret.EncryptOpenId(player.WeixinName);
            ViewBag.accesstoken = WxPayConfig._access_token.Access_token;
            ViewBag.jsToken     = WxPayConfig._jsapi_ticket.Ticket;
            return(View(rooms_));
        }
        public override IActionResult GameIndex()
        {
            StringBuilder url = new StringBuilder();

            url.Append(WxPayConfig.SiteName + "/GameProjects/GameHandler/GameIndex?gameCityId=");
            url.Append(_gameCity.Id);
            url.Append("&roomId=");
            url.Append(_room.Id);
            ViewBag.wxConfig    = new wxConfig(url.ToString());
            ViewBag.manager     = ManagePlayer.GetOnlyInstance();
            ViewBag.Player      = player;
            ViewBag.shareId     = ToolsSecret.EncryptOpenId(player.WeixinName);
            ViewBag.accesstoken = WxPayConfig._access_token.Access_token;
            ViewBag.jsToken     = WxPayConfig._jsapi_ticket.Ticket;
            var iGameProject = _room.InningGame.IGameProject;

            ViewBag.GameProject = iGameProject;
            var gameName = iGameProject.Name;

            return(View(gameName + "GameIndex", _room));
        }
示例#7
0
        public IActionResult LoginGame(string weixinName, string shareId, [FromServices] ILoginGame Ilogin)
        {
            Ilogin.DaddPlayer = _playerService.AddPlayer;
            Ilogin.DgetPlayerByWeixianName = _playerService.FindPlayerByName;
            if (shareId == null || shareId == "")
            {
                shareId = ToolsSecret.EncryptOpenId(ManagePlayer.GetOnlyInstance().WeixinName);
            }
            Player player = Ilogin.Login(weixinName, ToolsSecret.DecryptOpenId(shareId));

            if (player != null && base.player != null && base.player.WeixinName != player.WeixinName)
            {
                return(View("Index"));
            }
            SavePlayerInfoInSession(player);
            base.LoadPlayerInfo();
            Sigin(player);
            BuiderShareLink(player);
            if (GameCity.IsColsed && player.Id != ManagePlayer.GetOnlyInstance().Id)
            {
                return(RedirectToAction("ShowNotice"));
            }
            return(RedirectToAction("RoomsList", "Rooms", new { Area = "Citys" }));
        }
示例#8
0
        public IActionResult LogGameAgain()
        {
            if (player != null)
            {
                return(RedirectToAction("loginGame", new { weixinName = player.WeixinName, shareId = ToolsSecret.EncryptOpenId(player.IntroducerWeixinName) }));
            }

            return(View("Index"));
        }