Пример #1
0
        public void ResetFilter(bool applyToOutgoing = true)
        {
            log.Trace($"Resetting filter {(applyToOutgoing ? "Outgoing" : "Incoming")} offers");
            if (applyToOutgoing)
            {
                if (_outgoingOffers != null)
                {
                    OutgoingOffers.Clear();

                    foreach (var offer in _outgoingOffers)
                    {
                        OutgoingOffers.Add(offer);
                    }
                }
            }
            else
            {
                if (_offers != null)
                {
                    Offers.Clear();

                    foreach (var offer in _offers)
                    {
                        Offers.Add(offer);
                    }
                }
            }
        }
Пример #2
0
        public Station(XElement station)
            : base(station)
        {
            this._orders = new ObservableCollection <XElement>();
            this._offers = new ObservableCollection <XElement>();
            this._crew   = new ObservableCollection <CMember>();

            IEnumerable <XElement> crewquery =
                from crew in this.Data.Descendants().Elements("component")
                where (string)crew.Attribute("class") == "npc"
                select crew;

            foreach (XElement person in crewquery)
            {
                Crew.Add(new CMember(person));
            }

            foreach (XElement order in this.Data.Elements("trade").Elements("orders").Elements("trade"))
            {
                Orders.Add(order);
            }

            foreach (XElement offer in this.Data.Elements("trade").Elements("offers").Descendants <XElement>().Elements("trade"))
            {
                Offers.Add(offer);
            }
        }
Пример #3
0
        public async Task Load()
        {
            using (var client = new HttpClient())
            {
                URLBuilder url = new URLBuilder(_filter, controler);
                url.URL += "&ShowMyOffers=false";
                var request = new HttpRequestMessage()
                {
                    RequestUri = new Uri(url.URL),
                    Method     = HttpMethod.Get
                };
                request.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(System.Text.ASCIIEncoding.ASCII.GetBytes(string.Format("{0}:{1}", _authenticationUser.UserId.ToString(), _authenticationUser.Password))));
                var response = await client.SendAsync(request);

                var contents = await response.Content.ReadAsStringAsync();

                List <SellOfferDto> result = JsonConvert.DeserializeObject <List <SellOfferDto> >(contents);
                Offers.Clear();
                foreach (SellOfferDto bo in result)
                {
                    SellOfferWrapper boffer = bo.createSellOffer();
                    Offers.Add(boffer);
                }
            }
        }
