Пример #1
0
        //[Transaction(TransactionMode.Requires)]
        public virtual IList PerformActivity(Int64 flowId, IDictionary attributeValues, String transitionName, Relations relations)
        {
            IList                flows                 = null;
            DbSession            dbSession             = null;
            IOrganisationService organisationComponent = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));

            try
            {
                dbSession             = OpenSession();
                organisationComponent = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));
                flows = implementation.PerformActivity(ActorId, flowId, attributeValues, transitionName, relations, dbSession, organisationComponent);
                ServiceLocator.Instance.Release(organisationComponent);
            }
            catch (ExecutionException e)
            {
                log.Error("Error when performing activity :", e);
                throw e;
            }
            catch (Exception e)
            {
                log.Error("uncaught exception when performing activity :", e);
                throw new SystemException("uncaught exception : " + e.Message, e);
            }
            finally
            {
                ServiceLocator.Instance.Release(organisationComponent);
            }
            return(flows);
        }
Пример #2
0
        public void ContainerTest()
        {
            container = new WindsorContainer(TestHelper.GetConfigDir() + "WindsorContainerTest.xml");

            IOrganisationService organisationSession = (IOrganisationService)container["OrganisationSession"];

            Assert.IsNotNull(organisationSession);
            organisationSession = (IOrganisationService)container[typeof(IOrganisationService)];
            Assert.IsNotNull(organisationSession);

            ISchedulerSessionLocal schedulerSession = (ISchedulerSessionLocal)container["SchedulerSession"];

            Assert.IsNotNull(schedulerSession);
            schedulerSession = (ISchedulerSessionLocal)container[typeof(ISchedulerSessionLocal)];
            Assert.IsNotNull(schedulerSession);

            IProcessDefinitionService definitionSession = (IProcessDefinitionService)container["DefinitionSession"];

            Assert.IsNotNull(definitionSession);
            definitionSession = (IProcessDefinitionService)container[typeof(IProcessDefinitionService)];
            Assert.IsNotNull(definitionSession);

            IExecutionApplicationService executionSession = (IExecutionApplicationService)container["ExecutionSession"];

            Assert.IsNotNull(executionSession);
            executionSession = (IExecutionApplicationService)container[typeof(IExecutionApplicationService)];
            Assert.IsNotNull(executionSession);

            ILogSessionLocal logSession = (ILogSessionLocal)container["LogSession"];

            Assert.IsNotNull(logSession);
            logSession = (ILogSessionLocal)container[typeof(ILogSessionLocal)];
            Assert.IsNotNull(logSession);
        }
 public OrganisationController(
     IOrganisationService organisationService,
     IMapper mapper)
 {
     _organisationService = organisationService;
     _mapper = mapper;
 }
 public OrganisationController(IOrganisationService organisationService,
                                 ISessionIdentity sessionIdentity,
                                 IUserService userService)
     : base(sessionIdentity, userService)
 {
     this.organisationService = organisationService;
 }
Пример #5
0
 public void SetContainer()
 {
     //configure the container
     _container           = new NetBpmContainer(new XmlInterpreter("WindsorConfig.xml"));
     servicelocator       = ServiceLocator.Instance;
     _organisationService = servicelocator.GetService(typeof(IOrganisationService)) as IOrganisationService;
 }
Пример #6
0
        public Object Deserialize(String text)
        {
            if (text == null)
            {
                return(null);
            }

            IActor actor = null;
            IOrganisationService organisationComponent = (IOrganisationService)serviceLocator.GetService(typeof(IOrganisationService));

            try
            {
                actor = organisationComponent.FindActorById(text);
                serviceLocator.Release(organisationComponent);
            }
            catch (Exception t)
            {
                throw new ArgumentException("couldn't deserialize " + text + " to a User : "******" : " + t.Message);
            }
            finally
            {
                serviceLocator.Release(organisationComponent);
            }

            return(actor);
        }
Пример #7
0
        public virtual IProcessInstance StartProcessInstance(Int64 processDefinitionId, IDictionary attributeValues, String transitionName, Relations relations)
        {
            IProcessInstance     processInstance       = null;
            DbSession            dbSession             = null;
            IOrganisationService organisationComponent = null;

            try
            {
                dbSession             = OpenSession();
                organisationComponent = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));
                processInstance       = implementation.StartProcessInstance(ActorId, processDefinitionId, attributeValues, transitionName, relations, dbSession, organisationComponent);
                ServiceLocator.Instance.Release(organisationComponent);
            }
            catch (ExecutionException e)
            {
                log.Error("Error when starting process instance :", e);
                throw e;
            }
            catch (Exception e)
            {
                log.Error("uncaught exception when starting process instance:", e);
                throw new SystemException("uncaught exception : " + e.Message, e);
            }
            finally
            {
                ServiceLocator.Instance.Release(organisationComponent);
            }
            return(processInstance);
        }
 public BaseController()
 {
     this.userService                 = new UserService();
     this.rightService                = new RightService();
     this.locationService             = new LocationService();
     this.organisationService         = new OrganisationService();
     this.siteService                 = new SiteService();
     this.billService                 = new BillService();
     this.itemService                 = new ItemService();
     this.requestToAcquireItemService = new RequestToAcquireAssestService();
     this.eventService                = new EventService();
     this.assetService                = new AssetService();
     this.assetHistoryService         = new AssetHistoryService();
     this.requestForScrappingService  = new RequestForScrappingService();
     this.requestForRelocationService = new RequestForRelocationService();
     this.requestForRenovationService = new RequestForRenovationService();
     this.providerService             = new ProviderService();
     this.packingSlipService          = new PackingSlipService();
     this.requestForAssetService      = new RequestForAssetService();
     this.requestToProviderService    = new RequestToProviderService();
     this.currencyService             = new CurrencyService();
     this.invoiceService              = new InvoiceService();
     this.exchangeService             = new ExchangeRateService();
     this.accidentService             = new AccidentService();
     this.securityGroupService        = new SecurityGroupService();
 }
