public clsDataPoint(clsDataPoint dp) { this.Old = dp.Old; this.New = dp.New; this.Field = dp.Field; this.Time = dp.Time; this.VideoID = dp.VideoID; }
void sm_OnEntryUpdated(object Sender, clsDataPoint DataPoint, clsVideoEntry Entry) { if (this.InvokeRequired) { GenericDelegate dlg = delegate() { lb2.Items.Add(Entry.Title + ", " + DataPoint.Field.ToString() + ", " + DataPoint.Old.ToString() + " => " + DataPoint.New.ToString() ); }; lb2.Invoke(dlg); } else lb2.Items.Add(DataPoint.Field.ToString()); }
private void _entry_updated(clsDataPoint DataPoint, clsVideoEntry Entry) { if (_file_logger != null) _file_logger.appendFile(DataPoint.ToString()); if (OnEntryUpdated != null) OnEntryUpdated(this, DataPoint, Entry); }
private void _compare_stat(double Old, double New, clsDataPointField.VideoDataFields Field, clsVideoEntry Entry) { if (Old == New) return; else { clsDataPoint new_datapoint = new clsDataPoint(Old, New, new clsDataPointField(Field), Entry.VideoID); if (_historical_data.ContainsKey(Entry.VideoID)) _historical_data[Entry.VideoID].Add(new_datapoint); else { List<clsDataPoint> new_dp_list = new List<clsDataPoint>(); new_dp_list.Add(new_datapoint); _historical_data.Add(Entry.VideoID, new_dp_list); } _entry_updated(new_datapoint, Entry); } }
private static List<clsDataPoint> _compare_entities(clsVideoEntry e_adding, clsVideoEntry e_init) { clsDataPoint new_dp = null; List<clsDataPoint> ret = new List<clsDataPoint>(); if (e_adding.Time < e_init.Time) { if (e_adding.ViewsCount != e_adding.ViewsCount) { new_dp = new clsDataPoint((double)e_adding.ViewsCount, (double)e_init.ViewsCount, new clsDataPointField(clsDataPointField.VideoDataFields.VIEWS), e_init.VideoID); new_dp.Time = e_init.Time; ret.Add(new_dp); } if (e_adding.ViewsCount != e_adding.ViewsCount) { new_dp = new clsDataPoint((double)e_adding.Raters, (double)e_init.Raters, new clsDataPointField(clsDataPointField.VideoDataFields.RATERS), e_init.VideoID); new_dp.Time = e_init.Time; ret.Add(new_dp); } if (e_adding.ViewsCount != e_adding.ViewsCount) { new_dp = new clsDataPoint((double)e_adding.FavoritedCount, (double)e_init.FavoritedCount, new clsDataPointField(clsDataPointField.VideoDataFields.FAVORITED_COUNT), e_init.VideoID); new_dp.Time = e_init.Time; ret.Add(new_dp); } if (e_adding.ViewsCount != e_adding.ViewsCount) { new_dp = new clsDataPoint((double)e_adding.CommentCount, (double)e_init.CommentCount, new clsDataPointField(clsDataPointField.VideoDataFields.COMMENT_COUNT), e_init.VideoID); new_dp.Time = e_init.Time; ret.Add(new_dp); } if (e_adding.ViewsCount != e_adding.ViewsCount) { new_dp = new clsDataPoint((double)e_adding.AverageRating, (double)e_init.AverageRating, new clsDataPointField(clsDataPointField.VideoDataFields.AVERAGE_RATING), e_init.VideoID); new_dp.Time = e_init.Time; ret.Add(new_dp); } e_init = e_adding; } else { if (e_init.ViewsCount != e_init.ViewsCount) { new_dp = new clsDataPoint((double)e_init.ViewsCount, (double)e_adding.ViewsCount, new clsDataPointField(clsDataPointField.VideoDataFields.VIEWS), e_adding.VideoID); new_dp.Time = e_adding.Time; ret.Add(new_dp); } if (e_init.ViewsCount != e_init.ViewsCount) { new_dp = new clsDataPoint((double)e_init.Raters, (double)e_adding.Raters, new clsDataPointField(clsDataPointField.VideoDataFields.RATERS), e_adding.VideoID); new_dp.Time = e_adding.Time; ret.Add(new_dp); } if (e_init.ViewsCount != e_init.ViewsCount) { new_dp = new clsDataPoint((double)e_init.FavoritedCount, (double)e_adding.FavoritedCount, new clsDataPointField(clsDataPointField.VideoDataFields.FAVORITED_COUNT), e_adding.VideoID); new_dp.Time = e_adding.Time; ret.Add(new_dp); } if (e_init.ViewsCount != e_init.ViewsCount) { new_dp = new clsDataPoint((double)e_init.CommentCount, (double)e_adding.CommentCount, new clsDataPointField(clsDataPointField.VideoDataFields.COMMENT_COUNT), e_adding.VideoID); new_dp.Time = e_adding.Time; ret.Add(new_dp); } if (e_init.ViewsCount != e_init.ViewsCount) { new_dp = new clsDataPoint((double)e_init.AverageRating, (double)e_adding.AverageRating, new clsDataPointField(clsDataPointField.VideoDataFields.AVERAGE_RATING), e_adding.VideoID); new_dp.Time = e_adding.Time; ret.Add(new_dp); } } return ret; }
public void LoadDataFile(string LogFileContents) { List<clsVideoEntry> init = new List<clsVideoEntry>(); Dictionary<string, List<clsDataPoint>> hist = new Dictionary<string, List<clsDataPoint>>(); string log = LogFileContents; Regex r = new Regex("init : .+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}.+?{(.+?)}"); MatchCollection matches = r.Matches(log); foreach (Match m in matches) { Google.GData.YouTube.YouTubeEntry entry = new Google.GData.YouTube.YouTubeEntry(); entry.VideoId = m.Groups[3].Value; Google.GData.Extensions.FeedLink feedlink = new Google.GData.Extensions.FeedLink(); feedlink.CountHint = int.Parse(m.Groups[8].Value); entry.Comments = new Google.GData.Extensions.Comments(); entry.Comments.FeedLink = feedlink; entry.Statistics = new Google.GData.YouTube.Statistics(); entry.Statistics.ViewCount = m.Groups[7].Value; entry.Statistics.FavoriteCount = m.Groups[9].Value; entry.Rating = new Google.GData.Extensions.Rating(); entry.Rating.NumRaters = int.Parse(m.Groups[5].Value); entry.Rating.Average = double.Parse(m.Groups[6].Value); entry.Title = new Google.GData.Client.AtomTextConstruct(Google.GData.Client.AtomTextConstructElementType.Title, m.Groups[4].Value); clsVideoEntry new_e = new clsVideoEntry(entry); new_e.Time = DateTime.Parse(m.Groups[1].Value + " " + m.Groups[2].Value); clsVideoEntry old_entry = _GetEntryByIdFromList(init, new_e.VideoID); if ( old_entry == null) init.Add(new_e); else { List<clsDataPoint> new_dps = _compare_entities(new_e, old_entry); if (new_e.Time < old_entry.Time) old_entry = new_e; foreach (clsDataPoint dp in new_dps) { if (!hist.ContainsKey(new_e.VideoID)) hist.Add(new_e.VideoID, new List<clsDataPoint>()); hist[new_e.VideoID].Add(dp); } } } r = new Regex("upd : d{(.*)},t{(.*)},vId{(.*),(.*)},old{(.*)},new{(.*)}"); matches = r.Matches(log); foreach (Match m in matches) { string v = m.Groups[3].Value; string f = m.Groups[4].Value; double Iv = double.Parse(m.Groups[5].Value); double Nv = double.Parse(m.Groups[6].Value); if (!hist.ContainsKey(v)) hist.Add(v, new List<clsDataPoint>()); clsDataPointField field = new clsDataPointField(); switch (f) { case "VIEWS": field.Field = clsDataPointField.VideoDataFields.VIEWS; break; case "RATERS": field.Field = clsDataPointField.VideoDataFields.RATERS; break; case "AVERAGE_RATING": field.Field = clsDataPointField.VideoDataFields.AVERAGE_RATING; break; case "COMMENT_COUNT": field.Field = clsDataPointField.VideoDataFields.COMMENT_COUNT; break; case "FAVORITED_COUNT": field.Field = clsDataPointField.VideoDataFields.FAVORITED_COUNT; break; } clsDataPoint new_dp = new clsDataPoint(Iv, Nv, field, v); new_dp.Time = DateTime.Parse(m.Groups[1].Value + " " + m.Groups[2].Value); hist[v].Add(new_dp); } _initial_dataset = init; _historical_data = hist; _sort_historical_data(); }