Ejemplo n.º 1
0
        protected internal virtual BusinessProcessEvent createEvent(DelegateTask task)
        {
            ExecutionContext        executionContext  = Context.ExecutionContext;
            ProcessDefinitionEntity processDefinition = null;

            if (executionContext != null)
            {
                processDefinition = executionContext.ProcessDefinition;
            }

            // map type
            string eventName = task.EventName;
            BusinessProcessEventType type = null;

            if ([email protected]_Fields.EVENTNAME_CREATE.Equals(eventName))
            {
                type = org.camunda.bpm.engine.cdi.BusinessProcessEventType_Fields.CREATE_TASK;
            }
            else if ([email protected]_Fields.EVENTNAME_ASSIGNMENT.Equals(eventName))
            {
                type = org.camunda.bpm.engine.cdi.BusinessProcessEventType_Fields.ASSIGN_TASK;
            }
            else if ([email protected]_Fields.EVENTNAME_COMPLETE.Equals(eventName))
            {
                type = org.camunda.bpm.engine.cdi.BusinessProcessEventType_Fields.COMPLETE_TASK;
            }
            else if ([email protected]_Fields.EVENTNAME_DELETE.Equals(eventName))
            {
                type = org.camunda.bpm.engine.cdi.BusinessProcessEventType_Fields.DELETE_TASK;
            }

            return(new CdiBusinessProcessEvent(task, processDefinition, type, ClockUtil.CurrentTime));
        }
Ejemplo n.º 2
0
        public void Queue(MainLoopTask task)
        {
            DelegateTask dTask = cache.Dequeue();

            dTask.Task = task;
            Queue(dTask);
        }
Ejemplo n.º 3
0
 public ResultStatus CreateParametricData(
     DelegateTask delegateTask,
     DelegateTask_Request request,
     out DelegateTask_Result result)
 {
     return(this.CreateParametricData(delegateTask, (DelegateTask_Parameters)null, request, out result));
 }
Ejemplo n.º 4
0
 public ResultStatus ProcessComputation(
     DelegateTask delegateTask,
     DelegateTask_Request request,
     out DelegateTask_Result result)
 {
     return(this.ProcessComputation(delegateTask, (DelegateTask_Parameters)null, request, out result));
 }
Ejemplo n.º 5
0
 public ResultStatus DelegateApprover(
     DelegateTask delegateTask,
     DelegateTask_Request request,
     out DelegateTask_Result result)
 {
     return(this.DelegateApprover(delegateTask, (DelegateTask_DelegateApprover_Parameters)null, request, out result));
 }
Ejemplo n.º 6
0
 public ResultStatus LoadESigDetails(
     DelegateTask delegateTask,
     DelegateTask_Request request,
     out DelegateTask_Result result)
 {
     return(this.LoadESigDetails(delegateTask, (DelegateTask_LoadESigDetails_Parameters)null, request, out result));
 }
Ejemplo n.º 7
0
        void Loop()
        {
            while (true)
            {
                DelegateTask task = null;

                lock (tasks)
                {
                    if (tasks.Count > 0)
                    {
                        task = tasks.Dequeue();
                    }
                }

                if (task == null)
                {
                    handle.WaitOne();
                }
                else
                {
                    bool reuse = !task.IsBlocking;
                    task.Execute();
                    if (reuse)
                    {
                        cache.Enqueue(task);
                    }
                }
                Thread.Sleep(10);
            }
        }
Ejemplo n.º 8
0
        public void RemoveTask(string name)
        {
            DelegateTask t = _tasks.Find(x => x.Name == name);

            t.Active = false;
            RemoveTask(t);
        }
Ejemplo n.º 9
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            timeSpinning = 0.0f;

            var jitterTimer = 0f;
            var moveAtMouse = new MoveTowardsMouseForSeconds(this, 2.0f);
            var spin        = new DelegateTask(PickSpinRotation, SpinForSeconds);
            var jitter      = new DelegateTask(() => {}, () =>
            {
                jitterTimer += Time.deltaTime;

                var position       = transform.position + 0.1f * Random.insideUnitSphere;
                position.z         = 0;
                transform.position = position;

                return(jitterTimer > 3);
            });

            moveAtMouse.Then(spin).Then(jitter);

            _tm.Do(moveAtMouse);
        }

        _tm.Update();
    }
