Example #1
0
        public Task <Result> ExecuteAsync(ReloadRulesJob job)
        {
            _jobs.Start(job);

            var path = GetFolder();

            //находим версию Устава
            var version = _dbContext.GetTypiconVersion(job.TypiconId, job.TypiconVersionStatus);

            Result result = Result.Ok();

            Result.Combine(path, version)
            .OnSuccess(() =>
            {
                DoTheJob(path.Value, version.Value);
            })
            .OnSuccess(async() =>
            {
                await _dbContext.UpdateTypiconVersionAsync(version.Value);

                await _dbContext.ClearModifiedYearsAsync(version.Value.Id);

                await _dbContext.ClearOutputFormsAsync(version.Value.TypiconId, true);

                _jobs.Finish(job, string.Empty);
            })
            .OnFailure(err =>
            {
                _jobs.Fail(job, err);

                result = Result.Fail(err);
            });

            return(Task.FromResult(result));
        }