public PlayerStoneFactoryAccountInfo[] GetAllPlayerStoneFactoryAccountInfos() { List <PlayerStoneFactoryAccountInfo> listFactories = new List <PlayerStoneFactoryAccountInfo>(); MyDBHelper.Instance.ConnectionCommandSelect(mycmd => { string sqlText = "select f.*, s.UserName from playerstonefactoryaccountinfo f left join playersimpleinfo s on f.UserID = s.id "; mycmd.CommandText = sqlText; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd); adapter.Fill(table); var items = MetaDBAdapter <PlayerStoneFactoryAccountInfo> .GetPlayerStoneFactoryAccountInfoItemFromDataTable(table); table.Dispose(); adapter.Dispose(); if (items == null || items.Length == 0) { return; } foreach (var account in items) { if (account.LastFeedSlaveTime != null) { account.SlaveLiveDiscountms = StoneFactoryConfig.OnceFeedFoodSlaveCanLivems - (int)(DateTime.Now - account.LastFeedSlaveTime.ToDateTime()).TotalSeconds; } else { account.SlaveLiveDiscountms = 0; } SumUserAccountStoneStackCount(account, mycmd); SumUserAccountProfitRMBCount(account, mycmd); listFactories.Add(account); } }); return(listFactories.ToArray()); }
public PlayerStoneFactoryAccountInfo GetPlayerStoneFactoryAccountInfo(int userID) { PlayerStoneFactoryAccountInfo account = null; MyDBHelper.Instance.ConnectionCommandSelect(mycmd => { string sqlText = "select ttt.*, s.UserName from " + " (select f.* from playerstonefactoryaccountinfo f where f.`UserID`=@UserID ) ttt " + " left join playersimpleinfo s on ttt.UserID = s.id "; mycmd.Parameters.AddWithValue("@UserID", userID); mycmd.CommandText = sqlText; DataTable table = new DataTable(); MySqlDataAdapter adapter = new MySqlDataAdapter(mycmd); adapter.Fill(table); var items = MetaDBAdapter <PlayerStoneFactoryAccountInfo> .GetPlayerStoneFactoryAccountInfoItemFromDataTable(table); table.Dispose(); adapter.Dispose(); if (items == null || items.Length == 0) { return; } account = items[0]; if (account.LastFeedSlaveTime != null) { account.SlaveLiveDiscountms = StoneFactoryConfig.OnceFeedFoodSlaveCanLivems - (int)(DateTime.Now - account.LastFeedSlaveTime.ToDateTime()).TotalSeconds; } else { account.SlaveLiveDiscountms = 0; } SumUserAccountStoneStackCount(account, mycmd); SumUserAccountProfitRMBCount(account, mycmd); }); return(account); }