Пример #9
0
        public async Task <IActionResult> UpdateOrganisationAsync(
            [FromRoute] string organisationId,
            [FromBody] Organisation orgRequest,
            [FromServices] IOrganisationService service)
        {
            if (string.IsNullOrWhiteSpace(organisationId) || orgRequest == null)
            {
                return(BadRequest(new { reason = $"Invalid request!", request = orgRequest, organisationId }));
            }

            if (!organisationId.Equals(orgRequest.Name))
            {
                return(BadRequest(new { reason = $"Invalid organisation name!", request = orgRequest, organisationId }));
            }

            try
            {
                var organisation = await service.UpdateAsync(orgRequest);

                if (organisation == null)
                {
                    return(NotFound());
                }

                return(Ok(organisation));
            }
            catch (Exception)
            {
                return(StatusCode(statusCode: (int)HttpStatusCode.InternalServerError));
            }
        }
Пример #10
0
        public async Task <IActionResult> RegisterOrganisationAsync(
            [FromRoute] string organisationId,
            [FromBody] OrganisationRegistration organisation,
            [FromServices] IOrganisationService service)
        {
            if (string.IsNullOrWhiteSpace(organisationId) || organisation == null)
            {
                return(BadRequest(new { reason = $"Invalid request!", request = organisation, organisationId }));
            }

            if (!organisationId.Equals(organisation.Id))
            {
                return(BadRequest(new { reason = $"Invalid organisation name!", request = organisation, organisationId }));
            }

            try
            {
                organisation.CreatedAt = DateTime.Now;
                var organisationResult = await service.RegisterAsync(organisation);

                return(CreatedAtRoute(nameof(GetOrganisationAsync), new { organisationId }, organisationResult));
            }
            catch (NameAlreadyUsedException ex)
            {
                return(BadRequest(new { reason = ex.Message }));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(StatusCode(statusCode: (int)HttpStatusCode.InternalServerError));
            }
        }
Пример #11
0
 public void SetUp()
 {
     //configure the container
     container      = new NetBpm.NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir() + "app_config.xml"));
     servicelocator = ServiceLocator.Instance;
     orgComp        = servicelocator.GetService(typeof(IOrganisationService)) as IOrganisationService;
 }
 public virtual void SetUp()
 {
     OrganisationService = MockRepository.GenerateMock<IOrganisationService>();
     ApplicationRepository = MockRepository.GenerateMock<IApplicationRepository>();
     ApiKeyCreator = MockRepository.GenerateMock<IApiKeyCreator>();
     ApplicationService = new ApplicationService(ApplicationRepository, OrganisationService, ApiKeyCreator);
 }
Пример #13
0
 public MemberServiceDependencies(IUserService userService,
                                  IOrganisationService organisationService, IStorageService storageService)
 {
     UserService         = userService;
     OrganisationService = organisationService;
     StorageService      = storageService;
 }
		public void SetUp()
		{
			//configure the container
			container = new NetBpm.NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir()+"app_config.xml"));
			servicelocator = ServiceLocator.Instance;
			orgComp = servicelocator.GetService(typeof (IOrganisationService)) as IOrganisationService;
		}
Пример #15
0
        public IProcessInstance StartProcessInstance(long processDefinitionId, IDictionary attributeValues = null, string transitionName = null, Relations relations = null)
        {
            ProcessInstanceImpl  processInstance     = null;
            IOrganisationService organisationService = null;

            using (ISession session = NHibernateHelper.OpenSession())
            {
                using (var tran = session.BeginTransaction())
                {
                    DbSession             dbSession         = new DbSession(session);
                    ProcessDefinitionImpl processDefinition = myProcessDefinitionService.GetProcessDefinition(processDefinitionId, dbSession);
                    processInstance = new ProcessInstanceImpl(ActorId, processDefinition);
                    processInstanceRepository.Save(processInstance, dbSession);//到這裏應該存了ProcessInstance,RootFlow

                    ExecutionContext executionContext = new ExecutionContext();
                    //logRepository.CreateLog();
                    processDefinition.StartState.CheckAccess(attributeValues);

                    attributeService = new AttributeService((FlowImpl)processInstance.RootFlow, dbSession);
                    attributeService.StoreAttributeValue(attributeValues);//儲存傳入的欄位值
                    attributeService.StoreRole(organisationService.FindActorById(ActorId), (ActivityStateImpl)processDefinition.StartState);

                    //flow的node推進到下一關卡
                    //flow的actor=解析出來的actor.Id
                    transitionService = new TransitionService(ActorId, dbSession);
                    TransitionImpl transitionTo = transitionService.GetTransition(transitionName, processDefinition.StartState, dbSession);
                    transitionService.ProcessTransition(transitionTo, (FlowImpl)processInstance.RootFlow, dbSession);

                    session.Flush();
                    tran.Commit();
                }
            }

            return(processInstance);
        }
