Example #1
0
        public ActionResult LeftMenu(Dictionary <string, string> queryvalues)
        {
            ILog log = LogManager.GetLogger("Club");

            log.Info("进入LeftMenu");


            int uid = queryvalues.ContainsKey("uid") ? (string.IsNullOrEmpty(queryvalues["uid"]) ? -1 : Convert.ToInt32(queryvalues["uid"])) : -1;
            //int hport = queryvalues.ContainsKey("hpost") ? (string.IsNullOrEmpty(queryvalues["hpost"]) ? -1 : Convert.ToInt32(queryvalues["hpost"])) : -1;
            // string hip = queryvalues.ContainsKey("hip") ? queryvalues["hip"] : "";
            //uid = 10701;
            int    hport = Convert.ToInt32(serverPort);
            string hip   = serverIP;
            //115.159.100.154
            //192.168.1.18

            ClubInit model = new ClubInit()
            {
                Ip   = hip,
                Port = hport,
                UID  = uid
            };

            return(View(model));
        }
Example #2
0
        // GET: Club
        public ActionResult Index(Dictionary <string, string> queryvalues)
        {
            ILog log = LogManager.GetLogger("Club");



            int uid = queryvalues.ContainsKey("uid") ? (string.IsNullOrEmpty(queryvalues["uid"])?-1:Convert.ToInt32(queryvalues["uid"])): -1;


            // uid = 10701;
            string hip   = serverIP;
            int    hport = Convert.ToInt32(serverPort);

            Dictionary <char, char> arrC = new Dictionary <char, char>();

            /*'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'*/
            arrC.Add('0', 'a'); arrC.Add('1', 'b'); arrC.Add('2', 'c');
            arrC.Add('3', 'd'); arrC.Add('4', 'e'); arrC.Add('5', 'f');
            arrC.Add('6', 'g'); arrC.Add('7', 'h'); arrC.Add('8', 'i');
            arrC.Add('9', 'j');
            string uidStr = uid.ToString();
            string resStr = "";

            for (int i = 0; i < uidStr.Length; i++)
            {
                char ci = arrC[uidStr[i]];
                resStr += ci;
            }
            string code = resStr;

            resStr = gameUrl + resStr;

            //生成短网址

            // resStr =  BaiDuHelper.TransLongUrlToTinyUrl(resStr);



            //发送socket请求
            IPAddress  ip           = IPAddress.Parse(hip);
            IPEndPoint ipe          = new IPEndPoint(ip, hport);
            Socket     clientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            clientSocket.Connect(ipe);
            Int16 head    = 8;
            Int16 protol  = 1;
            Int32 content = uid;

            byte[] headBytes    = System.BitConverter.GetBytes(head);
            byte[] protolBytes  = System.BitConverter.GetBytes(protol);
            byte[] contentBytes = System.BitConverter.GetBytes(content);
            byte[] c            = new byte[headBytes.Length + protolBytes.Length + contentBytes.Length];
            headBytes.CopyTo(c, 0);
            protolBytes.CopyTo(c, headBytes.Length);
            contentBytes.CopyTo(c, headBytes.Length + protolBytes.Length);



            clientSocket.Send(c);
            // = unpack("vv1/vv2/Lc1/Lc2/Lc3/a16c4/cc5",$out);
            //vv1/vv2/Lc1/Lc2/Lc3/a16c4/cc5
            //2位/2位/4位/4位/4位/16位/1位



            byte[] recBytes = new byte[1024];
            int    bytes    = clientSocket.Receive(recBytes, recBytes.Length, 0);



            if (bytes <= 0)
            {
                //没有登录
                return(View("Nologin", bytes));
            }
            else
            {
                Int16 v1 = System.BitConverter.ToInt16(recBytes, 0);
                Int16 v2 = System.BitConverter.ToInt16(recBytes, 2);
                Int32 c1 = System.BitConverter.ToInt32(recBytes, 4);
                Int32 c2 = System.BitConverter.ToInt32(recBytes, 8);
                Int32 c3 = System.BitConverter.ToInt32(recBytes, 12);


                string c4 = Encoding.ASCII.GetString(recBytes, 16, 16);


                byte c5 = recBytes[32];


                ClubInit model = new ClubInit()
                {
                    C1   = c1,
                    C2   = c2,
                    C3   = c3,
                    C4   = c4,
                    C5   = c5,
                    V1   = v1,
                    V2   = v2,
                    Mark = resStr,
                    Ip   = hip,
                    Port = hport,
                    UID  = uid,
                    Code = code
                };
                clientSocket.Close();


                //查询本周总贡献总额
                Int64  weekTotal = ClubBLL.GetClubWeekTotal(uid);
                string fanli     = "20";
                string nextTotal = "";
                string nextFanLi = "";

                if (weekTotal < 500000000)
                {
                    fanli     = "25"; //当前返利
                    nextTotal = "5";  //下个返利服务费
                    nextFanLi = "30"; //下个返利比例
                }
                else if (weekTotal < 1000000000)
                {
                    fanli     = "30";
                    nextTotal = "10";
                    nextFanLi = "35";
                }
                else if (weekTotal < 1500000000)
                {
                    fanli     = "35";
                    nextTotal = "15";
                    nextFanLi = "40";
                }
                else if (weekTotal < 2000000000)
                {
                    fanli     = "40";
                    nextTotal = "20";
                    nextFanLi = "45";
                }
                else if (weekTotal < 3000000000)
                {
                    fanli     = "45";
                    nextTotal = "30";
                    nextFanLi = "50";
                }
                else
                {
                    fanli = "50";
                }

                //if (weekTotal < 500000000)
                //{
                //    fanli = "20";
                //    nextTotal = "5";
                //    nextFanLi = "25";
                //}
                //else if(weekTotal < 1000000000)
                //{
                //    fanli = "25";
                //    nextTotal = "10";
                //    nextFanLi = "30";
                //}
                //else if (weekTotal < 3000000000)
                //{
                //    fanli = "30";
                //    nextTotal = "30";
                //    nextFanLi = "40";
                //}
                //else if (weekTotal < 5000000000)
                //{
                //    fanli = "40";
                //    nextTotal = "50";
                //    nextFanLi = "50";
                //}
                //else
                //{
                //    fanli = "50";
                //}
                model.WeekTotal    = weekTotal;
                model.FanLi        = fanli;
                model.NextTotal    = nextTotal;
                model.NextFanLi    = nextFanLi;
                model.WeekTotalStr = weekTotal.ToString("#,0.");
                return(View(model));
            }
        }