/// <summary> /// Get a list of the Eve accounts that are part of the specified report group /// </summary> /// <param name="rptGroupID"></param> /// <returns></returns> public static List<EVEAccount> GetGroupAccounts(int rptGroupID) { EMMADataSet.EveAccountsDataTable accountsData = new EMMADataSet.EveAccountsDataTable(); List<EVEAccount> retVal = new List<EVEAccount>(); eveAccountsTableAdapter.ClearBeforeFill = true; eveAccountsTableAdapter.FillByReportGroup(accountsData, rptGroupID); foreach (EMMADataSet.EveAccountsRow account in accountsData) { retVal.Add(new EVEAccount(account)); } return retVal; }
/// <summary> /// Store the specified Eve account in the EMMA database. /// </summary> /// <param name="account"></param> public static void Store(EVEAccount account) { EMMADataSet.EveAccountsDataTable table = new EMMADataSet.EveAccountsDataTable(); EMMADataSet.EveAccountsRow data = LoadAccountFromDB(account.UserID); bool newRow = false; if (data == null) { newRow = true; data = table.NewEveAccountsRow(); data.UserID = account.UserID; } data.APIKey = account.ApiKey; data.CharList = account.CharList.InnerXml; data.LastCharListUpdate = account.LastcharListUpdate; if (data.LastCharListUpdate.CompareTo(SqlDateTime.MinValue.Value) < 0) { data.LastCharListUpdate = SqlDateTime.MinValue.Value; } try { if (newRow) { table.AddEveAccountsRow(data); eveAccountsTableAdapter.Update(table); } else { eveAccountsTableAdapter.Update(data); } } catch (Exception ex) { throw new EMMADataException(ExceptionSeverity.Critical, "Error storing eve account data in the " + "EMMA database.", ex); } }
/// <summary> /// Return the specified account row direct from the EMMA database /// </summary> /// <returns></returns> private static EMMADataSet.EveAccountsRow LoadAccountFromDB(long userID) { EMMADataSet.EveAccountsRow retVal = null; EMMADataSet.EveAccountsDataTable accountsData = new EMMADataSet.EveAccountsDataTable(); eveAccountsTableAdapter.ClearBeforeFill = true; eveAccountsTableAdapter.FillByID(accountsData, userID); if (accountsData != null) { if (accountsData.Count == 1) { retVal = accountsData[0]; } } return retVal; }