private void FinishButton_Click(object sender, RoutedEventArgs e) { EducationDatabase.Self().SaveToDatabase(); MessageBox.Show("Updates saved to database", "Patient Education Assembler", MessageBoxButton.OK, MessageBoxImage.Information); }
private void ApplyButton_Click(object sender, RoutedEventArgs e) { foreach (DiscrepancyResolution res in resolutions) { switch (res.action) { case DiscrepancyResolution.ActionTypes.AcceptNew: res.input.Enabled = true; break; case DiscrepancyResolution.ActionTypes.Merge: EducationDatabase.Self().removeMergedDocument(res.input, res.secondary); res.secondary.mergeWith(res.input); break; case DiscrepancyResolution.ActionTypes.Delete: res.input.deleteFromDatabase(); break; case DiscrepancyResolution.ActionTypes.Ignore: res.input.ignoreDocument(); break; } } Close(); }
internal void SetupDiscrepancies(HTMLContentProvider contentProvider) { Title += " - " + contentProvider.contentProviderName + " - " + contentProvider.contentBundleName; foreach (HTMLDocument doc in EducationDatabase.Self().EducationCollection) { if (doc.ParentProvider == contentProvider) { switch (doc.LoadStatus) { case PatientEducationObject.LoadStatusEnum.NewFromWebIndex: unmatched.Add(doc); break; case PatientEducationObject.LoadStatusEnum.DatabaseEntry: if (doc.Enabled) { existing.Add(doc); } // If not enabled, it has previously been disabled = don't show again break; } } } UnmatchedList.ItemsSource = unmatched; ExistingList.ItemsSource = existing; }
private void PrepareToParse() { EducationDatabase.Self().DisclaimerFooter = DisclaimerTextBox.Text; DisclaimerTextBox.IsEnabled = false; EducationDatabase.Self().OrganisationName = MainWindow.thisWindow.OrganisationName.Text; OrganisationName.IsEnabled = false; }
private void IncludeAllAvailable_Click(object sender, RoutedEventArgs e) { foreach (PatientEducationObject edu in EducationDatabase.Self().EducationCollection) { if (edu.LoadStatus == PatientEducationObject.LoadStatusEnum.LoadedSucessfully) { edu.Enabled = true; } } }
public void loadSpecification(string filename) { SpecificationXML.Text = File.ReadAllText(filename); HTMLContentProvider currentProvider = new HTMLContentProvider(new Uri("file://" + filename)); currentProvider.loadSpecifications(HTMLContentProvider.LoadDepth.TopLevel); ProviderProgress.Value++; EducationDatabase.Self().addContentProvider(currentProvider.contentProviderName, currentProvider); currrentProviderChanged(); }
private void StartThisButton_Click(object sender, RoutedEventArgs e) { EducationDatabase.Self().DisclaimerFooter = DisclaimerTextBox.Text; DisclaimerTextBox.IsEnabled = false; EducationDatabase.Self().OrganisationName = MainWindow.thisWindow.OrganisationName.Text; OrganisationName.IsEnabled = false; EducationDatabase.Self().CurrentProvider.loadSpecifications(); }
static private void requestRetrieveAndParse(HTMLDocument thisPage) { if (thisPage.DocumentParsed || thisPage.ParseTask != null) { return; } MainWindow.thisWindow.DocumentProgress.Maximum++; thisPage.ParseTask = new Task(() => thisPage.retrieveAndParse(MainWindow.thisWindow.ReportDocumentProgress)); EducationDatabase.Self().scheduleParse(thisPage); }
private void StartAllButton_Click(object sender, RoutedEventArgs e) { EducationDatabase.Self().DisclaimerFooter = DisclaimerTextBox.Text; DisclaimerTextBox.IsEnabled = false; EducationDatabase.Self().OrganisationName = MainWindow.thisWindow.OrganisationName.Text; OrganisationName.IsEnabled = false; foreach (HTMLContentProvider provider in EducationDatabase.Self().allProviders()) { provider.loadSpecifications(); } }
private HTMLDocument LoadDocumentInternal(XElement node, Uri link, string title) { HTMLDocument thisPage; if (!EducationDatabase.Self().EducationObjects.ContainsKey(HTMLDocument.URLForDictionary(link))) { thisPage = new HTMLDocument(this, node, link); // Postfix the content provider tag to the document title thisPage.Title = title + TitlePostfix; if (currentLoadDepth == LoadDepth.OneDocument) { if (loadCount == 0) { loadCount++; requestRetrieveAndParse(thisPage); } } else if (currentLoadDepth == LoadDepth.Full) { loadCount++; requestRetrieveAndParse(thisPage); } EducationDatabase.Self().registerNewDocument(thisPage, HTMLDocument.URLForDictionary(link)); } else { thisPage = (HTMLDocument)EducationDatabase.Self().EducationObjects[HTMLDocument.URLForDictionary(link)]; // Update the status to show it was found in the index thisPage.foundInWebIndex(); // Update the link in case it has subtly changed eg. http to https, case of URL etc. if (thisPage.URL != link) { EducationDatabase.Self().updateDocumentURL(thisPage, HTMLDocument.URLForDictionary(thisPage.URL), HTMLDocument.URLForDictionary(link)); thisPage.URL = link; } if (currentLoadDepth == LoadDepth.Full) { requestRetrieveAndParse(thisPage); } } MainWindow.thisWindow.IndexProgress.Value++; return(thisPage); }
public void loadDocument(OleDbDataReader reader) { string bundleName = reader.GetString((int)EducationDatabase.MetadataColumns.Bundle); foreach (XElement bundleSpec in ProviderSpecification.DescendantNodes().Where(n => n.NodeType == System.Xml.XmlNodeType.Element)) { if (bundleSpec.Name == "Bundle" && bundleSpec.Attribute("name") != null && bundleSpec.Attribute("name").Value == bundleName) { HTMLDocument loadDoc = new HTMLDocument(this, bundleSpec.Elements("Document").First(), reader); EducationDatabase.Self().EducationObjects.Add(HTMLDocument.URLForDictionary(loadDoc.URL), loadDoc); EducationDatabase.Self().EducationCollection.Add(loadDoc); } } }
internal void addFooter() { NewParagraph("Subtle Emphasis"); string footer = EducationDatabase.Self().DisclaimerFooter; footer = footer.Replace("%ORGANISATION%", EducationDatabase.Self().OrganisationName); footer = footer.Replace("%PROVIDER%", ParentProvider.contentProviderName + " - " + ParentProvider.contentBundleName); footer = footer.Replace("%CACHEDATE%", cacheDate().ToShortDateString()); AddText(footer); NewParagraph(); InsertQRCode(URL); NewParagraph(); ConvertAndAddText(URL.AbsoluteUri); }
private void OpenNextDocument() { int currentIndex = EducationDatabase.Self().EducationCollection.IndexOf(currentReviewDocument); for (int i = currentIndex + 1; i < EducationDatabase.Self().EducationCollection.Count; i++) { if (NavMode.SelectedItem.ToString() == "All" || EducationDatabase.Self().EducationCollection[i].ParseIssueCount > 0) { SelectItem(EducationDatabase.Self().EducationCollection[i]); return; } } MessageBox.Show("No more documents with parsue issues found"); }
public void loadSpecifications(LoadDepth depth = LoadDepth.Full) { currentLoadDepth = depth; loadCount = 0; XDocument specDoc = XDocument.Load(sourceXML.LocalPath); //try { XElement top = specDoc.Element("CustomPatientEducation"); ProviderSpecification = top.Element("ContentProvider"); contentProviderName = ProviderSpecification.Attribute("name").Value.ToString(); TitlePostfix = " - " + ProviderSpecification.Attribute("postfix").Value; string tempUri = ProviderSpecification.Attribute("url").Value.ToString(); contentProviderUrl = new Uri(tempUri); XElement e = ProviderSpecification.Element("Bundle"); if (e != null) { // TODO Only one bundle per provider is currently supported. bundleUrl = new Uri(contentProviderUrl, e.Attribute("url").Value.ToString()); contentBundleName = e.Attribute("name").Value.ToString(); if (currentLoadDepth != LoadDepth.TopLevel) { ParseBundle(e); ResolveDiscrepancies(); EducationDatabase.Self().scheduleTasks(); } } else { MessageBox.Show("No content bundle found within specifications for provider " + contentProviderName, "Missing Content Bundle Definition", MessageBoxButton.OK, MessageBoxImage.Error); } } /*catch (Exception e) * { * MessageBox.Show("Unhandled Exception: " + e.ToString(), "Patient Education Assembler"); * }*/ }
private void currrentProviderChanged() { if (EducationDatabase.Self().CurrentProvider != null) { CurrentContentProviderName.Text = EducationDatabase.Self().CurrentProvider.contentProviderName; SpecificationXML.Text = EducationDatabase.Self().CurrentProvider.GetSpecification(); ReloadContentSpec.IsEnabled = true; ButtonLoadIndex.IsEnabled = true; ButtonParseOne.IsEnabled = true; StartThisButton.IsEnabled = true; StartAllButton.IsEnabled = true; //dv = new System.Data.DataView(HTMLContentProvider.getEducationCollection(), ""); //EducationItemsDataGrid. //DataView dv; //dv = new DataView(ds.Tables[0], "type = 'business' ", "type Desc", DataViewRowState.CurrentRows); //dataGridView1.DataSource = dv; } }
private void setOutputDirectory(string directory) { OutputDirectoryPath.Text = directory; EducationDatabase.Self().CachePath = directory; if (directory.Length > 0 && Directory.Exists(directory)) { if (!Directory.Exists(PatientEducationObject.cachePath())) { Directory.CreateDirectory(PatientEducationObject.cachePath()); } if (!Directory.Exists(PatientEducationObject.imagesPath())) { Directory.CreateDirectory(PatientEducationObject.imagesPath()); } Properties.Settings.Default.OutputDirectory = directory; Properties.Settings.Default.Save(); } }
public MainWindow() { thisWindow = this; InitializeComponent(); setSpecDirectory(Properties.Settings.Default.SpecDirectory); setOutputDirectory(Properties.Settings.Default.OutputDirectory); setMaxWordInstances(Properties.Settings.Default.MaxWordInstances); setCacheAge(Properties.Settings.Default.CacheAge); ExpireCachedContent.IsChecked = Properties.Settings.Default.ExpireCachedContent; ShowWord.IsChecked = Properties.Settings.Default.AlwaysShowWord; ReportDocumentProgress = new Progress <int>(completed => { DocumentProgress.Value += completed; }); // Connect the education collection (all education documents) to the data grid EducationItemsDataGrid.ItemsSource = EducationDatabase.Self().EducationCollection; if (MessageBox.Show("Please ensure that you have the appropriate permission(s) from the content provider before you run this tool to download information from the internet", "Patient Education Assembler", MessageBoxButton.OKCancel, MessageBoxImage.Warning) == MessageBoxResult.Cancel) { Application.Current.Shutdown(); } // Force load of the Chromium browser components, to load more quickly and allow one time setup SingleItemBrowser.EnsureCoreWebView2Async(); SingleItemBrowser.CoreWebView2InitializationCompleted += SingleItemBrowser_CoreWebView2InitializationCompleted; SingleItemBrowser.ContentLoading += SingleItemBrowser_ContentLoading; if (OutputDirectoryPath.Text.Length > 0) { ConnectToDatabaseImpl(); } }
private void ConnectToDatabaseImpl() { EducationDatabase.Self().connectDatabase(); ConnectToDatabase.IsEnabled = false; }
private void ButtonLoadIndex_Click(object sender, RoutedEventArgs e) { EducationDatabase.Self().CurrentProvider.loadSpecifications(HTMLContentProvider.LoadDepth.IndexOnly); }
private void ButtonParseOne_Click(object sender, RoutedEventArgs e) { PrepareToParse(); EducationDatabase.Self().CurrentProvider.loadSpecifications(HTMLContentProvider.LoadDepth.OneDocument); }
private void PrevContentProvider_Click(object sender, RoutedEventArgs e) { EducationDatabase.Self().prevProvider(); currrentProviderChanged(); }