Пример #16
0
        public async Task <IActionResult> GetOrganisationAsync(
            [FromRoute] string organisationId,
            [FromServices] IOrganisationService service)
        {
            if (string.IsNullOrWhiteSpace(organisationId))
            {
                return(BadRequest(new { reason = $"Invalid organisation id {organisationId}" }));
            }

            try
            {
                var organisation = await service.GetByOrganisationNameAsync(organisationId);

                if (organisation == null)
                {
                    return(NotFound());
                }

                return(Ok(organisation));
            }
            catch
            {
                return(StatusCode(statusCode: (int)HttpStatusCode.InternalServerError));
            }
        }
Пример #17
0
        public virtual void CancelFlow(Int64 flowId)
        {
            DbSession            dbSession             = null;
            IOrganisationService organisationComponent = null;

            try
            {
                dbSession             = OpenSession();
                organisationComponent = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));
                implementation.CancelFlow(ActorId, flowId, dbSession, organisationComponent);
                ServiceLocator.Instance.Release(organisationComponent);
            }
            catch (ExecutionException e)
            {
                log.Error("Error when canceling flow :", e);
                throw e;
            }
            catch (Exception e)
            {
                log.Error("uncaught exception when canceling flow :", e);
                throw new SystemException("uncaught exception : " + e.Message);
            }
            finally
            {
                ServiceLocator.Instance.Release(organisationComponent);
            }
        }
 public InteractionService(IVerintConnection verint, IIndividualService individualService, IOrganisationService organisationService, ILogger <InteractionService> logger)
 {
     _verintConnection    = verint.Client();
     _individualService   = individualService;
     _organisationService = organisationService;
     _logger = logger;
 }
Пример #19
0
 public AdministratorController(IOrganisationService organisationService, IBranchService branchService, IBankService bankService, IEmployeeService employeeService, IUserManager userManager)
 {
     _organisationService = organisationService;
     _branchService = branchService;
     _bankService = bankService;
     _employeeService = employeeService;
     _userManager = userManager;
 }
Пример #20
0
        public void DisposeContainer()
        {
            servicelocator.Release(_organisationService);
            _organisationService = null;

            _container.Dispose();
            _container = null;
        }
Пример #21
0
        public void SetContainer()
        {
            //configure the container
            _container = new NetBpmContainer(new XmlInterpreter("WindsorConfig.xml"));
            servicelocator = ServiceLocator.Instance;
            _organisationService = servicelocator.GetService(typeof(IOrganisationService)) as IOrganisationService;

        }
 public virtual void SetUp()
 {
     OrganisationService        = Substitute.For <IOrganisationService>();
     FormsAuthenticationService = Substitute.For <IFormsAuthenticationService>();
     ApplicationService         = Substitute.For <IApplicationService>();
     LabelCollectionRetriever   = Substitute.For <ILabelCollectionRetriever>();
     DashboardViewModelGetter   = new DashboardViewModelGetter(ApplicationService, LabelCollectionRetriever, OrganisationService);
 }
Пример #23
0
 public void SetUp()
 {
     //configure the container
     container                    = new NetBpm.NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir() + "app_config.xml"));
     organisationComponent        = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));
     testAssignmentContext        = new TestAssignmentContext(this, organisationComponent);
     assignmentExpressionResolver = new AssignmentExpressionResolver();
 }
Пример #24
0
        public void DisposeContainer()
        {
            servicelocator.Release(_organisationService);
            _organisationService = null;

            _container.Dispose();
            _container = null;
        }
Пример #25
0
 public OrganisationsApi(IOrganisationService organisationService,
                         ISearchApi searchApi,
                         IUserDigestService userDigestService)
 {
     _organisationService = organisationService;
     _searchApi           = searchApi;
     _userDigestService   = userDigestService;
 }
Пример #26
0
		public void SetUp()
		{
			//configure the container
			container = new NetBpm.NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir()+"app_config.xml"));
			organisationComponent = (IOrganisationService) ServiceLocator.Instance.GetService(typeof (IOrganisationService));
			testAssignmentContext = new TestAssignmentContext(this,organisationComponent);
			assignmentExpressionResolver = new AssignmentExpressionResolver();
		}
Пример #27
0
 public MembershipApplicationServiceDependencies(IStorageService storageService,
                                                 IUserService userService, IOrganisationService organisationService
                                                 )
 {
     StorageService      = storageService;
     UserService         = userService;
     OrganisationService = organisationService;
 }
Пример #28
0
 public OrganisationsController(
     IAuthenticationService authenticationService,
     IOrganisationService organisationService,
     IFileStorageService fileStorageService)
 {
     OrganisationService   = organisationService;
     AuthenticationService = authenticationService;
     FileStorageService    = fileStorageService;
 }
Пример #29
0
 public ExecutionContextImpl(String actorId, ProcessInstanceImpl processInstance, DbSession dbSession, IOrganisationService organisationComponent)
 {
     this._actorId               = actorId;
     this._processInstance       = processInstance;
     this._processDefinition     = (ProcessDefinitionImpl)processInstance.ProcessDefinition;
     this._dbSession             = dbSession;
     this._organisationComponent = organisationComponent;
     this._assignedFlows         = new ArrayList();
 }
Пример #30
0
 public GetByEdsUrnStrategy(IEmployerReadRepository employerReadRepository, IEmployerWriteRepository employerWriteRepository, IOrganisationService organisationService, IAddressLookupProvider addressLookupProvider, IMapper mapper, ILogService logService)
 {
     _employerReadRepository  = employerReadRepository;
     _employerWriteRepository = employerWriteRepository;
     _organisationService     = organisationService;
     _mapper                = mapper;
     _logService            = logService;
     _addressLookupProvider = addressLookupProvider;
 }
