AppMetrics.LogEvent.ProcessRequest C# (CSharp) Method

ProcessRequest() public method

public ProcessRequest ( HttpContext context ) : void
context System.Web.HttpContext
return void
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                var request = context.Request;

                var applicationKey = request.Params["MessageAppKey"];
                if (string.IsNullOrEmpty(applicationKey))
                    throw new ApplicationException("No application key\r\n" + Uri.UnescapeDataString(request.Params.ToString()));

                var accessKey = request.Params["AccessKey"];
                if (string.IsNullOrEmpty(accessKey))
                {
                    var appKeyParts = applicationKey.Split('|');
                    if (appKeyParts.Length == 2)
                    {
                        applicationKey = appKeyParts[0];
                        accessKey = appKeyParts[1];
                    }
                }

                if (string.IsNullOrWhiteSpace(accessKey))
                    ReportLog("No access key\r\n" + Uri.UnescapeDataString(request.Params.ToString()));
                AccessKeys.VerifyAccess(accessKey);

                // NOTE that client side has to escape data if it contains the same char that is used as line separator char
                var tmp = request.Params["LineSeparator"];
                if (string.IsNullOrEmpty(tmp))
                    tmp = "\t";
                if (tmp.Length > 1)
                    throw new ApplicationException("Invalid line separator");
                var separator = tmp[0];

                var messages = request.Params["MessagesList"];
                if (!string.IsNullOrEmpty(messages))
                {
                    var sessionId = request.Params["MessageSession"];
                    if (string.IsNullOrEmpty(sessionId))
                        ProcessMessages(request, applicationKey, messages, separator);
                    else
                        ProcessMessages(request, applicationKey, sessionId, messages, separator);
                }
                else
                    ProcessMessage(context, applicationKey);
            }
            catch (ApplicationException exc)
            {
                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                ReportLog(exc.Message);
            }
            catch (Exception exc)
            {
                context.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
                ReportLog(exc);
            }
        }