Ejemplo n.º 1
0
        public ActionResult BindClub(Dictionary <string, string> queryvalues)
        {
            log.Info("绑定俱乐部URL: " + Utils.GetUrl());

            string id     = queryvalues.ContainsKey("id") ? queryvalues["id"] : string.Empty;
            string clubid = queryvalues.ContainsKey("clubid") ? queryvalues["clubid"] : string.Empty;
            string sign   = queryvalues.ContainsKey("sign") ? queryvalues["sign"] : string.Empty;



            if (string.IsNullOrEmpty(id) || string.IsNullOrEmpty(clubid) || string.IsNullOrEmpty(sign))
            {
                return(Content("-2"));
            }

            sign = sign.ToUpper();

            string md5 = Utils.MD5(string.Concat(id, clubid, _key)).ToUpper();



            if (!sign.Equals(md5))
            {
                return(Content("-1"));
            }


            Beland_Club_C BelandlubC;

            // model.Minu 传一个时间长短给服务器
            BelandlubC = Beland_Club_C.CreateBuilder()
                         .SetClubID((uint)Convert.ToInt32(clubid))
                         .SetDwUserID((uint)Convert.ToInt32(id))
                         .Build();

            Bind tbind = Cmd.runClient(new Bind(ServiceCmd.SC_BELAND_CLUB, BelandlubC.ToByteArray()));


            switch ((CenterCmd)tbind.header.CommandID)
            {
            case CenterCmd.CS_BELAND_CLUB:
                Beland_Club_S BelandClubS = Beland_Club_S.ParseFrom(tbind.body.ToBytes());
                bool          res         = BelandClubS.Suc;
                if (res)
                {
                    return(Content("1"));
                }
                else
                {
                    return(Content("0"));
                }

            case CenterCmd.CS_CONNECT_ERROR:
                break;
            }

            return(Content("0"));
        }