Ejemplo n.º 10
0
        public virtual void notify(DelegateTask delegateTask)
        {
            // Note: we can't cache the result of the expression, because the
            // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}'

            VariableScope variableScope = delegateTask.Execution;

            if (variableScope == null)
            {
                variableScope = delegateTask.CaseExecution;
            }

            object @delegate = expression.getValue(variableScope);

            applyFieldDeclaration(fieldDeclarations, @delegate);

            if (@delegate is TaskListener)
            {
                try
                {
                    Context.ProcessEngineConfiguration.DelegateInterceptor.handleInvocation(new TaskListenerInvocation((TaskListener)@delegate, delegateTask));
                }
                catch (Exception e)
                {
                    throw new ProcessEngineException("Exception while invoking TaskListener: " + e.Message, e);
                }
            }
            else
            {
                throw new ProcessEngineException("Delegate expression " + expression + " did not resolve to an implementation of " + typeof(TaskListener));
            }
        }
Ejemplo n.º 11
0
        private object QueueWait(DelegateTask t)
        {
            if (t.Handle != null)
            {
                t.Handle.Reset();
            }
            else
            {
                t.Handle = new ManualResetEvent(false);
            }

            if (Thread.CurrentThread == thread)
            {
                t.Execute();
            }
            else
            {
                Queue(t);
            }

            t.Handle.WaitOne();
            t.Handle.Close();

            return(t.Result);
        }
Ejemplo n.º 12
0
        void Loop()
        {
            while (true)
            {
                DelegateTask task = null;

                lock (_tasks)
                {
                    if (_tasks.Count > 0)
                    {
                        task = _tasks.Dequeue();
                    }
                }

                if (task == null)
                {
                    if (_disposeEnqueued)
                    {
                        _disposed        = true;
                        _disposeEnqueued = false;
                        break;
                    }

                    _handle.WaitOne();
                }
                else
                {
                    task.Execute();
                    if (!task.IsBlocking)
                    {
                        _cache.Enqueue(task);
                    }
                }
            }
        }
Ejemplo n.º 13
0
 public virtual void notify(DelegateTask delegateTask)
 {
     foreach (DelegateTaskAsserter asserter in asserts)
     {
         asserter.doAssert(delegateTask);
     }
 }
Ejemplo n.º 14
0
    private static Task DefineDialogueSequence()
    {
        Task enterDialogue = new DelegateTask(() => { Logger.Warning("DefineDialogueSequence start"); }, () =>
        {
            return(Services.PlayerMovement.inPlaceForSequence);
        });

        ActionTask triggerCameraAndUI = new ActionTask(() =>
        {
            Logger.Warning("DefineDialogueSequence triggering camera to enter dialogue");
            Services.CameraManager.EnterDialogue();
            Services.UIManager.EnterDialogue();
        });

        Task fadeIn = new WaitTask(.5f);

        Task startConvo = new ActionTask(() =>
        {
            Logger.Warning("DefineDialogueSequence entering dialogue");
            Services.DialogueController.EnterDialogue();
            _enterDialogueFailsafe.Abort();
        });

        enterDialogue.Then(triggerCameraAndUI).Then(fadeIn).Then(startConvo);
        return(enterDialogue);
    }
Ejemplo n.º 15
0
 public ResultStatus GetWIPMsgs(
     DelegateTask delegateTask,
     DelegateTask_Request request,
     out DelegateTask_Result result)
 {
     return(this.GetWIPMsgs(delegateTask, (DelegateTask_Parameters)null, request, out result));
 }
Ejemplo n.º 16
0
 private void Queue(DelegateTask task)
 {
     lock (_tasks)
     {
         _tasks.Enqueue(task);
         _handle.Set();
     }
 }
Ejemplo n.º 17
0
 private void Queue(DelegateTask task, Priority priority)
 {
     lock (tasks)
     {
         tasks.Enqueue(task);
         handle.Set();
     }
 }
Ejemplo n.º 18
0
 private void Queue(DelegateTask task, Priority priority)
 {
     lock (tasks)
     {
         tasks.Enqueue(task);
         handle.Set();
     }
 }
Ejemplo n.º 19
0
        // ******************************* PUBLIC METHODS *******************************************************************

        public Scheduler.DelegateTask AddTask(string name, int interval, DelegateTask.DoItDelegate dlg, object what)
        {
            Debug.Assert(_tasks.Find(x => x.Name == name) == null);
            DelegateTask t = new DelegateTask(name, interval, dlg, what);

            t.Active = true;
            _tasks.Add(t);
            return(t);
        }
