Beispiel #1
0
        public void InsertAccountTime(int id, AccountTime accTime)
        {
            MySqlConnection connection = DAO.GetConnection();

            try
            {
                connection.Open();
                string       cmdText      = "INSERT INTO account_time(account_id, create_time, last_active, expiration_type, expiration_time, expiration_period) VALUES (?account_id, ?create_time, ?last_active, ?expiration_type, ?expiration_time, ?expiration_period)";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?account_id", id);
                mySqlCommand.Parameters.AddWithValue("?create_time", accTime.CreateTime);
                mySqlCommand.Parameters.AddWithValue("?last_active", accTime.LastLoginTime);
                mySqlCommand.Parameters.AddWithValue("?expiration_type", accTime.ExpirationType.ToString());
                mySqlCommand.Parameters.AddWithValue("?expiration_time", accTime.ExpirationTime);
                mySqlCommand.Parameters.AddWithValue("?expiration_period", accTime.ExpirationPeriod);
                mySqlCommand.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2);
                ProjectData.ClearProjectError();
            }
            finally
            {
                connection.Close();
            }
        }
Beispiel #2
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;
     }
 }
        private static Account CreateAccount(string userName, string password)
        {
            if (!NamePattern.Match(userName).Success)
            {
                return(null);
            }
            string  password2 = Conversions.ToString(EncodePassword(password));
            Account account   = new Account();

            account.Name      = userName;
            account.Password  = password2;
            account.Activated = 1;
            if (DAOManager.AccountDAO.InsertAccount(account))
            {
                AccountTime accountTime = new AccountTime(account.Id);
                accountTime.CreateTime       = DateAndTime.Now;
                accountTime.ExpirationPeriod = DateAndTime.Now;
                DateTime lastTime     = DateAndTime.Now.AddDays(-1.0);
                DateTime dayTime      = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 8, 0, 0);
                DateTime birthDayTime = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day);
                if (ExpirationConfig.EXPIRATION_ENABLE)
                {
                    accountTime.ExpirationType = (ExpirationType)Conversions.ToInteger(Enum.Parse(typeof(ExpirationType), ExpirationConfig.EXPIRATION_TYPE, ignoreCase: true));
                    if (accountTime.ExpirationType == ExpirationType.TIMING)
                    {
                        accountTime.ExpirationPeriod = DateAndTime.Now.AddHours(ExpirationConfig.EXPIRATION_VALUE);
                    }
                    else if (accountTime.ExpirationType == ExpirationType.PERIOD)
                    {
                        accountTime.ExpirationTime = checked ((uint)(ExpirationConfig.EXPIRATION_VALUE * 60 * 60));
                    }
                }
                else
                {
                    accountTime.ExpirationType = ExpirationType.FREE;
                }
                DAOManager.AccountTimeDAO.InsertAccountTime(account.Id, accountTime);
                account.AccountTime = accountTime;
                account.LoginReward = new LoginReward(account.Id, 0, 0, lastTime, dayTime, birthDayTime);
                DAOManager.LoginRewardDAO.InsertLoginReward(account.LoginReward);
                account.LunaInfo = new LunaInfo(account.Id, 0L, 0, 0, 0, dayTime.AddHours(1.0));
                DAOManager.LunaDAO.Store(account.LunaInfo);
                return(account);
            }
            return(null);
        }
Beispiel #4
0
        protected override void runImpl()
        {
            LoginReward loginReward = DAOManager.LoginRewardDAO.LoadLoginReward(accountId);
            AccountTime accountTime = DAOManager.AccountTimeDAO.LoadAccountTime(accountId);

            loginReward.RewardID    = rewardId;
            loginReward.RewardIndex = rewardIndex;
            if (updataDay)
            {
                loginReward.LastRewardTime = DateAndTime.Now;
                loginReward.NextRewardTime = DateAndTime.DateAdd(DateInterval.Day, 1.0, new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 8, 0, 0));
                log.InfoFormat("帐号ID为 {0} 的用户领取了切克隆每日奖励!", (object)accountId);
            }
            if (updataBirth)
            {
                loginReward.NextBirthDayTime = DateAndTime.DateAdd(DateInterval.Year, 1.0, new DateTime(DateAndTime.Now.Year, accountTime.CreateTime.Month, accountTime.CreateTime.Day));
                log.InfoFormat("帐号ID为 {0} 的用户领取了切克隆生日奖励!", (object)accountId);
            }
            DAOManager.LoginRewardDAO.UpdataLoginReward(loginReward);
        }
Beispiel #5
0
        internal AccountTime LoadAccountTime(int id)
        {
            AccountTime     accountTime = new AccountTime(id);
            MySqlConnection connection  = DAO.GetConnection();

            try
            {
                connection.Open();
                string       cmdText      = "SELECT * FROM account_time WHERE account_id = ?account_id";
                MySqlCommand mySqlCommand = new MySqlCommand(cmdText, connection);
                mySqlCommand.Parameters.AddWithValue("?account_id", id);
                MySqlDataReader mySqlDataReader = mySqlCommand.ExecuteReader();
                if (mySqlDataReader.Read())
                {
                    accountTime.CreateTime       = mySqlDataReader.GetDateTime("create_time");
                    accountTime.LastLoginTime    = mySqlDataReader.GetDateTime("last_active");
                    accountTime.ExpirationType   = (ExpirationType)Conversions.ToInteger(Enum.Parse(typeof(ExpirationType), mySqlDataReader.GetString("expiration_type"), ignoreCase: true));
                    accountTime.ExpirationTime   = mySqlDataReader.GetUInt32("expiration_time");
                    accountTime.ExpirationPeriod = mySqlDataReader.GetDateTime("expiration_period");
                }
                mySqlDataReader.Close();
                return(accountTime);
            }
            catch (Exception ex)
            {
                ProjectData.SetProjectError(ex);
                Exception ex2 = ex;
                log.Error((object)ex2);
                ProjectData.ClearProjectError();
                return(accountTime);
            }
            finally
            {
                connection.Close();
            }
        }