public List <WorkflowStateInfo> GetAvailiableWorkflowStateToSet(ApiCommandArgument arg) { var infos = new List <WorkflowStateInfo>(); AuthenticationService.Authenticate(arg.SecurityToken); if (!AuthenticationService.IsAuthenticated()) { return(infos); } if (!SecurityEntityService.CheckTrusteeWithIdIsInRole(AuthenticationService.GetCurrentIdentity().Id, BudgetRole.FullControl)) { var permissions = SecurityEntityService.GetAlPermissionsForTrusteeAndworkflow(arg.SecurityToken) .Where(p => p.LinkedStateToSet != null) .Select(p => p.LinkedStateToSet); if (permissions.Count() < 1) { return(infos); } infos = WorkflowStateService.GetAllAvailiableStates(arg.InstanceId) .Where(i => permissions.Count(p => p.WorkflowStateName == i.StateSystemName && p.Type.Id == i.WorkflowTypeId) > 0) .ToList(); } else { infos = WorkflowStateService.GetAllAvailiableStates(arg.InstanceId); } return(infos); }
public bool IsAllowedToExecuteCommand(IEnumerable <Guid> instanceIds, WorkflowCommandType commandType) { //STUB Сюда добавится еще и масс согласование заявок if (commandType != WorkflowCommandType.Export) { return(false); } if (SecurityEntityService.CheckTrusteeWithIdIsInRole(AuthenticationService.GetCurrentIdentity().Id, BudgetRole.Accountant)) { return(true); } return(false); }
public List <WorkflowCommandType> GetListOfAllowedOperations(ApiCommandArgument arg) { var allowedOperations = new List <WorkflowCommandType>(); AuthenticationService.Authenticate(arg.SecurityToken); if (!AuthenticationService.IsAuthenticated()) { return(allowedOperations); } var commandsToCheck = new List <WorkflowCommandType>() { WorkflowCommandType.StartProcessing, WorkflowCommandType.Sighting, WorkflowCommandType.Denial, WorkflowCommandType.DenialByTechnicalCauses, WorkflowCommandType.PostingAccounting, WorkflowCommandType.CheckStatus, WorkflowCommandType.SetDenialStatus, WorkflowCommandType.SetPaidStatus, WorkflowCommandType.Export }; allowedOperations = AuthorizationService.IsAllowedToExecuteCommand(arg.InstanceId, commandsToCheck); if (!SecurityEntityService.CheckTrusteeWithIdIsInRole(AuthenticationService.GetCurrentIdentity().Id, BudgetRole.FullControl)) { var type = WorkflowStateService.TryGetExpectedWorkflowType(arg.InstanceId); if (SecurityEntityService.GetAlPermissionsForTrusteeAndworkflow(arg.SecurityToken) .Count(p => p.LinkedStateToSet != null && p.LinkedStateToSet.Type.Id == type.Id) > 0) { allowedOperations.Add(WorkflowCommandType.SetWorkflowState); } } else { allowedOperations.Add(WorkflowCommandType.SetWorkflowState); } return(allowedOperations); }
private bool CheckNotAllowToSetState(SetStateApiCommandArgument arg) { AuthenticationService.Authenticate(arg.SecurityToken); if (!AuthenticationService.IsAuthenticated()) { return(true); } if ( !SecurityEntityService.CheckTrusteeWithIdIsInRole(AuthenticationService.GetCurrentIdentity().Id, BudgetRole.FullControl)) { if (SecurityEntityService.GetAlPermissionsForTrusteeAndworkflow(arg.SecurityToken) .Count( p => p.LinkedStateToSet != null && p.LinkedStateToSet.WorkflowStateName == arg.StateNameToSet) < 1) { return(true); } } return(false); }
public bool IsInRole(Guid identityId, BudgetRole role) { return(SecurityEntityService.CheckTrusteeWithIdIsInRole(identityId, role)); }