Ejemplo n.º 1
0
        /// <summary>
        /// Fired when the cache needs and image that it does not currently hold.
        /// </summary>
        /// <param name="myObject"></param>
        /// <param name="args"></param>
        static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<long, Image> args)
        {
            bool success = false;
            Image pic = GetImageFromAPI(args.Key, out success);

            if (success)
            {
                StorePortrait(args.Key, pic);
                args.Data = pic;
            }
            else
            {
                EMMADataSet.PortraitsRow rowData = LoadPortraitFromDB(args.Key);
                //EMMADataSet.PortraitsRow rowData = null;
                if (rowData != null)
                {
                    MemoryStream stream = new MemoryStream(rowData.portrait);
                    pic = Image.FromStream(stream);
                    args.Data = pic;
                }
                else
                {
                    // Just use the placeholder generated by the failed call to 'GetImageFromAPI'
                    args.Data = pic;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Called when the cache requires a region name to be read from the database
        /// </summary>
        /// <param name="myObject"></param>
        /// <param name="args"></param>
        static void NameCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<long, string> args)
        {
            string name = "";

            lock (regionsTableAdapter)
            {
                EveDataSet.mapRegionsDataTable table = new EveDataSet.mapRegionsDataTable();
                regionsTableAdapter.FillByIDs(table, args.Key.ToString());
                if (table.Count > 0)
                {
                    name = table[0].regionName;
                }
            }

            if (name.Equals(""))
            {
                name = "Unknown Region (" + args.Key + ")";
            }
            // Add region ID to wormhole regions
            if (name.Trim().ToUpper().Equals("UNKNOWN"))
            {
                name = "Unknown (" + args.Key + ")";
            }

            args.Data = name;
        }
        static void LocationCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<int, int> args)
        {
            EveDataSet.mapConstellationsDataTable retVal = new EveDataSet.mapConstellationsDataTable();
            lock (tableAdapter)
            {
                tableAdapter.FillByIDs(retVal, args.Key.ToString());
            }

            if (retVal.Count > 0)
            {
                args.Data = retVal[0].regionID;
            }
        }
Ejemplo n.º 4
0
 static void Descriptions_DataUpdateNeeded(object myObject,
     DataUpdateNeededArgs<short, string> args)
 {
     string desc = "";
     _tableAdapter.GetDesc(args.Key, ref desc);
     args.Data = desc;
 }
Ejemplo n.º 5
0
 static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<long, Contract> args)
 {
     EMMADataSet.ContractsDataTable contracts = new EMMADataSet.ContractsDataTable();
     contractsTableAdapter.FillByID(contracts, args.Key);
     if (contracts.Count > 0)
     {
         args.Data = new Contract(contracts[0]);
     }
 }
Ejemplo n.º 6
0
        static void VolCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<int, double> args)
        {
            double vol = 0;

            EveDataSet.invTypesRow itemData = GetItem(args.Key);

            if (itemData == null || itemData.IsvolumeNull())
            {
                vol = 0;
            }
            else
            {
                int groupID = itemData.groupID;
                if (groupTable == null)
                {
                    groupTable = new EveDataSet.invGroupsDataTable();
                    groupsTableAdapter.Fill(groupTable);
                }
                EveDataSet.invGroupsRow groupData = groupTable.FindBygroupID(groupID);

                if (groupData.categoryID == 6)
                {
                    // If the item is a ship then use the groupID to get the unpackaged volume
                    // Shuttle
                    if (groupID == 31) { vol = 500; }
                    // Frigs, Interceptors, Covops, EAS, Assault Ships, Stealth Bombers
                    else if (groupID == 25 || groupID == 831 || groupID == 830 || groupID == 893 ||
                        groupID == 324 || groupID == 834) { vol = 2500; }
                    // Mining Barges, Exhumers
                    else if (groupID == 463 || groupID == 543) { vol = 3750; }
                    // Destroyers, Interdictors
                    else if (groupID == 420 || groupID == 541) { vol = 5000; }
                    // Cruiser, HACs, HICs, Logistics, Combat Recons, Force Recons
                    else if (groupID == 26 || groupID == 358 || groupID == 894 || groupID == 832 ||
                        groupID == 906 || groupID == 833) { vol = 10000; }
                    // Battlecruiser, Command Ships
                    else if (groupID == 419 || groupID == 540) { vol = 15000; }
                    // Industrials, Transport Ships
                    else if (groupID == 28 || groupID == 380) { vol = 20000; }
                    // Battleships, Blackops, Marauders
                    else if (groupID == 27 || groupID == 898 || groupID == 900) { vol = 50000; }
                    // Freighters, Jump Freighters
                    else if (groupID == 513 || groupID == 902) { vol = 1000000; }
                    // If the ship belongs to a different group we don't know about then just use
                    // it's unpackaged volume.
                    else { vol = itemData.volume; }
                }
                else
                {
                    vol = itemData.volume;
                }
            }

            args.Data = vol;
        }
