Exemplo n.º 1
0
 private void Serialize(XmlNode node, string typ)
 {
     if (node != null)
     {
         node = node.FirstChild;
         for (; ;)
         {
             if (node == null)
             {
                 break;
             }
             if (node.LocalName.ToUpper() == "DATA")
             {
                 if (typ == "JO")
                 {
                     var data = new JoggenDaten();
                     if (data.Serialize(node.FirstChild))
                     {
                         this.JoDaten.Add(data);
                     }
                 }
                 if (typ == "HT")
                 {
                     var data = new HeimtrainerDaten();
                     if (data.Serialize(node.FirstChild))
                     {
                         this.HtDaten.Add(data);
                     }
                 }
                 if (typ == "RV")
                 {
                     var data = new RVDaten();
                     if (data.Serialize(node.FirstChild))
                     {
                         this.RvDaten.Add(data);
                     }
                 }
             }
             node = node.NextSibling;
         }
     }
 }
Exemplo n.º 2
0
        protected override void OnInitial()
        {
            //			SetData(2,0,11.2345,2);

            this.Text  = "Joggen-Info";
            this.Text += " (" + Settings.Jahr + ")";

            SetTitel(" Datum     Zeit   G1 /W1  G2 /W2  G3 /W3  G4 /W4  G5   Gewicht Strecke               Bemerkung ");
            SetTitel(" Datum       Zeit    Position-1    Position-2    Position-3    Position-4    Position-5    Position-6   Gewicht Strecke          Bemerkung ");
            //
            //			double tZeit=0.0;
            //			double tKJoul=0.0;
            //			double tKm=0.0;
            for (var i = 0; i < _rv.JoDaten.Count; i++)
            {
                var jo = _rv.JoDaten[i];
                //
                var datum = jo.StringDatum.Substring(6, 2) + "." + jo.StringDatum.Substring(4, 2) + "." + jo.StringDatum.Substring(0, 4);

                SetData(1, i, datum);//"Monat            Km     Std     Km/h     mal      ");

                SetData(15, i, jo.Dauer, 2);
                if (jo.Position1 != 0.0)
                {
                    SetData(23, i, jo.Position1, 2);
                }
                if (jo.Position2 != 0.0)
                {
                    SetData(23 + 6, i, JoggenDaten.GetZwischenZeit(jo.Position2, jo.Position1), 2, Color.Beige);
                }

                //string ss=jo.ZZ1;

                //                if(jo.W1!=0.0)
                //                {
                //                    if(jo.W1>=1.0)
                //                        SetData(23,i, jo.W1,0);
                //                    else
                //                    {
                //                        SetData(22,i, jo.W1,1);
                ////						SetData(22,i, "<1");
                //                    }
                //                    SetData(23-2,i, "/");
                //                }
                //                if(jo.G2!=0.0)SetData(27,i, jo.G2,1);
                if (jo.Position2 != 0.0)
                {
                    SetData(37, i, jo.Position2, 2);
                }
                if (jo.Position3 != 0.0)
                {
                    SetData(37 + 6, i, JoggenDaten.GetZwischenZeit(jo.Position3, jo.Position2), 2, Color.Beige);
                }

                //if(jo.W2!=0.0)
                //{
                //    if(jo.W2>=1.0)
                //        SetData(31,i, jo.W2,0);
                //    else
                //    {
                //        SetData(30,i, jo.W2,1);
                //    //	SetData(30,i, "<1");
                //    }

                //    SetData(31-2,i, "/");
                //}
                //if(jo.G3!=0.0)SetData(35,i, jo.G3,1);
                if (jo.Position3 != 0.0)
                {
                    SetData(51, i, jo.Position3, 2);
                }
                if (jo.Position4 != 0.0)
                {
                    SetData(51 + 6, i, JoggenDaten.GetZwischenZeit(jo.Position4, jo.Position3), 2, Color.Beige);
                }

                //				if(jo.W3!=0.0)
                //				{
                //					if(jo.W3>=1.0)
                //						SetData(39,i, jo.W3,0);
                //					else
                //					{
                //						SetData(38,i, jo.W3,1);
                //					//	SetData(38,i, "<1");
                //					}
                //					SetData(39-2,i, "/");
                //				}
                //				if(jo.G4!=0.0)SetData(43,i, jo.G4,1);
                if (jo.Position4 != 0.0)
                {
                    SetData(65, i, jo.Position4, 2);
                }
                if (jo.Position5 != 0.0)
                {
                    SetData(65 + 6, i, JoggenDaten.GetZwischenZeit(jo.Position5, jo.Position4), 2, Color.Beige);
                }

                //				if(jo.W4!=0.0)
                //				{
                //					SetData(47,i, jo.W4,0);
                //					SetData(47-2,i, "/");
                //				}
                //				if(jo.G5!=0.0)SetData(51,i, jo.G5,1);
                if (jo.Position5 != 0.0)
                {
                    SetData(79, i, jo.Position5, 2);
                }
                if (jo.Position6 != 0.0)
                {
                    SetData(79 + 6, i, JoggenDaten.GetZwischenZeit(jo.Position6, jo.Position5), 2, Color.Beige);
                }

                if (jo.Position6 != 0.0)
                {
                    SetData(93, i, jo.Position6, 2);
                }
                //if(jo.Position6!=0.0)
                //	SetData(93+5, i, jo.Position6-jo.Position5, 1, Color.Beige);

                //if(jo.W5!=0.0)SetData(55,i, jo.W5,0);

                if (jo.Gewicht != 0.0)
                {
                    SetData(106, i, jo.Gewicht, 1);
                }

                SetData(112, i, jo.Strecke);
                //				SetData(35, i, f.ConvertToDouble(jo.Zeit),2);
                if (!string.IsNullOrWhiteSpace(jo.Bemerkung))
                {
                    SetData(127, i, "                                 ");
                    SetData(127, i, "  " + jo.Bemerkung);
                }

                //				SetData(15, i, ht.Belastung,1);
                //				SetData(25, i, f.ConvertToDouble(ht.Zeit),2);
                //				SetData(34, i, ht.PulsschlagVor,0);
                //				SetData(34, i, "/");
                //				SetData(38, i, ht.PulsschlagNach,0);
                //				SetData(44, i, ht.Distanz,1);
                //				SetData(52, i, 60*ht.Distanz/f.ConvertToDouble(ht.Zeit),2);
                //				SetData(65, i, ht.KJoul,0);
                //				SetData(71, i, ht.KJoul/4.186,0);
                //				SetData(78, i, f.ConvertToDouble(ht.Gewicht),1);
                //
                //				tZeit+=f.ConvertToDouble(ht.Zeit);
                //				tKm+=ht.Distanz;
                //				tKJoul+=ht.KJoul;
            }
            //
            //
            //			int y=_rv.HtDaten.Count+2;
            //			SetData(1, y, _rv.HtDaten.Count.ToString());
            //			SetData(25, y, tZeit/60,2);
            //			SetData(29, y, "Std");
            //			SetData(44, y, tKm,1);
            //			SetData(47, y, "Km");
            //			//SetData(65, y, tKJoul/4.186,2);
            //			SetData(68, y, tKJoul/4.186/900/10,2);
            //			SetData(72, y, "Kg");
        }
