Example #1
0
        public async Task ArchiveDocument(string archivedToolStateId, RavenToolStateDto ravenToolState)
        {
            var insertCommand = new
            {
                Method   = "PUT",
                Key      = archivedToolStateId,
                Document = ravenToolState,
                Metadata = new object()
            };
            var deleteCommand = GetDeleteCommand(RavenConstants.ToolStateId);

            var commands = ravenToolState.Batches.Select(b => GetDeleteCommand(b)).Cast <object>().ToList();

            commands.Add(insertCommand);
            commands.Add(deleteCommand);

            await PostToBulkDocs(commands);
        }
        public async Task ArchiveDocument(string archivedToolStateId, RavenToolStateDto ravenToolState)
        {
            var insertCommand = new
            {
                Id           = archivedToolStateId,
                Type         = "PUT",
                Document     = ravenToolState,
                ChangeVector = (object)null
            };

            var deleteCommand = GetDeleteCommand(RavenConstants.ToolStateId);
            var commands      = ravenToolState.Batches.Select(b => GetDeleteCommand(b)).ToList();

            commands.Add(insertCommand);
            commands.Add(deleteCommand);

            await PostToBulkDocs(commands);
        }
Example #3
0
        public async Task <IToolState> Prepare(DateTime maxCutoffTime, string endpointName, IDictionary <string, string> runParameters)
        {
            var toolStateDTO = new RavenToolStateDto {
                RunParameters = runParameters, Endpoint = endpointName, Status = MigrationStatus.Preparing
            };

            await ravenAdapter.UpdateDocument(RavenConstants.ToolStateId, toolStateDTO);

            var batches = await PrepareBatchesAndTimeouts(maxCutoffTime, endpointName);

            toolStateDTO.Batches          = RavenToolStateDto.ToBatches(batches);
            toolStateDTO.Status           = MigrationStatus.StoragePrepared;
            toolStateDTO.StartedAt        = DateTime.UtcNow;
            toolStateDTO.NumberOfBatches  = batches.Count();
            toolStateDTO.NumberOfTimeouts = batches.Sum(b => b.NumberOfTimeouts);

            await ravenAdapter.UpdateDocument(RavenConstants.ToolStateId, toolStateDTO);

            return(toolStateDTO.ToToolState(batches));
        }