Optimization

This commit is contained in:
pavelbannov 2019-08-28 12:15:33 +03:00
parent d3676064cb
commit fa6e8ab647
3 changed files with 34 additions and 25 deletions

View File

@ -54,35 +54,42 @@ namespace System.Web
public static Uri GetUrlRewriter(IHeaderDictionary headers, HttpRequest request)
{
if (request.Query != null && request.Query.Count > 0)
{
var rewriterUri = ParseRewriterUrl(request.Query[UrlRewriterHeader]);
if (rewriterUri != null)
if (headers != null)
{
var h = headers[UrlRewriterHeader];
var rewriterUri = !string.IsNullOrEmpty(h) ? ParseRewriterUrl(h) : null;
if (request != null && rewriterUri != null)
{
var result = new UriBuilder(request.GetDisplayUrl())
var result = new UriBuilder()
{
Scheme = rewriterUri.Scheme,
Host = rewriterUri.Host,
Port = rewriterUri.Port
};
};
result.Query = request.QueryString.Value;
result.Path = request.Path.Value;
return result.Uri;
}
}
}
if (request != null && request.Query != null)
{
var h = request.Query[UrlRewriterHeader];
var rewriterUri = !string.IsNullOrEmpty(h) ? ParseRewriterUrl(h) : null;
if (rewriterUri != null)
{
var result = new UriBuilder()
{
Scheme = rewriterUri.Scheme,
Host = rewriterUri.Host,
Port = rewriterUri.Port
};
result.Query = request.QueryString.Value;
result.Path = request.Path.Value;
if (headers != null && !string.IsNullOrEmpty(headers[UrlRewriterHeader]))
{
var rewriterUri = ParseRewriterUrl(headers[UrlRewriterHeader]);
if (rewriterUri != null)
{
var result = new UriBuilder(request.GetDisplayUrl())
{
Scheme = rewriterUri.Scheme,
Host = rewriterUri.Host,
Port = rewriterUri.Port
};
return result.Uri;
}
}
}
return request.Url();
}

View File

@ -67,7 +67,8 @@ namespace ASC.Common.Utils
OlsonTimeZoneId = olsonTimeZone,
WindowsTimeZoneId = row.Attribute("other").Value,
Territory = row.Attribute("territory").Value
};
};
_mapZones = _mapZones.ToList();
}
catch (Exception error)
{

View File

@ -97,7 +97,7 @@ namespace ASC.Web.Core.Users
public class UserPhotoManager
{
private static readonly ConcurrentDictionary<Guid, IDictionary<CacheSize, string>> Photofiles = new ConcurrentDictionary<Guid, IDictionary<CacheSize, string>>();
private static readonly ConcurrentDictionary<CacheSize, ConcurrentDictionary<Guid, string>> Photofiles = new ConcurrentDictionary<CacheSize, ConcurrentDictionary<Guid, string>>();
private static readonly ICacheNotify<UserPhotoManagerCacheItem> CacheNotify;
static UserPhotoManager()
@ -109,7 +109,7 @@ namespace ASC.Web.Core.Users
CacheNotify.Subscribe((data) =>
{
var userId = new Guid(data.UserID.ToByteArray());
Photofiles.GetOrAdd(userId, (r) => new ConcurrentDictionary<CacheSize, string>())[data.Size] = data.FileName;
Photofiles.GetOrAdd(data.Size, (r) => new ConcurrentDictionary<Guid, string>())[userId] = data.FileName;
}, CacheNotifyAction.InsertOrUpdate);
CacheNotify.Subscribe((data) =>
@ -119,7 +119,8 @@ namespace ASC.Web.Core.Users
try
{
Photofiles.TryRemove(userId, out _);
Photofiles.TryGetValue(CacheSize.Big, out var dict);
dict?.TryRemove(userId, out _);
//var storage = GetDataStore();
//storage.DeleteFiles("", data.UserID + "*.*", false);
//SetCacheLoadedForTenant(false);
@ -370,11 +371,11 @@ namespace ASC.Web.Core.Users
isDef = false;
string fileName = null;
Photofiles.TryGetValue(userId, out var photo);
Photofiles.TryGetValue(ToCache(size), out var photo);
if (size != Size.Empty)
{
photo?.TryGetValue(ToCache(size), out fileName);
photo?.TryGetValue(userId, out fileName);
}
else
{