public void SendEventNow(AppEnvironment env, string tag, bool reserved = false) { var evtrequest = new BugSenseEventRequest(env, tag, reserved); string contents = evtrequest.getFlatLine(); Task t = new Task(async () => { try { string uuid = env.Uid; string url = WebRequests.GetEventURL(uuid); _lockToSendEvt.WaitOne(); if (!evtrequest.TimeStamp.Equals(_prevEvtTs)) { _prevEvtTs = evtrequest.TimeStamp; _lockToSendEvt.Release(); Helpers.Log("begin(SendEventNow-1)"); LogEvent evt = new LogEvent(contents, reserved); string str = await evt.Execute(); if (!string.IsNullOrEmpty(str)) { SendRequest msg = new SendRequest(url, str, false); _lockToSend.WaitOne(); Helpers.Log("begin(SendEventNow-2)"); bool res = await msg.Execute(); Helpers.Log("end(SendEventNow-2): " + res); _lockToSend.Release(); } Helpers.Log("end(SendEventNow-1)"); } else { Helpers.Log("Duplicate_Event(SendEventNow(" + _prevEvtTs + "))"); _lockToSendEvt.Release(); } } catch (Exception) { Helpers.Log("fail(SendEventNow)"); } }); t.Start(); }
public void CacheEvent(AppEnvironment env, string tag, bool reserved = false) { var evtrequest = new BugSenseEventRequest(env, tag, reserved); string contents = evtrequest.getFlatLine(); Task t = new Task(async () => { try { LogEvent evt = new LogEvent(contents, reserved); _lockToSendEvt.WaitOne(); if (!evtrequest.TimeStamp.Equals(_prevEvtTs)) { _prevEvtTs = evtrequest.TimeStamp; _lockToSendEvt.Release(); Helpers.Log("begin(CacheEvent)"); string res = await evt.Execute(); Helpers.Log("end(CacheEvent): " + res); } else { Helpers.Log("Duplicate_Event(CacheEvent(" + _prevEvtTs + "))"); _lockToSendEvt.Release(); } } catch (Exception) { Helpers.Log("fail(CacheEvent)"); } }); t.Start(); }
private string CacheTestPing (string uuid) { string res = ""; var evtrequest = new BugSenseEventRequest ( BugSenseEnvironment.GetEnvironment ("test", "0.0.0.0", uuid, true), "_ping", true); string contents = evtrequest.getFlatLine (); LogEvent evt = new LogEvent (contents, true); Task.Run (async () => { res = await evt.Execute (); }).Wait (); return res; }