예제 #1
0
        private void HoleDaten(string strFile, string strSort, string strWomit)
        {
            CollWertpapiere cwp = Wertpapiere_ReadXml(strFile, out DateTime dt);

            foreach (Wertpapier wp in cwp)
            {
                if (wp.IsSumme)
                {
                    continue;
                }
                Wertpapierklasse typeid = (Wertpapierklasse)wp.Type;
                if (typeid < Wertpapierklasse.MinWertpap || typeid > Wertpapierklasse.MaxWertpap)
                {
                    continue;
                }
                if (wp.ISIN.ToString().Length != 12)
                {
                    continue;
                }
                _synchrovs.Add(new SynchroV {
                    WPVAnzahl           = wp.Anzahl,
                    WPVName             = wp.Name,
                    WPVKursZeit         = wp.KursZeit,
                    WPVAktWert          = wp.AktWert,
                    WPVISIN             = wp.ISIN,
                    WPVURL              = wp.URL,
                    WPVKurs             = (float)wp.AktKurs,
                    WPVProzentAenderung = wp.Heute,
                    WPVType             = (Wertpapierklasse)wp.Type,
                    WPVSharpe           = wp.Sharpe,
                    WPVBemerkung        = strWomit + " " + strFile + " " + dt,
                    WPVSort             = wp.ISIN + " " + strSort,
                    WPVRowColor         = "0",
                    WPVAnzeigen         = NurPreisDifferenzen ^ true,
                    WPVForegroundColor  = Brushes.AliceBlue
                });
            }
        }
        public void Ausführen()
        {
            txtUnten.Clear();
            txtUnten.FontSize   = 10;
            txtUnten.FontFamily = new FontFamily("Courier New, Verdana");
            PrintTxtUnten("Start -KontenAusInternetSynchronisieren-2-");
            DateTime dt = DataSetAdmin.HolenAusXml(Helpers.GlobalRef.g_Ein.MyDataPfad);

            if (dt == null)
            {
                MessageBox.Show("MeineFinanzen HauptFenster.xaml.cs HauptFenster() Fehler HolenAusXml() DataSetAdmin");
                MessageBox.Show("MyPortfolio Fehler!!  Dateien nicht geladen!!!!");
                Close();
            }
            PrintTxtUnten(dt.ToString());
            // DataColumn[] keys = new DataColumn[1];
            // keys[0] = DataSetAdmin.dtPortFol.Columns["WPIsin"];
            // DataSetAdmin.dtPortFol.PrimaryKey = keys;       // NOCH
            Visibility  = Visibility.Visible;
            WindowState = WindowState.Maximized;
            string[] _strurl = new string[3];
            _strurl[0] = "http://www.finanztreff.de";
            _strurl[1] = "http://waehrungen.finanztreff.de/devisen_uebersicht.htn";                       // USD ...
            _strurl[2] = "http://waehrungen.finanztreff.de/devisen_einzelkurs_uebersicht,i,2079609.html"; // nur SGD
            string[] _strWohin = new string[3];
            _strWohin[0] = "MarktÜberblick";
            _strWohin[1] = "USD";
            _strWohin[2] = "SGD";
            string strx = _strFile + _strWohin[0] + ".html";

            if (!File.Exists(strx))
            {
                File.Create(strx);
            }
            //DateTime dtLastWriteTime = File.GetLastWriteTime(strx);
            string _url = "";

            for (int lop = 0; lop < 3; lop++)
            {
                _url = _strurl[lop];
                string    strFile  = _strFile + _strWohin[lop] + ".html";
                WebClient wclient1 = new WebClient();
                wclient1.DownloadFile(new Uri(_url), strFile);
            }
            dtPortFol = DataSetAdmin.dsHier.Tables["tblPortFol"];       // dtPortFol geholt.
            foreach (DataRow dr in dtPortFol.Rows)
            {
                Wertpapierklasse typeid = (Wertpapierklasse)dr["WPTypeID"];

                //if (typeid != Wertpapierklasse.Anleihe)
                //    continue;

                if (typeid < Wertpapierklasse.MinWertpap || typeid > Wertpapierklasse.MaxWertpap)
                {
                    continue;
                }
                if (dr["WPISIN"].ToString().Length != 12)
                {
                    continue;
                }
                _wertpapsynchro.Add(new WertpapSynchro {
                    WPSAnzahl   = Convert.ToSingle(dr["WPAnzahl"]),
                    WPSName     = dr["WPName"].ToString(),
                    WPSKursZeit = Convert.ToDateTime(dr["WPStand"]),
                    WPSISIN     = dr["WPISIN"].ToString(),

                    WPSURL              = dr["WPUrlText"].ToString(),
                    WPSKurs             = Convert.ToSingle(dr["WPKurs"]),
                    WPSProzentAenderung = Convert.ToSingle(dr["WPProzentAenderung"]),
                    WPSType             = (Wertpapierklasse)Convert.ToInt32(dr["WPTypeID"]),
                    WPSSharpe           = Convert.ToSingle(dr["WPSharpe"]),

                    WPURLSharp   = dr["WPUrlSharpe"].ToString(),
                    WPXPathKurs  = dr["WPXPathKurs"].ToString(),
                    WPXPathAend  = dr["WPXPathAend"].ToString(),
                    WPXPathZeit  = dr["WPXPathZeit"].ToString(),
                    WPXPathSharp = dr["WPXPathSharp"].ToString(),
                    WPSColor     = "0"
                });
            }
            progrBar.Maximum = _wertpapsynchro.Count;
            Progress         = 1;
            Minimum          = 0;
            Maximum          = _wertpapsynchro.Count;
            do
            {
            } while (LosGehts(true));
        }