public NotificationModel(HotItem item, NotifierRule rule, String message, DateTime timeStamp, NotificationType notificationType)
        {
            this.DataId = item.DataId;
            this.NotificationType = notificationType;
            this.TimeStamp = timeStamp;
            this.Message = message;
            this.Item = item;
            if (this.Item != null)
            {
                this.BuyMoney = item.BuyMoney;
                this.SellMoney = item.SellMoney;
            }

            if (NotificationType == NotificationType.Buy)
            {
                this.RuleBuy = rule;
            }
            else if (NotificationType == NotificationType.Sell)
            {
                this.RuleSell = rule;
            }
        }
        public SearchResult ParseSearch(SearchResult sr, JObject json)
        {
            if (sr == null)
                sr = new SearchResult();

            try
            {
                sr.Count = json["count"].ToObject<int>();

                int page = json["page"].ToObject<int>();
                if (page == 0)
                    page++;
                page--;// Yeah that makes sense \o/

                sr.Offset = page * ItemsPerPage + 1;
                sr.Total = json["total"].ToObject<int>();
                JToken token = json["results"];
                for (int i = 0; i < token.Count(); i++)
                {
                    int dataId = token[i]["data_id"].ToObject<int>();
                    string name = token[i]["name"].ToObject<String>();
                    string imgUri = token[i]["img"].ToObject<String>();
                    HotItem item = new HotItem(dataId)
                    {
                        Name = name,
                        SellPrice = token[i]["min_sale_unit_price"].ToObject<int>(),
                        BuyPrice = token[i]["max_offer_unit_price"].ToObject<int>(),
                        BuyVolume = token[i]["offer_availability"].ToObject<long>(),
                        SaleVolume = token[i]["sale_availability"].ToObject<long>(),
                        DateTimeStamp = token[i]["price_last_changed"].ToObject<String>(),
                        Rarity = token[i]["rarity"].ToObject<int>(),
                        ImgUri = imgUri,
                        Quantity = token[i]["sale_availability"].ToObject<int>(),
                        Level = token[i]["restriction_level"].ToObject<int>()
                    };

                    sr.Items.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            return sr;
        }
        public HotItem ParseItemListing(HotItem item, JObject json)
        {
            if (item == null)
                item = new HotItem();
            try
            {
                try
                {
                    item.BuyPrice = json["result"]["max_offer_unit_price"].ToObject<int>();
                }
                catch
                {

                }
                try
                {
                    item.SellPrice = json["result"]["min_sale_unit_price"].ToObject<int>();
                }
                catch
                {

                }

                item.BuyVolume = json["result"]["offer_availability"].ToObject<int>();
                item.SaleVolume = json["result"]["sale_availability"].ToObject<int>();
            }
            catch
            {

            }
            return item;
        }
        public HotItem ParseItem(HotItem item, JObject json)
        {
            if (item == null)
                item = new HotItem();
            try
            {
                try
                {
                    item.Name = json["result"]["name"].ToObject<String>();
                }
                catch
                {

                }

                try
                {
                    item.ImgUri = json["result"]["img"].ToObject<String>();
                }
                catch
                {

                }
            }
            catch
            {

            }
            return item;
        }
 public void UnregisterRecipeItem(HotItem item)
 {
     UnregisterRecipeItem(item.DataId);
 }
 public void Remove(HotItem item)
 {
     //item.BuyNotification -= new EventHandler<NotificationEventArgs>(item_BuyNotification);
     //item.SellNotification -= new EventHandler<NotificationEventArgs>(item_SellNotification);
     item.BuyPriceChanged -= new EventHandler<PriceChangedEventArgs>(item_BuyPriceChanged);
     item.SellPriceChanged -= new EventHandler<PriceChangedEventArgs>(item_SellPriceChanged);
     Queue.Remove(item);
 }
        public void RegisterRecipeItem(HotItem item)
        {
            int dataId = item.DataId;
            if (!RecipeItemPool.ContainsKey(dataId))
            {
                var newItem = new HotItem(dataId);
                newItem.Built += newItem_Built;
                newItem.Crawled += newItem_Crawled;
                RecipeItemPool.Add(dataId, newItem);
            }

            RecipeItemPool[dataId].Items.Add(item);
        }
Exemplo n.º 8
0
        public void GroupItem(HotItem item, IList<HotItem> result)
        {
            int quantity = result.Sum(x => x.Quantity);
            double avg = result.Average(x => x.UnitPrice);
            this.UnitPrice = (int)Math.Round(avg);
            this.Quantity = quantity;

            this.DisplayName = String.Format("Transactions {0}", result.Count());
            this.DateTimeStamp = item.DateTimeStamp;
            this.TransactionTime = result.OrderByDescending(t => t.TransactionTime).First().TransactionTime;

            if (TransactionTime == DateTime.MinValue)
            {
                var tempDateTime = ParseTimeStamp(DateTimeStamp);
                if (tempDateTime.HasValue)
                {
                    this.TransactionTime = tempDateTime.Value;
                }
            }

            this.Name = item.Name;
            this.ItemBuildDone = item.ItemBuildDone;
            this.Image = item.Image;
            this.ListingId = item.ListingId;
            this.DataId = item.DataId;
            this.BuyPrice = item.BuyPrice;
            this.SellPrice = item.SellPrice;
        }
 //private void LoadRavenDB()
 //{
 //    //MongoClient = new MongoClient("mongodb://localhost");
 //    //MongoServer = MongoClient.GetServer();
 //    //var db = MongoServer.GetDatabase("ztpn");
 //    var path = Path.Combine(ZicoresUtils.Zicore.Configuration.ConfigHelper.GetConfigFolder(), "RavenDB");
 //    DocumentStore = new EmbeddableDocumentStore { DataDirectory = path };
 //    DocumentStore.Initialize();
 //    ItemStore = new ItemStore(DocumentStore);
 //}
 private void UpdateItem(HotItem item1, HotItem item2)
 {
     item1.Name = item2.Name;
     item1.SellPrice = item2.SellPrice;
     item1.BuyPrice = item2.BuyPrice;
     item1.Rarity = item2.Rarity;
     item1.RarityWord = item2.RarityWord;
     //item1.BuyContext = item2.BuyContext;
     //item1.SellContext = item2.SellContext;
     item1.SaleVolume = item2.SaleVolume;
     item1.BuyVolume = item2.BuyVolume;
     item1.Image = item2.Image;
     item1.ImgUri = item2.ImgUri;
 }
 public void AddNotificationMessage(HotItem item, String message)
 {
     NotificationModel m = new NotificationModel(item, null, message, item.TransactionTimeLocal, NotificationType.Undefined);
     m.AsTransaction();
     AddBuyNotification(m);
 }
 private void RemoveInternal(HotItem item)
 {
     HotItemController.Remove(item);
 }
 private void AddItemInternal(HotItem item)
 {
     HotItemController.Add(item);
 }
 public ItemContext(bool isSellContext, HotItem item)
 {
     this.IsSellContext = isSellContext;
     this.Item = item;
 }
        public void Register(HotItem item, ObservableDataSource<ItemProxy> items)
        {
            items.SetYMapping(y => y.SellPrice);
            items.SetXMapping(x => HorizontalAxis.ConvertToDouble(x.DateTime));

            ChartPlotter.AddLineGraph(items, 2.0, item.Name + " S");

            chartItems.Add(item.DataId, items);
            item.PropertyChanged += item_PropertyChanged;
        }
 public void Add(HotItem item)
 {
     //item.BuyNotification += new EventHandler<NotificationEventArgs>(item_BuyNotification);
     //item.SellNotification += new EventHandler<NotificationEventArgs>(item_SellNotification);
     item.BuyPriceChanged += new EventHandler<PriceChangedEventArgs>(item_BuyPriceChanged);
     item.SellPriceChanged += new EventHandler<PriceChangedEventArgs>(item_SellPriceChanged);
     Queue.Add(item);
 }
 public void ViewRecipe(HotItem item)
 {
     Task.Factory.StartNew(() =>
     {
         int itemId = HotItemController.DataIdToRecipeId(item.DataId);
         if (itemId > 0)
         {
             Recipe recipe = HotItemController.RecipeDB.Find(x => x.CreatedItemId == itemId);
             Add(recipe);
         }
     });
 }
Exemplo n.º 17
0
        public static HotItem CreateGroupItem(HotItem item, IList<HotItem> items)
        {
            HotItem groupItem = new HotItem(item.DataId);
            item.Parent = groupItem;
            groupItem.IsGroup = true;

            var result = items.Where(x => x.DataId == item.DataId).ToList();

            foreach (var i in result)
            {
                groupItem.Items.Add(i);
            }

            groupItem.GroupItem(item, result);
            return groupItem;
        }