Check() публичный статический Метод

public static Check ( Permission, current, Permission, check ) : bool
current Permission,
check Permission,
Результат bool
Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "CMS Users", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                users  = db.cms_user.ToList();
                groups = db.cms_groups.ToList();
                selectgroup.DataSource     = groups;
                selectgroup.DataTextField  = "name";
                selectgroup.DataValueField = "id";
                selectgroup.DataBind();
                foreach (cms_groups group in groups)
                {
                    groupsList += ",{ value: " + group.id + ", text: '" + group.name + "' }";
                }
                if (groupsList.Length > 0)
                {
                    groupsList = groupsList.Substring(1);
                }
            }
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int opId = int.Parse(Request["opId"]);

            int.TryParse(Request["page"], out page);
            bool perm = Permissions.Check(opId, "Schools", "view");

            levels    = db.BooksLevels.ToList();
            searchKey = Request["key"];
            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                var allresults = db.Schools.OrderByDescending(x => x.id).ToList();
                if (!string.IsNullOrEmpty(searchKey))
                {
                    allresults = allresults.Where(x => x.title.ToLower().Contains(searchKey) || x.artitle.ToLower().Contains(searchKey)).ToList();
                }
                resultCount = allresults.Count;
                PageCount   = resultCount / pageSize;
                if (allresults.Count % pageSize > 0)
                {
                    PageCount += 1;
                }
                if (page < 1 || page > PageCount)
                {
                    page = 1;
                }
                results = allresults.Skip((page - 1) * pageSize)
                          .Take(pageSize).ToList();
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "CMS Users", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
                contentList = db.Contents.ToList();
                if (contentList.Count() > 0)
                {
                    row                       = contentList.FirstOrDefault();
                    AboutUs.Value             = row.AboutUs;
                    Description.Value         = row.Description;
                    Keywords.Value            = row.keywords;
                    Email.Value               = row.Email;
                    AddressLine.Value         = row.AddressLine;
                    Phone.Value               = row.Phone;
                    Fax.Value                 = row.Fax;
                    Longitude.Value           = row.longitude.ToString();
                    Latitude.Value            = row.latitude.ToString();
                    SmtpServer.Value          = row.SmtpServer;
                    SmtpPort.Value            = row.SmtpPort;
                    IsSSL.Checked             = row.IsSSL != null ? (bool)row.IsSSL : false;
                    SystemEmail.Value         = row.SystemEmail;
                    SystemEmailPassword.Value = row.SystemEmailPassword;
                    InfoEmail.Value           = row.InfoEmail;
                    SmartLearningVideo.Value  = row.SmartLearningVideo;
                }
            }
        }
