コード例 #1
0
        /// <summary>
        /// Store the specified API Character record in the database.
        /// </summary>
        /// <param name="apiChar"></param>
        public static void Store(APICharacter apiChar)
        {
            EMMADataSet.APICharactersDataTable table = new EMMADataSet.APICharactersDataTable();
            lock (apiCharTableAdapter)
            {
                EMMADataSet.APICharactersRow data = LoadCharFromDB(apiChar.CharID);

                bool newRow = false;

                if (data == null)
                {
                    newRow = true;

                    data = table.NewAPICharactersRow();
                    data.ID = apiChar.CharID;
                }
                data.CharSheet = apiChar.CharSheet.InnerXml;
                data.CorpSheet = apiChar.CorpSheet.InnerXml;
                data.LastCharSheetUpdate = apiChar.CharSheetXMLLastUpdate;
                data.LastCorpSheetUpdate = apiChar.CorpSheetXMLLastUpdate;
                data.LastCharAssetsUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Char, APIDataType.Assets);
                data.LastCharJournalUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Char, APIDataType.Journal);
                data.LastCharOrdersUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Char, APIDataType.Orders);
                data.LastCharTransUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Char, APIDataType.Transactions);
                data.LastCorpAssetsUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Corp, APIDataType.Assets);
                data.LastCorpJournalUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Corp, APIDataType.Journal);
                data.LastCorpOrdersUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Corp, APIDataType.Orders);
                data.LastCorpTransUpdate = apiChar.GetLastAPIUpdateTime(CharOrCorp.Corp, APIDataType.Transactions);
                data.CorpFinanceAccess = apiChar.CorpFinanceAccess;
                data.HighestCharJournalID = apiChar.GetHighestID(CharOrCorp.Char, APIDataType.Journal);
                data.HighestCharTransID = apiChar.GetHighestID(CharOrCorp.Char, APIDataType.Transactions);
                data.HighestCorpJournalID = apiChar.GetHighestID(CharOrCorp.Corp, APIDataType.Journal);
                data.HighestCorpTransID = apiChar.GetHighestID(CharOrCorp.Corp, APIDataType.Transactions);

                try
                {
                    if (newRow)
                    {
                        table.AddAPICharactersRow(data);
                        apiCharTableAdapter.Update(table);
                    }
                    else
                    {
                        apiCharTableAdapter.Update(data);
                    }
                }
                catch (Exception ex)
                {
                    throw new EMMADataException(ExceptionSeverity.Critical, "Error storing eve character " +
                        "data in the EMMA database.", ex);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Return the specified API character row direct from the EMMA database
        /// </summary>
        /// <returns></returns>
        private static EMMADataSet.APICharactersRow LoadCharFromDB(long charID)
        {
            EMMADataSet.APICharactersRow retVal = null;
            EMMADataSet.APICharactersDataTable charData = new EMMADataSet.APICharactersDataTable();

            lock (apiCharTableAdapter)
            {
                apiCharTableAdapter.ClearBeforeFill = true;
                apiCharTableAdapter.FillByID(charData, charID);
                if (charData != null)
                {
                    if (charData.Count == 1)
                    {
                        retVal = charData[0];
                    }
                }
            }

            return retVal;
        }