当前位置: 首页>>代码示例>>C#>>正文


C# ItemList.OrderByDescending方法代码示例

本文整理汇总了C#中ItemList.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# ItemList.OrderByDescending方法的具体用法?C# ItemList.OrderByDescending怎么用?C# ItemList.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ItemList的用法示例。


在下文中一共展示了ItemList.OrderByDescending方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetAceObject

        public bool SetAceObject(ItemList<AceWrapper> aceWrappers, String objectID, bool notify, String message)
        {
            ErrorIf(string.IsNullOrEmpty(objectID), FilesCommonResource.ErrorMassage_BadRequest, true);

            using (var ddao = GetFolderDao())
            using (var fdao = GetFileDao())
            using (var tagDao = GetTagDao())
            {
                Debug.Assert(objectID != null, "objectID != null");
                var entryType = objectID.StartsWith("file_") ? FileEntryType.File : FileEntryType.Folder;
                var entryId = objectID.Substring((entryType == FileEntryType.File ? "file_" : "folder_").Length);
                var entry = entryType == FileEntryType.File
                                ? (FileEntry) fdao.GetFile(entryId)
                                : (FileEntry) ddao.GetFolder(entryId);

                ErrorIf(entry == null, FilesCommonResource.ErrorMassage_BadRequest, true);

                ErrorIf(entry.RootFolderType == FolderType.COMMON && !Global.IsAdministrator, FilesCommonResource.ErrorMassage_SecurityException, true);
                ErrorIf(entry.RootFolderType == FolderType.USER && !Equals(entry.RootFolderId, Global.FolderMy), FilesCommonResource.ErrorMassage_SecurityException, true);
                //ErrorIf(entry.RootFolderType == FolderType.USER && entryType == FileEntryType.Folder, FilesCommonResource.ErrorMassage_NotSupportedFormat, true);

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

                var subscriptionProvider = NotifySource.Instance.GetSubscriptionProvider();
                var recipientsProvider = NotifySource.Instance.GetRecipientsProvider();

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

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

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

                    var parentShare = ace != null ? ace.Share : defaultShare;
                    var share = parentShare == w.Share ? FileShare.None : w.Share;

                    if (w.SubjectId == FileConstant.ShareLinkId)
                        share = w.Share == FileShare.Restrict ? FileShare.None : w.Share;

                    FileSecurity.Share(entryId, entryType, w.SubjectId, share);

                    if (entry.RootFolderType != FolderType.USER
                        || entryType == FileEntryType.Folder
                        || w.SubjectId == FileConstant.ShareLinkId)
                        continue;

                    var recipients = new List<Notify.Recipients.IRecipient>();
                    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.ForEach(id =>
                                            {
                                                if (id == SecurityContext.CurrentAccount.ID)
                                                    return;

                                                var recipient = recipientsProvider.GetRecipient(id.ToString());

                                                if (share == FileShare.Read || share == FileShare.ReadWrite)
                                                {
                                                    if (subscriptionProvider.IsSubscribed(NotifyConstants.Event_ShareDocument, recipient, null))
                                                    {
                                                        subscriptionProvider.Subscribe(NotifyConstants.Event_UpdateDocument, entry.UniqID, recipient);
                                                        recipients.Add(recipient);
                                                    }

                                                    tagDao.SaveTags(Tag.New(id, entry));
                                                }
                                                else
                                                {
                                                    subscriptionProvider.UnSubscribe(NotifyConstants.Event_UpdateDocument, entry.UniqID, recipient);
                                                    recipients.Remove(recipient);
                                                    tagDao.RemoveTags(Tag.New(id, entry));
                                                }
                                            });

                    if (notify)
                    {
                        NotifyClient.SendShareNotice((File) entry, share, recipients.ToArray(), message);
                    }
                }
                entry = entryType == FileEntryType.File
                            ? (FileEntry) fdao.GetFile(entryId)
                            : (FileEntry) ddao.GetFolder(entryId);

                return entry.SharedByMe;
            }
        }
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:99,代码来源:Service.svc.cs


注:本文中的ItemList.OrderByDescending方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。