Пример #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "IP Security", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                results = GetBlockedIP();
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int opId = int.Parse(Request["opId"]);

            int.TryParse(Request["page"], out page);
            pageId = int.Parse(Request["pageId"]);
            bool perm = Permissions.Check(opId, "Web Users", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                school    = db.Schools.Where(x => x.id == pageId).SingleOrDefault();
                searchKey = Request["key"];
                var allresults = db.Students.Where(x => x.schoolId == pageId).OrderByDescending(x => x.id).ToList();
                if (!string.IsNullOrEmpty(searchKey))
                {
                    allresults = allresults.Where(x => x.Address.Contains(searchKey) || (x.School != null ? x.School.title.Contains(searchKey) : false) || x.Email.Contains(searchKey) || x.FirstName.Contains(searchKey) || x.LastName.Contains(searchKey) || x.Phone.Contains(searchKey)).ToList();
                }
                resultCount = allresults.Count;
                PageCount   = resultCount / pageSize;
                if (allresults.Count % pageSize > 0)
                {
                    PageCount += 1;
                }
                if (page < 1 || page > PageCount)
                {
                    page = 1;
                }
                results = allresults.Skip((page - 1) * pageSize)
                          .Take(pageSize).OrderByDescending(x => x.id).ToList();
                var levels = db.BooksLevels.ToList();
                levelsSelect.DataSource     = levels;
                levelsSelect.DataTextField  = "title";
                levelsSelect.DataValueField = "id";
                levelsSelect.DataBind();
                levelsSelect.Items.Insert(0, new ListItem("Select Level", "-1"));
                foreach (BooksLevel level in levels)
                {
                    levelsList += ",{ value: " + level.id + ", text: '" + level.title + "' }";
                }
                if (levelsList.Length > 0)
                {
                    levelsList = levelsList.Substring(1);
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "Books", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                results = db.BooksLevels.ToList().OrderBy(x => x.OrderIndex).ToList();
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId = int.Parse(Request["opId"]);
            bool perm = Permissions.Check(opId, "CMS Groups", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                groups      = db.cms_groups.ToList();
                permissions = db.cms_permissions.ToList();
            }
        }
Пример #8
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int  opId   = int.Parse(Request["opId"]);
            int  bookId = int.Parse(Request["pageId"]);
            bool perm   = Permissions.Check(opId, "Books", "view");

            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                results = db.BookStories.Where(x => x.bookId == bookId).ToList();
                book    = db.Books.Where(x => x.id == bookId).SingleOrDefault();
            }
        }
        public async Task <bool> PermissionAsync(Permissions permissions, PermissionDescription key, Operation operation, string permissionUserName, string targetUserCompanyCode, string description = null)
        {
            var a = await LogAsync(UserOperation.Permission, permissionUserName, $"授权到{targetUserCompanyCode}执行{key?.Name} {key?.Description}@{operation} {description}", false, ActionRank.Danger);

            if (permissions.Check(key, operation, targetUserCompanyCode))
            {
                Status(a, true, "直接权限");
                return(true);
            }
            var u = usersService.GetById(permissionUserName);

            if (u != null)
            {
                var uc   = u.CompanyInfo;
                var ud   = uc.Duties.IsMajorManager;
                var ucmp = uc.CompanyCode;
                if (targetUserCompanyCode == null || (targetUserCompanyCode.Length >= ucmp.Length && targetUserCompanyCode.StartsWith(ucmp)) && ud)
                {
                    Status(a, true, $"单位主官");
                    return(true);
                }
                else
                {
                    var results = userServiceDetail.InMyManage(u).Result;
                    if (targetUserCompanyCode == null && results.Item2 > 0)
                    {
                        return(true);                                                                        // 如果无授权对象,则有任意单位权限即可
                    }
                    else if (results.Item2 > 0 && results.Item1.Any(c => targetUserCompanyCode.Length >= c.Code.Length && targetUserCompanyCode.StartsWith(c.Code)))
                    {
                        Status(a, true, $"单位管理");
                        return(true);
                    }
                }
            }
            //throw new ActionStatusMessageException(ActionStatusMessage.Account.Auth.Invalid.Default);
            return(false);
        }
Пример #10
0
            /// <summary>
            /// Returns the contacts in the device operating system which match the specified search query.
            /// </summary>
            public static async Task <IEnumerable <Contact> > Search(ContactSearchParams searchParams, OnError errorAction = OnError.Alert)
            {
                try
                {
                    if (await Permissions.Check(Permission.Contacts) != PermissionResult.Granted)
                    {
                        if (await Permissions.Request(Permission.Contacts) != PermissionResult.Granted)
                        {
                            await errorAction.Apply("Permission for reading device contacts not granted");

                            return(null);
                        }
                    }

                    return(await DoReadContacts(searchParams));
                }
                catch (Exception ex)
                {
                    await errorAction.Apply(ex, "Failed to read contacts: " + ex.Message);

                    return(null);
                }
            }
 public void Check(Permission owned, Permission desired, bool expected) =>
 Assert.Equal(expected, Permissions.Check(owned, desired));
