private async Task AsyncGenerateHtml(bool IsOpenBrower) { if (_htmlService.IsHtmlGenerating == false) { _htmlService.IsHtmlGenerating = true; } else { return; } //Application.Current.MainWindow.IsEnabled = false; _busyIndicator.Progress = 3; _busyIndicator.CanStop = true; _busyIndicator.IsShow = true; //load page data and create all images await AsyncConvertAllPages(); Debug.WriteLine("----->HtmlGen----->End All Convert"); //generate the html files. if (_busyIndicator.IsContinue == false) { _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; return; } _busyIndicator.Progress = 90; _busyIndicator.Content = @"Generate the HTML Page......"; bool bIsSuccessful = await Task.Factory.StartNew <bool>(GenerateHtml); if (bIsSuccessful == false) { _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; MessageBox.Show(GlobalData.FindResource("Error_Generate_Html_Access")); return; } //Browser to open page if (_busyIndicator.IsContinue == false) { _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; return; } _busyIndicator.Progress = 98; _busyIndicator.Content = @"HTML Page is ready now, Open the Browser.."; if (IsOpenBrower) { IWebServer httpServer = ServiceLocator.Current.GetInstance <IWebServer>(); if (httpServer != null) { try { Process.Start("explorer.exe", httpServer.GetWebUrl()); } catch { NLogger.Error("Preview:Open Browser failed!"); } } else { NLogger.Error("httpServer is null when open browner!"); } } _busyIndicator.Progress = 100; _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; }
private async Task AsyncGenerateMD5Html(DiffGeneratorParameter para) { //Application.Current.MainWindow.IsEnabled = false; _busyIndicator.Progress = 3; _busyIndicator.CanStop = true; _busyIndicator.IsShow = true; //load page data and create all images,ignore it now //foreach (IDocumentService doc in para.Docs) //{ // await AsyncConvertAllPages(doc.Document); //} //generate the html files. //if (_busyIndicator.IsContinue == false) //{ // _busyIndicator.IsShow = false; // IsHtmlGenerating = false; // return; //} _busyIndicator.Progress = 30; //_busyIndicator.Content=@"Generate the HTML Page......"; //Create All Page Htmls with MD5 hash int i = 0; foreach (IDocumentService doc in para.Docs) { await AsyncConvertAllPages(doc.Document); string szLocation = _outputFolder + @"\" + i++; bool bIsSuccessful = await Task.Factory.StartNew <bool>(() => GenerateMD5Html(doc, szLocation)); if (bIsSuccessful == false) { _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; MessageBox.Show(GlobalData.FindResource("Error_Generate_Html_Access")); return; } _busyIndicator.Progress = _busyIndicator.Progress + 15; } //Create Differ project Json Date bool bSuccessful = await Task.Factory.StartNew <bool>(() => GenerateMD5DifferInfo(para.Docs, _outputFolder)); if (bSuccessful == false) { _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; MessageBox.Show(GlobalData.FindResource("Error_Generate_Html_Access")); return; } //Browser to open page if (_busyIndicator.IsContinue == false) { _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; return; } _busyIndicator.Progress = 98; _busyIndicator.Content = @"HTML Page is ready now, Open the Browser.."; //open the web browser IWebServer httpServer = ServiceLocator.Current.GetInstance <IWebServer>(); if (httpServer != null) { try { Process.Start("explorer.exe", httpServer.GetWebUrl()); } catch { NLogger.Error("Preview:Open Browser failed!"); } } else { NLogger.Error("httpServer is null when open browner!"); } //end progress show _busyIndicator.Progress = 100; _busyIndicator.IsShow = false; _htmlService.IsHtmlGenerating = false; }