Пример #31
0
 public ExecutionContextImpl(String actorId, ProcessInstanceImpl processInstance, DbSession dbSession, IOrganisationService organisationComponent)
 {
     this._actorId = actorId;
     this._processInstance = processInstance;
     this._processDefinition = (ProcessDefinitionImpl) processInstance.ProcessDefinition;
     this._dbSession = dbSession;
     this._organisationComponent = organisationComponent;
     this._assignedFlows = new ArrayList();
 }
Пример #32
0
 public DepartmentController(IDepartmentService departmentService,
                             IEmployeeService employeeService,
                             IOrganisationService organisationService, IUserService userService, IServiceService serviceService)
 {
     _departmentService   = departmentService;
     _employeeService     = employeeService;
     _organisationService = organisationService;
     _userService         = userService;
     _serviceService      = serviceService;
 }
 public EmployeeOrganisationController(IEmployeeOrganisationService employeeOrganisationService,
                                       IOrganisationService organisationService,
                                       IEmployeePositionOfficialService employeePositionOfficialService,
                                       IEmployeeService employeeService)
 {
     _employeeOrganisationService     = employeeOrganisationService;
     _organisationService             = organisationService;
     _employeePositionOfficialService = employeePositionOfficialService;
     _employeeService = employeeService;
 }
Пример #34
0
 public OrganisationsController(
     IOrganisationService organisationService,
     IValidator <CreateOrganisationRequestDto> createOrganisationRequestDto,
     IValidator <UpdateOrganisationRequestDto> updateOrganisationRequestDtoValidator,
     IMapper mapper) : base(mapper)
 {
     _organisationService = organisationService;
     _createOrganisationRequestDtoValidator = createOrganisationRequestDto;
     _updateOrganisationRequestDtoValidator = updateOrganisationRequestDtoValidator;
 }
Пример #35
0
        public ProcessExecutionService()
        {
            myProcessDefinitionService = new MyProcessDefinitionService();
            delegateService            = new DelegationService();
            organisationService        = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));

            taskRepository            = TaskRepository.Instance;
            transitionRepository      = TransitionRepository.Instance;
            processInstanceRepository = ProcessInstanceRepository.Instance;
            flowRepository            = FlowRepository.Instance;
        }
Пример #36
0
        public ProcessExecutionService()
        {
            myProcessDefinitionService = new MyProcessDefinitionService();
            delegateService = new DelegationService();
            organisationService = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));

            taskRepository = TaskRepository.Instance;
            transitionRepository = TransitionRepository.Instance;
            processInstanceRepository = ProcessInstanceRepository.Instance;
            flowRepository = FlowRepository.Instance;
        }
Пример #37
0
 public TokenService(
     IAppSecretRepository appSecretRepository,
     UserManager <ApplicationUser> userManager,
     IdentityServerTools tools,
     IOrganisationService organisationService)
 {
     this.appSecretRepository = appSecretRepository;
     this.userManager         = userManager;
     this.tools = tools;
     this.organisationService = organisationService;
 }
Пример #38
0
 public SuggestionServiceDependencies(IOrganisationService organisationService,
                                      IUserService userService,
                                      IStorageService storageService,
                                      IMemberService memberService
                                      )
 {
     OrganisationService = organisationService;
     UserService         = userService;
     StorageService      = storageService;
     MemberService       = memberService;
 }
Пример #39
0
		public void SetContainer()
		{
			//configure the container
			_container = new NetBpmContainer(new XmlInterpreter(TestHelper.GetConfigDir()+"app_config.xml"));
			testUtil = new TestUtil();
			servicelocator = ServiceLocator.Instance;
			definitionComponent = servicelocator.GetService(typeof (IProcessDefinitionService)) as IProcessDefinitionService;
			executionComponent = servicelocator.GetService(typeof (IExecutionApplicationService)) as IExecutionApplicationService;
			schedulerComponent = servicelocator.GetService(typeof (ISchedulerSessionLocal)) as ISchedulerSessionLocal;
			organisationComponent = servicelocator.GetService(typeof (IOrganisationService)) as IOrganisationService;
			testUtil.LoginUser("ae");
		}
Пример #40
0
		public void DisposeContainer()
		{	
			servicelocator.Release(definitionComponent);
			definitionComponent=null;
			servicelocator.Release(executionComponent);
			executionComponent=null;
			servicelocator.Release(schedulerComponent);
			schedulerComponent=null;
			servicelocator.Release(organisationComponent);
			organisationComponent=null;

			_container.Dispose();
			_container = null;
		}
Пример #41
0
		public void SetContainer()
		{
			//configure the container
			_container = new NetBpmContainer(new XmlInterpreter("app_config.xml"));
			testUtil = new TestUtil();
			servicelocator = ServiceLocator.Instance;
			definitionComponent = servicelocator.GetService(typeof (IProcessDefinitionService)) as IProcessDefinitionService;
			executionComponent = servicelocator.GetService(typeof (IExecutionApplicationService)) as IExecutionApplicationService;
			schedulerComponent = servicelocator.GetService(typeof (ISchedulerSessionLocal)) as ISchedulerSessionLocal;
			organisationComponent = servicelocator.GetService(typeof (IOrganisationService)) as IOrganisationService;
			testUtil.LoginUser("ae");

			// Par是一個壓縮檔,除了有定義檔之外,還有可以用來展出Web-UI定義及相關圖形
			FileInfo parFile = new FileInfo(TestHelper.GetExampleDir()+GetParArchiv());
			FileStream fstream = parFile.OpenRead();
			byte[] b = new byte[parFile.Length];
			fstream.Read(b, 0, (int) parFile.Length);
            //此處在解壓縮Par
			definitionComponent.DeployProcessArchive(b);

		}