Ejemplo n.º 7
0
        static void ReproCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<int, Dictionary<int, double>> args)
        {
            // decimal value = 0;
            Dictionary<int, double> list = new Dictionary<int, double>();

            try
            {
                EveDataSetTableAdapters.ReprocesResultsTableAdapter reproAdapter =
                    new EveMarketMonitorApp.DatabaseClasses.EveDataSetTableAdapters.ReprocesResultsTableAdapter();
                EveDataSet.ReprocesResultsDataTable reprocessResults = new EveDataSet.ReprocesResultsDataTable();

                reproAdapter.Fill(reprocessResults, args.Key);

                foreach (EveDataSet.ReprocesResultsRow row in reprocessResults)
                {
                    double quantity = row.quantity;
                    EveDataSet.invTypesRow item = Items.GetItem(args.Key);
                    int portion = (item.IsportionSizeNull() ? 0 : item.portionSize);
                    if (portion != 0)
                    {
                        quantity /= portion;
                    }
                    //value += quantity * UserAccount.CurrentGroup.ItemsTraded.GetItemValue(row.requiredTypeID);

                    list.Add(row.requiredTypeID, quantity);
                }
            }
            catch (Exception ex)
            {
                EMMAException emmaEx = ex as EMMAException;
                if (emmaEx == null)
                {
                    new EMMAException(ExceptionSeverity.Error, "Problem getting reprocessor update for item '" +
                        Items.GetItemName(args.Key) + "'", ex);
                }
            }

            //args.Data = value;
            args.Data = list;
        }
Ejemplo n.º 8
0
        static void NameCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<int, string> args)
        {
            string name = "";

            lock (tableAdapter)
            {
                tableAdapter.GetName(args.Key, ref name);
            }

            if (name.Equals(""))
            {
                AddItem(args.Key, "Unknown Item (" + args.Key + ")");
                name = "Unknown Item (" + args.Key + ")";
            }

            args.Data = name;
        }
Ejemplo n.º 9
0
 static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<int, PublicCorp> args)
 {
     PublicCorp data = null;
     EMMADataSet.PublicCorpsDataTable table =new EMMADataSet.PublicCorpsDataTable();
     tableAdapter.FillByID(table, args.Key);
     if (table.Count > 0)
     {
         data = new PublicCorp(table[0]);
     }
     args.Data = data;
 }
Ejemplo n.º 10
0
 static void SecurityCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<long, double> args)
 {
     double security = 0;
     EveDataSet.staStationsRow station = GetStation(args.Key);
     if (station != null)
     {
         EveDataSet.mapSolarSystemsRow system = SolarSystems.GetSystem(station.solarSystemID);
         if(system != null)
         {
             security = (double)system.security;
         }
     }
     args.Data = security;
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Called when the cache requires a station name to be read from the database
        /// </summary>
        /// <param name="myObject"></param>
        /// <param name="args"></param>
        static void NameCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<long, string> args)
        {
            string name = "";

            lock (stationsTableAdapter)
            {
                stationsTableAdapter.GetName((int)args.Key, ref name);
            }

            if (name.Equals(""))
            {
                name = "Unknown Station (" + args.Key + ")";
            }

            args.Data = name;
        }
