コード例 #1
0
        public ManifestEntity Execute()
        {
            _DbContext.BeginTransaction(); //TODO should be using WebDbContentProvider

            var now           = _DateTimeProvider.Now();
            var releaseCutoff = now - TimeSpan.FromHours(_GaenContentConfig.ManifestLifetimeHours);

            var e = _DbContext.ManifestContent
                    .Where(x => x.Release > releaseCutoff)
                    .OrderByDescending(x => x.Release)
                    .Take(1)
                    .SingleOrDefault();

            if (e != null)
            {
                return(e);
            }

            _DbContext.BulkDelete(_DbContext.Set <ManifestEntity>().ToList()); //TODO execute sql.
            var content = JsonConvert.SerializeObject(_ManifestBuilder.Execute());
            var bytes   = Encoding.UTF8.GetBytes(content);

            e = new ManifestEntity
            {
                Release         = now,
                ContentTypeName = ContentHeaderValues.Json,
                Content         = bytes,
            };
            e.PublishingId = _PublishingId.Create(e.Content);
            _DbContext.ManifestContent.Add(e);
            _DbContext.SaveAndCommit();

            return(e);
        }
コード例 #2
0
        public async Task Execute()
        {
            if (_ContentDb != null)
            {
                throw new InvalidOperationException("Command already used.");
            }

            _ContentDb         = _ContentDbProvider();
            await using var tx = _ContentDb.BeginTransaction();
            var candidate = await _Builder.Execute();

            if (!await WriteCandidate(candidate))
            {
                _Logger.LogInformation("Manifest does NOT require updating.");
                return;
            }

            _Logger.LogInformation("Manifest updating.");

            var snapshot = _DateTimeProvider.Snapshot;
            var e        = new ContentEntity
            {
                Created = snapshot,
                Release = snapshot,
                Type    = ContentTypes.Manifest
            };
            await _Formatter.Fill(e, candidate);

            _Result.Updated = true;

            _ContentDb.Add(e);
            _ContentDb.SaveAndCommit();

            _Logger.LogInformation("Manifest updated.");
        }
        public async Task <ManifestEntity?> Execute(string _)
        {
            var e = new ManifestEntity
            {
                Release = _DateTimeProvider.Now(),
            };
            var content   = _ManifestBuilder.Execute();
            var formatter = new StandardContentEntityFormatter(new ZippedSignedContentFormatter(_Signer), new StandardPublishingIdFormatter(_Signer));
            await formatter.Fill(e, content);

            return(e);
        }
コード例 #4
0
        public async Task <ContentEntity> Execute()
        {
            var now = _DateTimeProvider.Now();
            var e   = new ContentEntity
            {
                Created = now,
                Release = now,
            };

            _Logger.LogDebug("Build new manifest.");
            var content = await _ManifestBuilder.Execute();

            _Logger.LogDebug("Format and sign new manifest.");
            await _Formatter.Fill(e, content); //TODO add release date as a parameter

            return(e);
        }
        public async Task <ContentEntity> Execute()
        {
            var snapshot = _DateTimeProvider.Snapshot;
            var e        = new ContentEntity
            {
                Created = snapshot,
                Release = snapshot,
                Type    = ContentTypes.Manifest
            };

            _Logger.LogDebug("Build new manifest.");
            var content = await _ManifestBuilder.Execute();

            _Logger.LogDebug("Format and sign new manifest.");
            await _Formatter.Fill(e, content);

            return(e);
        }