コード例 #1
0
        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);
        }
コード例 #2
0
        private bool ValidateLimitManager(ServiceIdentity identity, Guid instanceId)
        {
            var bd = BillDemandBuinessService.GetBillDemand(instanceId);

            if (bd.BudgetPartId == 0)
            {
                return(CheckLimitSighting(identity, instanceId, SightingType.BillDemandLimitManagerSighting));
            }
            else
            {
                var sighters  = BillDemandBuinessService.GetLimitManagerSighters(instanceId, true);
                var sightings = BillDemandBuinessService.GetLimitManagerSightings(instanceId);
                foreach (var sighter in sighters)
                {
                    if (sightings.Count(s => s.LimitId == sighter.LimitId) < 1)
                    {
                        if (SecurityEntityService.GetHeadIdsByDivision(sighter.LimitId, bd.BudgetId).Contains(identity.Id))
                        {
                            return(true);
                        }
                    }
                }

                return(false);
            }
        }
コード例 #3
0
        private bool ValidateInitiatorHead(ServiceIdentity identity, Guid instanceId)
        {
            var billDemand = BillDemandBuinessService.GetBillDemand(instanceId);

            if (!billDemand.AuthorId.HasValue)
            {
                return(false);
            }
            var heads = SecurityEntityService.GetHeadIds(billDemand.AuthorId.Value, billDemand.BudgetId);

            return(heads.Contains(identity.Id));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        private bool ValidateInitiatorHead(ServiceIdentity identity, Guid instanceId)
        {
            using (var context = CreateContext())
            {
                var dlo = new DataLoadOptions();
                dlo.LoadWith <Demand>(d => d.BudgetVersion);
                context.LoadOptions = dlo;

                var demand = context.Demands.FirstOrDefault(
                    p =>
                    p.Id == instanceId && p.AuthorId.HasValue);

                if (demand == null)
                {
                    return(false);
                }

                var heads = SecurityEntityService.GetHeadIds(demand.AuthorId.Value, demand.BudgetVersion.BudgetId);

                return(heads.Contains(identity.Id));
            }
        }
コード例 #7
0
        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);
        }
コード例 #8
0
 public bool IsInRole(Guid identityId, BudgetRole role)
 {
     return(SecurityEntityService.CheckTrusteeWithIdIsInRole(identityId, role));
 }