Skip to content

Commit

Permalink
analizators/U2U1210
Browse files Browse the repository at this point in the history
  • Loading branch information
SuhorukovAnton committed Jan 18, 2022
1 parent 6c57925 commit 78047d3
Show file tree
Hide file tree
Showing 13 changed files with 103 additions and 76 deletions.
12 changes: 9 additions & 3 deletions common/ASC.Data.Storage/RackspaceCloud/RackspaceCloudStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,8 +404,11 @@ public override void DeleteFiles(string domain, string folderPath, string patter
.Where(x => Wildcard.IsMatch(pattern, Path.GetFileName(x.Name)));

if (!files.Any()) return;

files.ToList().ForEach(x => client.DeleteObject(_private_container, x.Name));

foreach(var file in files)
{
client.DeleteObject(_private_container, file.Name);
}

if (QuotaController != null)
{
Expand Down Expand Up @@ -462,7 +465,10 @@ public override void DeleteFiles(string domain, string folderPath, DateTime from

if (!files.Any()) return;

files.ToList().ForEach(x => client.DeleteObject(_private_container, x.Name));
foreach(var file in files)
{
client.DeleteObject(_private_container, file.Name);
}

if (QuotaController != null)
{
Expand Down
5 changes: 2 additions & 3 deletions common/ASC.FederatedLogin/AccountLinker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ private List<LoginProfile> GetLinkedProfilesFromDB(string obj)
//Retrieve by uinque id
return AccountLinks
.Where(r => r.Id == obj)
.Select(r => r.Profile)
.ToList()
.ConvertAll(x => LoginProfile.CreateFromSerializedString(Signature, InstanceCrypto, x));
.Select(x => LoginProfile.CreateFromSerializedString(Signature, InstanceCrypto, x.Profile))
.ToList();
}

public void AddLink(string obj, LoginProfile profile)
Expand Down
9 changes: 4 additions & 5 deletions common/ASC.VoipService/Dao/VoipDao.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ public virtual IEnumerable<VoipPhone> GetAllNumbers()
{
return VoipDbContext.VoipNumbers
.Where(r => r.TenantId == TenantID)
.ToList()
.ConvertAll(ToPhone);
.Select(ToPhone);
}

public virtual IEnumerable<VoipPhone> GetNumbers(params string[] ids)
Expand All @@ -106,7 +105,7 @@ public virtual IEnumerable<VoipPhone> GetNumbers(params string[] ids)
numbers = numbers.Where(r => ids.Any(a => a == r.Number || a == r.Id));
}

return numbers.ToList().ConvertAll(ToPhone);
return numbers.Select(ToPhone);
}

public VoipPhone GetNumber(string id)
Expand Down Expand Up @@ -204,7 +203,7 @@ public IEnumerable<VoipCall> GetCalls(VoipCallFilter filter)
query = query.Skip((int)filter.Offset);
query = query.Take((int)filter.Max * 3);

var calls = query.ToList().ConvertAll(ToCall);
var calls = query.Select(ToCall);

calls = calls.GroupJoin(calls, call => call.Id, h => h.ParentID, (call, h) =>
{
Expand Down Expand Up @@ -249,7 +248,7 @@ public IEnumerable<VoipCall> GetMissedCalls(Guid agent, long count = 0, DateTime
.Max(tmp => tmp.DialDate)
}).Where(r => r.dbVoipCall.DbVoipCall.DialDate >= r.tmpDate || r.tmpDate == default);

return a.ToList().ConvertAll(r => ToCall(r.dbVoipCall));
return a.Select(r => ToCall(r.dbVoipCall)).ToList();
}

private IQueryable<CallContact> GetCallsQuery(VoipCallFilter filter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,17 +455,31 @@ private Folder MoveFld(Folder folder, string newUrl, bool delete = true)
var newFolder = CreateFolder(newUrl);

if (delete)
{
folder.Folders.ToList().ForEach(r => MoveFolder(r.ServerRelativeUrl, newUrl));
folder.Files.ToList().ForEach(r => MoveFile(r.ServerRelativeUrl, newUrl));
{
foreach (var f in folder.Folders)
{
MoveFolder(f.ServerRelativeUrl, newUrl);
}

foreach (var f in folder.Files)
{
MoveFile(f.ServerRelativeUrl, newUrl);
}

folder.DeleteObject();
clientContext.ExecuteQuery();
}
else
{
folder.Folders.ToList().ForEach(r => CopyFolder(r.ServerRelativeUrl, newUrl));
folder.Files.ToList().ForEach(r => CopyFile(r.ServerRelativeUrl, newUrl));
{
foreach (var f in folder.Folders)
{
CopyFolder(f.ServerRelativeUrl, newUrl);
}

foreach(var f in folder.Files)
{
CopyFile(f.ServerRelativeUrl, newUrl);
}
}

return newFolder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,12 @@ private ItemNameValueCollection<T> GetEntriesPathId(IServiceScope scope)
}
if (0 < Folders.Count)
{
FilesSecurity.FilterRead(FolderDao.GetFolders(Files)).Cast<FileEntry<T>>().ToList()
.ForEach(folder => fileMarker.RemoveMarkAsNew(folder));
var folders = FilesSecurity.FilterRead(FolderDao.GetFolders(Files));

foreach(var folder in folders)
{
fileMarker.RemoveMarkAsNew(folder);
}

var filesInFolder = GetFilesInFolders(scope, Folders, string.Empty);
entriesPathId.Add(filesInFolder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,12 @@ private void Do<TTo>(IServiceScope scope, TTo tto)
needToMark.AddRange(MoveOrCopyFolders(scope, Folders, toFolder, _copy));
needToMark.AddRange(MoveOrCopyFiles(scope, Files, toFolder, _copy));

needToMark.Distinct().ToList().ForEach(x => fileMarker.MarkAsNew(x));
var ntm = needToMark.Distinct();

foreach(var n in ntm)
{
fileMarker.MarkAsNew(n);
}
}

private List<FileEntry<TTo>> MoveOrCopyFolders<TTo>(IServiceScope scope, List<T> folderIds, Folder<TTo> toFolder, bool copy)
Expand Down
13 changes: 7 additions & 6 deletions products/ASC.Files/Core/Utils/EntryManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -600,13 +600,14 @@ public IEnumerable<Folder<string>> GetThirpartyFolders<T>(Folder<T> parent, stri
if (folderList.Any())
{
var securityDao = DaoFactory.GetSecurityDao<string>();
securityDao.GetPureShareRecords(folderList)
var ids = securityDao.GetPureShareRecords(folderList)
//.Where(x => x.Owner == SecurityContext.CurrentAccount.ID)
.Select(x => x.EntryId).Distinct().ToList()
.ForEach(id =>
{
folderList.First(y => y.ID.Equals(id)).Shared = true;
});
.Select(x => x.EntryId).Distinct();

foreach(var id in ids)
{
folderList.First(y => y.ID.Equals(id)).Shared = true;
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions products/ASC.Files/Core/Utils/FileConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ private void CheckConvertFilesStatus(object _)
{
timer.Change(Timeout.Infinite, Timeout.Infinite);

conversionQueue.Where(x => !string.IsNullOrEmpty(x.Value.Processed)
var queues = conversionQueue.Where(x => !string.IsNullOrEmpty(x.Value.Processed)
&& (x.Value.Progress == 100 && DateTime.UtcNow - x.Value.StopDateTime > TimeSpan.FromMinutes(1) ||
DateTime.UtcNow - x.Value.StopDateTime > TimeSpan.FromMinutes(10)))
.ToList()
.ForEach(x =>
{
conversionQueue.Remove(x);
cache.Remove(GetKey(x.Key));
});
DateTime.UtcNow - x.Value.StopDateTime > TimeSpan.FromMinutes(10)));

foreach (var q in queues)
{
conversionQueue.Remove(q);
cache.Remove(GetKey(q.Key));
}

logger.DebugFormat("Run CheckConvertFilesStatus: count {0}", conversionQueue.Count);

Expand Down
29 changes: 14 additions & 15 deletions products/ASC.Files/Core/Utils/FileMarker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,22 @@ internal void ExecMarkFileAsNew<T>(AsyncTaskData<T> obj)
if (obj.FileEntry.ProviderEntry)
{
userIDs = userIDs.Where(u => !UserManager.GetUsers(u).IsVisitor(UserManager)).ToList();
}

foreach(var parentFolder in parentFolders)
{
var ids = filesSecurity
.WhoCanRead(parentFolder)
.Where(userID => userIDs.Contains(userID) && userID != obj.CurrentAccountId);
foreach (var id in ids)
{
if (userEntriesData.TryGetValue(id, out var value))
value.Add(parentFolder);
else
userEntriesData.Add(id, new List<FileEntry> { parentFolder });
}
}

parentFolders.ForEach(parentFolder =>
filesSecurity
.WhoCanRead(parentFolder)
.Where(userID => userIDs.Contains(userID) && userID != obj.CurrentAccountId)
.ToList()
.ForEach(userID =>
{
if (userEntriesData.ContainsKey(userID))
userEntriesData[userID].Add(parentFolder);
else
userEntriesData.Add(userID, new List<FileEntry> { parentFolder });
})
);



if (obj.FileEntry.RootFolderType == FolderType.USER)
{
Expand Down
19 changes: 8 additions & 11 deletions products/ASC.Files/Core/Utils/FileTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,14 @@ public void ChangeRight<T>(T fileId, Guid userId, bool check)
{
var tracker = GetTracker(fileId);
if (tracker != null)
{

tracker.EditingBy.Values
.ToList()
.ForEach(i =>
{
if (i.UserId == userId || userId == Guid.Empty)
{
i.CheckRightTime = check ? DateTime.MinValue : DateTime.UtcNow;
}
});
{
foreach(var value in tracker.EditingBy.Values)
{
if (value.UserId == userId || userId == Guid.Empty)
{
value.CheckRightTime = check ? DateTime.MinValue : DateTime.UtcNow;
}
}
SetTracker(fileId, tracker);
}
else
Expand Down
6 changes: 5 additions & 1 deletion web/ASC.Web.Api/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,11 @@ private void SaveWhiteLabelSettingsForTenant(TenantWhiteLabelSettings settings,
if (model.Logo != null)
{
var logoDict = new Dictionary<int, string>();
model.Logo.ToList().ForEach(n => logoDict.Add(Int32.Parse(n.Key), n.Value));

foreach(var l in model.Logo)
{
logoDict.Add(Int32.Parse(l.Key), l.Value);
}

TenantWhiteLabelSettingsHelper.SetLogo(settings, logoDict, storage);
}
Expand Down
4 changes: 2 additions & 2 deletions web/ASC.Web.Core/Calendars/RecurrenceRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private bool CheckDate(DateTime d)
if (ByMonthDay != null && !ByMonthDay.Contains(d.Day) && !ByMonthDay.Contains(d.Day - d.GetDaysInMonth() + 1))
return false;

if (ByDay != null && !ByDay.ToList().Exists(item => item.DayOfWeek == d.DayOfWeek))
if (ByDay != null && !ByDay.Any(item => item.DayOfWeek == d.DayOfWeek))
return false;

return true;
Expand Down Expand Up @@ -387,7 +387,7 @@ public List<DateTime> GetDates(DateTime utcStartDate, TimeZoneInfo eventTimeZone
dateRange.RemoveAll(date => (!ByMonthDay.Contains(date.Day) && !ByMonthDay.Contains(date.Day - (date.GetDaysInMonth() + 1))));

if (ByDay != null)
dateRange.RemoveAll(date => !ByDay.ToList().Exists(wd => wd.DayOfWeek == date.DayOfWeek));
dateRange.RemoveAll(date => !ByDay.Any(wd => wd.DayOfWeek == date.DayOfWeek));

if (ByDay == null && ByMonthDay == null && ByYearDay == null)
dateRange.RemoveAll(date => date.Day != d.Day);
Expand Down
25 changes: 12 additions & 13 deletions web/ASC.Web.Core/Files/FileUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,19 +330,18 @@ public Dictionary<string, List<string>> ExtsConvertible
var dbManager = FilesDbContext;
var list = dbManager.FilesConverts.Select(r => new { r.Input, r.Output }).ToList();


list.ForEach(item =>
{
var input = item.Input;
var output = item.Output;
if (string.IsNullOrEmpty(input) || string.IsNullOrEmpty(output))
return;
input = input.ToLower().Trim();
output = output.ToLower().Trim();
if (!_extsConvertible.ContainsKey(input))
_extsConvertible[input] = new List<string>();
_extsConvertible[input].Add(output);
});
foreach (var item in list)
{
var input = item.Input;
var output = item.Output;
if (string.IsNullOrEmpty(input) || string.IsNullOrEmpty(output))
continue;
input = input.ToLower().Trim();
output = output.ToLower().Trim();
if (!_extsConvertible.ContainsKey(input))
_extsConvertible[input] = new List<string>();
_extsConvertible[input].Add(output);
}
}
return _extsConvertible;
}
Expand Down

0 comments on commit 78047d3

Please sign in to comment.