コード例 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        UserBal   Bal = new UserBal();
        UserProp  p   = new UserProp();
        DataTable dt  = new DataTable();

        if (!IsPostBack)
        {
            if (Session["User_ID"] == null)
            {
                welcome.Visible = false;
                log.InnerHtml   = "Login";
                log.HRef        = "Login";
                sign.Visible    = true;
                div.Visible     = true;
            }
            else
            {
                log.InnerHtml   = "Logout";
                log.HRef        = "Logout";
                welcome.Visible = true;
                p._tag          = 5;
                p._ID           = Convert.ToInt16(Session["User_ID"]);
                dt = Bal.fetchBal(p);
                welcome.InnerHtml = "Welcome " + dt.Rows[0]["FN"].ToString();
                sign.Visible      = false;
                div.Visible       = false;
            }
        }
    }
コード例 #2
0
ファイル: UserDal.cs プロジェクト: MaharshiIT/UsedStuffs
 public int Add(UserProp p)
 {
     try
     {
         con.Open();
         SqlCommand cmd = new SqlCommand("userSP", con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@tag", p._tag);
         cmd.Parameters.AddWithValue("@Address", p._Address);
         cmd.Parameters.AddWithValue("@City_ID", p._CityID);
         cmd.Parameters.AddWithValue("@EMail", p._EMail);
         cmd.Parameters.AddWithValue("@Gender", p._Gender);
         cmd.Parameters.AddWithValue("@Mobile", p._Mobile);
         cmd.Parameters.AddWithValue("@FN", p._FN);
         cmd.Parameters.AddWithValue("@LN", p._LN);
         cmd.Parameters.AddWithValue("@Password", p._Password);
         cmd.Parameters.AddWithValue("@Username", p._Username);
         cmd.Parameters.AddWithValue("@ID", p._ID);
         cmd.Parameters.AddWithValue("@AddID", p._AddID);
         cmd.Parameters.AddWithValue("@EditID", p._EditID);
         cmd.Parameters.AddWithValue("@CrDate", p._CrDate);
         return(cmd.ExecuteNonQuery());
     }
     catch (Exception e)
     {
         con.Close();
         return(0);
     }
     finally
     {
         con.Close();
     }
 }
コード例 #3
0
ファイル: UserBal.cs プロジェクト: MaharshiIT/UsedStuffs
 public DataTable fetchBal(UserProp pr)
 {
     try
     {
         UserDal dal = new UserDal();
         return(dal.fetch(pr));
     }
     catch (Exception e)
     {
         return(null);
     }
 }
コード例 #4
0
ファイル: UserBal.cs プロジェクト: MaharshiIT/UsedStuffs
 public int AddBal(UserProp pr)
 {
     try
     {
         UserDal dal = new UserDal();
         return(dal.Add(pr));
     }
     catch (Exception e)
     {
         return(0);
     }
 }
コード例 #5
0
        public BoardUserPage(MobileBoardUser selectedUser)
        {
            InitializeComponent();
            BindingContext = this;


            foreach (var prop in selectedUser.GetType().GetProperties())
            {
                if (prop.GetValue(selectedUser).GetType() == typeof(String))
                {
                    UserProp NewUserProp = new UserProp
                    {
                        userprop  = prop.Name.ToString(),
                        uservalue = prop.GetValue(selectedUser).ToString()
                    };
                    SelectedUserProps.Add(NewUserProp);
                }
            }
        }
コード例 #6
0
        private void ExchangeTeleFarePiece(string uid, int duihuanId, JObject responseData)
        {
            TeleFarePieceData pieceData = null;

            foreach (var data in MySqlService.teleFarePieceDatas)
            {
                if (data.duihuan_id == duihuanId)
                {
                    pieceData = data;
                    break;
                }
            }

            if (pieceData == null)
            {
                OperatorFail(responseData, $"兑换id有误:{duihuanId}");
            }
            else
            {
                UserProp userProp = MySqlManager <UserProp> .Instance.GetUserProp(uid, pieceData.material_id);

                if (userProp == null)
                {
                    OperatorFail(responseData, $"材料不足");
                }
                else
                {
                    if (userProp.PropNum < pieceData.material_num)
                    {
                        OperatorFail(responseData, $"材料不足:{ pieceData.material_num}");
                    }
                    else
                    {
                        userProp.PropNum -= pieceData.material_num;
                        MySqlManager <UserProp> .Instance.Update(userProp);

                        string propReward = pieceData.Synthesis_id + ":" + pieceData.Synthesis_num;
                        MySqlUtil.AddProp(uid, propReward, "话费碎片兑换");
                        OperatorSuccess(responseData, "兑换成功");
                    }
                }
            }
        }
コード例 #7
0
        private bool AddProp(Goods goods, string uid)
        {
            List <string> list = new List <String>();

            CommonUtil.splitStr(goods.props, list, ';');
            for (int i = 0; i < list.Count; i++)
            {
                string[] strings = list[i].Split(':');
                int      propId  = Convert.ToInt32(strings[0]);
                int      propNum = Convert.ToInt32(strings[1]);

                UserProp userProp = NHibernateHelper.userPropManager.GetUserProp(uid, propId);
                if (userProp == null)
                {
                    userProp = new UserProp()
                    {
                        Uid     = uid,
                        PropId  = propId,
                        PropNum = propNum
                    };
                    if (!NHibernateHelper.userPropManager.Add(userProp))
                    {
                        MySqlService.log.Warn("添加道具失败");
                        return(false);
                    }
                }
                else
                {
                    userProp.PropNum += propNum;
                    if (!NHibernateHelper.userPropManager.Update(userProp))
                    {
                        MySqlService.log.Warn("更新道具失败");
                        return(false);
                    }
                }
            }

            return(true);
        }
コード例 #8
0
        private void UseLaBaSql(string uid, JObject responseData)
        {
            UserProp userProp = NHibernateHelper.userPropManager.GetUserProp(uid, 106);

            if (userProp == null || userProp.PropNum <= 0)
            {
                MySqlService.log.Warn("没有喇叭");
                OperatorFail(responseData);
            }
            else
            {
                userProp.PropNum--;
                if (NHibernateHelper.userPropManager.Update(userProp))
                {
                    OperatorSuccess(responseData);
                }
                else
                {
                    MySqlService.log.Warn("使用道具失败");
                    OperatorFail(responseData);
                }
            }
        }
コード例 #9
0
ファイル: UserDal.cs プロジェクト: MaharshiIT/UsedStuffs
 public DataTable fetch(UserProp p)
 {
     try
     {
         con.Open();
         SqlCommand cmd = new SqlCommand("userSP", con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@tag", p._tag);
         cmd.Parameters.AddWithValue("@Address", p._Address);
         cmd.Parameters.AddWithValue("@City_ID", p._CityID);
         cmd.Parameters.AddWithValue("@EMail", p._EMail);
         cmd.Parameters.AddWithValue("@Gender", p._Gender);
         cmd.Parameters.AddWithValue("@Mobile", p._Mobile);
         cmd.Parameters.AddWithValue("@FN", p._FN);
         cmd.Parameters.AddWithValue("@LN", p._LN);
         cmd.Parameters.AddWithValue("@Password", p._Password);
         cmd.Parameters.AddWithValue("@Username", p._Username);
         cmd.Parameters.AddWithValue("@ID", p._ID);
         cmd.Parameters.AddWithValue("@AddID", p._AddID);
         cmd.Parameters.AddWithValue("@EditID", p._EditID);
         cmd.Parameters.AddWithValue("@CrDate", p._CrDate);
         SqlDataAdapter da = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();
         da.Fill(dt);
         return(dt);
     }
     catch (Exception e)
     {
         con.Close();
         return(null);
     }
     finally
     {
         con.Close();
     }
 }
コード例 #10
0
        private void UsePropSql(string uid, int propId, JObject responseData)
        {
            UserProp userProp = NHibernateHelper.userPropManager.GetUserProp(uid, propId);

            if (userProp == null || userProp.BuffNum <= 0)
            {
                MySqlService.log.Warn("没有该道具或者不能使用该道具");
                OperatorFail(responseData);
            }
            else
            {
                userProp.BuffNum--;
                if (NHibernateHelper.userPropManager.Update(userProp))
                {
                    //TODO buff为0,删除玩家道具
                    OperatorSuccess(responseData);
                }
                else
                {
                    MySqlService.log.Warn("使用Buff道具失败");
                    OperatorFail(responseData);
                }
            }
        }
コード例 #11
0
        public async Task <ActionResult <int> > Login([FromBody] UserProp user)
        {
            var userScore = await _sQLAccess.UserLoginCommand(user.UsernameProp, user.PasswordProp);

            return(userScore);
        }
コード例 #12
0
        private void UsePropSql(string uid, int propId, JObject responseData)
        {
            UserProp userProp = NHibernateHelper.userPropManager.GetUserProp(uid, propId);

            if (userProp == null || userProp.PropNum <= 0)
            {
                MySqlService.log.Warn("没有该道具或者不能使用该道具");
                OperatorFail(responseData);
            }
            else
            {
                userProp.PropNum--;
                if (NHibernateHelper.userPropManager.Update(userProp))
                {
                    UserGame userGame = NHibernateHelper.userGameManager.GetByUid(uid);
                    if (userGame == null)
                    {
                        MySqlService.log.Warn("查找用户游戏数据失败");
                        OperatorFail(responseData);
                        return;
                    }

                    switch (userProp.PropId)
                    {
                    //魅力值修正卡
                    case 109:
                        userGame.MeiliZhi = 0;
                        NHibernateHelper.userGameManager.Update(userGame);
                        break;

                    //逃跑率清零卡
                    case 108:
                        userGame.RunCount = 0;
                        NHibernateHelper.userGameManager.Update(userGame);
                        break;

                    //记牌器
                    case 101:
                    //加倍卡
                    case 102:
                    //出牌发光
                    case 105:
                        userProp.BuffNum++;
                        NHibernateHelper.userPropManager.Update(userProp);
                        break;

                    case 111:
                    case 112:

                        break;

                    case 130:
                        List <JDCard> tenJDCard = MySqlManager <JDCard> .Instance.GetByPorperty("price", "10", "state", "1");

                        JDCard jDCard = null;
                        foreach (var card in tenJDCard)
                        {
                            if (card.Uid == uid)
                            {
                                jDCard = card;
                                break;
                            }
                        }

                        if (jDCard == null)
                        {
                            OperatorFail(responseData);
                            return;
                        }
                        else
                        {
                            jDCard.state = 2 + "";
                            MySqlManager <JDCard> .Instance.Update(jDCard);

                            SendEmailUtil.SendEmail(uid, "10元京东卡",
                                                    $"您的京东卡:\n卡号:{jDCard.card_number} \n卡密:{jDCard.card_secret} \n有效期:{jDCard.valid_time}", "");
                        }

                        break;

                    case 131:
                        List <JDCard> twentyJDCard = MySqlManager <JDCard> .Instance.GetByPorperty("price", "20", "state", "1");

                        JDCard jDCard2 = null;
                        foreach (var card in twentyJDCard)
                        {
                            if (card.Uid == uid)
                            {
                                jDCard2 = card;
                                break;
                            }
                        }

                        if (jDCard2 == null)
                        {
                            OperatorFail(responseData);
                            return;
                        }
                        else
                        {
                            jDCard2.state = 2 + "";
                            MySqlManager <JDCard> .Instance.Update(jDCard2);

                            SendEmailUtil.SendEmail(uid, "20元京东卡",
                                                    $"您的京东卡:\n卡号:{jDCard2.card_number} \n卡密:{jDCard2.card_secret} \n有效期:{jDCard2.valid_time}", "");
                        }
                        break;
                    }
                    OperatorSuccess(responseData);
                }
                else
                {
                    MySqlService.log.Warn("使用道具失败");
                    OperatorFail(responseData);
                }
            }
        }
コード例 #13
0
        private void UseHuaFeiSql(string uid, int propId, string phone, int num, JObject responseData)
        {
            UserProp userProp = NHibernateHelper.userPropManager.GetUserProp(uid, propId);
            UserGame userGame = MySqlManager <UserGame> .Instance.GetByUid(uid);

            //限制话费使用
            if (userGame == null)
            {
                MySqlService.log.Warn($"没有该道具或者不能使用该道具:{uid},{propId},{num}");
                OperatorFail(responseData, "没有该道具或者不能使用该道具");
                return;
            }
            else
            {
                if (userGame.DailyGameCount < 1)
                {
                    MySqlService.log.Info($"{uid}:当天未完成一次对局");
                    OperatorFail(responseData, "充值话费失败:完成一次对局方可使用");
                    return;
                }
            }

            if (userProp == null || userProp.PropNum < num)
            {
                MySqlService.log.Warn($"没有该道具或者不能使用该道具:{uid},{propId},{num}");
                OperatorFail(responseData, "没有该道具或者不能使用该道具");
            }
            else
            {
                userProp.PropNum -= num;
                bool isPhoneFee = true;
                switch (userProp.PropId)
                {
                //1元话费
                case 111:
                //5元话费
                case 112:
                //10元话费
                case 113:
                    //测试环境不需要到账
                    if (!MySqlService.IsTest)
                    {
                        isPhoneFee = PhoneFeeRecharge(uid, propId, phone, num);
                    }

                    break;
                }

                if (isPhoneFee)
                {
                    if (NHibernateHelper.userPropManager.Update(userProp))
                    {
                        MySqlService.log.Info($"成功充值,还剩{userProp.BuffNum}");

                        //记录充值记录
                        int amount = 0;
                        if (propId == 111)
                        {
                            amount = 1 * num;
                        }
                        else if (propId == 112)
                        {
                            amount = 5;
                        }
                        else if (propId == 113)
                        {
                            amount = 10;
                        }


                        UserPhoneExchange userPhoneExchange = new UserPhoneExchange()
                        {
                            Uid        = uid,
                            Money      = amount,
                            Phone      = phone,
                            CreateTime = DateTime.Now
                        };
                        MySqlManager <UserPhoneExchange> .Instance.Add(userPhoneExchange);

                        OperatorSuccess(responseData);
                    }
                    else
                    {
                        MySqlService.log.Warn("更新话费道具失败:" + uid + " " + userProp.PropId);
                        OperatorFail(responseData, "更新话费道具失败");
                    }
                }
                else
                {
                    MySqlService.log.Warn($"充值话费失败,uid:{uid},propid:{propId},phone:{phone}");
                    OperatorFail(responseData, "充值话费失败");
                }
            }
        }
コード例 #14
0
        public async Task <ActionResult <string> > Create([FromBody] UserProp user)
        {
            var createSucc = await _sQLAccess.NewUserCommand(user.UsernameProp, user.PasswordProp);

            return(createSucc);
        }
コード例 #15
0
        /// <summary>
        /// 1.是金币,2.是话费,4徽章
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="propId">1,2...</param>
        /// <param name="propNum"></param>
        /// <param name="reason"></param>
        /// <returns></returns>
        public static bool ChangeProp(string uid, int propId, int propNum, string reason)
        {
            UserInfo userInfo = NHibernateHelper.userInfoManager.GetByUid(uid);

            if (userInfo == null)
            {
                MySqlService.log.Warn("用户不存在");
                return(false);
            }

            if (propId == 1)
            {
                userInfo.Gold += propNum;
                if (userInfo.Gold <= 0)
                {
                    User user = NHibernateHelper.userManager.GetByUid(uid);
                    if (user.IsRobot == 1)
                    {
                        userInfo.Gold = new Random().Next(80000, 100000);
                    }
                    else
                    {
                        userInfo.Gold = 0;
                    }
                }

                if (userInfo.Gold >= 0)
                {
                    if (!NHibernateHelper.userInfoManager.Update(userInfo))
                    {
                        MySqlService.log.Warn("添加金币失败");
                        return(false);
                    }
                    else
                    {
                        int afterGold  = userInfo.Gold;
                        int changeGold = propNum;

                        StatictisLogUtil.ChangeWealth(userInfo.Uid, userInfo.NickName, MyCommon.GOLD, reason, afterGold - changeGold, changeGold, afterGold);

//                        string msg = $"改变了{propNum}金币";
//                        LogUtil.Log(uid, MyCommon.OpType.CHANGE_WEALTH, msg);
                    }
                    //发送奖励金;
                    SendSupplyGold(uid);
                }
                else
                {
                    MySqlService.log.Warn("金币不足");
                    return(false);
                }
            }
            else if (propId == 2)
            {
                userInfo.YuanBao += propNum;

                if (userInfo.YuanBao >= 0)
                {
                    if (!NHibernateHelper.userInfoManager.Update(userInfo))
                    {
                        MySqlService.log.Warn("添加元宝失败");
                        return(false);
                    }
                    else
                    {
                        //记录玩家财富变化日志
                        int after  = userInfo.YuanBao;
                        int change = propNum;

                        StatictisLogUtil.ChangeWealth(userInfo.Uid, userInfo.NickName, MyCommon.YUANBAO, reason, after - change, change, after);
                        //                        string msg = $"改变了{propNum}元宝";
                        //                        LogUtil.Log(uid, MyCommon.OpType.CHANGE_WEALTH, msg);
                    }
                }
                else
                {
                    MySqlService.log.Warn("元宝不足");
                    return(false);
                }
            }
            else if (propId == 110)
            {
                userInfo.Medel += propNum;
                if (userInfo.Medel >= 0)
                {
                    if (!NHibernateHelper.userInfoManager.Update(userInfo))
                    {
                        MySqlService.log.Warn($"添加徽章失败-medal:{userInfo.Medel}-改变的数量:{propNum}");
                        return(false);
                    }
                    else
                    {
                        //记录玩家财富变化日志
                        int after  = userInfo.Medel;
                        int change = propNum;

                        StatictisLogUtil.ChangeWealth(userInfo.Uid, userInfo.NickName, MyCommon.Medal, reason, after - change, change, after);
                        //                        string msg = $"改变了{propNum}徽章";
                        //                        LogUtil.Log(uid, MyCommon.OpType.CHANGE_WEALTH, msg);
                    }
                }
                else
                {
                    MySqlService.log.Warn($"徽章不足-medal:{userInfo.Medel}-改变的数量:{propNum}");
                    return(false);
                }
            }
            else
            {
                UserProp userProp = NHibernateHelper.userPropManager.GetUserProp(uid, propId);
                if (userProp == null)
                {
                    userProp = new UserProp()
                    {
                        Uid     = uid,
                        PropId  = propId,
                        PropNum = propNum
                    };
                    if (!NHibernateHelper.userPropManager.Add(userProp))
                    {
                        MySqlService.log.Warn($"添加道具失败-propId:{propId}-propNum:{propNum}");
                        return(false);
                    }
                    else
                    {
                        //记录玩家财富变化日志
                        int after  = propNum;
                        int change = propNum;

                        StatictisLogUtil.ChangeWealth(userInfo.Uid, userInfo.NickName, propId + "", reason, after - change, change, after);
                        //                        string msg = $"改变了{propId}道具,{propNum}个";
                        //                        LogUtil.Log(uid, MyCommon.OpType.CHANGE_WEALTH, msg);
                    }
                }
                else
                {
                    userProp.PropNum += propNum;
                    if (userProp.PropNum >= 0)
                    {
                        if (!NHibernateHelper.userPropManager.Update(userProp))
                        {
                            MySqlService.log.Warn("更新道具失败");
                            return(false);
                        }
                        else
                        {
                            //记录玩家财富变化日志
                            int after  = userProp.PropNum;
                            int change = propNum;

                            StatictisLogUtil.ChangeWealth(userInfo.Uid, userInfo.NickName, propId + "", reason, after - change, change, after);
                            //string msg = $"改变了{propId}道具,{propNum}个";
                            //LogUtil.Log(uid, MyCommon.OpType.CHANGE_WEALTH, msg);
                        }
                    }
                    else
                    {
                        MySqlService.log.Warn("道具不足");
                        return(false);
                    }
                }
            }
            return(true);
        }
コード例 #16
0
        public async Task <ActionResult <string> > Verify([FromBody] UserProp user)
        {
            var userIdCheck = await _sQLAccess.VerifyUsernameCommand(user.UsernameProp);

            return(userIdCheck);
        }
コード例 #17
0
        public async Task <string> ScoreUpdate([FromBody] UserProp user)
        {
            var scoreUpdateCheck = await _sQLAccess.ScoreUpdateCommand(user.UsernameProp, user.HighscoreProp);

            return(scoreUpdateCheck);
        }