public static void AddAccount(Account toAdd) { string createCmd = @"INSERT OR REPLACE INTO ecmAccounts(KeyID, VCode, Expires, Access, LogonCount, MinPlayed, CreateDate, PaidUntil) VALUES(@KeyID, @VCode, @Expires, @Access, @LogonCount, @MinPlayed, @CreateDate, @PaidUntil)"; bool mustClose = false; if(sqlConnection == null || sqlConnection.State != System.Data.ConnectionState.Open) { OpenDatabase(); mustClose = true; } SQLiteCommand cmd = sqlConnection.CreateCommand(); cmd.CommandText = createCmd; cmd.Parameters.AddWithValue("@KeyID", toAdd.KeyID); cmd.Parameters.AddWithValue("@VCode", toAdd.VCode); cmd.Parameters.AddWithValue("@Expires", toAdd.Expires.ToString()); cmd.Parameters.AddWithValue("@Access", toAdd.KeyAccess); cmd.Parameters.AddWithValue("@LogonCount", toAdd.LogonCount); cmd.Parameters.AddWithValue("@MinPlayed", toAdd.LogonMinutes); cmd.Parameters.AddWithValue("@CreateDate", toAdd.CreateDate.ToString()); cmd.Parameters.AddWithValue("@PaidUntil", toAdd.PaidUntil.ToString()); cmd.ExecuteNonQuery(); if(mustClose) { CloseDatabase(); } }
public Character(Account account, long characterID, string name) { Account = account; ID = characterID; Name = name; Standings = new CharacterNPCStandings(); m_charSheetRequest = new CharacterApiRequest<CharacterSheet>(characterID, Account.KeyID, Account.VCode); m_charSheetRequest.OnRequestUpdate += ApiRequestUpdate; m_charInfoRequest = new CharacterApiRequest<CharacterInfo>(characterID, Account.KeyID, Account.VCode); m_charInfoRequest.OnRequestUpdate += ApiRequestUpdate; m_skillQueueRequest = new CharacterApiRequest<SkillQueue>(characterID, Account.KeyID, Account.VCode); m_skillQueueRequest.OnRequestUpdate += ApiRequestUpdate; m_AssetListRequest = new CharacterApiRequest<AssetList>(characterID, Account.KeyID, Account.VCode); m_AssetListRequest.OnRequestUpdate += ApiRequestUpdate; m_StandingsRequest = new CharacterApiRequest<CharacterStandings>(characterID, Account.KeyID, Account.VCode); m_StandingsRequest.OnRequestUpdate += ApiRequestUpdate; API.EveApi.AddRequest(m_charInfoRequest); API.EveApi.AddRequest(m_charSheetRequest); API.EveApi.AddRequest(m_skillQueueRequest); API.EveApi.AddRequest(m_AssetListRequest); API.EveApi.AddRequest(m_StandingsRequest); }
public static void RemoveAccount(Account toRemove) { m_Accounts.Remove(toRemove.KeyID); AccountDatabase.RemoveAccount(toRemove); }
public static void AddAccount(Account toAdd) { m_Accounts.Add(toAdd.KeyID, toAdd); foreach (Character character in toAdd.Characters) { AddCharacter(character); } // HACK: to get first character - need to find better way (and store settings!) if(CurrentCharacter == null && m_Characters.Count > 0) CurrentCharacter = m_Characters[m_FirstCharID]; UpdateGui(); }
public static List<Account> GetAllAccounts() { string selectCmd = "SELECT * FROM ecmAccounts"; bool mustClose = false; List<Account> accounts = new List<Account>(); if(sqlConnection == null || sqlConnection.State != System.Data.ConnectionState.Open) { OpenDatabase(); mustClose = true; } SQLiteCommand cmd = sqlConnection.CreateCommand(); cmd.CommandText = selectCmd; SQLiteDataReader reader = cmd.ExecuteReader(); if(reader.HasRows) { while(reader.Read()) { string keyID = reader["KeyID"].ToString(); string vCode = reader["VCode"].ToString(); API.EVE.ApiKeyMask access = (API.EVE.ApiKeyMask)Enum.Parse(typeof(API.EVE.ApiKeyMask), reader["Access"].ToString()); DateTime expires = Convert.ToDateTime(reader["Expires"].ToString()); Account newAcc = new Account(keyID, vCode, access, expires); newAcc.LogonCount = Convert.ToInt32(reader["LogonCount"].ToString()); newAcc.LogonMinutes = Convert.ToInt32(reader["MinPlayed"].ToString()); newAcc.CreateDate = Convert.ToDateTime(reader["CreateDate"].ToString()); newAcc.PaidUntil = Convert.ToDateTime(reader["PaidUntil"].ToString()); accounts.Add(newAcc); // get Characters for account GetAccountCharacters(newAcc); } } if(mustClose) { CloseDatabase(); } return accounts; }
internal static void GetAccountCharacters(Account account) { string selectCmd = "SELECT * FROM ecmCharacters WHERE AccountID = " + account.KeyID; bool mustClose = false; if(sqlConnection == null || sqlConnection.State != System.Data.ConnectionState.Open) { OpenDatabase(); mustClose = true; } SQLiteCommand cmd = sqlConnection.CreateCommand(); cmd.CommandText = selectCmd; SQLiteDataReader reader = cmd.ExecuteReader(); if(reader.HasRows) { while(reader.Read()) { string name = reader["Name"].ToString(); long charID = Convert.ToInt64(reader["ID"].ToString()); account.AddCharacter(charID, name); Character newChar = account.GetCharacter(charID); newChar.AutoUpdate = Convert.ToBoolean(reader["AutoUpdate"].ToString()); newChar.Race = reader["Race"].ToString(); newChar.Bloodline = reader["Bloodline"].ToString(); newChar.Ancestry = reader["Ancestry"].ToString(); newChar.AccountBalance = Convert.ToDouble(reader["AccountBalance"].ToString()); newChar.SkillPoints = Convert.ToInt32(reader["Skillpoints"].ToString()); newChar.ShipName = reader["ShipName"].ToString(); newChar.ShipTypeID = Convert.ToInt64(reader["ShipTypeID"].ToString()); newChar.ShipTypeName = reader["ShipTypeName"].ToString(); newChar.CorporationID = Convert.ToInt64(reader["CorporationID"].ToString()); newChar.Corporation = reader["Corporation"].ToString(); newChar.CorporationDate = Convert.ToDateTime(reader["CorporationDate"].ToString()); newChar.AllianceID = Convert.ToInt64(reader["AllianceID"].ToString()); newChar.Alliance = reader["Alliance"].ToString(); newChar.AllianceDate = Convert.ToDateTime(reader["AllianceDate"].ToString()); newChar.LastKnownLocation = reader["LastKnownLocation"].ToString(); newChar.SecurityStatus = Convert.ToDouble(reader["SecurityStatus"].ToString()); newChar.Birthday = Convert.ToDateTime(reader["Birthday"].ToString()); newChar.Gender = reader["Gender"].ToString(); newChar.CloneName = reader["CloneName"].ToString(); newChar.CloneSkillPoints = Convert.ToInt64(reader["CloneSkillpoints"].ToString()); newChar.Attributes.Intelligence = Convert.ToInt32(reader["Intelligence"].ToString()); newChar.Attributes.Memory = Convert.ToInt32(reader["Memory"].ToString()); newChar.Attributes.Perception = Convert.ToInt32(reader["Perception"].ToString()); newChar.Attributes.Willpower = Convert.ToInt32(reader["Willpower"].ToString()); newChar.Attributes.Charisma = Convert.ToInt32(reader["Charisma"].ToString()); newChar.Portrait = new System.IO.MemoryStream((byte[])reader["Portrait"]); using (MemoryStream assetStream = new System.IO.MemoryStream((byte[])reader["Assets"])) { BinaryFormatter formatter = new BinaryFormatter(); newChar.Assets = (Dictionary<long, List<AssetListInfo>>)formatter.Deserialize(assetStream); Console.WriteLine("Loading {0} assets for {1}", newChar.Assets.Count, newChar.Name); } // Get Implants GetCharacterImplants(newChar); // Get Skills GetCharacterSkills(newChar); // Get Certificates GetCharacterCertificates(newChar); // Get Standings GetCharacterStandings(newChar); } } if(mustClose) { CloseDatabase(); } }
public static void RemoveAccount(Account toRemove) { throw new NotImplementedException (); }