public override Offer Create(XElement xml)
        {
            int        id;
            int        bid;
            int?       cbid;
            bool       isAvailable;
            string     url;
            double     price;
            string     currencyId;
            CategoryId categoryId;
            string     picture;
            bool?      delivery;
            string     description;

            XmlParser.ParseOfferPart(xml, out id, out bid, out cbid, out isAvailable, out url, out price, out currencyId, out categoryId,
                                     out picture, out delivery, out description);
            OfferKind kindOfBook = GetOfferKindById(Convert.ToInt32(categoryId.Text), xml);
            string    name       = xml.Element("name").Value;
            string    author     = xml.Element("author").Value;
            int       year       = Convert.ToInt32(xml.Element("year").Value);
            string    publisher  = xml.Element("publisher").Value;
            string    isbn       = xml.Element("ISBN").Value;
            string    language   = xml.Element("language").Value;
            string    series;

            if (xml.Elements().SingleOrDefault(el => el.Name == "series") != null)
            {
                series = xml.Element("series").Value;
            }
            {
                series = null;
            }
            bool      downloadable = Convert.ToBoolean(xml.Element("downloadable").Value);
            OfferType newType      = GetType(xml.Attribute("type").Value, xml);

            return(new Book()
            {
                Id = id,
                OfferType = newType,
                BId = bid,
                IsAvailable = isAvailable,
                CBId = cbid,
                Url = url,
                Price = price,
                CurrencyId = currencyId,
                CategoryId = categoryId,
                Picture = picture,
                Delivery = delivery,
                Description = description,
                Name = name,
                Author = author,
                Year = year,
                Publisher = publisher,
                ISBN = isbn,
                Language = language,
                Series = series,
                Downloadable = downloadable,
                KindOfBook = kindOfBook
            });
        }