Ejemplo n.º 20
0
 public DelegateTaskMethod(
     DelegateTask Cdo,
     DelegateTaskMethods Method,
     DelegateTask_Parameters Parameters)
 {
     this.Cdo           = Cdo;
     this.ServiceMethod = Method;
     this.Parameters    = Parameters;
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Queues work that will be run in the engine main thread.
        /// </summary>
        /// <param name="action">The action to run.</param>
        /// <param name="arg1">The first argument.</param>
        /// <param name="arg2">The second argument.</param>
        /// <param name="arg3">The third argument.</param>
        public static void QueueWork <T1, T2, T3>(Action <T1, T2, T3> action, T1 arg1, T2 arg2, T3 arg3)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var task = new DelegateTask <T1, T2, T3>(action, arg1, arg2, arg3);

            QueueWork(task);
        }
Ejemplo n.º 22
0
 public CdiBusinessProcessEvent(string activityId, string transitionName, ProcessDefinition processDefinition, DelegateExecution execution, BusinessProcessEventType type, DateTime timeStamp)
 {
     this.activityId        = activityId;
     this.transitionName    = transitionName;
     this.processInstanceId = execution.ProcessInstanceId;
     this.executionId       = execution.Id;
     this.type              = type;
     this.timeStamp         = timeStamp;
     this.processDefinition = processDefinition;
     this.delegateTask      = null;
 }
Ejemplo n.º 23
0
        /// <summary>
        /// Queues work that will be run in the engine main thread.
        /// </summary>
        /// <param name="action">The action to run.</param>
        /// <param name="arg">The argument.</param>
        public static void QueueWork <T>(Action <T> action, T arg)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var task = new DelegateTask <T>(action, arg);

            QueueWork(task);
        }
Ejemplo n.º 24
0
 public CdiBusinessProcessEvent(DelegateTask task, ProcessDefinitionEntity processDefinition, BusinessProcessEventType type, DateTime timeStamp)
 {
     this.activityId        = null;
     this.transitionName    = null;
     this.processInstanceId = task.ProcessInstanceId;
     this.executionId       = task.ExecutionId;
     this.type              = type;
     this.timeStamp         = timeStamp;
     this.processDefinition = processDefinition;
     this.delegateTask      = task;
 }
Ejemplo n.º 25
0
        /// <summary>
        /// Queues work that will be run in the engine main thread.
        /// </summary>
        /// <param name="action">The action to run.</param>
        public static void QueueWork(Action action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }

            var task = new DelegateTask(action);

            QueueWork(task);
        }
Ejemplo n.º 26
0
            private void JumpTasks()
            {
                float        elapsedTime = 0f;
                const float  duration    = 9f / 60f;
                DelegateTask moveAndWait = new DelegateTask(() => { }, () =>
                {
                    elapsedTime += Time.fixedDeltaTime;
                    Cont._charController.Move(Cont._currentMovementVector * _jumpingMovementMultiplier);
                    return(elapsedTime > duration);
                });

                DelegateTask jump = new DelegateTask(
                    () =>
                {
                    Vector3 jumpVector            = Cont.transform.forward * Cont._jumpForwardDistance;// + Vector3.up * Cont._upwardJumpSpeed;
                    Cont._currentMovementVector  += jumpVector * Time.deltaTime;
                    Cont._currentMovementVector.y = Cont._jumpSpeed;
                },
                    () =>
                {
                    // Fall downwards
                    Cont._currentMovementVector.y += Cont._gravity * Time.deltaTime;
                    Cont._charController.Move(Cont._currentMovementVector);
                    if (Cont.OnGround() || Cont._currentMovementVector.y <= 0f)
                    {
                        return(true);
                    }
                    return(false);
                },
                    () =>
                {
                    System.Type type = Cont._fsm.CurrentState.GetType();
                    if (type == typeof(InDialogueState) || type == typeof(CutsceneState) || type == typeof(ForcedIdleState))
                    {
                        Logger.Warning($"Jump task finished outside of NPC area. Currently in {type.FullName}.");
                    }
                    else if (Cont._currentMovementVector.y < 0f)
                    {
                        TransitionTo <FallingState>();
                    }
                    else if (Cont.GroundMovementInputsEntered)
                    {
                        TransitionTo <MovingOnGroundState>();
                    }
                    else
                    {
                        TransitionTo <IdleState>();
                    }
                });

                moveAndWait.Then(jump);

                Cont._taskManager.Do(moveAndWait);
            }
