예제 #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
        public void ExportBillDemand(ApiCommandArgument arg)
        {
            AuthenticationService.Authenticate(arg.SecurityToken);

            if (!AuthenticationService.IsAuthenticated())
            {
                return;
            }

            if (!AuthorizationService.IsAllowedToExecuteCommand(arg.InstanceId, WorkflowCommandType.Export))
            {
                return;
            }

            FireCommandWithWaiting(arg, delegate(ApiCommandArgument arg1)
            {
                using (var sync = GetWorkflowSync(arg1))
                {
                    WorkflowInitService.RaiseExport(arg1.InstanceId);
                    sync.WaitHandle.WaitOne(60000);
                }
            });

            var state = WorkflowStateService.GetCurrentState(arg.InstanceId);

            if (state == WorkflowState.BillDemandInAccountingWithExport)
            {
                var errorMessage = WorkflowParcelService.GetAndRemoveMessage(arg.InstanceId);

                throw new FaultException <BaseFault>(new BaseFault((int)ErrorCodes.BillDemandUploadError),
                                                     new FaultReason(string.IsNullOrEmpty(errorMessage) ?
                                                                     "Не удалось выгрузить расходный документ. Попробуйте провести данную операцию еще раз. Если сообщение будет повторятся, обратитесь к Администратору." : errorMessage));
            }
        }
예제 #3
0
        public void StartProcessing(ApiCommandArgument arg)
        {
            AuthenticationService.Authenticate(arg.SecurityToken);

            if (!AuthenticationService.IsAuthenticated())
            {
                return;
            }

            if (!AuthorizationService.IsAllowedToExecuteCommand(arg.InstanceId, WorkflowCommandType.StartProcessing))
            {
                return;
            }

            WorkflowInitService.CreateWorkflowIfNotExists(arg.InstanceId);

            using (var sync = GetWorkflowSync(arg))
            {
                sync.WaitHandle.WaitOne(4000);
            }

            FireCommandWithWaiting(arg, delegate(ApiCommandArgument arg1)
            {
                using (var sync = GetWorkflowSync(arg1))
                {
                    WorkflowInitService.RaiseStartProcessing(arg1.InstanceId);
                    sync.WaitHandle.WaitOne(4000);
                }
            });
        }
예제 #4
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);
        }
예제 #5
0
        public void SetDenialStatus(ApiCommandArgument arg)
        {
            AuthenticationService.Authenticate(arg.SecurityToken);

            if (!AuthenticationService.IsAuthenticated())
            {
                return;
            }

            if (!AuthorizationService.IsAllowedToExecuteCommand(arg.InstanceId, WorkflowCommandType.SetDenialStatus))
            {
                return;
            }

            FireCommandWithWaiting(arg, delegate(ApiCommandArgument arg1)
            {
                using (var sync = GetWorkflowSync(arg1))
                {
                    WorkflowInitService.RaiseSetDenialStatus(arg1.InstanceId, arg1.Comment);
                    sync.WaitHandle.WaitOne(4000);
                }
            });
        }
예제 #6
0
 private WorkflowSync GetWorkflowSync(ApiCommandArgument arg)
 {
     return(GetWorkflowSync(arg.InstanceId));
 }
예제 #7
0
 private void FireCommandWithWaiting(ApiCommandArgument arg, Action <ApiCommandArgument> action)
 {
     FireCommandWithWaiting <ApiCommandArgument>(arg, action, arg1 => arg1.InstanceId);
 }