private Activity GetFileActivity(FileEntry fileEntry, DateTimeRange range)
        {
            object wrapper;

            if (fileEntry is File)
                wrapper = new FileWrapper((File) fileEntry);
            else
                wrapper = new FolderWrapper((Folder) fileEntry);

            var activity = new Activity(Documents, wrapper)
            {
                Action = (range.In(fileEntry.CreateOn) ? ActivityAction.Created : ActivityAction.Undefined) | (range.In(fileEntry.ModifiedOn) ? ActivityAction.Updated : ActivityAction.Undefined) | (range.In(fileEntry.SharedToMeOn) ? ActivityAction.Shared : ActivityAction.Undefined),
                ItemType = "file",
            };

            if (range.In(fileEntry.CreateOn))
            {
                activity.CreatedBy = fileEntry.CreateBy;
                activity.When = fileEntry.CreateOn;
            }
            else if (range.In(fileEntry.ModifiedOn))
            {
                activity.CreatedBy = fileEntry.ModifiedBy;
                activity.When = fileEntry.ModifiedOn;
            }
            else if (range.In(fileEntry.SharedToMeOn))
            {
                activity.CreatedBy = new Guid(fileEntry.SharedToMeBy);
                activity.When = fileEntry.SharedToMeOn;
            }

            return activity;
        }
예제 #2
0
 public static bool CanSetAccess(FileEntry entry)
 {
     return
         entry != null
         && (entry.RootFolderType == FolderType.COMMON && Global.IsAdministrator
             || entry.RootFolderType == FolderType.USER && (Equals(entry.RootFolderId, Global.FolderMy) || Global.GetFilesSecurity().CanEdit(entry)));
 }
예제 #3
0
        public static void Send(FileEntry entry1, FileEntry entry2, Dictionary<string, string> headers, MessageAction action, params string[] description)
        {
            // do not log actions in users folder
            if (entry1 == null || entry2 == null || entry1.RootFolderType == FolderType.USER || entry2.RootFolderType == FolderType.USER) return;

            SendHeadersMessage(headers, action, description);
        }
        private static UserActivity ApplyCustomeActivityParams(FileEntry entry, string imgFileName, string actionText, int actionType, int businessValue, string containerId)
        {
            if (entry == null) return null;

            string url;
            var moduleId = ProductEntryPoint.ID;
            var additionalData = "";
            var securityId = "0";

            if (entry.RootFolderType == FolderType.BUNCH)
            {
                var title = Global.DaoFactory.GetFolderDao().GetFolder(entry.RootFolderId).Title;

                if (title.StartsWith("projects/project/"))
                {
                    moduleId = ProjectModuleId;
                    additionalData = "File||";
                    containerId = title.Replace("projects/project/", "");
                    securityId = "File||" + containerId;
                }
                else if (title.StartsWith("crm/crm_common/"))
                {
                    moduleId = CrmModuleId;
                    securityId = "6|" + entry.UniqID;
                }
            }

            if (entry is File)
            {
                url = FileUtility.ExtsWebPreviewed.Contains(FileUtility.GetFileExtension(entry.Title), StringComparer.CurrentCultureIgnoreCase)
                          ? CommonLinkUtility.GetFileWebViewerUrl(entry.ID)
                          : ((File) entry).ViewUrl;
            }
            else
            {
                url = PathProvider.GetFolderUrl((Folder) entry);
            }

            var ua = new UserActivity
                         {
                             Title = entry.Title,
                             ContentID = entry.UniqID,
                             URL = url,
                             ModuleID = moduleId,
                             ProductID = moduleId,
                             TenantID = TenantProvider.CurrentTenantID,
                             Date = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                             ImageOptions = new ImageOptions {PartID = ProductEntryPoint.ID, ImageFileName = imgFileName},
                             ActionText = actionText,
                             UserID = SecurityContext.CurrentAccount.ID,
                             ActionType = actionType,
                             BusinessValue = businessValue,
                             AdditionalData = additionalData,
                             ContainerID = containerId,
                             SecurityId = securityId
                         };
            return ua;
        }
예제 #5
0
 public Tag(string name, TagType type, Guid owner, FileEntry entry)
 {
     TagName = name;
     TagType = type;
     Owner = owner;
     if (entry != null)
     {
         EntryId = entry.ID;
         EntryType = entry is File ? FileEntryType.File : FileEntryType.Folder;
     }
 }
