bool SendTimingData(TelemetryTimingData Data, string Version, string IpAddress) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting timing data... ({0}, {1}, {2}, {3}, {4}, {5})", Data.Action, Data.Result, Data.UserName, Data.Project, Data.Timestamp, Data.Duration); using (SqlConnection Connection = new SqlConnection(SqlConnectionString)) { Connection.Open(); using (SqlCommand Command = new SqlCommand("INSERT INTO dbo.[Telemetry.v2] (Action, Result, UserName, Project, Timestamp, Duration, Version, IpAddress) VALUES (@Action, @Result, @UserName, @Project, @Timestamp, @Duration, @Version, @IpAddress)", Connection)) { Command.Parameters.AddWithValue("@Action", Data.Action); Command.Parameters.AddWithValue("@Result", Data.Result); Command.Parameters.AddWithValue("@UserName", Data.UserName); Command.Parameters.AddWithValue("@Project", Data.Project); Command.Parameters.AddWithValue("@Timestamp", Data.Timestamp); Command.Parameters.AddWithValue("@Duration", Data.Duration); Command.Parameters.AddWithValue("@Version", Version); Command.Parameters.AddWithValue("@IPAddress", IpAddress); Command.ExecuteNonQuery(); } } LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
bool SendEventToBackend(EventData Event) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting event... ({0}, {1}, {2})", Event.Change, Event.UserName, Event.Type); using (SqlConnection Connection = new SqlConnection(SqlConnectionString)) { Connection.Open(); using (SqlCommand Command = new SqlCommand("INSERT INTO dbo.UserVotes (Changelist, UserName, Verdict, Project) VALUES (@Changelist, @UserName, @Verdict, @Project)", Connection)) { Command.Parameters.AddWithValue("@Changelist", Event.Change); Command.Parameters.AddWithValue("@UserName", Event.UserName.ToString()); Command.Parameters.AddWithValue("@Verdict", Event.Type.ToString()); Command.Parameters.AddWithValue("@Project", Event.Project); Command.ExecuteNonQuery(); } } LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
bool SendUpdate(IssueUpdateData Update) { try { RESTApi.PUT <IssueUpdateData>(ApiUrl, String.Format("issues/{0}", Update.Id), Update); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); LastStatusMessage = String.Format("Failed to send update: ({0})", Ex.ToString()); return(false); } }
bool SendEventToBackend(EventData Event) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting event... ({0}, {1}, {2})", Event.Change, Event.UserName, Event.Type); RESTApi.POST(ApiUrl, "event", new JavaScriptSerializer().Serialize(Event)); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
bool SendTimingData(TelemetryTimingData Data, string Version, string IpAddress) { try { Stopwatch Timer = Stopwatch.StartNew(); LogWriter.WriteLine("Posting timing data... ({0}, {1}, {2}, {3}, {4}, {5})", Data.Action, Data.Result, Data.UserName, Data.Project, Data.Timestamp, Data.Duration); RESTApi.POST(ApiUrl, "telemetry", new JavaScriptSerializer().Serialize(Data), string.Format("Version={0}", Version), string.Format("IpAddress={0}", IpAddress)); LogWriter.WriteLine("Done in {0}ms.", Timer.ElapsedMilliseconds); return(true); } catch (Exception Ex) { LogWriter.WriteException(Ex, "Failed with exception."); return(false); } }
void PollForUpdates() { while (!bDisposing) { try { PollForUpdatesInner(); } catch (ThreadAbortException) { break; } catch (Exception Ex) { LogWriter.WriteException(Ex, "Unhandled exception in PollForUpdatesInner()"); } } }