DocSpace-client/products/ASC.Files/Server/Helpers/Global.cs

599 lines
22 KiB
C#
Raw Normal View History

2020-01-27 11:15:18 +00:00
/*
*
* (c) Copyright Ascensio System Limited 2010-2018
*
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
*
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
*
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
*
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
*
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
* relevant author attributions when distributing the software. If the display of the logo in its graphic
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
* in every copy of the program you distribute.
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
*
*/
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
2020-01-31 07:56:40 +00:00
using ASC.Common;
2020-01-27 11:15:18 +00:00
using ASC.Common.Caching;
using ASC.Common.Logging;
using ASC.Core;
2020-01-31 07:56:40 +00:00
using ASC.Core.Common.Settings;
2020-01-27 11:15:18 +00:00
using ASC.Core.Users;
using ASC.Data.Storage;
using ASC.Files.Core;
2020-02-12 15:21:58 +00:00
using ASC.Files.Core.Data;
2020-01-27 11:15:18 +00:00
using ASC.Files.Core.Security;
2020-02-18 08:39:28 +00:00
using ASC.Files.Resources;
2020-01-27 11:15:18 +00:00
using ASC.Web.Core;
2020-01-31 07:56:40 +00:00
using ASC.Web.Core.Users;
2020-01-27 11:15:18 +00:00
using ASC.Web.Core.WhiteLabel;
using ASC.Web.Files.Utils;
2020-01-31 07:56:40 +00:00
using Microsoft.Extensions.Configuration;
2020-02-10 16:04:54 +00:00
using Microsoft.Extensions.DependencyInjection;
2020-01-31 07:56:40 +00:00
using Microsoft.Extensions.Options;
2020-01-27 11:15:18 +00:00
using Constants = ASC.Core.Configuration.Constants;
using File = ASC.Files.Core.File;
namespace ASC.Web.Files.Classes
{
2020-01-31 13:03:21 +00:00
public class GlobalNotify
2020-01-27 11:15:18 +00:00
{
2020-01-31 07:56:40 +00:00
public ICacheNotify<AscCacheItem> Notify { get; set; }
2020-01-31 13:03:21 +00:00
public ILog Logger { get; set; }
public GlobalNotify(ICacheNotify<AscCacheItem> notify, IOptionsMonitor<ILog> options, CoreBaseSettings coreBaseSettings)
{
Notify = notify;
Logger = options.Get("ASC.Files");
if (coreBaseSettings.Standalone)
{
ClearCache();
}
}
private void ClearCache()
{
try
{
Notify.Subscribe((item) =>
{
try
{
GlobalFolder.ProjectsRootFolderCache.Clear();
GlobalFolder.UserRootFolderCache.Clear();
GlobalFolder.CommonFolderCache.Clear();
GlobalFolder.ShareFolderCache.Clear();
GlobalFolder.TrashFolderCache.Clear();
}
catch (Exception e)
{
Logger.Fatal("ClearCache action", e);
}
}, CacheNotifyAction.Any);
}
catch (Exception e)
{
Logger.Fatal("ClearCache subscribe", e);
}
}
}
public class Global
{
2020-01-31 07:56:40 +00:00
public IConfiguration Configuration { get; }
public AuthContext AuthContext { get; }
public UserManager UserManager { get; }
public CoreSettings CoreSettings { get; }
public DisplayUserSettingsHelper DisplayUserSettingsHelper { get; }
public CustomNamingPeople CustomNamingPeople { get; }
2020-02-12 13:50:38 +00:00
public FileSecurityCommon FileSecurityCommon { get; }
2020-01-31 07:56:40 +00:00
public Global(
IConfiguration configuration,
AuthContext authContext,
UserManager userManager,
CoreSettings coreSettings,
DisplayUserSettingsHelper displayUserSettingsHelper,
2020-02-04 09:08:21 +00:00
CustomNamingPeople customNamingPeople,
2020-02-12 13:50:38 +00:00
FileSecurityCommon fileSecurityCommon)
2020-01-27 11:15:18 +00:00
{
2020-01-31 07:56:40 +00:00
Configuration = configuration;
AuthContext = authContext;
UserManager = userManager;
CoreSettings = coreSettings;
DisplayUserSettingsHelper = displayUserSettingsHelper;
CustomNamingPeople = customNamingPeople;
2020-02-12 13:50:38 +00:00
FileSecurityCommon = fileSecurityCommon;
2020-01-27 11:15:18 +00:00
}
#region Property
public const int MaxTitle = 170;
public static readonly Regex InvalidTitleChars = new Regex("[\t*\\+:\"<>?|\\\\/\\p{Cs}]");
2020-01-31 07:56:40 +00:00
public bool EnableUploadFilter
2020-01-27 11:15:18 +00:00
{
2020-01-31 07:56:40 +00:00
get { return bool.TrueString.Equals(Configuration["files:upload-filter"] ?? "false", StringComparison.InvariantCultureIgnoreCase); }
2020-01-27 11:15:18 +00:00
}
2020-01-31 07:56:40 +00:00
public TimeSpan StreamUrlExpire
2020-01-27 11:15:18 +00:00
{
get
{
2020-01-31 07:56:40 +00:00
int.TryParse(Configuration["files:stream-url-minute"], out var validateTimespan);
2020-01-27 11:15:18 +00:00
if (validateTimespan <= 0) validateTimespan = 16;
return TimeSpan.FromMinutes(validateTimespan);
}
}
2020-01-31 07:56:40 +00:00
public bool IsAdministrator
2020-01-27 11:15:18 +00:00
{
2020-02-12 13:50:38 +00:00
get { return FileSecurityCommon.IsAdministrator(AuthContext.CurrentAccount.ID); }
2020-01-27 11:15:18 +00:00
}
2020-01-31 07:56:40 +00:00
public string GetDocDbKey()
2020-01-27 11:15:18 +00:00
{
const string dbKey = "UniqueDocument";
2020-01-31 07:56:40 +00:00
var resultKey = CoreSettings.GetSetting(dbKey);
2020-01-27 11:15:18 +00:00
2020-01-27 14:58:33 +00:00
if (!string.IsNullOrEmpty(resultKey)) return resultKey;
2020-01-27 11:15:18 +00:00
resultKey = Guid.NewGuid().ToString();
2020-01-31 07:56:40 +00:00
CoreSettings.SaveSetting(dbKey, resultKey);
2020-01-27 11:15:18 +00:00
return resultKey;
}
2020-01-31 13:03:21 +00:00
#endregion
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public static string ReplaceInvalidCharsAndTruncate(string title)
{
if (string.IsNullOrEmpty(title)) return title;
title = title.Trim();
if (MaxTitle < title.Length)
{
var pos = title.LastIndexOf('.');
if (MaxTitle - 20 < pos)
{
title = title.Substring(0, MaxTitle - (title.Length - pos)) + title.Substring(pos);
}
else
{
title = title.Substring(0, MaxTitle);
2020-01-27 11:15:18 +00:00
}
}
2020-01-31 13:03:21 +00:00
return InvalidTitleChars.Replace(title, "_");
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
public string GetUserName(Guid userId, bool alive = false)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
if (userId.Equals(AuthContext.CurrentAccount.ID)) return FilesCommonResource.Author_Me;
if (userId.Equals(Constants.Guest.ID)) return FilesCommonResource.Guest;
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
var userInfo = UserManager.GetUsers(userId);
if (userInfo.Equals(ASC.Core.Users.Constants.LostUser)) return alive ? FilesCommonResource.Guest : CustomNamingPeople.Substitute<FilesCommonResource>("ProfileRemoved");
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
return userInfo.DisplayUserName(false, DisplayUserSettingsHelper);
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
}
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public class GlobalStore
{
public StorageFactory StorageFactory { get; }
public TenantManager TenantManager { get; }
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public GlobalStore(StorageFactory storageFactory, TenantManager tenantManager)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
StorageFactory = storageFactory;
TenantManager = tenantManager;
}
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public IDataStore GetStore(bool currentTenant = true)
{
return StorageFactory.GetStorage(currentTenant ? TenantManager.GetCurrentTenant().TenantId.ToString() : string.Empty, FileConstant.StorageModule);
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
public IDataStore GetStoreTemplate()
{
return StorageFactory.GetStorage(string.Empty, FileConstant.StorageTemplate);
}
}
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public class GlobalSpace
{
2020-02-12 13:50:38 +00:00
public FilesUserSpaceUsage FilesUserSpaceUsage { get; }
2020-01-31 13:03:21 +00:00
public AuthContext AuthContext { get; }
2020-02-12 13:50:38 +00:00
public GlobalSpace(FilesUserSpaceUsage filesUserSpaceUsage, AuthContext authContext)
2020-01-27 11:15:18 +00:00
{
2020-02-12 13:50:38 +00:00
FilesUserSpaceUsage = filesUserSpaceUsage;
2020-01-31 13:03:21 +00:00
AuthContext = authContext;
}
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public long GetUserUsedSpace()
{
return GetUserUsedSpace(AuthContext.CurrentAccount.ID);
}
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public long GetUserUsedSpace(Guid userId)
{
2020-02-12 13:50:38 +00:00
return FilesUserSpaceUsage.GetUserSpaceUsage(userId);
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
}
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public class GlobalFolder
{
public CoreBaseSettings CoreBaseSettings { get; }
public WebItemManager WebItemManager { get; }
public WebItemSecurity WebItemSecurity { get; }
public AuthContext AuthContext { get; }
public TenantManager TenantManager { get; }
public UserManager UserManager { get; }
public SettingsManager SettingsManager { get; }
public GlobalStore GlobalStore { get; }
2020-02-10 16:04:54 +00:00
public IServiceProvider ServiceProvider { get; }
2020-01-31 13:03:21 +00:00
public ILog Logger { get; }
public GlobalFolder(
CoreBaseSettings coreBaseSettings,
WebItemManager webItemManager,
WebItemSecurity webItemSecurity,
AuthContext authContext,
TenantManager tenantManager,
UserManager userManager,
SettingsManager settingsManager,
GlobalStore globalStore,
2020-02-10 16:04:54 +00:00
IOptionsMonitor<ILog> options,
IServiceProvider serviceProvider
2020-01-31 13:03:21 +00:00
)
{
CoreBaseSettings = coreBaseSettings;
WebItemManager = webItemManager;
WebItemSecurity = webItemSecurity;
AuthContext = authContext;
TenantManager = tenantManager;
UserManager = userManager;
SettingsManager = settingsManager;
GlobalStore = globalStore;
2020-02-10 16:04:54 +00:00
ServiceProvider = serviceProvider;
2020-01-31 13:03:21 +00:00
Logger = options.Get("ASC.Files");
}
internal static readonly IDictionary<int, object> ProjectsRootFolderCache =
new ConcurrentDictionary<int, object>(); /*Use SYNCHRONIZED for cross thread blocks*/
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
public object GetFolderProjects(IDaoFactory daoFactory)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
if (CoreBaseSettings.Personal) return null;
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
if (WebItemManager[WebItemManager.ProjectsProductID].IsDisabled(WebItemSecurity, AuthContext)) return null;
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
var folderDao = daoFactory.FolderDao;
if (!ProjectsRootFolderCache.TryGetValue(TenantManager.GetCurrentTenant().TenantId, out var result))
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
result = folderDao.GetFolderIDProjects(true);
ProjectsRootFolderCache[TenantManager.GetCurrentTenant().TenantId] = result;
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
return result;
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
internal static readonly IDictionary<string, object> UserRootFolderCache =
new ConcurrentDictionary<string, object>(); /*Use SYNCHRONIZED for cross thread blocks*/
2020-01-27 11:15:18 +00:00
2020-02-07 10:29:16 +00:00
public object GetFolderMy(FileMarker fileMarker, IDaoFactory daoFactory)
2020-01-31 13:03:21 +00:00
{
if (!AuthContext.IsAuthenticated) return 0;
if (UserManager.GetUsers(AuthContext.CurrentAccount.ID).IsVisitor(UserManager)) return 0;
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
var cacheKey = string.Format("my/{0}/{1}", TenantManager.GetCurrentTenant().TenantId, AuthContext.CurrentAccount.ID);
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
if (!UserRootFolderCache.TryGetValue(cacheKey, out var myFolderId))
{
2020-02-07 10:29:16 +00:00
myFolderId = GetFolderIdAndProccessFirstVisit(fileMarker, daoFactory, true);
2020-01-31 13:03:21 +00:00
if (!Equals(myFolderId, 0))
UserRootFolderCache[cacheKey] = myFolderId;
}
return myFolderId;
}
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
protected internal void SetFolderMy(object value)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
var cacheKey = string.Format("my/{0}/{1}", TenantManager.GetCurrentTenant().TenantId, value);
UserRootFolderCache.Remove(cacheKey);
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
internal static readonly IDictionary<int, object> CommonFolderCache =
new ConcurrentDictionary<int, object>(); /*Use SYNCHRONIZED for cross thread blocks*/
2020-01-27 11:15:18 +00:00
2020-02-07 10:29:16 +00:00
public object GetFolderCommon(FileMarker fileMarker, IDaoFactory daoFactory)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
if (CoreBaseSettings.Personal) return null;
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
if (!CommonFolderCache.TryGetValue(TenantManager.GetCurrentTenant().TenantId, out var commonFolderId))
{
2020-02-07 10:29:16 +00:00
commonFolderId = GetFolderIdAndProccessFirstVisit(fileMarker, daoFactory, false);
2020-01-31 13:03:21 +00:00
if (!Equals(commonFolderId, 0))
CommonFolderCache[TenantManager.GetCurrentTenant().TenantId] = commonFolderId;
}
return commonFolderId;
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
internal static readonly IDictionary<int, object> ShareFolderCache =
new ConcurrentDictionary<int, object>(); /*Use SYNCHRONIZED for cross thread blocks*/
2020-01-27 11:15:18 +00:00
2020-01-31 15:32:27 +00:00
public object GetFolderShare(IFolderDao folderDao)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
if (CoreBaseSettings.Personal) return null;
if (IsOutsider) return null;
if (!ShareFolderCache.TryGetValue(TenantManager.GetCurrentTenant().TenantId, out var sharedFolderId))
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
sharedFolderId = folderDao.GetFolderIDShare(true);
if (!sharedFolderId.Equals(0))
ShareFolderCache[TenantManager.GetCurrentTenant().TenantId] = sharedFolderId;
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
return sharedFolderId;
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
internal static readonly IDictionary<string, object> TrashFolderCache =
new ConcurrentDictionary<string, object>(); /*Use SYNCHRONIZED for cross thread blocks*/
public object GetFolderTrash(IFolderDao folderDao)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
if (IsOutsider) return null;
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
var cacheKey = string.Format("trash/{0}/{1}", TenantManager.GetCurrentTenant().TenantId, AuthContext.CurrentAccount.ID);
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
if (!TrashFolderCache.TryGetValue(cacheKey, out var trashFolderId))
{
trashFolderId = AuthContext.IsAuthenticated ? folderDao.GetFolderIDTrash(true) : 0;
TrashFolderCache[cacheKey] = trashFolderId;
}
return trashFolderId;
2020-01-27 11:15:18 +00:00
}
2020-01-31 13:03:21 +00:00
protected internal void SetFolderTrash(object value)
{
var cacheKey = string.Format("trash/{0}/{1}", TenantManager.GetCurrentTenant().TenantId, value);
TrashFolderCache.Remove(cacheKey);
}
2020-01-27 11:15:18 +00:00
2020-02-07 10:29:16 +00:00
private object GetFolderIdAndProccessFirstVisit(FileMarker fileMarker, IDaoFactory daoFactory, bool my)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
var folderDao = daoFactory.FolderDao;
var fileDao = daoFactory.FileDao;
var id = my ? folderDao.GetFolderIDUser(false) : folderDao.GetFolderIDCommon(false);
if (Equals(id, 0)) //TODO: think about 'null'
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
id = my ? folderDao.GetFolderIDUser(true) : folderDao.GetFolderIDCommon(true);
2020-01-27 11:15:18 +00:00
2020-01-31 13:03:21 +00:00
//Copy start document
if (AdditionalWhiteLabelSettings.Instance(SettingsManager).StartDocsEnabled)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
try
{
var storeTemplate = GlobalStore.GetStoreTemplate();
var culture = my ? UserManager.GetUsers(AuthContext.CurrentAccount.ID).GetCulture() : TenantManager.GetCurrentTenant().GetCulture();
var path = FileConstant.StartDocPath + culture + "/";
if (!storeTemplate.IsDirectory(path))
path = FileConstant.StartDocPath + "default/";
path += my ? "my/" : "corporate/";
2020-01-27 11:15:18 +00:00
2020-02-07 10:29:16 +00:00
SaveStartDocument(fileMarker, folderDao, fileDao, id, path, storeTemplate);
2020-01-31 13:03:21 +00:00
}
catch (Exception ex)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
Logger.Error(ex);
2020-01-27 11:15:18 +00:00
}
}
}
2020-01-31 13:03:21 +00:00
return id;
2020-01-27 11:15:18 +00:00
}
2020-02-07 10:29:16 +00:00
private void SaveStartDocument(FileMarker fileMarker, IFolderDao folderDao, IFileDao fileDao, object folderId, string path, IDataStore storeTemplate)
2020-01-27 11:15:18 +00:00
{
foreach (var file in storeTemplate.ListFilesRelative("", path, "*", false))
{
2020-02-07 10:29:16 +00:00
SaveFile(fileMarker, fileDao, folderId, path + file, storeTemplate);
2020-01-31 07:56:40 +00:00
}
2020-01-27 11:15:18 +00:00
foreach (var folderName in storeTemplate.ListDirectoriesRelative(path, false))
{
2020-02-11 11:51:45 +00:00
var folder = ServiceProvider.GetService<Folder>();
folder.Title = folderName;
folder.ParentFolderID = folderId;
var subFolderId = folderDao.SaveFolder(folder);
2020-01-27 11:15:18 +00:00
2020-02-07 10:29:16 +00:00
SaveStartDocument(fileMarker, folderDao, fileDao, subFolderId, path + folderName + "/", storeTemplate);
2020-01-27 11:15:18 +00:00
}
}
2020-02-07 10:29:16 +00:00
private void SaveFile(FileMarker fileMarker, IFileDao fileDao, object folder, string filePath, IDataStore storeTemp)
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
using var stream = storeTemp.GetReadStream("", filePath);
var fileName = Path.GetFileName(filePath);
2020-02-10 16:04:54 +00:00
var file = ServiceProvider.GetService<File>();
file.Title = fileName;
file.ContentLength = stream.CanSeek ? stream.Length : storeTemp.GetFileSize("", filePath);
file.FolderID = folder;
file.Comment = FilesCommonResource.CommentCreate;
2020-01-31 13:03:21 +00:00
stream.Position = 0;
try
{
file = fileDao.SaveFile(file, stream);
2020-01-27 11:15:18 +00:00
2020-02-07 10:29:16 +00:00
fileMarker.MarkAsNew(file);
2020-01-31 13:03:21 +00:00
}
catch (Exception ex)
{
Logger.Error(ex);
2020-01-27 11:15:18 +00:00
}
}
2020-01-31 13:03:21 +00:00
public bool IsOutsider
2020-01-27 11:15:18 +00:00
{
2020-01-31 13:03:21 +00:00
get { return UserManager.GetUsers(AuthContext.CurrentAccount.ID).IsOutsider(UserManager); }
2020-01-27 11:15:18 +00:00
}
}
2020-01-31 15:32:27 +00:00
public class GlobalFolderHelper
{
2020-02-07 10:29:16 +00:00
public FileMarker FileMarker { get; }
2020-02-04 08:41:04 +00:00
public IDaoFactory DaoFactory { get; }
2020-01-31 15:32:27 +00:00
public GlobalFolder GlobalFolder { get; }
2020-02-04 08:41:04 +00:00
2020-02-07 10:29:16 +00:00
public GlobalFolderHelper(FileMarker fileMarker, IDaoFactory daoFactory, GlobalFolder globalFolder)
2020-01-31 15:32:27 +00:00
{
2020-02-07 10:29:16 +00:00
FileMarker = fileMarker;
2020-02-04 08:41:04 +00:00
DaoFactory = daoFactory;
2020-01-31 15:32:27 +00:00
GlobalFolder = globalFolder;
}
public object FolderProjects
{
get
{
2020-02-04 08:41:04 +00:00
return GlobalFolder.GetFolderProjects(DaoFactory);
2020-01-31 15:32:27 +00:00
}
}
public object FolderCommon
{
get
{
2020-02-07 10:29:16 +00:00
return GlobalFolder.GetFolderCommon(FileMarker, DaoFactory);
2020-01-31 15:32:27 +00:00
}
}
public object FolderMy
{
get
{
2020-02-07 10:29:16 +00:00
return GlobalFolder.GetFolderMy(FileMarker, DaoFactory);
2020-01-31 15:32:27 +00:00
}
set
{
GlobalFolder.SetFolderMy(value);
}
}
public object FolderShare
{
get
{
2020-02-04 08:41:04 +00:00
return GlobalFolder.GetFolderShare(DaoFactory.FolderDao);
2020-01-31 15:32:27 +00:00
}
}
public object FolderTrash
{
get
{
2020-02-04 08:41:04 +00:00
return GlobalFolder.GetFolderTrash(DaoFactory.FolderDao);
2020-01-31 15:32:27 +00:00
}
set
{
GlobalFolder.SetFolderTrash(value);
}
}
}
2020-02-12 13:50:38 +00:00
public static class GlobalExtention
{
2020-02-17 08:58:14 +00:00
public static DIHelper AddGlobalNotifyService(this DIHelper services)
2020-02-12 13:50:38 +00:00
{
services.TryAddSingleton<GlobalNotify>();
return services
.AddKafkaService()
.AddCoreBaseSettingsService();
}
2020-02-17 08:58:14 +00:00
public static DIHelper AddGlobalService(this DIHelper services)
2020-02-12 13:50:38 +00:00
{
services.TryAddScoped<Global>();
return services
.AddAuthContextService()
.AddUserManagerService()
.AddCoreSettingsService()
.AddTenantManagerService()
.AddDisplayUserSettingsService()
.AddCustomNamingPeopleService()
.AddFileSecurityCommonService();
}
2020-02-17 08:58:14 +00:00
public static DIHelper AddGlobalStoreService(this DIHelper services)
2020-02-12 13:50:38 +00:00
{
services.TryAddScoped<GlobalStore>();
return services
.AddStorageFactoryService()
.AddTenantManagerService();
}
2020-02-17 08:58:14 +00:00
public static DIHelper AddGlobalSpaceService(this DIHelper services)
2020-02-12 13:50:38 +00:00
{
services.TryAddScoped<GlobalSpace>();
return services
.AddFilesUserSpaceUsageService()
.AddAuthContextService();
}
2020-02-17 08:58:14 +00:00
public static DIHelper AddGlobalFolderService(this DIHelper services)
2020-02-12 13:50:38 +00:00
{
services.TryAddScoped<GlobalFolder>();
return services
.AddCoreBaseSettingsService()
.AddWebItemManager()
.AddWebItemSecurity()
.AddAuthContextService()
.AddTenantManagerService()
.AddUserManagerService()
.AddSettingsManagerService()
.AddGlobalStoreService();
}
2020-02-12 15:21:58 +00:00
2020-02-17 08:58:14 +00:00
public static DIHelper AddGlobalFolderHelperService(this DIHelper services)
2020-02-12 15:21:58 +00:00
{
services.TryAddScoped<GlobalFolderHelper>();
return services
.AddGlobalFolderService()
.AddDaoFactoryService()
.AddFileMarkerService()
;
}
2020-02-12 13:50:38 +00:00
}
2020-01-27 11:15:18 +00:00
}