예제 #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="entry"></param>
 protected FileEntryWrapper(FileEntry entry)
 {
     Id = entry.ID;
     Title = entry.Title;
     Access = entry.Access;
     SharedByMe = entry.SharedByMe;
     Created = (ApiDateTime)entry.CreateOn;
     CreatedBy = EmployeeWraper.Get(entry.CreateBy);
     Updated = (ApiDateTime)entry.ModifiedOn;
     UpdatedBy = EmployeeWraper.Get(entry.ModifiedBy);
     RootFolderType = entry.RootFolderType;
 }
예제 #7
0
        public static void Send(FileEntry entry, HttpRequest request, MessageAction action, params string[] description)
        {
            // do not log actions in users folder
            if (entry == null || entry.RootFolderType == FolderType.USER) return;

            if (request == null)
            {
                log.Debug(string.Format("Empty Http Request for \"{0}\" type of event", action));
                return;
            }

            MessageService.Send(request, action, description);
        }
        public bool CanRead(FileEntry file, Guid userId)
        {
            var eventDao = Global.DaoFactory.GetRelationshipEventDao();
            var tagDao = FilesIntegration.GetTagDao();

            var eventIds = tagDao.GetTags(file.ID, FileEntryType.File, TagType.System)
                       .Where(x => x.TagName.StartsWith("RelationshipEvent_"))
                       .Select(x => Convert.ToInt32(x.TagName.Split(new[] { '_' })[1]));

            if (!eventIds.Any()) return false;

            return CRMSecurity.CanAccessTo(eventDao.GetByID(eventIds.First()));
        }
예제 #9
0
        private bool Can(FileEntry file, Guid userId, SecurityAction action)
        {
            if (!ProjectSecurity.CanReadFiles(Project)) return false;

            if (IsAdmin(userId)) return true;
            if (file == null || Project == null) return false;
            if (file is Folder && ((Folder)file).FolderType == FolderType.DEFAULT && file.CreateBy == userId) return true;
            if (file is File && file.CreateBy == userId) return true;

            switch (action)
            {
                case SecurityAction.Read: return Project.Private ? dao.IsInTeam(Project.ID, userId) : true;
                case SecurityAction.Create: return dao.IsInTeam(Project.ID, userId);
                case SecurityAction.Edit: return Project.Responsible == userId;
                case SecurityAction.Delete: return Project.Responsible == userId;
                default: return false;
            }
        }
예제 #10
0
        public static void SendShareNotice(FileEntry fileEntry, Dictionary<Guid, FileShare> recipients, string message)
        {
            if (fileEntry == null || recipients.Count == 0) return;

            using (var folderDao = Global.DaoFactory.GetFolderDao())
            {
                if (fileEntry is File
                    && folderDao.GetFolder(((File)fileEntry).FolderID) == null) return;

                String url;
                if (fileEntry is File)
                {
                    url = FilesLinkUtility.GetFileWebPreviewUrl(fileEntry.Title, fileEntry.ID);
                }
                else
                    url = PathProvider.GetFolderUrl(((Folder)fileEntry));

                var recipientsProvider = NotifySource.Instance.GetRecipientsProvider();

                foreach (var recipientPair in recipients)
                {
                    var u = CoreContext.UserManager.GetUsers(recipientPair.Key);
                    var culture = string.IsNullOrEmpty(u.CultureName)
                                      ? CoreContext.TenantManager.GetCurrentTenant().GetCulture()
                                      : CultureInfo.GetCultureInfo(u.CultureName);

                    var aceString = GetAccessString(recipientPair.Value, culture);
                    var recipient = recipientsProvider.GetRecipient(u.ID.ToString());

                    Instance.SendNoticeAsync(
                        fileEntry is File ? NotifyConstants.Event_ShareDocument : NotifyConstants.Event_ShareFolder,
                        fileEntry.UniqID,
                        recipient,
                        true,
                        new TagValue(NotifyConstants.Tag_DocumentTitle, fileEntry.Title),
                        new TagValue(NotifyConstants.Tag_FolderID, fileEntry.ID),
                        new TagValue(NotifyConstants.Tag_DocumentUrl, CommonLinkUtility.GetFullAbsolutePath(url)),
                        new TagValue(NotifyConstants.Tag_AccessRights, aceString),
                        new TagValue(NotifyConstants.Tag_Message, message.HtmlEncode())
                        );
                }
            }
        }