Example #2
0
        private Entry GetEntryFromUrl(string url, OfferKind kind, bool house = false)
        {
            var offerToParse = GetParsedHtmlFromUrl(url);
            var paragraphs   = offerToParse.QuerySelectorAll(".c p");
            var floor        = MatchOrNull(TryGetParagraphValueString(paragraphs, "Piętro:"), "([0-9]+|Parter)")?.Value;

            floor = floor == "Parter" ? "0" : floor;
            PolishCity city;
            var        description = offerToParse.QuerySelector(".c .col-md-9 > p").Text();

            return(new Entry
            {
                OfferDetails = new OfferDetails
                {
                    Url = url,
                    CreationDateTime = DateTime.Parse(offerToParse.QuerySelector(".ann-panel-right p:last-of-type b:last-of-type").Text()),
                    OfferKind = kind,
                    SellerContact = new SellerContact
                    {
                        //Not a proper email validation but it's simple
                        Email = MatchOrNull(description, @"\w+@\w+\.\w+")?.Value,
                        Telephone = GetParsedHtmlFromUrl(
                            $"{mainUrl}/ajax_daj_telefon.php?hash={offerToParse.QuerySelector(".tel-btn")?.GetAttribute("data-hash")}&token={offerToParse.QuerySelector(".tel-btn")?.GetAttribute("data-token")}")
                                    ?.QuerySelector("a")
                                    ?.Text() ?? MatchOrNull(description, "([0-9]{3}(-| )?){2}[0-9]{3}")?.Value,
                        Name = offerToParse.QuerySelector(".ann-panel-right > p > b").Text()
                    },
                    IsStillValid = true
                },
                PropertyAddress = new PropertyAddress
                {
                    City = Enum.TryParse(MatchOrNull(url, "m_(?<city>[a-z_]+)[-/]").Groups["city"]?.Value.ToUpper(), out city) ? city : default,
Example #3
0
 public Offer(OfferId offerid, OfferKind kind, uint typeid, uint amount, uint pieceprice, string character, TerminationType terminationtype)
 {
     this.OfferId         = offerid;
     this.Kind            = kind;
     this.TypeId          = typeid;
     this.Amount          = amount;
     this.PiecePrice      = pieceprice;
     this.Character       = character;
     this.TerminationType = terminationtype;
 }
Example #4
0
        public OfferStatistic(double timestamp, OfferKind kind, uint totaltransactions, uint totalprice, uint maximumprice, uint minimumprice)
        {
            double   ts = Math.Floor(timestamp / 86400) * 86400;
            DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime();

            dt                     = dt.AddMilliseconds(ts);
            this.Timestamp         = dt;
            this.Kind              = kind;
            this.TotalTransactions = totaltransactions;
            this.TotalPrice        = totalprice;
            this.MaximumPrice      = maximumprice;
            this.MinimumPrice      = minimumprice;
        }
        public override Offer Create(XElement xml)
        {
            int        id;
            int        bid;
            int?       cbid;
            bool       isAvailable;
            string     url;
            double     price;
            string     currencyId;
            CategoryId categoryId;
            string     picture;
            bool?      delivery;
            string     description;

            XmlParser.ParseOfferPart(xml, out id, out bid, out cbid, out isAvailable, out url, out price, out currencyId, out categoryId,
                                     out picture, out delivery, out description);
            string    typePrefix           = xml.Element("typePrefix").Value;
            double    localDeliveryCost    = Convert.ToDouble(xml.Element("local_delivery_cost").Value);
            string    countryOfOrigin      = xml.Element("country_of_origin").Value;
            bool      manufacturerWarranty = Convert.ToBoolean(xml.Element("manufacturer_warranty").Value);
            string    vendor     = xml.Element("vendor").Value;
            string    vendorCode = xml.Element("vendorCode").Value;
            string    model      = xml.Element("model").Value;
            OfferType type       = GetType(xml.Attribute("type").Value, xml);
            OfferKind kind       = GetOfferKindById(Convert.ToInt32(categoryId.Text), xml);

            return(new OfficeEquipment()
            {
                Id = id,
                OfferType = type,
                BId = bid,
                IsAvailable = isAvailable,
                CBId = cbid,
                Url = url,
                Price = price,
                CurrencyId = currencyId,
                CategoryId = categoryId,
                Picture = picture,
                Delivery = delivery,
                Description = description,
                TypePrefix = typePrefix,
                LocalDeliveryCost = localDeliveryCost,
                CountryOfOrigin = countryOfOrigin,
                ManufacturerWarranty = manufacturerWarranty,
                Vendor = vendor,
                VendorCode = vendorCode,
                Model = model,
                KindOfOfficeEquipment = kind
            });
        }
        public override Offer Create(XElement xml)
        {
            int        id;
            int        bid;
            int?       cbid;
            bool       isAvailable;
            string     url;
            double     price;
            string     currencyId;
            CategoryId categoryId;
            string     picture;
            bool?      delivery;
            string     description;

            XmlParser.ParseOfferPart(xml, out id, out bid, out cbid, out isAvailable, out url, out price, out currencyId, out categoryId,
                                     out picture, out delivery, out description);
            double    localDeliveryCost = Convert.ToDouble(xml.Element("local_delivery_cost").Value);
            string    worldRegion       = xml.Element("worldRegion").Value;
            string    country           = xml.Element("country").Value;
            string    region            = xml.Element("region").Value;
            OfferType type = GetType(xml.Attribute("type").Value, xml);
            OfferKind kind = GetOfferKindById(Convert.ToInt32(categoryId.Text), xml);

            return(new Travel()
            {
                Id = id,
                OfferType = type,
                BId = bid,
                IsAvailable = isAvailable,
                CBId = cbid,
                Url = url,
                Price = price,
                CurrencyId = currencyId,
                CategoryId = categoryId,
                Picture = picture,
                Delivery = delivery,
                Description = description,
                LocalDeliveryCost = localDeliveryCost,
                WorldRegion = worldRegion,
                Country = country,
                Region = region,
                KindOfTravel = kind
            });
        }
Example #7
0
        public override Offer Create(XElement xml)
        {
            int        id;
            int        bid;
            int?       cbid;
            bool       isAvailable;
            string     url;
            double     price;
            string     currencyId;
            CategoryId categoryId;
            string     picture;
            bool?      delivery;
            string     description;

            XmlParser.ParseOfferPart(xml, out id, out bid, out cbid, out isAvailable, out url, out price, out currencyId, out categoryId,
                                     out picture, out delivery, out description);
            string    title       = xml.Element("title").Value;
            string    storage     = xml.Element("media").Value;
            int       year        = Convert.ToInt32(xml.Element("year").Value);
            OfferKind kindOfMedia = GetOfferKindById(Convert.ToInt32(categoryId.Text), xml);
            OfferType offerType   = GetType(xml.Attribute("type").Value, xml);

            return(new Media()
            {
                Id = id,
                OfferType = offerType,
                BId = bid,
                IsAvailable = isAvailable,
                CBId = cbid,
                Url = url,
                Price = price,
                CurrencyId = currencyId,
                CategoryId = categoryId,
                Picture = picture,
                Delivery = delivery,
                Description = description,
                Title = title,
                Storage = storage,
                Year = year,
                KindOfMedia = kindOfMedia
            });
        }
        public OfferDetails ReturnOfferDetails(HtmlNode htmlbody, string url)
        {
            var phone       = htmlbody.SelectSingleNode("//a[@class='phoneButton__button']");
            var seller      = htmlbody.SelectSingleNode("//div[@class='offerOwner__details']/h3[@class='offerOwner__person ']");
            var whatPrice   = htmlbody.SelectSingleNode("//span[@class='priceInfo__value']");
            var bruttoPrice = whatPrice != null && whatPrice.InnerText.Any(x => char.IsDigit(x)) ? Convert.ToDecimal(whatPrice.InnerText.Split("zł")[0].Replace(" ", string.Empty)) : 0;

            OfferKind sale = bruttoPrice == 0 || bruttoPrice > 10000 ? OfferKind.SALE : OfferKind.RENTAL;

            return(new OfferDetails
            {
                Url = url,
                CreationDateTime = DateTime.Now,
                LastUpdateDateTime = DateTime.Now,
                OfferKind = sale,
                SellerContact = new SellerContact
                {
                    Telephone = phone != null ? phone.Attributes["data-full-phone-number"].Value.Trim() : "brak informacji",
                    Name = seller != null?seller.InnerText.Trim() : "brak informacji"
                },
                IsStillValid = true
            });
        }
Example #9
0
 public OfferStatistic(double timestamp, OfferKind kind, uint totaltransactions, uint totalprice, uint maximumprice, uint minimumprice)
 {
     double ts = Math.Floor(timestamp / 86400) * 86400;
     DateTime dt = new DateTime(1970, 1, 1, 0, 0, 0).ToUniversalTime();
     dt = dt.AddMilliseconds(ts);
     this.Timestamp = dt;
     this.Kind = kind;
     this.TotalTransactions = totaltransactions;
     this.TotalPrice = totalprice;
     this.MaximumPrice = maximumprice;
     this.MinimumPrice = minimumprice;
 }
Example #10
0
 public Offer(OfferId offerid, OfferKind kind, uint typeid, uint amount, uint pieceprice, string character, TerminationType terminationtype)
 {
     this.OfferId = offerid;
     this.Kind = kind;
     this.TypeId = typeid;
     this.Amount = amount;
     this.PiecePrice = pieceprice;
     this.Character = character;
     this.TerminationType = terminationtype;
 }
Example #11
0
        private void ReadMarketOffer(InMessage message, OfferKind offer, ushort request)
        {
            uint Timestamp = message.ReadUInt();
            ushort Counter = message.ReadUShort();
            ushort TypeId = 0;
            switch (request)
            {
                case 65534:
                case 65535:
                    TypeId = message.ReadUShort();
                    break;
                default:
                    TypeId = request;
                    break;
            }
            ushort Amount = message.ReadUShort();
            uint PiecePrice = message.ReadUInt();
            string Character = "";
            TerminationType TerminationType = Domain.TerminationType.Active;
            switch (request)
            {
                case 65534:
                    break;
                case 65535:
                    TerminationType = (TerminationType)message.ReadByte();
                    break;
                default:
                    Character = message.ReadString();
                    break;
            }

            client.Market.Offers.Add(new Offer(new OfferId(Timestamp, Counter), offer, TypeId, Amount, PiecePrice, Character, TerminationType));
        }
Example #12
0
        internal void SendServerMarketCreate(OfferKind kind, ushort itemid, ushort amount, uint pieceprice, bool isanonymous)
        {
            if (!client.LoggedIn)
                return;

            var message = new OutMessage();
            message.WriteByte(0xF5);
            message.WriteByte((byte)kind);
            message.WriteUShort(itemid);
            message.WriteUShort(amount);
            message.WriteUInt(pieceprice);
            message.WriteByte(Convert.ToByte(isanonymous));

            client.Proxy.SendToServer(message);
        }