Esempio n. 1
0
        public bool Store(LunaInfo luna)
        {
            MySqlConnection connection = DAO.GetConnection();

            try
            {
                connection.Open();
                string       cmdText      = "REPLACE INTO luna(account_id, luna, today_use, key_value, reward_id, next_updata) VALUES (?account_id, ?luna, ?today_use, ?key_value, ?reward_id, ?next_updata)";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?account_id", luna.AccountId);
                mySqlCommand.Parameters.AddWithValue("?luna", luna.Luna);
                mySqlCommand.Parameters.AddWithValue("?today_use", luna.TodayUse);
                mySqlCommand.Parameters.AddWithValue("?key_value", luna.Keys);
                mySqlCommand.Parameters.AddWithValue("?reward_id", luna.TodayRewardId);
                mySqlCommand.Parameters.AddWithValue("?next_updata", luna.NextTime);
                mySqlCommand.ExecuteNonQuery();
                return(true);
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2);
                bool result = false;
                ProjectData.ClearProjectError();
                return(result);
            }
            finally
            {
                connection.Close();
            }
        }
Esempio n. 2
0
        internal static void CheckAuth(SessionKey key, GameConnection client)
        {
            AionConnection value = null;

            if (Conversions.ToBoolean(accountOnLS.TryGetValue(key.AccountId, out value) && Conversions.ToBoolean(value.SessionKey.CheckSessionKey(key))))
            {
                accountOnLS.Remove(key.AccountId);
                GameInfo gameInfo = GameService.GameServerIndoForId(client.GameServerId);
                Account  account  = value.Account;
                gameInfo.AddAccount(account);
                account.LastServer = checked ((byte)gameInfo.ServerId);
                LunaInfo lunaInfo = DAOManager.LunaDAO.LoadLuna(key.AccountId);
                if (Information.IsNothing(lunaInfo))
                {
                    DateTime time = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 9, 0, 0);
                    lunaInfo = new LunaInfo(key.AccountId, 0L, 0, 0, 0, time);
                    DAOManager.LunaDAO.Store(lunaInfo);
                }
                account.LunaInfo = lunaInfo;
                client.SendPacket(new SM_GS_ACCOUNT_AUTH_RESPONSE(key.AccountId, ok: true, account));
                DAOManager.AccountDAO.UpdateLastIpAndServer(account);
                if (ExpirationConfig.EXPIRATION_ENABLE)
                {
                    ExpirationService.GetInstance().Add(account);
                }
            }
            else
            {
                client.SendPacket(new SM_GS_ACCOUNT_AUTH_RESPONSE(key.AccountId, ok: false, null));
            }
        }
Esempio n. 3
0
 public SM_GS_ACCOUNT_AUTH_RESPONSE(int accountId, bool ok, Account acc)
 {
     _accountId = accountId;
     _ok        = ok;
     _acc       = acc;
     if (!Information.IsNothing(acc))
     {
         _time   = acc.AccountTime;
         _reward = acc.LoginReward;
         _luna   = acc.LunaInfo;
     }
 }
Esempio n. 4
0
        public void Request(GameConnection client, int responseId, int activeId, int accountId, long cost)
        {
            LunaInfo lunaInfo = DAOManager.LunaDAO.LoadLuna(accountId);
            DateTime now      = DateTime.Now;
            DateTime nextTime = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 9, 0, 0);

            if (now.Hour > 9)
            {
                nextTime = nextTime.AddDays(1.0);
            }
            if (cost > 0 && lunaInfo.Luna < cost)
            {
                log.InfoFormat("#{0}服务器ID为{1}的用户使用{2}露娜失败!账户余额不足!", (object)client.GameServerId, (object)accountId, (object)cost);
                client.SendPacket(new SM_GS_LUNA_RESPONSE(responseId, isSuccess: false, lunaInfo.Luna, lunaInfo.TodayUse));
                return;
            }
            checked
            {
                long num = cost * -1;
                lunaInfo.Luna += num;
                if (num < 0)
                {
                    LunaInfo lunaInfo2;
                    (lunaInfo2 = lunaInfo).TodayUse = (int)(lunaInfo2.TodayUse + cost);
                    lunaInfo.NextTime = nextTime;
                }
                if (DAOManager.LunaDAO.Store(lunaInfo))
                {
                    if (num > 0)
                    {
                        log.InfoFormat("#{0}服务器ID为{1}的用户充值{2}露娜!账户余额:{3}", new object[4]
                        {
                            client.GameServerId,
                            accountId,
                            num,
                            lunaInfo.Luna
                        });
                    }
                    else
                    {
                        log.InfoFormat("#{0}服务器ID为{1}的用户消费{2}露娜!账户余额:{3}", new object[4]
                        {
                            client.GameServerId,
                            accountId,
                            cost,
                            lunaInfo.Luna
                        });
                    }
                    client.SendPacket(new SM_GS_LUNA_RESPONSE(responseId, isSuccess: true, lunaInfo.Luna, lunaInfo.TodayUse));
                }
            }
        }
Esempio n. 5
0
        public LunaInfo LoadLuna(int accountId)
        {
            MySqlConnection connection = DAO.GetConnection();
            LunaInfo        lunaInfo   = null;

            try
            {
                connection.Open();
                string       cmdText      = "SELECT * FROM luna WHERE account_id = ?account_id";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?account_id", accountId);
                MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
                if (mySqlDataReader.Read())
                {
                    long     @int     = mySqlDataReader.GetInt64("luna");
                    int      int2     = mySqlDataReader.GetInt32("today_use");
                    int      int3     = mySqlDataReader.GetInt32("key_value");
                    int      int4     = mySqlDataReader.GetInt32("reward_id");
                    DateTime dateTime = mySqlDataReader.GetDateTime("next_updata");
                    if (DateTime.Compare(dateTime, DateTime.Now) < 0 && int2 > 0)
                    {
                        DateTime time = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, checked (DateAndTime.Now.Day + 1), 9, 0, 0);
                        lunaInfo = new LunaInfo(accountId, @int, 0, int3, int4, time);
                        Store(lunaInfo);
                    }
                    else
                    {
                        lunaInfo = new LunaInfo(accountId, @int, int2, int3, int4, dateTime);
                    }
                }
                mySqlDataReader.Close();
                return(lunaInfo);
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2);
                ProjectData.ClearProjectError();
                return(lunaInfo);
            }
            finally
            {
                connection.Close();
            }
        }