Exemple #1
0
        protected void Application_BeginRequest(object sender, EventArgs e)
        {

            HttpContext context = HttpContext.Current;
            HttpRequest request = context.Request;
            HttpResponse response = context.Response;


            ELSLogs esLog = new ELSLogs();
            esLog.ElsUser = new ElsUserInfromation();
            esLog.ElsResponse = response.StatusCode;
            esLog.ElsIpaddress = request.UserHostAddress;
            esLog.ElsUser.UserId = "Tz";
            esLog.ElsRequest =
                "[" + DateTime.Now.ToString("dd/MMM/yyyy:HH:mm:ss.FFF zz") + "]" + " \"" + request.HttpMethod + " "
                + request.Path + "\" " + response.StatusCode + " " + request.TotalBytes + " \"" +
                request.UrlReferrer + "\" " + "\"" + request.UserAgent + "\"" + " " + request.Form;

            if (string.IsNullOrEmpty(request.Form.ToString()))
            {
                esLog.ElsRequest += "null";}
            QueryInfo i = new QueryInfo {Type = "logs", Size = 10,SearchText = "Beijing",Start =DateTime.Now.AddDays(-33),End=DateTime.Now};
           

             //Task.Run(() => ss(esLog));
           // sp(i);


            // _logHandler.CallMessageApi(request,response);

            // IRequestHandler ireRequestHandler=new RequestHandler();
            //IRequestHandler ireRequestHandler=new RequestHandler();
            // ireRequestHandler.CallMessageApi(request,response);

        }
Exemple #2
0
        private void sp(QueryInfo i)
        {
            HttpClient httpClient = new HttpClient();
            //string dd = JsonConvert.SerializeObject(esLog);
            string uri = "https://microsoft-apiapp463245e7d2084cb79dbc3d162e7b94cb.azurewebsites.net/query/StringQuery";
            var javaScriptSerializer = new
              System.Web.Script.Serialization.JavaScriptSerializer();
            string jsonString = javaScriptSerializer.Serialize(i);
            //Console.WriteLine(jsonString);
            // httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            // await httpClient.PostAsJsonAsync(uri, jsonString);

             var x =httpClient.PostAsync(uri, new StringContent(jsonString, Encoding.UTF8, "application/json")).Result;
            
            var y = x;
        }