コード例 #1
0
        /// <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);
            }
        }