예제 #11
0
        private bool Can(FileEntry fileEntry, Guid userId, SecurityAction action)
        {
            if (!ProjectSecurity.CanReadFiles(Project, userId)) return false;

            if (ProjectSecurity.IsAdministrator(userId)) return true;
            if (fileEntry == null || Project == null) return false;
            if (fileEntry is Folder && ((Folder) fileEntry).FolderType == FolderType.DEFAULT && fileEntry.CreateBy == userId) return true;
            if (fileEntry is File && fileEntry.CreateBy == userId) return true;

            switch (action)
            {
                case SecurityAction.Read:
                    return !Project.Private || dao.IsInTeam(Project.ID, userId);
                case SecurityAction.Create:
                case SecurityAction.Edit:
                    return dao.IsInTeam(Project.ID, userId)
                           && (!ProjectSecurity.IsVisitor(userId) || fileEntry is Folder && ((Folder) fileEntry).FolderType == FolderType.BUNCH);
                case SecurityAction.Delete:
                    return !ProjectSecurity.IsVisitor(userId) && Project.Responsible == userId;
                default:
                    return false;
            }
        }
예제 #12
0
 public bool CanDelete(FileEntry file, Guid userId)
 {
     return Can(file, userId, SecurityAction.Delete);
 }
예제 #13
0
 public bool CanRead(FileEntry file, Guid userId)
 {
     return Can(file, userId, SecurityAction.Read);
 }
예제 #14
0
 public static Tag New(Guid owner, FileEntry file)
 {
     return new Tag("new", TagType.New, owner, file);
 }
예제 #15
0
        public static List<AceWrapper> GetSharedInfo(FileEntry entry)
        {
            if (!CanSetAccess(entry)) throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException);

            var linkAccess = FileShare.Restrict;
            var result = new List<AceWrapper>();

            var fileSecurity = Global.GetFilesSecurity();

            var records = fileSecurity
                .GetShares(entry)
                .GroupBy(r => r.Subject)
                .Select(g => g.OrderBy(r => r.Level)
                              .ThenBy(r => r.Level)
                              .ThenByDescending(r => r.Share).FirstOrDefault());

            foreach (var r in records)
            {
                if (r.Subject == FileConstant.ShareLinkId)
                {
                    linkAccess = r.Share;
                    continue;
                }

                var u = CoreContext.UserManager.GetUsers(r.Subject);
                var isgroup = false;
                var title = u.DisplayUserName(false);

                if (u.ID == Constants.LostUser.ID)
                {
                    var g = CoreContext.GroupManager.GetGroupInfo(r.Subject);
                    isgroup = true;
                    title = g.Name;

                    if (g.ID == Constants.GroupAdmin.ID)
                        title = FilesCommonResource.Admin;
                    if (g.ID == Constants.GroupEveryone.ID)
                        title = FilesCommonResource.Everyone;

                    if (g.ID == Constants.LostGroupInfo.ID)
                    {
                        fileSecurity.RemoveSubject(r.Subject);
                        continue;
                    }
                }

                var w = new AceWrapper
                    {
                        SubjectId = r.Subject,
                        SubjectName = title,
                        SubjectGroup = isgroup,
                        Share = r.Share,
                        Owner =
                            entry.RootFolderType == FolderType.USER
                                ? entry.RootFolderCreator == r.Subject
                                : entry.CreateBy == r.Subject,
                        LockedRights = r.Subject == SecurityContext.CurrentAccount.ID
                    };
                result.Add(w);
            }

            if (entry is File && result.All(w => w.SubjectId != FileConstant.ShareLinkId))
            {
                var w = new AceWrapper
                    {
                        SubjectId = FileConstant.ShareLinkId,
                        SubjectName = FileShareLink.GetLink((File)entry),
                        SubjectGroup = true,
                        Share = linkAccess,
                        Owner = false
                    };
                result.Add(w);
            }

            if (!result.Any(w => w.Owner))
            {
                var ownerId = entry.RootFolderType == FolderType.USER ? entry.RootFolderCreator : entry.CreateBy;
                var w = new AceWrapper
                    {
                        SubjectId = ownerId,
                        SubjectName = Global.GetUserName(ownerId),
                        SubjectGroup = false,
                        Share = FileShare.ReadWrite,
                        Owner = true
                    };
                result.Add(w);
            }

            if (result.Any(w => w.SubjectId == SecurityContext.CurrentAccount.ID))
                result.Single(w => w.SubjectId == SecurityContext.CurrentAccount.ID).LockedRights =
                    true;

            if (entry.RootFolderType == FolderType.COMMON)
            {
                if (result.All(w => w.SubjectId != Constants.GroupAdmin.ID))
                {
                    var w = new AceWrapper
                        {
                            SubjectId = Constants.GroupAdmin.ID,
                            SubjectName = FilesCommonResource.Admin,
                            SubjectGroup = true,
                            Share = FileShare.ReadWrite,
                            Owner = false,
                            LockedRights = true,
                        };
                    result.Add(w);
                }
                if (result.All(w => w.SubjectId != Constants.GroupEveryone.ID))
                {
                    var w = new AceWrapper
                        {
                            SubjectId = Constants.GroupEveryone.ID,
                            SubjectName = FilesCommonResource.Everyone,
                            SubjectGroup = true,
                            Share = fileSecurity.DefaultCommonShare,
                            Owner = false,
                            DisableRemove = true
                        };
                    result.Add(w);
                }
            }

            return result;
        }
