Example #1
0
        private void Delete()
        {
            // TODO: Delete [for deletion, loop while there are items to delete => then sleep)
            var items = _playerItemDao.GetItemsMarkedForOnlineDeletion();

            if (items.Count > 0)
            {
                var ids        = Uri.EscapeDataString(JsonConvert.SerializeObject(items.Select(m => m.OID)));
                var parameters = $"token={_token}&ids={ids}";
                var result     = Post(parameters, DeleteUrl);
                if (string.IsNullOrEmpty(result))
                {
                    Logger.Warn("Error removing items from remote backup server");
                    return;
                }

                var obj = JsonConvert.DeserializeObject <PlayerItemBackupDeleteResponse>(result);
                if (!obj.Success)
                {
                    Logger.Warn($"Error {obj.ErrorCode} deleting items from online backup.");
                }
                else
                {
                    if (_playerItemDao.ClearItemsMarkedForOnlineDeletion() != items.Count)
                    {
                        Logger.Warn($"Not all deletion tags were removed.");
                    }
                    else
                    {
                        Logger.Info("Remove backup server notified of deleted items");
                    }
                }
            }
        }
Example #2
0
 public IList <ItemIdentifierDto> GetItemsMarkedForOnlineDeletion()
 {
     return(_playerItemDao.GetItemsMarkedForOnlineDeletion()
            .Select(item => new ItemIdentifierDto {
         Id = item.Id
     })
            .ToList());
 }
        public void TestRemoveHalfStack()
        {
            const long oid = 456499611;
            long       id;
            {
                var item = new PlayerItem {
                    BaseRecord       = "for-testing-item-halfstack-removal",
                    Mod              = string.Empty,
                    MinimumLevel     = 200,
                    LevelRequirement = 200,
                    StackCount       = 30,
                    OnlineId         = oid
                };
                dao.Save(item);


                item.Id.Should().Be.GreaterThan(0);
                id = item.Id;
            }


            // Reduce to 15
            {
                var reloaded = dao.GetByOnlineId(oid);
                reloaded.Id.Should().Be.EqualTo(id);
                reloaded.StackCount = 15;
                dao.Update(new List <PlayerItem> {
                    reloaded
                }, true);
            }


            // Ensure the online ID has been cleared
            {
                var reloaded = dao.GetByOnlineId(oid);
                reloaded.Should().Be.Null();
            }

            // Ensure the item still exists
            {
                var reloaded = dao.GetById(id);
                reloaded.Should().Not.Be.Null();
                reloaded.Count.Should().Be.EqualTo(15);
            }

            // Ensure the old OID is marked for removal
            var deletionEntry = dao.GetItemsMarkedForOnlineDeletion().FirstOrDefault(m => m.OID == oid);

            deletionEntry.Should().Not.Be.Null();
        }
Example #4
0
 public IList <DeletedPlayerItem> GetItemsMarkedForOnlineDeletion()
 {
     return(ThreadExecuter.Execute(
                () => repo.GetItemsMarkedForOnlineDeletion()
                ));
 }