示例#1
0
        /// <summary>
        /// Gets today's daily record class.  If not found, a new one is created.
        /// </summary>
        /// <returns></returns>
        public DailyRecord GetDailyRecord()
        {
            DateTime today = DateTime.Now.Date;

            foreach( DailyRecord record in this.DailyRecords )
            {
                if( record.Date == today )
                    return record;
            }

            DailyRecord newrecord = new DailyRecord();
            newrecord.Date = today;
            newrecord.CurrentWords = this.NumWords;
            newrecord.StartingWords = this.NumWords;
            newrecord.Elapsed = new TimeSpan();

            this.DailyRecords.Add( newrecord );

            return newrecord;
        }
示例#2
0
        public static void LoadStatistics( XmlTextReader reader, IList<DailyRecord> records )
        {
            string nodeName = reader.Name;

            while( reader.Read() )
            {
                if( reader.NodeType == XmlNodeType.EndElement && reader.Name == nodeName )
                    break;

                if( reader.NodeType != XmlNodeType.Element ) continue;

                switch( reader.Name )
                {
                    case "record":
                        DailyRecord record = new DailyRecord();
                        record.Date = DateTime.ParseExact( reader.GetAttribute( "date" ), "s", System.Globalization.CultureInfo.InvariantCulture );
                        record.Elapsed = TimeSpan.Parse( reader.GetAttribute( "elapsed" ) );
                        record.StartingWords = int.Parse( reader.GetAttribute( "start" ) );
                        record.CurrentWords = int.Parse( reader.GetAttribute( "end" ) );
                        records.Add( record );
                        break;
                }
            }
        }