Esempio n. 1
0
        public void FlushInetAddress(Interview interview)
        {
            PhysicsAddress address = interview.IP.GetPhysicsAddressInfo().Result;

            if (address?.Status == 0)
            {
                interview.Address  = $"{address.AddressResult.FormattedAddress} {address.AddressResult.AddressComponent.Direction}{address.AddressResult.AddressComponent.Distance ?? "0"}米";
                interview.Country  = address.AddressResult.AddressComponent.Country;
                interview.Province = address.AddressResult.AddressComponent.Province;
                IList <string> strs = new List <string>();
                address.AddressResult?.Pois?.ForEach(s => strs.Add($"{s.AddressDetail} {s.Direction}{s.Distance ?? "0"}米"));
                if (strs.Any())
                {
                    interview.ReferenceAddress = string.Join("|", strs);
                }
                if ("true" == CommonHelper.GetSettings("EnableDenyArea"))
                {
                    CommonHelper.GetSettings("DenyArea")?.Split(',', ',').ForEach(area =>
                    {
                        if (interview.Address.Contains(area) || (interview.ReferenceAddress != null && interview.ReferenceAddress.Contains(area)))
                        {
                            CommonHelper.DenyAreaIP.AddOrUpdate(area, a => new HashSet <string>
                            {
                                interview.IP
                            }, (s, list) =>
                            {
                                lock (list)
                                {
                                    list.Add(interview.IP);
                                    return(list);
                                }
                            });
                            File.WriteAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "App_Data", "denyareaip.txt"), CommonHelper.DenyAreaIP.ToJsonString());
                        }
                    });
                }
            }
            interview.ISP = interview.IP.GetISP();
            Interview i = InterviewBll.AddEntitySaved(interview);

            CommonHelper.InterviewCount = InterviewBll.GetAll().Count(); //记录访问量
        }
Esempio n. 2
0
        public void FlushInetAddress(Interview interview)
        {
            PhysicsAddress address = interview.IP.GetPhysicsAddressInfo().Result;

            if (address?.Status == 0)
            {
                interview.Address  = $"{address.AddressResult.FormattedAddress} {address.AddressResult.AddressComponent.Direction}{address.AddressResult.AddressComponent.Distance ?? "0"}米";
                interview.Country  = address.AddressResult.AddressComponent.Country;
                interview.Province = address.AddressResult.AddressComponent.Province;
                IList <string> strs = new List <string>();
                address.AddressResult?.Pois?.ForEach(s => strs.Add($"{s.AddressDetail} {s.Direction}{s.Distance ?? "0"}米"));
                if (strs.Any())
                {
                    interview.ReferenceAddress = string.Join("|", strs);
                }
            }
            interview.ISP = interview.IP.GetISP();
            Interview i = InterviewBll.AddEntitySaved(interview);

            CommonHelper.InterviewCount = InterviewBll.GetAll().Count();//记录访问量
        }