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 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); } }
public static void Enqueue(string Action, string Result, string Project, DateTime Timestamp, float Duration) { TelemetryWriter Writer = Instance; if (Writer != null) { TelemetryTimingData Telemetry = new TelemetryTimingData(); Telemetry.Action = Action; Telemetry.Result = Result; Telemetry.UserName = Environment.UserName; Telemetry.Project = Project; Telemetry.Timestamp = Timestamp; Telemetry.Duration = Duration; Writer.QueuedTimingData.Enqueue(Telemetry); Writer.RefreshEvent.Set(); } }
public static void Enqueue(string Action, string Result, string Project, DateTime Timestamp, float Duration) { TelemetryWriter Writer = Instance; if(Writer != null) { TelemetryTimingData Telemetry = new TelemetryTimingData(); Telemetry.Action = Action; Telemetry.Result = Result; Telemetry.UserName = Environment.UserName; Telemetry.Project = Project; Telemetry.Timestamp = Timestamp; Telemetry.Duration = Duration; Writer.QueuedTimingData.Enqueue(Telemetry); Writer.RefreshEvent.Set(); } }
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; } }