Exemple #1
0
        public int GetReadPrice(PayReward reward)
        {
            MySqlConnection connection = DAO.GetConnection();
            int             result     = 0;

            try
            {
                connection.Open();
                string       cmdText      = "SELECT read_num FROM pay_rewards WHERE account_name = ?account_name And reward_id=?reward_id And start_time=?start_time And end_time=?end_time";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?account_name", reward.AccountName);
                mySqlCommand.Parameters.AddWithValue("?reward_id", reward.RewardId);
                mySqlCommand.Parameters.AddWithValue("?start_time", reward.StartTime);
                mySqlCommand.Parameters.AddWithValue("?end_time", reward.EndTime);
                MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
                if (mySqlDataReader.Read())
                {
                    result = mySqlDataReader.GetInt32("read_num");
                    return(result);
                }
                return(result);
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2.ToString());
                ProjectData.ClearProjectError();
                return(result);
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #2
0
        public void UpdataPayReward(PayReward reward, int price)
        {
            MySqlConnection connection = DAO.GetConnection();

            try
            {
                connection.Open();
                string       cmdText      = "UPDATE pay_rewards SET read_num=?read_num WHERE account_name = ?account_name And reward_id=?reward_id And start_time=?start_time And end_time=?end_time";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?read_num", price);
                mySqlCommand.Parameters.AddWithValue("?account_name", reward.AccountName);
                mySqlCommand.Parameters.AddWithValue("?reward_id", reward.RewardId);
                mySqlCommand.Parameters.AddWithValue("?start_time", reward.StartTime);
                mySqlCommand.Parameters.AddWithValue("?end_time", reward.EndTime);
                mySqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2.ToString());
                ProjectData.ClearProjectError();
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #3
0
        public void InsertPayReward(PayReward pay)
        {
            MySqlConnection connection = DAO.GetConnection();

            try
            {
                connection.Open();
                string       cmdText      = "INSERT INTO pay_rewards(account_name, reward_type, pay_num, reward_id, read_num, start_time, end_time) VALUES (?account_name, ?reward_type, ?pay_num, ?reward_id, ?read_num, ?start_time, ?end_time) ON DUPLICATE KEY UPDATE pay_num=pay_num+?pay_num";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?account_name", pay.AccountName);
                mySqlCommand.Parameters.AddWithValue("?reward_type", pay.RewardType.ToString());
                mySqlCommand.Parameters.AddWithValue("?pay_num", pay.PayNum);
                mySqlCommand.Parameters.AddWithValue("?reward_id", pay.RewardId);
                mySqlCommand.Parameters.AddWithValue("?read_num", pay.ReadNum);
                mySqlCommand.Parameters.AddWithValue("?start_time", pay.StartTime);
                mySqlCommand.Parameters.AddWithValue("?end_time", pay.EndTime);
                mySqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2.ToString());
                ProjectData.ClearProjectError();
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #4
0
        internal void TaotalConsumHandle(GameConnection gs, int id, string accountName, string playerName, int cost)
        {
            PayRewardTemplate payRewardTemplate = _payRewards[id];

            if (!Information.IsNothing(payRewardTemplate) && payRewardTemplate.IsActive() && payRewardTemplate.type == PayRewardType.TOTAL_CONSUM)
            {
                PayReward payReward = new PayReward(accountName, payRewardTemplate.type, id, 0, DateTime.Parse(payRewardTemplate.start_time), DateTime.Parse(payRewardTemplate.end_time));
                payReward.PayNum = cost;
                DAOManager.PayRewardDAO.InsertPayReward(payReward);
            }
        }
Exemple #5
0
        private void InitializeReward()
        {
            List <PayInfo> list = DAOManager.PayInfoDAO.LoadPayInfo();

            foreach (PayInfo item in list)
            {
                foreach (PayRewardTemplate item2 in ActiveRewards())
                {
                    if (item2.type != PayRewardType.TOTAL_CONSUM)
                    {
                        PayReward payReward = new PayReward(item.AccountName, item2.type, item2.id, 0, DateTime.Parse(item2.start_time), DateTime.Parse(item2.end_time));
                        payReward.PayNum = item.PayNum;
                        DAOManager.PayRewardDAO.InsertPayReward(payReward);
                        break;
                    }
                }
                DAOManager.PayInfoDAO.DeletePay(item.AccountName);
            }
        }
Exemple #6
0
        public List <PayReward> LoadPayReward(string account)
        {
            List <PayReward> list       = new List <PayReward>();
            MySqlConnection  connection = DAO.GetConnection();

            try
            {
                connection.Open();
                string       cmdText      = "SELECT * FROM pay_rewards WHERE account_name = ?account_name";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?account_name", account);
                MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
                while (mySqlDataReader.Read())
                {
                    PayRewardType rewardType = (PayRewardType)Conversions.ToInteger(Enum.Parse(typeof(PayRewardType), mySqlDataReader.GetString("reward_type")));
                    int           @int       = mySqlDataReader.GetInt32("pay_num");
                    int           int2       = mySqlDataReader.GetInt32("reward_id");
                    int           int3       = mySqlDataReader.GetInt32("read_num");
                    DateTime      dateTime   = mySqlDataReader.GetDateTime("start_time");
                    DateTime      dateTime2  = mySqlDataReader.GetDateTime("end_time");
                    PayReward     payReward  = new PayReward(account, rewardType, int2, int3, dateTime, dateTime2);
                    payReward.PayNum = @int;
                    list.Add(payReward);
                }
                mySqlDataReader.Close();
                return(list);
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2.ToString());
                ProjectData.ClearProjectError();
                return(list);
            }
            finally
            {
                connection.Close();
            }
        }
Exemple #7
0
 internal void SendRequest(GameConnection gs, string account, string playerName, PayReward pay, PayRewardGroup rd, string payName)
 {
     try
     {
         Interlocked.Increment(ref requestId);
         PayRequest payRequest = new PayRequest(requestId, account, playerName, pay, rd);
         activeRequest.Add(requestId, payRequest);
         gs.SendPacket(new SM_GS_SEND_PAYREWARD(payName, payRequest));
         log.InfoFormat("发送: 角色名:{0} 充值或消费 {1} 商城币奖励 操作ID:{2}", (object)playerName, (object)rd.price, (object)payRequest.RequestId);
     }
     catch (Exception ex)
     {
         ProjectData.SetProjectError(ex);
         Exception ex2 = ex;
         log.Error((object)ex2.ToString());
         ProjectData.ClearProjectError();
     }
 }