Пример #42
0
        public void CancelFlow(String authenticatedActorId, Int64 flowId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            // first check if the actor is allowed to cancel this flow
            authorizationHelper.CheckCancelFlow(authenticatedActorId, flowId, dbSession);

            FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);

            log.Info("actor '" + authenticatedActorId + "' cancels flow '" + flowId + "'...");

            // only perform the cancel if this flow is not finished yet
            if (!flow.EndHasValue)
            {
                ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, flow, dbSession, organisationComponent);
                executionContext.CreateLog(authenticatedActorId, EventType.FLOW_CANCEL);

                if (flow.IsRootFlow())
                {
                    // set the flow in the end-state
                    log.Debug("setting root flow to the end state...");
                    EndStateImpl endState = (EndStateImpl) flow.ProcessInstance.ProcessDefinition.EndState;
                    engine.ProcessEndState(endState, executionContext, dbSession);
                }
                else
                {
                    // set the flow in the join
                    ConcurrentBlockImpl concurrentBlock = (ConcurrentBlockImpl) flow.Node.ProcessBlock;
                    JoinImpl join = (JoinImpl) concurrentBlock.Join;
                    log.Debug("setting concurrent flow to join '" + join + "'");
                    engine.ProcessJoin(join, executionContext, dbSession);
                }

                // flush the updates to the db
                dbSession.Update(flow);
                dbSession.Flush();
            }
        }
Пример #43
0
        private IList GetGroupTaskList(String authenticatedActorId, ArrayList groupTaskLists, String groupId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            if (groupTaskLists == null)
            {
                groupTaskLists = new ArrayList();
            }
            IGroup g = organisationComponent.FindGroupById(groupId, new Relations("parent"));
            IGroup gParent = g.Parent;
            if (gParent != null)
            {
                // scan if this group has more parent(s)
                GetGroupTaskList(authenticatedActorId, groupTaskLists, gParent.Id, dbSession, organisationComponent);
            }
            // no more parent
            IList gTaskLists = taskRepository.FindTasks(g.Id, dbSession);
            groupTaskLists.AddRange(gTaskLists);
            log.Debug("added task lists [" + gTaskLists + "] for group [" + g + "]");

            return groupTaskLists;
        }
Пример #44
0
        public IProcessInstance StartProcessInstance(String authenticatedActorId, Int64 processDefinitionId, IDictionary attributeValues, String transitionName, Relations relations, DbSession dbSession, IOrganisationService organisationComponent)
        {
            ProcessInstanceImpl processInstance = null;

            // First check if the actor is allowed to start this instance
            authorizationHelper.CheckStartProcessInstance(authenticatedActorId, processDefinitionId, attributeValues, transitionName, dbSession);

            // get the process-definition and its start-state
            ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl)definitionRepository.GetProcessDefinition(processDefinitionId, null, dbSession);
            StartStateImpl startState = (StartStateImpl) processDefinition.StartState;

            log.Info("actor '" + authenticatedActorId + "' starts an instance of process '" + processDefinition.Name + "'...");

            processInstance = new ProcessInstanceImpl(authenticatedActorId, processDefinition);
            FlowImpl rootFlow = (FlowImpl) processInstance.RootFlow;

            ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, rootFlow, dbSession, organisationComponent);
            MyExecutionContext myExecutionContext = new MyExecutionContext();

            // save the process instance to allow hibernate queries
            dbSession.Save(processInstance);
            //dbSession.Lock(processInstance,LockMode.Upgrade);

            delegationService.RunActionsForEvent(EventType.BEFORE_PERFORM_OF_ACTIVITY, startState.Id, executionContext,dbSession);

            // store the attributes
            executionContext.CreateLog(authenticatedActorId, EventType.PROCESS_INSTANCE_START);
            //LogImpl logImpl = rootFlow.CreateLog(authenticatedActorId, EventType.PROCESS_INSTANCE_START);//new add
            executionContext.CheckAccess(attributeValues, startState);
            //startState.CheckAccess(attributeValues);
            //�ݨӤ]�䤣��AttributeInstance
            executionContext.StoreAttributeValues(attributeValues);

            // if this activity has a role-name, save the actor in the corresponding attribute
            executionContext.StoreRole(authenticatedActorId, startState);

            // run the actions
            delegationService.RunActionsForEvent(EventType.PROCESS_INSTANCE_START, processDefinitionId, executionContext,dbSession);

            // from here on, we consider the actor as being the previous actor
            executionContext.SetActorAsPrevious();

            // process the start-transition
            TransitionImpl startTransition = transitionRepository.GetTransition(transitionName, startState, dbSession);
            engine.ProcessTransition(startTransition, executionContext, dbSession);

            // run the actions
            delegationService.RunActionsForEvent(EventType.AFTER_PERFORM_OF_ACTIVITY, startState.Id, executionContext,dbSession);

            // flush the updates to the db
            dbSession.Update(processInstance);
            dbSession.Flush();

            //@portme
            /*			if (relations != null)
            {
                relations.resolve(processInstance);
            }
            */
            return processInstance;
        }
