/// <summary> /// Deserialization constructor. /// </summary> /// <param name="serial"></param> internal Account(SerializableAccount serial) : this() { m_userId = serial.ID; m_apiKey = serial.Key; m_keyLevel = serial.KeyLevel; m_accountExpirationDate = serial.PaidUntil; m_accountCreated = serial.CreateDate; m_ignoreList.Import(serial.IgnoreList); }
/// <summary> /// Deserialization constructor. /// </summary> /// <param name="serial"></param> internal Account(SerializableAccount serial) : this() { m_userId = serial.ID; m_apiKey = serial.Key; m_keyLevel = serial.KeyLevel; m_ignoreList.Import(serial.IgnoreList); m_chractersListMonitor.Reset(serial.LastCharacterListUpdate); m_chractersListMonitor.ForceUpdate(true); }
/// <summary> /// Constructor. /// </summary> /// <param name="userID"></param> /// <param name="apiKey"></param> /// <param name="serialCharacterList"></param> /// <param name="serialBalanceList"></param> internal AccountCreationEventArgs(long userID, string apiKey, APIResult <SerializableCharacterList> serialCharacterList, APIResult <SerializableAccountBalanceList> serialBalanceList) { m_userID = userID; m_apiKey = apiKey; m_serialCharacterList = serialCharacterList; m_keyLevel = CredentialsLevel.Unknown; m_fullKeyError = ""; // Didn't test whether the ley was full because the character list was not retrieved. if (serialBalanceList == null) { m_fullKeyError = serialCharacterList.ErrorMessage; } // No error ? Then it is a full key else { m_keyLevel = Account.GetCredentialsLevel(serialBalanceList); // On error, retrieve the error message. if (m_keyLevel == CredentialsLevel.Unknown) { m_fullKeyError = serialBalanceList.ErrorMessage; } } // Retrieves the characters list if (m_serialCharacterList.HasError) { return; } foreach (var serialID in m_serialCharacterList.Result.Characters) { // Look for an existing char ID and update its name. var id = EveClient.CharacterIdentities[serialID.ID]; if (id != null) { id.Name = serialID.Name; } else { // Create an identity if necessary id = EveClient.CharacterIdentities.Add(serialID.ID, serialID.Name); } m_identities.Add(id); } }
/// <summary> /// Constructor. /// </summary> /// <param name="userID"></param> /// <param name="apiKey"></param> /// <param name="serialCharacterList"></param> /// <param name="serialBalanceList"></param> internal AccountCreationEventArgs(long userID, string apiKey, APIResult <SerializableAPIAccountStatus> serialAccountStatus, APIResult <SerializableAPICharacters> serialCharacterList) { m_userID = userID; m_apiKey = apiKey; m_serialAccountStatus = serialAccountStatus; m_serialCharacterList = serialCharacterList; m_keyLevel = CredentialsLevel.Unknown; m_fullKeyError = String.Empty; //Determine the API key level m_keyLevel = Account.GetCredentialsLevel(serialAccountStatus); // On error, retrieve the error message if (m_keyLevel == CredentialsLevel.Unknown) { m_fullKeyError = serialAccountStatus.ErrorMessage; } // Retrieves the characters list if (m_serialCharacterList.HasError) { return; } foreach (var serialID in m_serialCharacterList.Result.Characters) { // Look for an existing char ID and update its name var id = EveClient.CharacterIdentities[serialID.ID]; if (id != null) { id.Name = serialID.Name; } else { // Create an identity if necessary id = EveClient.CharacterIdentities.Add(serialID.ID, serialID.Name); } m_identities.Add(id); } }
/// <summary> /// Constructor. /// </summary> /// <param name="userID"></param> /// <param name="apiKey"></param> /// <param name="serialCharacterList"></param> /// <param name="serialBalanceList"></param> internal AccountCreationEventArgs(long userID, string apiKey, APIResult<SerializableAPIAccountStatus> serialAccountStatus, APIResult<SerializableAPICharacters> serialCharacterList) { m_userID = userID; m_apiKey = apiKey; m_serialAccountStatus = serialAccountStatus; m_serialCharacterList = serialCharacterList; m_keyLevel = CredentialsLevel.Unknown; m_fullKeyError = String.Empty; //Determine the API key level m_keyLevel = Account.GetCredentialsLevel(serialAccountStatus); // On error, retrieve the error message if (m_keyLevel == CredentialsLevel.Unknown) m_fullKeyError = serialAccountStatus.ErrorMessage; // Retrieves the characters list if (m_serialCharacterList.HasError) return; foreach (var serialID in m_serialCharacterList.Result.Characters) { // Look for an existing char ID and update its name var id = EveClient.CharacterIdentities[serialID.ID]; if (id != null) { id.Name = serialID.Name; } else { // Create an identity if necessary id = EveClient.CharacterIdentities.Add(serialID.ID, serialID.Name); } m_identities.Add(id); } }
/// <summary> /// Update when we can update the key level. /// </summary> /// <param name="result"></param> private void OnKeyLevelUpdated(APIResult <SerializableAPIAccountStatus> result) { m_lastKeyLevelUpdate = DateTime.UtcNow; m_keyLevel = GetCredentialsLevel(result); // Notify error if any if (m_keyLevel == CredentialsLevel.Unknown) { EveClient.Notifications.NotifyKeyLevelError(this, result); return; } // Notify characters changed foreach (CharacterIdentity id in CharacterIdentities) { CCPCharacter ccpCharacter = id.CCPCharacter; if (ccpCharacter != null) { EveClient.OnCharacterChanged(ccpCharacter); } } }
/// <summary> /// Updates the account with the informations extracted from the API by <see cref="AccountCreationEventArgs"/>. /// </summary> /// <param name="apiKey"></param> /// <param name="keyLevel"></param> /// <param name="identities"></param> /// <param name="charListQueryResult"></param> internal void UpdateAPIKey(string apiKey, CredentialsLevel keyLevel, IEnumerable <CharacterIdentity> identities, APIResult <SerializableAPICharacters> charListQueryResult, APIResult <SerializableAPIAccountStatus> accountStatusQueryResult) { m_apiKey = apiKey; m_keyLevel = keyLevel; m_charactersListMonitor.UpdateWith(charListQueryResult); m_accountStatusMonitor.UpdateWith(accountStatusQueryResult); // Clear the account for the currently associated identities foreach (CharacterIdentity id in EveClient.CharacterIdentities) { if (id.Account == this) { id.Account = null; } } // Assign this account to the new identities and create CCP characters foreach (CharacterIdentity id in identities) { // Skip if in the ignore list id.Account = this; if (m_ignoreList.Contains(id)) { continue; } // Retrieves the ccp character and create one if none CCPCharacter ccpCharacter = id.CCPCharacter; if (ccpCharacter == null) { ccpCharacter = new CCPCharacter(id); EveClient.Characters.Add(ccpCharacter, true); ccpCharacter.Monitored = true; } } }
/// <summary> /// Updates the account with the informations extracted from the API by <see cref="AccountCreationEventArgs"/>. /// </summary> /// <param name="apiKey"></param> /// <param name="keyLevel"></param> /// <param name="identities"></param> /// <param name="charListQueryResult"></param> internal void UpdateAPIKey(string apiKey, CredentialsLevel keyLevel, IEnumerable<CharacterIdentity> identities, APIResult<SerializableAPICharacters> charListQueryResult, APIResult<SerializableAPIAccountStatus> accountStatusQueryResult) { m_apiKey = apiKey; m_keyLevel = keyLevel; m_charactersListMonitor.UpdateWith(charListQueryResult); m_accountStatusMonitor.UpdateWith(accountStatusQueryResult); // Clear the account for the currently associated identities foreach (CharacterIdentity id in EveClient.CharacterIdentities) { if (id.Account == this) id.Account = null; } // Assign this account to the new identities and create CCP characters foreach (CharacterIdentity id in identities) { // Skip if in the ignore list id.Account = this; if (m_ignoreList.Contains(id)) continue; // Retrieves the ccp character and create one if none CCPCharacter ccpCharacter = id.CCPCharacter; if (ccpCharacter == null) { ccpCharacter = new CCPCharacter(id); EveClient.Characters.Add(ccpCharacter, true); ccpCharacter.Monitored = true; } } }
/// <summary> /// Update when we can update the key level. /// </summary> /// <param name="result"></param> private void OnKeyLevelUpdated(APIResult<SerializableAPIAccountStatus> result) { m_lastKeyLevelUpdate = DateTime.UtcNow; m_keyLevel = GetCredentialsLevel(result); // Notify error if any if (m_keyLevel == CredentialsLevel.Unknown) { EveClient.Notifications.NotifyKeyLevelError(this, result); return; } // Notify characters changed foreach (CharacterIdentity id in CharacterIdentities) { CCPCharacter ccpCharacter = id.CCPCharacter; if (ccpCharacter != null) EveClient.OnCharacterChanged(ccpCharacter); } }