mirror of
https://git.teknik.io/Teknikode/Teknik.git
synced 2023-08-02 14:16:22 +02:00
Made tracking a synchronous process
This commit is contained in:
parent
86559669b7
commit
c695051a9b
@ -28,7 +28,7 @@ namespace Teknik.Filters
|
||||
{
|
||||
string userAgent = request.UserAgent;
|
||||
|
||||
string ipAddress = request.ClientIPFromRequest(true);
|
||||
string clientIp = request.ClientIPFromRequest(true);
|
||||
|
||||
string urlReferrer = request.UrlReferrer?.ToString();
|
||||
|
||||
@ -37,15 +37,10 @@ namespace Teknik.Filters
|
||||
url = request.Url.ToString();
|
||||
|
||||
// Fire and forget. Don't need to wait for it.
|
||||
Task.Run(() => AsyncTrackDownload(userAgent, ipAddress, url, urlReferrer));
|
||||
Tracking.TrackDownload(userAgent, clientIp, url, urlReferrer);
|
||||
}
|
||||
|
||||
base.OnActionExecuted(filterContext);
|
||||
}
|
||||
|
||||
private static void AsyncTrackDownload(string userAgent, string clientIp, string url, string urlReferrer)
|
||||
{
|
||||
Tracking.TrackDownload(userAgent, clientIp, url, urlReferrer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ namespace Teknik.Filters
|
||||
{
|
||||
string userAgent = request.UserAgent;
|
||||
|
||||
string ipAddress = request.ClientIPFromRequest(true);
|
||||
string clientIp = request.ClientIPFromRequest(true);
|
||||
|
||||
string urlReferrer = request.UrlReferrer?.ToString();
|
||||
|
||||
@ -36,15 +36,10 @@ namespace Teknik.Filters
|
||||
url = request.Url.ToString();
|
||||
|
||||
// Fire and forget. Don't need to wait for it.
|
||||
Task.Run(() => AsyncTrackLink(userAgent, ipAddress, url, urlReferrer));
|
||||
Tracking.TrackLink(userAgent, clientIp, url, urlReferrer);
|
||||
}
|
||||
|
||||
base.OnActionExecuted(filterContext);
|
||||
}
|
||||
|
||||
private static void AsyncTrackLink(string userAgent, string clientIp, string url, string urlReferrer)
|
||||
{
|
||||
Tracking.TrackLink(userAgent, clientIp, url, urlReferrer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ namespace Teknik.Filters
|
||||
sub = request.Url?.AbsoluteUri.GetSubdomain();
|
||||
}
|
||||
|
||||
string ipAddress = request.ClientIPFromRequest(true);
|
||||
string clientIp = request.ClientIPFromRequest(true);
|
||||
|
||||
string url = string.Empty;
|
||||
if (request.Url != null)
|
||||
@ -54,15 +54,10 @@ namespace Teknik.Filters
|
||||
bool hasJava = request.Browser.JavaApplets;
|
||||
|
||||
// Fire and forget. Don't need to wait for it.
|
||||
Task.Run(() => AsyncTrackPageView(title, sub, ipAddress, url, urlReferrer, userAgent,pixelWidth, pixelHeight, hasCookies, acceptLang, hasJava));
|
||||
Tracking.TrackPageView(title, sub, clientIp, url, urlReferrer, userAgent, pixelWidth, pixelHeight, hasCookies, acceptLang, hasJava);
|
||||
}
|
||||
|
||||
base.OnActionExecuted(filterContext);
|
||||
}
|
||||
|
||||
private static void AsyncTrackPageView(string title, string sub, string clientIp, string url, string urlReferrer, string userAgent, int pixelWidth, int pixelHeight, bool hasCookies, string acceptLang, bool hasJava)
|
||||
{
|
||||
Tracking.TrackPageView(title, sub, clientIp, url, urlReferrer, userAgent, pixelWidth, pixelHeight, hasCookies, acceptLang, hasJava);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,13 +20,6 @@ namespace Teknik.Utilities
|
||||
int bytesToRead = chunkSize;
|
||||
do
|
||||
{
|
||||
// Flush the response
|
||||
if (flush)
|
||||
{
|
||||
//response.OutputStream.Write(buffer, 0, 1);
|
||||
response.Flush();
|
||||
}
|
||||
|
||||
if (chunkSize > bytesRemaining)
|
||||
{
|
||||
bytesToRead = bytesRemaining;
|
||||
@ -37,11 +30,19 @@ namespace Teknik.Utilities
|
||||
{
|
||||
response.OutputStream.Write(buffer, 0, processedBytes);
|
||||
|
||||
// Flush the response
|
||||
if (flush)
|
||||
{
|
||||
response.Flush();
|
||||
}
|
||||
|
||||
// Clear the buffer
|
||||
Array.Clear(buffer, 0, chunkSize);
|
||||
}
|
||||
|
||||
// decrement the total bytes remaining to process
|
||||
bytesRemaining -= processedBytes;
|
||||
}
|
||||
}
|
||||
while (processedBytes > 0 && bytesRemaining > 0);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -51,10 +52,7 @@ namespace Teknik.Utilities
|
||||
finally
|
||||
{
|
||||
// dispose of file stream
|
||||
if (stream != null)
|
||||
{
|
||||
stream.Dispose();
|
||||
}
|
||||
stream?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user