Пример #45
0
 public void SaveActivity(String authenticatedActorId, Int64 flowId, IDictionary attributeValues, DbSession dbSession, IOrganisationService organisationComponent)
 {
     // get the flow
     FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);
     // create the execution-context
     ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, flow, dbSession, organisationComponent);
     executionContext.StoreAttributeValues(attributeValues);
 }
Пример #46
0
        public IList PerformActivity(String authenticatedActorId, Int64 flowId, IDictionary attributeValues, String transitionName, Relations relations, DbSession dbSession, IOrganisationService organisationComponent)
        {
            IList assignedFlows = null;
            // get the flow
            FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);
            dbSession.Lock(flow.ProcessInstance, LockMode.Upgrade);
            ActivityStateImpl activityState = (ActivityStateImpl) flow.Node;

            // TODO : check which part can move to the DefaultAuthorizationHandler
            if ((Object) flow.ActorId == null)
            {
                throw new SystemException("the flow on which you try to perform an activity is not assigned to an actor");
            }
            else
            {
                if ((Object) authenticatedActorId == null)
                {
                    throw new AuthorizationException("you can't perform an activity because you are not authenticated");
                }
                //		else if ( ! authenticatedActorId.equals( flow.getActorId() ) ) {
                //        throw new AuthorizationException( "activity '" + activityState.getName() + "' in flow " + flow.getId() + " is not assigned to the authenticated actor (" + authenticatedActorId + ") but to " + flow.getActorId() );
                //      }
            }

            // first check if the actor is allowed to perform this activity
            authorizationHelper.CheckPerformActivity(authenticatedActorId, flowId, attributeValues, transitionName, dbSession);

            log.Info("actor '" + authenticatedActorId + "' performs activity '" + activityState.Name + "'...");

            // create the execution-context
            ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, flow, dbSession, organisationComponent);

            // if this activity has a role-name, save the actor in the corresponding attribute
            // attributeValues = state.addRoleAttributeValue( attributeValues, authenticatedActorId, organisationComponent );

            // log event & trigger actions
            delegationService.RunActionsForEvent(EventType.BEFORE_PERFORM_OF_ACTIVITY, activityState.Id, executionContext,dbSession);

            // store the supplied attribute values
            executionContext.CreateLog(authenticatedActorId, EventType.PERFORM_OF_ACTIVITY);
            executionContext.AddLogDetail(new ObjectReferenceImpl(activityState));
            executionContext.CheckAccess(attributeValues, activityState);
            executionContext.StoreAttributeValues(attributeValues);

            // log event & trigger actions
            delegationService.RunActionsForEvent(EventType.PERFORM_OF_ACTIVITY, activityState.Id, executionContext,dbSession);

            // from here on, we consider the actor as being the previous actor
            executionContext.SetActorAsPrevious();

            // select and process the transition
            TransitionImpl startTransition = transitionRepository.GetTransition(transitionName, activityState, dbSession);
            engine.ProcessTransition(startTransition, executionContext, dbSession);

            // log event & trigger actions
            delegationService.RunActionsForEvent(EventType.AFTER_PERFORM_OF_ACTIVITY, activityState.Id, executionContext,dbSession);

            assignedFlows = executionContext.AssignedFlows;

            // flush the updates to the db
            dbSession.Update(flow.ProcessInstance);
            dbSession.Flush();

            if (relations != null)
            {
                relations.Resolve(assignedFlows);
            }
            dbSession.Update(flow.ProcessInstance);
            return assignedFlows;
        }
Пример #47
0
 public IList GetTaskList(String authenticatedActorId, IList actorIds, Relations relations, DbSession dbSession, IOrganisationService organisationComponent)
 {
     ArrayList tasks = null;
     IEnumerator actorIdsIterator = actorIds.GetEnumerator();
     while (actorIdsIterator.MoveNext())
     {
         String actorId = (String) actorIdsIterator.Current;
         if (tasks == null)
         {
             tasks = new ArrayList();
         }
         tasks.AddRange(GetTaskList(authenticatedActorId, actorId, relations, dbSession, organisationComponent));
     }
     return tasks;
 }
Пример #48
0
        //private const String queryFindTasks = "select flow " +
        //    "from flow in class NetBpm.Workflow.Execution.Impl.FlowImpl " +
        //    "where flow.ActorId = ?";
        public IList GetTaskList(String authenticatedActorId, String actorId, Relations relations, DbSession dbSession, IOrganisationService organisationComponent)
        {
            IList tasks = null;
            IActor actor = organisationComponent.FindActorById(actorId);

            if (actor is IUser)
            {
                log.Debug("getting task lists for actor --> User : [" + actor + "]");
                tasks = taskRepository.FindTasks(actorId, dbSession);
            }
            else if (actor is IGroup)
            {
                log.Debug("getting task lists for actor --> Group : [" + actor + "]");
                tasks = GetGroupTaskList(authenticatedActorId, null, actorId, dbSession, organisationComponent);
            }

            if (relations != null)
            {
                relations.Resolve(tasks);
            }

            return tasks;
        }
 public OrganisationController(IOrganisationService organisationService)
 {
     _organisationService = organisationService;
 }
