protected void PreProcessReport(TelemetryReport report, bool omitGlobals) { if (TelemetrySessionID != null) { report.LogDataPoint("TelemetrySessionID", TelemetrySessionID); } if (!omitGlobals) { foreach (KeyValuePair <string, object> item in GlobalDataPoints) { report.LogDataPoint(item.Key, item.Value); } } }
/// <summary> /// Creates a new <see cref="TelemetryReport"/> from available data points. /// </summary> /// <param name="dataPoints">Set of data points used to initialize the report.</param> /// <returns>TelemetryReport.</returns> public static TelemetryReport CreateReportFromDataPoints(Dictionary <string, object> dataPoints) { TelemetryReport report = new TelemetryReport(); report._parameters = dataPoints; if (dataPoints.ContainsKey("ActivityTime")) { report._activityTime = DateTime.Parse(dataPoints["ActivityTime"].ToString()); } if (dataPoints.ContainsKey("StatusCode")) { report._statusCode = Int32.Parse(dataPoints["StatusCode"].ToString()); } if (dataPoints.ContainsKey("ErrorCode")) { report._errorCode = Int32.Parse(dataPoints["ErrorCode"].ToString()); } return(report); }
/// <summary> /// Appends global data points to report and then saves the report to the specified <see cref="TempStorageProvider"/>. /// </summary> /// <param name="report">Report to be added to the Temporary Storage Provider.</param> /// <param name="tempProvider">Temporary Report Storage Provider</param> /// <param name="omitGlobals">Should Global Data Points be ommitted for saved reports? Defaults to false.</param> public Task SaveToTempStorageAsync(TelemetryReport report, TempStorageProvider tempProvider, bool omitGlobals = false) { PreProcessReport(report, omitGlobals); return(tempProvider.WriteDataAsync(report)); }
/// <summary> /// Adds a report to the client's Active Reports. This allows for batching of multiple reports in a call context to be uploaded simultaneously. /// </summary> /// <param name="report">Report to be added to the Active Reports cache.</param> public void AddActiveReport(TelemetryReport report) { ActiveReports.Add(report); }
/// <summary> /// Immediately uploads a report to the target <see cref="ReportStorageProvider" />. /// </summary> /// <param name="report">Report to be uploaded</param> /// <param name="provider">Non-Temporary Report Storage Provider</param> /// <param name="omitGlobals">Should Global Data Points be ommitted for saved reports? Defaults to false.</param> public Task UploadAsync(TelemetryReport report, ReportStorageProvider provider, bool omitGlobals = false) { PreProcessReport(report, omitGlobals); return(provider.SaveToStorageAsync(report)); }