Exemplo n.º 1
0
        public async Task <Reply> AddNode(R2PackagePart pkgPart, CancellationToken cancelTkn)
        {
            var errors   = new List <string>();
            var warnings = new List <string>();

            if (!pkgPart.IsValid(ref errors))
            {
                goto ReturnReply;
            }

            if (await AlreadyInServer(pkgPart, cancelTkn))
            {
                warnings.Add($"“{pkgPart.PackageFilename}” part {pkgPart.PartNumber} of {pkgPart.TotalParts} already exists in the server.");
                goto ReturnReply;
            }

            var dict = await _client.PostNode(pkgPart, cancelTkn);

            //todo: add status and result to returned reply

ReturnReply:
            return(new Reply
            {
                Errors = errors,
                Warnings = warnings
            });
        }
Exemplo n.º 2
0
        public async void CanPostDeletePackagePart()
        {
            (await _sut.EnableWriteAccess(_creds)).Should().BeTrue();
            var sampl = SamplePkgPart();
            var fNme  = sampl.PackageFilename;
            var hash  = sampl.PackageHash;

            var list = await _parts.ListByPkgHash(fNme, hash, new CancellationToken());

            list.Should().HaveCount(0);

            var reply = await _sut.PostNode(sampl, new CancellationToken());

            reply.Should().NotBeNull();
            reply.IsSuccessful.Should().BeTrue();
            reply.Nid.Should().BeGreaterThan(1);

            list = await _parts.ListByPkgHash(fNme, hash, new CancellationToken());

            list.Should().HaveCount(1);

            var delRep = await _sut.DeleteNode(reply.Nid, new CancellationToken());

            delRep.IsSuccessful.Should().BeTrue();

            list = await _parts.ListByPkgHash(fNme, hash, new CancellationToken());

            list.Should().HaveCount(0);
        }
Exemplo n.º 3
0
        public async void Post(R2ErrorTicket r2ErrorTicket)
        {
            NodeReply rep = null;

            try
            {
                rep = await _client.PostNode(r2ErrorTicket, new CancellationToken());
            }
            catch (Exception ex)
            {
                LogErrorInPosting(r2ErrorTicket, ex);
                return;
            }

            if (rep == null)
            {
                LogFailedReply(null, r2ErrorTicket);
            }

            else if (rep.Failed)
            {
                LogFailedReply(rep, r2ErrorTicket);
            }
        }