Пример #50
0
        public IActivityForm GetActivityForm(String authenticatedActorId, Int64 flowId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            IActivityForm activityForm = null;

            // First check if the actor is allowed to get this form
            authorizationHelper.CheckGetActivityForm(authenticatedActorId, flowId, dbSession);

            FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);
            StateImpl state = (StateImpl) flow.Node;

            // create an executionContext for easy attributeValue retrieval
            ExecutionContextImpl executionContext = new ExecutionContextImpl(null, flow, dbSession, organisationComponent);

            // create a convenient map from the attribute-names to the fields
            IList fields = fieldRepository.FindFieldsByState(state.Id,dbSession);
            IDictionary attributeValues = new Hashtable();
            IEnumerator iter = fields.GetEnumerator();
            while (iter.MoveNext())
            {
                FieldImpl field = (FieldImpl) iter.Current;
                if (FieldAccessHelper.IsReadable(field.Access) || FieldAccessHelper.IsWritable(field.Access))
                {
                    // activity form contains only readable or writeable fields
                    String attributeName = field.Attribute.Name;
                    if (executionContext.GetAttribute(attributeName) != null)
                    {
                        // attribute might not exist (this will cause a warning already being logged previusly)
                        attributeValues[attributeName] = executionContext.GetAttribute(attributeName);
                    }
                }
            }

            activityForm = new ActivityFormImpl(flow, fields, attributeValues);

            return activityForm;
        }
Пример #51
0
        //@todo delete parameter organisationComponent
        public void DelegateActivity(String authenticatedActorId, Int64 flowId, String delegateActorId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            // first check if the actor is allowed to delegate this activity
            authorizationHelper.CheckDelegateActivity(authenticatedActorId, flowId, delegateActorId, dbSession);

            // reassign the flow
            FlowImpl flow = (FlowImpl) dbSession.Load(typeof (FlowImpl), flowId);
            flow.ActorId = delegateActorId;

            // flush the updates to the db
            dbSession.Update(flow);
            dbSession.Flush();
        }
Пример #52
0
        public long ExecuteTask(DbSession dbSession, IOrganisationService organisationComponent)
        {
            long millisToWait = DEFAULT_INTERVAL;

            DateTime now = DateTime.Now;

            IEnumerator iter = dbSession.Iterate(queryFindJobsToBeExecuted, now, DbType.TIMESTAMP).GetEnumerator();
            if (iter.MoveNext())
            {
                JobImpl job = (JobImpl) iter.Current;

                try
                {
                    log.Debug("executing activation '" + job.Id + "' scheduled for " + job.Date.ToString());
                    log.Debug("activation's flow-context is :" + job.Context);

                    String userId = job.UserId;

                    DelegationImpl actionDelegation = job.ActionDelegation;

                    ExecutionContextImpl executionContext = new ExecutionContextImpl(userId, dbSession, organisationComponent);
                    IFlow context = job.Context;
                    if (context != null)
                    {
                        executionContext.SetFlow(context);
                        executionContext.SetProcessInstance(context.ProcessInstance);
                        executionContext.SetProcessDefinition(context.ProcessInstance.ProcessDefinition);
                    }
                    else
                    {
                        executionContext.SetProcessDefinition(job.ProcessDefinition);
                    }

                    delegationHelper.DelegateScheduledAction(actionDelegation, executionContext);

                }
                catch (Exception t)
                {
                    log.Error("scheduler-exception : couldn't perform task : " + t.Message, t);
                }

                dbSession.Delete(job);
                dbSession.Flush();
                if (iter.MoveNext())
                {
                    return 0;
                }
            }

            iter = dbSession.Iterate(queryFindJobsInTheFuture, now, DbType.TIMESTAMP).GetEnumerator();
            if (iter.MoveNext())
            {
                JobImpl activation = (JobImpl) iter.Current;
                long activationDate = activation.Date.Ticks;
                millisToWait = activationDate - now.Ticks;
                log.Debug("next activation is scheduled at " + activation.Date.ToString() + ", (in " + millisToWait + " millis)");
                if (millisToWait < 0)
                    millisToWait = 0;
                if (millisToWait > DEFAULT_INTERVAL)
                    millisToWait = DEFAULT_INTERVAL;
            }

            return millisToWait;
        }
 public ActorExpressionResolverService(string previousActorId)
 {
     PreviousActorId = previousActorId;
     organizationService = (IOrganisationService)ServiceLocator.Instance.GetService(typeof(IOrganisationService));
 }
Пример #54
0
			public TestAssignmentContext(ActorExpressionTest enclosingInstance,IOrganisationService organisationComponent)
			{
				orgComponent = organisationComponent;
				InitBlock(enclosingInstance);
				this.previousActor = organisationComponent.FindActorById("ae");
				this.processInstance = new ProcessInstanceImpl();
				this.processInstance.InitiatorActorId = "pf";
				this.configuration = new Hashtable();
				this.attributes = new Hashtable();
				this.attributes["boss"] = organisationComponent.FindActorById("cg");
				this.attributes["requester group"] = organisationComponent.FindGroupById("group-rd");
			}