예제 #16
0
        public static IEnumerable<Guid> GetProjectTeam(FileEntry fileEntry)
        {
            using (var folderDao = DaoFactory.GetFolderDao())
            {
                var path = folderDao.GetBunchObjectID(fileEntry.RootFolderId);

                var projectID = path.Split('/').Last();

                if (String.IsNullOrEmpty(projectID)) return new List<Guid>();

                var apiUrl = String.Format("project/{0}/team.json", projectID);

                JToken responseApi;
                try
                {
                    responseApi = JObject.Parse(GetApiResponse(apiUrl))["response"];
                }
                catch (Exception ex)
                {
                    Logger.Error(ex);
                    return new List<Guid>();
                }

                if (!(responseApi is JArray)) return new List<Guid>();

                return responseApi.Children()
                                  .Where(x => x["canReadFiles"].Value<bool>())
                                  .Select(x => new Guid(x["id"].Value<String>()))
                                  .Where(id => id != SecurityContext.CurrentAccount.ID);
            }
        }
예제 #17
0
        public static void RemoveMarkAsNewForAll(FileEntry fileEntry)
        {
            List<Guid> userIDs;

            using (var tagDao = Global.DaoFactory.GetTagDao())
            {
                var tags = tagDao.GetTags(fileEntry.ID, fileEntry is File ? FileEntryType.File : FileEntryType.Folder, TagType.New);
                userIDs = tags.Select(tag => tag.Owner).Distinct().ToList();
            }

            foreach (var userID in userIDs)
            {
                RemoveMarkAsNew(fileEntry, userID);
            }
        }
예제 #18
0
 public void MarkAsNew(Guid subject, FileEntry fileEntry)
 {
 }
예제 #19
0
        private static void SendInitiatorMessage(FileEntry entry, MessageInitiator initiator, MessageAction action, params string[] description)
        {
            // do not log actions in users folder
            if (entry == null || entry.RootFolderType == FolderType.USER) return;

            MessageService.Send(initiator, action, description);
        }
예제 #20
0
 internal string GetCreateByString(FileEntry fileEntry)
 {
     return(!fileEntry.CreateBy.Equals(Guid.Empty) ? Global.GetUserName(fileEntry.CreateBy) : fileEntry._createByString);
 }
예제 #21
0
 public static Tag New(Guid owner, FileEntry entry)
 {
     return New(owner, entry, 1);
 }
예제 #22
0
 public static void MarkAsNew(FileEntry fileEntry)
 {
     MarkAsNew(fileEntry, null);
 }
예제 #23
0
 public static Tag New(Guid owner, FileEntry entry, int count)
 {
     return new Tag("new", TagType.New, owner, entry, count);
 }
예제 #24
0
 public bool CanEdit(FileEntry file, Guid userId)
 {
     return Can(file, userId, SecurityAction.Edit);
 }
예제 #25
0
 public bool CanRead(FileEntry file, int projectId)
 {
     return GetFileSecurity(projectId).CanRead(file, SecurityContext.CurrentAccount.ID);
 }
예제 #26
0
 internal string GetModifiedByString(FileEntry fileEntry)
 {
     return(!fileEntry.ModifiedBy.Equals(Guid.Empty) ? Global.GetUserName(fileEntry.ModifiedBy) : fileEntry._modifiedByString);
 }
