Beispiel #1
0
        public PyObjectData GetMarketGroups()
        {
            // this one is a messy boy, there is a util.FilterRowset which is just used here presumably
            // due to this being an exclusive case, better build it manually and call it a day
            Rowset result = Database.PrepareRowsetQuery("SELECT marketGroupID, parentGroupID, marketGroupName, description, graphicID, hasTypes, 0 AS types, 0 AS dataID FROM invMarketGroups ORDER BY parentGroupID");

            // build some dicts to know what points where
            Dictionary <int, List <int> > marketToTypeID = new Dictionary <int, List <int> >();
            // Dictionary<int, int> marketToParent = new Dictionary<int, int>();
            Dictionary <int, List <int> > parentToMarket   = new Dictionary <int, List <int> >();
            Dictionary <int, List <int> > marketTypeIDsMap = new Dictionary <int, List <int> >();

            MySqlConnection connection = null;
            MySqlDataReader reader     = null;

            reader = Database.Query(ref connection, "SELECT marketGroupID, parentGroupID FROM invMarketGroups");

            using (connection)
                using (reader)
                {
                    while (reader.Read() == true)
                    {
                        int child  = reader.GetInt32(0);
                        int parent = reader.IsDBNull(1) == true ? -1 : reader.GetInt32(1);

                        if (parentToMarket.ContainsKey(parent) == false)
                        {
                            parentToMarket[parent] = new List <int>();
                        }

                        parentToMarket[parent].Add(child);
                        // marketToParent[child] = parent;
                    }
                }

            connection = null;

            reader = Database.Query(ref connection, "SELECT marketGroupID, typeID FROM invTypes WHERE marketGroupID IS NOT NULL ORDER BY marketGroupID");

            using (connection)
                using (reader)
                {
                    while (reader.Read() == true)
                    {
                        int marketGroupID = reader.GetInt32(0);
                        int typeID        = reader.GetInt32(1);

                        if (marketToTypeID.ContainsKey(marketGroupID) == false)
                        {
                            marketToTypeID[marketGroupID] = new List <int>();
                        }

                        marketToTypeID[marketGroupID].Add(typeID);
                    }
                }

            // maps for ids are already built, time to build the correct list of item types
            this.BuildItemTypeList(ref marketTypeIDsMap, marketToTypeID, parentToMarket, -1);

            PyDictionary finalResult = new PyDictionary();
            PyNone       key         = new PyNone();

            foreach (PyList row in result.Rows)
            {
                PyInteger  marketGroupID = row[0] as PyInteger;
                PyDataType parentGroupID = row[1];

                PyList <PyInteger> types = new PyList <PyInteger>();

                if (marketTypeIDsMap.TryGetValue(marketGroupID, out List <int> typeIDsMap) == true)
                {
                    foreach (int typeID in typeIDsMap)
                    {
                        types.Add(typeID);
                    }
                }

                row[6] = types;

                PyDataType resultKey = parentGroupID ?? key;

                if (finalResult.TryGetValue(resultKey, out PyList values) == false)
                {
                    finalResult[resultKey] = values = new PyList();
                }

                values.Add(row);
            }

            return(new PyObjectData("util.FilterRowset", new PyDictionary
            {
                ["header"] = result.Header,
                ["idName"] = "parentGroupID",
                ["RowClass"] = new PyToken("util.Row"),
                ["idName2"] = null,
                ["items"] = finalResult
            }
                                    ));
        }
Beispiel #2
0
        public PyDataType GetContractList(PyObjectData filtersKeyval, CallInformation call)
        {
            PyDictionary <PyString, PyDataType> filters = KeyVal.ToDictionary(filtersKeyval).GetEnumerable <PyString, PyDataType>();
            PyList <PyInteger> notIssuedByIDs           = null;
            PyList <PyInteger> issuedByIDs = null;

            call.NamedPayload.TryGetValue("startContractID", out PyInteger startContractID);
            int resultsPerPage = call.NamedPayload["num"] as PyInteger;

            filters.TryGetValue("regionID", out PyInteger regionID);
            filters.TryGetValue("stationID", out PyInteger stationID);
            filters.TryGetValue("solarSystemID", out PyInteger solarSystemID);
            filters.TryGetValue("itemTypeID", out PyInteger itemTypeID);
            filters.TryGetValue("assigneeID", out PyInteger assigneeID);
            filters.TryGetValue("itemGroupID", out PyInteger itemGroupID);
            filters.TryGetValue("itemCategoryID", out PyInteger itemCategoryID);
            filters.TryGetValue("priceMax", out PyInteger priceMax);
            filters.TryGetValue("priceMin", out PyInteger priceMin);
            filters.TryGetValue("type", out PyInteger type);
            filters.TryGetValue("description", out PyString description);

            if (priceMax < 0 || priceMin < 0 || priceMax < priceMin)
            {
                throw new ConMinMaxPriceError();
            }

            if (filters.TryGetValue("issuedByIDs", out PyList issuedIDs) == true && issuedIDs is not null)
            {
                issuedByIDs = issuedIDs.GetEnumerable <PyInteger>();
            }
            if (filters.TryGetValue("notIssuedByIDs", out PyList notIssuedIDs) == true && notIssuedIDs is not null)
            {
                notIssuedByIDs = notIssuedIDs.GetEnumerable <PyInteger>();
            }

            // limit the number of results to 100
            if (resultsPerPage > 100)
            {
                resultsPerPage = 100;
            }

            int?locationID = null;

            if (stationID is not null)
            {
                locationID = stationID;
            }
            else if (solarSystemID is not null)
            {
                locationID = solarSystemID;
            }
            else if (regionID is not null)
            {
                locationID = regionID;
            }

            List <int> contractList = this.DB.GetContractList(
                startContractID, resultsPerPage, itemTypeID, notIssuedByIDs, issuedByIDs, assigneeID,
                locationID, itemGroupID, itemCategoryID, priceMax ?? 0, priceMin ?? 0, type, description,
                call.Client.EnsureCharacterIsSelected(), call.Client.CorporationID
                );

            return(KeyVal.FromDictionary(new PyDictionary()
            {
                ["contracts"] = this.DB.GetInformationForContractList(contractList),
                ["bids"] = this.DB.GetBidsForContractList(contractList),
                ["items"] = this.DB.GetItemsForContractList(contractList)
            }
                                         ));
        }