Пример #55
0
        //private const String queryFieldsByState = "select f from f in class NetBpm.Workflow.Definition.Impl.FieldImpl " +
        //    "where f.State.Id = ? " +
        //    "order by f.Index";
        public IActivityForm GetStartForm(String authenticatedActorId, Int64 processDefinitionId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            IActivityForm activityForm = null;

            // First check if the actor is allowed to get this form
            authorizationHelper.CheckGetStartForm(authenticatedActorId, processDefinitionId, dbSession);

            ProcessDefinitionImpl processDefinition = (ProcessDefinitionImpl) dbSession.Load(typeof (ProcessDefinitionImpl), processDefinitionId);
            StartStateImpl startState = (StartStateImpl) processDefinition.StartState;

            // create a convenient map from the attribute-names to the fields
            IList fields = fieldRepository.FindFieldsByState(startState.Id, dbSession);
            IDictionary attributeValues = new Hashtable();
            IEnumerator iter = fields.GetEnumerator();
            while (iter.MoveNext())
            {
                FieldImpl field = (FieldImpl) iter.Current;

                // if the attribute has an initial value
                AttributeImpl attribute = (AttributeImpl) field.Attribute;
                String attributeName = attribute.Name;
                String initialValue = attribute.InitialValue;
                if ((Object) initialValue != null && (FieldAccessHelper.IsReadable(field.Access) || FieldAccessHelper.IsWritable(field.Access)))
                {
                    // start form contains only fields that are readable or writable

                    // get it and store it in the attributeValues
                    AttributeInstanceImpl attributeInstance = new AttributeInstanceImpl();
                    attributeInstance.Attribute = attribute;
                    attributeInstance.ValueText = initialValue;
                    attributeValues[attributeName] = attributeInstance.GetValue();
                }
            }

            activityForm = new ActivityFormImpl(processDefinition, fields, attributeValues);

            return activityForm;
        }
Пример #56
0
        public void CancelProcessInstance(String authenticatedActorId, Int64 processInstanceId, DbSession dbSession, IOrganisationService organisationComponent)
        {
            // first check if the actor is allowed to cancel this process instance
            authorizationHelper.CheckCancelProcessInstance(authenticatedActorId, processInstanceId, dbSession);

            ProcessInstanceImpl processInstance = (ProcessInstanceImpl) dbSession.Load(typeof (ProcessInstanceImpl), processInstanceId);

            log.Info("actor '" + authenticatedActorId + "' cancels processInstance '" + processInstanceId + "'...");

            if (!processInstance.EndHasValue)
            {
                CancelFlowRecursive((FlowImpl) processInstance.RootFlow, DateTime.Now);
                ExecutionContextImpl executionContext = new ExecutionContextImpl(authenticatedActorId, (FlowImpl) processInstance.RootFlow, dbSession, organisationComponent);
                executionContext.CreateLog(authenticatedActorId, EventType.PROCESS_INSTANCE_CANCEL);
                EndStateImpl endState = (EndStateImpl) processInstance.ProcessDefinition.EndState;
                engine.ProcessEndState(endState, executionContext, dbSession);
                processInstance.End = DateTime.Now;

                // flush the updates to the db
                dbSession.Update(processInstance);
                dbSession.Flush();
            }
            else
            {
                throw new SystemException("couldn't cancel process instance : process instance '" + processInstanceId + "' was already finished");
            }
        }
Пример #57
0
 public ExecutionContextImpl(String actorId, DbSession dbSession, IOrganisationService organisationComponent)
 {
     this._actorId = actorId;
     this._dbSession = dbSession;
     this._organisationComponent = organisationComponent;
 }
 public void SetUp()
 {
     OrganisationService = MockRepository.GenerateMock<IOrganisationService>();
     OrganisationsController = new OrganisationController(OrganisationService);
 }
 private void SendValidationMailToOrganisation(IOrganisationService srvOrg, Organisation org)
 {
     if (org.ValidationState.LastIndexOf(OrganisationValidate.NoProgram) >= 0)
       {
     srvOrg.OrganisationValidateSendEmailByCategory(org, EmailCategory.ValidationNoProgram, "");
     if (pbOrgValidate.Visible && pbOrgValidate.Maximum -1 < pbOrgValidate.Value)
       pbOrgValidate.Value++;
       }
       if (org.ValidationState.LastIndexOf(OrganisationValidate.NoQuestionForm) >= 0)
       {
     srvOrg.OrganisationValidateSendEmailByCategory(org, EmailCategory.ValidationNoQuestionForm, "");
     if (pbOrgValidate.Visible && pbOrgValidate.Maximum - 1 < pbOrgValidate.Value)
     pbOrgValidate.Value++;
       }
       if (org.ValidationState.LastIndexOf(OrganisationValidate.NoQuestionFormRefresh) >= 0)
       {
     srvOrg.OrganisationValidateSendEmailByCategory(org, EmailCategory.ValidationNoQuestionFormRefresh, "");
     if (pbOrgValidate.Visible && pbOrgValidate.Maximum - 1 < pbOrgValidate.Value)
     pbOrgValidate.Value++;
       }
       if (org.ValidationState.LastIndexOf(OrganisationValidate.NoOrgQuestionForm) >= 0)
       {
     srvOrg.OrganisationValidateSendEmailByCategory(org, EmailCategory.ValidationNoOrgQuestionForm, "");
     if (pbOrgValidate.Visible && pbOrgValidate.Maximum - 1 < pbOrgValidate.Value)
     pbOrgValidate.Value++;
       }
       if (org.ValidationState.LastIndexOf(OrganisationValidate.NoOrgQuestionFormRefresh) >= 0)
       {
     srvOrg.OrganisationValidateSendEmailByCategory(org, EmailCategory.ValidationNoOrgQuestionFormRefresh, "");
     if (pbOrgValidate.Visible && pbOrgValidate.Maximum - 1 < pbOrgValidate.Value)
     pbOrgValidate.Value++;
       }
       if (org.ValidationState.LastIndexOf(OrganisationValidate.NoBaseDatasRefresh) >= 0)
       {
     srvOrg.OrganisationValidateSendEmailByCategory(org, EmailCategory.ValidationNoBaseDatasRefresh, "");
     if (pbOrgValidate.Visible && pbOrgValidate.Maximum - 1 < pbOrgValidate.Value)
     pbOrgValidate.Value++;
       }
 }