示例#1
0
 public async Task <UpdateStatusEnum> UpdateItemAsync(VisitorEntry data)
 {
     if (!Usable)
     {
         return(UpdateStatusEnum.RecordDeleted);
     }
     return(await UpdateItemAsync(data.Key, data));
 }
示例#2
0
 public async Task <UpdateStatusEnum> UpdateItemAsync(int originalKey, VisitorEntry data)
 {
     if (!Usable)
     {
         return(UpdateStatusEnum.RecordDeleted);
     }
     return(await DataProvider.UpdateAsync(originalKey, data.Key, data));
 }
示例#3
0
        private static async Task AddVisitEntryAsync(string url, string error = null)
        {
            if (!InCallback)
            {
                InCallback = true;

                try {
                    if (!YetaWFManager.HaveManager || !YetaWFManager.Manager.HaveCurrentSite || !YetaWFManager.Manager.HaveCurrentContext)
                    {
                        return;
                    }
                    YetaWFManager manager = YetaWFManager.Manager;

                    using (VisitorEntryDataProvider visitorDP = new VisitorEntryDataProvider()) {
                        if (!visitorDP.Usable)
                        {
                            return;
                        }

                        string userAgent;
                        string sessionId = manager.CurrentSessionId;
                        if (url == null)
                        {
                            url = manager.CurrentRequestUrl;
                        }
#if MVC6
                        userAgent = manager.CurrentRequest.Headers["User-Agent"].ToString();
#else
                        userAgent = manager.CurrentRequest.UserAgent;
#endif
                        string referrer = manager.ReferrerUrl;

                        VisitorEntry visitorEntry = new VisitorEntry {
                            SessionId                         = sessionId,
                            AccessDateTime                    = DateTime.UtcNow,
                            UserId                            = manager.UserId,
                            IPAddress                         = manager.UserHostAddress.Truncate(Globals.MaxIP),
                            Url                               = url != null?url.Truncate(Globals.MaxUrl) : "",
                                                     Referrer = referrer != null?referrer.Truncate(Globals.MaxUrl) : "",
                                                                    UserAgent = userAgent != null?userAgent.Truncate(VisitorEntry.MaxUserAgent) : "",
                                                                                    Longitude     = 0.0f,
                                                                                    Latitude      = 0.0f,
                                                                                    ContinentCode = VisitorEntry.Unknown,
                                                                                    CountryCode   = VisitorEntry.Unknown,
                                                                                    RegionCode    = VisitorEntry.Unknown,
                                                                                    City          = VisitorEntry.Unknown,
                                                                                    Error         = error.Truncate(VisitorEntry.MaxError),
                        };
                        await visitorDP.AddItemAsync(visitorEntry);
                    }
                } catch (Exception) {
                } finally {
                    InCallback = false;
                }
            }
        }
示例#4
0
 public async Task <bool> AddItemAsync(VisitorEntry data)
 {
     if (!Usable || SiteIdentity == 0)
     {
         return(false);
     }
     data.Referrer = data.Referrer.Truncate(Globals.MaxUrl);
     data.Url      = data.Url.Truncate(Globals.MaxUrl);
     return(await DataProvider.AddAsync(data));
 }
示例#5
0
 public async Task UpdateSameIPAddressesAsync(VisitorEntry visitorEntry)
 {
     // update all records that have the same IP Address
     await DataProviderIOMode.UpdateSameIPAddressesAsync(visitorEntry);
 }