/// <summary> /// Method to serialize MonitoringAPICall CSM event to json. /// </summary> private static JsonWriter CreateUDPMessage(MonitoringAPICall monitoringAPICall, JsonWriter jw) { string response = string.Empty; if (!string.IsNullOrEmpty(monitoringAPICall.Api)) { jw.WritePropertyName("Api"); jw.Write(monitoringAPICall.Api); } if (!string.IsNullOrEmpty(monitoringAPICall.Service)) { jw.WritePropertyName("Service"); jw.Write(monitoringAPICall.Service); } if (!string.IsNullOrEmpty(monitoringAPICall.ClientId)) { jw.WritePropertyName("ClientId"); jw.Write(monitoringAPICall.ClientId); } jw.WritePropertyName("Version"); jw.Write(monitoringAPICall.Version); if (!string.IsNullOrEmpty(monitoringAPICall.Type)) { jw.WritePropertyName("Type"); jw.Write(monitoringAPICall.Type); } jw.WritePropertyName("Timestamp"); jw.Write(monitoringAPICall.Timestamp); if (!string.IsNullOrEmpty(monitoringAPICall.Region)) { jw.WritePropertyName("Region"); jw.Write(monitoringAPICall.Region); } if (!string.IsNullOrEmpty(monitoringAPICall.UserAgent)) { jw.WritePropertyName("UserAgent"); jw.Write(monitoringAPICall.UserAgent); } return(jw); }
public static void SerializetoJsonAndPostOverUDP(MonitoringAPICall monitoringAPICall) { string response = string.Empty; var monitoringAPICallAttempt = monitoringAPICall as MonitoringAPICallAttempt; if (monitoringAPICallAttempt != null) { if (CreateUDPMessage(monitoringAPICallAttempt, out response)) { MonitoringListener.Instance.PostMessagesOverUDP(response); } } else { if (CreateUDPMessage((MonitoringAPICallEvent)monitoringAPICall, out response)) { MonitoringListener.Instance.PostMessagesOverUDP(response); } } }
public static Task SerializetoJsonAndPostOverUDPAsync(MonitoringAPICall monitoringAPICall) { var monitoringAPICallAttempt = monitoringAPICall as MonitoringAPICallAttempt; if (monitoringAPICallAttempt != null) { if (CreateUDPMessage(monitoringAPICallAttempt, out string response)) { return(MonitoringListener.Instance.PostMessagesOverUDPAsync(response)); } } else { if (CreateUDPMessage((MonitoringAPICallEvent)monitoringAPICall, out string response)) { return(MonitoringListener.Instance.PostMessagesOverUDPAsync(response)); } } return(Task.FromResult(0)); }