예제 #27
0
        internal FileShare GetFileShare(FileEntry file, int projectId)
        {
            if (!CanRead(file, projectId)) return FileShare.Restrict;
            if (!CanCreate(file, projectId) || !CanEdit(file, projectId)) return FileShare.Read;
            if (!CanDelete(file, projectId)) return FileShare.ReadWrite;

            return FileShare.None;
        }
예제 #28
0
        public static void MarkAsNew(FileEntry fileEntry, List<Guid> userIDs)
        {
            if (CoreContext.Configuration.Personal) return;

            if (fileEntry == null) return;
            userIDs = userIDs ?? new List<Guid>();

            var taskData = new AsyncTaskData
                {
                    FileEntry = (FileEntry)fileEntry.Clone(),
                    UserIDs = userIDs
                };

            if (fileEntry.RootFolderType == FolderType.BUNCH && !userIDs.Any())
            {
                var projectTeam = Global.GetProjectTeam(fileEntry);

                if (!projectTeam.Any()) return;

                taskData.UserIDs = projectTeam.ToList();
            }

            lock (SyncObj)
            {
                AsyncTasks.Add(taskData);

                if (!AsyncTasks.IsStarted)
                    AsyncTasks.Start(ExecMarkFileAsNew);
            }
        }
예제 #29
0
        public static void SetAceObject(List<AceWrapper> aceWrappers, FileEntry entry, bool notify, string message)
        {
            if (entry == null) throw new ArgumentNullException(FilesCommonResource.ErrorMassage_BadRequest);
            if (!CanSetAccess(entry)) throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException);

            var fileSecurity = Global.GetFilesSecurity();

            var defaultShare = entry.RootFolderType == FolderType.COMMON
                                   ? fileSecurity.DefaultCommonShare
                                   : fileSecurity.DefaultMyShare;

            var entryType = entry is File ? FileEntryType.File : FileEntryType.Folder;
            var recipients = new Dictionary<Guid, FileShare>();

            foreach (var w in aceWrappers.OrderByDescending(ace => ace.SubjectGroup))
            {
                var subjects = fileSecurity.GetUserSubjects(w.SubjectId);

                if (entry.RootFolderType == FolderType.COMMON
                    && subjects.Contains(Constants.GroupAdmin.ID))
                    continue;

                var ace = fileSecurity.GetShares(entry)
                                      .Where(r => subjects.Contains(r.Subject))
                                      .OrderBy(r => subjects.IndexOf(r.Subject))
                                      .ThenBy(r => r.Level)
                                      .ThenByDescending(r => r.Share)
                                      .FirstOrDefault();

                var parentShare = ace != null && !(ace.Subject == w.SubjectId && ace.Share == w.Share) ? ace.Share : defaultShare;
                var share = parentShare == w.Share ? FileShare.None : w.Share;

                if (w.SubjectId == FileConstant.ShareLinkId)
                {
                    if (w.Share == FileShare.ReadWrite && CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID).IsVisitor()) throw new SecurityException(FilesCommonResource.ErrorMassage_SecurityException);
                    share = w.Share == FileShare.Restrict ? FileShare.None : w.Share;
                }

                fileSecurity.Share(entry.ID, entryType, w.SubjectId, share);

                if (w.SubjectId == FileConstant.ShareLinkId)
                    continue;

                entry.Access = share;

                var listUsersId = new List<Guid>();

                if (w.SubjectGroup)
                    listUsersId = CoreContext.UserManager.GetUsersByGroup(w.SubjectId).Select(ui => ui.ID).ToList();
                else
                    listUsersId.Add(w.SubjectId);
                listUsersId.Remove(SecurityContext.CurrentAccount.ID);

                if (entryType == FileEntryType.File)
                {
                    listUsersId.ForEach(uid => FileTracker.ChangeRight(entry.ID, uid, true));
                }

                var addRecipient = share == FileShare.Read
                                   || share == FileShare.ReadWrite
                                   || share == FileShare.None && entry.RootFolderType == FolderType.COMMON;
                listUsersId.ForEach(id =>
                                        {
                                            recipients.Remove(id);
                                            if (addRecipient)
                                            {
                                                recipients.Add(id, share);
                                            }
                                        });
            }

            if (recipients.Any())
            {
                if (entryType == FileEntryType.File
                    || ((Folder)entry).TotalSubFolders + ((Folder)entry).TotalFiles > 0
                    || entry.ProviderEntry)
                {
                    FileMarker.MarkAsNew(entry, recipients.Keys.ToList());
                }

                if (entry.RootFolderType == FolderType.USER
                    && notify)
                {
                    NotifyClient.SendShareNotice(entry, recipients, message);
                }
            }
        }
