Ejemplo n.º 1
0
        public void SendErrorNow(BugSenseExceptionRequest req, bool isFatal,
			bool debugFixResponse = false)
        {
            Task t = new Task(async () =>
                {
                    try
                    {
                        Helpers.Log("begin(SendErrorNow-1)");
                        LogError err = new LogError(req, isFatal);
                        string str = await err.Execute();
                        if (!string.IsNullOrEmpty(str))
                        {
                            try
                            {
                                SendRequest msg = null;
                                if (isFatal)
                                    msg = new SendRequest(str, FixNotificationAndDieAction);
                                else
                                    msg = new SendRequest(str, FixNotificationAction);
                                if (debugFixResponse)
                                    msg.setDebugFixedResponse(true);
                                _lockToSend.WaitOne();
                                Helpers.Log("begin(SendErrorNow-2)");
                                bool res = await msg.Execute();
                                Helpers.Log("end(SendErrorNow-2): " + res);
                                _lockToSend.Release();
                            }
                            catch (Exception)
                            {
                                Helpers.Log("fail(SendErrorNow)");
                            }
                        }
                        Helpers.Log("end(SendErrorNow-1)");
                    }
                    catch (Exception)
                    {
                        Helpers.Log("fail(SendErrorNow)");
                    }
                });
            t.Start();
        }
Ejemplo n.º 2
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.º 3
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;
		}