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


C# ItemList.Any方法代码示例

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


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

示例1: GetSharedInfo

        public ItemList<AceWrapper> GetSharedInfo(String objectId)
        {
            ErrorIf(!SecurityContext.IsAuthenticated, FilesCommonResource.ErrorMassage_SecurityException, true);
            ErrorIf(string.IsNullOrEmpty(objectId), FilesCommonResource.ErrorMassage_BadRequest, true);

            var entryType = objectId.StartsWith("file_") ? FileEntryType.File : FileEntryType.Folder;
            var entryId = objectId.Substring((entryType == FileEntryType.File ? "file_" : "folder_").Length);

            var shareLink = FileShare.Restrict;

            var result = new ItemList<AceWrapper>();

            using (var folderDao = GetFolderDao())
            using (var fileDao = GetFileDao())
            {
                var entry = entryType == FileEntryType.File
                                ? (FileEntry) fileDao.GetFile(entryId)
                                : (FileEntry) folderDao.GetFolder(entryId);

                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);

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

                foreach (var r in records)
                {
                    if (r.Subject == FileConstant.ShareLinkId)
                    {
                        shareLink = r.Share;
                    }
                    else
                    {
                        var u = CoreContext.UserManager.GetUsers(r.Subject);
                        var isgroup = false;
                        var title = u.DisplayUserName(false);

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

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

                            if (g.ID == ASC.Core.Users.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,
                                    };
                        result.Add(w);
                    }
                }

                if (entryType == FileEntryType.File && !result.Any(w => w.SubjectId == FileConstant.ShareLinkId))
                {
                    var w = new AceWrapper
                                {
                                    SubjectId = FileConstant.ShareLinkId,
                                    SubjectName = DocumentUtils.GetShareLinkParam(entryId),
                                    SubjectGroup = true,
                                    Share = shareLink,
                                    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 = FileEntry.GetUserName(ownerId),
                                    SubjectGroup = false,
                                    Share = FileShare.ReadWrite,
                                    Owner = true,
                                };
                    result.Add(w);
                }
                if (entry.RootFolderType == FolderType.COMMON)
                {
//.........这里部分代码省略.........
开发者ID:ridhouan,项目名称:teamlab.v6.5,代码行数:101,代码来源:Service.svc.cs


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