Ejemplo n.º 1
0
        private async Task GetValueAsync(CancellationToken token, ITaskListener listener, string propertyName)
        {
            listener.NotifyTaskStarting();
            T    value = default(T);
            bool?isSuccess;

            try
            {
                value = await _getValueAsync(token);

                isSuccess = true;
            }
            catch (OperationCanceledException)
            {
                isSuccess = null;
            }
            catch
            {
                isSuccess = false;
            }
            finally
            {
                _isCalculating = false;
            }
            if (isSuccess == true)
            {
                DoSetValue(value, propertyName);
            }
            listener.NotifyTaskCompleted(isSuccess);
        }
    // Start is called before the first frame update

    void Start()
    {
        masterCanvas.SetActive(true);        //In case of AR canvas needs to be set to active
        scatterPlotManager.SetActive(true);
        taskFactory  = TaskFactory.Instance; //singleton
        taskListener = new TaskListener(taskFactory, masterCanvas, scatterPlotManager, selector, controlerType);
        taskFactory.getTask(COUNTER).init(taskListener, masterCanvas, scatterPlotManager);
    }
Ejemplo n.º 3
0
 private void CalculateValue(CancellationToken token, ITaskListener listener, string propertyName)
 {
     if (!_isCalculating)
     {
         _isCalculating = true;
         StartGetValue(token, listener, propertyName);
     }
 }
