コード例 #1
0
        public void InterviewTrace(Guid uid, string url)
        {
            for (int j = 0; j < 10; j++) //重试10次,找到这个访客
            {
                var view = InterviewBll.GetFirstEntity(i => i.Uid.Equals(uid));
                if (view != null)
                {
                    view.InterviewDetails.Add(new InterviewDetail()
                    {
                        Time = DateTime.Now,
                        Url  = url
                    });
                    if (view.InterviewDetails.Count >= 2)
                    {
                        TimeSpan ts  = DateTime.Now - view.InterviewDetails.FirstOrDefault().Time;
                        string   len = string.Empty;
                        if (ts.Hours > 0)
                        {
                            len += $"{ts.Hours}小时";
                        }

                        if (ts.Minutes > 0)
                        {
                            len += $"{ts.Minutes}分钟";
                        }
                        len                   += $"{ts.Seconds}.{ts.Milliseconds}秒";
                        view.OnlineSpan        = len;
                        view.OnlineSpanSeconds = ts.TotalSeconds;
                    }
                    InterviewBll.UpdateEntitySaved(view);
                    break;
                }
                Thread.Sleep(1000);
            }
        }
コード例 #2
0
        public void FlushUnhandledAddress()
        {
            var list = InterviewBll.LoadEntities(i => string.IsNullOrEmpty(i.Address)).AsEnumerable();

            list.ForEach(i =>
            {
                PhysicsAddress addr = i.IP.GetPhysicsAddressInfo().Result;
                if (addr?.Status == 0)
                {
                    i.Address           = $"{addr.AddressResult.FormattedAddress} {addr.AddressResult.AddressComponent.Direction}{addr.AddressResult.AddressComponent.Distance}米";
                    i.Province          = addr.AddressResult.AddressComponent.Province;
                    IList <string> strs = new List <string>();
                    addr.AddressResult.Pois.ForEach(s => strs.Add($"{s.AddressDetail} {s.Direction}{s.Distance}米"));
                    i.ReferenceAddress = string.Join("|", strs);
                }
                i.ISP = i.IP.GetISP();
                InterviewBll.UpdateEntitySaved(i);
            });
            InterviewBll.DeleteEntitySaved(i => i.IP.Contains(":") || i.IP.Equals("127.0.0.1"));
        }