Ejemplo n.º 12
0
        void PriceCache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<PriceCacheKey, decimal> args)
        {
            int itemID = args.Key.ItemID;
            long regionID = args.Key.RegionID;
            DateTime valueDate = args.Key.ValueDate;
            bool buyPrice = myObject == _buyPriceCache;

            args.Data = GetItemValue(itemID, regionID, valueDate, buyPrice);
        }
        /// <summary>
        /// Called when the cache does not contain the requested route length.
        /// Attempt to get length from the database, if it's not there then calculate it and
        /// store the result in the database.
        /// </summary>
        /// <param name="myObject"></param>
        /// <param name="args"></param>
        static void _cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<RouteKey, int> args)
        {
            int jumps = int.MaxValue;
            int startSystemID = args.Key.StartSystem;
            int endSystemID = args.Key.EndSystem;

            if (_hitLevel.ContainsKey(args.Key))
            {
                _hitLevel.Remove(args.Key);
            }

            EveDataSet.SolarSystemDistancesDataTable distances = new EveDataSet.SolarSystemDistancesDataTable();

            // try the database...
            LoadDistanceData(startSystemID, endSystemID, distances);
            EveDataSet.SolarSystemDistancesRow distanceData =
                distances.FindByFromSolarSystemIDToSolarSystemID(startSystemID, endSystemID);

            if (distanceData != null)
            {
                jumps = distanceData.Distance;
                _hitLevel.Add(args.Key, 2);
            }
            else
            {
                LoadDistanceData(endSystemID, startSystemID, distances);
                distanceData = distances.FindByFromSolarSystemIDToSolarSystemID(endSystemID, startSystemID);
                if (distanceData != null)
                {
                    jumps = distanceData.Distance;
                    SetDistance(startSystemID, endSystemID, jumps);
                    _hitLevel.Add(args.Key, 2);
                }
                else
                {
                    // If it's not in the database then we need to calculate it.
                    Map.SetCosts(1, 1, 1);
                    jumps = Map.CalcRouteLength(startSystemID, endSystemID);
                    SetDistance(startSystemID, endSystemID, jumps);
                    _hitLevel.Add(args.Key, 3);
                }
            }

            args.Data = jumps;
        }
Ejemplo n.º 14
0
        static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<string, decimal> args)
        {
            EMMADataSet.StandingsDataTable table = new EMMADataSet.StandingsDataTable();
            lock (tableAdapter)
            {
                char[] delim = { '|' };
                long toID = 0, fromID = 0;
                string[] ids = args.Key.Split(delim);
                toID = long.Parse(ids[0]);
                fromID = long.Parse(ids[1]);
                tableAdapter.FillByIDs(table, toID, fromID);
            }

            if (table.Count > 0)
            {
                args.Data = table[0].standing;
            }
            else
            {
                args.Data = 0;
            }
        }
Ejemplo n.º 15
0
 static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<long, string> args)
 {
     try
     {
         string name = "";
         lock (namesTableAdapter)
         {
             namesTableAdapter.GetName(args.Key, ref name);
         }
         if (name == null || name.Equals(""))
         {
             name = EveAPI.GetName(args.Key);
             if (!name.Equals("")) { AddName(args.Key, name); }
         }
         args.Data = name;
     }
     catch (Exception)
     {
         args.Data = null;
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Fired when the cache needs data from the database.
        /// </summary>
        /// <param name="myObject"></param>
        /// <param name="args"></param>
        static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<string, APICharacter> args)
        {
            char[] delim = {'|'};
            string[] keyData = args.Key.Split(delim);

            EVEAccount account = EveAccounts.GetAccount(int.Parse(keyData[0]));

            EMMADataSet.APICharactersRow rowData = LoadCharFromDB(long.Parse(keyData[2]));
            if (rowData != null)
            {
                args.Data = new APICharacter(long.Parse(keyData[0]), keyData[1], account.Type, rowData);
            }
            else
            {
                args.Data = null;
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Fired when the cache needs data from the database.
 /// </summary>
 /// <param name="myObject"></param>
 /// <param name="args"></param>
 static void Cache_DataUpdateNeeded(object myObject, DataUpdateNeededArgs<int, EVEAccount> args)
 {
     EMMADataSet.EveAccountsRow rowData = LoadAccountFromDB(args.Key);
     if (rowData != null)
     {
         args.Data = new EVEAccount(rowData);
     }
     else
     {
         args.Data = null;
     }
 }