Esempio n. 1
0
        private static EdFiOdsApiConfiguration GetEdFiOdsApiConfig(LearningStandardsJobContext context,
                                                                   SecureCredentials credentials)
        {
            var oAuthAuthenticationConfiguration = new AuthenticationConfiguration(
                credentials.ProductionApiKey,
                credentials.ProductionApiSecret);

            return(new EdFiOdsApiConfiguration(
                       context.ApiUrl, EdFiOdsApiCompatibilityVersion.v3,
                       oAuthAuthenticationConfiguration, context.SchoolYear));
        }
Esempio n. 2
0
        protected override async Task <WorkflowResult> RunJob(LearningStandardsJobContext jobContext,
                                                              IJobCancellationToken jobCancellationToken)
        {
            var secureCredentials = await GetSecureCredentials(jobContext.OdsInstanceId);

            var edFiOdsApiConfiguration        = GetEdFiOdsApiConfig(jobContext, secureCredentials);
            var academicBenchmarkApiAuthConfig = GetAcademicBenchmarkApiAuthConfig(secureCredentials);

            var validationResult =
                await ValidateConfiguration(edFiOdsApiConfiguration, academicBenchmarkApiAuthConfig);

            if (!validationResult.IsSuccess)
            {
                OnStatusComplete(
                    new LearningStandardsSynchronizerProgressInfo(
                        TaskName, 100,
                        new Exception(validationResult.ErrorMessage)));

                return(new WorkflowResult
                {
                    ErrorMessage = validationResult.ErrorMessage,
                    Error = true
                });
            }

            var response = await _learningStandardsPlugin.LearningStandardsSynchronizer.SynchronizeAsync(
                edFiOdsApiConfiguration,
                academicBenchmarkApiAuthConfig,
                new LearningStandardsSynchronizationOptions(),
                jobCancellationToken.ShutdownToken,
                new Progress <LearningStandardsSynchronizerProgressInfo>(OnStatusUpdate));

            if (response.IsSuccess)
            {
                await SaveSuccessfulSync(jobContext.OdsInstanceId);

                OnStatusComplete(new LearningStandardsSynchronizerProgressInfo(TaskName, "Completed Successfully", 100));
            }
            else
            {
                var innerResponses = response.InnerResponses;

                if (innerResponses != null && innerResponses.Any(x => x.IsSuccess))
                {
                    const string link =
                        "<a href=\"https://techdocs.ed-fi.org/display/ADMIN/Known+Issues\">Admin App Known Issues</a>";

                    var failedResponses = innerResponses.Where(x => !x.IsSuccess);
                    await SaveSuccessfulSync(jobContext.OdsInstanceId);

                    var taskState =
                        $"Warning: {failedResponses.Count()} learning standards may not have synchronized correctly to this ODS/API instance. " +
                        "This occasionally occurs due to internal sequencing of learning standards items for your locality. " +
                        "The easiest way to fix is to re-run this synchronization process by clicking on " +
                        "the 'Update Now' button after clicking 'Reload' below. " +
                        $"More information on this issue can be found in TechDocs for {link}.";

                    OnStatusComplete(new LearningStandardsSynchronizerProgressInfo(TaskName, taskState, 100));
                }
                else
                {
                    OnStatusComplete(
                        new LearningStandardsSynchronizerProgressInfo(TaskName, 100, new Exception(response.ErrorMessage)));
                }
            }

            return(new WorkflowResult
            {
                Error = !response.IsSuccess,
                ErrorMessage = response.ErrorMessage
            });
        }