Ejemplo n.º 1
0
        private void GetItemsLocalesAsync(IEnumerable <WowApiLocalizedData> items)
        {
            CultureInfo   culture   = Settings.LocalizationCulture;
            var           apiKey    = Services.ViewModels.SettingsViewModel.GetBattleNetApiKey();
            IDataProvider provider  = DataProviderManager.GetHttpCachedProvider();
            var           grabber   = new WowApiClient(provider, culture, apiKey);
            Type          dataType  = SelectedDataType.DataType;
            int           batchSize = 50; // for query throttling, this is the number of items per second we allow to be processed
            TimeSpan      throttle  = TimeSpan.FromMilliseconds(1000d / batchSize);

            Observable.Start(() =>
            {
                var unprocessed = items.Where(o => o.Status == LocalizationStatus.Unprocessed);
                while (unprocessed.Any())
                {
                    var item = unprocessed.First();
                    try
                    {
                        item.Query = grabber.GetUrl(dataType, item.ItemId);
                        item.Data  = provider.ProvideData(item.Query);
                    }
                    catch (Exception ex)
                    {
                        // if we got an error, keep it to investigate
                        item.Error = ex.Message;
                        break;     // stop processing if any error
                    }
                    System.Threading.Thread.Sleep((int)throttle.TotalMilliseconds);
                }
            });
        }
Ejemplo n.º 2
0
 public static void ClassInit(TestContext context)
 {
     _client = new WowApiClient(Region.US, Locale.en_US, ApiKey);
 }