Exemplo n.º 3
0
        public void Load(bool useJsonFileFormat = false)
        {
            var ecpwin = System.Text.Encoding.GetEncoding(1252);

            //RVDaten
            var pfad = this.Pfad + this.Jahr + "\\RV-" + this.Jahr + ".csv";

            RvDaten.Clear();
            if (File.Exists(pfad))
            {
                var sr = new StreamReader(File.OpenRead(pfad), ecpwin);
                sr.BaseStream.Seek(0, SeekOrigin.Begin);

                for (; ;)
                {
                    var rv = new RVDaten();
                    if (!rv.Serialize(sr))
                    {
                        break;
                    }
                    RvDaten.Add(rv);
                }
                sr.Close();
            }

            pfad = this.Pfad + this.Jahr + "\\SD.csv";
            if (!File.Exists(pfad))
            {
                pfad = this.Pfad + this.Jahr + "\\SD-" + this.Jahr + ".csv";
            }

            SdDaten.Clear();
            if (File.Exists(pfad))
            {
                var sr = new StreamReader(File.OpenRead(pfad), ecpwin);
                sr.BaseStream.Seek(0, SeekOrigin.Begin);
                for (; ;)
                {
                    var sd = new SDDaten();
                    if (!sd.Serialize(sr))
                    {
                        break;
                    }
                    SdDaten.Add(sd);
                }
                sr.Close();
            }

            //HeimtrainerDaten
            pfad = this.Pfad + this.Jahr + "\\HT-" + this.Jahr + ".csv";
            HtDaten.Clear();
            if (File.Exists(pfad))
            {
                var sr = new StreamReader(File.OpenRead(pfad), ecpwin);
                sr.BaseStream.Seek(0, SeekOrigin.Begin);

                for (; ;)
                {
                    var htd = new HeimtrainerDaten();
                    if (!htd.Serialize(sr))
                    {
                        break;
                    }
                    HtDaten.Add(htd);
                }
                sr.Close();
            }

            //JoggenDaten
            pfad = this.Pfad + this.Jahr + "\\JO-" + this.Jahr + ".csv";
            JoDaten.Clear();
            if (File.Exists(pfad))
            {
                var sr = new StreamReader(File.OpenRead(pfad), ecpwin);
                sr.BaseStream.Seek(0, SeekOrigin.Begin);

                long version = 1;
                for (; ;)
                {
                    var htd = new JoggenDaten();
                    if (!htd.Serialize(sr, ref version))
                    {
                        break;
                    }

                    //var tmp = htd.Strecke.ToLower().Trim();
                    JoDaten.Add(htd);
                }
                sr.Close();
            }

            #region Load jo.xml, and save jo.json

            var jo_xml = this.Pfad + this.Jahr + "\\JO-" + this.Jahr + ".xml";
            if (!File.Exists(jo_xml))
            {
                jo_xml = this.Pfad + this.Jahr + "\\JO.xml";
            }

            var jsonJoFile = jo_xml.Replace(".xml", ".json");
            if (useJsonFileFormat && File.Exists(jsonJoFile))
            {
                var fileContent = File.ReadAllText(jsonJoFile, Encoding.UTF8);
                this.JoDaten = JsonConvert.DeserializeObject <List <JoggenDaten> >(fileContent);
            }
            else if (File.Exists(jo_xml))
            {
                var settings = new XmlReaderSettings();
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.IgnoreWhitespace = true;
                settings.IgnoreComments   = true;
                var reader = XmlReader.Create(jo_xml, settings);

                var node = FindRoot(reader);
                Serialize(node, "JO");
                reader.Close();

                var jsonString = JsonConvert.SerializeObject(this.JoDaten, Newtonsoft.Json.Formatting.Indented);
                File.WriteAllText(jsonJoFile, jsonString, Encoding.UTF8);
            }

            #endregion

            #region Load ht.xml, and save ht.json

            var ht_xml = this.Pfad + this.Jahr + "\\HT-" + this.Jahr + ".xml";
            if (!File.Exists(ht_xml))
            {
                ht_xml = this.Pfad + this.Jahr + "\\HT.xml";
            }

            var jsonHtFile = ht_xml.Replace(".xml", ".json");
            if (useJsonFileFormat && File.Exists(jsonHtFile))
            {
                var fileContent = File.ReadAllText(jsonHtFile, Encoding.UTF8);
                this.HtDaten = JsonConvert.DeserializeObject <List <HeimtrainerDaten> >(fileContent);
            }
            else if (File.Exists(ht_xml))
            {
                var settings = new XmlReaderSettings();
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.IgnoreWhitespace = true;
                settings.IgnoreComments   = true;
                var reader = XmlReader.Create(ht_xml, settings);

                var node = FindRoot(reader);
                Serialize(node, "HT");
                reader.Close();

                var jsonString = JsonConvert.SerializeObject(this.HtDaten, Newtonsoft.Json.Formatting.Indented);
                File.WriteAllText(jsonHtFile, jsonString, Encoding.UTF8);
            }

            #endregion

            #region Load rv.xml and save rv.json

            var rv_xml = this.Pfad + this.Jahr + "\\RV-" + this.Jahr + ".xml";
            if (!File.Exists(rv_xml))
            {
                rv_xml = this.Pfad + this.Jahr + "\\RV.xml";
            }

            var jsonRvFile = rv_xml.Replace(".xml", ".json");
            if (useJsonFileFormat && File.Exists(jsonRvFile))
            {
                var fileContent = File.ReadAllText(jsonRvFile, Encoding.UTF8);
                this.RvDaten = JsonConvert.DeserializeObject <List <RVDaten> >(fileContent);
            }
            else if (File.Exists(rv_xml))
            {
                var settings = new XmlReaderSettings();
                settings.ConformanceLevel = ConformanceLevel.Fragment;
                settings.IgnoreWhitespace = true;
                settings.IgnoreComments   = true;
                var reader = XmlReader.Create(rv_xml, settings);

                var node = FindRoot(reader);
                Serialize(node, "RV");
                reader.Close();

                var jsonString = JsonConvert.SerializeObject(this.RvDaten, Newtonsoft.Json.Formatting.Indented);
                File.WriteAllText(jsonRvFile, jsonString, Encoding.UTF8);
            }

            #endregion
        }
