private bool Open(string file, bool selfContained, bool zipped) { if (service != null) { service.Close(); service = null; } this.file = file; this.selfContained = selfContained; this.zipped = zipped; service = new AdaptService(); if (selfContained) { if (!service.OpenContainer(file, zipped, ProcessMessageAsync)) { return(false); } } else { if (!service.OpenPath(file, ProcessMessageAsync)) { return(false); } } String url = service.GetBootstrapURL(); String init = service.GetInitCall("main", "\"autoresize\":true"); Console.Out.Write("URL:" + url + " Command:" + init + "\n"); initCommand = init; view.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(ScriptLoaded); view.Navigate(url); return(true); }
private async Task <AdaptCourseData> GetAdaptCourseDataAsync(string courseId) { var course = await CourseService.GetPackageAsync(courseId, true); var pages = await CourseService.GetPagesAsync(courseId, true); return(AdaptService.GenerateCourseData(pages, course)); }
private void PublicationWindow_FormClosing(object sender, FormClosingEventArgs e) { if (service != null) { service.Close(); service = null; initCommand = null; } }
public async Task <GenerateResultModel> GeneratePackageDataAsync(string courseId, bool usePreview, CourseFileTypeEnum type) { if (string.IsNullOrEmpty(courseId)) { throw new NotSupportedException($"Please specify '{nameof(courseId)}' parameter"); } var course = await CourseService.GetPackageAsync(courseId, usePreview); var pages = await CourseService.GetPagesAsync(courseId, usePreview); var courseData = AdaptService.GenerateCourseData(pages, course); // (re)generate course json files FileService.CreateCourseJsonFiles(course.CourseId, course.Language?.FirstOrDefault()?.Codename, type, courseData); return(new GenerateResultModel() { Course = course, CourseData = courseData }); }
private bool Open(string file, bool selfContained, bool zipped) { if (service != null) { service.Close(); service = null; } this.file = file; this.selfContained = selfContained; this.zipped = zipped; service = new AdaptService(); if (selfContained) { if (!service.OpenContainer(file, zipped, ProcessMessageAsync)) { return false; } } else { if (!service.OpenPath(file, ProcessMessageAsync)) { return false; } } String url = service.GetBootstrapURL(); String init = service.GetInitCall("main", "\"autoresize\":true"); Console.Out.Write("URL:" + url + " Command:" + init + "\n"); initCommand = init; view.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(ScriptLoaded); view.Navigate(url); return true; }