Пример #1
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are
        /// refreshed (prices, titles ...).
        /// </summary>
        /// <param name="message">Message that contains information about the process that is occurring.</param>
        public void onMarketItemsRefreshFinished(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message);

            string[]          marketItemsChanges = Regex.Split(message, "#SOOM#");
            List <MarketItem> marketItems        = new List <MarketItem>();

            foreach (string mic in marketItemsChanges)
            {
                if (string.IsNullOrEmpty(mic.Trim()))
                {
                    continue;
                }

                JSONObject micJSON           = new JSONObject(mic);
                string     productId         = micJSON["productId"].str;
                string     marketPrice       = micJSON["market_price"].str;
                string     marketTitle       = micJSON["market_title"].str;
                string     marketDescription = micJSON["market_desc"].str;
                try {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId);
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPrice       = marketPrice;
                    mi.MarketTitle       = marketTitle;
                    mi.MarketDescription = marketDescription;
                    pvi.save();

                    marketItems.Add(mi);
                } catch (VirtualItemNotFoundException ex) {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }
Пример #2
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are
        /// refreshed (prices, titles ...).
        /// </summary>
        /// <param name="message">Message that contains information about the process that is occurring.</param>
        public void onMarketItemsRefreshFinished(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message);

            var eventJSON = new JSONObject(message);

            List <MarketItem> marketItems = new List <MarketItem>();

            foreach (var micJSON in eventJSON.list)
            {
                string productId          = micJSON[StoreJSONConsts.MARKETITEM_PRODUCT_ID].str;
                string marketPrice        = micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICE].str;
                string marketTitle        = micJSON[StoreJSONConsts.MARKETITEM_MARKETTITLE].str;
                string marketDescription  = micJSON[StoreJSONConsts.MARKETITEM_MARKETDESC].str;
                string marketCurrencyCode = micJSON[StoreJSONConsts.MARKETITEM_MARKETCURRENCYCODE].str;
                long   marketPriceMicros  = System.Convert.ToInt64(micJSON[StoreJSONConsts.MARKETITEM_MARKETPRICEMICROS].n);
                try {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId);
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPriceAndCurrency = marketPrice;
                    mi.MarketTitle            = marketTitle;
                    mi.MarketDescription      = marketDescription;
                    mi.MarketCurrencyCode     = marketCurrencyCode;
                    mi.MarketPriceMicros      = marketPriceMicros;
                    pvi.Save();

                    marketItems.Add(mi);
                } catch (VirtualItemNotFoundException ex) {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }
Пример #3
0
        public static void onMarketItemsRefreshFinished(MarketItemsRefreshFinishedEvent _Event)
        {
            List <SoomlaWpStore.domain.MarketItem> pluginMarketItems = _Event.GetMarketItems();

            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + pluginMarketItems.Count);

            List <MarketItem> marketItems = new List <MarketItem>();

            foreach (SoomlaWpStore.domain.MarketItem mic in pluginMarketItems)
            {
                try
                {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(mic.getProductId());
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPriceAndCurrency = mic.getMarketPrice();
                    mi.MarketTitle            = mic.getMarketTitle();
                    mi.MarketDescription      = mic.getMarketDescription();
                    if (mic.isPriceSuccessfullyParsed())
                    {
                        mi.MarketPriceMicros  = mic.getMarketPriceMicros();
                        mi.MarketCurrencyCode = mic.getMarketCurrencyCode();
                    }
                    pvi.Save();

                    marketItems.Add(mi);
                }
                catch (VirtualItemNotFoundException ex)
                {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }
Пример #4
0
        /// <summary>
        /// Handles the <c>onMarketItemsRefreshFinished</c> event, which is fired when items associated with market are
        /// refreshed (prices, titles ...).
        /// </summary>
        /// <param name="message">Message that contains information about the process that is occurring.</param>
        public void onMarketItemsRefreshFinished(string message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onMarketItemsRefreshFinished: " + message);

            string[]          marketItemsChanges = Regex.Split(message, "#SOOM#");
            List <MarketItem> marketItems        = new List <MarketItem>();

            foreach (string mic in marketItemsChanges)
            {
                if (string.IsNullOrEmpty(mic.Trim()))
                {
                    continue;
                }

                JSONObject micJSON            = new JSONObject(mic);
                string     productId          = micJSON[JSONConsts.MARKETITEM_PRODUCT_ID].str;
                string     marketPrice        = micJSON[JSONConsts.MARKETITEM_MARKETPRICE].str;
                string     marketTitle        = micJSON[JSONConsts.MARKETITEM_MARKETTITLE].str;
                string     marketDescription  = micJSON[JSONConsts.MARKETITEM_MARKETDESC].str;
                string     marketCurrencyCode = micJSON[JSONConsts.MARKETITEM_MARKETCURRENCYCODE].str;
                long       marketPriceMicros  = System.Convert.ToInt64(micJSON[JSONConsts.MARKETITEM_MARKETPRICEMICROS].n);
                try {
                    PurchasableVirtualItem pvi = StoreInfo.GetPurchasableItemWithProductId(productId);
                    MarketItem             mi  = ((PurchaseWithMarket)pvi.PurchaseType).MarketItem;
                    mi.MarketPriceAndCurrency = marketPrice;
                    mi.MarketTitle            = marketTitle;
                    mi.MarketDescription      = marketDescription;
                    mi.MarketCurrencyCode     = marketCurrencyCode;
                    mi.MarketPriceMicros      = marketPriceMicros;
                    pvi.save();

                    marketItems.Add(mi);
                } catch (VirtualItemNotFoundException ex) {
                    SoomlaUtils.LogDebug(TAG, ex.Message);
                }
            }

            StoreEvents.OnMarketItemsRefreshFinished(marketItems);
        }