public override void Write(Datum aggregatedDatum) { if (!App.Available) { return; } if (UseLog) { base.Write(aggregatedDatum); } var node = ReceiverNode; if (node.IsNullOrWhiteSpace()) { return; } string site; if (SiteName.IsNotNullOrWhiteSpace()) { site = SiteName; } else { site = "{0}::{1}@{2}".Args(App.Name, App.InstanceID, System.Environment.MachineName); } try { if (m_Client == null) { m_Client = new TelemetryReceiverClient(ReceiverNode); } m_Client.Send(site, aggregatedDatum); } catch (Exception error) { cleanupClient(); WriteLog(MessageType.Error, error.ToMessageWithType(), from: "{0}.{1}".Args(GetType().Name, "Write(datum)")); } }
private void cleanupClient() { var cl = m_Client; if (cl == null) { return; } try { m_Client = null; cl.Dispose(); } catch (Exception error) { WriteLog(MessageType.Error, error.ToMessageWithType(), from: "{0}.{1}".Args(GetType().Name, "cleanupClient()")); } }
public override void Write(Datum aggregatedDatum) { if (!App.Available) return; if (UseLog) base.Write(aggregatedDatum); var node = ReceiverNode; if (node.IsNullOrWhiteSpace()) return; string site; if (SiteName.IsNotNullOrWhiteSpace()) site = SiteName; else site = "{0}::{1}@{2}".Args(App.Name, App.InstanceID, System.Environment.MachineName); try { if (m_Client==null) m_Client = new TelemetryReceiverClient(ReceiverNode); m_Client.Send(site, aggregatedDatum); } catch(Exception error) { cleanupClient(); WriteLog(MessageType.Error, error.ToMessageWithType(), from: "{0}.{1}".Args(GetType().Name, "Write(datum)") ); } }
private void cleanupClient() { var cl = m_Client; if (cl==null) return; try { m_Client = null; cl.Dispose(); } catch(Exception error) { WriteLog(MessageType.Error, error.ToMessageWithType(), from: "{0}.{1}".Args(GetType().Name, "cleanupClient()") ); } }