Ejemplo n.º 27
0
        public uint QueueTimeout(TimeSpan span, TimeoutTask task)
        {
            DelegateTask dTask = cache.Dequeue();

            dTask.Timeout = task;

            return(dispatcher.Add(span, delegate {
                QueueWait(dTask);
                return dTask.TimeoutResult;
            }));
        }
Ejemplo n.º 28
0
        void Loop()
        {
            while (true)
            {
                DelegateTask task = null;

                lock (tasks)
                {
                    if (tasks.Count > 0)
                    {
                        task = tasks.Dequeue();
                    }
                }

                if (task == null)
                {
                    if (disposed)
                    {
                        break;
                    }

                    #if DISABLED
                    // WARNING: if we are being disposed at _this_ point, there
                    // are no new tasks added and we are waiting forever, then
                    // we would leak this thread! The dispose check + break will
                    // never happen, so we have to use a sane timeout here.
                    // Checking every 60 seconds if we are disposed should be
                    // reasonable.
                    handle.WaitOne(60 * 1000);
                    #endif
                    // OPT: let Dispose() trigger the handle, but is this safe?
                    handle.WaitOne();
                }
                else
                {
                    task.Execute();

                    if (task.Exception != null)
                    {
                        if (ExceptionEvent != null)
                        {
                            ExceptionEvent(this, new TaskQueueExceptionEventArgs(task.Exception));
                        }
                        break;
                    }
                }
            }

            if (AbortedEvent != null)
            {
                AbortedEvent(this, EventArgs.Empty);
            }
        }
Ejemplo n.º 29
0
        public uint QueueTimeout(TimeSpan span, Func <bool> task)
        {
            DelegateTask dTask = new DelegateTask();

            dTask.Timeout = task;

            return(_dispatcher.Add(span, (state, timeout) =>
            {
                QueueWait(dTask);
                return dTask.TimeoutResult;
            }));
        }
Ejemplo n.º 30
0
        public virtual void notify(DelegateTask task)
        {
            // test whether cdi is setup correctly. (if not, just do not deliver the event)
            if (!testCdiSetup())
            {
                return;
            }

            BusinessProcessEvent @event = createEvent(task);

            Annotation[] qualifiers = getQualifiers(@event);
            BeanManager.fireEvent(@event, qualifiers);
        }
Ejemplo n.º 31
0
        private void Queue(DelegateTask task)//, Priority priority = Priority.Normal)
        {
            if (task == null)
            {
                return;
            }

            lock (_tasks)
            {
                _tasks.Enqueue(task);
                _handle.Set();
            }
        }
Ejemplo n.º 32
0
 private void Queue(DelegateTask task)
 {
     lock (_tasks)
     {
         _tasks.Enqueue(task);
         _handle.Set();
     }
 }
Ejemplo n.º 33
0
        private void QueueWait(DelegateTask t)
        {
            t.WaitHandle.Reset();
            t.IsBlocking = true;

            Queue(t);

            t.WaitHandle.WaitOne();

            if (t.StoredException != null)
                throw new TorrentException("Exception in mainloop", t.StoredException);
        }
Ejemplo n.º 34
0
        private void QueueWait(DelegateTask t)
        {
            t.WaitHandle.Reset();
            t.IsBlocking = true;
            if (Thread.CurrentThread == thread)
                t.Execute();
            else
                Queue(t, Priority.Highest);

            t.WaitHandle.WaitOne();

            if (t.StoredException != null)
                throw new TorrentException("Exception in mainloop", t.StoredException);
        }
Ejemplo n.º 35
0
 private void Queue(DelegateTask task)
 {
     Queue(task, Priority.Normal);
 }
Ejemplo n.º 36
0
 private void Queue(DelegateTask task, Priority priority)
 {
     tasks.Add(task);
 }
Ejemplo n.º 37
0
        private object QueueWait(DelegateTask t)
        {
            if (t.Handle != null)
                t.Handle.Reset();
            else
                t.Handle = new ManualResetEvent(false);

            if (Thread.CurrentThread == thread)
                t.Execute();
            else
                Queue(t);

            t.Handle.WaitOne();
            t.Handle.Close();

            return t.Result;
        }