コード例 #1
0
        private void SyncDown(BuddySubscription subscription)
        {
            try {
                Logger.Debug("Checking buddy cloud for new items..");
                // Fetching the known IDs will allow us to skip the items we just uploaded. A massive issue if you just logged on and have 10,000 items for download.
                var knownItems = _buddyItemDao.GetOnlineIds(subscription);
                var sync       = Get(subscription);

                // Skip items we've already have
                var items = sync.Items
                            .Where(item => !knownItems.Contains(item.Id))
                            .Select(item => ToBuddyItem(subscription, item))
                            .ToList();


                // Store items in batches, to prevent IA just freezing up if we happen to get 10-20,000 items.
                var batches = BatchUtil.ToBatches <BuddyItem>(items);
                foreach (var batch in batches)
                {
                    Logger.Debug($"Storing batch of {batch.Count} items");
                    _buddyItemDao.Save(subscription, batch);
                }
                _buddyItemDao.UpdateNames(items);

                // Delete items that no longer exist
                _buddyItemDao.Delete(subscription, sync.Removed);

                // Store timestamp to db
                subscription.LastSyncTimestamp = sync.Timestamp;
                _subscriptionRepo.Update(subscription);


                Logger.Debug($"Fetched {items.Count} items, new timestamp is {sync.Timestamp}");
            }
            catch (AggregateException ex) {
                Logger.Warn(ex.Message, ex);
                return;
            }
            catch (WebException ex) {
                Logger.Warn(ex.Message, ex);
                return;
            }
            catch (Exception ex) {
                ExceptionReporter.ReportException(ex, "SyncDown");
                Logger.Warn(ex);
                return;
            }
        }
コード例 #2
0
 private static BuddyItem ToBuddyItem(BuddySubscription subscription, CloudItemDto itemDto)
 {
     return(new BuddyItem {
         BaseRecord = itemDto.BaseRecord,
         EnchantmentRecord = itemDto.EnchantmentRecord,
         IsHardcore = itemDto.IsHardcore,
         MateriaRecord = itemDto.MateriaRecord,
         Mod = itemDto.Mod,
         ModifierRecord = itemDto.ModifierRecord,
         PrefixRecord = itemDto.PrefixRecord,
         StackCount = itemDto.StackCount,
         SuffixRecord = itemDto.SuffixRecord,
         TransmuteRecord = itemDto.TransmuteRecord,
         RemoteItemId = itemDto.Id,
         CreationDate = itemDto.CreatedAt,
         MinimumLevel = itemDto.LevelRequirement,
         Rarity = itemDto.Rarity,
         BuddyId = subscription.Id,
         PrefixRarity = itemDto.PrefixRarity,
     });
 }
コード例 #3
0
ファイル: BuddyItemsService.cs プロジェクト: marius00/iagd
        private ItemDownloadDto Get(BuddySubscription subscription)
        {
            var url = $"{Uris.BuddyItemsUrl}?id={subscription.Id}&ts={subscription.LastSyncTimestamp}";

            return(_authService.GetRestService()?.Get <ItemDownloadDto>(url));
        }
コード例 #4
0
ファイル: BuddyItemRepo.cs プロジェクト: 211847750/iagd
 public void Delete(BuddySubscription subscription, List <DeleteItemDto> items)
 {
     ThreadExecuter.Execute(
         () => _repo.Delete(subscription, items)
         );
 }
コード例 #5
0
ファイル: BuddyItemRepo.cs プロジェクト: 211847750/iagd
 public void Save(BuddySubscription subscription, List <BuddyItem> items)
 {
     ThreadExecuter.Execute(
         () => _repo.Save(subscription, items)
         );
 }
コード例 #6
0
ファイル: BuddyItemRepo.cs プロジェクト: 211847750/iagd
 public IList <string> GetOnlineIds(BuddySubscription subscription)
 {
     return(ThreadExecuter.Execute(
                () => _repo.GetOnlineIds(subscription)
                ));
 }