Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
		private bool SendTest (string fname, bool isJSON = true)
		{
			bool res = false;
			
			SendRequest send = new SendRequest (fname, isJSON);
			Task.Run (async () => {
				res = await send.Execute ();
			}).Wait ();
			
			return res;
		}