Exemplo n.º 4
0
        private void cmdOk_Click(object sender, System.EventArgs e)
        {
            var data = new JoggenDaten();

            data.StringDatum = dtDatum.Value.ToString("yyyyMMdd");
            data.Strecke     = cboStrecke.Text;

            //if(tbPause1.Text!="1.00")
            //    data.W1=f.ConvertToDouble(tbPause1.Text);
            //if(tbPause2.Text!="1.00")
            //    data.W2=f.ConvertToDouble(tbPause2.Text);
            //if(tbPause3.Text!="1.00")
            //    data.W3=f.ConvertToDouble(tbPause3.Text);
            //if(tbPause4.Text!="1.00")
            //    data.W4=f.ConvertToDouble(tbPause4.Text);

            //data.LP1=f.ConvertToDouble(tbLp1.Text);
            //data.LP2=f.ConvertToDouble(tbLp2.Text);
            //data.LP3=f.ConvertToDouble(tbLp3.Text);
            //data.LP4=f.ConvertToDouble(tbLp4.Text);
            //data.LP5=f.ConvertToDouble(tbLp5.Text);

            //if(data.LP5==0.0)	data.W4=0.0;
            //if(data.LP4==0.0)	data.W3=0.0;
            //if(data.LP3==0.0)	data.W2=0.0;
            //if(data.LP2==0.0)	data.W1=0.0;

            /*
             *          data.G1=f.ConvertToDouble(tbLp1.Text);
             *          data.G2=f.ConvertToDouble(tbLp2.Text);
             *          data.G3=f.ConvertToDouble(tbLp3.Text);
             *          data.G4=f.ConvertToDouble(tbLp4.Text);
             *          data.G5=f.ConvertToDouble(tbLp5.Text);*/
            data.Gewicht   = tbGewicht.Text.ToDouble();
            data.Bemerkung = this.tbBemerkung.Text;

            /*			data.Belastung=f.ConvertToDouble(tbBelastung.Text);
             *          data.Zeit=tbDauer.Text;
             *          data.PulsschlagVor=f.ConvertToDouble(tbPulsschlagV.Text);
             *          data.PulsschlagNach=f.ConvertToDouble(tbPulsschlagN.Text);
             *          data.Distanz=f.ConvertToDouble(tbDistanz.Text);
             *          data.KJoul=f.ConvertToDouble(tbKJoul.Text);
             *          data.Gewicht=tbGewicht.Text;
             */
            _rv.JoDaten.Add(data);

            _rv.SaveData("JO");

            //			cboStrecke.Text="";
            tbLp1.Text       = "0.0";
            tbLp2.Text       = "0.0";
            tbLp3.Text       = "0.0";
            tbLp4.Text       = "0.0";
            tbLp5.Text       = "0.0";
            tbBemerkung.Text = "";
            tbGewicht.Text   = "0.0";

            /*			tbBelastung.Text="0.0";
             *          tbDauer.Text="0.0";
             *          tbPulsschlagV.Text="0.0";
             *          tbPulsschlagN.Text="0.0";
             *          tbDistanz.Text="0.0";
             *          tbKJoul.Text="0.0";
             *          tbGewicht.Text="0.0";
             */
        }