private void DgvUrls_Neu_Click(object sender, RoutedEventArgs e) { DatagridContextMenu.IsOpen = false; string xxx = DatagridContextMenu.ToString(); string strType = dgRow1.Item.GetType().ToString(); // MeineFinanzen.Model.WertpapSynchroNeu System.Windows.Controls.DataGrid dataGrid = ItemsControl.ItemsControlFromItemContainer(dgRow1) as System.Windows.Controls.DataGrid; WertpapSynchroNeu wpsn = (WertpapSynchroNeu)dataGrid.ItemContainerGenerator.ItemFromContainer(dgRow1); wb1.Navigate(new Uri("https://www.google.de/search?q=" + "Kurs " + wpsn.WPVISIN + "&ie=utf-8&oe=utf-8&client=firefox-b")); //https://www.google.com/search?q=XXYY&ie=utf-8&oe=utf-8&client=firefox-b //string browser = GetDefaultBrowser(); }
private int SearchSuchbegriff(string url1, string boxanfang, string txtkurse, string txtkurszeit, string txtkursdatum, string txtkurs, ref WertpapSynchroNeu wpsneu) { if (wb1.Document == null) { return(2); } string pattBetrag = @"(\d+)([,])(\d+)(\d+)"; // 9,99 string pattDatum = @"(\d+)(\d+)([.])(\d+)(\d+)([.])(\d+)(\d+)(\d+)(\d+)"; // 99.99.9999 string pattZeit = @"(\d+)(\d+)([:])(\d+)(\d+)([:])(\d+)(\d+)"; // 99:99:99 HtmlElementCollection elemColl = null; HtmlDocument doc = wb1.Document; if (doc != null) { AddTextStr("--- Start ---" + wb1.Document.Url); } elemColl = doc.GetElementsByTagName("body"); string strInnerText = ""; string strKursdatum = ""; string strKurszeit = ""; string strKurs = ""; //string strSharpe = ""; string strZeilePlus = ""; string[] strarr1; string[] strarr2; string[] strarr3; string strf = ""; foreach (HtmlElement elem in elemColl) // Ein Element (Node) { if (!elem.InnerHtml.Contains(boxanfang)) { continue; } //DoEvents(); strInnerText = elem.InnerText; // Beginn Box 'row quotebox' strInnerText = Regex.Replace(strInnerText, "[\x00-\x1F]+", "/"); string[] strZeilenTeile = strInnerText.Split('/'); Console.Write("---- {0,2} {1,5} {2,-80} BoxAnf:{3}", elem.Children.Count, elem.InnerHtml.Length, wb1.Document.Url, boxanfang); int nn = 0; strKursdatum = ""; strKurszeit = ""; strKurs = ""; // Und +-EUR, +-% //strSharpe = ""; char[] charSeparators = new char[] { ' ' }; foreach (string strZeile in strZeilenTeile) // Zeilen in der Box. { strf = ""; ++nn; if (strZeile.StartsWith(txtkurse)) { continue; } strZeilePlus = ""; if (strZeile.StartsWith(txtkursdatum)) { strZeilePlus += String.Format(" nn:{0,3} {1} =", nn, strZeile); foreach (Match m in Regex.Matches(strZeile, pattDatum)) { strKursdatum += String.Format("{0} ", m.Value); } } if (strZeile.StartsWith(txtkurszeit)) { strZeilePlus += String.Format(" nn:{0,3} {1} =", nn, strZeile); foreach (Match m in Regex.Matches(strZeile, pattZeit)) { strKurszeit += String.Format("{0} ", m.Value); } } if (strZeile.StartsWith(txtkurs)) { strZeilePlus += String.Format(" nn:{0,3} {1} =", nn, strZeile); foreach (Match m in Regex.Matches(strZeile, pattBetrag)) { strKurs += String.Format("{0} ", m.Value); } } if (strZeilePlus.Length > 0) { strarr1 = strKurs.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); strarr2 = strKursdatum.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); strarr3 = strKurszeit.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); strf = String.Format("@1 {0,-40}-->(K:{1} {2}) (D:{3} {4}) (Z:{5} {6})", strZeilePlus, strKurs, strarr1.Length, strKursdatum, strarr2.Length, strKurszeit, strarr1.Length); AddTextStr(strf); Console.WriteLine("{0}", strf); } } // foreach (string strZeile in strZeilenTeile) strf = String.Format("@2 K:{0} D:{1} Z:{2}", strKurs, strKursdatum, strKurszeit); if (strf.Length == 0) { return(2); } string[] strarrx = strKurs.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); if (strKurs.Length > 0) { wpsneu.WPVKursNeu = Convert.ToDouble(strarrx[0]); // 128,96 2,33 1,84 } if (strarrx.Length > 1) { wpsneu.WPVProzentAenderungNeu = Convert.ToDouble(strarrx[1]); } if (strarrx.Length > 2) { wpsneu.WPVProzentAenderungNeu = Convert.ToDouble(strarrx[2]); } strarrx = strKursdatum.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); if (strarrx.Length > 0) { wpsneu.WPVKursZeitNeu = Convert.ToDateTime(strarrx[0]); } Console.WriteLine("§{0,7} {1} {2}", wpsneu.WPVKursNeu, wpsneu.WPVProzentAenderungNeu, wpsneu.WPVKursZeitNeu); //Progress++; return(1); } // foreach (HtmlElement elem in elemColl) System.Windows.MessageBox.Show("Fehler. Auf dieser WebSeite kein 'row quotebox' gefunden!!!"); //SetDataRowColor("R"); return(3); // Wenn kein 'row quotebox' gefunden. }
private void DgvUrls_PreviewMouseDown(object sender, MouseButtonEventArgs e) { DependencyObject dep = (DependencyObject)e.OriginalSource; while ((dep != null) && !(dep is System.Windows.Controls.DataGridCell)) { dep = VisualTreeHelper.GetParent(dep); } if (dep == null) { return; } dgRow1 = dep as DataGridRow; while ((dep != null) && !(dep is DataGridRow)) { dep = VisualTreeHelper.GetParent(dep); } dgRow1 = dep as DataGridRow; if (dgRow1 == null) { return; } if (e.RightButton == MouseButtonState.Pressed) { return; } ResetDgRow(); _ColHeaderVorgabe = null; System.Windows.Controls.DataGrid dataGrid = ItemsControl.ItemsControlFromItemContainer(dgRow1) as System.Windows.Controls.DataGrid; WertpapSynchroNeu wpsn = (WertpapSynchroNeu)dataGrid.ItemContainerGenerator.ItemFromContainer(dgRow1); //System.Windows.Controls.DataGridCell cell1 = dep as System.Windows.Controls.DataGridCell; //Console.WriteLine("cell1.Column.Header: {0} Color: {1}", cell1.Column.Header, wpsn.WPVRowColor); dgRow1.DetailsVisibility = Visibility.Visible; dgRow1.Background = new SolidColorBrush(Colors.LightYellow); _Url1 = wpsn.WPVURL; Meldung("Ok, ausgewählt: " + _Url1); wb1.Navigate(new Uri(_Url1)); while (wb1.IsBusy || wb1.ReadyState != WebBrowserReadyState.Complete) { DoEvents(); } // ---- Vorgabe-Parametersatz in dgvVorgabeInt2 suchen ---- int iSearch = 0; char[] charSeparators = new char[] { '/' }; string[] url1split = _Url1.Split(charSeparators, StringSplitOptions.RemoveEmptyEntries); UrlVerwalten vor = null; Console.WriteLine("---- gesucht wird in DataGrid-Vorgabe: _Url1:{0} _Url2: {1}", _Url1, _Url2); foreach (UrlVerwalten vor1 in liVorg) { if (vor1.Url1 == url1split[0] + @"//" + url1split[1] + @"/" && vor1.Url2 == url1split[2]) // https://www.finanzen.net/ == https://www.finanzen.net/ etf leer { vor = vor1; Console.WriteLine("---- Url1 gefunden: {0} Url2: {1} Wert1: {2} Wert2: {3}", vor.Url1, vor1.Url2, vor1.Wert1, vor1.Wert2); if (vor1.Wert1 == string.Empty) { Meldung("Wert1 muß eingegeben werden!"); iSearch = 4; } else { if (vor.Url2 == url1split[2]) { AddTextStr("---- Url2 gefunden: " + vor.Url2); _BoxAnfang = vor.Boxanfang; // "row quotebox"; _TxtKurse = vor.Ausschluss1; // "Kurse"; _TxtKursdatum = vor.Wert1; // "Kursdatum"; _TxtKurszeit = vor.Wert2; // "Kurszeit"; _TxtKurs = vor.Wert3; // "Kurs"; iSearch = SearchWebPageHIER(_Url1, _BoxAnfang, _TxtKurse, _TxtKurszeit, _TxtKursdatum, _TxtKurs, ref wpsn); if (iSearch == 1) { AddTextStr("Ok. 1."); } else { Meldung("!!!! Nee, Die Suche nach Kurs... im WEB war nicht erfolgreich. !!!! : " + iSearch); } } } } } // foreach vor1 vor.Vg2Color = iSearch.ToString(); //if (iSearch == 1) // AddTextStr("Ok. 2."); //else // Meldung("!!!! Nee Fehler 2.!!!! FehlerNummer: " + iSearch); dgvVorgabeInt2.ItemsSource = null; dgvVorgabeInt2.ItemsSource = liVorg; dgvVorgabeInt2.EnableRowVirtualization = false; dgvVorgabeInt2.UpdateLayout(); Meldung("Suchargumente anlegen/ändern."); borderCombo.Background = new SolidColorBrush(Colors.LightGreen); }