protected IPermissionRequest CreatePermissionRequest(object entity, string requestedPermission) { var handle = ObjectSpace.GetObjectHandle(entity); var request = new ClientPermissionRequest(entity.GetType(), null, handle, requestedPermission); return(request); }
private void UpdateApprovalActionState() { bool isGranted = false; string objectHandle = ObjectSpace.GetObjectHandle(View.CurrentObject); bool isDirector = SecuritySystem.IsGranted(new PermissionRequest(ObjectSpace, typeof(OfficeLeave), "DirectorComment", null, SecurityOperations.Write)); //SecuritySystem.IsGranted(new ClientPermissionRequest(typeof(OfficeLeave), "DirectorComment", objectHandle, SecurityOperations.Write)); bool isHR = SecuritySystem.IsGranted(new PermissionRequest(ObjectSpace, typeof(OfficeLeave), "HRComment", null, SecurityOperations.Write)); //SecuritySystem.IsGranted(new ClientPermissionRequest(typeof(OfficeLeave), "HRComment", objectHandle, SecurityOperations.Write)); bool isManager = SecuritySystem.IsGranted(new PermissionRequest(ObjectSpace, typeof(OfficeLeave), "ManagerComment", null, SecurityOperations.Write)); //SecuritySystem.IsGranted(new ClientPermissionRequest(typeof(OfficeLeave), "ManagerComment", objectHandle, SecurityOperations.Write)); if (isDirector || isHR || isManager) { isGranted = true; } ApproveOffiveLeaveAction.Enabled.SetItemValue("Security", isGranted); }
private void UpdateSetTaskActionState() { bool isGranted = true; foreach (object selectedObject in View.SelectedObjects) { string objectHandle = ObjectSpace.GetObjectHandle(selectedObject); bool isPriorityGranted = SecuritySystem.IsGranted(new ClientPermissionRequest(typeof(DemoTask), "Priority", objectHandle, SecurityOperations.Write)); bool isStatusGranted = SecuritySystem.IsGranted(new ClientPermissionRequest(typeof(DemoTask), "Status", objectHandle, SecurityOperations.Write)); if (!isPriorityGranted || !isStatusGranted) { isGranted = false; } } SetTaskAction.Enabled.SetItemValue("SecurityAllowance", isGranted); }
private void UpdateStatusPriorityActionState() { var isGranted = true; foreach (object selectedObject in View.SelectedObjects) { var objectHandle = ObjectSpace.GetObjectHandle(selectedObject); var isPriorityGranted = SecuritySystem.IsGranted(new PermissionRequest(this.View.ObjectSpace, this.TargetObjectType, SecurityOperations.Write, "Priority")); var isStatusGranted = SecuritySystem.IsGranted(new PermissionRequest(this.View.ObjectSpace, this.TargetObjectType, SecurityOperations.Write, "Status")); if (!isPriorityGranted || !isStatusGranted) { isGranted = false; } } this._setStatusPriority.Enabled.SetItemValue("SecurityAllowance", isGranted); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); Position developerPosition = ObjectSpace.FindObject <Position>(CriteriaOperator.Parse("Title == 'Developer'")); if (developerPosition == null) { developerPosition = ObjectSpace.CreateObject <Position>(); developerPosition.Title = "Developer"; } Position managerPosition = ObjectSpace.FindObject <Position>(CriteriaOperator.Parse("Title == 'Manager'")); if (managerPosition == null) { managerPosition = ObjectSpace.CreateObject <Position>(); managerPosition.Title = "Manager"; } Contact contactJohn = ObjectSpace.FindObject <Contact>(CriteriaOperator.Parse("FirstName == 'John' && LastName == 'Nilsen'")); if (contactJohn == null) { contactJohn = ObjectSpace.CreateObject <Contact>(); contactJohn.FirstName = "John"; contactJohn.LastName = "Nilsen"; contactJohn.Email = "*****@*****.**"; contactJohn.Birthday = new DateTime(1981, 10, 3); contactJohn.Position = developerPosition; } PhoneNumber johnPhoneNumber_1 = ObjectSpace.FindObject <PhoneNumber>(CriteriaOperator.Parse("Number == '888-111-222'")); if (johnPhoneNumber_1 == null) { johnPhoneNumber_1 = ObjectSpace.CreateObject <PhoneNumber>(); johnPhoneNumber_1.Number = "888-111-222"; contactJohn.PhoneNumbers.Add(johnPhoneNumber_1); } PhoneNumber johnPhoneNumber_2 = ObjectSpace.FindObject <PhoneNumber>(CriteriaOperator.Parse("Number == '888-333-222'")); if (johnPhoneNumber_2 == null) { johnPhoneNumber_2 = ObjectSpace.CreateObject <PhoneNumber>(); johnPhoneNumber_2.Number = "888-333-222"; contactJohn.PhoneNumbers.Add(johnPhoneNumber_2); } ObjectSpace.CommitChanges(); Contact contactMary = ObjectSpace.FindObject <Contact>(CriteriaOperator.Parse("FirstName == 'Mary' && LastName == 'Tellitson'")); if (contactMary == null) { contactMary = ObjectSpace.CreateObject <Contact>(); contactMary.FirstName = "Mary"; contactMary.LastName = "Tellitson"; contactMary.Email = "*****@*****.**"; contactMary.Birthday = new DateTime(1980, 11, 27); contactMary.Position = managerPosition; } PhoneNumber maryPhoneNumber_1 = ObjectSpace.FindObject <PhoneNumber>(CriteriaOperator.Parse("Number == '999-999-999'")); if (maryPhoneNumber_1 == null) { maryPhoneNumber_1 = ObjectSpace.CreateObject <PhoneNumber>(); maryPhoneNumber_1.Number = "999-999-999"; contactMary.PhoneNumbers.Add(maryPhoneNumber_1); } PhoneNumber maryPhoneNumber_2 = ObjectSpace.FindObject <PhoneNumber>(CriteriaOperator.Parse("Number == '999-999-777'")); if (maryPhoneNumber_2 == null) { maryPhoneNumber_2 = ObjectSpace.CreateObject <PhoneNumber>(); maryPhoneNumber_2.Number = "999-999-777"; contactMary.PhoneNumbers.Add(maryPhoneNumber_2); } ObjectSpace.CommitChanges(); Company myOrg = ObjectSpace.FindObject <Company>(CriteriaOperator.Parse("Name == 'Demo Company'")); if (myOrg == null) { myOrg = ObjectSpace.CreateObject <Company>(); myOrg.Name = "Demo Company"; myOrg.City = "DefaultCity"; } #if !DXCORE3 CreateReport("OrdinalReport", OrdinalReportResource.ReportLayout, "ReportWithParametersObject", typeof(DemoParameters)); ReportDataV2 reportData = CreateReport("SubreportCompany", SubreportCompanyLayout.ReportLayout); string reportWithSubReportLayout = ReportWithSubReportLayout.ReportLayout.Replace("SubReportKEY", ObjectSpace.GetObjectHandle(reportData)); ReportDataV2 simpleSubReportData = CreateReport("SimpleSubReport", SimpleSubReportLayout.ReportLayout); string reportWithSubReportDifferentEnumsLayout = ReportWithSubReportDifferentEnumsLayout.ReportLayout.Replace("SubReportKEY", ObjectSpace.GetObjectHandle(simpleSubReportData)); CreateReport("ReportWithSecurity", ReportWithSecurity.ReportLayout); CreateReport("ReportWithSubReportDifferentEnums", reportWithSubReportDifferentEnumsLayout); CreateReport("ReportWithSubReport", reportWithSubReportLayout); CreateReport("ReportWithViewDataSource", ReportWithViewDataSourceLayout.ReportLayout); CreateReport("OrdinalReport", OrdinalReportResource.ReportLayout); #else CreateReport("OrdinalReport", "OrdinalReport.repx"); CreateReport("ReportWithSecurity", "ReportWithSecurity.repx"); CreateReport("OrdinalReport", "OrdinalReport.repx", "ReportWithParametersObject", typeof(DemoParameters)); ReportDataV2 simpleSubReportData = CreateReport("SimpleSubReport", "SimpleSubReport.repx"); CreateReport("ReportWithSubReportDifferentEnums", "ReportWithSubReportDifferentEnums.repx", subReportUrl: ObjectSpace.GetObjectHandle(simpleSubReportData)); ReportDataV2 reportData = CreateReport("SubreportCompany", "SubreportCompany.repx"); CreateReport("ReportWithSubReport", "ReportWithSubReport.repx", subReportUrl: ObjectSpace.GetObjectHandle(reportData)); CreateReport("ReportWithViewDataSource", "ReportWithViewDataSource.repx"); #endif CreateReportParameters(); CreateReportMultiValueParameters(); CreateReportWithBookmark(); CreateUser(); SimpleObjectWithEnum simpleObjectWithEnum = ObjectSpace.FindObject <SimpleObjectWithEnum>(CriteriaOperator.Parse("Name == 'One'")); if (simpleObjectWithEnum == null) { simpleObjectWithEnum = ObjectSpace.CreateObject <SimpleObjectWithEnum>(); simpleObjectWithEnum.Name = "One"; simpleObjectWithEnum.SimpleEnum = SimpleEnum.One; } ObjectWithSecurity objectWithSecurity = ObjectSpace.FindObject <ObjectWithSecurity>(new BinaryOperator("Name", "TestObject")); if (objectWithSecurity == null) { objectWithSecurity = ObjectSpace.CreateObject <ObjectWithSecurity>(); objectWithSecurity.Name = "TestObject"; PermissionPolicyUser user = ObjectSpace.FindObject <PermissionPolicyUser>(new BinaryOperator("UserName", "User")); objectWithSecurity.User = user; } ObjectSpace.CommitChanges(); }
void UpdateActionState() { if (SecuritySystem.Instance is ISecurityComplex) { bool isGranted = true; foreach (object selectedObject in View.SelectedObjects) { var clientPermissionRequest = new ClientPermissionRequest(typeof(IDashboardDefinition), "Xml", ObjectSpace.GetObjectHandle(selectedObject), SecurityOperations.Write); isGranted = SecuritySystem.IsGranted(clientPermissionRequest); } _dashboardEdit.Active["SecurityIsGranted"] = isGranted; _dashboardExportXml.Active["SecurityIsGranted"] = isGranted; _dashboardImportXml.Active["SecurityIsGranted"] = isGranted; } }