Exemplo n.º 1
0
        /// <summary>
        /// Transitions the <see cref="TesTask"/> to the new state, based on the rules defined in the tesTaskStateTransitions list.
        /// </summary>
        /// <param name="tesTask">TES task</param>
        /// <param name="batchTaskState">Current Azure Batch task state</param>
        /// <returns>True if the TES task was changed.</returns>
        private async Task <bool> HandleTesTaskTransitionAsync(TesTask tesTask, BatchTaskState batchTaskState)
        {
            var tesTaskChanged = false;

            var mapItem = tesTaskStateTransitions
                          .FirstOrDefault(m => (m.Condition == null || m.Condition(tesTask)) && (m.CurrentBatchTaskState == null || m.CurrentBatchTaskState == batchTaskState));

            if (mapItem != null)
            {
                if (mapItem.Action != null)
                {
                    await mapItem.Action(tesTask);

                    tesTaskChanged = true;
                }

                if (mapItem.NewTesTaskState != null && mapItem.NewTesTaskState != tesTask.State)
                {
                    tesTask.State  = mapItem.NewTesTaskState.Value;
                    tesTaskChanged = true;
                }
            }

            return(tesTaskChanged);
        }
Exemplo n.º 2
0
        public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                BatchTaskState state       = (BatchTaskState)value;
                BitmapImage    imageSource = null;
                switch (state)
                {
                case BatchTaskState.Running:
                    //return "Running...";
                    imageSource = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/circle_double.png", UriKind.RelativeOrAbsolute));
                    break;

                case BatchTaskState.Finished:
                    //return "Finished";
                    //imageSource = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/right.png", UriKind.RelativeOrAbsolute));
                    return("Done");

                case BatchTaskState.Pending:
                default:
                    //return "Remove";
                    imageSource = new BitmapImage(new Uri("/GisEditorInfrastructure;component/Images/delete.png", UriKind.RelativeOrAbsolute));
                    break;
                }

                return(new Image {
                    Source = imageSource, Stretch = Stretch.None
                });
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                return(Binding.DoNothing);
            }
        }
Exemplo n.º 3
0
        public override object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            try
            {
                BatchTaskState state = (BatchTaskState)value;
                switch (state)
                {
                case BatchTaskState.Running:
                case BatchTaskState.Finished:
                    return(false);

                case BatchTaskState.Pending:
                default:
                    return(true);
                }
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                return(true);
            }
        }
Exemplo n.º 4
0
 public TesTaskStateTransition(TesState currentTesTaskState, BatchTaskState batchTaskState, Func <TesTask, Task> transition, TesState?newTesTaskState = null)
     : this(tesTask => tesTask.State == currentTesTaskState, batchTaskState, transition, newTesTaskState)
 {
 }
Exemplo n.º 5
0
 public TesTaskStateTransition(Func <TesTask, bool> condition, BatchTaskState batchTaskState, TesState newTesTaskState)
     : this(condition, batchTaskState, null, newTesTaskState)
 {
 }
Exemplo n.º 6
0
 public TesTaskStateTransition(TesState currentTesTaskState, BatchTaskState batchTaskState, TesState newTesTaskState)
     : this(tesTask => tesTask.State == currentTesTaskState, batchTaskState, null, newTesTaskState)
 {
 }