analizators/U2U1009
This commit is contained in:
parent
c85c2e6f26
commit
50c0596eff
@ -112,19 +112,23 @@ namespace ASC.Core.Common.Billing
|
|||||||
Log.Error(ex.Message, ex);
|
Log.Error(ex.Message, ex);
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal Task<IEnumerable<AvangateProduct>> GetProducts()
|
||||||
|
{
|
||||||
|
if (Products != null) return Task.FromResult(Products);
|
||||||
|
return InternalGetProducts();
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<IEnumerable<AvangateProduct>> GetProducts()
|
private async Task<IEnumerable<AvangateProduct>> InternalGetProducts()
|
||||||
{
|
{
|
||||||
if (Products != null) return Products;
|
|
||||||
|
|
||||||
await SemaphoreSlim.WaitAsync();
|
await SemaphoreSlim.WaitAsync();
|
||||||
|
|
||||||
if (Products != null)
|
if (Products != null)
|
||||||
{
|
{
|
||||||
SemaphoreSlim.Release();
|
SemaphoreSlim.Release();
|
||||||
return Products;
|
return Products;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -133,10 +133,16 @@ namespace ASC.Core.Common.EF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public async ValueTask DisposeAsync()
|
|
||||||
{
|
|
||||||
if (Context == null) return;
|
|
||||||
|
|
||||||
|
public ValueTask DisposeAsync()
|
||||||
|
{
|
||||||
|
if (Context == null) return ValueTask.CompletedTask;
|
||||||
|
|
||||||
|
return InternalDisposeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async ValueTask InternalDisposeAsync()
|
||||||
|
{
|
||||||
foreach (var c in Context)
|
foreach (var c in Context)
|
||||||
{
|
{
|
||||||
if (c != null)
|
if (c != null)
|
||||||
|
@ -280,11 +280,15 @@ namespace ASC.Data.Backup.Tasks
|
|||||||
Logger.DebugFormat("complete mysql file {0}", file);
|
Logger.DebugFormat("complete mysql file {0}", file);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task RunMysqlFile(Stream stream, string delimiter = ";")
|
protected Task RunMysqlFile(Stream stream, string delimiter = ";")
|
||||||
{
|
{
|
||||||
|
if (stream == null) return Task.CompletedTask;
|
||||||
|
|
||||||
if (stream == null) return;
|
return InternalRunMysqlFile(stream, delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalRunMysqlFile(Stream stream, string delimiter)
|
||||||
|
{
|
||||||
using var reader = new StreamReader(stream, Encoding.UTF8);
|
using var reader = new StreamReader(stream, Encoding.UTF8);
|
||||||
string commandText;
|
string commandText;
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@ namespace ASC.Data.Storage.DiscStorage
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IServiceProvider ServiceProvider { get; }
|
private IServiceProvider ServiceProvider { get; }
|
||||||
|
|
||||||
public async Task Invoke(HttpContext context)
|
public Task Invoke(HttpContext context)
|
||||||
{
|
{
|
||||||
using var scope = ServiceProvider.CreateScope();
|
using var scope = ServiceProvider.CreateScope();
|
||||||
var scopeClass = scope.ServiceProvider.GetService<StorageHandlerScope>();
|
var scopeClass = scope.ServiceProvider.GetService<StorageHandlerScope>();
|
||||||
var (tenantManager, securityContext, storageFactory, emailValidationKeyProvider) = scopeClass;
|
var (tenantManager, securityContext, storageFactory, emailValidationKeyProvider) = scopeClass;
|
||||||
@ -73,11 +73,11 @@ namespace ASC.Data.Storage.DiscStorage
|
|||||||
if (_checkAuth && !securityContext.IsAuthenticated)
|
if (_checkAuth && !securityContext.IsAuthenticated)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
var storage = storageFactory.GetStorage(tenantManager.GetCurrentTenant().TenantId.ToString(CultureInfo.InvariantCulture), _module);
|
var storage = storageFactory.GetStorage(tenantManager.GetCurrentTenant().TenantId.ToString(CultureInfo.InvariantCulture), _module);
|
||||||
var path = CrossPlatform.PathCombine(_path, GetRouteValue("pathInfo").Replace('/', Path.DirectorySeparatorChar));
|
var path = CrossPlatform.PathCombine(_path, GetRouteValue("pathInfo", context).Replace('/', Path.DirectorySeparatorChar));
|
||||||
var header = context.Request.Query[Constants.QUERY_HEADER].FirstOrDefault() ?? "";
|
var header = context.Request.Query[Constants.QUERY_HEADER].FirstOrDefault() ?? "";
|
||||||
|
|
||||||
var auth = context.Request.Query[Constants.QUERY_AUTH].FirstOrDefault() ?? "";
|
var auth = context.Request.Query[Constants.QUERY_AUTH].FirstOrDefault() ?? "";
|
||||||
@ -92,14 +92,14 @@ namespace ASC.Data.Storage.DiscStorage
|
|||||||
if (validateResult != EmailValidationKeyProvider.ValidationResult.Ok)
|
if (validateResult != EmailValidationKeyProvider.ValidationResult.Ok)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!storage.IsFile(_domain, path))
|
if (!storage.IsFile(_domain, path))
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
var headers = header.Length > 0 ? header.Split('&').Select(HttpUtility.UrlDecode) : new string[] { };
|
var headers = header.Length > 0 ? header.Split('&').Select(HttpUtility.UrlDecode) : new string[] { };
|
||||||
@ -113,9 +113,9 @@ namespace ASC.Data.Storage.DiscStorage
|
|||||||
//context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
//context.Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
||||||
|
|
||||||
context.Response.Redirect(uri.ToString());
|
context.Response.Redirect(uri.ToString());
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
string encoding = null;
|
string encoding = null;
|
||||||
if (storage is DiscDataStore && storage.IsFile(_domain, path + ".gz"))
|
if (storage is DiscDataStore && storage.IsFile(_domain, path + ".gz"))
|
||||||
{
|
{
|
||||||
@ -143,18 +143,23 @@ namespace ASC.Data.Storage.DiscStorage
|
|||||||
if (encoding != null)
|
if (encoding != null)
|
||||||
context.Response.Headers["Content-Encoding"] = encoding;
|
context.Response.Headers["Content-Encoding"] = encoding;
|
||||||
|
|
||||||
|
return InternalInvoke(context, storage, path);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalInvoke(HttpContext context, IDataStore storage, string path)
|
||||||
|
{
|
||||||
using (var stream = storage.GetReadStream(_domain, path))
|
using (var stream = storage.GetReadStream(_domain, path))
|
||||||
{
|
{
|
||||||
await stream.CopyToAsync(context.Response.Body);
|
await stream.CopyToAsync(context.Response.Body);
|
||||||
}
|
}
|
||||||
|
|
||||||
await context.Response.Body.FlushAsync();
|
await context.Response.Body.FlushAsync();
|
||||||
await context.Response.CompleteAsync();
|
await context.Response.CompleteAsync();
|
||||||
|
}
|
||||||
string GetRouteValue(string name)
|
|
||||||
{
|
private string GetRouteValue(string name, HttpContext context)
|
||||||
return (context.GetRouteValue(name) ?? "").ToString();
|
{
|
||||||
}
|
return (context.GetRouteValue(name) ?? "").ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,13 +271,18 @@ namespace ASC.ElasticSearch
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task IndexAsync(List<T> data, bool immediately = true, int retry = 0)
|
public Task IndexAsync(List<T> data, bool immediately = true, int retry = 0)
|
||||||
{
|
{
|
||||||
var t = ServiceProvider.GetService<T>();
|
var t = ServiceProvider.GetService<T>();
|
||||||
if (!Support(t) || !data.Any()) return;
|
if (!Support(t) || !data.Any()) return Task.CompletedTask;
|
||||||
|
|
||||||
|
return InternalIndexAsync(data, immediately, retry);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalIndexAsync(List<T> data, bool immediately, int retry)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await Indexer.IndexAsync(data, immediately).ConfigureAwait(false);
|
await Indexer.IndexAsync(data, immediately).ConfigureAwait(false);
|
||||||
@ -627,9 +632,9 @@ namespace ASC.ElasticSearch
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> CheckStateAsync(bool cacheState = true)
|
public Task<bool> CheckStateAsync(bool cacheState = true)
|
||||||
{
|
{
|
||||||
const string key = "elasticsearch";
|
const string key = "elasticsearch";
|
||||||
|
|
||||||
if (cacheState)
|
if (cacheState)
|
||||||
@ -637,10 +642,15 @@ namespace ASC.ElasticSearch
|
|||||||
var cacheValue = cache.Get<string>(key);
|
var cacheValue = cache.Get<string>(key);
|
||||||
if (!string.IsNullOrEmpty(cacheValue))
|
if (!string.IsNullOrEmpty(cacheValue))
|
||||||
{
|
{
|
||||||
return Convert.ToBoolean(cacheValue);
|
return Task.FromResult(Convert.ToBoolean(cacheValue));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return InternalCheckStateAsync(cacheState, key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<bool> InternalCheckStateAsync(bool cacheState, string key)
|
||||||
|
{
|
||||||
var cacheTime = DateTime.UtcNow.AddMinutes(15);
|
var cacheTime = DateTime.UtcNow.AddMinutes(15);
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -54,7 +54,7 @@ namespace ASC.Web.CRM.HttpHandlers
|
|||||||
|
|
||||||
private readonly RequestDelegate _next;
|
private readonly RequestDelegate _next;
|
||||||
|
|
||||||
public async System.Threading.Tasks.Task Invoke(HttpContext context,
|
public System.Threading.Tasks.Task Invoke(HttpContext context,
|
||||||
SetupInfo setupInfo,
|
SetupInfo setupInfo,
|
||||||
CrmSecurity crmSecurity,
|
CrmSecurity crmSecurity,
|
||||||
FileSizeComment fileSizeComment,
|
FileSizeComment fileSizeComment,
|
||||||
@ -62,8 +62,7 @@ namespace ASC.Web.CRM.HttpHandlers
|
|||||||
MessageTarget messageTarget,
|
MessageTarget messageTarget,
|
||||||
MessageService messageService,
|
MessageService messageService,
|
||||||
DaoFactory daoFactory,
|
DaoFactory daoFactory,
|
||||||
ContactPhotoManager contactPhotoManager)
|
ContactPhotoManager contactPhotoManager){
|
||||||
{
|
|
||||||
|
|
||||||
if (!webItemSecurity.IsAvailableForMe(ProductEntryPoint.ID))
|
if (!webItemSecurity.IsAvailableForMe(ProductEntryPoint.ID))
|
||||||
throw crmSecurity.CreateSecurityException();
|
throw crmSecurity.CreateSecurityException();
|
||||||
@ -82,6 +81,18 @@ namespace ASC.Web.CRM.HttpHandlers
|
|||||||
throw crmSecurity.CreateSecurityException();
|
throw crmSecurity.CreateSecurityException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return InternalInvoke(context, setupInfo, fileSizeComment, messageTarget, messageService, contactPhotoManager, contact, contactId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async System.Threading.Tasks.Task InternalInvoke(HttpContext context,
|
||||||
|
SetupInfo setupInfo,
|
||||||
|
FileSizeComment fileSizeComment,
|
||||||
|
MessageTarget messageTarget,
|
||||||
|
MessageService messageService,
|
||||||
|
ContactPhotoManager contactPhotoManager,
|
||||||
|
Contact contact,
|
||||||
|
int contactId)
|
||||||
|
{
|
||||||
var fileUploadResult = new FileUploadResult();
|
var fileUploadResult = new FileUploadResult();
|
||||||
|
|
||||||
if (context.Request.Form.Files.Count == 0)
|
if (context.Request.Form.Files.Count == 0)
|
||||||
|
@ -50,7 +50,7 @@ namespace ASC.Web.CRM.HttpHandlers
|
|||||||
_next = next;
|
_next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Invoke(HttpContext context,
|
public Task Invoke(HttpContext context,
|
||||||
WebItemSecurity webItemSecurity,
|
WebItemSecurity webItemSecurity,
|
||||||
CrmSecurity crmSecurity,
|
CrmSecurity crmSecurity,
|
||||||
Global global,
|
Global global,
|
||||||
@ -59,6 +59,15 @@ namespace ASC.Web.CRM.HttpHandlers
|
|||||||
if (!webItemSecurity.IsAvailableForMe(ProductEntryPoint.ID))
|
if (!webItemSecurity.IsAvailableForMe(ProductEntryPoint.ID))
|
||||||
throw crmSecurity.CreateSecurityException();
|
throw crmSecurity.CreateSecurityException();
|
||||||
|
|
||||||
|
return InternalInvoke(context, webItemSecurity, crmSecurity, global, importFromCSV);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalInvoke(HttpContext context,
|
||||||
|
WebItemSecurity webItemSecurity,
|
||||||
|
CrmSecurity crmSecurity,
|
||||||
|
Global global,
|
||||||
|
ImportFromCSV importFromCSV)
|
||||||
|
{
|
||||||
var fileUploadResult = new FileUploadResult();
|
var fileUploadResult = new FileUploadResult();
|
||||||
|
|
||||||
if (context.Request.Form.Files.Count == 0)
|
if (context.Request.Form.Files.Count == 0)
|
||||||
|
@ -50,7 +50,7 @@ namespace ASC.Web.CRM.HttpHandlers
|
|||||||
_next = next;
|
_next = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async System.Threading.Tasks.Task Invoke(HttpContext context,
|
public System.Threading.Tasks.Task Invoke(HttpContext context,
|
||||||
CrmSecurity crmSecurity,
|
CrmSecurity crmSecurity,
|
||||||
SetupInfo setupInfo,
|
SetupInfo setupInfo,
|
||||||
FileSizeComment fileSizeComment,
|
FileSizeComment fileSizeComment,
|
||||||
@ -62,6 +62,16 @@ namespace ASC.Web.CRM.HttpHandlers
|
|||||||
if (!crmSecurity.IsAdmin)
|
if (!crmSecurity.IsAdmin)
|
||||||
throw crmSecurity.CreateSecurityException();
|
throw crmSecurity.CreateSecurityException();
|
||||||
|
|
||||||
|
return InternalInvoke(context, crmSecurity, setupInfo, fileSizeComment, contactPhotoManager, organisationLogoManager);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async System.Threading.Tasks.Task InternalInvoke(HttpContext context,
|
||||||
|
CrmSecurity crmSecurity,
|
||||||
|
SetupInfo setupInfo,
|
||||||
|
FileSizeComment fileSizeComment,
|
||||||
|
ContactPhotoManager contactPhotoManager,
|
||||||
|
OrganisationLogoManager organisationLogoManager)
|
||||||
|
{
|
||||||
var fileUploadResult = new FileUploadResult();
|
var fileUploadResult = new FileUploadResult();
|
||||||
|
|
||||||
if (context.Request.Form.Files.Count == 0)
|
if (context.Request.Form.Files.Count == 0)
|
||||||
|
@ -1507,7 +1507,7 @@ namespace ASC.Files.Core.Data
|
|||||||
return dbFile;
|
return dbFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal protected async Task<DbFile> InitDocumentAsync(DbFile dbFile)
|
internal protected Task<DbFile> InitDocumentAsync(DbFile dbFile)
|
||||||
{
|
{
|
||||||
if (!FactoryIndexer.CanIndexByContent(dbFile))
|
if (!FactoryIndexer.CanIndexByContent(dbFile))
|
||||||
{
|
{
|
||||||
@ -1515,9 +1515,14 @@ namespace ASC.Files.Core.Data
|
|||||||
{
|
{
|
||||||
Data = Convert.ToBase64String(Encoding.UTF8.GetBytes(""))
|
Data = Convert.ToBase64String(Encoding.UTF8.GetBytes(""))
|
||||||
};
|
};
|
||||||
return dbFile;
|
return Task.FromResult(dbFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return InernalInitDocumentAsync(dbFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task<DbFile> InernalInitDocumentAsync(DbFile dbFile)
|
||||||
|
{
|
||||||
var file = ServiceProvider.GetService<File<int>>();
|
var file = ServiceProvider.GetService<File<int>>();
|
||||||
file.ID = dbFile.Id;
|
file.ID = dbFile.Id;
|
||||||
file.Title = dbFile.Title;
|
file.Title = dbFile.Title;
|
||||||
|
@ -41,6 +41,7 @@ using ASC.Common.Logging;
|
|||||||
using ASC.Common.Utils;
|
using ASC.Common.Utils;
|
||||||
using ASC.Common.Web;
|
using ASC.Common.Web;
|
||||||
using ASC.Core;
|
using ASC.Core;
|
||||||
|
using ASC.Data.Storage;
|
||||||
using ASC.Files.Core;
|
using ASC.Files.Core;
|
||||||
using ASC.Files.Core.Resources;
|
using ASC.Files.Core.Resources;
|
||||||
using ASC.Files.Core.Security;
|
using ASC.Files.Core.Security;
|
||||||
@ -172,17 +173,22 @@ namespace ASC.Web.Files
|
|||||||
TempStream = tempStream;
|
TempStream = tempStream;
|
||||||
UserManager = userManager;
|
UserManager = userManager;
|
||||||
Logger = optionsMonitor.CurrentValue;
|
Logger = optionsMonitor.CurrentValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Invoke(HttpContext context)
|
public Task Invoke(HttpContext context)
|
||||||
{
|
{
|
||||||
if (TenantExtra.IsNotPaid())
|
if (TenantExtra.IsNotPaid())
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.PaymentRequired;
|
context.Response.StatusCode = (int)HttpStatusCode.PaymentRequired;
|
||||||
//context.Response.StatusDescription = "Payment Required.";
|
//context.Response.StatusDescription = "Payment Required.";
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return InternalInvoke(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalInvoke(HttpContext context)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch ((context.Request.Query[FilesLinkUtility.Action].FirstOrDefault() ?? "").ToLower())
|
switch ((context.Request.Query[FilesLinkUtility.Action].FirstOrDefault() ?? "").ToLower())
|
||||||
@ -228,13 +234,13 @@ namespace ASC.Web.Files
|
|||||||
throw new HttpException((int)HttpStatusCode.InternalServerError, FilesCommonResource.ErrorMassage_BadRequest, e);
|
throw new HttpException((int)HttpStatusCode.InternalServerError, FilesCommonResource.ErrorMassage_BadRequest, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task BulkDownloadFile(HttpContext context)
|
private Task BulkDownloadFile(HttpContext context)
|
||||||
{
|
{
|
||||||
if (!SecurityContext.IsAuthenticated)
|
if (!SecurityContext.IsAuthenticated)
|
||||||
{
|
{
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
var ext = CompressToArchive.GetExt(ServiceProvider, context.Request.Query["ext"]);
|
var ext = CompressToArchive.GetExt(ServiceProvider, context.Request.Query["ext"]);
|
||||||
@ -245,18 +251,22 @@ namespace ASC.Web.Files
|
|||||||
{
|
{
|
||||||
Logger.ErrorFormat("BulkDownload file error. File is not exist on storage. UserId: {0}.", AuthContext.CurrentAccount.ID);
|
Logger.ErrorFormat("BulkDownload file error. File is not exist on storage. UserId: {0}.", AuthContext.CurrentAccount.ID);
|
||||||
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
context.Response.StatusCode = (int)HttpStatusCode.NotFound;
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (store.IsSupportedPreSignedUri)
|
if (store.IsSupportedPreSignedUri)
|
||||||
{
|
{
|
||||||
var url = store.GetPreSignedUri(FileConstant.StorageDomainTmp, path, TimeSpan.FromHours(1), null).ToString();
|
var url = store.GetPreSignedUri(FileConstant.StorageDomainTmp, path, TimeSpan.FromHours(1), null).ToString();
|
||||||
context.Response.Redirect(url);
|
context.Response.Redirect(url);
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Response.Clear();
|
context.Response.Clear();
|
||||||
|
return InternalBulkDownloadFile(context, store, path, ext);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalBulkDownloadFile(HttpContext context, IDataStore store, string path, string ext)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var flushed = false;
|
var flushed = false;
|
||||||
@ -1041,9 +1051,9 @@ namespace ASC.Web.Files
|
|||||||
{
|
{
|
||||||
return file.ID + ":" + file.Version + ":" + file.Title.GetHashCode() + ":" + file.ContentLength;
|
return file.ID + ":" + file.Version + ":" + file.Title.GetHashCode() + ":" + file.ContentLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CreateFile(HttpContext context)
|
private Task CreateFile(HttpContext context)
|
||||||
{
|
{
|
||||||
if (!SecurityContext.IsAuthenticated)
|
if (!SecurityContext.IsAuthenticated)
|
||||||
{
|
{
|
||||||
//var refererURL = context.Request.GetUrlRewriter().AbsoluteUri;
|
//var refererURL = context.Request.GetUrlRewriter().AbsoluteUri;
|
||||||
@ -1051,9 +1061,14 @@ namespace ASC.Web.Files
|
|||||||
//context.Session["refererURL"] = refererURL;
|
//context.Session["refererURL"] = refererURL;
|
||||||
var authUrl = "~/Auth.aspx";
|
var authUrl = "~/Auth.aspx";
|
||||||
context.Response.Redirect(authUrl, true);
|
context.Response.Redirect(authUrl, true);
|
||||||
return;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return InternalCreateFile(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalCreateFile(HttpContext context)
|
||||||
|
{
|
||||||
var folderId = context.Request.Query[FilesLinkUtility.FolderId].FirstOrDefault();
|
var folderId = context.Request.Query[FilesLinkUtility.FolderId].FirstOrDefault();
|
||||||
if (string.IsNullOrEmpty(folderId))
|
if (string.IsNullOrEmpty(folderId))
|
||||||
{
|
{
|
||||||
@ -1070,11 +1085,12 @@ namespace ASC.Web.Files
|
|||||||
await CreateFile(context, folderId);
|
await CreateFile(context, folderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task CreateFile<T>(HttpContext context, T folderId)
|
private Task CreateFile<T>(HttpContext context, T folderId)
|
||||||
{
|
{
|
||||||
var responseMessage = context.Request.Query["response"] == "message";
|
var responseMessage = context.Request.Query["response"] == "message";
|
||||||
|
|
||||||
Folder<T> folder;
|
Folder<T> folder;
|
||||||
|
|
||||||
var folderDao = DaoFactory.GetFolderDao<T>();
|
var folderDao = DaoFactory.GetFolderDao<T>();
|
||||||
@ -1100,28 +1116,40 @@ namespace ASC.Web.Files
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Logger.Error(ex);
|
return InternalWriteError(context, ex, responseMessage);
|
||||||
if (responseMessage)
|
|
||||||
{
|
|
||||||
await context.Response.WriteAsync("error: " + ex.Message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context.Response.Redirect(PathProvider.StartURL + "#error/" + HttpUtility.UrlEncode(ex.Message), true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FileMarker.MarkAsNew(file);
|
FileMarker.MarkAsNew(file);
|
||||||
|
|
||||||
if (responseMessage)
|
if (responseMessage)
|
||||||
{
|
{
|
||||||
await context.Response.WriteAsync("ok: " + string.Format(FilesCommonResource.MessageFileCreated, folder.Title));
|
return InternalWriteOk(context, folder);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Response.Redirect(
|
context.Response.Redirect(
|
||||||
(context.Request.Query["openfolder"].FirstOrDefault() ?? "").Equals("true")
|
(context.Request.Query["openfolder"].FirstOrDefault() ?? "").Equals("true")
|
||||||
? PathProvider.GetFolderUrlById(file.FolderID)
|
? PathProvider.GetFolderUrlById(file.FolderID)
|
||||||
: (FilesLinkUtility.GetFileWebEditorUrl(file.ID) + "#message/" + HttpUtility.UrlEncode(string.Format(FilesCommonResource.MessageFileCreated, folder.Title))));
|
: (FilesLinkUtility.GetFileWebEditorUrl(file.ID) + "#message/" + HttpUtility.UrlEncode(string.Format(FilesCommonResource.MessageFileCreated, folder.Title))));
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalWriteError(HttpContext context, Exception ex, bool responseMessage)
|
||||||
|
{
|
||||||
|
Logger.Error(ex);
|
||||||
|
|
||||||
|
if (responseMessage)
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync("error: " + ex.Message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context.Response.Redirect(PathProvider.StartURL + "#error/" + HttpUtility.UrlEncode(ex.Message), true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalWriteOk<T>(HttpContext context, Folder<T> folder)
|
||||||
|
{
|
||||||
|
await context.Response.WriteAsync("ok: " + string.Format(FilesCommonResource.MessageFileCreated, folder.Title));
|
||||||
}
|
}
|
||||||
|
|
||||||
private File<T> CreateFileFromTemplate<T>(Folder<T> folder, string fileTitle, string docType)
|
private File<T> CreateFileFromTemplate<T>(Folder<T> folder, string fileTitle, string docType)
|
||||||
@ -1264,10 +1292,10 @@ namespace ASC.Web.Files
|
|||||||
{
|
{
|
||||||
await TrackFile(context, q.FirstOrDefault() ?? "");
|
await TrackFile(context, q.FirstOrDefault() ?? "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task TrackFile<T>(HttpContext context, T fileId)
|
private Task TrackFile<T>(HttpContext context, T fileId)
|
||||||
{
|
{
|
||||||
var auth = context.Request.Query[FilesLinkUtility.AuthKey].FirstOrDefault();
|
var auth = context.Request.Query[FilesLinkUtility.AuthKey].FirstOrDefault();
|
||||||
Logger.Debug("DocService track fileid: " + fileId);
|
Logger.Debug("DocService track fileid: " + fileId);
|
||||||
|
|
||||||
@ -1277,8 +1305,13 @@ namespace ASC.Web.Files
|
|||||||
{
|
{
|
||||||
Logger.ErrorFormat("DocService track auth error: {0}, {1}: {2}", validateResult.ToString(), FilesLinkUtility.AuthKey, auth);
|
Logger.ErrorFormat("DocService track auth error: {0}, {1}: {2}", validateResult.ToString(), FilesLinkUtility.AuthKey, auth);
|
||||||
throw new HttpException((int)HttpStatusCode.Forbidden, FilesCommonResource.ErrorMassage_SecurityException);
|
throw new HttpException((int)HttpStatusCode.Forbidden, FilesCommonResource.ErrorMassage_SecurityException);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return InternalTrackFile(context, fileId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InternalTrackFile<T>(HttpContext context, T fileId)
|
||||||
|
{
|
||||||
DocumentServiceTracker.TrackerData fileData;
|
DocumentServiceTracker.TrackerData fileData;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user