Ejemplo n.º 2
0
        public ActionResult MemberUpdateForVIP(Dictionary <string, string> queryvalues)
        {
            int  _type  = queryvalues.ContainsKey("Type") ? Convert.ToInt32(queryvalues["Type"]) : 0;
            int  _id    = queryvalues.ContainsKey("ID") ? Convert.ToInt32(queryvalues["ID"]) : 0;
            int  _level = queryvalues.ContainsKey("Grade") ? Convert.ToInt32(queryvalues["Grade"]) : 0;
            int  _point = queryvalues.ContainsKey("Point") ? Convert.ToInt32(queryvalues["Point"]) : 0;
            Role model  = new Role();

            model = RoleBLL.GetRoleByString(new Role()
            {
                ID = _id
            });
            if (model == null)
            {
                return(View(model));
            }
            model.UpdateProperty = _type;
            //数据修改操作
            if (Request.IsAjaxRequest())
            {
                //没有封号不能修改
                if (model.IsFreeze == isSwitch.开)
                {
                    return(Content("-1"));
                }
                if (_type == 3)     //绑定俱乐部
                {
                    //检查是不是俱乐部,不是俱乐部,不让绑定
                    IEnumerable <ClubInfo> clubs = ClubBLL.GetClubInfo(_level);
                    if (clubs != null && clubs.Count() > 0)
                    {
                    }
                    else
                    {
                        return(Content("4"));//不是俱乐部
                    }


                    Beland_Club_C BelandlubC;
                    // model.Minu 传一个时间长短给服务器
                    BelandlubC = Beland_Club_C.CreateBuilder()
                                 .SetClubID((uint)_level)
                                 .SetDwUserID((uint)_id)
                                 .Build();



                    Bind tbind = Cmd.runClient(new Bind(ServiceCmd.SC_BELAND_CLUB, BelandlubC.ToByteArray()));


                    switch ((CenterCmd)tbind.header.CommandID)
                    {
                    case CenterCmd.CS_BELAND_CLUB:
                        Beland_Club_S BelandClubS = Beland_Club_S.ParseFrom(tbind.body.ToBytes());
                        bool          res         = BelandClubS.Suc;
                        if (res)
                        {
                            return(Content("5"));
                        }
                        else
                        {
                            return(Content("6"));
                        }

                    case CenterCmd.CS_CONNECT_ERROR:
                        break;
                    }

                    return(Content("6"));



                    //model.ClubID = _level;
                    //int res = RoleBLL.UpdateRoleClub(model);
                    //if(res == 1)    //绑定不是俱乐部ID
                    //{
                    //    return Content("4");
                    //}
                    //else
                    //{
                    //    return Content(res.ToString());
                    //}
                }
                //玩家数据为空
                if (model.ExtInfo == null)
                {
                    return(Content("-2"));
                }
                else
                {
                    /////////////////////////////////////////////////////////////////////////////////

                    if (SystemType == "2")//万人德州
                    {
                        BExtInfo BExtInfo = BExtInfo.ParseFrom(model.ExtInfo);
                        if (_type == 1)  //修改VIP等级
                        {
                            VipInfo VipInfo22;

                            VipInfo22 = VipInfo.CreateBuilder(BExtInfo.VipInfo)
                                        .SetGrade((int)_level)
                                        .SetCurrent((int)_point)
                                        .Build();


                            BExtInfo = BExtInfo.CreateBuilder(BExtInfo)
                                       .SetVipInfo(VipInfo22)
                                       .Build();
                        }
                        else if (_type == 2) //修改等级
                        {
                            LevelInfo LevelInfo22;

                            LevelInfo22 = LevelInfo.CreateBuilder(BExtInfo.LevelInfo)
                                          .SetLevel(_level)
                                          .SetExp(_point)
                                          .Build();


                            BExtInfo = BExtInfo.CreateBuilder(BExtInfo)
                                       .SetLevelInfo(LevelInfo22)
                                       .Build();
                        }
                        byte[] bs = BExtInfo.ToByteArray();
                        model.ExtInfo = bs;
                        return(Content(RoleBLL.UpdateRole(model).ToString()));
                    }
                    else if (SystemType == "1")
                    {
                        byte[] Data = new byte[4];
                        Array.Copy(model.ExtInfo, 4, Data, 0, 4);
                        int    num   = System.BitConverter.ToInt32(Data, 0);
                        byte[] Grade = System.BitConverter.GetBytes(_level);
                        byte[] Point = System.BitConverter.GetBytes(_point);
                        for (int j = 0; j < 4; j++)
                        {
                            if (_type == 1)  //修改VIP等级
                            {
                                model.ExtInfo[16 + j] = Grade[j];
                                model.ExtInfo[20 + j] = Point[j];
                            }
                            else if (_type == 2) //修改等级
                            {
                                model.ExtInfo[36 + j] = Grade[j];
                                model.ExtInfo[40 + j] = Point[j];
                            }
                        }
                        return(Content(RoleBLL.UpdateRole(model).ToString()));
                    }
                    else
                    {
                    }
                }
            }
            //数据查询操作
            if (model.ExtInfo == null)
            {
                return(View(model));
            }
            else
            {
                if (SystemType == "2")
                {
                    BExtInfo BExtInfo = BExtInfo.ParseFrom(model.ExtInfo);
                    model.VipGrade   = BExtInfo.VipInfo.Grade;   //VIP等级
                    model.VipPoint   = BExtInfo.VipInfo.Current; //VIP等级
                    model.LevelGrade = BExtInfo.LevelInfo.Level; //玩家等级
                    model.LevelPoint = BExtInfo.LevelInfo.Exp;   //玩家等级
                    return(View(model));
                }
                else
                {
                    int    indexData = 4;
                    byte[] numData   = new byte[4];
                    Array.Copy(model.ExtInfo, indexData, numData, 0, 4);
                    int num = System.BitConverter.ToInt32(numData, 0);
                    indexData = indexData + 4;

                    byte[] DataInfo = new byte[num];
                    Array.Copy(model.ExtInfo, 0, DataInfo, 0, num);
                    while (indexData < num)
                    {
                        //类型ID
                        int typeid = System.BitConverter.ToInt32(DataInfo, indexData);
                        indexData = indexData + 4;
                        //数据长度
                        int datanum = System.BitConverter.ToInt32(DataInfo, indexData);
                        indexData = indexData + 4;
                        //VIP等级
                        if (typeid == 1)
                        {
                            model.VipGrade = System.BitConverter.ToInt32(DataInfo, indexData);
                            model.VipPoint = System.BitConverter.ToInt32(DataInfo, indexData + 4);
                            indexData      = indexData + datanum;
                        }
                        //玩家等级
                        else if (typeid == 2)
                        {
                            model.LevelGrade = System.BitConverter.ToInt32(DataInfo, indexData);
                            model.LevelPoint = System.BitConverter.ToInt32(DataInfo, indexData + 4);
                            indexData        = indexData + datanum;
                        }
                        else
                        {
                            indexData = indexData + datanum;
                        }
                    }
                    return(View(model));
                }
            }
        }