public async Task <WebsiteVisit> MakeAsync()
        {
            var entity = new WebsiteVisit {
                AbseloutUrl = AppHttpContext.AbsoluteUrl,
                CreateDate  = _dateService.UtcNow(),
                IP          = AppHttpContext.IpAddress,
                OsPlatform  = AppHttpContext.OsPlatform,
                UserAgent   = AppHttpContext.UserAgent,
                UrlReferrer = AppHttpContext.UrlReferer,
                SessionId   = AppHttpContext.SessionId,
                WebsiteId   = _websiteInfo.Id
            };

            return(await Task.FromResult(entity));
        }
Beispiel #2
0
        public void StartOperation(string CurrentClientIP)
        {
            NetworkOperation objNetworkOperation = new NetworkOperation();
            //string CurrentClientIP = ClientIPaddress();
            IpInformation IpInfo = GetLocationIPINFO(CurrentClientIP);

            var _objEntityWebsiteVisit = new RepositoryPattern <WebsiteVisit>(new ApplicationDbContext());

            var newItem = new WebsiteVisit
            {
                VisitTime  = TimeNow(),
                DateShamsi = DateConvertor.DateToNumber(DateConvertor.TodayDate()),
                DateMiladi = DateConvertor.DateToNumber(DateConvertor.TodayDateMiladi()),
                Browser    = objNetworkOperation.ClientBrowser(),
                DeviceInfo = objNetworkOperation.ClientDeviceType(),
                IP_Address = CurrentClientIP,
                HostName   = objNetworkOperation.ClientHostName(),
                country    = IpInfo.country,
                //asn = IpInfo.@as,
                city        = IpInfo.city,
                countryCode = IpInfo.countryCode,
                isp         = IpInfo.isp,
                lat         = IpInfo.lat,
                lon         = (IpInfo.lon),
                org         = IpInfo.org,
                query       = IpInfo.query,
                region      = IpInfo.region,
                regionName  = IpInfo.regionName,
                status      = IpInfo.status,
                timezone    = IpInfo.timezone,
                zip         = IpInfo.zip,
                district    = IpInfo.district,
                mobile      = IpInfo.mobile, // == true? "1" : "0",
                proxy       = IpInfo.proxy,  // == true ? "1" : "0"
                reverse     = IpInfo.reverse
            };


            _objEntityWebsiteVisit.Insert(newItem);
            _objEntityWebsiteVisit.Save();

            try
            {
                var strSubject = " بازديد از وبسايت " + newItem.DateShamsi + " " + newItem.VisitTime;
                var strMessage =
                    " بازديد وب سايت" +
                    "  <br />  " + " IP Address : " + newItem.IP_Address +
                    "  <br />  " + " مشخصات دستگاه : " + newItem.DeviceInfo +
                    "  <br />  " + " كشور : " + newItem.country +
                    "  <br />  " + " شهر و منطقه : " + newItem.regionName + " - " + newItem.city;

                OpratingClasses.EmailService emailService = new OpratingClasses.EmailService();
                Task.Factory.StartNew(() => emailService.SendMail(strSubject, strMessage));
            }
            catch (Exception)
            {
            }
            var cou = newItem.ID;

            _objEntityWebsiteVisit.Dispose();
        }