Beispiel #1
0
 public Config()
 {
     // Initialize data sources
     Source = new SourceSite()
     {
         Name       = "Poe.Ninja",
         SourceApis = new List <SourceApi>()
         {
             new SourceApi()
             {
                 Display    = "Currency",
                 Url        = "https://poe.ninja/api/data/currencyoverview?league={league}&type={category}",
                 Categories = new List <string>()
                 {
                     "Currency", "Fragment"
                 }
             },
             new SourceApi()
             {
                 Display    = "Items",
                 Url        = "https://poe.ninja/api/data/itemoverview?league={league}&type={category}",
                 Categories = new List <string>()
                 {
                     "UniqueArmour", "Essence", "DivinationCard", "Prophecy", "UniqueMap",
                     "Map", "UniqueJewel", "UniqueFlask", "UniqueWeapon", "UniqueAccessory", "SkillGem"
                 }
             }
         }
     };
 }
Beispiel #2
0
        public Listing(
            CarsContext context,
            Cache cache,
            SourceSite source,
            string sourceId,
            string make,
            string model,
            int year,
            int price,
            int mileage,
            string location,
            string description)
        {
            Active = true;
            DateAdded = DateTime.Now;
            DateLastSeen = DateTime.Now;

            Source = source;
            SourceId = sourceId;
            Year = year;
            Price = price;
            Mileage = mileage;
            Description = description;

            MakeId = cache.GetOrCreate<Make>(make, () => context.Set<Make>().GetOrCreate(make));
            ModelId = cache.GetOrCreate<Model>(model, () => context.Set<Model>().GetOrCreate(model));

            County = EnumHelpers.FromString<County>(location);
        }
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime();

            eventString += DestEntity.ToLink(link, pov, this);
            eventString += " made a copy of ";
            if (FromOriginal)
            {
                eventString += "the original ";
            }
            eventString += Artifact.ToLink(link, pov, this);
            eventString += " from ";
            eventString += SourceStructure.ToLink(link, pov, this);
            eventString += " in ";
            eventString += SourceSite.ToLink(link, pov, this);
            eventString += " of ";
            eventString += SourceEntity.ToLink(link, pov, this);
            eventString += " keeping it within ";
            eventString += DestStructure.ToLink(link, pov, this);
            eventString += " in ";
            eventString += DestSite.ToLink(link, pov, this);
            eventString += PrintParentCollection(link, pov);
            eventString += ".";
            return(eventString);
        }
Beispiel #4
0
        public Trade(List <Property> properties, World world) : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "trader_hfid": Trader = world.GetHistoricalFigure(Convert.ToInt32(property.Value)); break;

                case "trader_entity_id": TraderEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "source_site_id": SourceSite = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "dest_site_id": DestSite = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "production_zone_id": ProductionZoneId = Convert.ToInt32(property.Value); break;

                case "allotment": Allotment = Convert.ToInt32(property.Value); break;

                case "allotment_index": AllotmentIndex = Convert.ToInt32(property.Value); break;

                case "account_shift": AccountShift = Convert.ToInt32(property.Value); break;
                }
            }


            SourceSite.AddEvent(this);
            DestSite.AddEvent(this);
            Trader.AddEvent(this);
            TraderEntity.AddEvent(this);
        }