Beispiel #3
0
 private void ExtractExtraCharacterAppearance(PyDictionary data, out PyInteger accessoryID,
                                              out PyInteger beardID, out PyInteger decoID, out PyInteger lipstickID, out PyInteger makeupID,
                                              out PyDecimal morph1e, out PyDecimal morph1n, out PyDecimal morph1s, out PyDecimal morph1w,
                                              out PyDecimal morph2e, out PyDecimal morph2n, out PyDecimal morph2s, out PyDecimal morph2w,
                                              out PyDecimal morph3e, out PyDecimal morph3n, out PyDecimal morph3s, out PyDecimal morph3w,
                                              out PyDecimal morph4e, out PyDecimal morph4n, out PyDecimal morph4s, out PyDecimal morph4w)
 {
     data.TryGetValue("accessoryID", out accessoryID);
     data.TryGetValue("beardID", out beardID);
     data.TryGetValue("decoID", out decoID);
     data.TryGetValue("lipstickID", out lipstickID);
     data.TryGetValue("makeupID", out makeupID);
     data.TryGetValue("morph1e", out morph1e);
     data.TryGetValue("morph1n", out morph1n);
     data.TryGetValue("morph1s", out morph1s);
     data.TryGetValue("morph1w", out morph1w);
     data.TryGetValue("morph2e", out morph2e);
     data.TryGetValue("morph2n", out morph2n);
     data.TryGetValue("morph2s", out morph2s);
     data.TryGetValue("morph2w", out morph2w);
     data.TryGetValue("morph3e", out morph3e);
     data.TryGetValue("morph3n", out morph3n);
     data.TryGetValue("morph3s", out morph3s);
     data.TryGetValue("morph3w", out morph3w);
     data.TryGetValue("morph4e", out morph4e);
     data.TryGetValue("morph4n", out morph4n);
     data.TryGetValue("morph4s", out morph4s);
     data.TryGetValue("morph4w", out morph4w);
 }
Beispiel #4
0
 private void ExtractCharacterAppearance(PyDictionary data, out PyInteger costumeID, out PyInteger eyebrowsID,
                                         out PyInteger eyesID, out PyInteger hairID, out PyInteger skinID, out PyInteger backgroundID,
                                         out PyInteger lightID, out PyDecimal headRotation1, out PyDecimal headRotation2,
                                         out PyDecimal headRotation3, out PyDecimal eyeRotation1, out PyDecimal eyeRotation2,
                                         out PyDecimal eyeRotation3, out PyDecimal camPos1, out PyDecimal camPos2, out PyDecimal camPos3)
 {
     if (data.TryGetValue("costumeID", out costumeID) == false)
     {
         throw new Exception("Cannot get costumeID from character appearance");
     }
     if (data.TryGetValue("eyebrowsID", out eyebrowsID) == false)
     {
         throw new Exception("Cannot get eyebrowsID from character appearance");
     }
     if (data.TryGetValue("eyesID", out eyesID) == false)
     {
         throw new Exception("Cannot get eyesID from character appearance");
     }
     if (data.TryGetValue("hairID", out hairID) == false)
     {
         throw new Exception("Cannot get hairID from character appearance");
     }
     if (data.TryGetValue("skinID", out skinID) == false)
     {
         throw new Exception("Cannot get skinID from character appearance");
     }
     if (data.TryGetValue("backgroundID", out backgroundID) == false)
     {
         throw new Exception("Cannot get backgroundID from character appearance");
     }
     if (data.TryGetValue("lightID", out lightID) == false)
     {
         throw new Exception("Cannot get lightID from character appearance");
     }
     if (data.TryGetValue("headRotation1", out headRotation1) == false)
     {
         throw new Exception("Cannot get headRotation1 from character appearance");
     }
     if (data.TryGetValue("headRotation2", out headRotation2) == false)
     {
         throw new Exception("Cannot get headRotation2 from character appearance");
     }
     if (data.TryGetValue("headRotation3", out headRotation3) == false)
     {
         throw new Exception("Cannot get headRotation3 from character appearance");
     }
     if (data.TryGetValue("eyeRotation1", out eyeRotation1) == false)
     {
         throw new Exception("Cannot get eyeRotation1 from character appearance");
     }
     if (data.TryGetValue("eyeRotation2", out eyeRotation2) == false)
     {
         throw new Exception("Cannot get eyeRotation2 from character appearance");
     }
     if (data.TryGetValue("eyeRotation3", out eyeRotation3) == false)
     {
         throw new Exception("Cannot get eyeRotation3 from character appearance");
     }
     if (data.TryGetValue("camPos1", out camPos1) == false)
     {
         throw new Exception("Cannot get camPos1 from character appearance");
     }
     if (data.TryGetValue("camPos2", out camPos2) == false)
     {
         throw new Exception("Cannot get camPos2 from character appearance");
     }
     if (data.TryGetValue("camPos3", out camPos3) == false)
     {
         throw new Exception("Cannot get camPos3 from character appearance");
     }
 }
