Merge branch 'master' into feature/files
This commit is contained in:
commit
f4e8912cc2
@ -309,7 +309,7 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
Entries = new ItemList<FileEntry>(entries.ToList()),
|
||||
FolderPathParts = new ItemList<T>(breadCrumbs.Select(f => f.ID)),
|
||||
FolderInfo = parent,
|
||||
RootFoldersIdMarkedAsNew = FileMarker.GetRootFoldersIdMarkedAsNew<T>()
|
||||
New = FileMarker.GetRootFoldersIdMarkedAsNew(parentId)
|
||||
};
|
||||
|
||||
return result;
|
||||
|
@ -77,6 +77,8 @@ namespace ASC.Api.Documents
|
||||
[DataMember(IsRequired = false, EmitDefaultValue = true)]
|
||||
public int Total { get; set; }
|
||||
|
||||
public int New { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="folderItems"></param>
|
||||
@ -151,6 +153,7 @@ namespace ASC.Api.Documents
|
||||
result.Current = FolderWrapperHelper.Get(folderItems.FolderInfo);
|
||||
result.Count = result.Files.Count + result.Folders.Count;
|
||||
result.Total = folderItems.Total;
|
||||
result.New = folderItems.New;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -32,6 +32,7 @@ using System.Threading;
|
||||
using ASC.Common.Security.Authentication;
|
||||
using ASC.Core.Tenants;
|
||||
using ASC.Files.Core;
|
||||
using ASC.Web.Files.Classes;
|
||||
using ASC.Web.Files.Utils;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -110,8 +111,18 @@ namespace ASC.Web.Files.Services.WCFService.FileOperations
|
||||
ProgressStep();
|
||||
});
|
||||
|
||||
var newrootfolder = fileMarker
|
||||
.GetRootFoldersIdMarkedAsNew<T>()
|
||||
var globalFolder = scope.ServiceProvider.GetService<GlobalFolder>();
|
||||
var daoFactory = scope.ServiceProvider.GetService<IDaoFactory>();
|
||||
var rootIds = new List<int>
|
||||
{
|
||||
globalFolder.GetFolderMy(fileMarker, daoFactory),
|
||||
globalFolder.GetFolderCommon(fileMarker, daoFactory),
|
||||
globalFolder.GetFolderShare(daoFactory),
|
||||
globalFolder.GetFolderProjects(daoFactory),
|
||||
};
|
||||
|
||||
var newrootfolder =
|
||||
rootIds.Select(r => new KeyValuePair<int, int>(r, fileMarker.GetRootFoldersIdMarkedAsNew(r)))
|
||||
.Select(item => string.Format("new_{{\"key\"? \"{0}\", \"value\"? \"{1}\"}}", item.Key, item.Value));
|
||||
|
||||
Status += string.Join(SPLIT_CHAR, newrootfolder.ToArray());
|
||||
|
@ -24,7 +24,6 @@
|
||||
*/
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
using ASC.Files.Core;
|
||||
@ -46,7 +45,6 @@ namespace ASC.Web.Files.Services.WCFService
|
||||
[DataMember(IsRequired = false, Name = "folder_info")]
|
||||
public Folder<T> FolderInfo { get; set; }
|
||||
|
||||
[DataMember(IsRequired = false, Name = "root_folders_id_marked_as_new")]
|
||||
public Dictionary<T, int> RootFoldersIdMarkedAsNew { get; set; }
|
||||
public int New { get; set; }
|
||||
}
|
||||
}
|
@ -455,49 +455,26 @@ namespace ASC.Web.Files.Utils
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<T, int> GetRootFoldersIdMarkedAsNew<T>()
|
||||
public int GetRootFoldersIdMarkedAsNew<T>(T rootId)
|
||||
{
|
||||
var rootIds = new List<T>
|
||||
{
|
||||
GlobalFolder.GetFolderMy<T>(this, DaoFactory),
|
||||
GlobalFolder.GetFolderCommon<T>(this, DaoFactory),
|
||||
GlobalFolder.GetFolderShare<T>(DaoFactory),
|
||||
GlobalFolder.GetFolderProjects<T>(DaoFactory)
|
||||
};
|
||||
|
||||
var requestIds = new List<T>();
|
||||
var news = new Dictionary<T, int>();
|
||||
|
||||
rootIds.ForEach(rootId =>
|
||||
{
|
||||
var fromCache = GetCountFromCahce(rootId);
|
||||
if (fromCache == -1)
|
||||
{
|
||||
requestIds.Add(rootId);
|
||||
}
|
||||
else if ((fromCache) > 0)
|
||||
{
|
||||
news.Add(rootId, fromCache);
|
||||
}
|
||||
});
|
||||
|
||||
if (requestIds.Any())
|
||||
var fromCache = GetCountFromCahce(rootId);
|
||||
if (fromCache == -1)
|
||||
{
|
||||
IEnumerable<Tag> requestTags;
|
||||
var tagDao = DaoFactory.GetTagDao<T>();
|
||||
var folderDao = DaoFactory.GetFolderDao<T>();
|
||||
requestTags = tagDao.GetNewTags(AuthContext.CurrentAccount.ID, folderDao.GetFolders(requestIds.ToArray()));
|
||||
var requestTags = tagDao.GetNewTags(AuthContext.CurrentAccount.ID, folderDao.GetFolder(rootId));
|
||||
var requestTag = requestTags.FirstOrDefault(tag => tag.EntryId.Equals(rootId));
|
||||
var count = requestTag == null ? 0 : requestTag.Count;
|
||||
InsertToCahce(rootId, count);
|
||||
|
||||
requestIds.ForEach(requestId =>
|
||||
{
|
||||
var requestTag = requestTags.FirstOrDefault(tag => tag.EntryId.Equals(requestId));
|
||||
InsertToCahce(requestId, requestTag == null ? 0 : requestTag.Count);
|
||||
});
|
||||
|
||||
news = news.Concat(requestTags.ToDictionary(x => (T)Convert.ChangeType(x.EntryId, typeof(T)), x => x.Count)).ToDictionary(x => x.Key, x => x.Value);
|
||||
return count;
|
||||
}
|
||||
else if (fromCache > 0)
|
||||
{
|
||||
return fromCache;
|
||||
}
|
||||
|
||||
return news;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<FileEntry> MarkedItems<T>(Folder<T> folder)
|
||||
|
Loading…
Reference in New Issue
Block a user