Ejemplo n.º 4
0
        private void StartGetValue(CancellationToken token, ITaskListener listener, string propertyName)
        {
            var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

            listener = listener ?? AggregateTaskListener.Empty;
            Task.Factory.StartNew(() => GetValueAsync(token, listener, propertyName),
                                  CancellationToken.None, TaskCreationOptions.None, scheduler);
        }
 public override void init(ITaskListener taskListener, GameObject masterCanvas, GameObject scatterPlotManager)
 {
     setType(TaskType.TYPE_2);
     base.init(taskListener, masterCanvas, scatterPlotManager);
     setState(TaskState.INIT);
     question = questionFactory.getQuestion(2);
     execute();
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets the value of an asynchronous property.
 /// </summary>
 /// <typeparam name="T">The type of the property value.</typeparam>
 /// <param name="getValueAsync">The delegate used to calculate the property value.</param>
 /// <param name="listener">The optional task listener.</param>
 /// <param name="propertyName">The name of the property.</param>
 public T Get <T>(Func <Task <T> > getValueAsync, ITaskListener listener = null,
                  [CallerMemberName] string propertyName = null)
 {
     if (getValueAsync == null)
     {
         throw new ArgumentNullException("getValueAsync");
     }
     return(Get(_ => getValueAsync(), CancellationToken.None, listener, propertyName));
 }
Ejemplo n.º 7
0
        protected internal virtual void InitExecutionListeners(IHistoryEventProducer historyEventProducer,
                                                               IHistoryLevel historyLevel)
        {
            ProcessInstanceStartListener = new ProcessInstanceStartListener(historyEventProducer, historyLevel);
            ProcessInstanceEndListener   = new ProcessInstanceEndListener(historyEventProducer, historyLevel);

            ActivityInstanceStartListener = new ActivityInstanceStartListener(historyEventProducer, historyLevel);
            ActivityInstanceEndListener   = new ActivityInstanceEndListener(historyEventProducer, historyLevel);

            UserTaskAssignmentHandler = new ActivityInstanceUpdateListener(historyEventProducer, historyLevel);
            UserTaskIdHandler         = UserTaskAssignmentHandler;
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Gets the property value.
 /// </summary>
 /// <param name="token">The optional cancellation token.</param>
 /// <param name="listener">The optional task listener.</param>
 /// <param name="propertyName">The name of the property.</param>
 public T GetValue(CancellationToken token, ITaskListener listener, string propertyName)
 {
     if (propertyName == null)
     {
         throw new ArgumentNullException("propertyName");
     }
     if (!IsValueValid)
     {
         CalculateValue(token, listener, propertyName);
     }
     return(DoGetValue());
 }
Ejemplo n.º 9
0
 // Task listener
 public virtual void Notify(IDelegateTask delegateTask)
 {
     if (taskListenerInstance == null)
     {
         taskListenerInstance = TaskListenerInstance;
     }
     try
     {
         Context.ProcessEngineConfiguration.DelegateInterceptor.HandleInvocation(new TaskListenerInvocation(taskListenerInstance, delegateTask));
     }
     catch (Exception e)
     {
         throw new ActivitiException("Exception while invoking TaskListener: " + e.Message, e);
     }
 }
Ejemplo n.º 10
0
    public string baseQuestionPopup = "Popup - InputQuestion"; //Default

    public virtual void init(ITaskListener taskListener, GameObject masterCanvas, GameObject scatterPlotManager)
    {
        this.taskListener       = taskListener;
        this.masterCanvas       = masterCanvas;
        this.scatterplotManager = scatterPlotManager;

        baseOverlay       = (taskType == TaskType.TYPE_1) ? "Overlay - Input" : "Overlay - Option";
        baseQuestionPopup = (taskType == TaskType.TYPE_1) ? "Popup - InputQuestion" : "Popup - OptionQuestion";


        masterCanvas.transform.Find("Overlay - Input").gameObject.SetActive(!(taskType == TaskType.TYPE_1));
        masterCanvas.transform.Find("Overlay - Option").gameObject.SetActive(!(taskType == TaskType.TYPE_2));

        masterCanvas.transform.Find("Overlay - Input").gameObject.SetActive(taskType == TaskType.TYPE_1);
        masterCanvas.transform.Find("Overlay - Option").gameObject.SetActive(taskType == TaskType.TYPE_2);

        try
        {
            questionObject    = masterCanvas.transform.Find(baseOverlay + "/" + baseQuestionPopup + "/Container/Question").gameObject;
            submitButton      = masterCanvas.transform.Find(baseOverlay + "/" + baseQuestionPopup + "/Container/Button - Submit").GetComponent <Button>();
            hideOverlayButton = masterCanvas.transform.Find(baseOverlay + "/" + baseQuestionPopup + "/Container/Button - HideOverlay").GetComponent <Button>();
        }
        catch (NullReferenceException ex)
        {
            questionObject    = masterCanvas.transform.Find(baseQuestionPopup + "/Container/Question").gameObject;
            submitButton      = masterCanvas.transform.Find(baseQuestionPopup + "/Container/Button - Submit").GetComponent <Button>();
            hideOverlayButton = masterCanvas.transform.Find(baseQuestionPopup + "/Container/Button - HideOverlay").GetComponent <Button>();

            //questionObject.transform.SetParent(masterCanvas.transform.Find(baseQuestionPopup).transform);

            masterCanvas.transform.Find("Popup - InputQuestion").gameObject.SetActive(!(taskType == TaskType.TYPE_1));
            masterCanvas.transform.Find("Popup - OptionQuestion").gameObject.SetActive(!(taskType == TaskType.TYPE_2));

            masterCanvas.transform.Find("Popup - InputQuestion").gameObject.SetActive(taskType == TaskType.TYPE_1);
            masterCanvas.transform.Find("Popup - OptionQuestion").gameObject.SetActive(taskType == TaskType.TYPE_2);
        }

        submitButton.onClick.AddListener(result);

        showOverlayButton = masterCanvas.transform.Find(baseOverlay + "/Button - ShowOverlay").GetComponent <Button>();
        showOverlayButton.onClick.Invoke();
    }
Ejemplo n.º 11
0
        /**
         * Adds a task listener to this task. When there is a relevant change in the
         * status of this task, the listener will be notified by calling its
         * {@link ITaskListener#statusChanged(TaskEvent)} method.
         *
         * @param listener
         *            the listener to add.
         */

        public void AddTaskListener(ITaskListener listener)
        {
            _listeners.Add(listener);
        }
Ejemplo n.º 12
0
 public void Unsubscribe(ITaskListener taskListener)
 {
     _listeners.Remove(taskListener);
 }
Ejemplo n.º 13
0
 T IAsyncProperty <T> .GetValue(CancellationToken token, ITaskListener listener, string propertyName)
 {
     SetPropertyName(propertyName);
     DependencyTracker.Instance.Register(this);
     return(_property.GetValue(token, listener, propertyName));
 }
Ejemplo n.º 14
0
        /**
         * Removes a listener from this task.
         *
         * @param listener
         *            the task listener to remove.
         */

        public void RemoveTaskListener(ITaskListener listener)
        {
            _listeners.Remove(listener);
        }
Ejemplo n.º 15
0
 public TaskListenerInvocation(ITaskListener taskListenerInstance, IDelegateTask delegateTask,
                               IBaseDelegateExecution contextExecution) : base(contextExecution, null)
 {
     this.TaskListenerInstance = taskListenerInstance;
     this.DelegateTask         = delegateTask;
 }
Ejemplo n.º 16
0
 public virtual void AddBuiltInTaskListener(string eventName, ITaskListener taskListener)
 {
     CollectionUtil.AddToMapOfLists(TaskListeners, eventName, taskListener);
     CollectionUtil.AddToMapOfLists(builtinTaskListeners, eventName, taskListener);
 }
Ejemplo n.º 17
0
 public TaskListenerInvocation(ITaskListener executionListenerInstance, IDelegateTask delegateTask)
     : this(executionListenerInstance, delegateTask, null)
 {
 }
Ejemplo n.º 18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="executionListenerInstance"></param>
 /// <param name="delegateTask"></param>
 public TaskListenerInvocation(ITaskListener executionListenerInstance, IDelegateTask delegateTask)
 {
     this.executionListenerInstance = executionListenerInstance;
     this.delegateTask = delegateTask;
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Gets the value of an asynchronous property.
 /// </summary>
 /// <typeparam name="T">The type of the property value.</typeparam>
 /// <param name="getValueAsync">The delegate used to calculate the property value.</param>
 /// <param name="token">The optional cancellation token.</param>
 /// <param name="listener">The optional task listener.</param>
 /// <param name="propertyName">The name of the property.</param>
 public T Get <T>(Func <CancellationToken, Task <T> > getValueAsync, CancellationToken token = default(CancellationToken),
                  ITaskListener listener = null, [CallerMemberName] string propertyName = null)
 {
     return(GetOrAddAsyncProperty(getValueAsync, propertyName).GetValue(token, listener, propertyName));
 }
Ejemplo n.º 20
0
 /**
  * Removes a listener from this task.
  *
  * @param listener
  *            the task listener to remove.
  */
 public void RemoveTaskListener(ITaskListener listener)
 {
     _listeners.Remove(listener);
 }
Ejemplo n.º 21
0
 public void Subscribe(ITaskListener taskListener)
 {
     _listeners.Add(taskListener);
 }
Ejemplo n.º 22
0
 /**
  * Adds a task listener to this task. When there is a relevant change in the
  * status of this task, the listener will be notified by calling its
  * {@link ITaskListener#statusChanged(TaskEvent)} method.
  *
  * @param listener
  *            the listener to add.
  */
 public void AddTaskListener(ITaskListener listener)
 {
     _listeners.Add(listener);
 }
Ejemplo n.º 23
0
 public ICompleted SetListener(ITaskListener listener)
 {
     this.listener = listener;
     return(this);
 }
Ejemplo n.º 24
0
 static IEnumerable<ICommandOutput> Wrap(IEnumerable<ICommandOutput> execute, ITaskListener eventListener)
 {
     foreach (var value in execute)
         yield return value;
     eventListener.Stop();
 }
Ejemplo n.º 25
0
 public Application(IRegistrar registrar, ITaskListener listener, ILog logger)
 {
     _registrar = registrar;
     _listener  = listener;
     _logger    = logger;
 }