public static void recordEvent(TimelineEvent evt, DateTime startTime) { var _ctx = DbCtx.Get(); var pers = _ctx.Person.FirstOrDefault(p0 => p0.Id == evt.userId); var disc = _ctx.Discussion.FirstOrDefault(d0 => d0.Id == evt.discussionId); if (disc == null) { return; } var topic = _ctx.Topic.FirstOrDefault(t0 => t0.Id == evt.topicId); var s = new StatsEvent(); s.DiscussionId = evt.discussionId; s.DiscussionName = disc.Subject; s.TopicId = evt.topicId; if (topic != null) s.TopicName = topic.Name; else s.TopicName = ""; s.UserId = evt.userId; s.UserName = pers.Name; s.Event = (int) evt.e; s.Time = startTime.Add(evt.Span); s.DeviceType = (int) evt.devType; _ctx.AddToStatsEvent(s); }
private static void AddEventRow(StringBuilder sb, StatsEvent ev) { var eventView = new EventViewModel((StEvent) ev.Event, ev.UserId, ev.Time, (DeviceType)ev.DeviceType); sb.Append(ev.Id); sb.Append(";"); sb.Append(ev.Event); sb.Append(";"); sb.Append("\"" + eventView.evt + "\""); sb.Append(";"); sb.Append(ev.DiscussionId); sb.Append(";"); sb.Append("\"" + ev.DiscussionName + "\""); sb.Append(";"); sb.Append(ev.TopicId); sb.Append(";"); sb.Append("\"" + ev.TopicName + "\""); sb.Append(";"); sb.Append(ev.UserId); sb.Append(";"); sb.Append("\"" + ev.UserName + "\""); sb.Append(";"); sb.Append(ev.Time.ToString("dd.MM.yyyy HH:mm:ss")); sb.Append(";"); sb.Append(ev.DeviceType); sb.Append(";"); sb.AppendLine("\"" + eventView.devType + "\""); }
static bool EventPassesFilter(StatsEvent ev, List<ReportParameters> reportParams) { bool userTest = reportParams.Any(p => p.requiredUsers.Contains(ev.UserId)); if (!userTest) return false; if (ev.TopicId == -1) return true; return reportParams.Any(p => p.topic.Id == ev.TopicId); }
public static bool Log(DiscCtx ctx, StEvent e, int userId, int discussionId, int topicId, DeviceType devType) { var pers = ctx.Person.FirstOrDefault(p0 => p0.Id == userId); if (pers == null && userId != -1) return false; var disc = ctx.Discussion.FirstOrDefault(d0 => d0.Id == discussionId); if (disc == null) return false; var topic = ctx.Topic.FirstOrDefault(t0 => t0.Id == topicId); if (topic == null) return false; if (!topic.Running && e != StEvent.RecordingStarted && e != StEvent.RecordingStopped) { return false; } var s = new StatsEvent { DiscussionId = discussionId, DiscussionName = disc.Subject, TopicId = topicId, TopicName = topic.Name, UserId = userId }; if (pers != null) s.UserName = pers.Name; else s.UserName = "******"; s.Event = (int) e; s.Time = DateTime.Now; s.DeviceType = (int) devType; ctx.AddToStatsEvent(s); ctx.SaveChanges(); return true; }
/// <summary> /// Deprecated Method for adding a new object to the StatsEvent EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToStatsEvent(StatsEvent statsEvent) { base.AddObject("StatsEvent", statsEvent); }
/// <summary> /// Create a new StatsEvent object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="event">Initial value of the Event property.</param> /// <param name="discussionId">Initial value of the DiscussionId property.</param> /// <param name="discussionName">Initial value of the DiscussionName property.</param> /// <param name="topicId">Initial value of the TopicId property.</param> /// <param name="topicName">Initial value of the TopicName property.</param> /// <param name="userId">Initial value of the UserId property.</param> /// <param name="userName">Initial value of the UserName property.</param> /// <param name="time">Initial value of the Time property.</param> /// <param name="deviceType">Initial value of the DeviceType property.</param> public static StatsEvent CreateStatsEvent(global::System.Int32 id, global::System.Int32 @event, global::System.Int32 discussionId, global::System.String discussionName, global::System.Int32 topicId, global::System.String topicName, global::System.Int32 userId, global::System.String userName, global::System.DateTime time, global::System.Int32 deviceType) { StatsEvent statsEvent = new StatsEvent(); statsEvent.Id = id; statsEvent.Event = @event; statsEvent.DiscussionId = discussionId; statsEvent.DiscussionName = discussionName; statsEvent.TopicId = topicId; statsEvent.TopicName = topicName; statsEvent.UserId = userId; statsEvent.UserName = userName; statsEvent.Time = time; statsEvent.DeviceType = deviceType; return statsEvent; }
private TreeViewItem GetEvent(StatsEvent e, DiscCtx ctx) { var res = new TreeViewItem(); var eventView = new EventViewModel((StEvent) e.Event, e.UserId, e.Time, (DeviceType) e.DeviceType); res.Header = eventView.evt; res.Items.Add(GetUser(ctx.Person.FirstOrDefault(p0 => p0.Id == e.UserId))); if (!string.IsNullOrEmpty(e.TopicName)) res.Items.Add(e.TopicName); if (!string.IsNullOrEmpty(e.DiscussionName)) res.Items.Add(e.DiscussionName); res.Items.Add(eventView.dateTime); res.Items.Add(eventView.devType); return res; }