Merge branch 'develop' into bugfix/create-room-tag-input
This commit is contained in:
commit
0ca2bf2b4f
@ -169,17 +169,21 @@ RUN chown nginx:nginx /etc/nginx/* -R && \
|
||||
|
||||
## Doceditor ##
|
||||
FROM noderun as doceditor
|
||||
WORKDIR ${BUILD_PATH}/products/ASC.Files/editor
|
||||
WORKDIR ${BUILD_PATH}/products/ASC.Editors/editor
|
||||
|
||||
COPY --chown=onlyoffice:onlyoffice docker-entrypoint.py ./docker-entrypoint.py
|
||||
COPY --from=base --chown=onlyoffice:onlyoffice ${SRC_PATH}/build/deploy/editor/ .
|
||||
ENTRYPOINT ["node", "server.js"]
|
||||
|
||||
CMD ["server.js", "ASC.Editors"]
|
||||
|
||||
## Login ##
|
||||
FROM noderun as login
|
||||
WORKDIR ${BUILD_PATH}/products/ASC.Login/login
|
||||
|
||||
COPY --chown=onlyoffice:onlyoffice docker-entrypoint.py ./docker-entrypoint.py
|
||||
COPY --from=base --chown=onlyoffice:onlyoffice ${SRC_PATH}/build/deploy/login/ .
|
||||
ENTRYPOINT ["node", "server.js"]
|
||||
|
||||
CMD ["server.js", "ASC.Login"]
|
||||
|
||||
## ASC.Data.Backup.BackgroundTasks ##
|
||||
FROM dotnetrun AS backup_background
|
||||
|
@ -364,7 +364,7 @@ public class LdapUserImporter : IDisposable
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool TrySyncUserGroupMembership(Tuple<UserInfo, LdapObject> ldapUserInfo)
|
||||
public async Task<bool> TrySyncUserGroupMembership(Tuple<UserInfo, LdapObject> ldapUserInfo)
|
||||
{
|
||||
if (ldapUserInfo == null ||
|
||||
!Settings.GroupMembership)
|
||||
@ -401,12 +401,12 @@ public class LdapUserImporter : IDisposable
|
||||
groupInfo = UserManager.SaveGroupInfo(_ldapObjectExtension.ToGroupInfo(ldapUserGroup, Settings));
|
||||
|
||||
_logger.DebugTrySyncUserGroupMembershipAddingUserToGroup(userInfo.UserName, ldapUser.Sid, groupInfo.Name, groupInfo.Sid);
|
||||
UserManager.AddUserIntoGroup(userInfo.Id, groupInfo.ID);
|
||||
await UserManager.AddUserIntoGroup(userInfo.Id, groupInfo.ID);
|
||||
}
|
||||
else if (!portalUserLdapGroups.Contains(groupInfo))
|
||||
{
|
||||
_logger.DebugTrySyncUserGroupMembershipAddingUserToGroup(userInfo.UserName, ldapUser.Sid, groupInfo.Name, groupInfo.Sid);
|
||||
UserManager.AddUserIntoGroup(userInfo.Id, groupInfo.ID);
|
||||
await UserManager.AddUserIntoGroup(userInfo.Id, groupInfo.ID);
|
||||
}
|
||||
|
||||
actualPortalLdapGroups.Add(groupInfo);
|
||||
|
@ -136,7 +136,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
InitDisturbedTask();
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -206,7 +206,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
Do();
|
||||
await Do();
|
||||
}
|
||||
catch (AuthorizingException authError)
|
||||
{
|
||||
@ -247,7 +247,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
}
|
||||
}
|
||||
|
||||
private void Do()
|
||||
private async Task Do()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -288,7 +288,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
_logger.DebugLdapSettings(sb.ToString());
|
||||
}
|
||||
|
||||
SyncLDAP();
|
||||
await SyncLDAP();
|
||||
|
||||
if (!string.IsNullOrEmpty(Error))
|
||||
{
|
||||
@ -380,7 +380,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
|
||||
_logger.DebugSaveUserInfo(existingLDAPUser.GetUserInfoString());
|
||||
|
||||
_userManager.SaveUserInfo(existingLDAPUser);
|
||||
_userManager.UpdateUserInfo(existingLDAPUser);
|
||||
break;
|
||||
case LdapOperationType.SaveTest:
|
||||
case LdapOperationType.SyncTest:
|
||||
@ -394,7 +394,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
}
|
||||
}
|
||||
|
||||
private void SyncLDAP()
|
||||
private async Task SyncLDAP()
|
||||
{
|
||||
var currentDomainSettings = _settingsManager.Load<LdapCurrentDomain>();
|
||||
|
||||
@ -408,21 +408,21 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
{
|
||||
_logger.DebugSyncLDAPUsers();
|
||||
|
||||
SyncLDAPUsers();
|
||||
await SyncLDAPUsers();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.DebugSyncLDAPUsersInGroups();
|
||||
|
||||
SyncLDAPUsersInGroups();
|
||||
await SyncLDAPUsersInGroups();
|
||||
}
|
||||
|
||||
SyncLdapAvatar();
|
||||
await SyncLdapAvatar();
|
||||
|
||||
SyncLdapAccessRights();
|
||||
await SyncLdapAccessRights();
|
||||
}
|
||||
|
||||
private void SyncLdapAvatar()
|
||||
private async Task SyncLdapAvatar()
|
||||
{
|
||||
SetProgress(90, Resource.LdapSettingsStatusUpdatingUserPhotos);
|
||||
|
||||
@ -438,7 +438,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
foreach (var guid in ph.CurrentPhotos.Keys)
|
||||
{
|
||||
_logger.InfoSyncLdapAvatarsRemovingPhoto(guid);
|
||||
_userPhotoManager.RemovePhoto(guid);
|
||||
await _userPhotoManager.RemovePhoto(guid);
|
||||
_userPhotoManager.ResetThumbnailSettings(guid);
|
||||
}
|
||||
|
||||
@ -511,16 +511,16 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
_settingsManager.Save(photoSettings);
|
||||
}
|
||||
|
||||
private void SyncLdapAccessRights()
|
||||
private async Task SyncLdapAccessRights()
|
||||
{
|
||||
SetProgress(95, Resource.LdapSettingsStatusUpdatingAccessRights);
|
||||
|
||||
var currentUserRights = new List<LdapSettings.AccessRight>();
|
||||
TakeUsersRights(_currentUser != null ? currentUserRights : null);
|
||||
await TakeUsersRights(_currentUser != null ? currentUserRights : null);
|
||||
|
||||
if (LDAPSettings.GroupMembership && LDAPSettings.AccessRights != null && LDAPSettings.AccessRights.Count > 0)
|
||||
{
|
||||
GiveUsersRights(LDAPSettings.AccessRights, _currentUser != null ? currentUserRights : null);
|
||||
await GiveUsersRights(LDAPSettings.AccessRights, _currentUser != null ? currentUserRights : null);
|
||||
}
|
||||
|
||||
if (currentUserRights.Count > 0)
|
||||
@ -531,7 +531,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
_settingsManager.Save(LDAPSettings);
|
||||
}
|
||||
|
||||
private void TakeUsersRights(List<LdapSettings.AccessRight> currentUserRights)
|
||||
private async Task TakeUsersRights(List<LdapSettings.AccessRight> currentUserRights)
|
||||
{
|
||||
var current = _settingsManager.Load<LdapCurrentAcccessSettings>();
|
||||
|
||||
@ -558,7 +558,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
else
|
||||
{
|
||||
_logger.DebugTakingAdminRights(right.Key, user);
|
||||
_webItemSecurity.SetProductAdministrator(LdapSettings.AccessRightsGuids[right.Key], userId, false);
|
||||
await _webItemSecurity.SetProductAdministrator(LdapSettings.AccessRightsGuids[right.Key], userId, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -567,7 +567,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
_settingsManager.Save(current);
|
||||
}
|
||||
|
||||
private void GiveUsersRights(Dictionary<LdapSettings.AccessRight, string> accessRightsSettings, List<LdapSettings.AccessRight> currentUserRights)
|
||||
private async Task GiveUsersRights(Dictionary<LdapSettings.AccessRight, string> accessRightsSettings, List<LdapSettings.AccessRight> currentUserRights)
|
||||
{
|
||||
var current = _settingsManager.Load<LdapCurrentAcccessSettings>();
|
||||
var currentAccessRights = new Dictionary<LdapSettings.AccessRight, List<string>>();
|
||||
@ -618,7 +618,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
if (_webItemSecurity.IsProductAdministrator(prodId, user.Id))
|
||||
{
|
||||
cleared = true;
|
||||
_webItemSecurity.SetProductAdministrator(prodId, user.Id, false);
|
||||
await _webItemSecurity.SetProductAdministrator(prodId, user.Id, false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -636,7 +636,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
|
||||
SetProgress((int)currentPercent,
|
||||
string.Format(Resource.LdapSettingsStatusGivingRights, _userFormatter.GetUserName(user, DisplayUserNameFormat.Default), access.Key));
|
||||
_webItemSecurity.SetProductAdministrator(LdapSettings.AccessRightsGuids[access.Key], user.Id, true);
|
||||
await _webItemSecurity.SetProductAdministrator(LdapSettings.AccessRightsGuids[access.Key], user.Id, true);
|
||||
|
||||
if (currentUserRights != null && currentUserRights.Contains(access.Key))
|
||||
{
|
||||
@ -651,7 +651,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
_settingsManager.Save(current);
|
||||
}
|
||||
|
||||
private void SyncLDAPUsers()
|
||||
private async Task SyncLDAPUsers()
|
||||
{
|
||||
SetProgress(15, Resource.LdapSettingsStatusGettingUsersFromLdap);
|
||||
|
||||
@ -675,14 +675,14 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
: Resource.LdapSettingsStatusSyncingUsers,
|
||||
"");
|
||||
|
||||
SyncDbUsers(ldapUsers);
|
||||
await SyncDbUsers(ldapUsers);
|
||||
|
||||
SetProgress(70, Resource.LdapSettingsStatusRemovingOldGroups, "");
|
||||
|
||||
RemoveOldDbGroups(new List<GroupInfo>()); // Remove all db groups with sid
|
||||
}
|
||||
|
||||
private void SyncLDAPUsersInGroups()
|
||||
private async Task SyncLDAPUsersInGroups()
|
||||
{
|
||||
SetProgress(15, Resource.LdapSettingsStatusGettingGroupsFromLdap);
|
||||
|
||||
@ -717,11 +717,11 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
: Resource.LdapSettingsStatusSyncingUsers,
|
||||
"");
|
||||
|
||||
var newUniqueLdapGroupUsers = SyncGroupsUsers(uniqueLdapGroupUsers);
|
||||
var newUniqueLdapGroupUsers = await SyncGroupsUsers(uniqueLdapGroupUsers);
|
||||
|
||||
SetProgress(60, Resource.LdapSettingsStatusSavingGroups, "");
|
||||
|
||||
SyncDbGroups(ldapGroupsUsers);
|
||||
await SyncDbGroups(ldapGroupsUsers);
|
||||
|
||||
SetProgress(80, Resource.LdapSettingsStatusRemovingOldGroups, "");
|
||||
|
||||
@ -732,7 +732,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
RemoveOldDbUsers(newUniqueLdapGroupUsers);
|
||||
}
|
||||
|
||||
private void SyncDbGroups(Dictionary<GroupInfo, List<UserInfo>> ldapGroupsWithUsers)
|
||||
private async Task SyncDbGroups(Dictionary<GroupInfo, List<UserInfo>> ldapGroupsWithUsers)
|
||||
{
|
||||
const double percents = 20;
|
||||
|
||||
@ -765,18 +765,18 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
|
||||
if (Equals(dbLdapGroup, Constants.LostGroupInfo))
|
||||
{
|
||||
AddNewGroup(ldapGroup, ldapGroupUsers, gIndex, gCount);
|
||||
await AddNewGroup(ldapGroup, ldapGroupUsers, gIndex, gCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateDbGroup(dbLdapGroup, ldapGroup, ldapGroupUsers, gIndex, gCount);
|
||||
await UpdateDbGroup(dbLdapGroup, ldapGroup, ldapGroupUsers, gIndex, gCount);
|
||||
}
|
||||
|
||||
percentage += step;
|
||||
}
|
||||
}
|
||||
|
||||
private void AddNewGroup(GroupInfo ldapGroup, List<UserInfo> ldapGroupUsers, int gIndex, int gCount)
|
||||
private async Task AddNewGroup(GroupInfo ldapGroup, List<UserInfo> ldapGroupUsers, int gIndex, int gCount)
|
||||
{
|
||||
if (!ldapGroupUsers.Any()) // Skip empty groups
|
||||
{
|
||||
@ -815,7 +815,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
++index, count,
|
||||
_userFormatter.GetUserName(userBySid, DisplayUserNameFormat.Default)));
|
||||
|
||||
_userManager.AddUserIntoGroup(userBySid.Id, ldapGroup.ID);
|
||||
await _userManager.AddUserIntoGroup(userBySid.Id, ldapGroup.ID);
|
||||
}
|
||||
break;
|
||||
case LdapOperationType.SaveTest:
|
||||
@ -846,7 +846,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
return needUpdate;
|
||||
}
|
||||
|
||||
private void UpdateDbGroup(GroupInfo dbLdapGroup, GroupInfo ldapGroup, List<UserInfo> ldapGroupUsers, int gIndex,
|
||||
private async Task UpdateDbGroup(GroupInfo dbLdapGroup, GroupInfo ldapGroup, List<UserInfo> ldapGroupUsers, int gIndex,
|
||||
int gCount)
|
||||
{
|
||||
SetProgress(currentSource:
|
||||
@ -911,7 +911,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
++index, count,
|
||||
_userFormatter.GetUserName(userInfo, DisplayUserNameFormat.Default)));
|
||||
|
||||
_userManager.AddUserIntoGroup(userInfo.Id, dbLdapGroup.ID);
|
||||
await _userManager.AddUserIntoGroup(userInfo.Id, dbLdapGroup.ID);
|
||||
}
|
||||
|
||||
if (dbGroupMembers.All(dbUser => groupMembersToRemove.Exists(u => u.Id.Equals(dbUser.Id)))
|
||||
@ -965,7 +965,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
return foundUser;
|
||||
}
|
||||
|
||||
private void SyncDbUsers(List<UserInfo> ldapUsers)
|
||||
private async Task SyncDbUsers(List<UserInfo> ldapUsers)
|
||||
{
|
||||
const double percents = 35;
|
||||
|
||||
@ -992,12 +992,11 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
{
|
||||
case LdapOperationType.Save:
|
||||
case LdapOperationType.Sync:
|
||||
_lDAPUserManager.SyncLDAPUser(userInfo, ldapUsers);
|
||||
await _lDAPUserManager.SyncLDAPUser(userInfo, ldapUsers);
|
||||
break;
|
||||
case LdapOperationType.SaveTest:
|
||||
case LdapOperationType.SyncTest:
|
||||
LdapChangeCollection changes;
|
||||
_lDAPUserManager.GetLDAPSyncUserChange(userInfo, ldapUsers, out changes);
|
||||
var changes = (await _lDAPUserManager.GetLDAPSyncUserChange(userInfo, ldapUsers)).LdapChangeCollection;
|
||||
_ldapChanges.AddRange(changes);
|
||||
break;
|
||||
default:
|
||||
@ -1065,7 +1064,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
|
||||
_logger.DebugSaveUserInfo(removedUser.GetUserInfoString());
|
||||
|
||||
_userManager.SaveUserInfo(removedUser);
|
||||
_userManager.UpdateUserInfo(removedUser);
|
||||
break;
|
||||
case LdapOperationType.SaveTest:
|
||||
case LdapOperationType.SyncTest:
|
||||
@ -1129,7 +1128,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
}
|
||||
}
|
||||
|
||||
private List<UserInfo> SyncGroupsUsers(List<UserInfo> uniqueLdapGroupUsers)
|
||||
private async Task<List<UserInfo>> SyncGroupsUsers(List<UserInfo> uniqueLdapGroupUsers)
|
||||
{
|
||||
const double percents = 30;
|
||||
|
||||
@ -1157,7 +1156,7 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
{
|
||||
case LdapOperationType.Save:
|
||||
case LdapOperationType.Sync:
|
||||
user = _lDAPUserManager.SyncLDAPUser(ldapGroupUser, uniqueLdapGroupUsers);
|
||||
user = await _lDAPUserManager.SyncLDAPUser(ldapGroupUser, uniqueLdapGroupUsers);
|
||||
if (!Equals(user, Constants.LostUser))
|
||||
{
|
||||
newUniqueLdapGroupUsers.Add(user);
|
||||
@ -1165,8 +1164,9 @@ public class LdapOperationJob : DistributedTaskProgress
|
||||
break;
|
||||
case LdapOperationType.SaveTest:
|
||||
case LdapOperationType.SyncTest:
|
||||
LdapChangeCollection changes;
|
||||
user = _lDAPUserManager.GetLDAPSyncUserChange(ldapGroupUser, uniqueLdapGroupUsers, out changes);
|
||||
var wrapper = await _lDAPUserManager.GetLDAPSyncUserChange(ldapGroupUser, uniqueLdapGroupUsers);
|
||||
user = wrapper.UserInfo;
|
||||
var changes = wrapper.LdapChangeCollection;
|
||||
if (!Equals(user, Constants.LostUser))
|
||||
{
|
||||
newUniqueLdapGroupUsers.Add(user);
|
||||
|
@ -51,6 +51,7 @@ global using ASC.ActiveDirectory.Novell;
|
||||
global using ASC.ActiveDirectory.Novell.Data;
|
||||
global using ASC.ActiveDirectory.Novell.Exceptions;
|
||||
global using ASC.ActiveDirectory.Novell.Extensions;
|
||||
global using ASC.ActiveDirectory.Wrapper;
|
||||
global using ASC.Common;
|
||||
global using ASC.Common.Security.Authorizing;
|
||||
global using ASC.Common.Threading;
|
||||
|
@ -1,30 +1,31 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL 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 details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
|
||||
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL 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 details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
|
||||
using Constants = ASC.Core.Users.Constants;
|
||||
using Mapping = ASC.ActiveDirectory.Base.Settings.LdapSettings.MappingFields;
|
||||
using SecurityContext = ASC.Core.SecurityContext;
|
||||
@ -43,8 +44,8 @@ public class LdapUserManager
|
||||
private readonly DisplayUserSettingsHelper _displayUserSettingsHelper;
|
||||
private readonly UserFormatter _userFormatter;
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly NovellLdapUserImporter _novellLdapUserImporter;
|
||||
private readonly CountRoomAdminChecker _countRoomAdminChecker;
|
||||
private readonly NovellLdapUserImporter _novellLdapUserImporter;
|
||||
private readonly CountRoomAdminChecker _countRoomAdminChecker;
|
||||
private LdapLocalization _resource;
|
||||
|
||||
public LdapUserManager(
|
||||
@ -58,7 +59,7 @@ public class LdapUserManager
|
||||
SettingsManager settingsManager,
|
||||
DisplayUserSettingsHelper displayUserSettingsHelper,
|
||||
UserFormatter userFormatter,
|
||||
NovellLdapUserImporter novellLdapUserImporter,
|
||||
NovellLdapUserImporter novellLdapUserImporter,
|
||||
CountRoomAdminChecker countRoomAdminChecker)
|
||||
{
|
||||
_logger = logger;
|
||||
@ -71,8 +72,8 @@ public class LdapUserManager
|
||||
_displayUserSettingsHelper = displayUserSettingsHelper;
|
||||
_userFormatter = userFormatter;
|
||||
_serviceProvider = serviceProvider;
|
||||
_novellLdapUserImporter = novellLdapUserImporter;
|
||||
_countRoomAdminChecker = countRoomAdminChecker;
|
||||
_novellLdapUserImporter = novellLdapUserImporter;
|
||||
_countRoomAdminChecker = countRoomAdminChecker;
|
||||
}
|
||||
|
||||
public void Init(LdapLocalization resource = null)
|
||||
@ -108,9 +109,9 @@ public class LdapUserManager
|
||||
return Equals(foundUser, Constants.LostUser) || foundUser.Id == userId;
|
||||
}
|
||||
|
||||
public bool TryAddLDAPUser(UserInfo ldapUserInfo, bool onlyGetChanges, out UserInfo portalUserInfo)
|
||||
public async Task<UserInfo> TryAddLDAPUser(UserInfo ldapUserInfo, bool onlyGetChanges)
|
||||
{
|
||||
portalUserInfo = Constants.LostUser;
|
||||
var portalUserInfo = Constants.LostUser;
|
||||
|
||||
try
|
||||
{
|
||||
@ -125,24 +126,14 @@ public class LdapUserManager
|
||||
{
|
||||
_logger.DebugUserAlredyExistsForEmail(ldapUserInfo.Sid, ldapUserInfo.Email);
|
||||
|
||||
return false;
|
||||
return portalUserInfo;
|
||||
}
|
||||
|
||||
if (!TryChangeExistingUserName(ldapUserInfo.UserName, onlyGetChanges))
|
||||
{
|
||||
_logger.DebugUserAlredyExistsForUserName(ldapUserInfo.Sid, ldapUserInfo.UserName);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_countRoomAdminChecker.CheckAppend().Wait();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
_logger.DebugExceedQuota(ldapUserInfo.Sid, ldapUserInfo.UserName);
|
||||
throw;
|
||||
return portalUserInfo;
|
||||
}
|
||||
|
||||
if (!ldapUserInfo.WorkFromDate.HasValue)
|
||||
@ -153,12 +144,12 @@ public class LdapUserManager
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
portalUserInfo = ldapUserInfo;
|
||||
return true;
|
||||
return portalUserInfo;
|
||||
}
|
||||
|
||||
_logger.DebugSaveUserInfo(ldapUserInfo.GetUserInfoString());
|
||||
|
||||
portalUserInfo = _userManager.SaveUserInfo(ldapUserInfo);
|
||||
portalUserInfo = await _userManager.SaveUserInfo(ldapUserInfo);
|
||||
|
||||
var quotaSettings = _settingsManager.Load<TenantUserQuotaSettings>();
|
||||
if (quotaSettings.EnableUserQuota)
|
||||
@ -172,8 +163,6 @@ public class LdapUserManager
|
||||
_logger.DebugSetUserPassword(portalUserInfo.Id);
|
||||
|
||||
_securityContext.SetUserPasswordHash(portalUserInfo.Id, passwordHash);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (TenantQuotaException ex)
|
||||
{
|
||||
@ -188,7 +177,7 @@ public class LdapUserManager
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return portalUserInfo;
|
||||
}
|
||||
|
||||
private bool TryChangeExistingUserName(string ldapUserName, bool onlyGetChanges)
|
||||
@ -223,7 +212,7 @@ public class LdapUserManager
|
||||
|
||||
_logger.DebugSaveUserInfo(otherUser.GetUserInfoString());
|
||||
|
||||
_userManager.SaveUserInfo(otherUser);
|
||||
_userManager.UpdateUserInfo(otherUser);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -235,25 +224,26 @@ public class LdapUserManager
|
||||
return false;
|
||||
}
|
||||
|
||||
public UserInfo GetLDAPSyncUserChange(UserInfo ldapUserInfo, List<UserInfo> ldapUsers, out LdapChangeCollection changes)
|
||||
public async Task<UserInfoAndLdapChangeCollectionWrapper> GetLDAPSyncUserChange(UserInfo ldapUserInfo, List<UserInfo> ldapUsers)
|
||||
{
|
||||
return SyncLDAPUser(ldapUserInfo, ldapUsers, out changes, true);
|
||||
return await SyncLDAPUser(ldapUserInfo, ldapUsers, true);
|
||||
}
|
||||
|
||||
public UserInfo SyncLDAPUser(UserInfo ldapUserInfo, List<UserInfo> ldapUsers = null)
|
||||
public async Task<UserInfo> SyncLDAPUser(UserInfo ldapUserInfo, List<UserInfo> ldapUsers = null)
|
||||
{
|
||||
LdapChangeCollection changes;
|
||||
return SyncLDAPUser(ldapUserInfo, ldapUsers, out changes);
|
||||
return (await SyncLDAPUser(ldapUserInfo, ldapUsers, false)).UserInfo;
|
||||
}
|
||||
|
||||
private UserInfo SyncLDAPUser(UserInfo ldapUserInfo, List<UserInfo> ldapUsers, out LdapChangeCollection changes, bool onlyGetChanges = false)
|
||||
private async Task<UserInfoAndLdapChangeCollectionWrapper> SyncLDAPUser(UserInfo ldapUserInfo, List<UserInfo> ldapUsers, bool onlyGetChanges = false)
|
||||
{
|
||||
UserInfo result;
|
||||
|
||||
changes = new LdapChangeCollection(_userFormatter);
|
||||
|
||||
UserInfo userToUpdate;
|
||||
|
||||
var wrapper = new UserInfoAndLdapChangeCollectionWrapper()
|
||||
{
|
||||
LdapChangeCollection = new LdapChangeCollection(_userFormatter),
|
||||
UserInfo = Constants.LostUser
|
||||
};
|
||||
|
||||
var userBySid = _userManager.GetUserBySid(ldapUserInfo.Sid);
|
||||
|
||||
if (Equals(userBySid, Constants.LostUser))
|
||||
@ -266,28 +256,28 @@ public class LdapUserManager
|
||||
{
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
changes.SetSkipUserChange(ldapUserInfo);
|
||||
wrapper.LdapChangeCollection.SetSkipUserChange(ldapUserInfo);
|
||||
}
|
||||
|
||||
_logger.DebugSyncUserLdapFailedWithStatus(ldapUserInfo.Sid, ldapUserInfo.UserName,
|
||||
Enum.GetName(typeof(EmployeeStatus), ldapUserInfo.Status));
|
||||
|
||||
return Constants.LostUser;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
if (!TryAddLDAPUser(ldapUserInfo, onlyGetChanges, out result))
|
||||
wrapper.UserInfo = await TryAddLDAPUser(ldapUserInfo, onlyGetChanges);
|
||||
if (wrapper.UserInfo == Constants.LostUser)
|
||||
{
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
changes.SetSkipUserChange(ldapUserInfo);
|
||||
wrapper.LdapChangeCollection.SetSkipUserChange(ldapUserInfo);
|
||||
}
|
||||
|
||||
return Constants.LostUser;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
changes.SetAddUserChange(result, _logger);
|
||||
wrapper.LdapChangeCollection.SetAddUserChange(wrapper.UserInfo, _logger);
|
||||
}
|
||||
|
||||
if (!onlyGetChanges && _settingsManager.Load<LdapSettings>().SendWelcomeEmail &&
|
||||
@ -317,7 +307,7 @@ public class LdapUserManager
|
||||
new TagValue(NotifyCommonTags.WithoutUnsubscribe, true));
|
||||
}
|
||||
|
||||
return result;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
if (userByEmail.IsLDAP())
|
||||
@ -326,13 +316,13 @@ public class LdapUserManager
|
||||
{
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
changes.SetSkipUserChange(ldapUserInfo);
|
||||
wrapper.LdapChangeCollection.SetSkipUserChange(ldapUserInfo);
|
||||
}
|
||||
|
||||
_logger.DebugSyncUserLdapFailedWithEmail(
|
||||
ldapUserInfo.Sid, ldapUserInfo.UserName, ldapUserInfo.Email);
|
||||
|
||||
return Constants.LostUser;
|
||||
return wrapper;
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,29 +340,30 @@ public class LdapUserManager
|
||||
_logger.DebugSyncUserLdapSkipping(ldapUserInfo.Sid, ldapUserInfo.UserName);
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
changes.SetNoneUserChange(ldapUserInfo);
|
||||
wrapper.LdapChangeCollection.SetNoneUserChange(ldapUserInfo);
|
||||
}
|
||||
|
||||
return userBySid;
|
||||
wrapper.UserInfo = userBySid;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
_logger.DebugSyncUserLdapUpdaiting(ldapUserInfo.Sid, ldapUserInfo.UserName);
|
||||
if (!TryUpdateUserWithLDAPInfo(userToUpdate, ldapUserInfo, onlyGetChanges, out result))
|
||||
UserInfo uf;
|
||||
if (!TryUpdateUserWithLDAPInfo(userToUpdate, ldapUserInfo, onlyGetChanges, out uf))
|
||||
{
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
changes.SetSkipUserChange(ldapUserInfo);
|
||||
wrapper.LdapChangeCollection.SetSkipUserChange(ldapUserInfo);
|
||||
}
|
||||
|
||||
return Constants.LostUser;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
if (onlyGetChanges)
|
||||
{
|
||||
changes.SetUpdateUserChange(ldapUserInfo, result, _logger);
|
||||
wrapper.LdapChangeCollection.SetUpdateUserChange(ldapUserInfo, uf, _logger);
|
||||
}
|
||||
|
||||
return result;
|
||||
wrapper.UserInfo = uf;
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private const string EXT_MOB_PHONE = "extmobphone";
|
||||
@ -601,7 +592,7 @@ public class LdapUserManager
|
||||
{
|
||||
_logger.DebugSaveUserInfo(userToUpdate.GetUserInfoString());
|
||||
|
||||
portlaUserInfo = _userManager.SaveUserInfo(userToUpdate);
|
||||
portlaUserInfo = _userManager.UpdateUserInfo(userToUpdate);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -615,9 +606,9 @@ public class LdapUserManager
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool TryGetAndSyncLdapUserInfo(string login, string password, out UserInfo userInfo)
|
||||
public async Task<UserInfo> TryGetAndSyncLdapUserInfo(string login, string password)
|
||||
{
|
||||
userInfo = Constants.LostUser;
|
||||
var userInfo = Constants.LostUser;
|
||||
|
||||
|
||||
try
|
||||
@ -626,7 +617,7 @@ public class LdapUserManager
|
||||
|
||||
if (!settings.EnableLdapAuthentication)
|
||||
{
|
||||
return false;
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
_logger.DebugTryGetAndSyncLdapUserInfo(login);
|
||||
@ -638,7 +629,7 @@ public class LdapUserManager
|
||||
if (ldapUserInfo == null || ldapUserInfo.Item1.Equals(Constants.LostUser))
|
||||
{
|
||||
_logger.DebugNovellLdapUserImporterLoginFailed(login);
|
||||
return false;
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
var portalUser = _userManager.GetUserBySid(ldapUserInfo.Item1.Sid);
|
||||
@ -648,16 +639,16 @@ public class LdapUserManager
|
||||
if (!ldapUserInfo.Item2.IsDisabled)
|
||||
{
|
||||
_logger.DebugTryCheckAndSyncToLdapUser(ldapUserInfo.Item1.UserName, ldapUserInfo.Item1.Email, ldapUserInfo.Item2.DistinguishedName);
|
||||
|
||||
if (!TryCheckAndSyncToLdapUser(ldapUserInfo, _novellLdapUserImporter, out userInfo))
|
||||
userInfo = await TryCheckAndSyncToLdapUser(ldapUserInfo, _novellLdapUserImporter);
|
||||
if (Equals(userInfo, Constants.LostUser))
|
||||
{
|
||||
_logger.DebugTryCheckAndSyncToLdapUserFailed();
|
||||
return false;
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -679,18 +670,18 @@ public class LdapUserManager
|
||||
tenantManager.SetCurrentTenant(tenant);
|
||||
securityContext.AuthenticateMe(Core.Configuration.Constants.CoreSystem);
|
||||
|
||||
var uInfo = SyncLDAPUser(ldapUserInfo.Item1);
|
||||
var uInfo = await SyncLDAPUser(ldapUserInfo.Item1);
|
||||
|
||||
var newLdapUserInfo = new Tuple<UserInfo, LdapObject>(uInfo, ldapUserInfo.Item2);
|
||||
|
||||
if (novellLdapUserImporter.Settings.GroupMembership)
|
||||
{
|
||||
if (!novellLdapUserImporter.TrySyncUserGroupMembership(newLdapUserInfo))
|
||||
if (!(await novellLdapUserImporter.TrySyncUserGroupMembership(newLdapUserInfo)))
|
||||
{
|
||||
log.DebugTryGetAndSyncLdapUserInfoDisablingUser(login, uInfo);
|
||||
uInfo.Status = EmployeeStatus.Terminated;
|
||||
uInfo.Sid = null;
|
||||
userManager.SaveUserInfo(uInfo);
|
||||
userManager.UpdateUserInfo(uInfo);
|
||||
await cookiesManager.ResetUserCookie(uInfo.Id);
|
||||
}
|
||||
}
|
||||
@ -699,7 +690,7 @@ public class LdapUserManager
|
||||
if (ldapUserInfo.Item2.IsDisabled)
|
||||
{
|
||||
_logger.DebugTryGetAndSyncLdapUserInfo(login);
|
||||
return false;
|
||||
return userInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -707,24 +698,24 @@ public class LdapUserManager
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return userInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorTryGetLdapUserInfoFailed(login, ex);
|
||||
userInfo = Constants.LostUser;
|
||||
return false;
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
|
||||
private bool TryCheckAndSyncToLdapUser(Tuple<UserInfo, LdapObject> ldapUserInfo, LdapUserImporter importer,
|
||||
out UserInfo userInfo)
|
||||
private async Task<UserInfo> TryCheckAndSyncToLdapUser(Tuple<UserInfo, LdapObject> ldapUserInfo, LdapUserImporter importer)
|
||||
{
|
||||
UserInfo userInfo;
|
||||
try
|
||||
{
|
||||
_securityContext.AuthenticateMe(Core.Configuration.Constants.CoreSystem);
|
||||
|
||||
userInfo = SyncLDAPUser(ldapUserInfo.Item1);
|
||||
userInfo = await SyncLDAPUser(ldapUserInfo.Item1);
|
||||
|
||||
if (userInfo == null || userInfo.Equals(Constants.LostUser))
|
||||
{
|
||||
@ -735,18 +726,18 @@ public class LdapUserManager
|
||||
|
||||
if (!importer.Settings.GroupMembership)
|
||||
{
|
||||
return true;
|
||||
return userInfo;
|
||||
}
|
||||
|
||||
if (!importer.TrySyncUserGroupMembership(newLdapUserInfo))
|
||||
if (!(await importer.TrySyncUserGroupMembership(newLdapUserInfo)))
|
||||
{
|
||||
userInfo.Sid = null;
|
||||
userInfo.Status = EmployeeStatus.Terminated;
|
||||
_userManager.SaveUserInfo(userInfo);
|
||||
_userManager.UpdateUserInfo(userInfo);
|
||||
throw new Exception("The user did not pass the configuration check by ldap group settings");
|
||||
}
|
||||
|
||||
return true;
|
||||
return userInfo;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -759,6 +750,6 @@ public class LdapUserManager
|
||||
}
|
||||
|
||||
userInfo = Constants.LostUser;
|
||||
return false;
|
||||
return userInfo;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,32 @@
|
||||
// (c) Copyright Ascensio System SIA 2010-2022
|
||||
//
|
||||
// This program is a free software product.
|
||||
// You can redistribute it and/or modify it under the terms
|
||||
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
|
||||
// Foundation. In accordance with Section 7(a) of the GNU AGPL 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 details, see
|
||||
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
//
|
||||
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
|
||||
//
|
||||
// The interactive user interfaces in modified source and object code versions of the Program must
|
||||
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
|
||||
//
|
||||
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
|
||||
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
|
||||
// trademark law for use of our trademarks.
|
||||
//
|
||||
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
namespace ASC.ActiveDirectory.Wrapper;
|
||||
public class UserInfoAndLdapChangeCollectionWrapper
|
||||
{
|
||||
public UserInfo UserInfo { get; set; }
|
||||
public LdapChangeCollection LdapChangeCollection { get; set; }
|
||||
}
|
@ -57,7 +57,7 @@ public class CookieAuthHandler : AuthenticationHandler<AuthenticationSchemeOptio
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
protected override Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -75,7 +75,7 @@ public class CookieAuthHandler : AuthenticationHandler<AuthenticationSchemeOptio
|
||||
authorization = authorization.Substring("Bearer ".Length);
|
||||
}
|
||||
|
||||
if (!_securityContext.AuthenticateMe(authorization))
|
||||
if (!(await _securityContext.AuthenticateMe(authorization)))
|
||||
{
|
||||
throw new AuthenticationException(nameof(HttpStatusCode.Unauthorized));
|
||||
}
|
||||
@ -83,7 +83,7 @@ public class CookieAuthHandler : AuthenticationHandler<AuthenticationSchemeOptio
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return Task.FromResult(AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorized))));
|
||||
return AuthenticateResult.Fail(new AuthenticationException(nameof(HttpStatusCode.Unauthorized)));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@ -95,6 +95,6 @@ public class CookieAuthHandler : AuthenticationHandler<AuthenticationSchemeOptio
|
||||
}
|
||||
}
|
||||
|
||||
return Task.FromResult(AuthenticateResult.Success(new AuthenticationTicket(Context.User, Scheme.Name)));
|
||||
return AuthenticateResult.Success(new AuthenticationTicket(Context.User, Scheme.Name));
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ namespace ASC.Api.Core.Extensions;
|
||||
public static class ISetupBuilderExtension
|
||||
{
|
||||
public static ISetupBuilder LoadConfiguration(this ISetupBuilder loggingBuilder, IConfiguration configuration, IHostEnvironment hostEnvironment)
|
||||
{
|
||||
{
|
||||
var conf = new XmlLoggingConfiguration(CrossPlatform.PathCombine(configuration["pathToConf"], "nlog.config"));
|
||||
|
||||
var settings = new ConfigurationExtension(configuration).GetSetting<NLogSettings>("log");
|
||||
@ -56,10 +56,18 @@ public static class ISetupBuilderExtension
|
||||
{
|
||||
awsTarget.LogGroup = awsTarget.LogGroup.Replace("${var:name}", settings.Name);
|
||||
}
|
||||
|
||||
|
||||
var awsAccessKeyId = string.IsNullOrEmpty(settings.AWSAccessKeyId) ? configuration["aws:cloudWatch:accessKeyId"] : settings.AWSAccessKeyId;
|
||||
var awsSecretAccessKey = string.IsNullOrEmpty(settings.AWSSecretAccessKey) ? configuration["aws:cloudWatch:secretAccessKey"] : settings.AWSSecretAccessKey;
|
||||
|
||||
if (!string.IsNullOrEmpty(settings.AWSSecretAccessKey))
|
||||
{
|
||||
awsTarget.Credentials = new Amazon.Runtime.BasicAWSCredentials(settings.AWSAccessKeyId, settings.AWSSecretAccessKey);
|
||||
if (!string.IsNullOrEmpty(awsAccessKeyId))
|
||||
{
|
||||
|
||||
awsTarget.LogGroup = String.IsNullOrEmpty(configuration["aws:cloudWatch:logGroupName"]) ? awsTarget.LogGroup : configuration["aws:cloudWatch:logGroupName"];
|
||||
awsTarget.Region = String.IsNullOrEmpty(configuration["aws:cloudWatch:region"]) ? awsTarget.Region : configuration["aws:cloudWatch:region"];
|
||||
|
||||
awsTarget.Credentials = new Amazon.Runtime.BasicAWSCredentials(awsAccessKeyId, awsSecretAccessKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ public class EmployeeFullDtoHelper : EmployeeDtoHelper
|
||||
|
||||
return lambda;
|
||||
}
|
||||
public EmployeeFullDto GetSimple(UserInfo userInfo)
|
||||
public async Task<EmployeeFullDto> GetSimple(UserInfo userInfo)
|
||||
{
|
||||
var result = new EmployeeFullDto
|
||||
{
|
||||
@ -167,7 +167,7 @@ public class EmployeeFullDtoHelper : EmployeeDtoHelper
|
||||
|
||||
FillGroups(result, userInfo);
|
||||
|
||||
var photoData = _userPhotoManager.GetUserPhotoData(userInfo.Id, UserPhotoManager.BigFotoSize);
|
||||
var photoData = await _userPhotoManager.GetUserPhotoData(userInfo.Id, UserPhotoManager.BigFotoSize);
|
||||
|
||||
if (photoData != null)
|
||||
{
|
||||
|
@ -145,7 +145,7 @@ public class KafkaCacheNotify<T> : IDisposable, ICacheNotify<T> where T : IMessa
|
||||
_cancelationToken[channelName] = new CancellationTokenSource();
|
||||
_actions[channelName] = onchange;
|
||||
|
||||
void action()
|
||||
async void action()
|
||||
{
|
||||
var conf = new ConsumerConfig(_clientConfig)
|
||||
{
|
||||
@ -160,7 +160,7 @@ public class KafkaCacheNotify<T> : IDisposable, ICacheNotify<T> where T : IMessa
|
||||
try
|
||||
{
|
||||
//TODO: must add checking exist
|
||||
adminClient.CreateTopicsAsync(
|
||||
await adminClient.CreateTopicsAsync(
|
||||
new TopicSpecification[]
|
||||
{
|
||||
new TopicSpecification
|
||||
@ -169,7 +169,7 @@ public class KafkaCacheNotify<T> : IDisposable, ICacheNotify<T> where T : IMessa
|
||||
NumPartitions = 1,
|
||||
ReplicationFactor = 1
|
||||
}
|
||||
}).Wait();
|
||||
});
|
||||
}
|
||||
catch (AggregateException) { }
|
||||
}
|
||||
|
@ -24,8 +24,6 @@
|
||||
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
|
||||
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
|
||||
using JsonSerializer = System.Text.Json.JsonSerializer;
|
||||
|
||||
namespace ASC.Common.Threading;
|
||||
|
||||
[ProtoContract(IgnoreUnknownSubTypes = true)]
|
||||
@ -77,21 +75,6 @@ public class DistributedTask
|
||||
Publication(this);
|
||||
}
|
||||
|
||||
public T GetProperty<T>(string propName)
|
||||
{
|
||||
if (!_props.TryGetValue(propName, out var propValue))
|
||||
{
|
||||
return default;
|
||||
}
|
||||
|
||||
return JsonSerializer.Deserialize<T>(propValue);
|
||||
}
|
||||
|
||||
public void SetProperty<T>(string propName, T propValue)
|
||||
{
|
||||
_props[propName] = JsonSerializer.Serialize(propValue);
|
||||
}
|
||||
|
||||
public dynamic this[string propName]
|
||||
{
|
||||
get
|
||||
|
@ -45,15 +45,15 @@ public class DistributedTaskProgress : DistributedTask
|
||||
[ProtoMember(3)]
|
||||
protected int StepCount { get; set; }
|
||||
|
||||
public void RunJob()
|
||||
public virtual async Task RunJob(DistributedTask _, CancellationToken cancellationToken)
|
||||
{
|
||||
Percentage = 0;
|
||||
Status = DistributedTaskStatus.Running;
|
||||
|
||||
DoJob();
|
||||
await DoJob();
|
||||
}
|
||||
|
||||
protected virtual void DoJob() { }
|
||||
protected virtual Task DoJob() { return Task.CompletedTask; }
|
||||
|
||||
protected void StepDone()
|
||||
{
|
||||
|
@ -121,41 +121,7 @@ public class DistributedTaskQueue
|
||||
|
||||
public void EnqueueTask(DistributedTaskProgress taskProgress)
|
||||
{
|
||||
EnqueueTask((a, b) => taskProgress.RunJob(), taskProgress);
|
||||
}
|
||||
|
||||
public void EnqueueTask(Action<DistributedTask, CancellationToken> action, DistributedTask distributedTask = null)
|
||||
{
|
||||
if (distributedTask == null)
|
||||
{
|
||||
distributedTask = new DistributedTask();
|
||||
}
|
||||
|
||||
distributedTask.InstanceId = INSTANCE_ID;
|
||||
|
||||
var cancelation = new CancellationTokenSource();
|
||||
var token = cancelation.Token;
|
||||
_cancelations[distributedTask.Id] = cancelation;
|
||||
|
||||
var task = new Task(() => { action(distributedTask, token); }, token, TaskCreationOptions.LongRunning);
|
||||
|
||||
task.ConfigureAwait(false)
|
||||
.GetAwaiter()
|
||||
.OnCompleted(() => OnCompleted(task, distributedTask.Id));
|
||||
|
||||
distributedTask.Status = DistributedTaskStatus.Running;
|
||||
|
||||
if (distributedTask.Publication == null)
|
||||
{
|
||||
distributedTask.Publication = GetPublication();
|
||||
}
|
||||
|
||||
distributedTask.PublishChanges();
|
||||
|
||||
task.Start(Scheduler);
|
||||
|
||||
_logger.TraceEnqueueTask(distributedTask.Id, INSTANCE_ID);
|
||||
|
||||
EnqueueTask(taskProgress.RunJob, taskProgress);
|
||||
}
|
||||
|
||||
public void EnqueueTask(Func<DistributedTask, CancellationToken, Task> action, DistributedTask distributedTask = null)
|
||||
@ -393,5 +359,4 @@ public class DistributedTaskQueue
|
||||
|
||||
return destination;
|
||||
}
|
||||
|
||||
}
|
@ -61,7 +61,7 @@ public class UserManager
|
||||
private readonly CardDavAddressbook _cardDavAddressbook;
|
||||
private readonly ILogger<UserManager> _log;
|
||||
private readonly ICache _cache;
|
||||
private readonly TenantQuotaFeatureCheckerCount<CountRoomAdminFeature> _tenantQuotaFeatureChecker;
|
||||
private readonly TenantQuotaFeatureCheckerCount<CountRoomAdminFeature> _countRoomAdminChecker;
|
||||
private readonly TenantQuotaFeatureCheckerCount<CountUserFeature> _activeUsersFeatureChecker;
|
||||
private readonly Constants _constants;
|
||||
|
||||
@ -85,7 +85,7 @@ public class UserManager
|
||||
CardDavAddressbook cardDavAddressbook,
|
||||
ILogger<UserManager> log,
|
||||
ICache cache,
|
||||
TenantQuotaFeatureCheckerCount<CountRoomAdminFeature> tenantQuotaFeatureChecker,
|
||||
TenantQuotaFeatureCheckerCount<CountRoomAdminFeature> countRoomAdrminChecker,
|
||||
TenantQuotaFeatureCheckerCount<CountUserFeature> activeUsersFeatureChecker
|
||||
)
|
||||
{
|
||||
@ -100,7 +100,7 @@ public class UserManager
|
||||
_cardDavAddressbook = cardDavAddressbook;
|
||||
_log = log;
|
||||
_cache = cache;
|
||||
_tenantQuotaFeatureChecker = tenantQuotaFeatureChecker;
|
||||
_countRoomAdminChecker = countRoomAdrminChecker;
|
||||
_activeUsersFeatureChecker = activeUsersFeatureChecker;
|
||||
_constants = _userManagerConstants.Constants;
|
||||
}
|
||||
@ -135,7 +135,7 @@ public class UserManager
|
||||
}
|
||||
|
||||
|
||||
#region Users
|
||||
#region Users
|
||||
|
||||
public UserInfo[] GetUsers()
|
||||
{
|
||||
@ -198,7 +198,7 @@ public class UserManager
|
||||
public UserInfo GetUserBySid(string sid)
|
||||
{
|
||||
return GetUsersInternal()
|
||||
.FirstOrDefault(u => u.Sid != null && string.Equals(u.Sid, sid, StringComparison.CurrentCultureIgnoreCase)) ?? Constants.LostUser;
|
||||
.FirstOrDefault(u => u.Sid != null && string.Equals(u.Sid, sid, StringComparison.CurrentCultureIgnoreCase)) ?? Constants.LostUser;
|
||||
}
|
||||
|
||||
public UserInfo GetSsoUserByNameId(string nameId)
|
||||
@ -296,11 +296,11 @@ public class UserManager
|
||||
foreach (var user in users)
|
||||
{
|
||||
var properties = new string[]
|
||||
{
|
||||
user.LastName ?? string.Empty,
|
||||
user.FirstName ?? string.Empty,
|
||||
user.Title ?? string.Empty,
|
||||
user.Location ?? string.Empty,
|
||||
{
|
||||
user.LastName ?? string.Empty,
|
||||
user.FirstName ?? string.Empty,
|
||||
user.Title ?? string.Empty,
|
||||
user.Location ?? string.Empty,
|
||||
user.Email ?? string.Empty,
|
||||
};
|
||||
if (IsPropertiesContainsWords(properties, words))
|
||||
@ -312,22 +312,49 @@ public class UserManager
|
||||
return findUsers.ToArray();
|
||||
}
|
||||
|
||||
public UserInfo SaveUserInfo(UserInfo u, bool isUser = false, bool syncCardDav = false)
|
||||
public UserInfo UpdateUserInfo(UserInfo u)
|
||||
{
|
||||
if (IsSystemUser(u.Id))
|
||||
{
|
||||
return SystemUsers[u.Id];
|
||||
}
|
||||
|
||||
if (u.Id == Guid.Empty)
|
||||
_permissionContext.DemandPermissions(new UserSecurityProvider(u.Id), Constants.Action_EditUser);
|
||||
|
||||
if (u.Status == EmployeeStatus.Terminated && u.Id == _tenantManager.GetCurrentTenant().OwnerId)
|
||||
{
|
||||
_permissionContext.DemandPermissions(Constants.Action_AddRemoveUser);
|
||||
throw new InvalidOperationException("Can not disable tenant owner.");
|
||||
}
|
||||
else
|
||||
|
||||
var oldUserData = _userService.GetUserByUserName(_tenantManager.GetCurrentTenant().Id, u.UserName);
|
||||
|
||||
if (oldUserData == null || Equals(oldUserData, Constants.LostUser))
|
||||
{
|
||||
_permissionContext.DemandPermissions(new UserSecurityProvider(u.Id), Constants.Action_EditUser);
|
||||
throw new InvalidOperationException("User not found.");
|
||||
}
|
||||
|
||||
return _userService.SaveUser(_tenantManager.GetCurrentTenant().Id, u);
|
||||
}
|
||||
|
||||
public async Task<UserInfo> UpdateUserInfoWithSyncCardDavAsync(UserInfo u)
|
||||
{
|
||||
var oldUserData = _userService.GetUserByUserName(_tenantManager.GetCurrentTenant().Id, u.UserName);
|
||||
|
||||
var newUser = UpdateUserInfo(u);
|
||||
await SyncCardDavAsync(u, oldUserData, newUser);
|
||||
|
||||
return newUser;
|
||||
}
|
||||
|
||||
public async Task<UserInfo> SaveUserInfo(UserInfo u, bool isVisitor = false, bool syncCardDav = false)
|
||||
{
|
||||
if (IsSystemUser(u.Id))
|
||||
{
|
||||
return SystemUsers[u.Id];
|
||||
}
|
||||
|
||||
_permissionContext.DemandPermissions(Constants.Action_AddRemoveUser);
|
||||
|
||||
if (!_coreBaseSettings.Personal)
|
||||
{
|
||||
if (_constants.MaxEveryoneCount <= GetUsersByGroup(Constants.GroupEveryone.ID).Length)
|
||||
@ -336,97 +363,96 @@ public class UserManager
|
||||
}
|
||||
}
|
||||
|
||||
if (u.Status == EmployeeStatus.Terminated && u.Id == _tenantManager.GetCurrentTenant().OwnerId)
|
||||
{
|
||||
throw new InvalidOperationException("Can not disable tenant owner.");
|
||||
}
|
||||
|
||||
var oldUserData = _userService.GetUserByUserName(_tenantManager.GetCurrentTenant().Id, u.UserName);
|
||||
|
||||
if (Equals(oldUserData, Constants.LostUser))
|
||||
if (oldUserData != null && !Equals(oldUserData, Constants.LostUser))
|
||||
{
|
||||
if (isUser)
|
||||
{
|
||||
_activeUsersFeatureChecker.CheckAppend().Wait();
|
||||
}
|
||||
else
|
||||
{
|
||||
_tenantQuotaFeatureChecker.CheckAppend().Wait();
|
||||
}
|
||||
throw new InvalidOperationException("User already exist.");
|
||||
}
|
||||
|
||||
if (isVisitor)
|
||||
{
|
||||
await _activeUsersFeatureChecker.CheckAppend();
|
||||
}
|
||||
else
|
||||
{
|
||||
await _countRoomAdminChecker.CheckAppend();
|
||||
}
|
||||
|
||||
var newUser = _userService.SaveUser(_tenantManager.GetCurrentTenant().Id, u);
|
||||
|
||||
if (syncCardDav)
|
||||
{
|
||||
var tenant = _tenantManager.GetCurrentTenant();
|
||||
var myUri = (_accessor?.HttpContext != null) ? _accessor.HttpContext.Request.GetUrlRewriter().ToString() :
|
||||
(_cache.Get<string>("REWRITE_URL" + tenant.Id) != null) ?
|
||||
new Uri(_cache.Get<string>("REWRITE_URL" + tenant.Id)).ToString() : tenant.GetTenantDomain(_coreSettings);
|
||||
await SyncCardDavAsync(u, oldUserData, newUser);
|
||||
}
|
||||
|
||||
var rootAuthorization = _cardDavAddressbook.GetSystemAuthorization();
|
||||
var allUserEmails = GetDavUserEmails().ToList();
|
||||
return newUser;
|
||||
}
|
||||
|
||||
if (oldUserData != null && oldUserData.Status != newUser.Status && newUser.Status == EmployeeStatus.Terminated)
|
||||
private async Task SyncCardDavAsync(UserInfo u, UserInfo oldUserData, UserInfo newUser)
|
||||
{
|
||||
var tenant = _tenantManager.GetCurrentTenant();
|
||||
var myUri = (_accessor?.HttpContext != null) ? _accessor.HttpContext.Request.GetUrlRewriter().ToString() :
|
||||
(_cache.Get<string>("REWRITE_URL" + tenant.Id) != null) ?
|
||||
new Uri(_cache.Get<string>("REWRITE_URL" + tenant.Id)).ToString() : tenant.GetTenantDomain(_coreSettings);
|
||||
|
||||
var rootAuthorization = _cardDavAddressbook.GetSystemAuthorization();
|
||||
var allUserEmails = GetDavUserEmails().ToList();
|
||||
|
||||
if (oldUserData != null && oldUserData.Status != newUser.Status && newUser.Status == EmployeeStatus.Terminated)
|
||||
{
|
||||
var userAuthorization = oldUserData.Email.ToLower() + ":" + _instanceCrypto.Encrypt(oldUserData.Email);
|
||||
var requestUrlBook = _cardDavAddressbook.GetRadicaleUrl(myUri, newUser.Email.ToLower(), true, true);
|
||||
var collection = await _cardDavAddressbook.GetCollection(requestUrlBook, userAuthorization, myUri.ToString());
|
||||
if (collection.Completed && collection.StatusCode != 404)
|
||||
{
|
||||
var userAuthorization = oldUserData.Email.ToLower() + ":" + _instanceCrypto.Encrypt(oldUserData.Email);
|
||||
var requestUrlBook = _cardDavAddressbook.GetRadicaleUrl(myUri, newUser.Email.ToLower(), true, true);
|
||||
var collection = _cardDavAddressbook.GetCollection(requestUrlBook, userAuthorization, myUri.ToString()).Result;
|
||||
if (collection.Completed && collection.StatusCode != 404)
|
||||
{
|
||||
_cardDavAddressbook.Delete(myUri, newUser.Id, newUser.Email, tenant.Id).Wait();//TODO
|
||||
}
|
||||
foreach (var email in allUserEmails)
|
||||
{
|
||||
var requestUrlItem = _cardDavAddressbook.GetRadicaleUrl(myUri.ToString(), email.ToLower(), true, true, itemID: newUser.Id.ToString());
|
||||
try
|
||||
{
|
||||
var davItemRequest = new DavRequest()
|
||||
{
|
||||
Url = requestUrlItem,
|
||||
Authorization = rootAuthorization,
|
||||
Header = myUri
|
||||
};
|
||||
_radicaleClient.RemoveAsync(davItemRequest).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorWithException(ex);
|
||||
}
|
||||
}
|
||||
await _cardDavAddressbook.Delete(myUri, newUser.Id, newUser.Email, tenant.Id);
|
||||
}
|
||||
else
|
||||
foreach (var email in allUserEmails)
|
||||
{
|
||||
|
||||
var requestUrlItem = _cardDavAddressbook.GetRadicaleUrl(myUri.ToString(), email.ToLower(), true, true, itemID: newUser.Id.ToString());
|
||||
try
|
||||
{
|
||||
var cardDavUser = new CardDavItem(u.Id, u.FirstName, u.LastName, u.UserName, u.BirthDate, u.Sex, u.Title, u.Email, u.ContactsList, u.MobilePhone);
|
||||
|
||||
try
|
||||
var davItemRequest = new DavRequest()
|
||||
{
|
||||
_cardDavAddressbook.UpdateItemForAllAddBooks(allUserEmails, myUri, cardDavUser, _tenantManager.GetCurrentTenant().Id, oldUserData != null && oldUserData.Email != newUser.Email ? oldUserData.Email : null).Wait(); // todo
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorWithException(ex);
|
||||
}
|
||||
|
||||
Url = requestUrlItem,
|
||||
Authorization = rootAuthorization,
|
||||
Header = myUri
|
||||
};
|
||||
await _radicaleClient.RemoveAsync(davItemRequest).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorWithException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return newUser;
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
var cardDavUser = new CardDavItem(u.Id, u.FirstName, u.LastName, u.UserName, u.BirthDate, u.Sex, u.Title, u.Email, u.ContactsList, u.MobilePhone);
|
||||
try
|
||||
{
|
||||
await _cardDavAddressbook.UpdateItemForAllAddBooks(allUserEmails, myUri, cardDavUser, _tenantManager.GetCurrentTenant().Id, oldUserData != null && oldUserData.Email != newUser.Email ? oldUserData.Email : null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorWithException(ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorWithException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetDavUserEmails()
|
||||
{
|
||||
return _userService.GetDavUserEmails(_tenantManager.GetCurrentTenant().Id);
|
||||
}
|
||||
|
||||
public void DeleteUser(Guid id)
|
||||
public async Task DeleteUser(Guid id)
|
||||
{
|
||||
if (IsSystemUser(id))
|
||||
{
|
||||
@ -454,7 +480,7 @@ public class UserManager
|
||||
new Uri(_cache.Get<string>("REWRITE_URL" + tenant.Id)).ToString() : tenant.GetTenantDomain(_coreSettings);
|
||||
var davUsersEmails = GetDavUserEmails();
|
||||
var requestUrlBook = _cardDavAddressbook.GetRadicaleUrl(myUri, delUser.Email.ToLower(), true, true);
|
||||
var addBookCollection = _cardDavAddressbook.GetCollection(requestUrlBook, userAuthorization, myUri.ToString()).Result;
|
||||
var addBookCollection = await _cardDavAddressbook.GetCollection(requestUrlBook, userAuthorization, myUri.ToString());
|
||||
|
||||
|
||||
if (addBookCollection.Completed && addBookCollection.StatusCode != 404)
|
||||
@ -465,7 +491,7 @@ public class UserManager
|
||||
Authorization = rootAuthorization,
|
||||
Header = myUri
|
||||
};
|
||||
_radicaleClient.RemoveAsync(davbookRequest).ConfigureAwait(false);
|
||||
await _radicaleClient.RemoveAsync(davbookRequest).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
foreach (var email in davUsersEmails)
|
||||
@ -479,14 +505,13 @@ public class UserManager
|
||||
Authorization = rootAuthorization,
|
||||
Header = myUri
|
||||
};
|
||||
_radicaleClient.RemoveAsync(davItemRequest).ConfigureAwait(false);
|
||||
await _radicaleClient.RemoveAsync(davItemRequest).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_log.ErrorWithException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -600,7 +625,7 @@ public class UserManager
|
||||
return GetUsers(employeeStatus).Where(u => IsUserInGroupInternal(u.Id, groupId, refs)).ToArray();
|
||||
}
|
||||
|
||||
public void AddUserIntoGroup(Guid userId, Guid groupId, bool dontClearAddressBook = false)
|
||||
public async Task AddUserIntoGroup(Guid userId, Guid groupId, bool dontClearAddressBook = false)
|
||||
{
|
||||
if (Constants.LostUser.Id == userId || Constants.LostGroupInfo.ID == groupId)
|
||||
{
|
||||
@ -618,10 +643,10 @@ public class UserManager
|
||||
var myUri = (_accessor?.HttpContext != null) ? _accessor.HttpContext.Request.GetUrlRewriter().ToString() :
|
||||
(_cache.Get<string>("REWRITE_URL" + tenant.Id) != null) ?
|
||||
new Uri(_cache.Get<string>("REWRITE_URL" + tenant.Id)).ToString() : tenant.GetTenantDomain(_coreSettings);
|
||||
|
||||
|
||||
if (!dontClearAddressBook)
|
||||
{
|
||||
_cardDavAddressbook.Delete(myUri, user.Id, user.Email, tenant.Id).Wait(); //todo
|
||||
await _cardDavAddressbook.Delete(myUri, user.Id, user.Email, tenant.Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -646,10 +671,10 @@ public class UserManager
|
||||
new HttpRequestDictionary<List<Guid>>(_accessor?.HttpContext, "GroupInfoID").Reset(userID.ToString());
|
||||
}
|
||||
|
||||
#endregion Users
|
||||
#endregion Users
|
||||
|
||||
|
||||
#region Company
|
||||
#region Company
|
||||
|
||||
public GroupInfo[] GetDepartments()
|
||||
{
|
||||
@ -697,10 +722,10 @@ public class UserManager
|
||||
SetDepartmentManager(Guid.Empty, userId);
|
||||
}
|
||||
|
||||
#endregion Company
|
||||
#endregion Company
|
||||
|
||||
|
||||
#region Groups
|
||||
#region Groups
|
||||
|
||||
public GroupInfo[] GetGroups()
|
||||
{
|
||||
@ -779,7 +804,7 @@ public class UserManager
|
||||
_userService.RemoveGroup(Tenant.Id, id);
|
||||
}
|
||||
|
||||
#endregion Groups
|
||||
#endregion Groups
|
||||
|
||||
|
||||
private bool IsPropertiesContainsWords(IEnumerable<string> properties, IEnumerable<string> words)
|
||||
@ -873,4 +898,4 @@ public class UserManager
|
||||
Sid = g.Sid
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ public class SecurityContext
|
||||
return AuthenticateMe(new UserAccount(u, tenantid, _userFormatter), funcLoginEvent);
|
||||
}
|
||||
|
||||
public bool AuthenticateMe(string cookie)
|
||||
public async Task<bool> AuthenticateMe(string cookie)
|
||||
{
|
||||
if (string.IsNullOrEmpty(cookie)) return false;
|
||||
|
||||
@ -161,7 +161,7 @@ public class SecurityContext
|
||||
return false;
|
||||
}
|
||||
|
||||
var settingLoginEvents = _dbLoginEventsManager.GetLoginEventIds(tenant, userid).Result; // remove Result
|
||||
var settingLoginEvents = await _dbLoginEventsManager.GetLoginEventIds(tenant, userid);
|
||||
if (loginEventId != 0 && !settingLoginEvents.Contains(loginEventId))
|
||||
{
|
||||
return false;
|
||||
|
@ -29,6 +29,6 @@ namespace ASC.Notify.Channels;
|
||||
public interface ISenderChannel
|
||||
{
|
||||
string SenderName { get; }
|
||||
SendResponse DirectSend(INoticeMessage message);
|
||||
void SendAsync(INoticeMessage message);
|
||||
Task<SendResponse> DirectSend(INoticeMessage message);
|
||||
Task SendAsync(INoticeMessage message);
|
||||
}
|
||||
|
@ -45,16 +45,16 @@ public class SenderChannel : ISenderChannel
|
||||
_firstSink = AddSink(_firstSink, dispatcherSink);
|
||||
}
|
||||
|
||||
public void SendAsync(INoticeMessage message)
|
||||
public async Task SendAsync(INoticeMessage message)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(message);
|
||||
|
||||
_firstSink.ProcessMessageAsync(message);
|
||||
await _firstSink.ProcessMessageAsync(message);
|
||||
}
|
||||
|
||||
public SendResponse DirectSend(INoticeMessage message)
|
||||
public async Task<SendResponse> DirectSend(INoticeMessage message)
|
||||
{
|
||||
return _senderSink.ProcessMessage(message);
|
||||
return await _senderSink.ProcessMessage(message);
|
||||
}
|
||||
|
||||
private ISink AddSink(ISink firstSink, ISink addedSink)
|
||||
|
@ -38,7 +38,7 @@ public class EmailSenderSink : Sink
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public override SendResponse ProcessMessage(INoticeMessage message)
|
||||
public override async Task<SendResponse> ProcessMessage(INoticeMessage message)
|
||||
{
|
||||
if (message.Recipient.Addresses == null || message.Recipient.Addresses.Length == 0)
|
||||
{
|
||||
@ -50,7 +50,7 @@ public class EmailSenderSink : Sink
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var m = scope.ServiceProvider.GetRequiredService<EmailSenderSinkMessageCreator>().CreateNotifyMessage(message, _senderName);
|
||||
var result = _sender.Send(m);
|
||||
var result = await _sender.Send(m);
|
||||
|
||||
responce.Result = result switch
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public class DispatchEngine
|
||||
_logger.LogOnly(_logOnly);
|
||||
}
|
||||
|
||||
public SendResponse Dispatch(INoticeMessage message, string senderName)
|
||||
public async Task<SendResponse> Dispatch(INoticeMessage message, string senderName)
|
||||
{
|
||||
var response = new SendResponse(message, senderName, SendResult.OK);
|
||||
if (!_logOnly)
|
||||
@ -51,7 +51,7 @@ public class DispatchEngine
|
||||
var sender = _context.GetSender(senderName);
|
||||
if (sender != null)
|
||||
{
|
||||
response = sender.DirectSend(message);
|
||||
response = await sender.DirectSend(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private void NotifyScheduler(object state)
|
||||
private async void NotifyScheduler(object state)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -124,8 +124,9 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
copy = _sendMethods.ToList();
|
||||
}
|
||||
|
||||
foreach (var w in copy)
|
||||
for (var i = 0; i < copy.Count; i++)
|
||||
{
|
||||
using var w = copy[i];
|
||||
if (!w.ScheduleDate.HasValue)
|
||||
{
|
||||
lock (_sendMethods)
|
||||
@ -138,7 +139,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
w.InvokeSendMethod(now);
|
||||
await w.InvokeSendMethod(now);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
@ -177,7 +178,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
|
||||
|
||||
private void NotifySender(object state)
|
||||
private async void NotifySender(object state)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -201,7 +202,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
|
||||
try
|
||||
{
|
||||
SendNotify(request, scope);
|
||||
await SendNotify(request, scope);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -225,7 +226,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
|
||||
|
||||
private NotifyResult SendNotify(NotifyRequest request, IServiceScope serviceScope)
|
||||
private async Task<NotifyResult> SendNotify(NotifyRequest request, IServiceScope serviceScope)
|
||||
{
|
||||
var sendResponces = new List<SendResponse>();
|
||||
|
||||
@ -236,7 +237,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
else
|
||||
{
|
||||
sendResponces.AddRange(SendGroupNotify(request, serviceScope));
|
||||
sendResponces.AddRange(await SendGroupNotify(request, serviceScope));
|
||||
}
|
||||
|
||||
NotifyResult result;
|
||||
@ -258,15 +259,15 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
return request.Intercept(place, serviceScope) ? new SendResponse(request.NotifyAction, sender, request.Recipient, SendResult.Prevented) : null;
|
||||
}
|
||||
|
||||
private List<SendResponse> SendGroupNotify(NotifyRequest request, IServiceScope serviceScope)
|
||||
private async Task<List<SendResponse>> SendGroupNotify(NotifyRequest request, IServiceScope serviceScope)
|
||||
{
|
||||
var responces = new List<SendResponse>();
|
||||
SendGroupNotify(request, responces, serviceScope);
|
||||
await SendGroupNotify(request, responces, serviceScope);
|
||||
|
||||
return responces;
|
||||
}
|
||||
|
||||
private void SendGroupNotify(NotifyRequest request, List<SendResponse> responces, IServiceScope serviceScope)
|
||||
private async Task SendGroupNotify(NotifyRequest request, List<SendResponse> responces, IServiceScope serviceScope)
|
||||
{
|
||||
if (request.Recipient is IDirectRecipient)
|
||||
{
|
||||
@ -276,7 +277,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
var directresponses = new List<SendResponse>(1);
|
||||
try
|
||||
{
|
||||
directresponses = SendDirectNotify(request, serviceScope);
|
||||
directresponses = await SendDirectNotify(request, serviceScope);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@ -308,7 +309,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
try
|
||||
{
|
||||
var newRequest = request.Split(recipient);
|
||||
SendGroupNotify(newRequest, responces, serviceScope);
|
||||
await SendGroupNotify(newRequest, responces, serviceScope);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@ -334,7 +335,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private List<SendResponse> SendDirectNotify(NotifyRequest request, IServiceScope serviceScope)
|
||||
private async Task<List<SendResponse>> SendDirectNotify(NotifyRequest request, IServiceScope serviceScope)
|
||||
{
|
||||
if (request.Recipient is not IDirectRecipient)
|
||||
{
|
||||
@ -371,7 +372,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
response = SendDirectNotify(request, channel, serviceScope);
|
||||
response = await SendDirectNotify(request, channel, serviceScope);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
@ -396,7 +397,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
return responses;
|
||||
}
|
||||
|
||||
private SendResponse SendDirectNotify(NotifyRequest request, ISenderChannel channel, IServiceScope serviceScope)
|
||||
private async Task<SendResponse> SendDirectNotify(NotifyRequest request, ISenderChannel channel, IServiceScope serviceScope)
|
||||
{
|
||||
if (request.Recipient is not IDirectRecipient)
|
||||
{
|
||||
@ -418,7 +419,7 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
return preventresponse;
|
||||
}
|
||||
|
||||
channel.SendAsync(noticeMessage);
|
||||
await channel.SendAsync(noticeMessage);
|
||||
|
||||
return new SendResponse(noticeMessage, channel.SenderName, SendResult.Inprogress);
|
||||
}
|
||||
@ -585,19 +586,21 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
|
||||
|
||||
private sealed class SendMethodWrapper
|
||||
private sealed class SendMethodWrapper : IDisposable
|
||||
{
|
||||
private readonly object _locker = new object();
|
||||
private readonly SemaphoreSlim _semaphore;
|
||||
private readonly CronExpression _cronExpression;
|
||||
private readonly Action<DateTime> _method;
|
||||
private readonly ILogger _logger;
|
||||
|
||||
public DateTime? ScheduleDate { get; private set; }
|
||||
public ILogger Logger { get; }
|
||||
|
||||
public SendMethodWrapper(Action<DateTime> method, string cron, ILogger log)
|
||||
{
|
||||
_semaphore = new SemaphoreSlim(1);
|
||||
_method = method;
|
||||
Logger = log;
|
||||
_logger = log;
|
||||
|
||||
if (!string.IsNullOrEmpty(cron))
|
||||
{
|
||||
_cronExpression = new CronExpression(cron);
|
||||
@ -617,26 +620,25 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorUpdateScheduleDate(e);
|
||||
_logger.ErrorUpdateScheduleDate(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void InvokeSendMethod(DateTime d)
|
||||
public async Task InvokeSendMethod(DateTime d)
|
||||
{
|
||||
lock (_locker)
|
||||
await _semaphore.WaitAsync();
|
||||
await Task.Run(() =>
|
||||
{
|
||||
Task.Run(() =>
|
||||
try
|
||||
{
|
||||
try
|
||||
{
|
||||
_method(d);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.ErrorInvokeSendMethod(e);
|
||||
}
|
||||
}).Wait();
|
||||
}
|
||||
_method(d);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorInvokeSendMethod(e);
|
||||
}
|
||||
});
|
||||
_semaphore.Release();
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
@ -648,6 +650,11 @@ public class NotifyEngine : INotifyEngine, IDisposable
|
||||
{
|
||||
return _method.GetHashCode();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_semaphore.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
@ -39,7 +39,7 @@ class JabberSenderSink : Sink
|
||||
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public override SendResponse ProcessMessage(INoticeMessage message)
|
||||
public override async Task<SendResponse> ProcessMessage(INoticeMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -53,7 +53,7 @@ class JabberSenderSink : Sink
|
||||
}
|
||||
else
|
||||
{
|
||||
_sender.Send(m);
|
||||
await _sender.Send(m);
|
||||
}
|
||||
|
||||
return new SendResponse(message, _senderName, result);
|
||||
|
@ -43,7 +43,7 @@ class PushSenderSink : Sink
|
||||
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public override SendResponse ProcessMessage(INoticeMessage message)
|
||||
public override async Task<SendResponse> ProcessMessage(INoticeMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -58,7 +58,7 @@ class PushSenderSink : Sink
|
||||
}
|
||||
else
|
||||
{
|
||||
_sender.Send(m);
|
||||
await _sender.Send(m);
|
||||
}
|
||||
|
||||
return new SendResponse(message, Constants.NotifyPushSenderSysName, result);
|
||||
|
@ -31,7 +31,7 @@ namespace ASC.Core.Notify.Senders;
|
||||
[Singletone]
|
||||
public class AWSSender : SmtpSender, IDisposable
|
||||
{
|
||||
private readonly object _locker = new object();
|
||||
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1);
|
||||
private AmazonSimpleEmailServiceClient _amazonEmailServiceClient;
|
||||
private TimeSpan _refreshTimeout;
|
||||
private DateTime _lastRefresh;
|
||||
@ -56,7 +56,7 @@ public class AWSSender : SmtpSender, IDisposable
|
||||
_lastRefresh = DateTime.UtcNow - _refreshTimeout; //set to refresh on first send
|
||||
}
|
||||
|
||||
public override NoticeSendResult Send(NotifyMessage m)
|
||||
public override async Task<NoticeSendResult> Send(NotifyMessage m)
|
||||
{
|
||||
NoticeSendResult result;
|
||||
try
|
||||
@ -71,11 +71,11 @@ public class AWSSender : SmtpSender, IDisposable
|
||||
var configuration = scope.ServiceProvider.GetService<CoreConfiguration>();
|
||||
if (!configuration.SmtpSettings.IsDefaultSettings)
|
||||
{
|
||||
result = base.Send(m);
|
||||
result = await base.Send(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = SendMessage(m);
|
||||
result = await SendMessage(m);
|
||||
}
|
||||
|
||||
_logger.Debug(result.ToString());
|
||||
@ -106,29 +106,28 @@ public class AWSSender : SmtpSender, IDisposable
|
||||
if (result == NoticeSendResult.MessageIncorrect || result == NoticeSendResult.SendingImpossible)
|
||||
{
|
||||
_logger.DebugAmazonSendingFailed(result);
|
||||
result = base.Send(m);
|
||||
result = await base.Send(m);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private NoticeSendResult SendMessage(NotifyMessage m)
|
||||
private async Task<NoticeSendResult> SendMessage(NotifyMessage m)
|
||||
{
|
||||
//Check if we need to query stats
|
||||
RefreshQuotaIfNeeded();
|
||||
await RefreshQuotaIfNeeded();
|
||||
if (_quota != null)
|
||||
{
|
||||
lock (_locker)
|
||||
await _semaphore.WaitAsync();
|
||||
if (_quota.Max24HourSend <= _quota.SentLast24Hours)
|
||||
{
|
||||
if (_quota.Max24HourSend <= _quota.SentLast24Hours)
|
||||
{
|
||||
//Quota exceeded, queue next refresh to +24 hours
|
||||
_lastRefresh = DateTime.UtcNow.AddHours(24);
|
||||
_logger.WarningQuotaLimit(_lastRefresh);
|
||||
//Quota exceeded, queue next refresh to +24 hours
|
||||
_lastRefresh = DateTime.UtcNow.AddHours(24);
|
||||
_logger.WarningQuotaLimit(_lastRefresh);
|
||||
|
||||
return NoticeSendResult.SendingImpossible;
|
||||
}
|
||||
return NoticeSendResult.SendingImpossible;
|
||||
}
|
||||
_semaphore.Release();
|
||||
}
|
||||
|
||||
var dest = new Destination
|
||||
@ -160,7 +159,7 @@ public class AWSSender : SmtpSender, IDisposable
|
||||
|
||||
ThrottleIfNeeded();
|
||||
|
||||
var response = _amazonEmailServiceClient.SendEmailAsync(request).Result;
|
||||
var response = await _amazonEmailServiceClient.SendEmailAsync(request);
|
||||
_lastSend = DateTime.UtcNow;
|
||||
|
||||
return response != null ? NoticeSendResult.OK : NoticeSendResult.TryOnceAgain;
|
||||
@ -182,34 +181,33 @@ public class AWSSender : SmtpSender, IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshQuotaIfNeeded()
|
||||
private async Task RefreshQuotaIfNeeded()
|
||||
{
|
||||
if (!IsRefreshNeeded())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_locker)
|
||||
await _semaphore.WaitAsync();
|
||||
if (IsRefreshNeeded())//Double check
|
||||
{
|
||||
if (IsRefreshNeeded())//Double check
|
||||
{
|
||||
_logger.DebugRefreshingQuota(_refreshTimeout, _lastRefresh);
|
||||
_logger.DebugRefreshingQuota(_refreshTimeout, _lastRefresh);
|
||||
|
||||
//Do quota refresh
|
||||
_lastRefresh = DateTime.UtcNow.AddMinutes(1);
|
||||
try
|
||||
{
|
||||
var r = new GetSendQuotaRequest();
|
||||
_quota = _amazonEmailServiceClient.GetSendQuotaAsync(r).Result;
|
||||
_sendWindow = TimeSpan.FromSeconds(1.0 / _quota.MaxSendRate);
|
||||
_logger.DebugQuota(_quota.SentLast24Hours, _quota.Max24HourSend, _quota.MaxSendRate, _sendWindow);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorRefreshingQuota(e);
|
||||
}
|
||||
//Do quota refresh
|
||||
_lastRefresh = DateTime.UtcNow.AddMinutes(1);
|
||||
try
|
||||
{
|
||||
var r = new GetSendQuotaRequest();
|
||||
_quota = await _amazonEmailServiceClient.GetSendQuotaAsync(r);
|
||||
_sendWindow = TimeSpan.FromSeconds(1.0 / _quota.MaxSendRate);
|
||||
_logger.DebugQuota(_quota.SentLast24Hours, _quota.Max24HourSend, _quota.MaxSendRate, _sendWindow);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorRefreshingQuota(e);
|
||||
}
|
||||
}
|
||||
_semaphore.Release();
|
||||
}
|
||||
|
||||
private bool IsRefreshNeeded()
|
||||
|
@ -29,5 +29,5 @@ namespace ASC.Core.Notify.Senders;
|
||||
public interface INotifySender
|
||||
{
|
||||
void Init(IDictionary<string, string> properties);
|
||||
NoticeSendResult Send(NotifyMessage m);
|
||||
Task<NoticeSendResult> Send(NotifyMessage m);
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public class JabberSender : INotifySender
|
||||
|
||||
public void Init(IDictionary<string, string> properties) { }
|
||||
|
||||
public NoticeSendResult Send(NotifyMessage m)
|
||||
public Task<NoticeSendResult> Send(NotifyMessage m)
|
||||
{
|
||||
var text = m.Content;
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
@ -59,7 +59,7 @@ public class JabberSender : INotifySender
|
||||
_logger.ErrorUnexpected(e);
|
||||
}
|
||||
|
||||
return NoticeSendResult.OK;
|
||||
return Task.FromResult(NoticeSendResult.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,10 +38,10 @@ public class NotifyServiceSender : INotifySender
|
||||
|
||||
public void Init(IDictionary<string, string> properties) { }
|
||||
|
||||
public NoticeSendResult Send(NotifyMessage m)
|
||||
public Task<NoticeSendResult> Send(NotifyMessage m)
|
||||
{
|
||||
_notifyServiceClient.SendNotifyMessage(m);
|
||||
|
||||
return NoticeSendResult.OK;
|
||||
return Task.FromResult(NoticeSendResult.OK);
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class PushSender : INotifySender
|
||||
|
||||
public void Init(IDictionary<string, string> properties) { }
|
||||
|
||||
public NoticeSendResult Send(NotifyMessage m)
|
||||
public Task<NoticeSendResult> Send(NotifyMessage m)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m.Content))
|
||||
{
|
||||
@ -59,7 +59,7 @@ public class PushSender : INotifySender
|
||||
_logger.ErrorUnexpected(e);
|
||||
}
|
||||
|
||||
return NoticeSendResult.OK;
|
||||
return Task.FromResult(NoticeSendResult.OK);
|
||||
}
|
||||
}
|
||||
public static class FirebaseSenderExtension
|
||||
|
@ -57,7 +57,7 @@ public class SmtpSender : INotifySender
|
||||
_initProperties = properties;
|
||||
}
|
||||
|
||||
public virtual NoticeSendResult Send(NotifyMessage m)
|
||||
public virtual Task<NoticeSendResult> Send(NotifyMessage m)
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var tenantManager = scope.ServiceProvider.GetService<TenantManager>();
|
||||
@ -149,7 +149,7 @@ public class SmtpSender : INotifySender
|
||||
smtpClient.Dispose();
|
||||
}
|
||||
|
||||
return result;
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
private void BuildSmtpSettings(CoreConfiguration configuration)
|
||||
|
@ -41,7 +41,7 @@ public class TelegramSender : INotifySender
|
||||
|
||||
public void Init(IDictionary<string, string> properties) { }
|
||||
|
||||
public NoticeSendResult Send(NotifyMessage m)
|
||||
public Task<NoticeSendResult> Send(NotifyMessage m)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m.Content))
|
||||
{
|
||||
@ -59,6 +59,6 @@ public class TelegramSender : INotifySender
|
||||
_logger.ErrorUnexpected(e);
|
||||
}
|
||||
|
||||
return NoticeSendResult.OK;
|
||||
return Task.FromResult(NoticeSendResult.OK);
|
||||
}
|
||||
}
|
||||
|
@ -37,13 +37,13 @@ class DispatchSink : Sink
|
||||
_senderName = senderName;
|
||||
}
|
||||
|
||||
public override SendResponse ProcessMessage(INoticeMessage message)
|
||||
public override Task<SendResponse> ProcessMessage(INoticeMessage message)
|
||||
{
|
||||
return _dispatcher.Dispatch(message, _senderName);
|
||||
}
|
||||
|
||||
public override void ProcessMessageAsync(INoticeMessage message)
|
||||
public override async Task ProcessMessageAsync(INoticeMessage message)
|
||||
{
|
||||
_dispatcher.Dispatch(message, _senderName);
|
||||
await _dispatcher.Dispatch(message, _senderName);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,6 @@ namespace ASC.Notify.Sinks;
|
||||
public interface ISink
|
||||
{
|
||||
ISink NextSink { get; set; }
|
||||
SendResponse ProcessMessage(INoticeMessage message);
|
||||
void ProcessMessageAsync(INoticeMessage message);
|
||||
Task<SendResponse> ProcessMessage(INoticeMessage message);
|
||||
Task ProcessMessageAsync(INoticeMessage message);
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ public abstract class Sink : ISink
|
||||
{
|
||||
public ISink NextSink { get; set; }
|
||||
|
||||
public abstract SendResponse ProcessMessage(INoticeMessage message);
|
||||
public abstract Task<SendResponse> ProcessMessage(INoticeMessage message);
|
||||
|
||||
public virtual void ProcessMessageAsync(INoticeMessage message)
|
||||
public virtual async Task ProcessMessageAsync(INoticeMessage message)
|
||||
{
|
||||
NextSink.ProcessMessageAsync(message);
|
||||
await NextSink.ProcessMessageAsync(message);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ class TelegramSenderSink : Sink
|
||||
}
|
||||
|
||||
|
||||
public override SendResponse ProcessMessage(INoticeMessage message)
|
||||
public override async Task<SendResponse> ProcessMessage(INoticeMessage message)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -47,7 +47,7 @@ class TelegramSenderSink : Sink
|
||||
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var m = scope.ServiceProvider.GetRequiredService<TelegramSenderSinkMessageCreator>().CreateNotifyMessage(message, _senderName);
|
||||
_sender.Send(m);
|
||||
await _sender.Send(m);
|
||||
|
||||
return new SendResponse(message, _senderName, result);
|
||||
}
|
||||
|
@ -76,4 +76,42 @@ public static class ActionInvoker
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task Try(
|
||||
Func<object, Task> action,
|
||||
object state,
|
||||
int maxAttempts,
|
||||
Action<Exception> onFailure = null,
|
||||
Action<Exception> onAttemptFailure = null,
|
||||
int sleepMs = 1000,
|
||||
bool isSleepExponential = true)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(action);
|
||||
|
||||
var countAttempts = 0;
|
||||
while (countAttempts++ < maxAttempts)
|
||||
{
|
||||
try
|
||||
{
|
||||
await action(state);
|
||||
return;
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
if (countAttempts < maxAttempts)
|
||||
{
|
||||
onAttemptFailure?.Invoke(error);
|
||||
|
||||
if (sleepMs > 0)
|
||||
{
|
||||
await Task.Delay(isSleepExponential ? sleepMs * countAttempts : sleepMs);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
onFailure?.Invoke(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -122,25 +122,25 @@ public class BackupAjaxHandler
|
||||
return _backupService.GetBackupProgress(tenantId);
|
||||
}
|
||||
|
||||
public void DeleteBackup(Guid id)
|
||||
public async Task DeleteBackup(Guid id)
|
||||
{
|
||||
DemandPermissionsBackup();
|
||||
|
||||
_backupService.DeleteBackup(id);
|
||||
await _backupService.DeleteBackup(id);
|
||||
}
|
||||
|
||||
public void DeleteAllBackups()
|
||||
public async Task DeleteAllBackups()
|
||||
{
|
||||
DemandPermissionsBackup();
|
||||
|
||||
_backupService.DeleteAllBackups(GetCurrentTenantId());
|
||||
await _backupService.DeleteAllBackups(GetCurrentTenantId());
|
||||
}
|
||||
|
||||
public List<BackupHistoryRecord> GetBackupHistory()
|
||||
public async Task<List<BackupHistoryRecord>> GetBackupHistory()
|
||||
{
|
||||
DemandPermissionsBackup();
|
||||
|
||||
return _backupService.GetBackupHistory(GetCurrentTenantId());
|
||||
return await _backupService.GetBackupHistory(GetCurrentTenantId());
|
||||
}
|
||||
|
||||
public void CreateSchedule(BackupStorageType storageType, Dictionary<string, string> storageParams, int backupsStored, CronParams cronParams)
|
||||
|
@ -32,13 +32,13 @@ public interface IBackupService
|
||||
BackupProgress GetBackupProgress(int tenantId);
|
||||
BackupProgress GetRestoreProgress(int tenantId);
|
||||
BackupProgress GetTransferProgress(int tenantId);
|
||||
List<BackupHistoryRecord> GetBackupHistory(int tenantId);
|
||||
Task<List<BackupHistoryRecord>> GetBackupHistory(int tenantId);
|
||||
List<TransferRegion> GetTransferRegions();
|
||||
ScheduleResponse GetSchedule(int tenantId);
|
||||
string GetTmpFolder();
|
||||
void CreateSchedule(CreateScheduleRequest request);
|
||||
void DeleteAllBackups(int tenantId);
|
||||
void DeleteBackup(Guid backupId);
|
||||
Task DeleteAllBackups(int tenantId);
|
||||
Task DeleteBackup(Guid backupId);
|
||||
void DeleteSchedule(int tenantId);
|
||||
void StartBackup(StartBackupRequest request);
|
||||
void StartRestore(StartRestoreRequest request);
|
||||
|
@ -45,7 +45,7 @@ public class DbBackupProvider : IBackupProvider
|
||||
|
||||
public event EventHandler<ProgressChangedEventArgs> ProgressChanged;
|
||||
|
||||
public IEnumerable<XElement> GetElements(int tenant, string[] configs, IDataWriteOperator writer)
|
||||
public Task<IEnumerable<XElement>> GetElements(int tenant, string[] configs, IDataWriteOperator writer)
|
||||
{
|
||||
_processedTables.Clear();
|
||||
var xml = new List<XElement>();
|
||||
@ -69,18 +69,19 @@ public class DbBackupProvider : IBackupProvider
|
||||
node.Add(BackupDatabase(tenant, connectionString, writer));
|
||||
}
|
||||
}
|
||||
|
||||
return xml;
|
||||
|
||||
return Task.FromResult(xml.AsEnumerable());
|
||||
}
|
||||
|
||||
public void LoadFrom(IEnumerable<XElement> elements, int tenant, string[] configs, IDataReadOperator reader)
|
||||
public Task LoadFrom(IEnumerable<XElement> elements, int tenant, string[] configs, IDataReadOperator reader)
|
||||
{
|
||||
_processedTables.Clear();
|
||||
|
||||
foreach (var connectionString in GetConnectionStrings(configs))
|
||||
{
|
||||
RestoreDatabase(connectionString, elements, reader);
|
||||
}
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public IEnumerable<ConnectionStringSettings> GetConnectionStrings(string[] configs)
|
||||
|
@ -50,12 +50,12 @@ public class FileBackupProvider : IBackupProvider
|
||||
|
||||
public event EventHandler<ProgressChangedEventArgs> ProgressChanged;
|
||||
|
||||
public IEnumerable<XElement> GetElements(int tenant, string[] configs, IDataWriteOperator writer)
|
||||
public async Task<IEnumerable<XElement>> GetElements(int tenant, string[] configs, IDataWriteOperator writer)
|
||||
{
|
||||
InvokeProgressChanged("Saving files...", 0);
|
||||
|
||||
var config = GetWebConfig(configs);
|
||||
var files = ComposeFiles(tenant, config);
|
||||
var files = await ComposeFiles(tenant, config);
|
||||
|
||||
var elements = new List<XElement>();
|
||||
var backupKeys = new List<string>();
|
||||
@ -74,7 +74,7 @@ public class FileBackupProvider : IBackupProvider
|
||||
{
|
||||
try
|
||||
{
|
||||
using var stream = storage.GetReadStreamAsync(file.Domain, file.Path).Result;
|
||||
using var stream = await storage.GetReadStreamAsync(file.Domain, file.Path);
|
||||
writer.WriteEntry(backupPath, stream);
|
||||
break;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class FileBackupProvider : IBackupProvider
|
||||
return elements;
|
||||
}
|
||||
|
||||
public void LoadFrom(IEnumerable<XElement> elements, int tenant, string[] configs, IDataReadOperator dataOperator)
|
||||
public async Task LoadFrom(IEnumerable<XElement> elements, int tenant, string[] configs, IDataReadOperator dataOperator)
|
||||
{
|
||||
InvokeProgressChanged("Restoring files...", 0);
|
||||
|
||||
@ -114,7 +114,7 @@ public class FileBackupProvider : IBackupProvider
|
||||
var storage = _storageFactory.GetStorage(config, tenant, backupInfo.Module, null);
|
||||
try
|
||||
{
|
||||
storage.SaveAsync(backupInfo.Domain, backupInfo.Path, entry).Wait();
|
||||
await storage.SaveAsync(backupInfo.Domain, backupInfo.Path, entry);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
@ -126,7 +126,7 @@ public class FileBackupProvider : IBackupProvider
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<FileBackupInfo> ComposeFiles(int tenant, string config)
|
||||
private async Task<IEnumerable<FileBackupInfo>> ComposeFiles(int tenant, string config)
|
||||
{
|
||||
var files = new List<FileBackupInfo>();
|
||||
foreach (var module in _storageFactoryConfig.GetModuleList(config))
|
||||
@ -138,13 +138,13 @@ public class FileBackupProvider : IBackupProvider
|
||||
|
||||
foreach (var domain in domainList)
|
||||
{
|
||||
files.AddRange(store
|
||||
.ListFilesRelativeAsync(domain, "\\", "*.*", true).ToArrayAsync().Result
|
||||
files.AddRange((await store
|
||||
.ListFilesRelativeAsync(domain, "\\", "*.*", true).ToArrayAsync())
|
||||
.Select(x => new FileBackupInfo(domain, module, x)));
|
||||
}
|
||||
|
||||
files.AddRange(store
|
||||
.ListFilesRelativeAsync(string.Empty, "\\", "*.*", true).ToArrayAsync().Result
|
||||
files.AddRange((await store
|
||||
.ListFilesRelativeAsync(string.Empty, "\\", "*.*", true).ToArrayAsync())
|
||||
.Where(x => domainList.All(domain => x.IndexOf($"{domain}/") == -1))
|
||||
.Select(x => new FileBackupInfo(string.Empty, module, x)));
|
||||
}
|
||||
|
@ -31,8 +31,8 @@ public interface IBackupProvider
|
||||
string Name { get; }
|
||||
event EventHandler<ProgressChangedEventArgs> ProgressChanged;
|
||||
|
||||
IEnumerable<XElement> GetElements(int tenant, string[] configs, IDataWriteOperator writer);
|
||||
void LoadFrom(IEnumerable<XElement> elements, int tenant, string[] configs, IDataReadOperator reader);
|
||||
Task<IEnumerable<XElement>> GetElements(int tenant, string[] configs, IDataWriteOperator writer);
|
||||
Task LoadFrom(IEnumerable<XElement> elements, int tenant, string[] configs, IDataReadOperator reader);
|
||||
}
|
||||
|
||||
public class ProgressChangedEventArgs : EventArgs
|
||||
|
@ -58,7 +58,7 @@ public class BackupService : IBackupService
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteBackup(Guid id)
|
||||
public async Task DeleteBackup(Guid id)
|
||||
{
|
||||
var backupRecord = _backupRepository.GetBackupRecord(id);
|
||||
_backupRepository.DeleteBackupRecord(backupRecord.Id);
|
||||
@ -69,10 +69,10 @@ public class BackupService : IBackupService
|
||||
return;
|
||||
}
|
||||
|
||||
storage.Delete(backupRecord.StoragePath);
|
||||
await storage.Delete(backupRecord.StoragePath);
|
||||
}
|
||||
|
||||
public void DeleteAllBackups(int tenantId)
|
||||
public async Task DeleteAllBackups(int tenantId)
|
||||
{
|
||||
foreach (var backupRecord in _backupRepository.GetBackupRecordsByTenantId(tenantId))
|
||||
{
|
||||
@ -85,7 +85,7 @@ public class BackupService : IBackupService
|
||||
continue;
|
||||
}
|
||||
|
||||
storage.Delete(backupRecord.StoragePath);
|
||||
await storage.Delete(backupRecord.StoragePath);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
@ -94,7 +94,7 @@ public class BackupService : IBackupService
|
||||
}
|
||||
}
|
||||
|
||||
public List<BackupHistoryRecord> GetBackupHistory(int tenantId)
|
||||
public async Task<List<BackupHistoryRecord>> GetBackupHistory(int tenantId)
|
||||
{
|
||||
var backupHistory = new List<BackupHistoryRecord>();
|
||||
foreach (var record in _backupRepository.GetBackupRecordsByTenantId(tenantId))
|
||||
@ -105,7 +105,7 @@ public class BackupService : IBackupService
|
||||
continue;
|
||||
}
|
||||
|
||||
if (storage.IsExists(record.StoragePath))
|
||||
if (await storage.IsExists(record.StoragePath))
|
||||
{
|
||||
backupHistory.Add(new BackupHistoryRecord
|
||||
{
|
||||
|
@ -115,7 +115,7 @@ public class BackupProgressItem : BaseBackupProgressItem
|
||||
_configPaths = configPaths;
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
if (ThreadPriority.BelowNormal < Thread.CurrentThread.Priority)
|
||||
{
|
||||
@ -147,13 +147,13 @@ public class BackupProgressItem : BaseBackupProgressItem
|
||||
PublishChanges();
|
||||
};
|
||||
|
||||
backupTask.RunJob();
|
||||
await backupTask.RunJob();
|
||||
|
||||
var backupStorage = _backupStorageFactory.GetBackupStorage(_storageType, TenantId, StorageParams);
|
||||
if (backupStorage != null)
|
||||
{
|
||||
storagePath = backupStorage.Upload(_storageBasePath, tempFile, _userId);
|
||||
Link = backupStorage.GetPublicLink(storagePath);
|
||||
storagePath = await backupStorage.Upload(_storageBasePath, tempFile, _userId);
|
||||
Link = await backupStorage.GetPublicLink(storagePath);
|
||||
}
|
||||
|
||||
var repo = _backupRepository;
|
||||
|
@ -104,7 +104,7 @@ public class RestoreProgressItem : BaseBackupProgressItem
|
||||
_configPaths = configPaths;
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
Tenant tenant = null;
|
||||
|
||||
@ -129,7 +129,7 @@ public class RestoreProgressItem : BaseBackupProgressItem
|
||||
|
||||
var storage = _backupStorageFactory.GetBackupStorage(StorageType, TenantId, StorageParams);
|
||||
|
||||
storage.Download(StoragePath, tempFile);
|
||||
await storage.Download(StoragePath, tempFile);
|
||||
|
||||
if (!_coreBaseSettings.Standalone)
|
||||
{
|
||||
@ -156,7 +156,7 @@ public class RestoreProgressItem : BaseBackupProgressItem
|
||||
Percentage = Percentage = 10d + 0.65 * args.Progress;
|
||||
PublishChanges();
|
||||
};
|
||||
restoreTask.RunJob();
|
||||
await restoreTask.RunJob();
|
||||
|
||||
Tenant restoredTenant = null;
|
||||
|
||||
|
@ -99,7 +99,7 @@ public class TransferProgressItem : BaseBackupProgressItem
|
||||
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
var tempFile = PathHelper.GetTempFileName(TempFolder);
|
||||
var tenant = _tenantManager.GetTenant(TenantId);
|
||||
@ -121,7 +121,7 @@ public class TransferProgressItem : BaseBackupProgressItem
|
||||
PublishChanges();
|
||||
};
|
||||
|
||||
transferProgressItem.RunJob();
|
||||
await transferProgressItem.RunJob();
|
||||
|
||||
Link = GetLink(alias, false);
|
||||
_notifyHelper.SendAboutTransferComplete(tenant, TargetRegion, Link, !Notify, transferProgressItem.ToTenantId);
|
||||
|
@ -43,36 +43,36 @@ public class ConsumerBackupStorage : IBackupStorage
|
||||
{
|
||||
var settings = new StorageSettings { Module = storageParams["module"], Props = storageParams.Where(r => r.Key != "module").ToDictionary(r => r.Key, r => r.Value) };
|
||||
_store = _storageSettingsHelper.DataStore(settings);
|
||||
}
|
||||
|
||||
public string Upload(string storageBasePath, string localPath, Guid userId)
|
||||
}
|
||||
|
||||
public async Task<string> Upload(string storageBasePath, string localPath, Guid userId)
|
||||
{
|
||||
using var stream = File.OpenRead(localPath);
|
||||
var storagePath = Path.GetFileName(localPath);
|
||||
_store.SaveAsync(Domain, storagePath, stream, ACL.Private).Wait();
|
||||
await _store.SaveAsync(Domain, storagePath, stream, ACL.Private);
|
||||
return storagePath;
|
||||
}
|
||||
|
||||
public void Download(string storagePath, string targetLocalPath)
|
||||
public async Task Download(string storagePath, string targetLocalPath)
|
||||
{
|
||||
using var source = _store.GetReadStreamAsync(Domain, storagePath).Result;
|
||||
using var source = await _store.GetReadStreamAsync(Domain, storagePath);
|
||||
using var destination = File.OpenWrite(targetLocalPath);
|
||||
source.CopyTo(destination);
|
||||
await source.CopyToAsync(destination);
|
||||
}
|
||||
|
||||
public void Delete(string storagePath)
|
||||
public async Task Delete(string storagePath)
|
||||
{
|
||||
if (_store.IsFileAsync(Domain, storagePath).Result)
|
||||
if (await _store.IsFileAsync(Domain, storagePath))
|
||||
{
|
||||
_store.DeleteAsync(Domain, storagePath).Wait();
|
||||
await _store.DeleteAsync(Domain, storagePath);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExists(string storagePath)
|
||||
public async Task<bool> IsExists(string storagePath)
|
||||
{
|
||||
if (_store != null)
|
||||
{
|
||||
return _store.IsFileAsync(Domain, storagePath).Result;
|
||||
return await _store.IsFileAsync(Domain, storagePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -80,8 +80,8 @@ public class ConsumerBackupStorage : IBackupStorage
|
||||
}
|
||||
}
|
||||
|
||||
public string GetPublicLink(string storagePath)
|
||||
public async Task<string> GetPublicLink(string storagePath)
|
||||
{
|
||||
return _store.GetInternalUriAsync(Domain, storagePath, TimeSpan.FromDays(1), null).Result.AbsoluteUri;
|
||||
return (await _store.GetInternalUriAsync(Domain, storagePath, TimeSpan.FromDays(1), null)).AbsoluteUri;
|
||||
}
|
||||
}
|
||||
|
@ -42,41 +42,41 @@ public class DataStoreBackupStorage : IBackupStorage
|
||||
{
|
||||
_webConfigPath = webConfigPath;
|
||||
_tenant = tenant;
|
||||
}
|
||||
|
||||
public string Upload(string storageBasePath, string localPath, Guid userId)
|
||||
}
|
||||
|
||||
public async Task<string> Upload(string storageBasePath, string localPath, Guid userId)
|
||||
{
|
||||
using var stream = File.OpenRead(localPath);
|
||||
var storagePath = Path.GetFileName(localPath);
|
||||
GetDataStore().SaveAsync("", storagePath, stream).Wait();
|
||||
await GetDataStore().SaveAsync("", storagePath, stream);
|
||||
|
||||
return storagePath;
|
||||
}
|
||||
|
||||
public void Download(string storagePath, string targetLocalPath)
|
||||
public async Task Download(string storagePath, string targetLocalPath)
|
||||
{
|
||||
using var source = GetDataStore().GetReadStreamAsync("", storagePath).Result;
|
||||
using var source = await GetDataStore().GetReadStreamAsync("", storagePath);
|
||||
using var destination = File.OpenWrite(targetLocalPath);
|
||||
source.CopyTo(destination);
|
||||
}
|
||||
|
||||
public void Delete(string storagePath)
|
||||
public async Task Delete(string storagePath)
|
||||
{
|
||||
var dataStore = GetDataStore();
|
||||
if (dataStore.IsFileAsync("", storagePath).Result)
|
||||
if (await dataStore.IsFileAsync("", storagePath))
|
||||
{
|
||||
dataStore.DeleteAsync("", storagePath).Wait();
|
||||
await dataStore.DeleteAsync("", storagePath);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExists(string storagePath)
|
||||
public async Task<bool> IsExists(string storagePath)
|
||||
{
|
||||
return GetDataStore().IsFileAsync("", storagePath).Result;
|
||||
return await GetDataStore().IsFileAsync("", storagePath);
|
||||
}
|
||||
|
||||
public string GetPublicLink(string storagePath)
|
||||
public async Task<string> GetPublicLink(string storagePath)
|
||||
{
|
||||
return GetDataStore().GetPreSignedUriAsync("", storagePath, TimeSpan.FromDays(1), null).Result.ToString();
|
||||
return (await GetDataStore().GetPreSignedUriAsync("", storagePath, TimeSpan.FromDays(1), null)).ToString();
|
||||
}
|
||||
|
||||
protected virtual IDataStore GetDataStore()
|
||||
|
@ -58,9 +58,9 @@ public class DocumentsBackupStorage : IBackupStorage
|
||||
{
|
||||
_tenantId = tenantId;
|
||||
_webConfigPath = webConfigPath;
|
||||
}
|
||||
|
||||
public string Upload(string folderId, string localPath, Guid userId)
|
||||
}
|
||||
|
||||
public async Task<string> Upload(string folderId, string localPath, Guid userId)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(_tenantId);
|
||||
if (!userId.Equals(Guid.Empty))
|
||||
@ -75,62 +75,62 @@ public class DocumentsBackupStorage : IBackupStorage
|
||||
|
||||
if (int.TryParse(folderId, out var fId))
|
||||
{
|
||||
return Upload(fId, localPath).ToString();
|
||||
return (await Upload(fId, localPath)).ToString();
|
||||
}
|
||||
|
||||
return Upload(folderId, localPath);
|
||||
return await Upload(folderId, localPath);
|
||||
}
|
||||
|
||||
public void Download(string fileId, string targetLocalPath)
|
||||
public async Task Download(string fileId, string targetLocalPath)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(_tenantId);
|
||||
|
||||
if (int.TryParse(fileId, out var fId))
|
||||
{
|
||||
DownloadDao(fId, targetLocalPath);
|
||||
await DownloadDao(fId, targetLocalPath);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
DownloadDao(fileId, targetLocalPath);
|
||||
await DownloadDao(fileId, targetLocalPath);
|
||||
}
|
||||
|
||||
public void Delete(string fileId)
|
||||
public async Task Delete(string fileId)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(_tenantId);
|
||||
|
||||
if (int.TryParse(fileId, out var fId))
|
||||
{
|
||||
DeleteDao(fId);
|
||||
await DeleteDao(fId);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
DeleteDao(fileId);
|
||||
await DeleteDao(fileId);
|
||||
}
|
||||
|
||||
public bool IsExists(string fileId)
|
||||
public async Task<bool> IsExists(string fileId)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(_tenantId);
|
||||
if (int.TryParse(fileId, out var fId))
|
||||
{
|
||||
return IsExistsDao(fId);
|
||||
return await IsExistsDao(fId);
|
||||
}
|
||||
|
||||
return IsExistsDao(fileId);
|
||||
return await IsExistsDao(fileId);
|
||||
}
|
||||
|
||||
public string GetPublicLink(string fileId)
|
||||
public Task<string> GetPublicLink(string fileId)
|
||||
{
|
||||
return string.Empty;
|
||||
return Task.FromResult(String.Empty);
|
||||
}
|
||||
|
||||
private T Upload<T>(T folderId, string localPath)
|
||||
private async Task<T> Upload<T>(T folderId, string localPath)
|
||||
{
|
||||
var folderDao = GetFolderDao<T>();
|
||||
var fileDao = GetFileDao<T>();
|
||||
|
||||
var folder = folderDao.GetFolderAsync(folderId).Result;
|
||||
var folder = await folderDao.GetFolderAsync(folderId);
|
||||
if (folder == null)
|
||||
{
|
||||
throw new FileNotFoundException("Folder not found.");
|
||||
@ -144,52 +144,52 @@ public class DocumentsBackupStorage : IBackupStorage
|
||||
|
||||
File<T> file = null;
|
||||
var buffer = new byte[_setupInfo.ChunkUploadSize];
|
||||
var chunkedUploadSession = fileDao.CreateUploadSessionAsync(newFile, source.Length).Result;
|
||||
var chunkedUploadSession = await fileDao.CreateUploadSessionAsync(newFile, source.Length);
|
||||
chunkedUploadSession.CheckQuota = false;
|
||||
|
||||
int bytesRead;
|
||||
|
||||
while ((bytesRead = source.Read(buffer, 0, (int)_setupInfo.ChunkUploadSize)) > 0)
|
||||
while ((bytesRead = await source.ReadAsync(buffer, 0, (int)_setupInfo.ChunkUploadSize)) > 0)
|
||||
{
|
||||
using (var theMemStream = new MemoryStream())
|
||||
{
|
||||
theMemStream.Write(buffer, 0, bytesRead);
|
||||
await theMemStream.WriteAsync(buffer, 0, bytesRead);
|
||||
theMemStream.Position = 0;
|
||||
file = fileDao.UploadChunkAsync(chunkedUploadSession, theMemStream, bytesRead).Result;
|
||||
file = await fileDao.UploadChunkAsync(chunkedUploadSession, theMemStream, bytesRead);
|
||||
}
|
||||
}
|
||||
|
||||
return file.Id;
|
||||
}
|
||||
|
||||
private void DownloadDao<T>(T fileId, string targetLocalPath)
|
||||
private async Task DownloadDao<T>(T fileId, string targetLocalPath)
|
||||
{
|
||||
_tenantManager.SetCurrentTenant(_tenantId);
|
||||
var fileDao = GetFileDao<T>();
|
||||
var file = fileDao.GetFileAsync(fileId).Result;
|
||||
var file = await fileDao.GetFileAsync(fileId);
|
||||
if (file == null)
|
||||
{
|
||||
throw new FileNotFoundException("File not found.");
|
||||
}
|
||||
|
||||
using var source = fileDao.GetFileStreamAsync(file).Result;
|
||||
using var source = await fileDao.GetFileStreamAsync(file);
|
||||
using var destination = File.OpenWrite(targetLocalPath);
|
||||
source.CopyTo(destination);
|
||||
await source.CopyToAsync(destination);
|
||||
}
|
||||
|
||||
private void DeleteDao<T>(T fileId)
|
||||
private async Task DeleteDao<T>(T fileId)
|
||||
{
|
||||
var fileDao = GetFileDao<T>();
|
||||
fileDao.DeleteFileAsync(fileId).Wait();
|
||||
await fileDao.DeleteFileAsync(fileId);
|
||||
}
|
||||
|
||||
private bool IsExistsDao<T>(T fileId)
|
||||
private async Task<bool> IsExistsDao<T>(T fileId)
|
||||
{
|
||||
var fileDao = GetFileDao<T>();
|
||||
try
|
||||
{
|
||||
|
||||
var file = fileDao.GetFileAsync(fileId).Result;
|
||||
var file = await fileDao.GetFileAsync(fileId);
|
||||
|
||||
return file != null && file.RootFolderType != FolderType.TRASH;
|
||||
}
|
||||
|
@ -28,9 +28,9 @@ namespace ASC.Data.Backup.Storage;
|
||||
|
||||
public interface IBackupStorage
|
||||
{
|
||||
bool IsExists(string storagePath);
|
||||
string GetPublicLink(string storagePath);
|
||||
string Upload(string storageBasePath, string localPath, Guid userId);
|
||||
void Delete(string storagePath);
|
||||
void Download(string storagePath, string targetLocalPath);
|
||||
Task<bool> IsExists(string storagePath);
|
||||
Task<string> GetPublicLink(string storagePath);
|
||||
Task<string> Upload(string storageBasePath, string localPath, Guid userId);
|
||||
Task Delete(string storagePath);
|
||||
Task Download(string storagePath, string targetLocalPath);
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace ASC.Data.Backup.Storage;
|
||||
[Scope]
|
||||
public class LocalBackupStorage : IBackupStorage
|
||||
{
|
||||
public string Upload(string storageBasePath, string localPath, Guid userId)
|
||||
public Task<string> Upload(string storageBasePath, string localPath, Guid userId)
|
||||
{
|
||||
if (!Directory.Exists(storageBasePath))
|
||||
{
|
||||
@ -42,26 +42,28 @@ public class LocalBackupStorage : IBackupStorage
|
||||
File.Copy(localPath, storagePath, true);
|
||||
}
|
||||
|
||||
return storagePath;
|
||||
return Task.FromResult(storagePath);
|
||||
}
|
||||
|
||||
public void Download(string storagePath, string targetLocalPath)
|
||||
public Task Download(string storagePath, string targetLocalPath)
|
||||
{
|
||||
File.Copy(storagePath, targetLocalPath, true);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public void Delete(string storagePath)
|
||||
public Task Delete(string storagePath)
|
||||
{
|
||||
File.Delete(storagePath);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public bool IsExists(string storagePath)
|
||||
public Task<bool> IsExists(string storagePath)
|
||||
{
|
||||
return File.Exists(storagePath);
|
||||
return Task.FromResult(File.Exists(storagePath));
|
||||
}
|
||||
|
||||
public string GetPublicLink(string storagePath)
|
||||
public Task<string> GetPublicLink(string storagePath)
|
||||
{
|
||||
return string.Empty;
|
||||
return Task.FromResult(string.Empty);
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ internal class S3BackupStorage : IBackupStorage
|
||||
_region = region;
|
||||
}
|
||||
|
||||
public string Upload(string storageBasePath, string localPath, Guid userId)
|
||||
public async Task<string> Upload(string storageBasePath, string localPath, Guid userId)
|
||||
{
|
||||
string key;
|
||||
|
||||
@ -58,7 +58,7 @@ internal class S3BackupStorage : IBackupStorage
|
||||
|
||||
using (var fileTransferUtility = new TransferUtility(_accessKeyId, _secretAccessKey, RegionEndpoint.GetBySystemName(_region)))
|
||||
{
|
||||
fileTransferUtility.Upload(
|
||||
await fileTransferUtility.UploadAsync(
|
||||
new TransferUtilityUploadRequest
|
||||
{
|
||||
BucketName = _bucket,
|
||||
@ -73,7 +73,7 @@ internal class S3BackupStorage : IBackupStorage
|
||||
return key;
|
||||
}
|
||||
|
||||
public void Download(string storagePath, string targetLocalPath)
|
||||
public async Task Download(string storagePath, string targetLocalPath)
|
||||
{
|
||||
var request = new GetObjectRequest
|
||||
{
|
||||
@ -82,27 +82,27 @@ internal class S3BackupStorage : IBackupStorage
|
||||
};
|
||||
|
||||
using var s3 = GetClient();
|
||||
using var response = s3.GetObjectAsync(request).Result;
|
||||
response.WriteResponseStreamToFileAsync(targetLocalPath, true, new CancellationToken());
|
||||
using var response = await s3.GetObjectAsync(request);
|
||||
await response.WriteResponseStreamToFileAsync(targetLocalPath, true, new CancellationToken());
|
||||
}
|
||||
|
||||
public void Delete(string storagePath)
|
||||
public async Task Delete(string storagePath)
|
||||
{
|
||||
using var s3 = GetClient();
|
||||
s3.DeleteObjectAsync(new DeleteObjectRequest
|
||||
await s3.DeleteObjectAsync(new DeleteObjectRequest
|
||||
{
|
||||
BucketName = _bucket,
|
||||
Key = GetKey(storagePath)
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsExists(string storagePath)
|
||||
public async Task<bool> IsExists(string storagePath)
|
||||
{
|
||||
using var s3 = GetClient();
|
||||
try
|
||||
{
|
||||
var request = new ListObjectsRequest { BucketName = _bucket, Prefix = GetKey(storagePath) };
|
||||
var response = s3.ListObjectsAsync(request).Result;
|
||||
var response = await s3.ListObjectsAsync(request);
|
||||
|
||||
return response.S3Objects.Count > 0;
|
||||
}
|
||||
@ -114,18 +114,18 @@ internal class S3BackupStorage : IBackupStorage
|
||||
}
|
||||
}
|
||||
|
||||
public string GetPublicLink(string storagePath)
|
||||
public Task<string> GetPublicLink(string storagePath)
|
||||
{
|
||||
using var s3 = GetClient();
|
||||
|
||||
return s3.GetPreSignedURL(
|
||||
using var s3 = GetClient();
|
||||
|
||||
return Task.FromResult(s3.GetPreSignedURL(
|
||||
new GetPreSignedUrlRequest
|
||||
{
|
||||
BucketName = _bucket,
|
||||
Key = GetKey(storagePath),
|
||||
Expires = DateTime.UtcNow.AddDays(1),
|
||||
Verb = HttpVerb.GET
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
private string GetKey(string fileName)
|
||||
|
@ -70,7 +70,7 @@ public class BackupPortalTask : PortalTaskBase
|
||||
|
||||
}
|
||||
|
||||
public override void RunJob()
|
||||
public override async Task RunJob()
|
||||
{
|
||||
_logger.DebugBeginBackup(TenantId);
|
||||
_tenantManager.SetCurrentTenant(TenantId);
|
||||
@ -80,13 +80,13 @@ public class BackupPortalTask : PortalTaskBase
|
||||
{
|
||||
if (_dump)
|
||||
{
|
||||
DoDump(writer);
|
||||
await DoDump(writer);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
var modulesToProcess = GetModulesToProcess().ToList();
|
||||
var fileGroups = GetFilesGroup();
|
||||
var fileGroups = await GetFilesGroup();
|
||||
|
||||
var stepscount = ProcessStorage ? fileGroups.Count : 0;
|
||||
SetStepsCount(modulesToProcess.Count + stepscount);
|
||||
@ -97,7 +97,7 @@ public class BackupPortalTask : PortalTaskBase
|
||||
}
|
||||
if (ProcessStorage)
|
||||
{
|
||||
DoBackupStorage(writer, fileGroups);
|
||||
await DoBackupStorage(writer, fileGroups);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,7 +121,7 @@ public class BackupPortalTask : PortalTaskBase
|
||||
return list;
|
||||
}
|
||||
|
||||
private void DoDump(IDataWriteOperator writer)
|
||||
private async Task DoDump(IDataWriteOperator writer)
|
||||
{
|
||||
var databases = new Dictionary<Tuple<string, string>, List<string>>();
|
||||
|
||||
@ -173,7 +173,7 @@ public class BackupPortalTask : PortalTaskBase
|
||||
var tenants = _tenantManager.GetTenants(false).Select(r => r.Id);
|
||||
foreach (var t in tenants)
|
||||
{
|
||||
files.AddRange(GetFiles(t));
|
||||
files.AddRange(await GetFiles(t));
|
||||
}
|
||||
|
||||
stepscount += files.Count * 2 + 1;
|
||||
@ -258,9 +258,9 @@ public class BackupPortalTask : PortalTaskBase
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<BackupFileInfo> GetFiles(int tenantId)
|
||||
private async Task<IEnumerable<BackupFileInfo>> GetFiles(int tenantId)
|
||||
{
|
||||
var files = GetFilesToProcess(tenantId).ToList();
|
||||
var files = (await GetFilesToProcess(tenantId)).ToList();
|
||||
using var backupRecordContext = _dbContextFactory.CreateDbContext();
|
||||
var exclude = backupRecordContext.Backups.AsQueryable().Where(b => b.TenantId == tenantId && b.StorageType == 0 && b.StoragePath != null).ToList();
|
||||
files = files.Where(f => !exclude.Any(e => f.Path.Replace('\\', '/').Contains($"/file_{e.StoragePath}/"))).ToList();
|
||||
@ -621,9 +621,9 @@ public class BackupPortalTask : PortalTaskBase
|
||||
_logger.DebugArchiveDirEnd(subDir);
|
||||
}
|
||||
|
||||
private List<IGrouping<string, BackupFileInfo>> GetFilesGroup()
|
||||
private async Task<List<IGrouping<string, BackupFileInfo>>> GetFilesGroup()
|
||||
{
|
||||
var files = GetFilesToProcess(TenantId).ToList();
|
||||
var files = (await GetFilesToProcess(TenantId)).ToList();
|
||||
|
||||
using var backupRecordContext = _dbContextFactory.CreateDbContext();
|
||||
var exclude = backupRecordContext.Backups.AsQueryable().Where(b => b.TenantId == TenantId && b.StorageType == 0 && b.StoragePath != null).ToList();
|
||||
@ -697,7 +697,7 @@ public class BackupPortalTask : PortalTaskBase
|
||||
_logger.DebugEndSavingDataForModule(module.ModuleName);
|
||||
}
|
||||
|
||||
private void DoBackupStorage(IDataWriteOperator writer, List<IGrouping<string, BackupFileInfo>> fileGroups)
|
||||
private async Task DoBackupStorage(IDataWriteOperator writer, List<IGrouping<string, BackupFileInfo>> fileGroups)
|
||||
{
|
||||
_logger.DebugBeginBackupStorage();
|
||||
|
||||
@ -710,10 +710,10 @@ public class BackupPortalTask : PortalTaskBase
|
||||
{
|
||||
var storage = StorageFactory.GetStorage(ConfigPath, TenantId, group.Key);
|
||||
var file1 = file;
|
||||
ActionInvoker.Try(state =>
|
||||
await ActionInvoker.Try(async state =>
|
||||
{
|
||||
var f = (BackupFileInfo)state;
|
||||
using var fileStream = storage.GetReadStreamAsync(f.Domain, f.Path).Result;
|
||||
using var fileStream = await storage.GetReadStreamAsync(f.Domain, f.Path);
|
||||
writer.WriteEntry(file1.GetZipKey(), fileStream);
|
||||
}, file, 5, error => _logger.WarningCanNotBackupFile(file1.Module, file1.Path, error));
|
||||
|
||||
|
@ -44,7 +44,7 @@ public class DeletePortalTask : PortalTaskBase
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public override void RunJob()
|
||||
public override async Task RunJob()
|
||||
{
|
||||
_logger.DebugBeginDelete(TenantId);
|
||||
var modulesToProcess = GetModulesToProcess().Reverse().ToList();
|
||||
@ -57,7 +57,7 @@ public class DeletePortalTask : PortalTaskBase
|
||||
|
||||
if (ProcessStorage)
|
||||
{
|
||||
DoDeleteStorage();
|
||||
await DoDeleteStorage();
|
||||
}
|
||||
|
||||
_logger.DebugEndDelete(TenantId);
|
||||
@ -84,7 +84,7 @@ public class DeletePortalTask : PortalTaskBase
|
||||
_logger.DebugEndDeleteDataForModule(module.ModuleName);
|
||||
}
|
||||
|
||||
private void DoDeleteStorage()
|
||||
private async Task DoDeleteStorage()
|
||||
{
|
||||
_logger.DebugBeginDeleteStorage();
|
||||
var storageModules = StorageFactoryConfig.GetModuleList(ConfigPath).Where(IsStorageModuleAllowed).ToList();
|
||||
@ -95,10 +95,10 @@ public class DeletePortalTask : PortalTaskBase
|
||||
var domains = StorageFactoryConfig.GetDomainList(ConfigPath, module);
|
||||
foreach (var domain in domains)
|
||||
{
|
||||
ActionInvoker.Try(state => storage.DeleteFilesAsync((string)state, "\\", "*.*", true).Wait(), domain, 5,
|
||||
await ActionInvoker.Try(async state => await storage.DeleteFilesAsync((string)state, "\\", "*.*", true), domain, 5,
|
||||
onFailure: error => _logger.WarningCanNotDeleteFilesForDomain(domain, error));
|
||||
}
|
||||
storage.DeleteFilesAsync("\\", "*.*", true).Wait();
|
||||
await storage.DeleteFilesAsync("\\", "*.*", true);
|
||||
SetCurrentStepProgress((int)(++modulesProcessed * 100 / (double)storageModules.Count));
|
||||
}
|
||||
|
||||
|
@ -85,14 +85,14 @@ public abstract class PortalTaskBase
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void RunJob();
|
||||
public abstract Task RunJob();
|
||||
|
||||
internal virtual IEnumerable<IModuleSpecifics> GetModulesToProcess()
|
||||
{
|
||||
return ModuleProvider.AllModules.Where(module => !_ignoredModules.Contains(module.ModuleName));
|
||||
}
|
||||
|
||||
protected IEnumerable<BackupFileInfo> GetFilesToProcess(int tenantId)
|
||||
protected async Task<IEnumerable<BackupFileInfo>> GetFilesToProcess(int tenantId)
|
||||
{
|
||||
var files = new List<BackupFileInfo>();
|
||||
foreach (var module in StorageFactoryConfig.GetModuleList(ConfigPath).Where(IsStorageModuleAllowed))
|
||||
@ -103,12 +103,12 @@ public abstract class PortalTaskBase
|
||||
foreach (var domain in domains)
|
||||
{
|
||||
files.AddRange(
|
||||
store.ListFilesRelativeAsync(domain, "\\", "*.*", true).ToArrayAsync().Result
|
||||
(await store.ListFilesRelativeAsync(domain, "\\", "*.*", true).ToArrayAsync())
|
||||
.Select(path => new BackupFileInfo(domain, module, path, tenantId)));
|
||||
}
|
||||
|
||||
files.AddRange(
|
||||
store.ListFilesRelativeAsync(string.Empty, "\\", "*.*", true).ToArrayAsync().Result
|
||||
(await store.ListFilesRelativeAsync(string.Empty, "\\", "*.*", true).ToArrayAsync())
|
||||
.Where(path => domains.All(domain => !path.Contains(domain + "/")))
|
||||
.Select(path => new BackupFileInfo(string.Empty, module, path, tenantId)));
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ public class RestoreDbModuleTask : PortalTaskBase
|
||||
Init(-1, null);
|
||||
}
|
||||
|
||||
public override void RunJob()
|
||||
public override Task RunJob()
|
||||
{
|
||||
_logger.DebugBeginRestoreDataForModule(_module.ModuleName);
|
||||
SetStepsCount(_module.Tables.Count(t => !_ignoredTables.Contains(t.Name)));
|
||||
@ -85,7 +85,8 @@ public class RestoreDbModuleTask : PortalTaskBase
|
||||
}
|
||||
}
|
||||
|
||||
_logger.DebugEndRestoreDataForModule(_module.ModuleName);
|
||||
_logger.DebugEndRestoreDataForModule(_module.ModuleName);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public string[] ExecuteArray(DbCommand command)
|
||||
|
@ -79,7 +79,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
Init(tenantId, toConfigPath);
|
||||
}
|
||||
|
||||
public override void RunJob()
|
||||
public override async Task RunJob()
|
||||
{
|
||||
_options.DebugBeginRestorePortal();
|
||||
|
||||
@ -94,7 +94,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
|
||||
if (Dump)
|
||||
{
|
||||
RestoreFromDump(dataReader);
|
||||
await RestoreFromDump(dataReader);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -111,7 +111,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
restoreTask.IgnoreTable(tableName);
|
||||
}
|
||||
|
||||
restoreTask.RunJob();
|
||||
await restoreTask.RunJob();
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
_ascCacheNotify.ClearCache();
|
||||
}
|
||||
|
||||
DoRestoreStorage(dataReader);
|
||||
await DoRestoreStorage(dataReader);
|
||||
}
|
||||
|
||||
if (UnblockPortalAfterCompleted)
|
||||
@ -153,7 +153,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
_options.DebugEndRestorePortal();
|
||||
}
|
||||
|
||||
private void RestoreFromDump(IDataReadOperator dataReader)
|
||||
private async Task RestoreFromDump(IDataReadOperator dataReader)
|
||||
{
|
||||
var keyBase = KeyHelper.GetDatabaseSchema();
|
||||
var keys = dataReader.GetEntries(keyBase).Select(r => Path.GetFileName(r)).ToList();
|
||||
@ -187,7 +187,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
|
||||
SetStepsCount(stepscount + 1);
|
||||
|
||||
DoDeleteStorage(storageModules, tenants);
|
||||
await DoDeleteStorage(storageModules, tenants);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -343,7 +343,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
}
|
||||
}
|
||||
|
||||
private void DoRestoreStorage(IDataReadOperator dataReader)
|
||||
private async Task DoRestoreStorage(IDataReadOperator dataReader)
|
||||
{
|
||||
_options.DebugBeginRestoreStorage();
|
||||
|
||||
@ -371,7 +371,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
using var stream = dataReader.GetEntry(key);
|
||||
try
|
||||
{
|
||||
storage.SaveAsync(file.Domain, adjustedPath, module != null ? module.PrepareData(key, stream, _columnMapper) : stream).Wait();
|
||||
await storage.SaveAsync(file.Domain, adjustedPath, module != null ? module.PrepareData(key, stream, _columnMapper) : stream);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
@ -399,7 +399,7 @@ public class RestorePortalTask : PortalTaskBase
|
||||
_options.DebugEndRestoreStorage();
|
||||
}
|
||||
|
||||
private void DoDeleteStorage(IEnumerable<string> storageModules, IEnumerable<Tenant> tenants)
|
||||
private async Task DoDeleteStorage(IEnumerable<string> storageModules, IEnumerable<Tenant> tenants)
|
||||
{
|
||||
_options.DebugBeginDeleteStorage();
|
||||
|
||||
@ -414,12 +414,12 @@ public class RestorePortalTask : PortalTaskBase
|
||||
|
||||
foreach (var domain in domains)
|
||||
{
|
||||
ActionInvoker.Try(
|
||||
state =>
|
||||
await ActionInvoker.Try(
|
||||
async state =>
|
||||
{
|
||||
if (storage.IsDirectoryAsync((string)state).Result)
|
||||
if (await storage.IsDirectoryAsync((string)state))
|
||||
{
|
||||
storage.DeleteFilesAsync((string)state, "\\", "*.*", true).Wait();
|
||||
await storage.DeleteFilesAsync((string)state, "\\", "*.*", true);
|
||||
}
|
||||
},
|
||||
domain,
|
||||
|
@ -74,7 +74,7 @@ public class TransferPortalTask : PortalTaskBase
|
||||
BackupDirectory = backupDirectory;
|
||||
}
|
||||
|
||||
public override void RunJob()
|
||||
public override async Task RunJob()
|
||||
{
|
||||
_logger.DebugBeginTransfer(TenantId);
|
||||
var fromDbFactory = new DbFactory(null, null);
|
||||
@ -103,7 +103,7 @@ public class TransferPortalTask : PortalTaskBase
|
||||
{
|
||||
backupTask.IgnoreModule(moduleName);
|
||||
}
|
||||
backupTask.RunJob();
|
||||
await backupTask.RunJob();
|
||||
|
||||
//restore db data from temporary file
|
||||
var restoreTask = _serviceProvider.GetService<RestorePortalTask>();
|
||||
@ -114,12 +114,12 @@ public class TransferPortalTask : PortalTaskBase
|
||||
{
|
||||
restoreTask.IgnoreModule(moduleName);
|
||||
}
|
||||
restoreTask.RunJob();
|
||||
await restoreTask.RunJob();
|
||||
|
||||
//transfer files
|
||||
if (ProcessStorage)
|
||||
{
|
||||
DoTransferStorage(columnMapper);
|
||||
await DoTransferStorage(columnMapper);
|
||||
}
|
||||
|
||||
SaveTenant(toDbFactory, tenantAlias, TenantStatus.Active);
|
||||
@ -153,10 +153,10 @@ public class TransferPortalTask : PortalTaskBase
|
||||
}
|
||||
}
|
||||
|
||||
private void DoTransferStorage(ColumnMapper columnMapper)
|
||||
private async Task DoTransferStorage(ColumnMapper columnMapper)
|
||||
{
|
||||
_logger.DebugBeginTransferStorage();
|
||||
var fileGroups = GetFilesToProcess(TenantId).GroupBy(file => file.Module).ToList();
|
||||
var fileGroups = (await GetFilesToProcess(TenantId)).GroupBy(file => file.Module).ToList();
|
||||
var groupsProcessed = 0;
|
||||
foreach (var group in fileGroups)
|
||||
{
|
||||
@ -173,7 +173,7 @@ public class TransferPortalTask : PortalTaskBase
|
||||
{
|
||||
try
|
||||
{
|
||||
utility.CopyFileAsync(file.Domain, file.Path, file.Domain, adjustedPath).Wait();
|
||||
await utility.CopyFileAsync(file.Domain, file.Path, file.Domain, adjustedPath);
|
||||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
|
@ -68,7 +68,7 @@ public class ReassignProgressItem : DistributedTaskProgress
|
||||
IsCompleted = false;
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
using var scope = _serviceScopeFactory.CreateScope();
|
||||
var scopeClass = scope.ServiceProvider.GetService<ReassignProgressItemScope>();
|
||||
@ -122,7 +122,7 @@ public class ReassignProgressItem : DistributedTaskProgress
|
||||
|
||||
if (_deleteProfile)
|
||||
{
|
||||
DeleteUserProfile(userManager, userPhotoManager, messageService, messageTarget, displayUserSettingsHelper, queueWorkerRemove);
|
||||
await DeleteUserProfile(userManager, userPhotoManager, messageService, messageTarget, displayUserSettingsHelper, queueWorkerRemove);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -174,13 +174,13 @@ public class ReassignProgressItem : DistributedTaskProgress
|
||||
studioNotifyService.SendMsgReassignsFailed(_currentUserId, fromUser, toUser, errorMessage);
|
||||
}
|
||||
|
||||
private void DeleteUserProfile(UserManager userManager, UserPhotoManager userPhotoManager, MessageService messageService, MessageTarget messageTarget, DisplayUserSettingsHelper displayUserSettingsHelper, QueueWorkerRemove queueWorkerRemove)
|
||||
private async Task DeleteUserProfile(UserManager userManager, UserPhotoManager userPhotoManager, MessageService messageService, MessageTarget messageTarget, DisplayUserSettingsHelper displayUserSettingsHelper, QueueWorkerRemove queueWorkerRemove)
|
||||
{
|
||||
var user = userManager.GetUsers(FromUser);
|
||||
var userName = user.DisplayUserName(false, displayUserSettingsHelper);
|
||||
|
||||
userPhotoManager.RemovePhoto(user.Id);
|
||||
userManager.DeleteUser(user.Id);
|
||||
await userPhotoManager.RemovePhoto(user.Id);
|
||||
await userManager.DeleteUser(user.Id);
|
||||
queueWorkerRemove.Start(_tenantId, user, _currentUserId, false);
|
||||
|
||||
if (_httpHeaders != null)
|
||||
|
@ -65,7 +65,7 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
IsCompleted = false;
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
using var scope = _serviceScopeFactory.CreateScope();
|
||||
var scopeClass = scope.ServiceProvider.GetService<RemoveProgressItemScope>();
|
||||
@ -82,7 +82,7 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
securityContext.AuthenticateMeWithoutCookie(_currentUserId);
|
||||
|
||||
long crmSpace;
|
||||
GetUsageSpace(webItemManagerSecurity, out var docsSpace, out var mailSpace, out var talkSpace);
|
||||
var wrapper = await GetUsageSpace(webItemManagerSecurity);
|
||||
|
||||
logger.LogInformation("deleting user data for {fromUser} ", FromUser);
|
||||
|
||||
@ -119,11 +119,11 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
PublishChanges();
|
||||
|
||||
logger.LogInformation("deleting of data from talk");
|
||||
DeleteTalkStorage(storageFactory);
|
||||
await DeleteTalkStorage(storageFactory);
|
||||
Percentage = 99;
|
||||
PublishChanges();
|
||||
|
||||
SendSuccessNotify(studioNotifyService, messageService, messageTarget, userName, docsSpace, crmSpace, mailSpace, talkSpace);
|
||||
SendSuccessNotify(studioNotifyService, messageService, messageTarget, userName, wrapper.DocsSpace, crmSpace, wrapper.MailSpace, wrapper.TalkSpace);
|
||||
|
||||
Percentage = 100;
|
||||
Status = DistributedTaskStatus.Completed;
|
||||
@ -148,9 +148,9 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
private void GetUsageSpace(WebItemManagerSecurity webItemManagerSecurity, out long docsSpace, out long mailSpace, out long talkSpace)
|
||||
private async Task<UsageSpaceWrapper> GetUsageSpace(WebItemManagerSecurity webItemManagerSecurity)
|
||||
{
|
||||
docsSpace = mailSpace = talkSpace = 0;
|
||||
var usageSpaceWrapper = new UsageSpaceWrapper();
|
||||
|
||||
var webItems = webItemManagerSecurity.GetItems(Web.Core.WebZones.WebZoneType.All, ItemAvailableState.All);
|
||||
|
||||
@ -166,7 +166,7 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
continue;
|
||||
}
|
||||
|
||||
docsSpace = manager.GetUserSpaceUsageAsync(FromUser).Result;
|
||||
usageSpaceWrapper.DocsSpace = await manager.GetUserSpaceUsageAsync(FromUser);
|
||||
}
|
||||
|
||||
if (item.ID == WebItemManager.MailProductID)
|
||||
@ -177,7 +177,7 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
continue;
|
||||
}
|
||||
|
||||
mailSpace = manager.GetUserSpaceUsageAsync(FromUser).Result;
|
||||
usageSpaceWrapper.MailSpace = await manager.GetUserSpaceUsageAsync(FromUser);
|
||||
}
|
||||
|
||||
if (item.ID == WebItemManager.TalkProductID)
|
||||
@ -188,12 +188,13 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
continue;
|
||||
}
|
||||
|
||||
talkSpace = manager.GetUserSpaceUsageAsync(FromUser).Result;
|
||||
usageSpaceWrapper.TalkSpace = await manager.GetUserSpaceUsageAsync(FromUser);
|
||||
}
|
||||
}
|
||||
return usageSpaceWrapper;
|
||||
}
|
||||
|
||||
private void DeleteTalkStorage(StorageFactory storageFactory)
|
||||
private async Task DeleteTalkStorage(StorageFactory storageFactory)
|
||||
{
|
||||
using var md5 = MD5.Create();
|
||||
var data = md5.ComputeHash(Encoding.Default.GetBytes(FromUser.ToString()));
|
||||
@ -209,9 +210,9 @@ public class RemoveProgressItem : DistributedTaskProgress
|
||||
|
||||
var storage = storageFactory.GetStorage(_tenantId, "talk");
|
||||
|
||||
if (storage != null && storage.IsDirectoryAsync(md5Hash).Result)
|
||||
if (storage != null && await storage.IsDirectoryAsync(md5Hash))
|
||||
{
|
||||
storage.DeleteDirectoryAsync(md5Hash).Wait();
|
||||
await storage.DeleteDirectoryAsync(md5Hash);
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,6 +310,13 @@ public class RemoveProgressItemScope
|
||||
optionsMonitor = _options;
|
||||
}
|
||||
}
|
||||
|
||||
class UsageSpaceWrapper
|
||||
{
|
||||
public long DocsSpace { get; set; }
|
||||
public long MailSpace { get; set; }
|
||||
public long TalkSpace { get; set; }
|
||||
}
|
||||
|
||||
public static class RemoveProgressItemExtension
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ public class EncryptionOperation : DistributedTaskProgress
|
||||
_serverRootPath = serverRootPath;
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
using var scope = _serviceScopeFactory.CreateScope();
|
||||
var scopeClass = scope.ServiceProvider.GetService<EncryptionOperationScope>();
|
||||
@ -95,9 +95,9 @@ public class EncryptionOperation : DistributedTaskProgress
|
||||
dictionary.Add(module, (DiscDataStore)storageFactory.GetStorage(ConfigPath, tenant.Id, module));
|
||||
}
|
||||
|
||||
Parallel.ForEach(dictionary, (elem) =>
|
||||
await Parallel.ForEachAsync(dictionary, async (elem, token) =>
|
||||
{
|
||||
EncryptStoreAsync(tenant, elem.Key, elem.Value, storageFactoryConfig, log).Wait();
|
||||
await EncryptStoreAsync(tenant, elem.Key, elem.Value, storageFactoryConfig, log);
|
||||
});
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class EncryptionOperation : DistributedTaskProgress
|
||||
|
||||
if (!_hasErrors)
|
||||
{
|
||||
DeleteProgressFilesAsync(storageFactory).Wait();
|
||||
await DeleteProgressFilesAsync(storageFactory);
|
||||
SaveNewSettings(encryptionSettingsHelper, log);
|
||||
}
|
||||
|
||||
|
@ -316,7 +316,7 @@ public class S3Storage : BaseStorage
|
||||
try
|
||||
{
|
||||
using var s3 = GetClient();
|
||||
var response = s3.UploadPartAsync(request).Result;
|
||||
var response = await s3.UploadPartAsync(request);
|
||||
|
||||
return response.ETag;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class UploadOperationProgress : DistributedTaskProgress
|
||||
StepCount = _directoryFiles.Count();
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
using var scope = _serviceProvider.CreateScope();
|
||||
var tenantManager = scope.ServiceProvider.GetService<TenantManager>();
|
||||
@ -268,7 +268,7 @@ public class UploadOperationProgress : DistributedTaskProgress
|
||||
foreach (var file in _directoryFiles)
|
||||
{
|
||||
var filePath = file.Substring(_mappedPath.TrimEnd('/').Length);
|
||||
staticUploader.UploadFileAsync(CrossPlatform.PathCombine(_relativePath, filePath), file, (res) => StepDone()).Wait();
|
||||
await staticUploader.UploadFileAsync(CrossPlatform.PathCombine(_relativePath, filePath), file, (res) => StepDone());
|
||||
}
|
||||
|
||||
tenant.SetStatus(TenantStatus.Active);
|
||||
|
@ -141,7 +141,7 @@ public class MigrateOperation : DistributedTaskProgress
|
||||
return MemberwiseClone();
|
||||
}
|
||||
|
||||
protected override void DoJob()
|
||||
protected override async Task DoJob()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -170,23 +170,23 @@ public class MigrateOperation : DistributedTaskProgress
|
||||
{
|
||||
//Status = module + domain;
|
||||
_logger.DebugDomain(domain);
|
||||
files = oldStore.ListFilesRelativeAsync(domain, "\\", "*.*", true).ToArrayAsync().Result;
|
||||
files = await oldStore.ListFilesRelativeAsync(domain, "\\", "*.*", true).ToArrayAsync();
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
_logger.DebugFile(file);
|
||||
crossModuleTransferUtility.CopyFileAsync(domain, file, domain, file).Wait();
|
||||
await crossModuleTransferUtility.CopyFileAsync(domain, file, domain, file);
|
||||
}
|
||||
}
|
||||
|
||||
files = oldStore.ListFilesRelativeAsync(string.Empty, "\\", "*.*", true).ToArrayAsync().Result
|
||||
files = (await oldStore.ListFilesRelativeAsync(string.Empty, "\\", "*.*", true).ToArrayAsync())
|
||||
.Where(path => domains.All(domain => !path.Contains(domain + "/")))
|
||||
.ToArray();
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
_logger.DebugFile(file);
|
||||
crossModuleTransferUtility.CopyFileAsync("", file, "", file).Wait();
|
||||
await crossModuleTransferUtility.CopyFileAsync("", file, "", file);
|
||||
}
|
||||
|
||||
StepDone();
|
||||
|
@ -139,7 +139,7 @@ public class MigrationController : ControllerBase
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("status")]
|
||||
public object Status()
|
||||
public async Task<object> Status()
|
||||
{
|
||||
if (!_coreBaseSettings.Standalone || !_userManager.IsDocSpaceAdmin(_authContext.CurrentAccount.ID))
|
||||
{
|
||||
@ -160,7 +160,7 @@ public class MigrationController : ControllerBase
|
||||
|
||||
var result = new MigrationStatus()
|
||||
{
|
||||
ParseResult = ongoingMigration.ParseTask.IsCompleted ? ongoingMigration.ParseTask.Result : null,
|
||||
ParseResult = ongoingMigration.ParseTask.IsCompleted ? await ongoingMigration.ParseTask : null,
|
||||
MigrationEnded = ongoingMigration.MigrationEnded,
|
||||
Progress = ongoingMigration.Migration.GetProgress(),
|
||||
ProgressStatus = ongoingMigration.Migration.GetProgressStatus()
|
||||
|
@ -32,7 +32,7 @@ public abstract class ImportableEntity
|
||||
|
||||
public abstract void Parse();
|
||||
|
||||
public abstract void Migrate();
|
||||
public abstract Task Migrate();
|
||||
|
||||
protected Action<string, Exception> Log { get; set; }
|
||||
|
||||
|
@ -131,7 +131,7 @@ namespace ASC.Migration.GoogleWorkspace
|
||||
return Task.FromResult(_migrationInfo.ToApiInfo());
|
||||
}
|
||||
|
||||
public override Task Migrate(MigrationApiInfo migrationApiInfo)
|
||||
public override async Task Migrate(MigrationApiInfo migrationApiInfo)
|
||||
{
|
||||
ReportProgress(0, MigrationResource.PreparingForMigration);
|
||||
_migrationInfo.Merge(migrationApiInfo);
|
||||
@ -148,12 +148,12 @@ namespace ASC.Migration.GoogleWorkspace
|
||||
var i = 1;
|
||||
foreach (var user in usersForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.UserMigration, user.DisplayName, i++, usersCount));
|
||||
try
|
||||
{
|
||||
user.DataСhange(migrationApiInfo.Users.Find(element => element.Key == user.Key));
|
||||
user.Migrate();
|
||||
await user.Migrate();
|
||||
_importedUsers.Add(user.Guid);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -173,11 +173,11 @@ namespace ASC.Migration.GoogleWorkspace
|
||||
i = 1;
|
||||
foreach (var group in groupsForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.GroupMigration, group.GroupName, i++, groupsCount));
|
||||
try
|
||||
{
|
||||
group.Migrate();
|
||||
await group.Migrate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -190,7 +190,7 @@ namespace ASC.Migration.GoogleWorkspace
|
||||
i = 1;
|
||||
foreach (var user in usersForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
if (failedUsers.Contains(user))
|
||||
{
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.UserSkipped, user.DisplayName, i, usersCount));
|
||||
@ -201,7 +201,7 @@ namespace ASC.Migration.GoogleWorkspace
|
||||
|
||||
try
|
||||
{
|
||||
user.MigratingContacts.Migrate();
|
||||
await user.MigratingContacts.Migrate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -231,7 +231,7 @@ namespace ASC.Migration.GoogleWorkspace
|
||||
_securityContext.AuthenticateMe(user.Guid);
|
||||
user.MigratingFiles.SetUsersDict(usersForImport.Except(failedUsers));
|
||||
user.MigratingFiles.SetGroupsDict(groupsForImport);
|
||||
user.MigratingFiles.Migrate();
|
||||
await user.MigratingFiles.Migrate();
|
||||
_securityContext.AuthenticateMe(currentUser.ID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -251,7 +251,6 @@ namespace ASC.Migration.GoogleWorkspace
|
||||
}
|
||||
|
||||
ReportProgress(100, MigrationResource.MigrationCompleted);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ public class GwsMigratingCalendar : MigratingCalendar
|
||||
//}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{
|
||||
if (!ShouldImport)
|
||||
{
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
// \portals\module\ASC.Api\ASC.Api.Calendar\CalendarApi.cs#L2311
|
||||
|
@ -89,7 +89,7 @@ public class GwsMigratingContacts : MigratingContacts
|
||||
}*/
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{/*
|
||||
if (!ShouldImport)
|
||||
{
|
||||
@ -107,7 +107,8 @@ public class GwsMigratingContacts : MigratingContacts
|
||||
{
|
||||
Log($"Couldn't save contactCard {card.ContactInfo.ContactName}", ex);
|
||||
}
|
||||
}*/
|
||||
}*/
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public GwsMigratingContacts(string rootFolder, GwsMigratingUser user, Action<string, Exception> log) : base(log)
|
||||
|
@ -119,7 +119,7 @@ public class GwsMigratingFiles : MigratingFiles
|
||||
_user = user;
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
if (!ShouldImport)
|
||||
{
|
||||
@ -150,7 +150,7 @@ public class GwsMigratingFiles : MigratingFiles
|
||||
var parentId = i == 0 ? _globalFolderHelper.FolderMy : foldersDict[string.Join(Path.DirectorySeparatorChar.ToString(), split.Take(i))].Id;
|
||||
try
|
||||
{
|
||||
var createdFolder = _fileStorageService.CreateNewFolderAsync(parentId, split[i]).Result;
|
||||
var createdFolder = await _fileStorageService.CreateNewFolderAsync(parentId, split[i]);
|
||||
path = path.Contains(_newParentFolder + Path.DirectorySeparatorChar.ToString()) ? path.Replace(_newParentFolder + Path.DirectorySeparatorChar.ToString(), "") : path;
|
||||
foldersDict.Add(path, createdFolder);
|
||||
}
|
||||
@ -165,7 +165,7 @@ public class GwsMigratingFiles : MigratingFiles
|
||||
if ((_folders == null || _folders.Count == 0) && (_files != null && _files.Count != 0))
|
||||
{
|
||||
var parentId = _globalFolderHelper.FolderMy;
|
||||
var createdFolder = _fileStorageService.CreateNewFolderAsync(parentId, _newParentFolder).Result;
|
||||
var createdFolder = await _fileStorageService.CreateNewFolderAsync(parentId, _newParentFolder);
|
||||
foldersDict.Add(_newParentFolder, createdFolder);
|
||||
}
|
||||
|
||||
@ -196,7 +196,7 @@ public class GwsMigratingFiles : MigratingFiles
|
||||
Title = Path.GetFileName(file),
|
||||
ContentLength = fs.Length
|
||||
};
|
||||
newFile = fileDao.SaveFileAsync(newFile, fs).Result;
|
||||
newFile = await fileDao.SaveFileAsync(newFile, fs);
|
||||
realPath = realPath.Contains(Path.DirectorySeparatorChar.ToString() + _newParentFolder) ? realPath.Replace(Path.DirectorySeparatorChar.ToString() + _newParentFolder, "") : realPath;
|
||||
filesDict.Add(realPath, newFile);
|
||||
|
||||
@ -263,7 +263,7 @@ public class GwsMigratingFiles : MigratingFiles
|
||||
}
|
||||
var entryGuid = userToShare == null ? groupToShare.Guid : userToShare.Guid;
|
||||
|
||||
if (checkRights != null && checkRights(kv.Value, entryGuid).Result)
|
||||
if (checkRights != null && await checkRights(kv.Value, entryGuid))
|
||||
{
|
||||
continue; // already have rights, skip
|
||||
}
|
||||
@ -301,7 +301,7 @@ public class GwsMigratingFiles : MigratingFiles
|
||||
|
||||
try
|
||||
{
|
||||
_fileStorageService.SetAceObjectAsync(aceCollection, false).Wait();
|
||||
await _fileStorageService.SetAceObjectAsync(aceCollection, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -312,7 +312,7 @@ public class GwsMigratingFiles : MigratingFiles
|
||||
|
||||
if (favFolders.Any() || favFiles.Any())
|
||||
{
|
||||
_fileStorageService.AddToFavoritesAsync(favFolders, favFiles).Wait();
|
||||
await _fileStorageService.AddToFavoritesAsync(favFolders, favFiles);
|
||||
}
|
||||
}
|
||||
catch
|
||||
|
@ -86,7 +86,7 @@ public class GWSMigratingGroups : MigratingGroup
|
||||
}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
var existingGroups = _userManager.GetGroups().ToList();
|
||||
var oldGroup = existingGroups.Find(g => g.Name == _groupinfo.Name);
|
||||
@ -110,7 +110,7 @@ public class GWSMigratingGroups : MigratingGroup
|
||||
}
|
||||
if (!_userManager.IsUserInGroup(user.Id, _groupinfo.ID))
|
||||
{
|
||||
_userManager.AddUserIntoGroup(user.Id, _groupinfo.ID);
|
||||
await _userManager.AddUserIntoGroup(user.Id, _groupinfo.ID);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -42,7 +42,7 @@ public class GwsMigratingMail : MigratingMail
|
||||
_user = user;
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ public class GwsMigratingUser : MigratingUser<GwsMigratingContacts, GwsMigrating
|
||||
}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_userInfo.FirstName))
|
||||
{
|
||||
@ -128,7 +128,7 @@ public class GwsMigratingUser : MigratingUser<GwsMigratingContacts, GwsMigrating
|
||||
}
|
||||
else
|
||||
{
|
||||
saved = _userManager.SaveUserInfo(_userInfo);
|
||||
saved = await _userManager.SaveUserInfo(_userInfo);
|
||||
}
|
||||
if (_hasPhoto)
|
||||
{
|
||||
|
@ -67,11 +67,11 @@ public class NCMigratingCalendar : MigratingCalendar
|
||||
//}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{
|
||||
if (!ShouldImport)
|
||||
{
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
|
@ -92,8 +92,9 @@ public class NCMigratingContacts : MigratingContacts
|
||||
*/
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
/*
|
||||
if (!ShouldImport)
|
||||
{
|
||||
|
@ -116,9 +116,8 @@ public class NCMigratingFiles : MigratingFiles
|
||||
}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
|
||||
if (!ShouldImport)
|
||||
{
|
||||
return;
|
||||
@ -149,7 +148,7 @@ public class NCMigratingFiles : MigratingFiles
|
||||
var parentId = i == 0 ? _globalFolderHelper.FolderMy : foldersDict[string.Join(Path.DirectorySeparatorChar.ToString(), split.Take(i))].Id;
|
||||
try
|
||||
{
|
||||
var newFolder = _fileStorageService.CreateNewFolderAsync(parentId, split[i]).Result;
|
||||
var newFolder = await _fileStorageService.CreateNewFolderAsync(parentId, split[i]);
|
||||
foldersDict.Add(path, newFolder);
|
||||
_matchingFileId.Add(newFolder.Id, folder.FileId);
|
||||
}
|
||||
@ -179,7 +178,7 @@ public class NCMigratingFiles : MigratingFiles
|
||||
var fileDao = _daoFactory.GetFileDao<int>();
|
||||
var folderDao = _daoFactory.GetFolderDao<int>();
|
||||
{
|
||||
var parentFolder = string.IsNullOrWhiteSpace(parentPath) ? folderDao.GetFolderAsync(_globalFolderHelper.FolderMy).Result : foldersDict[parentPath];
|
||||
var parentFolder = string.IsNullOrWhiteSpace(parentPath) ? await folderDao.GetFolderAsync(_globalFolderHelper.FolderMy) : foldersDict[parentPath];
|
||||
|
||||
var newFile = new File<int>
|
||||
{
|
||||
@ -188,7 +187,7 @@ public class NCMigratingFiles : MigratingFiles
|
||||
Title = Path.GetFileName(file.Path),
|
||||
ContentLength = fs.Length
|
||||
};
|
||||
newFile = fileDao.SaveFileAsync(newFile, fs).Result;
|
||||
newFile = await fileDao.SaveFileAsync(newFile, fs);
|
||||
_matchingFileId.Add(newFile.Id, file.FileId);
|
||||
}
|
||||
}
|
||||
@ -255,7 +254,7 @@ public class NCMigratingFiles : MigratingFiles
|
||||
|
||||
try
|
||||
{
|
||||
_fileStorageService.SetAceObjectAsync(aceCollection, false).Wait();
|
||||
await _fileStorageService.SetAceObjectAsync(aceCollection, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ public class NCMigratingGroups : MigratingGroup
|
||||
Module = new MigrationModules(ModuleName, MigrationResource.OnlyofficeModuleNamePeople);
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
var existingGroups = _userManager.GetGroups().ToList();
|
||||
var oldGroup = existingGroups.Find(g => g.Name == _groupinfo.Name);
|
||||
@ -80,7 +80,7 @@ public class NCMigratingGroups : MigratingGroup
|
||||
}
|
||||
if (!_userManager.IsUserInGroup(user.Id, _groupinfo.ID))
|
||||
{
|
||||
_userManager.AddUserIntoGroup(user.Id, _groupinfo.ID);
|
||||
await _userManager.AddUserIntoGroup(user.Id, _groupinfo.ID);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -32,7 +32,7 @@ public class NCMigratingMail : MigratingMail
|
||||
|
||||
public override int MessagesCount => messagesCount;
|
||||
public override string ModuleName => MigrationResource.ModuleNameMail;
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -177,7 +177,7 @@ public class NCMigratingUser : MigratingUser<NCMigratingContacts, NCMigratingCal
|
||||
}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_userInfo.FirstName))
|
||||
{
|
||||
@ -196,7 +196,7 @@ public class NCMigratingUser : MigratingUser<NCMigratingContacts, NCMigratingCal
|
||||
}
|
||||
else
|
||||
{
|
||||
saved = _userManager.SaveUserInfo(_userInfo);
|
||||
saved = await _userManager.SaveUserInfo(_userInfo);
|
||||
}
|
||||
if (_hasPhoto)
|
||||
{
|
||||
|
@ -456,7 +456,7 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
.Select(m => m.Groups[1].Value.Trim(new[] { '(', ')' }));
|
||||
}
|
||||
|
||||
public override Task Migrate(MigrationApiInfo migrationApiInfo)
|
||||
public override async Task Migrate(MigrationApiInfo migrationApiInfo)
|
||||
{
|
||||
ReportProgress(0, MigrationResource.PreparingForMigration);
|
||||
_migrationInfo.Merge(migrationApiInfo);
|
||||
@ -471,12 +471,12 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
var i = 1;
|
||||
foreach (var user in usersForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.UserMigration, user.DisplayName, i++, usersCount));
|
||||
try
|
||||
{
|
||||
user.dataСhange(migrationApiInfo.Users.Find(element => element.Key == user.Key));
|
||||
user.Migrate();
|
||||
await user.Migrate();
|
||||
_importedUsers.Add(user.Guid);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -497,7 +497,7 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
i = 1;
|
||||
foreach (var group in groupsForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.GroupMigration, group.GroupName, i++, groupsCount));
|
||||
try
|
||||
{
|
||||
@ -505,7 +505,7 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
.Where(user => group.UserUidList.Exists(u => user.Key == u))
|
||||
.Select(u => u)
|
||||
.ToDictionary(k => k.Key, v => v.Value.Guid);
|
||||
group.Migrate();
|
||||
await group.Migrate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -517,7 +517,7 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
i = 1;
|
||||
foreach (var user in usersForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
if (failedUsers.Contains(user))
|
||||
{
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.UserSkipped, user.DisplayName, i, usersCount));
|
||||
@ -528,7 +528,7 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
|
||||
try
|
||||
{
|
||||
user.MigratingContacts.Migrate();
|
||||
await user.MigratingContacts.Migrate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -558,7 +558,7 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
_securityContext.AuthenticateMe(user.Guid);
|
||||
user.MigratingFiles.SetUsersDict(usersForImport.Except(failedUsers));
|
||||
user.MigratingFiles.SetGroupsDict(groupsForImport);
|
||||
user.MigratingFiles.Migrate();
|
||||
await user.MigratingFiles.Migrate();
|
||||
_securityContext.AuthenticateMe(currentUser.ID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -577,6 +577,5 @@ public class NextcloudWorkspaceMigration : AbstractMigration<NCMigrationInfo, NC
|
||||
Directory.Delete(_tmpFolder, true);
|
||||
}
|
||||
ReportProgress(100, MigrationResource.MigrationCompleted);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -67,11 +67,11 @@ public class OCMigratingCalendar : MigratingCalendar
|
||||
//}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{
|
||||
if (!ShouldImport)
|
||||
{
|
||||
return;
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
throw new NotImplementedException();
|
||||
|
@ -92,8 +92,10 @@ public class OCMigratingContacts : MigratingContacts
|
||||
}*/
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
{/*
|
||||
public override Task Migrate()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
/*
|
||||
if (!ShouldImport)
|
||||
{
|
||||
return;
|
||||
|
@ -116,9 +116,8 @@ public class OCMigratingFiles : MigratingFiles
|
||||
}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
|
||||
if (!ShouldImport)
|
||||
{
|
||||
return;
|
||||
@ -149,7 +148,7 @@ public class OCMigratingFiles : MigratingFiles
|
||||
var parentId = i == 0 ? _globalFolderHelper.FolderMy : foldersDict[string.Join(Path.DirectorySeparatorChar.ToString(), split.Take(i))].Id;
|
||||
try
|
||||
{
|
||||
var newFolder = _fileStorageService.CreateNewFolderAsync(parentId, split[i]).Result;
|
||||
var newFolder = await _fileStorageService.CreateNewFolderAsync(parentId, split[i]);
|
||||
foldersDict.Add(path, newFolder);
|
||||
_matchingFileId.Add(newFolder.Id, folder.FileId);
|
||||
}
|
||||
@ -179,7 +178,7 @@ public class OCMigratingFiles : MigratingFiles
|
||||
var fileDao = _daoFactory.GetFileDao<int>();
|
||||
var folderDao = _daoFactory.GetFolderDao<int>();
|
||||
|
||||
var parentFolder = string.IsNullOrWhiteSpace(parentPath) ? folderDao.GetFolderAsync(_globalFolderHelper.FolderMy).Result : foldersDict[parentPath];
|
||||
var parentFolder = string.IsNullOrWhiteSpace(parentPath) ? await folderDao.GetFolderAsync(_globalFolderHelper.FolderMy) : foldersDict[parentPath];
|
||||
|
||||
var newFile = new File<int>
|
||||
{
|
||||
@ -188,7 +187,7 @@ public class OCMigratingFiles : MigratingFiles
|
||||
Title = Path.GetFileName(file.Path),
|
||||
ContentLength = fs.Length
|
||||
};
|
||||
newFile = fileDao.SaveFileAsync(newFile, fs).Result;
|
||||
newFile = await fileDao.SaveFileAsync(newFile, fs);
|
||||
_matchingFileId.Add(newFile.Id, file.FileId);
|
||||
|
||||
}
|
||||
@ -255,7 +254,7 @@ public class OCMigratingFiles : MigratingFiles
|
||||
|
||||
try
|
||||
{
|
||||
_fileStorageService.SetAceObjectAsync(aceCollection, false).Wait();
|
||||
await _fileStorageService.SetAceObjectAsync(aceCollection, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -56,7 +56,7 @@ public class OCMigratingGroups : MigratingGroup
|
||||
Module = new MigrationModules(ModuleName, MigrationResource.OnlyofficeModuleNamePeople);
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
var existingGroups = _userManager.GetGroups().ToList();
|
||||
var oldGroup = existingGroups.Find(g => g.Name == _groupinfo.Name);
|
||||
@ -80,7 +80,7 @@ public class OCMigratingGroups : MigratingGroup
|
||||
}
|
||||
if (!_userManager.IsUserInGroup(user.Id, _groupinfo.ID))
|
||||
{
|
||||
_userManager.AddUserIntoGroup(user.Id, _groupinfo.ID);
|
||||
await _userManager.AddUserIntoGroup(user.Id, _groupinfo.ID);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -32,7 +32,7 @@ public class OCMigratingMail : MigratingMail
|
||||
|
||||
public override int MessagesCount => messagesCount;
|
||||
public override string ModuleName => MigrationResource.ModuleNameMail;
|
||||
public override void Migrate()
|
||||
public override Task Migrate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ public class OCMigratingUser : MigratingUser<OCMigratingContacts, OCMigratingCal
|
||||
}
|
||||
}
|
||||
|
||||
public override void Migrate()
|
||||
public override async Task Migrate()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_userInfo.FirstName))
|
||||
{
|
||||
@ -171,7 +171,7 @@ public class OCMigratingUser : MigratingUser<OCMigratingContacts, OCMigratingCal
|
||||
}
|
||||
else
|
||||
{
|
||||
saved = _userManager.SaveUserInfo(_userInfo);
|
||||
saved = await _userManager.SaveUserInfo(_userInfo);
|
||||
}
|
||||
if (_hasPhoto)
|
||||
{
|
||||
|
@ -429,7 +429,7 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
.Select(m => m.Groups[1].Value.Trim(new[] { '(', ')' }));
|
||||
}
|
||||
|
||||
public override Task Migrate(MigrationApiInfo migrationApiInfo)
|
||||
public override async Task Migrate(MigrationApiInfo migrationApiInfo)
|
||||
{
|
||||
ReportProgress(0, MigrationResource.PreparingForMigration);
|
||||
_migrationInfo.Merge(migrationApiInfo);
|
||||
@ -445,12 +445,12 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
var i = 1;
|
||||
foreach (var user in usersForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.UserMigration, user.DisplayName, i++, usersCount));
|
||||
try
|
||||
{
|
||||
user.dataСhange(migrationApiInfo.Users.Find(element => element.Key == user.Key));
|
||||
user.Migrate();
|
||||
await user.Migrate();
|
||||
_importedUsers.Add(user.Guid);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -471,7 +471,7 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
i = 1;
|
||||
foreach (var group in groupsForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.GroupMigration, group.GroupName, i++, groupsCount));
|
||||
try
|
||||
{
|
||||
@ -479,7 +479,7 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
.Where(user => group.UserUidList.Exists(u => user.Key == u))
|
||||
.Select(u => u)
|
||||
.ToDictionary(k => k.Key, v => v.Value.Guid);
|
||||
group.Migrate();
|
||||
await group.Migrate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -491,7 +491,7 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
i = 1;
|
||||
foreach (var user in usersForImport)
|
||||
{
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return null; }
|
||||
if (_cancellationToken.IsCancellationRequested) { ReportProgress(100, MigrationResource.MigrationCanceled); return; }
|
||||
if (failedUsers.Contains(user))
|
||||
{
|
||||
ReportProgress(GetProgress() + progressStep, string.Format(MigrationResource.UserSkipped, user.DisplayName, i, usersCount));
|
||||
@ -502,7 +502,7 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
|
||||
try
|
||||
{
|
||||
user.MigratingContacts.Migrate();
|
||||
await user.MigratingContacts.Migrate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -532,7 +532,7 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
_securityContext.AuthenticateMe(user.Guid);
|
||||
user.MigratingFiles.SetUsersDict(usersForImport.Except(failedUsers));
|
||||
user.MigratingFiles.SetGroupsDict(groupsForImport);
|
||||
user.MigratingFiles.Migrate();
|
||||
await user.MigratingFiles.Migrate();
|
||||
_securityContext.AuthenticateMe(currentUser.ID);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -551,6 +551,5 @@ public class OwnCloudMigration : AbstractMigration<OCMigrationInfo, OCMigratingU
|
||||
Directory.Delete(_tmpFolder, true);
|
||||
}
|
||||
ReportProgress(100, MigrationResource.MigrationCompleted);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ if(logpath != null)
|
||||
const fileName = logpath ? path.join(logpath, "socket-io.%DATE%.log") : path.join(__dirname, "..", "..", "..", "Logs", "socket-io.%DATE%.log");
|
||||
const dirName = path.dirname(fileName);
|
||||
|
||||
const aws = config.get("aws");
|
||||
const aws = config.get("aws").cloudWatch;
|
||||
|
||||
const accessKeyId = aws.accessKeyId;
|
||||
const secretAccessKey = aws.secretAccessKey;
|
||||
@ -65,6 +65,7 @@ var options = {
|
||||
.replace("${guid}", guid)
|
||||
.replace("${date}", dateAsString);
|
||||
},
|
||||
logGroupName: logGroupName,
|
||||
awsRegion: awsRegion,
|
||||
jsonMessage: true,
|
||||
awsOptions: {
|
||||
@ -76,8 +77,6 @@ var options = {
|
||||
}
|
||||
};
|
||||
|
||||
//const fileTransport = new winston.transports.DailyRotateFile(options.file);
|
||||
|
||||
let transports = [
|
||||
new winston.transports.Console(options.console),
|
||||
new winston.transports.DailyRotateFile(options.file)
|
||||
@ -88,8 +87,6 @@ if (aws != null && aws.accessKeyId !== '')
|
||||
transports.push(new WinstonCloudWatch(options.cloudWatch));
|
||||
}
|
||||
|
||||
//winston.exceptions.handle(fileTransport);
|
||||
|
||||
const customFormat = winston.format(info => {
|
||||
const now = new Date();
|
||||
|
||||
@ -105,7 +102,6 @@ const customFormat = winston.format(info => {
|
||||
})();
|
||||
|
||||
module.exports = new winston.createLogger({
|
||||
//defaultMeta: { component: "socket.io-server" },
|
||||
format: winston.format.combine(
|
||||
customFormat,
|
||||
winston.format.json()
|
||||
|
@ -3,12 +3,5 @@
|
||||
"port": 9899,
|
||||
"appsettings": "../../../config",
|
||||
"environment": "Development"
|
||||
},
|
||||
"aws":{
|
||||
"accessKeyId": "",
|
||||
"secretAccessKey": "",
|
||||
"region": "",
|
||||
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
|
||||
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
|
||||
}
|
||||
}
|
||||
|
@ -17,25 +17,15 @@ function getAndSaveAppsettings(){
|
||||
}
|
||||
|
||||
var env = nconf.get("app").environment;
|
||||
var valueEnv = nconf.get(env);
|
||||
var fileWithEnv = path.join(appsettings, 'appsettings.' + valueEnv + '.json');
|
||||
|
||||
if(fs.existsSync(fileWithEnv)){
|
||||
nconf.file("appsettings", fileWithEnv);
|
||||
}
|
||||
else{
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
}
|
||||
console.log('environment: ' + env);
|
||||
nconf.file("appsettingsWithEnv", path.join(appsettings, 'appsettings.' + env + '.json'));
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
|
||||
nconf.file("appsettingsServices", path.join(appsettings, 'appsettings.services.json'));
|
||||
|
||||
var redisWithEnv = path.join(appsettings, 'redis.' + valueEnv + '.json');
|
||||
if(fs.existsSync(fileWithEnv)){
|
||||
nconf.file("redis", redisWithEnv);
|
||||
}
|
||||
else{
|
||||
nconf.file("redis", path.join(__dirname, appsettings, 'redis.json'));
|
||||
}
|
||||
nconf.file("redisWithEnv", path.join(appsettings, 'redis.' + env + '.json'));
|
||||
nconf.file("redis", path.join(appsettings, 'redis.json'));
|
||||
|
||||
var redis = nconf.get("Redis");
|
||||
if(redis != null)
|
||||
|
@ -52,7 +52,7 @@ if(logpath != null)
|
||||
fs.existsSync(logpath) || fs.mkdirSync(logpath);
|
||||
}
|
||||
|
||||
const aws = config["aws"];
|
||||
const aws = config["aws"].cloudWatch;
|
||||
|
||||
const accessKeyId = aws.accessKeyId;
|
||||
const secretAccessKey = aws.secretAccessKey;
|
||||
@ -88,6 +88,7 @@ if (aws != null && aws.accessKeyId !== '')
|
||||
.replace("${guid}", guid)
|
||||
.replace("${date}", dateAsString);
|
||||
},
|
||||
logGroupName: logGroupName,
|
||||
awsRegion: awsRegion,
|
||||
jsonMessage: true,
|
||||
awsOptions: {
|
||||
|
@ -63,12 +63,5 @@
|
||||
"image-path": "images",
|
||||
"rebranding": "rebranding",
|
||||
"https":"certs"
|
||||
},
|
||||
"aws":{
|
||||
"accessKeyId": "",
|
||||
"secretAccessKey": "",
|
||||
"region": "",
|
||||
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
|
||||
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@ const nconf = require("nconf"),
|
||||
nconf.argv()
|
||||
.env()
|
||||
.file("config",path.join(__dirname, "config.json"));
|
||||
|
||||
console.log("NODE_ENV: " + nconf.get("NODE_ENV"));
|
||||
|
||||
if (nconf.get("NODE_ENV") !== "development" && fs.existsSync(path.join(__dirname, nconf.get("NODE_ENV") + ".json"))) {
|
||||
nconf.file("config", path.join(__dirname, nconf.get("NODE_ENV") + ".json"));
|
||||
@ -38,14 +40,9 @@ function getAndSaveAppsettings(){
|
||||
appsettings =path.join(__dirname, appsettings);
|
||||
}
|
||||
var env = nconf.get("app").environment;
|
||||
var valueEnv = nconf.get(env);
|
||||
var fileWithEnv = path.join(appsettings, 'appsettings.' + valueEnv + '.json');
|
||||
console.log('environment: ' + env);
|
||||
|
||||
if(fs.existsSync(fileWithEnv)){
|
||||
nconf.file("appsettings", fileWithEnv);
|
||||
}
|
||||
else{
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
}
|
||||
nconf.file("appsettingsWithEnv", path.join(appsettings, 'appsettings.' + env + '.json'));
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
nconf.file("appsettingsServices", path.join(appsettings, 'appsettings.services.json'));
|
||||
}
|
@ -22,7 +22,7 @@ if(logpath != null)
|
||||
const fileName = logpath ? path.join(logpath, "web.shorturl.%DATE%.log") : path.join(__dirname, "..", "..", "..", "Logs", "web.shorturl.%DATE%.log");
|
||||
const dirName = path.dirname(fileName);
|
||||
|
||||
const aws = config.get("aws");
|
||||
const aws = config.get("aws").cloudWatch;
|
||||
|
||||
const accessKeyId = aws.accessKeyId;
|
||||
const secretAccessKey = aws.secretAccessKey;
|
||||
@ -65,6 +65,7 @@ var options = {
|
||||
.replace("${guid}", guid)
|
||||
.replace("${date}", dateAsString);
|
||||
},
|
||||
logGroupName: logGroupName,
|
||||
awsRegion: awsRegion,
|
||||
jsonMessage: true,
|
||||
awsOptions: {
|
||||
|
@ -3,12 +3,5 @@
|
||||
"port": 9999,
|
||||
"appsettings": "../../../config",
|
||||
"environment": "Development"
|
||||
},
|
||||
"aws":{
|
||||
"accessKeyId": "",
|
||||
"secretAccessKey": "",
|
||||
"region": "",
|
||||
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
|
||||
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
|
||||
}
|
||||
}
|
@ -45,15 +45,10 @@ function getAndSaveAppsettings(){
|
||||
}
|
||||
|
||||
var env = nconf.get("app").environment;
|
||||
var valueEnv = nconf.get(env);
|
||||
var fileWithEnv = path.join(appsettings, 'appsettings.' + valueEnv + '.json');
|
||||
|
||||
if(fs.existsSync(fileWithEnv)){
|
||||
nconf.file("appsettings", fileWithEnv);
|
||||
}
|
||||
else{
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
}
|
||||
console.log('environment: ' + env);
|
||||
|
||||
nconf.file("appsettingsWithEnv", path.join(appsettings, 'appsettings.' + env + '.json'));
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
nconf.file("appsettingsServices", path.join(appsettings, 'appsettings.services.json'));
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ const winston = require("winston"),
|
||||
date = require('date-and-time'),
|
||||
os = require("os");
|
||||
|
||||
|
||||
const { format } = require("winston");
|
||||
require("winston-daily-rotate-file");
|
||||
|
||||
@ -45,7 +46,27 @@ const fileTransport = new (winston.transports.DailyRotateFile)({
|
||||
maxFiles: "30d"
|
||||
});
|
||||
|
||||
const aws = config["aws"];
|
||||
const nconf = require("nconf");
|
||||
|
||||
nconf.argv()
|
||||
.env();
|
||||
|
||||
var appsettings = config.appsettings;
|
||||
|
||||
if(!path.isAbsolute(appsettings)){
|
||||
appsettings = path.join(__dirname, appsettings);
|
||||
}
|
||||
|
||||
var fileWithEnv = path.join(appsettings, 'appsettings.' + config.environment + '.json');
|
||||
|
||||
if(fs.existsSync(fileWithEnv)){
|
||||
nconf.file("appsettings", fileWithEnv);
|
||||
}
|
||||
else{
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
}
|
||||
|
||||
const aws = nconf.get("aws").cloudWatch;
|
||||
|
||||
const accessKeyId = aws.accessKeyId;
|
||||
const secretAccessKey = aws.secretAccessKey;
|
||||
@ -75,6 +96,7 @@ if (aws != null && aws.accessKeyId !== '')
|
||||
.replace("${guid}", guid)
|
||||
.replace("${date}", dateAsString);
|
||||
},
|
||||
logGroupName: logGroupName,
|
||||
awsRegion: awsRegion,
|
||||
jsonMessage: true,
|
||||
awsOptions: {
|
||||
|
@ -18,6 +18,7 @@
|
||||
"form-data": "^3.0.0",
|
||||
"get-byte": "0.0.0",
|
||||
"help": "^3.0.2",
|
||||
"nconf": "^0.10.0",
|
||||
"patch-package": "^6.4.7",
|
||||
"postinstall-postinstall": "^2.1.0",
|
||||
"request": "^2.88.0",
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
module.exports = {
|
||||
// Port listener WebDav Server
|
||||
port: 1900,
|
||||
port: 1900,
|
||||
appsettings: "../../../config",
|
||||
environment: "Development",
|
||||
// Path to pfx key
|
||||
pfxKeyPath: null,
|
||||
// Pass phrase for pfx key
|
||||
@ -53,14 +55,6 @@ module.exports = {
|
||||
// Path to read the file
|
||||
fileHandlerPath: "/Products/Files/HttpHandlers/filehandler.ashx?action=stream&fileid={0}",
|
||||
|
||||
aws: {
|
||||
"accessKeyId": "",
|
||||
"secretAccessKey": "",
|
||||
"region": "",
|
||||
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
|
||||
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
|
||||
},
|
||||
|
||||
method: {
|
||||
// Get root directory in "Root"
|
||||
pathRootDirectory: "@root",
|
||||
|
@ -872,6 +872,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ansi-regex@npm:^2.0.0":
|
||||
version: 2.1.1
|
||||
resolution: "ansi-regex@npm:2.1.1"
|
||||
checksum: 190abd03e4ff86794f338a31795d262c1dfe8c91f7e01d04f13f646f1dcb16c5800818f886047876f1272f065570ab86b24b99089f8b68a0e11ff19aed4ca8f1
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ansi-styles@npm:^3.2.1":
|
||||
version: 3.2.1
|
||||
resolution: "ansi-styles@npm:3.2.1"
|
||||
@ -922,6 +929,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"async@npm:^1.4.0":
|
||||
version: 1.5.2
|
||||
resolution: "async@npm:1.5.2"
|
||||
checksum: fe5d6214d8f15bd51eee5ae8ec5079b228b86d2d595f47b16369dec2e11b3ff75a567bb5f70d12d79006665fbbb7ee0a7ec0e388524eefd454ecbe651c124ebd
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"async@npm:^3.1.0, async@npm:^3.2.3":
|
||||
version: 3.2.4
|
||||
resolution: "async@npm:3.2.4"
|
||||
@ -1045,6 +1059,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"camelcase@npm:^2.0.1":
|
||||
version: 2.1.1
|
||||
resolution: "camelcase@npm:2.1.1"
|
||||
checksum: 20a3ef08f348de832631d605362ffe447d883ada89617144a82649363ed5860923b021f8e09681624ef774afb93ff3597cfbcf8aaf0574f65af7648f1aea5e50
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"caseless@npm:~0.12.0":
|
||||
version: 0.12.0
|
||||
resolution: "caseless@npm:0.12.0"
|
||||
@ -1080,6 +1101,24 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"cliui@npm:^3.0.3":
|
||||
version: 3.2.0
|
||||
resolution: "cliui@npm:3.2.0"
|
||||
dependencies:
|
||||
string-width: ^1.0.1
|
||||
strip-ansi: ^3.0.1
|
||||
wrap-ansi: ^2.0.0
|
||||
checksum: c68d1dbc3e347bfe79ed19cc7f48007d5edd6cd8438342e32073e0b4e311e3c44e1f4f19221462bc6590de56c2df520e427533a9dde95dee25710bec322746ad
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"code-point-at@npm:^1.0.0":
|
||||
version: 1.1.0
|
||||
resolution: "code-point-at@npm:1.1.0"
|
||||
checksum: 17d5666611f9b16d64fdf48176d9b7fb1c7d1c1607a189f7e600040a11a6616982876af148230336adb7d8fe728a559f743a4e29db3747e3b1a32fa7f4529681
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"color-convert@npm:^1.9.0, color-convert@npm:^1.9.3":
|
||||
version: 1.9.3
|
||||
resolution: "color-convert@npm:1.9.3"
|
||||
@ -1259,6 +1298,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"decamelize@npm:^1.1.1":
|
||||
version: 1.2.0
|
||||
resolution: "decamelize@npm:1.2.0"
|
||||
checksum: ad8c51a7e7e0720c70ec2eeb1163b66da03e7616d7b98c9ef43cce2416395e84c1e9548dd94f5f6ffecfee9f8b94251fc57121a8b021f2ff2469b2bae247b8aa
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"deep-is@npm:~0.1.3":
|
||||
version: 0.1.4
|
||||
resolution: "deep-is@npm:0.1.4"
|
||||
@ -1842,6 +1888,20 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ini@npm:^1.3.0":
|
||||
version: 1.3.8
|
||||
resolution: "ini@npm:1.3.8"
|
||||
checksum: dfd98b0ca3a4fc1e323e38a6c8eb8936e31a97a918d3b377649ea15bdb15d481207a0dda1021efbd86b464cae29a0d33c1d7dcaf6c5672bee17fa849bc50a1b3
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"invert-kv@npm:^1.0.0":
|
||||
version: 1.0.0
|
||||
resolution: "invert-kv@npm:1.0.0"
|
||||
checksum: aebeee31dda3b3d25ffd242e9a050926e7fe5df642d60953ab183aca1a7d1ffb39922eb2618affb0e850cf2923116f0da1345367759d88d097df5da1f1e1590e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ip@npm:^1.1.5":
|
||||
version: 1.1.8
|
||||
resolution: "ip@npm:1.1.8"
|
||||
@ -1897,6 +1957,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"is-fullwidth-code-point@npm:^1.0.0":
|
||||
version: 1.0.0
|
||||
resolution: "is-fullwidth-code-point@npm:1.0.0"
|
||||
dependencies:
|
||||
number-is-nan: ^1.0.0
|
||||
checksum: 4d46a7465a66a8aebcc5340d3b63a56602133874af576a9ca42c6f0f4bd787a743605771c5f246db77da96605fefeffb65fc1dbe862dcc7328f4b4d03edf5a57
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"is-number@npm:^7.0.0":
|
||||
version: 7.0.0
|
||||
resolution: "is-number@npm:7.0.0"
|
||||
@ -2016,6 +2085,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"lcid@npm:^1.0.0":
|
||||
version: 1.0.0
|
||||
resolution: "lcid@npm:1.0.0"
|
||||
dependencies:
|
||||
invert-kv: ^1.0.0
|
||||
checksum: e8c7a4db07663068c5c44b650938a2bc41aa992037eebb69376214320f202c1250e70b50c32f939e28345fd30c2d35b8e8cd9a19d5932c398246a864ce54843d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"levn@npm:~0.3.0":
|
||||
version: 0.3.0
|
||||
resolution: "levn@npm:0.3.0"
|
||||
@ -2176,6 +2254,18 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"nconf@npm:^0.10.0":
|
||||
version: 0.10.0
|
||||
resolution: "nconf@npm:0.10.0"
|
||||
dependencies:
|
||||
async: ^1.4.0
|
||||
ini: ^1.3.0
|
||||
secure-keys: ^1.0.0
|
||||
yargs: ^3.19.0
|
||||
checksum: 14052553bcde03dbdf11bc3ee95b8cdb7fe776ada550763df75c9683335a937545f62e96972ad2fd4bcc85f928d9880fc74b8c5f93eaddef58d6e0f46c0c836f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"negotiator@npm:0.6.3":
|
||||
version: 0.6.3
|
||||
resolution: "negotiator@npm:0.6.3"
|
||||
@ -2197,6 +2287,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"number-is-nan@npm:^1.0.0":
|
||||
version: 1.0.1
|
||||
resolution: "number-is-nan@npm:1.0.1"
|
||||
checksum: 13656bc9aa771b96cef209ffca31c31a03b507ca6862ba7c3f638a283560620d723d52e626d57892c7fff475f4c36ac07f0600f14544692ff595abff214b9ffb
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"oauth-sign@npm:~0.9.0":
|
||||
version: 0.9.0
|
||||
resolution: "oauth-sign@npm:0.9.0"
|
||||
@ -2269,6 +2366,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"os-locale@npm:^1.4.0":
|
||||
version: 1.4.0
|
||||
resolution: "os-locale@npm:1.4.0"
|
||||
dependencies:
|
||||
lcid: ^1.0.0
|
||||
checksum: 0161a1b6b5a8492f99f4b47fe465df9fc521c55ba5414fce6444c45e2500487b8ed5b40a47a98a2363fe83ff04ab033785300ed8df717255ec4c3b625e55b1fb
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"os-tmpdir@npm:~1.0.2":
|
||||
version: 1.0.2
|
||||
resolution: "os-tmpdir@npm:1.0.2"
|
||||
@ -2555,6 +2661,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"secure-keys@npm:^1.0.0":
|
||||
version: 1.0.0
|
||||
resolution: "secure-keys@npm:1.0.0"
|
||||
checksum: 3dd4e64e6717fe6e2dc4c70e172982fcbad87b853e96566ab1cfaec540587f737bac106853ae469cb32d4a6413cfe80a28176cfe7dfcf7ddd35c9f92e58dffed
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"semver@npm:^5.5.0, semver@npm:^5.6.0":
|
||||
version: 5.7.1
|
||||
resolution: "semver@npm:5.7.1"
|
||||
@ -2717,6 +2830,17 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"string-width@npm:^1.0.1":
|
||||
version: 1.0.2
|
||||
resolution: "string-width@npm:1.0.2"
|
||||
dependencies:
|
||||
code-point-at: ^1.0.0
|
||||
is-fullwidth-code-point: ^1.0.0
|
||||
strip-ansi: ^3.0.0
|
||||
checksum: 5c79439e95bc3bd7233a332c5f5926ab2ee90b23816ed4faa380ce3b2576d7800b0a5bb15ae88ed28737acc7ea06a518c2eef39142dd727adad0e45c776cd37e
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"string_decoder@npm:^1.1.1":
|
||||
version: 1.3.0
|
||||
resolution: "string_decoder@npm:1.3.0"
|
||||
@ -2733,6 +2857,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"strip-ansi@npm:^3.0.0, strip-ansi@npm:^3.0.1":
|
||||
version: 3.0.1
|
||||
resolution: "strip-ansi@npm:3.0.1"
|
||||
dependencies:
|
||||
ansi-regex: ^2.0.0
|
||||
checksum: 9b974de611ce5075c70629c00fa98c46144043db92ae17748fb780f706f7a789e9989fd10597b7c2053ae8d1513fd707816a91f1879b2f71e6ac0b6a863db465
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"strnum@npm:^1.0.5":
|
||||
version: 1.0.5
|
||||
resolution: "strnum@npm:1.0.5"
|
||||
@ -2972,6 +3105,7 @@ __metadata:
|
||||
form-data: ^3.0.0
|
||||
get-byte: 0.0.0
|
||||
help: ^3.0.2
|
||||
nconf: ^0.10.0
|
||||
patch-package: ^6.4.7
|
||||
postinstall-postinstall: ^2.1.0
|
||||
request: ^2.88.0
|
||||
@ -2994,6 +3128,15 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"window-size@npm:^0.1.4":
|
||||
version: 0.1.4
|
||||
resolution: "window-size@npm:0.1.4"
|
||||
bin:
|
||||
window-size: cli.js
|
||||
checksum: 409accca0b1373c69897400e3cc6a56a2acc8a6ba9009f0cd8e4adda4ebf308e50425d3bd375c0c08efb803c8f0b09d84d7266faa05422b3fadfe6ee422d0aef
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"winston-cloudwatch@npm:^6.1.1":
|
||||
version: 6.1.1
|
||||
resolution: "winston-cloudwatch@npm:6.1.1"
|
||||
@ -3064,6 +3207,16 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"wrap-ansi@npm:^2.0.0":
|
||||
version: 2.1.0
|
||||
resolution: "wrap-ansi@npm:2.1.0"
|
||||
dependencies:
|
||||
string-width: ^1.0.1
|
||||
strip-ansi: ^3.0.1
|
||||
checksum: 2dacd4b3636f7a53ee13d4d0fe7fa2ed9ad81e9967e17231924ea88a286ec4619a78288de8d41881ee483f4449ab2c0287cde8154ba1bd0126c10271101b2ee3
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"wrappy@npm:1":
|
||||
version: 1.0.2
|
||||
resolution: "wrappy@npm:1.0.2"
|
||||
@ -3098,9 +3251,31 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"y18n@npm:^3.2.0":
|
||||
version: 3.2.2
|
||||
resolution: "y18n@npm:3.2.2"
|
||||
checksum: 6154fd7544f8bbf5b18cdf77692ed88d389be49c87238ecb4e0d6a5276446cd2a5c29cc4bdbdddfc7e4e498b08df9d7e38df4a1453cf75eecfead392246ea74a
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yallist@npm:^3.0.2":
|
||||
version: 3.1.1
|
||||
resolution: "yallist@npm:3.1.1"
|
||||
checksum: 48f7bb00dc19fc635a13a39fe547f527b10c9290e7b3e836b9a8f1ca04d4d342e85714416b3c2ab74949c9c66f9cebb0473e6bc353b79035356103b47641285d
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"yargs@npm:^3.19.0":
|
||||
version: 3.32.0
|
||||
resolution: "yargs@npm:3.32.0"
|
||||
dependencies:
|
||||
camelcase: ^2.0.1
|
||||
cliui: ^3.0.3
|
||||
decamelize: ^1.1.1
|
||||
os-locale: ^1.4.0
|
||||
string-width: ^1.0.1
|
||||
window-size: ^0.1.4
|
||||
y18n: ^3.2.0
|
||||
checksum: 3e0f7fc1bc2052bcaaa7354cbd33d05a86fc0f236432d107ecd088989fbd175174c562d17e762727acbf25d04e8520d43625f7581b2a6ce55ce10034e80675fc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
@ -3,12 +3,5 @@
|
||||
"port": 5014,
|
||||
"appsettings": "../../../../config",
|
||||
"environment": "Development"
|
||||
},
|
||||
"aws":{
|
||||
"accessKeyId": "",
|
||||
"secretAccessKey": "",
|
||||
"region": "",
|
||||
"logGroupName": "/asc/docspace/cluster/cluster_name/general",
|
||||
"logStreamName": "${hostname} - ${applicationContext} - ${date} - ${guid}"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,16 +18,9 @@ function getAndSaveAppsettings() {
|
||||
}
|
||||
|
||||
var env = nconf.get("app").environment;
|
||||
|
||||
var valueEnv = nconf.get(env);
|
||||
|
||||
var fileWithEnv = path.join(appsettings, "appsettings." + valueEnv + ".json");
|
||||
|
||||
if (fs.existsSync(fileWithEnv)) {
|
||||
nconf.file("appsettings", fileWithEnv);
|
||||
} else {
|
||||
nconf.file("appsettings", path.join(appsettings, "appsettings.json"));
|
||||
}
|
||||
|
||||
console.log('environment: ' + env);
|
||||
|
||||
nconf.file("appsettingsWithEnv", path.join(appsettings, 'appsettings.' + env + '.json'));
|
||||
nconf.file("appsettings", path.join(appsettings, 'appsettings.json'));
|
||||
nconf.file("pluginsConf", path.join(appsettings, "plugins.json"));
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ if (!fs.existsSync(dirName)) {
|
||||
fs.mkdirSync(dirName);
|
||||
}
|
||||
|
||||
const aws = config.default.get("aws");
|
||||
const aws = config.default.get("aws").cloudWatch;
|
||||
|
||||
const accessKeyId = aws.accessKeyId;
|
||||
const secretAccessKey = aws.secretAccessKey;
|
||||
@ -65,6 +65,7 @@ const options = {
|
||||
.replace("${guid}", guid)
|
||||
.replace("${date}", dateAsString);
|
||||
},
|
||||
logGroupName:logGroupName,
|
||||
awsRegion: awsRegion,
|
||||
jsonMessage: true,
|
||||
awsOptions: {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user