public void Store(IActivityEvent activityEvent) { File.AppendAllLines(_fileFullPath, new List <string> { JsonConvert.SerializeObject(ActivitySerializer.Serialize(activityEvent)) }); }
private static EventPostRequest GetEventPostWebRequest(IActivityEvent log, string authToken) { var request = new EventPostRequest { AuthToken = authToken, }; switch (log.EventType) { case EventType.AskForHelpEvent: request.AskHelpEvent = (AskForHelpEvent)log; break; case EventType.BuildEvent: request.BuildEvent = (BuildEvent)log; break; case EventType.CutCopyPasteEvent: request.CutCopyPasteEvent = (CutCopyPasteEvent)log; break; case EventType.DebugEvent: request.DebugEvent = (DebugEvent)log; break; case EventType.EditorActivityEvent: request.EditorActivityEvent = (EditorActivityEvent)log; break; case EventType.ExceptionEvent: request.ExceptionEvent = (ExceptionEvent)log; break; case EventType.FeedPostEvent: request.FeedPostEvent = (FeedPostEvent)log; break; case EventType.LogCommentEvent: request.LogCommentEvent = (LogCommentEvent)log; break; case EventType.HelpfulMarkGivenEvent: request.HelpfulMarkEvent = (HelpfulMarkGivenEvent)log; break; case EventType.SaveEvent: request.SaveEvent = (SaveEvent)log; break; case EventType.SubmitEvent: request.SubmitEvent = (SubmitEvent)log; break; } return(request); }
public static int SaveEvent(IActivityEvent activityEvent) { try { //execute sql batch insert statements using (var connection = new SqlConnection(StringConstants.ConnectionString)) { using (var cmd = activityEvent.GetInsertCommand()) { cmd.Connection = connection; connection.Open(); var logId = Convert.ToInt32(cmd.ExecuteScalar()); connection.Close(); return(logId); } } } catch (Exception) { return(-1); } }
public async Task AddActivityEventAsync(IActivityEvent activityEvent) { if (activityEvent is null) { return; } else { this._ActivityEvents.Mutate1 <IActivityEvent>( activityEvent, (newItem, activityEvents) => { newItem.SequenceNo = activityEvents.Count + 1; return(activityEvents.Add(newItem)); }); await this._MediatorScopeService.Storage.AddActivityEventAsync(activityEvent); if (activityEvent is IActivityEventChangeStatus activityEventChangeStatus) { this.Status = activityEventChangeStatus.Status; } } }
public void Store(IActivityEvent activityEvent) { }
private static List <LogCommentEvent> ComposeComments(IActivityEvent subjectEvent, IList <ActivityEvent> eventLogs, IList <UserProfile> users, IEnumerable <LogCommentEvent> logComments, IList <HelpfulMarkGivenEvent> helpMarks, Dictionary <int, IUser> userDictionary) { var comments = logComments.Where(y => y.SourceEventLogId == subjectEvent.EventLogId).ToList(); foreach (var c in comments) { //not the best way to do this... //TODO: modify the stored procedure to get the proper/updated data instead of this... //we need to get more information from the event logs table and the stored procedure does not yet get this try { using (var sqlConnection = new SqlConnection(StringConstants.ConnectionString)) { sqlConnection.Open(); string query = "SELECT * FROM EventLogs WHERE Id = @EventLogId "; var result = sqlConnection.Query(query, new { EventLogId = c.EventLogId }).SingleOrDefault(); if (result != null) { c.IsAnonymous = result.IsAnonymous ?? false; } sqlConnection.Close(); } } catch (Exception) { //ignore for now } if (c.IsAnonymous) { // fill up each comment event properties not returned by query c.Sender = new UserProfile { ID = 0, FirstName = "Anonymous ", LastName = c.EventId.ToString(), }; c.SourceEvent = subjectEvent; c.NumberHelpfulMarks = helpMarks.Count(y => y.LogCommentEventId == c.EventId); // inflate the comment helpful marks for detail views var commentMarks = helpMarks.Where(y => y.LogCommentEventId == c.EventId).ToList(); foreach (var h in commentMarks) { var helpMarkEventLog = eventLogs.Single(z => z.EventLogId == h.EventLogId); h.Sender = GetUser(userDictionary, users, helpMarkEventLog.SenderId); h.LogComment = c; } } else { // fill up each comment event properties not returned by query c.Sender = GetUser(userDictionary, users, c.SenderId); c.SourceEvent = subjectEvent; c.NumberHelpfulMarks = helpMarks.Count(y => y.LogCommentEventId == c.EventId); // inflate the comment helpful marks for detail views var commentMarks = helpMarks.Where(y => y.LogCommentEventId == c.EventId).ToList(); foreach (var h in commentMarks) { var helpMarkEventLog = eventLogs.Single(z => z.EventLogId == h.EventLogId); h.Sender = GetUser(userDictionary, users, helpMarkEventLog.SenderId); h.LogComment = c; } } } return(comments); }
private static IEnumerable <FeedItem> NormalizeDataObjects(IList <ActivityEvent> eventLogs, IList <UserProfile> users, IList <AskForHelpEvent> askHelps, IList <BuildEvent> builds, IList <ExceptionEvent> exceptions, IList <FeedPostEvent> feedPosts, IList <LogCommentEvent> logComments, IList <HelpfulMarkGivenEvent> helpMarks, IList <SubmitEvent> submits, IList <CutCopyPasteEvent> cutCopyPastes, IList <DebugEvent> debugs, IList <EditorActivityEvent> editorActivities, IList <SaveEvent> saves) { var feedItems = new List <FeedItem>(); var userDictionary = new Dictionary <int, IUser>(); try { IActivityEvent xActivityEvent = null; foreach (var x in eventLogs) { #region compose the event log's activity event switch (x.EventType) { case EventType.AskForHelpEvent: xActivityEvent = ComposeAskForHelpEvent(x, userDictionary, users, askHelps); break; case EventType.BuildEvent: xActivityEvent = ComposeBuildEvent(x, userDictionary, users, builds); break; case EventType.ExceptionEvent: xActivityEvent = ComposeExceptionEvent(x, userDictionary, users, exceptions); break; case EventType.HelpfulMarkGivenEvent: xActivityEvent = ComposeHelpfulMarkGivenEvent(x, userDictionary, users, helpMarks); break; case EventType.FeedPostEvent: xActivityEvent = ComposeFeedPostEvent(x, userDictionary, users, feedPosts); break; case EventType.SubmitEvent: xActivityEvent = ComposeSubmitEvent(x, userDictionary, users, submits); break; case EventType.SaveEvent: xActivityEvent = ComposeSaveEvent(x, userDictionary, users, saves); break; case EventType.EditorActivityEvent: xActivityEvent = ComposeEditorActivityEvent(x, userDictionary, users, editorActivities); break; case EventType.DebugEvent: xActivityEvent = ComposeDebugEvent(x, userDictionary, users, debugs); break; case EventType.CutCopyPasteEvent: xActivityEvent = ComposeCutCopyPasteEvent(x, userDictionary, users, cutCopyPastes); break; } #endregion if (xActivityEvent == null) { continue; } FeedItem f = new FeedItem() { Event = xActivityEvent, Comments = ComposeComments(xActivityEvent, eventLogs, users, logComments, helpMarks, userDictionary) }; if (!feedItems.Contains(f)) { feedItems.Add(f); } xActivityEvent = null; } } catch (Exception) { // ignore } return(feedItems); }
public static ActivityDto Serialize(IActivityEvent activityEvent) { return(new ActivityDto(activityEvent.GetType().AssemblyQualifiedName, activityEvent.Timestamp.Date, activityEvent.Timestamp.TimeOfDay)); }
public Task AddActivityEventAsync(IActivityEvent activityEvent) { return(Task.CompletedTask); }
public void Store(IActivityEvent activityEvent) { _log.Debug($"Event {activityEvent.GetType().Name} : {activityEvent.Timestamp} stored."); }
// It is easier to see the JSON via TraceViewer. // It may be harder to parse JSON and post-process it via Cosmos. If that is the case, // then we may need another sink (observer) that dumps key/value formats for Cosmos to process // Anyway, additional observers are required if we do the following // a. pipe all activities from customer clusters to SFRP // b. pipe to MDM or operationalinsights. public static void Log(this IActivityEvent activityEvent, TraceType traceType) { activityEvent.Validate("activityEvent"); traceType.WriteInfo("{0}", activityEvent.ToJson()); }
public void Store(IActivityEvent activityEvent) { _events.AddLast(activityEvent); }
private async void SendLogToServer(IActivityEvent data) { SendStatus.IsActive = true; List <IActivityEvent> logsToBeSaved; string webServiceKey; //request exclusive access to our cache of existing logs lock (_cache) { //get pending records logsToBeSaved = GetLogsFromCache(); //add new log to list logsToBeSaved.Add(data); //clear out cache SaveLogsToCache(new List <IActivityEvent>()); webServiceKey = (string)_cache[StringConstants.AuthenticationCacheKey]; } //send logs to the server for (var idx = 0; idx < logsToBeSaved.Count; idx++) { var log = logsToBeSaved[idx]; //reset the log's sending user just to be safe _logger.WriteToLog(string.Format("Sending {0}th of {1} log(s) to the server", idx + 1, logsToBeSaved.Count), LogPriority.LowPriority); SendStatus.CurrentTransmission = log; //update send status with the number of logs that need to submit SendStatus.NumberOfTransmissions = logsToBeSaved.Count; try { //compose web request and send to the server var eventPostRequest = GetEventPostWebRequest(log, webServiceKey); var task = AsyncServiceClient.SubmitLog(eventPostRequest); var result = await task; //log status _logger.WriteToLog(string.Format("The return code of the batch is {0}", result), LogPriority.LowPriority); log.EventLogId = result; //update batch status SendStatus.LastTransmissionTime = DateTime.UtcNow; SendStatus.LastTransmission = log; SendStatus.CompletedTransmissions++; } catch (Exception ex) { SendError(ex); break; } } lock (_cache) { SaveLogsToCache(logsToBeSaved.Where(x => !(x.EventLogId > 0)).ToList()); } SendStatus.IsActive = false; }
public static IActivityEvent FromCommand(string commandName, DTE2 dte) { IActivityEvent oEvent = null; //debugging events if (DebugCommands.Contains(commandName)) { var action = (DebugActions)Enum.Parse(typeof(DebugActions), commandName.Split('.')[1]); var debug = new DebugEvent { SolutionName = dte.Solution.FullName, }; //sometimes document name can be null try { debug.DocumentName = dte.ActiveDocument.Name; } catch (Exception) { debug.DocumentName = dte.Solution.FullName; } //add line number if applicable if (action == DebugActions.StepInto || action == DebugActions.StepOut || action == DebugActions.StepOver ) { //line number can be null if there is no document open try { TextSelection debugSelection = dte.ActiveDocument.Selection; debugSelection.SelectLine(); var lineNumber = debugSelection.CurrentLine; debug.LineNumber = lineNumber; debug.DebugOutput = debugSelection.Text; } catch (Exception) { debug.LineNumber = 0; } } //kind of reappropriating this for our current use. Consider refactoring. debug.ExecutionAction = (int)action; //throw the content of the output window into the event if we just stopped debugging if (action == DebugActions.StopDebugging) { var debugWindow = dte.ToolWindows.OutputWindow.OutputWindowPanes.Item("Debug"); if (debugWindow != null) { var text = debugWindow.TextDocument; var selection = text.Selection; selection.StartOfDocument(); selection.EndOfDocument(true); debug.DebugOutput = selection.Text; selection.EndOfDocument(); } } oEvent = debug; } else if (CutCopyPasteCommands.Contains(commandName)) { var ccp = new CutCopyPasteEvent { SolutionName = dte.Solution.FullName, EventActionId = (int)Enum.Parse(typeof(CutCopyPasteActions), commandName.Split('.')[1]), Content = Clipboard.GetText() }; //sometimes document name can be null try { ccp.DocumentName = dte.ActiveDocument.Name; } catch (Exception) { ccp.DocumentName = dte.Solution.FullName; } oEvent = ccp; } return(oEvent); }
public void SubmitEvent(IActivityEvent evt) { SubmitEventRequested(this, new SubmitEventArgs(evt)); }
public SubmitEventArgs(IActivityEvent evt) { Event = evt; }
public EventCreatedArgs(IActivityEvent osbideEvent) { OsbideEvent = osbideEvent; }