//internal DataTable GetLocation(string varIPAddress)
        //{
        //    WebRequest varWebRequest = WebRequest.Create("http://freegeoip.net/json/" + varIPAddress);
        //    WebProxy px = new WebProxy("http://freegeoip.net/json/" + varIPAddress, true);
        //    varWebRequest.Proxy = px;
        //    varWebRequest.Timeout = 2000;
        //    try
        //    {
        //        WebResponse rep = varWebRequest.GetResponse();
        //        XmlTextReader xtr = new XmlTextReader(rep.GetResponseStream());
        //        DataSet ds = new DataSet();
        //        ds.ReadXml(xtr);
        //        return ds.Tables[0];
        //    }
        //    catch
        //    {
        //        return null;
        //    }
        //}

        internal static FreeGeoIpResponse GetLocation(string ipAddress)
        {
            try
            {
                if (ipAddress.Equals("127.0.0.1"))
                {
                    FreeGeoIpResponse response = new FreeGeoIpResponse();
                    response.ip = ipAddress;
                    return(response);
                }

                //string response = "";
                string url = "http://freegeoip.net/json/" + ipAddress;
                using (var syncClient = new WebClient())
                {
                    var response = syncClient.DownloadString(url);
                    DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(FreeGeoIpResponse));
                    using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(response)))
                    {
                        var locationResponse = (FreeGeoIpResponse)serializer.ReadObject(ms);
                        return(locationResponse);
                    }
                }
            }
            catch (Exception e)
            {
                return(null);
            }

            //return null;
        }
        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            AnalyticsData tableData = new AnalyticsData("1", "1");

            tableData.DiseaseId   = "1";
            tableData.DiseaseName = "Acne";
            //string diseaseId="1";
            if (filterContext.RouteData.Values.ContainsKey("diseaseId"))
            {
                tableData.DiseaseId = (string)filterContext.RouteData.Values["diseaseId"];
            }

            tableData.ProductId   = "1";
            tableData.ProductName = "Abalone";
            if (filterContext.RouteData.Values.ContainsKey("productId"))
            {
                tableData.ProductId = (string)filterContext.RouteData.Values["productId"];
            }

            tableData.AbsoluteUri = filterContext.HttpContext.Request.Url.AbsoluteUri;
            //String time = DateTime.UtcNow.ToString();
            string ipaddress = IPHostGenerator.GetVisitorDetails();

            tableData.IpAddress = "59.94.121.148";
            ipaddress           = "59.94.121.148";
            //string ip = ipaddress.Split(new char[] { ':' })[1];
            FreeGeoIpResponse location = IPHostGenerator.GetLocation(ipaddress);

            tableData.City        = location.city;
            tableData.Country     = location.country_name;
            tableData.CountryCode = location.country_code;
            tableData.State       = location.region_name;
            tableData.StateCode   = location.region_code;
            tableData.Latitude    = location.latitude;
            tableData.Longitute   = location.longitude;
            tableData.Timestamp   = tableData.Date = DateTime.UtcNow;
            tableStorageHelper.AddEntity(tableData);



            //filterContext.HttpContext.Request.Browser.Crawler
            Debug.WriteLine(filterContext.HttpContext.Request.Url.AbsoluteUri);
            Debug.WriteLine("SomeText");
        }