//Methoden public List <GPS_Punkt> createGPS(string Text) { char[] seperator = { '\r', '\n' }; string[] arText = Text.Split(seperator, StringSplitOptions.RemoveEmptyEntries); bool bTrigger = false; int index = 0; foreach (string Zeile in arText) { if (Zeile.Length > 10) { if (Zeile.Substring(0, 10) == "#MARKTIMEA") { bTrigger = true; index = 0; //Positionen nach Trigger Ereignis } if (bTrigger && Zeile.Length >= 6 && Zeile.Substring(0, 6) == "$GPGGA") { char[] Seperator = { ',' }; string[] arZeile = Zeile.Split(Seperator); GPS_Punkt objGPS = new GPS_Punkt(arZeile[1], arZeile[4], arZeile[2], arZeile[9], arZeile[6]); m_lsGPS.Add(objGPS); bTrigger = false; } index++; } } return(m_lsGPS); }
public override int GetHashCode() { return((string.IsNullOrWhiteSpace(Tourist) ? 0 : Tourist.GetHashCode()) ^ (string.IsNullOrWhiteSpace(Zeile) ? 0 : Zeile.GetHashCode()) ^ (string.IsNullOrWhiteSpace(Bund) ? 0 : Bund.GetHashCode()) ^ (string.IsNullOrWhiteSpace(Country) ? 0 : Country.GetHashCode()) ^ (string.IsNullOrWhiteSpace(RefundID) ? 0 : RefundID.GetHashCode()) ^ (string.IsNullOrWhiteSpace(CustomerVers) ? 0 : CustomerVers.GetHashCode()) ^ (string.IsNullOrWhiteSpace(CustomerID) ? 0 : CustomerID.GetHashCode()) ^ (string.IsNullOrWhiteSpace(PaymentID) ? 0 : PaymentID.GetHashCode()) ^ (string.IsNullOrWhiteSpace(Attempt) ? 0 : Attempt.GetHashCode()) ^ (string.IsNullOrWhiteSpace(TransactionID) ? 0 : TransactionID.GetHashCode()) ^ (string.IsNullOrWhiteSpace(TransactionHistoryID) ? 0 : TransactionHistoryID.GetHashCode())); }
private static void GetWikipedia(String Adresse = "https://de.wikipedia.org/wiki/Liste_der_UN-Nummern") { HttpWebRequest newRequest = (HttpWebRequest)WebRequest.Create(Adresse); newRequest.Method = "POST"; HttpWebResponse resp = (HttpWebResponse)newRequest.GetResponse(); StreamReader StrReader = new StreamReader(resp.GetResponseStream()); String Content = StrReader.ReadToEnd(); String[] TabellenRoh = Content.Split(new String[] { "<table class=\"prettytable\">", "</table>" }, StringSplitOptions.RemoveEmptyEntries); List <string> Tabellen = new List <string>(); foreach (String str in TabellenRoh) { if (str.Contains("<td>")) { Tabellen.Add(str); } } List <string> newData = new List <string>(); foreach (String str in Tabellen) { List <string> Zeilen = str.Split(new String[] { "<tr>", "</tr>\\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); foreach (string Zeile in Zeilen) { if (!Zeile.Contains("<td>")) { continue; } List <string> Teile = Zeile.Replace("\n", "").Split(new String[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList(); Teile.Insert(1, ""); if (Teile[0].Contains('+') || Teile[0].Contains('–') || Teile[0].Contains('-')) { Teile[1] = Teile[0].Split(new char[] { '+', '–', '-' })[1].Trim(); Teile[0] = Teile[0].Split(new char[] { '+', '–', '-' })[0].Trim(); } else { Teile[1] = Teile[0]; } newData.Add(DeHTML(Teile[0] + ";" + Teile[1] + ";" + Teile[2] + ";" + Teile[3] + ";" + Teile[4])); } } File.WriteAllLines("Daten.csv", newData, Encoding.UTF8); }
private void GetWikipedia(String Adresse = "https://de.wikipedia.org/wiki/Liste_der_UN-Nummern") //Runterladen der aktuellen Infos von Wikipedia und Export als CSV-datei { HttpWebRequest newRequest = (HttpWebRequest)WebRequest.Create(Adresse); newRequest.Method = "POST"; HttpWebResponse resp = (HttpWebResponse)newRequest.GetResponse(); StreamReader StrReader = new StreamReader(resp.GetResponseStream()); //Lauter Http-zeugs, um eine Anfrage zu stellen. String Content = StrReader.ReadToEnd(); //Im Wesentlichen bloß das Herunterladen des Quelltextes der angegebenen URL String[] TabellenRoh = Content.Split(new String[] { "<table class=\"prettytable\">", "</table>" }, StringSplitOptions.RemoveEmptyEntries); List <string> Tabellen = new List <string>(); //Im Folgenden werden die überflüssigen Bestandteile der Wikipedi-Seite entfernt. foreach (String str in TabellenRoh) //Hier Filterung nach den verschiedenen tabellen, die auf der Seite gezeigt sind { if (str.Contains("<td>")) //<td> ist der Tag für eine Tabellenzelle -> Ist eine tabelle; S. HTML-tags auf Wikipedia oder so { Tabellen.Add(str); } } List <string> newData = new List <string>(); foreach (String str in Tabellen) //Abarbeiten der einzelnen tabellen { List <string> Zeilen = str.Split(new String[] { "<tr>", "</tr>\\n" }, StringSplitOptions.RemoveEmptyEntries).ToList(); //Aufspalten in zeilen foreach (string Zeile in Zeilen) { if (!Zeile.Contains("<td>")) { continue; //Wenn in Zeilen Inhalte stehen -> keine Tabellenköpfe mit importieren } List <string> Teile = Zeile.Replace("\n", "").Split(new String[] { "<td>", "</td>" }, StringSplitOptions.RemoveEmptyEntries).ToList(); //Zeilenumbrüche (\n) entfernen und Zeile in die Infos aufteilen Teile.Insert(1, ""); //Der ganze Teil dient der Auftrennung der UN-Nummern, weil Wikipedia if (Teile[0].Contains('+') || Teile[0].Contains('–') || Teile[0].Contains('-')) //das so bescheuert mit 1-3 oder 1+2 angegeben hat. Deshalb trennung { //in untere und obere Nummern, wenn nur eine Nummer vorhanden dann wird die kopiert. Teile[1] = Teile[0].Split(new char[] { '+', '–', '-' })[1].Trim(); Teile[0] = Teile[0].Split(new char[] { '+', '–', '-' })[0].Trim(); } else { Teile[1] = Teile[0]; } newData.Add(DeHTML(Teile[0] + ";" + Teile[1] + ";" + Teile[2] + ";" + Teile[3] + ";" + Teile[4])); //Speichern der aktuellen zeile in einer Liste, vorher mit DeHTML() noch mal überarbeiten. Siehe DeHTML unten } } File.WriteAllLines("Daten.csv", newData, Encoding.UTF8); //fertige Liste als CSV abspeichern }
//Methoden public void readCodeTable() { m_bCode = Convert.ToBoolean(m_objRegistry.readValue("chk Codetabelle")); m_Codetabelle = (string)m_objRegistry.readValue("Codetabelle"); if (m_bCode) { StreamReader sr = new StreamReader(m_Codetabelle, Encoding.Default); string Text = sr.ReadToEnd(); sr.Close(); string[] arText = Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); //Zeilen von Codes in Array einfügen string[] arZeile; foreach (string Zeile in arText) { arZeile = Zeile.Split(new char[] { ';' }, StringSplitOptions.None); m_dicCodetabelle.Add(arZeile[0], arZeile[1]); } } }
//Methoden private void create_vMP(bool isMM) { bool bFehler = false; NumberFormatInfo nfi = new NumberFormatInfo(); nfi.NumberDecimalDigits = _config.GetAppSettingInt("decimals"); string[] arText = m_DAT_Text.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (string Zeile in arText) { try { string[] Datensatz = Zeile.Split(new Char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); // NumFormat.NumberDecimalDigits = Global.StringDigits(Datensatz[1]); string PNum = Datensatz[0]; double Rechtswert = System.Convert.ToDouble(Datensatz[1], nfi); double Hochwert = System.Convert.ToDouble(Datensatz[2], nfi); double?Höhe = null; int PresicionX = Global.StringDigits(Datensatz[1]); int PresicionY = Global.StringDigits(Datensatz[2]); int PresicionZ = Global.StringDigits(Datensatz[3]); try { if (Datensatz[3] != null) { Höhe = System.Convert.ToDouble(Datensatz[3], nfi); } } catch { } //Einlesen von Meter oder Millimeter? if (isMM) { Rechtswert /= 1000; Hochwert /= 1000; Höhe /= 1000; PresicionX += 3; PresicionY += 3; PresicionZ += 3; } //Code string Code = String.Empty; try { if (Datensatz[6] != null) { Code = Datensatz[6]; } } catch { } Messpunkt objMP = new Messpunkt(PNum, Rechtswert, Hochwert, Höhe, 0, 0, Code, new DateTime(), PresicionX, PresicionY, PresicionZ); m_vMP.Add(objMP); } catch { bFehler = true; } } if (bFehler) { System.Windows.Forms.MessageBox.Show("Fehler bei der Konvertierung festgestellt!!!"); } create_vMP_mm(); }
public void run() { OpenFileDialog ddOpenFile = new OpenFileDialog(); ddOpenFile.Title = "Vermessungspunkte importieren"; ddOpenFile.Filter = "Punktwolke|*.csv|Punktwolke|*.dat"; ddOpenFile.DefaultExt = m_Settings.Extention; Editor m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; DialogResult diagRes = DialogResult.None; if (!m_Settings.openExportFile) { diagRes = ddOpenFile.ShowDialog(); } else { ddOpenFile.FileName = m_Settings.ExportFile; diagRes = DialogResult.OK; } if (diagRes == DialogResult.OK) { bool fileOK = true; m_Filename = ddOpenFile.FileName; try { StreamReader sr = new StreamReader(m_Filename, Encoding.Default); m_Text = sr.ReadToEnd(); sr.Close(); } catch { fileOK = false; } if (fileOK) { m_Extention = m_Filename.Substring(m_Filename.LastIndexOf('.') + 1).ToLower(); string[] arZeile; string PNum; double Rechtswert = new double(); double Hochwert = new double(); double Höhe = new double(); double?Höhenwert = new Double(); myRegistry.regIO objRegIO = new myRegistry.regIO(); string Basislayer = (string)objRegIO.readValue("blocks", "Basislayer"); //Basislayer ggf. anlegen myAutoCAD.myLayer objLayer = myAutoCAD.myLayer.Instance; objLayer.checkLayer(Basislayer, true); int Zähler = 0; int iZeile = 1; switch (m_Extention) { case "dat": bool bDatFehler = false; m_arText = m_Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); //Zeilen von MP in Array einfügen foreach (string Zeile in m_arText) { arZeile = Zeile.Split(new char[] { (char)32 }, StringSplitOptions.RemoveEmptyEntries); m_arPunkte.Add(arZeile); if (arZeile.Length < 3) { bDatFehler = true; break; } iZeile++; } if (!bDatFehler) { foreach (string[] Zeile in m_arPunkte) { bool bFehler = false; PNum = Zeile[0]; if (m_Util.convertToDouble(Zeile[1], ref Rechtswert, null) != Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { bFehler = true; } if (m_Util.convertToDouble(Zeile[2], ref Hochwert, null) != Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { bFehler = true; } Autodesk.AutoCAD.Runtime.ErrorStatus eSHöhe = m_Util.convertToDouble(Zeile[3], ref Höhe, null); if (!(eSHöhe == Autodesk.AutoCAD.Runtime.ErrorStatus.OK || eSHöhe == Autodesk.AutoCAD.Runtime.ErrorStatus.NullExtents)) { bFehler = true; } //Nachkommastellen Höhe myAutoCAD.myUtilities objUtil = new myAutoCAD.myUtilities(); int Precision = objUtil.Precision(Zeile[3]); double CASHöhe = Höhe; Höhe = Math.Round(Höhe, Convert.ToInt32(m_objRegIO.readValue("blocks", "Kommastellen"))); //Att3 (Datum) string Att3 = String.Empty; try { if (Zeile[4] != "" && Zeile[4] != "\r") { Att3 = Zeile[4]; } } catch { } //Att4 (Code) string Att4 = String.Empty; try { if (Zeile[5] != "" && Zeile[5] != "\r") { Att4 = Zeile[5]; } } catch { } //Att5 (Hersteller) string Att5 = String.Empty; try { if (Zeile[6] != "" && Zeile[6] != "\r") { Att5 = Zeile[6]; } } catch { } if (!bFehler) { //Höhe if (eSHöhe == Autodesk.AutoCAD.Runtime.ErrorStatus.NullExtents) { Höhenwert = null; } else { Höhenwert = Höhe; } myAutoCAD.Messpunkt objMP = new Messpunkt(PNum, Rechtswert, Hochwert, Höhenwert, CASHöhe, Precision); if (Att3 != String.Empty) { objMP.Att3_Wert = Att3; } if (Att4 != String.Empty) { objMP.Att4_Wert = Att4; } if (Att5 != String.Empty) { objMP.Att5_Wert = Att5; } if (objMP.draw("MP", Basislayer) == Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { Zähler += 1; } else { break; } } } } else { MessageBox.Show("Fehler in dat File! (Zeile: " + iZeile.ToString()); } break; case "csv": m_arText = m_Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); //Zeilen von MP in Array einfügen foreach (string Zeile in m_arText) { arZeile = Zeile.Split(new char[] { ';' }, StringSplitOptions.None); m_arPunkte.Add(arZeile); } foreach (string[] Zeile in m_arPunkte) { bool bFehler = false; Rechtswert = new Double(); Hochwert = new Double(); Höhe = new Double(); string Blockname = String.Empty; PNum = Zeile[0]; if (m_Util.convertToDouble(Zeile[1], ref Rechtswert, null) != Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { bFehler = true; } if (m_Util.convertToDouble(Zeile[2], ref Hochwert, null) != Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { bFehler = true; } Autodesk.AutoCAD.Runtime.ErrorStatus eSHöhe = m_Util.convertToDouble(Zeile[3], ref Höhe, null); if (!(eSHöhe == Autodesk.AutoCAD.Runtime.ErrorStatus.OK || eSHöhe == Autodesk.AutoCAD.Runtime.ErrorStatus.NullExtents)) { bFehler = true; } //Nachkommastellen Höhe myAutoCAD.myUtilities objUtil = new myAutoCAD.myUtilities(); int Precision = objUtil.Precision(Zeile[3]); double CASHöhe = Höhe; Höhe = Math.Round(Höhe, Convert.ToInt32(m_objRegIO.readValue("blocks", "Kommastellen"))); //Blockname try { if (Zeile[4] != "" && Zeile[4] != "\r") { Blockname = Zeile[4]; } } catch { } //Att3 (Datum) string Att3 = String.Empty; try { if (Zeile[4] != "" && Zeile[4] != "\r") { Att3 = Zeile[4]; } } catch { } //Att4 (Code) string Att4 = String.Empty; try { if (Zeile[5] != "" && Zeile[5] != "\r") { Att4 = Zeile[5]; } } catch { } //Att5 (Hersteller) string Att5 = String.Empty; try { if (Zeile[6] != "" && Zeile[6] != "\r") { Att5 = Zeile[6]; } } catch { } //Att6 string Att6 = String.Empty; try { if (Zeile[7] != "" && Zeile[7] != "\r") { Att6 = Zeile[7]; } } catch { } //Att7 string Att7 = String.Empty; try { if (Zeile[8] != "" && Zeile[8] != "\r") { Att7 = Zeile[8]; } } catch { } //Att8 string Att8 = String.Empty; try { if (Zeile[9] != "" && Zeile[9] != "\r") { Att8 = Zeile[9]; } } catch { } //Att9 string Att9 = String.Empty; try { if (Zeile[10] != "" && Zeile[10] != "\r") { Att9 = Zeile[10]; } } catch { } //Att10 string Att10 = String.Empty; try { if (Zeile[11] != "" && Zeile[11] != "\r") { Att10 = Zeile[11]; } } catch { } if (!bFehler) { //Höhe if (eSHöhe == Autodesk.AutoCAD.Runtime.ErrorStatus.NullExtents) { Höhenwert = null; } else { Höhenwert = Höhe; } myAutoCAD.Messpunkt objMP = new Messpunkt(PNum, Rechtswert, Hochwert, Höhenwert, CASHöhe, Precision, Blockname); if (Att3 != String.Empty) { objMP.Att3_Wert = Att3; } if (Att4 != String.Empty) { objMP.Att4_Wert = Att4; } if (Att5 != String.Empty) { objMP.Att5_Wert = Att5; } if (Att6 != String.Empty) { objMP.Att6_Wert = Att6; } if (Att7 != String.Empty) { objMP.Att7_Wert = Att7; } if (Att8 != String.Empty) { objMP.Att8_Wert = Att8; } if (Att9 != String.Empty) { objMP.Att9_Wert = Att9; } if (Att10 != String.Empty) { objMP.Att10_Wert = Att10; } if (objMP.draw("MP", Basislayer) == Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { Zähler += 1; } else { break; } } } break; } MessageBox.Show(Zähler.ToString() + " Punkte importiert!"); m_ed.Regen(); //Object acadObject = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication; //acadObject.GetType().InvokeMember("ZoomExtents", BindingFlags.InvokeMethod, null, acadObject, null); } else { MessageBox.Show(m_Filename + " kann nicht geöffnet werden!"); } } }
public List <Fahrzeug> FahrzeugeAuslesen() { string[] DateiInhalt = File.ReadAllLines(@"fahrzeuge.txt"); string[] ZeilenInhalt; Fahrzeug fahrzeug; foreach (string Zeile in DateiInhalt) { ZeilenInhalt = Zeile.Split(';'); switch (ZeilenInhalt.Length) { case 9: fahrzeug = new PKW(); fahrzeug.Hersteller = ZeilenInhalt[0]; fahrzeug.Modell = ZeilenInhalt[1]; fahrzeug.Kennzeichen = ZeilenInhalt[2]; fahrzeug.Zulassungsdatum = Convert.ToDateTime(ZeilenInhalt[3]); fahrzeug.Anschaffungspreis = Convert.ToInt32(ZeilenInhalt[4]); (fahrzeug as PKW).Hubraum = Convert.ToInt32(ZeilenInhalt[5]); (fahrzeug as PKW).Leistung = Convert.ToInt32(ZeilenInhalt[6]); (fahrzeug as PKW).Schadstoffklasse = Convert.ToInt32(ZeilenInhalt[7]); break; case 8: fahrzeug = new LKW(); fahrzeug.Hersteller = ZeilenInhalt[0]; fahrzeug.Modell = ZeilenInhalt[1]; fahrzeug.Kennzeichen = ZeilenInhalt[2]; fahrzeug.Zulassungsdatum = Convert.ToDateTime(ZeilenInhalt[3]); fahrzeug.Anschaffungspreis = Convert.ToInt32(ZeilenInhalt[4]); (fahrzeug as LKW).Zuladung = Convert.ToDouble(ZeilenInhalt[5]); (fahrzeug as LKW).AchsenAnzahl = Convert.ToInt32(ZeilenInhalt[6]); break; case 7: fahrzeug = new Motorrad(); fahrzeug.Hersteller = ZeilenInhalt[0]; fahrzeug.Modell = ZeilenInhalt[1]; fahrzeug.Kennzeichen = ZeilenInhalt[2]; fahrzeug.Zulassungsdatum = Convert.ToDateTime(ZeilenInhalt[3]); fahrzeug.Anschaffungspreis = Convert.ToInt32(ZeilenInhalt[4]); (fahrzeug as Motorrad).Hubraum = Convert.ToInt32(ZeilenInhalt[5]); break; default: fahrzeug = null; break; } if (fahrzeug != null) { fahrzeuge.Add(fahrzeug); fahrzeug = null; } else { MessageBox.Show("Daten sind Fehlerhaft"); } } return(fahrzeuge); }
private void bt_OpenPTFile_Click(object sender, EventArgs e) { OpenFileDialog ddOpenFile = new OpenFileDialog(); ddOpenFile.Title = "Vermessungspunkte importieren"; ddOpenFile.Filter = "Punktwolke|*.csv"; ddOpenFile.DefaultExt = "csv"; string[] arText; //Array mit Zeilen List <string[]> arPunkte = new List <string[]>(); arPunkte.Clear(); m_lsMP.Clear(); tB_nPTÜbereinstimmung.Text = ""; m_lsMPÜbereinstimmung.Clear(); Editor m_ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; if (ddOpenFile.ShowDialog() == DialogResult.OK) { m_Filename = ddOpenFile.FileName; StreamReader sr = new StreamReader(m_Filename, Encoding.Default); m_Text = sr.ReadToEnd(); sr.Close(); m_Extention = m_Filename.Substring(m_Filename.LastIndexOf('.') + 1).ToLower(); string[] arZeile; int iZeile = 1; switch (m_Extention) { case "csv": arText = m_Text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries); //Zeilen von MP in Array einfügen foreach (string Zeile in arText) { arZeile = Zeile.Split(new char[] { ';' }, StringSplitOptions.None); arPunkte.Add(arZeile); } foreach (string[] Zeile in arPunkte) { string PNum; double Rechtswert = new double(); double Hochwert = new double(); double Höhe = new double(); double?Höhenwert = null; bool bFehler = false; Autodesk.AutoCAD.Runtime.ErrorStatus es; PNum = Zeile[0]; if (m_Util.convertToDouble(Zeile[1], ref Rechtswert, iZeile) != Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { bFehler = true; } if (m_Util.convertToDouble(Zeile[2], ref Hochwert, iZeile) != Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { bFehler = true; } es = m_Util.convertToDouble(Zeile[3], ref Höhe, iZeile); if (es == Autodesk.AutoCAD.Runtime.ErrorStatus.OK) { Höhenwert = Höhe; } if (es != Autodesk.AutoCAD.Runtime.ErrorStatus.OK || es != Autodesk.AutoCAD.Runtime.ErrorStatus.NullPtr) { bFehler = false; } //Nachkommastellen Höhe myAutoCAD.myUtilities objUtil = new myAutoCAD.myUtilities(); int Precision = objUtil.Precision(Zeile[3]); if (!bFehler) { myAutoCAD.Messpunkt objMP = new Messpunkt(PNum, Rechtswert, Hochwert, Höhenwert, Höhenwert, Precision); objMP.Att4_Wert = myUtilities.Global.Owner; m_lsMP.Add(objMP); } iZeile++; } //Bestimmen der Punkte mit Übereinstimmung Punktdatenfile mit Zeichnung foreach (Messpunkt MP in m_lsMP) { Messpunkt objMP = new Messpunkt(); if (m_Blöcke.findPos(ref objMP, new Autodesk.AutoCAD.Geometry.Point2d(MP.Position.X, MP.Position.Y), 0.01) == ErrorStatus.OK) { m_lsMPÜbereinstimmung.Add(objMP); } } //Ausgabe Dialogbox tB_PTFilename.Text = m_Filename; tb_nPunkteFile.Text = m_lsMP.Count.ToString(); tB_nPTÜbereinstimmung.Text = m_lsMPÜbereinstimmung.Count.ToString(); if (m_lsMPÜbereinstimmung.Count > 0) { bt_markieren.Enabled = true; bt_löschen.Enabled = true; } break; } } }