예제 #30
0
 public static void Send(FileEntry entry, MessageInitiator initiator, MessageAction action, params string[] description)
 {
     SendInitiatorMessage(entry, initiator, action, description);
 }
예제 #31
0
 public static void RemoveMarkAsNew(FileEntry fileEntry)
 {
     RemoveMarkAsNew(fileEntry, SecurityContext.CurrentAccount.ID);
 }
예제 #32
0
        public static void RemoveMarkAsNew(FileEntry fileEntry, Guid userID)
        {
            if (CoreContext.Configuration.Personal) return;

            if (fileEntry == null) return;

            using (var tagDao = Global.DaoFactory.GetTagDao())
            using (var folderDao = Global.DaoFactory.GetFolderDao())
            {
                if (!tagDao.GetNewTags(userID, fileEntry).Any()) return;

                object folderID;
                int valueNew;
                var userFolderId = folderDao.GetFolderID(FileConstant.ModuleId, "my", userID.ToString(), false);

                var removeTags = new List<Tag>();

                if (fileEntry is File)
                {
                    folderID = ((File)fileEntry).FolderID;

                    removeTags.Add(Tag.New(userID, fileEntry));
                    valueNew = 1;
                }
                else
                {
                    folderID = fileEntry.ID;

                    var listTags = tagDao.GetNewTags(userID, (Folder)fileEntry, true).ToList();
                    valueNew = listTags.FirstOrDefault(tag => tag.EntryId.Equals(fileEntry.ID)).Count;

                    if (Equals(fileEntry.ID, userFolderId) || Equals(fileEntry.ID, Global.FolderCommon) || Equals(fileEntry.ID, Global.FolderShare))
                    {
                        var folderTags = listTags.Where(tag => tag.EntryType == FileEntryType.Folder);

                        var providerFolderTags = folderTags.Select(tag => new KeyValuePair<Tag, Folder>(tag, folderDao.GetFolder(tag.EntryId)))
                                                           .Where(pair => pair.Value.ProviderEntry).ToList();

                        foreach (var providerFolderTag in providerFolderTags)
                        {
                            listTags.Remove(providerFolderTag.Key);
                            listTags.AddRange(tagDao.GetNewTags(userID, providerFolderTag.Value, true));
                        }
                    }

                    removeTags.AddRange(listTags);
                }

                var parentFolders = folderDao.GetParentFolders(folderID);
                parentFolders.Reverse();

                var rootFolder = parentFolders.Last();
                if (rootFolder.RootFolderType == FolderType.BUNCH)
                    parentFolders.Add(folderDao.GetFolder(Global.FolderProjects));
                else if (rootFolder.ProviderEntry && rootFolder.RootFolderType == FolderType.COMMON)
                    parentFolders.Add(folderDao.GetFolder(Global.FolderCommon));
                else if (rootFolder.RootFolderType == FolderType.USER)
                {
                    if (rootFolder.ProviderEntry && rootFolder.RootFolderCreator == userID)
                        parentFolders.Add(folderDao.GetFolder(userFolderId));
                    else if (!rootFolder.ProviderEntry && !Equals(rootFolder.RootFolderId, userFolderId)
                             || rootFolder.ProviderEntry && rootFolder.RootFolderCreator != userID)
                        parentFolders.Add(folderDao.GetFolder(Global.FolderShare));
                }

                var updateTags = new List<Tag>();
                foreach (var parentFolder in parentFolders)
                {
                    var parentTag = tagDao.GetNewTags(userID, parentFolder).FirstOrDefault();

                    if (parentTag != null)
                    {
                        parentTag.Count -= valueNew;

                        if (parentTag.Count > 0)
                        {
                            updateTags.Add(parentTag);
                        }
                        else
                        {
                            removeTags.Add(parentTag);
                        }
                    }
                }

                if (updateTags.Any())
                    tagDao.UpdateNewTags(updateTags.ToArray());
                if (removeTags.Any())
                    tagDao.RemoveTags(removeTags.ToArray());
            }
        }
예제 #33
0
 public string GetDownloadUrl <T>(FileEntry <T> fileEntry)
 {
     return(FilesLinkUtility.GetFileDownloadUrl(fileEntry.ID));
 }