Пример #12
0
 public void Check_read_and_write_for_read_and_delete()
 {
     Assert.False(Permissions.Check(Permission.Read | Permission.Write, Permission.Read | Permission.Delete));
 }
Пример #13
0
 public void CheckReadAndWriteForReadAndDelete() =>
 Assert.False(Permissions.Check(Permission.Read | Permission.Write, Permission.Read | Permission.Delete));
Пример #14
0
 public void CheckReadAndWriteAndDeleteForAll() =>
 Assert.True(Permissions.Check(Permission.Read | Permission.Write | Permission.Delete, Permission.All));
Пример #15
0
 public void CheckAllForWrite() =>
 Assert.True(Permissions.Check(Permission.All, Permission.Write));
Пример #16
0
 public void CheckReadAndWriteForReadAndWrite() =>
 Assert.True(Permissions.Check(Permission.Read | Permission.Write, Permission.Read | Permission.Write));
Пример #17
0
 public void CheckNoneForRead() =>
 Assert.False(Permissions.Check(Permission.None, Permission.Read));
Пример #18
0
 public void CheckWriteForWrite() =>
 Assert.True(Permissions.Check(Permission.Write, Permission.Write));
Пример #19
0
 public void Check_none_for_read()
 {
     Assert.False(Permissions.Check(Permission.None, Permission.Read));
 }
Пример #20
0
 public void Check_all_for_write()
 {
     Assert.True(Permissions.Check(Permission.All, Permission.Write));
 }
Пример #21
0
 public void Check_read_and_write_and_delete_for_all()
 {
     Assert.True(Permissions.Check(Permission.Read | Permission.Write | Permission.Delete, Permission.All));
 }
Пример #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            BrandsMktgBooksEntities db = new BrandsMktgBooksEntities();
            int opId = int.Parse(Request["opId"]);

            int.TryParse(Request["page"], out page);
            bool perm = Permissions.Check(opId, "Books", "view");

            searchKey = !string.IsNullOrEmpty(Request["key"])? Request["key"].ToLower():"";
            if (!perm)
            {
                Response.Write("<script>getContent('accessdenied.html');</script>");
            }
            else
            {
                var allresults = db.Books.OrderByDescending(x => x.id).ToList();
                if (!string.IsNullOrEmpty(searchKey))
                {
                    allresults = allresults.Where(x => x.title.ToLower().Contains(searchKey)).ToList();
                }
                resultCount = allresults.Count;
                PageCount   = resultCount / pageSize;
                if (allresults.Count % pageSize > 0)
                {
                    PageCount += 1;
                }
                if (page < 1 || page > PageCount)
                {
                    page = 1;
                }
                results = allresults.Skip((page - 1) * pageSize)
                          .Take(pageSize).ToList();
                levels = db.BooksLevels.ToList();
                levelselect.DataSource     = levels;
                levelselect.DataTextField  = "title";
                levelselect.DataValueField = "id";
                levelselect.DataBind();
                foreach (BooksLevel level in levels)
                {
                    levelsList += ",{ value: " + level.id + ", text: '" + level.title + "' }";
                }
                if (!string.IsNullOrEmpty(levelsList))
                {
                    levelsList = levelsList.Substring(1);
                }

                var categories = db.Categories.ToList();
                categoryselect.DataSource     = categories;
                categoryselect.DataTextField  = "title";
                categoryselect.DataValueField = "id";
                categoryselect.DataBind();
                foreach (Category category in categories)
                {
                    categoriesList += ",{ value: " + category.id + ", text: '" + category.title + "' }";
                }
                if (!string.IsNullOrEmpty(categoriesList))
                {
                    categoriesList = categoriesList.Substring(1);
                }
            }
        }
Пример #23
0
 public void Check_read_and_write_for_read_and_write()
 {
     Assert.True(Permissions.Check(Permission.Read | Permission.Write, Permission.Read | Permission.Write));
 }