Beispiel #5
0
        private void HandleOnItemUpdate(Notifications.Nodes.Inventory.OnItemChange change)
        {
            foreach ((PyInteger itemID, PyDictionary _changes) in change.Updates)
            {
                PyDictionary <PyString, PyTuple> changes = _changes.GetEnumerable <PyString, PyTuple>();

                ItemEntity item = this.ItemFactory.LoadItem(itemID, out bool loadRequired);

                // if the item was just loaded there's extra things to take into account
                // as the item might not even need a notification to the character it belongs to
                if (loadRequired == true)
                {
                    // trust that the notification got to the correct node
                    // load the item and check the owner, if it's logged in and the locationID is loaded by us
                    // that means the item should be kept here
                    if (this.ItemFactory.TryGetItem(item.LocationID, out ItemEntity location) == false || this.CharacterManager.IsCharacterConnected(item.OwnerID) == false)
                    {
                        // this item should not be loaded, so unload and return
                        this.ItemFactory.UnloadItem(item);
                        return;
                    }

                    bool locationBelongsToUs = true;

                    switch (location)
                    {
                    case Station _:
                        locationBelongsToUs = this.SystemManager.StationBelongsToUs(location.ID);
                        break;

                    case SolarSystem _:
                        locationBelongsToUs = this.SystemManager.SolarSystemBelongsToUs(location.ID);
                        break;
                    }

                    if (locationBelongsToUs == false)
                    {
                        this.ItemFactory.UnloadItem(item);
                        return;
                    }
                }

                OnItemChange itemChange = new OnItemChange(item);

                // update item and build change notification
                if (changes.TryGetValue("locationID", out PyTuple locationChange) == true)
                {
                    PyInteger oldValue = locationChange[0] as PyInteger;
                    PyInteger newValue = locationChange[1] as PyInteger;

                    itemChange.AddChange(ItemChange.LocationID, oldValue);
                    item.LocationID = newValue;
                }

                if (changes.TryGetValue("quantity", out PyTuple quantityChange) == true)
                {
                    PyInteger oldValue = quantityChange[0] as PyInteger;
                    PyInteger newValue = quantityChange[1] as PyInteger;

                    itemChange.AddChange(ItemChange.Quantity, oldValue);
                    item.Quantity = newValue;
                }

                if (changes.TryGetValue("ownerID", out PyTuple ownerChange) == true)
                {
                    PyInteger oldValue = ownerChange[0] as PyInteger;
                    PyInteger newValue = ownerChange[1] as PyInteger;

                    itemChange.AddChange(ItemChange.OwnerID, oldValue);
                    item.OwnerID = newValue;
                }

                if (changes.TryGetValue("singleton", out PyTuple singletonChange) == true)
                {
                    PyBool oldValue = singletonChange[0] as PyBool;
                    PyBool newValue = singletonChange[1] as PyBool;

                    itemChange.AddChange(ItemChange.Singleton, oldValue);
                    item.Singleton = newValue;
                }

                // TODO: IDEALLY THIS WOULD BE ENQUEUED SO ALL OF THEM ARE SENT AT THE SAME TIME
                // TODO: BUT FOR NOW THIS SHOULD SUFFICE
                // send the notification
                this.NotificationManager.NotifyCharacter(item.OwnerID, "OnMultiEvent",
                                                         new PyTuple(1)
                {
                    [0] = new PyList(1)
                    {
                        [0] = itemChange
                    }
                });

                if (item.LocationID == this.ItemFactory.LocationRecycler.ID)
                {
                    // the item is removed off the database if the new location is the recycler
                    item.Destroy();
                }
                else if (item.LocationID == this.ItemFactory.LocationMarket.ID)
                {
                    // items that are moved to the market can be unloaded
                    this.ItemFactory.UnloadItem(item);
                }
                else
                {
                    // save the item if the new location is not removal
                    item.Persist();
                }
            }
        }