Пример #4
0
        async Task ExecuteLoadItemsCommand(int?categoryId = null)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Offers.Clear();

                var items = await DataStore.GetItemsAsync(true, categoryId);

                foreach (var item in items)
                {
                    Offers.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #5
0
        /// <summary>
        /// Apply an offer to this calculation
        /// </summary>
        /// <param name="offer">The offer</param>
        /// <param name="value">The total value that this offer has changed the basket</param>
        public void AddOffer(Offer offer, decimal value)
        {
            var appliedOffer = new AppliedOffer();

            appliedOffer.Description = offer.Description;
            appliedOffer.PriceDelta  = value;
            Offers.Add(appliedOffer);
        }
Пример #6
0
        public void AddOffer(Offer offer)
        {
            if (offer.IsNull())
            {
                throw new ArgumentNullException(nameof(offer));
            }

            Offers.Add(offer);
        }
Пример #7
0
        //public RawMaterialOrder OrderMaterial(double quantity ,double price)
        //{
        //	//New Order Material
        //	RawMaterialOrder newOrder = new RawMaterialOrder(quantity, price);
        //	return newOrder;
        //}
        //public ChocolateOrder OrderChocolate(List<Chocolate> chocolates, IChocoBuyers buyer)
        //{
        //	//New Order Chocolate
        //	ChocolateOrder newOrder = new ChocolateOrder(chocolates, this, buyer);
        //	return newOrder;
        //}


        public RawMaterialOffer CreateOffer()
        {
            //Create an Offer
            Random selector = new Random();

            RawMaterialOffer newoffer = new RawMaterialOffer(selector.Next(2, 4), selector.Next(51, 300), this);

            Offers.Add(newoffer);

            return(newoffer);
        }
Пример #8
0
        public CountryMarketOffersListViewModel(Entities.Entity entity, Entities.Country currentCountry, IList <MarketOfferModel> offers, IList <Entities.Country> countries, IList <int> allowedProductTypes, PagingParam pagingParam, int quality, int productID)
        {
            Info = new CountryInfoViewModel(currentCountry);
            var marketService = DependencyResolver.Current.GetService <IMarketService>();

            foreach (var offer in offers)
            {
                Offers.Add(new MarketOfferViewModel(entity, offer, marketService));
            }

            initSelf(currentCountry, countries, allowedProductTypes, pagingParam, quality, productID);
        }
Пример #9
0
        private List <RawMaterialOffer> RequestOffers()
        {
            List <RawMaterialOffer> offers = new List <RawMaterialOffer>();

            foreach (var supplier in Suppliers)
            {
                RawMaterialOffer newOffer = supplier.CreateOffer();
                offers.Add(newOffer);
                Offers.Add(newOffer);
            }

            return(offers);
        }
Пример #10
0
 private void RefillOffers(IEnumerable <Ticket.UserTicket> userTickets)
 {
     InvokeOnMainThread(() => Offers.Clear());
     foreach (var userTicket in userTickets)
     {
         InvokeOnMainThread(
             () =>
             Offers.Add(new TicketOfferViewModel(userTicket.BinaryId, userTicket.Id, TicketId,
                                                 Ticket.UserServerId.Equals(ServiceBus.UserService.CurrentUser.ServerId))
         {
             NotifyOfferDeleted = OfferDeleted
         }));
     }
 }
Пример #11
0
        private void AppService_OnNewOffer(Core.Models.Offer offer)
        {
            log.Trace("New offer event");
            var config = Config;

            if (config.OnlyShowOffersOfCurrentLeague && config.CurrentLeague != offer.League)
            {
                return;
            }

            if (!offer.IsOutgoing)
            {
                AudioService.Instance.PlayNotif1();
            }

            App.Current.Dispatcher.Invoke(delegate {
                if (!offer.IsOutgoing)
                {
                    if (Offers.Count >= 8)
                    {
                        OverflowOffers.Enqueue(new Offer(offer));
                    }
                    else
                    {
                        Offers.Add(new Offer(offer));
                    }
                }
                else
                {
                    if (OutgoingOffers.Count >= 8)
                    {
                        var buffer = OutgoingOffers.ToList();
                        OverflowOutgoingOffers.Enqueue(buffer.Last());
                        buffer.RemoveAt(buffer.Count - 1);
                        OutgoingOffers.Clear();
                        buffer.ForEach(o => OutgoingOffers.Add(o));
                        OutgoingOffers.Add(new Offer(offer));
                        ReorderOutgoingOffers();
                    }
                    else
                    {
                        OutgoingOffers.Add(new Offer(offer));
                        ReorderOutgoingOffers();
                    }
                }

                OnPropertyChanged("IsOffersFilterVisible");
                OnPropertyChanged("IsOutgoingOffersFilterVisible");
            });
        }
Пример #12
0
        public void ClearOffers()
        {
            log.Trace("Clearing offers");
            AppService.Instance.FocusGame();
            Offers.Clear();


            while (OverflowOffers.Count > 0)
            {
                Offers.Add(OverflowOffers.Dequeue());
            }

            OnPropertyChanged("IsOffersFilterVisible");
        }
Пример #13
0
 public void AddOffer(Offer o)
 {
     try
     {
         /*Graph.Instance.Cypher
          *  .Match("(p:Product),(off:Offer)")
          *  .Where((Product p) => p.Id == this.Id)
          *  .AndWhere((Offer off) => off.Id == o.Id)
          *  .Create("(p)-[:HAS_OFFER]->(off)")
          *  .ExecuteWithoutResults();*/
         Offers.Add(o);
     }
     catch
     {
     }
 }
Пример #14
0
        public CompanyMarketOfferListViewModel(Entities.Company company, IQueryable <MarketOfferModel> marketOffers, PagingParam pagingParam,
                                               CompanyRights rights, IMarketService marketService)
        {
            Info          = new CompanyInfoViewModel(company);
            CompanyRights = rights;

            PagingParam = pagingParam;
            if (marketOffers.Count() > 0)
            {
                var filteredOffers = marketOffers.OrderByDescending(mo => mo.OfferID).Apply(PagingParam).ToList();

                foreach (var offer in filteredOffers)
                {
                    Offers.Add(new MarketOfferViewModel(SessionHelper.CurrentEntity, offer, marketService, deleteable: true, showDetails: true));
                }
            }
        }
Пример #15
0
        public void FilterOffers(string searchText, bool applyToOutgoing = true)
        {
            log.Trace($"Filtering {(applyToOutgoing ? "Outgoing" : "Incoming")} offers with {searchText}");

            searchText = searchText.ToLower().Trim();

            ResetFilter(applyToOutgoing);

            if (applyToOutgoing)
            {
                var results = OutgoingOffers.ToList().FindAll(e => e.ItemName.ToLower().IndexOf(searchText) != -1 || e.PlayerName.ToLower().IndexOf(searchText) != -1);

                if (_outgoingOffers == null)
                {
                    _outgoingOffers = new Offer[OutgoingOffers.Count];
                }

                OutgoingOffers.CopyTo(_outgoingOffers, 0);
                OutgoingOffers.Clear();

                foreach (var r in results)
                {
                    OutgoingOffers.Add(r);
                }
            }
            else
            {
                var results = Offers.ToList().FindAll(e => e.ItemName.ToLower().IndexOf(searchText) != -1 || e.PlayerName.ToLower().IndexOf(searchText) != -1);

                if (_offers == null)
                {
                    _offers = new Offer[Offers.Count];
                }

                Offers.CopyTo(_offers, 0);
                Offers.Clear();

                foreach (var r in results)
                {
                    Offers.Add(r);
                }
            }
        }
        public JobMarketOfferListViewModel(IList <JobOfferDOM> offers, int countryID, int workTypeID, int offerType, double minSkill, double maxSkill, double minSalary, double maxSalary, bool includeRegionInformation, PagingParam pagingParam)
        {
            PParam     = pagingParam;
            CountryID  = countryID;
            WorkTypeID = workTypeID;
            OfferType  = offerType;
            MinSalary  = minSalary;
            MaxSalary  = maxSalary;
            MinSkill   = minSkill;
            MaxSkill   = maxSkill;
            var currency = Persistent.Countries.GetCountryCurrency(countryID);

            foreach (var offer in offers)
            {
                Offers.Add(new JobMarketOfferViewModel(offer, currency));
            }

            IncludeRegionInformation = includeRegionInformation;
            IsCitizen = (SessionHelper.CurrentEntity.EntityID == SessionHelper.LoggedCitizen.ID);
        }
Пример #17
0
        public void RemoveOffer(int id, bool isOutgoing = false)
        {
            log.Trace($"Removing offer {id}");
            int index = isOutgoing ? OutgoingOffers.Select(e => e.Id)
                        .ToList()
                        .IndexOf(id) : Offers.Select(e => e.Id)
                        .ToList()
                        .IndexOf(id);

            if (index != -1)
            {
                App.Current.Dispatcher.Invoke(() => {
                    var refOffers = (isOutgoing ? OutgoingOffers : Offers);
                    refOffers.RemoveAt(index);

                    if (refOffers.Count < 8)
                    {
                        if (isOutgoing)
                        {
                            if (OverflowOutgoingOffers.Count > 0)
                            {
                                OutgoingOffers.Add(OverflowOutgoingOffers.Dequeue());
                                ReorderOutgoingOffers();
                            }
                        }
                        else
                        {
                            if (OverflowOffers.Count > 0)
                            {
                                Offers.Add(OverflowOffers.Dequeue());
                            }
                        }
                    }

                    UpdateOffers();
                    AppService.Instance.FocusGame();
                });
            }
        }
Пример #18
0
        protected CatalogPage(IReadOnlyPacket packet)
        {
            Id         = packet.ReadInt();
            Mode       = packet.ReadString();
            LayoutCode = packet.ReadString();

            short n = packet.ReadLegacyShort();

            for (int i = 0; i < n; i++)
            {
                Images.Add(packet.ReadString());
            }

            n = packet.ReadLegacyShort();
            for (int i = 0; i < n; i++)
            {
                Texts.Add(packet.ReadString());
            }

            n = packet.ReadLegacyShort();
            for (int i = 0; i < n; i++)
            {
                Offers.Add(CatalogOffer.Parse(packet));
            }

            UnknownIntA = packet.ReadInt();
            AcceptSeasonCurrencyAsCredits = packet.ReadBool();
            if (packet.Available > 0)
            {
                n = packet.ReadLegacyShort();
                for (int i = 0; i < n; i++)
                {
                    Data.Add(CatalogPageData.Parse(packet));
                }
            }
        }
Пример #19
0
        private void UpdateOffers()
        {
            log.Trace("Updating offers");
            Offer[] buffer = new Offer[Offers.Count];
            Offers.CopyTo(buffer, 0);
            Offers.Clear();

            foreach (var o in buffer)
            {
                Offers.Add(o);
            }

            Offer[] buffer2 = new Offer[OutgoingOffers.Count];
            OutgoingOffers.CopyTo(buffer2, 0);
            OutgoingOffers.Clear();

            foreach (var o in buffer2)
            {
                OutgoingOffers.Add(o);
            }

            OnPropertyChanged("IsOffersFilterVisible");
            OnPropertyChanged("IsOutgoingOffersFilterVisible");
        }
Пример #20
0
        public override void ParseFromNetworkMessage(NetworkMessage message)
        {
            CategoryName   = message.ReadString();
            DisplayOfferId = message.ReadUInt32();
            WindowType     = message.ReadByte();

            Collections.Capacity = message.ReadByte();
            for (var i = 0; i < Collections.Capacity; ++i)
            {
                Collections.Add(message.ReadString());
            }

            if (Client.VersionNumber >= 11900000)
            {
                DisplaySubCategory = message.ReadString();
            }

            Offers.Capacity = message.ReadUInt16();
            for (var i = 0; i < Offers.Capacity; ++i)
            {
                var offer = new Offer
                {
                    Name       = message.ReadString(),
                    IsFeatured = WindowType == 3
                };

                offer.Details.Capacity = message.ReadByte();
                for (var j = 0; j < offer.Details.Capacity; ++j)
                {
                    var details = new OfferDetails
                    {
                        Id     = message.ReadUInt32(),
                        Amount = message.ReadUInt16(),
                        Price  = message.ReadUInt32()
                    };

                    if (Client.VersionNumber >= 11900000)
                    {
                        details.IsConfirmedPrice = message.ReadBool();
                    }

                    details.IsDisabled = message.ReadBool();
                    if (details.IsDisabled)
                    {
                        details.DisabledReasons.Capacity = message.ReadByte();
                        for (var x = 0; x < details.DisabledReasons.Capacity; ++x)
                        {
                            var disabledReason = message.ReadString();
                            details.DisabledReasons.Add(disabledReason);
                        }
                    }

                    details.HighlightState = message.ReadByte();
                    if (details.HighlightState == (int)StoreOfferHighlightState.Sale)
                    {
                        // This may actually be wrong, but since there aren't currently
                        // any items on sale I can't confirm it.
                        var saleValidUntilTimestamp = message.ReadUInt32();
                        var basePrice = message.ReadUInt32();
                    }

                    offer.Details.Add(details);
                }

                offer.DisplayType = message.ReadByte();
                if (offer.DisplayType == 0) // image (.png)
                {
                    offer.DisplayImage = message.ReadString();
                }
                else if (offer.DisplayType == 1) // mount id
                {
                    offer.DisplayMountId = message.ReadUInt16();
                }
                else if (offer.DisplayType == 2) // outfit
                {
                    offer.DisplayLooktype    = message.ReadUInt16();
                    offer.DisplayColorHead   = message.ReadByte();
                    offer.DisplayColorTorso  = message.ReadByte();
                    offer.DisplayColorLegs   = message.ReadByte();
                    offer.DisplayColorDetail = message.ReadByte();
                }
                else if (offer.DisplayType == 3) // item id
                {
                    offer.DisplayItemId = message.ReadUInt16();
                }
                else if (offer.DisplayType == 4) // male/female outfit
                {
                    offer.GenderToShow          = message.ReadByte();
                    offer.DisplayFemaleLooktype = message.ReadUInt16();
                    offer.DisplayMaleLooktype   = message.ReadUInt16();
                    offer.DisplayColorHead      = message.ReadByte();
                    offer.DisplayColorTorso     = message.ReadByte();
                    offer.DisplayColorLegs      = message.ReadByte();
                    offer.DisplayColorDetail    = message.ReadByte();
                }

                offer.TryType           = message.ReadByte(); // 0 = disabled, 1 = mounts/outfits, 2 = hireling dresses
                offer.Collection        = message.ReadString();
                offer.PopularityScore   = message.ReadUInt16();
                offer.NewUntilTimestamp = message.ReadUInt32();
                offer.NeedsUserConfigurationBeforeBuying = message.ReadBool();

                offer.Products.Capacity = message.ReadUInt16();
                for (var j = 0; j < offer.Products.Capacity; ++j)
                {
                    var subOffer = new Offer
                    {
                        Name        = message.ReadString(),
                        DisplayType = message.ReadByte()
                    };

                    if (subOffer.DisplayType == 0) // image (.png)
                    {
                        subOffer.DisplayImage = message.ReadString();
                    }
                    else if (subOffer.DisplayType == 1) // mount id
                    {
                        subOffer.DisplayMountId = message.ReadUInt16();
                    }
                    else if (subOffer.DisplayType == 2) // outfit
                    {
                        subOffer.DisplayLooktype    = message.ReadUInt16();
                        subOffer.DisplayColorHead   = message.ReadByte();
                        subOffer.DisplayColorTorso  = message.ReadByte();
                        subOffer.DisplayColorLegs   = message.ReadByte();
                        subOffer.DisplayColorDetail = message.ReadByte();
                    }
                    else if (subOffer.DisplayType == 3) // item sprite
                    {
                        subOffer.DisplayItemId = message.ReadUInt16();
                    }
                    else if (subOffer.DisplayType == 4) // male/female outfit
                    {
                        subOffer.GenderToShow          = message.ReadByte();
                        subOffer.DisplayFemaleLooktype = message.ReadUInt16();
                        subOffer.DisplayMaleLooktype   = message.ReadUInt16();
                        subOffer.DisplayColorHead      = message.ReadByte();
                        subOffer.DisplayColorTorso     = message.ReadByte();
                        subOffer.DisplayColorLegs      = message.ReadByte();
                        subOffer.DisplayColorDetail    = message.ReadByte();
                    }
                    offer.Products.Add(subOffer);
                }
                Offers.Add(offer);
            }

            if (CategoryName.Equals("Search", StringComparison.CurrentCultureIgnoreCase))
            {
                TooManySearchResults = message.ReadBool();
            }

            if (WindowType == 3) // Home
            {
                Banners.Capacity = message.ReadByte();
                for (var i = 0; i < Banners.Capacity; ++i)
                {
                    var banner = new Banner
                    {
                        Image = message.ReadString(),
                        Type  = message.ReadByte()
                    };

                    if (banner.Type == 2)
                    {
                        banner.Category   = message.ReadString();
                        banner.Collection = message.ReadString();
                    }
                    else if (banner.Type == 4)
                    {
                        banner.OfferId = message.ReadUInt32();
                    }

                    banner.Unknown = message.ReadUInt16(); // Always 0x0200 (512)?
                    Banners.Add(banner);
                }
                BannerSwitchDelay = message.ReadByte();
            }
        }
Пример #21
0
        public void GetPage(int page, int min_price, int max_price, int order = 0)
        {
            string url = "";

            if (page <= 1)
            {
                url = "https://www.dns-shop.ru/catalog/c01df46f39137fd7/stiralnye-mashiny/?price=" + min_price.ToString() + "-" + max_price.ToString();
            }
            else
            {
                url = "https://www.dns-shop.ru/catalog/c01df46f39137fd7/stiralnye-mashiny/?p=" + page.ToString() + "&price=" + min_price.ToString() + "-" + max_price.ToString();
            }

            if (order >= 1)
            {
                url += "&order=" + order.ToString();
            }

            var    data         = GetURL(url);
            var    json         = JObject.Parse(data);
            var    html         = json["html"].ToString();
            CQ     cq           = CQ.Create(html);
            var    priceRequest = new PriceContainer();
            var    containers   = priceRequest.containers;
            string cnt          = json["data"]["itemsCount"].ToString();

            cq["div .catalog-item"].Each(c =>
            {
                var guid = c.GetAttribute("data-guid");
                if (guid == "")
                {
                    return;
                }
                var offer        = new Offer();
                offer.guid       = guid;
                var product      = c.Cq().Find(".n-catalog-product__main");
                var product_info = product.Find(".product-info");
                var price        = product.Find(".product-min-price");
                var link         = product_info.Find(".ui-link");
                var pics         = product_info.Find("picture");
                offer.Name       = link.Text().Trim();
                offer.URL        = link[0].GetAttribute("href").Trim();
                if (pics[0] != null)
                {
                    offer.Image = pics[0][0].GetAttribute("data-srcset");
                }
                offer.Rating    = product_info.Find(".product-info__rating")[0].GetAttribute("data-rating").Trim();
                offer.Character = product_info.Find(".product-info__title-description").Text().Trim();
                offer.PriceId   = price[0].GetAttribute("id");
                containers.Add(new PriceRequest()
                {
                    id   = offer.PriceId,
                    data = new GuidContainer()
                    {
                        id = offer.guid
                    }
                });
                GetCharacters(guid, offer);
                Thread.Sleep(1000);
                Offers.Add(offer);
            });

            string jsonPriceRequest = JsonConvert.SerializeObject(priceRequest);

            FormUrlEncodedContent content = new FormUrlEncodedContent(new Dictionary <string, string>()
            {
                { "data", jsonPriceRequest }
            });

            data = PostURL("https://www.dns-shop.ru/ajax-state/min-price/?cityId=17", content);

            json = JObject.Parse(data);
            foreach (var price in json["data"]["states"])
            {
                var pid   = price["id"].ToString();
                var offer = Offers.Where(t => t.PriceId == pid).First();
                offer.Price = int.Parse(price["data"]["current"].ToString());
                if (offer.Price < 20000)
                {
                    offer.Familly.Budget = Budget.small;
                }
                if (offer.Price >= 20000 && offer.Price < 35000)
                {
                    offer.Familly.Budget = Budget.normal;
                }
                if (offer.Price >= 35000)
                {
                    offer.Familly.Budget = Budget.big;
                }
            }

            if (page == 1)
            {
                ElementsOnPage = Offers.Count;
            }
            int cntElements = 0;

            int.TryParse(string.Join("", cnt.Where(c => char.IsDigit(c))), out cntElements);
            CntElements = cntElements;
        }
Пример #22
0
 public void RegisterOffer(Offer offer)
 {
     Offers.Add(offer);
 }
Пример #23
0
 public void AddOffer(int num, int price, int res1, int unlockinglevel)
 {
     Offers.Add(new OfferConfig(num, price, res1, unlockinglevel));
 }