Beispiel #5
0
        public override string Print(bool link = true, DwarfObject pov = null)
        {
            string eventString = GetYearTime();

            eventString += Trader.ToLink(link, pov, this);
            if (TraderEntity != null)
            {
                eventString += " of ";
                eventString += TraderEntity.ToLink(link, pov, this);
            }
            // same ranges like in "gamble" event
            var balance = AccountShift;

            if (balance >= 5000)
            {
                eventString += " made a fortune";
            }
            else if (balance >= 1000)
            {
                eventString += " did well";
            }
            else if (balance <= -1000)
            {
                eventString += " did poorly";
            }
            else if (balance <= -5000)
            {
                eventString += " lost a fortune";
            }
            else
            {
                eventString += " broke even";
            }
            eventString += " trading goods";
            if (SourceSite != null)
            {
                eventString += " from ";
                eventString += SourceSite.ToLink(link, pov, this);
            }

            if (DestSite != null)
            {
                eventString += " to ";
                eventString += DestSite.ToLink(link, pov, this);
            }

            eventString += PrintParentCollection(link, pov);
            eventString += ".";
            return(eventString);
        }
        private int AddSourceSiteIfExist(string source, int?Client_Id)
        {
            SourceSite new_sourcesite = _sourcesiteRep.FindBy(t => t.Site == source && t.ClientId == Client_Id).FirstOrDefault();

            if (new_sourcesite == null)
            {
                new_sourcesite = new SourceSite()
                {
                    Site = source, ClientId = Client_Id
                };
                _sourcesiteRep.Add(new_sourcesite);
                _sourcesiteRep.Save();
            }
            return(new_sourcesite.Id);
        }
        public ArtifactCopied(List <Property> properties, World world)
            : base(properties, world)
        {
            foreach (Property property in properties)
            {
                switch (property.Name)
                {
                case "artifact_id": Artifact = world.GetArtifact(Convert.ToInt32(property.Value)); break;

                case "dest_site_id": DestSite = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "dest_structure_id": DestStructureId = Convert.ToInt32(property.Value); break;

                case "dest_entity_id": DestEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "source_site_id": SourceSite = world.GetSite(Convert.ToInt32(property.Value)); break;

                case "source_structure_id": SourceStructureId = Convert.ToInt32(property.Value); break;

                case "source_entity_id": SourceEntity = world.GetEntity(Convert.ToInt32(property.Value)); break;

                case "from_original":
                    FromOriginal   = true;
                    property.Known = true;
                    break;
                }
            }

            if (DestSite != null)
            {
                DestStructure = DestSite.Structures.FirstOrDefault(structure => structure.Id == DestStructureId);
            }

            if (SourceSite != null)
            {
                SourceStructure = SourceSite.Structures.FirstOrDefault(structure => structure.Id == SourceStructureId);
            }

            Artifact.AddEvent(this);
            DestSite.AddEvent(this);
            DestStructure.AddEvent(this);
            DestEntity.AddEvent(this);
            SourceSite.AddEvent(this);
            SourceStructure.AddEvent(this);
            SourceEntity.AddEvent(this);
        }
Beispiel #8
0
        public RecipeParserResult Parse(string html, SourceSite settings)
        {
            var htmlDocument = new HtmlDocument();

            htmlDocument.LoadHtml(html);

            var recipe = new RecipeParserResult();

            recipe.Title                 = GetHeadline(htmlDocument, settings.TitleElement);
            recipe.Image                 = GetImage(htmlDocument, settings.ImageElement);
            recipe.Description           = GetDescription(htmlDocument, settings.DescriptionElement);
            recipe.CookingProcedureSteps = GetCookingProcedures(htmlDocument, settings.HowToElement, settings.UseBruteForce);
            recipe.Ingredients           = GetIngredients(htmlDocument, settings.IngredientsElement, settings.UseBruteForce);
            recipe.Tags = GetTags(htmlDocument, settings.TagsElement);

            return(recipe);
        }
        private async Task CorrectMiniCreator(Mini mini, CancellationToken cancellationToken)
        {
            MiniSourceSite currentSource = mini.Sources.Single();

            //Find a SourceSite that has both the same UserName and SiteName as the Mini's current
            SourceSite matchingSource = await _context.Set <SourceSite>().TagWith("MiniSubmissionHandler.cs 2")
                                        .Include(s => s.Creator).ThenInclude(c => c.Sites)
                                        .FirstOrDefaultAsync((s => s.CreatorUserName == currentSource.Site.CreatorUserName && s.SiteName == currentSource.Site.SiteName), cancellationToken);

            Creator foundCreator = matchingSource?.Creator;

            if (foundCreator != null)
            {
                _context.Remove(mini.Creator);
                mini.Creator = foundCreator;

                _context.Remove(currentSource.Site);
                currentSource.Site = matchingSource;

                return;
            }

            //If we didn't find a "perfect" match, try matching just off of the creator's names
            foundCreator = await _context.Set <Creator>().TagWith("MiniSubmissionHandler.cs 3")
                           .Include(c => c.Sites)
                           .FirstOrDefaultAsync(c => c.Name == mini.Creator.Name, cancellationToken);

            if (foundCreator != null)
            {
                mini.Creator = foundCreator;

                if (!foundCreator.Sites.Any(s => s.SiteName == currentSource.Site.SiteName))
                {
                    foundCreator.Sites.Add(currentSource.Site);
                }
            }
        }
 private int AddSourceSiteIfExist(string source, int? Client_Id)
 {
     SourceSite new_sourcesite = _sourcesiteRep.FindBy(t => t.Site == source && t.ClientId==Client_Id).FirstOrDefault();
     if (new_sourcesite == null)
     {
         new_sourcesite = new SourceSite() { Site = source, ClientId=Client_Id };
         _sourcesiteRep.Add(new_sourcesite);
         _sourcesiteRep.Save();
     }
     return new_sourcesite.Id;
 }