Ejemplo n.º 1
0
        public void SubmitForExecution(Plan plan)
        {
            if (!this.currentExecutionStatus.IsFinal() && this.currentExecutionStatus != ExecutionStatus.None)
            {
                throw new InvalidOperationException(
                          string.Format(
                              "SubmitForExecution() was called before current plan was fully completed, failed or interrupted (plan status: {0})",
                              currentExecutionStatus
                              )
                          );
            }

            this.plan = plan;

            if (plan.Length > 0)
            {
                this.currentExecutionStatus = ExecutionStatus.InProgress;
                this.currentActionIndex     = 0;

                this.currentAction = actionFactory.FromPlanningAction(plan.Actions.First().Name);
            }
            else
            {
                this.currentExecutionStatus = ExecutionStatus.Complete;
                this.currentActionIndex     = -1;

                this.currentAction = null;
            }
        }
        public ExecutionStatus <T> Get <T>(AggregateKey id, int?expectedVersion = null) where T : AggregateRoot
        {
            try
            {
                //w pamięci sprawdzamy czy nie próbujemy ze złą wersją dodać zdarzenie
                if (IsTracked(id))
                {
                    var trackedAggregate = (T)_trackedAggregates[id].Aggregate;
                    if (expectedVersion != null && trackedAggregate.Version != expectedVersion)
                    {
                        throw new ConcurrencyException(trackedAggregate.Key);
                    }
                    return(ExecutionStatus <T> .EventStoreOk(trackedAggregate));
                }

                //jeśli nie mamy w pamieci to odpytujemy repozytorium
                var aggregate = _repository.Get <T>(id);
                if (expectedVersion != null && aggregate.Version != expectedVersion)
                {
                    throw new ConcurrencyException(id);
                }
                Add(aggregate); //dodaj do tej warstwy pamięci

                return(ExecutionStatus <T> .EventStoreOk(aggregate));
            }
            catch (Exception ex)
            {
                if (ExecutionFlow.Options.ThrowExceptions)
                {
                    throw;
                }

                return(ExecutionStatus <T> .EventStoreError(ex));
            }
        }
        private void all_scenarios_with_status_other_than_STATUS_are_VISIBLE(ExecutionStatus status, [VisibleFormat] bool visible)
        {
            var elements = _driver.FindAllScenarios().Where(s => !s.HasClassName(status.ToString().ToLower())).ToArray();

            Assert.That(elements, Is.Not.Empty);
            Assert.That(elements.All(s => s.Displayed == visible));
        }
Ejemplo n.º 4
0
 public static bool IsPostProcessingStatus(this ExecutionStatus execStatus) =>
 (execStatus == ExecutionStatus.Canceled) ||
 (execStatus == ExecutionStatus.Failed) ||
 (execStatus == ExecutionStatus.Succeeded) ||
 (execStatus == ExecutionStatus.ValidationFailed) ||
 (execStatus == ExecutionStatus.ValidationSucceeded) ||
 (execStatus == ExecutionStatus.TimedOut);
Ejemplo n.º 5
0
        public ScenarioBuilder NewEmptyScenario(string scenario, ExecutionStatus status)
        {
            var builder = new ScenarioBuilder(status).WithName(scenario);

            _scenarios.Add(builder);
            return(builder);
        }
Ejemplo n.º 6
0
        public async Task <ExecutionStatus> UnregisterService()
        {
            ExecutionStatus status;

            if (_consulServiceInstance == null)
            {
                status         = ExecutionStatus.Bad();
                status.Message = $"No service is registered";
                return(status);
            }
            _canRun = false;

            try
            {
                var result = await _client.Agent.ServiceDeregister(_consulServiceInstance?.Id);

                if (result.StatusCode == HttpStatusCode.OK)
                {
                    status         = ExecutionStatus.Good();
                    status.Message = $"Service with id {_consulServiceInstance.Id} was successfully unregistred.";
                }
                else
                {
                    status         = ExecutionStatus.Bad();
                    status.Message = $"There were some problems unregistering service with id {_consulServiceInstance.Id}.";
                }
            }
            catch
            {
                status         = ExecutionStatus.Bad();
                status.Message = $"There were some problems unregistering service.";
            }

            return(status);
        }
Ejemplo n.º 7
0
        public async Task <ExecutionStatus <Category> > Run(CategoryId categoryId)
        {
            using var connection = new SqliteConnection
                                       (_geekLemonContext.ConnectionString);

            var q = @"SELECT Id, DisplayName, Name,
                WhatWeAreLookingFor,UniqueId ,Version  FROM Categories
                Where Id = @Id";

            try
            {
                var r = await connection.
                        QueryFirstOrDefaultAsync <CategoryTemp>
                            (q, new
                {
                    @Id = categoryId.Value,
                });

                var rmaped = _mapper.Map <Category>(r);

                return(ExecutionStatus <Category> .DbIfDefaultThenError(rmaped));
            }
            catch (Exception ex)
            {
                return(ExecutionStatus <Category> .DbError(ex));
            }
        }
Ejemplo n.º 8
0
        public async Task <ExecutionStatus> RefreshTokenAsync()
        {
            ExecutionStatus result = ExecutionStatus.Failed;

            _membershipService.ResetTokens();

            await Executor.ExecuteWithRetryAsync(async executionContext =>
            {
                var request = new HttpRequest()
                              .SetMethod(HttpMethods.Post)
                              .SetUri(_apiEndpoints.RefreshToken())
                              .WithData(await GetRefreshTokenRequestDataAsync().ConfigureAwait(false));

                request.ContentType = ContentType;

                var response = await _httpClient.ExecuteApiCallAsync(HttpRequestPriority.High, request).ConfigureAwait(false);

                if (response.IsSuccessful && response.Content != null)
                {
                    var tokens = JsonConverter.Deserialize <LoginResultDto>(response.Content);

                    await _membershipService.SaveTokensAsync(tokens.AccessToken, tokens.RefreshToken).ConfigureAwait(false);
                    result = ExecutionStatus.Completed;
                }
            }, 3);

            return(result);
        }
        public async Task <GetJudgesInListQueryResponse> Handle
            (GetJudgesInListQuery request, CancellationToken cancellationToken)
        {
            ExecutionStatus <IReadOnlyList <Judge> > databaseoperation =
                null;

            if (request.queryWitchDataBase == QueryWitchDataBase.WithEventSourcing)
            {
                databaseoperation = await _zEsjudgeRepository.GetAllAsync();
            }
            else
            {
                databaseoperation = await _judgeRepository.GetAllAsync();
            }

            if (!databaseoperation.Success)
            {
                return(new GetJudgesInListQueryResponse
                           (databaseoperation.RemoveGeneric()));
            }

            var ordered = databaseoperation.Value.OrderBy(a => a.Name.Last);
            var maped   = _mapper.Map <List <JudgesInListViewModel> >(ordered);

            return(new GetJudgesInListQueryResponse(maped));
        }
        public async Task <ExecutionStatus> Run(CategoryUniqueId categoryId)
        {
            using var connection = new SqliteConnection(_geekLemonContext.ConnectionString);

            var q = @"DELETE FROM Categories WHERE UniqueId=@UniqueId;";

            try
            {
                var result = await connection.QueryAsync <int>(q,
                                                               new
                {
                    @UniqueId = categoryId.Value.ToString()
                });
            }
            catch (Exception ex)
            {
                if (ExecutionFlow.Options.ThrowExceptions)
                {
                    throw;
                }

                return(ExecutionStatus.DbError(ex));
            }

            return(ExecutionStatus.DbOk());
        }
        public ExecutionStatus TryPreliminaryAccept(Judge decisionBy)
        {
            if (Status == CallForSpeechStatus.PreliminaryAcceptedByJudge)
            {
                return(ExecutionStatus.
                       LogicError("You already PreliminaryAcceptedByJudge this CallForSpeech"));
            }

            if (Status != CallForSpeechStatus.EvaluatedByMachine)
            {
                return(ExecutionStatus.LogicError("Cannot accept application that WASNT'T in EvaluatedByMachine"));
            }

            if (ScoreResult == null)
            {
                return(ExecutionStatus.LogicError("Cannot accept application before scoring"));
            }

            if (!decisionBy.CanAccept(this.Category.Id))
            {
                return(ExecutionStatus.
                       LogicError("Judge is from diffrent category. Can't Accept"));
            }

            Status = CallForSpeechStatus.PreliminaryAcceptedByJudge;
            PreliminaryDecision = new Decision(AppTime.Now(), decisionBy);
            return(ExecutionStatus.LogicOk());
        }
Ejemplo n.º 12
0
 public static void OpenActualExecutionPlan(this ExecutionStatus executionStatus, bool?forceEvenWithNoDebugger = false)
 {
     if (Debugger.IsAttached && !forceEvenWithNoDebugger.Value)
     {
         Tools.OpenFile(executionStatus.GetActualExecutionPlanHtml(), "html");
     }
 }
Ejemplo n.º 13
0
 void execution_CompleteFill(EZFill fill)
 {
     if (Metrics != null)
     {
         ExecutionStatus status = execution.GetExecutionStatus(this.Name);
         Spy.Print("METRICS (complete fill): {0} {1}", status.AverageBuyPrice, status.AverageSellPrice);
         // If the Fill side matches the Trade side then it is an ENTRY (otherwise it is an EXIT).
         if (fill.BuySell == this.BuySell)
         {
             tradeCycle.SetEntryPriceAverage(status.AverageBuyPrice);
             if (currentTradeState == TradeState.ENTERING)
             {
                 ChangeState(TradeState.ENTERED);
             }
         }
         else
         {
             tradeCycle.SetExitPriceAverage(status.AverageSellPrice);
             if (currentTradeState == TradeState.EXITING)
             {
                 ChangeState(TradeState.EXITED);
             }
             else if (currentTradeState == TradeState.STOPPING)
             {
                 ChangeState(TradeState.STOPPED);
             }
         }
     }
 }
Ejemplo n.º 14
0
        public void Update()
        {
            if (this.currentExecutionStatus != ExecutionStatus.None && !this.currentExecutionStatus.IsFinal())
            {
                DebugUtils.Assert(this.currentAction != null, "currentAction must not be null at this point");

                if (this.currentAction.Status == ExecutionStatus.None)
                {
                    this.currentAction.StartExecution();
                }

                this.currentAction.Update();

                if (this.currentAction.Status == ExecutionStatus.Interrupted || this.currentAction.Status == ExecutionStatus.Failed)
                {
                    this.currentExecutionStatus = this.currentAction.Status;
                }
                else if (this.currentAction.Status == ExecutionStatus.Complete)
                {
                    this.currentActionIndex++;

                    if (this.currentActionIndex >= this.plan.Length)
                    {
                        this.currentAction          = null;
                        this.currentExecutionStatus = ExecutionStatus.Complete;
                    }
                    else
                    {
                        this.currentAction = actionFactory.FromPlanningAction(plan.Actions.ElementAt(currentActionIndex).Name);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private void StartWrite()
        {
            // var threadName = Thread.CurrentThread.Name ?? "Main";
            //Console.WriteLine($"{threadName} start");
            using (var destinationStream = new FileStream(DestinationFileName, FileMode.Create, FileAccess.Write))
            {
                try
                {
                    while (true)
                    {
                        var task = QueueToWrite.Dequeue();
                        if (task == null)
                        {
                            break;
                        }
                        if (task.RethrowException != null)
                        {
                            throw new Exception(task.RethrowException);
                        }
                        //Console.WriteLine($"{threadName} writing {task.UncompressedOffset}");

                        destinationStream.Seek(task.UncompressedOffset, SeekOrigin.Begin);
                        destinationStream.Write(task.Buffer, 0, task.Buffer.Length);
                        ExecutionStatus.IncrementStatus();
                    }
                }
                catch (Exception ex)
                {
                    destinationStream.Flush(false);
                    throw new Exception(ex.Message);
                }
            }
            //Console.WriteLine($"{threadName} end");
        }
Ejemplo n.º 16
0
        Run(CallForSpeech callForSpeech)
        {
            var temp = _mapper.Map <CallForSpeechTemp>(callForSpeech);

            using var connection = new SqliteConnection(_geekLemonContext.ConnectionString);

            var q = SqlQueries.CallForSpeechInsert;

            try
            {
                var result = await connection.QueryAsync <int>(q, temp);

                int createdId = result.FirstOrDefault();

                CallForSpeechIds ids = new CallForSpeechIds()
                {
                    CreatedId = new CallForSpeechId(createdId),
                    UniqueId  = callForSpeech.UniqueId
                };

                return(ExecutionStatus <CallForSpeechIds> .DbOk(ids));
            }
            catch (Exception ex)
            {
                if (ExecutionFlow.Options.ThrowExceptions)
                {
                    throw;
                }

                return(ExecutionStatus <CallForSpeechIds> .DbError(ex));
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        ///   Activation. This method is called when the task was chosen to be executed. It's called right before the first update of the task. The task can setup its specific task data in here and do initial actions.
        /// </summary>
        /// <param name="agentData"> Agent data. </param>
        /// <param name="decisionData"> Decision data to use in activate method. </param>
        /// <returns> Execution status after activation. </returns>
        public override ExecutionStatus Activate(IAgentData agentData, IDecisionData decisionData)
        {
            DecisionData taskDecisionData = (DecisionData)decisionData;

            // Create child blackboard.
            Data data = new Data {
                Blackboard = taskDecisionData.Blackboard, PreviousBlackboard = agentData.Blackboard
            };

            agentData.CurrentTaskData = data;

            // Setup blackboard.
            Setup(agentData, data);

            // Activate child.
            ExecutionStatus result = this.ActivateChild(agentData, taskDecisionData.ChildDecisionData);

            if (result != ExecutionStatus.Running)
            {
                // Tear down.
                TearDown(agentData, data);
            }

            return(result);
        }
    // Handle puzzle-specific function calls if ProgramController.ExecuteNode set the handover flag
    public override ExecutionStatus ExecuteNode(NodeBase node)
    {
        ExecutionStatus baseStatus = base.ExecuteNode(node);

        if (!baseStatus.handover)
        {
            return(baseStatus);
        }

        if (CheckNodeType(node) == NodeType.FunctionCallBase)
        {
            FunctionCallBase funcCall = node.GetComponent <FunctionCallBase>();

            if (functions.ContainsKey(funcCall.functionName))
            {
                functions[funcCall.functionName].DynamicInvoke();
                return(new ExecutionStatus {
                    success = true, handover = false
                });
            }
        }

        return(new ExecutionStatus {
            success = true, handover = true
        });
    }
Ejemplo n.º 19
0
        public async Task <ExecutionStatus> Run(CallForSpeechId id, JudgeId judge, CallForSpeechStatus status)
        {
            using var connection = new SqliteConnection(_geekLemonContext.ConnectionString);

            var q = @"UPDATE CallForSpeakes
                SET FinalDecision_DecisionBy = @JudgeId,
                FinalDecision_Date = @Date,
                Status = @Status
                WHERE Id = @Id;";

            try
            {
                var result = await connection.ExecuteAsync(q,
                                                           new
                {
                    @JudgeId = judge.Value,
                    @Date    = AppTime.Now().ToLongDateString(),
                    @Id      = id.Value,
                    @Status  = (int)status
                });

                return(ExecutionStatus.DbOk());
            }
            catch (Exception ex)
            {
                if (ExecutionFlow.Options.ThrowExceptions)
                {
                    throw;
                }

                return(ExecutionStatus.DbError(ex));
            }
        }
Ejemplo n.º 20
0
        public override ExecutionStatus Execute(double time)
        {
            if (_nodes.Count == 0)
            {
                CurrentStatus = ExecutionStatus.Failure; return(CurrentStatus);
            }
            else
            {
                CurrentStatus = ExecutionStatus.Running;
                for (int i = 0; i < _nodes.Count; i++)
                {
                    if (_nodes[i] == null)
                    {
                        CurrentStatus = ExecutionStatus.Error;
                        return(CurrentStatus);
                    }

                    ExecutionStatus nStatus = _nodes[i].Execute(time);
                    if (nStatus != ExecutionStatus.Success)
                    {
                        CurrentStatus = nStatus;
                        return(CurrentStatus);
                    }
                    if (nStatus == ExecutionStatus.Error)
                    {
                        ErrorEventTrigger("Sequence internal error by node " + _nodes[i].Name);
                    }
                }
            }
            return(CurrentStatus);
        }
Ejemplo n.º 21
0
        public async Task <EsUpdateJudgeCommandResponse> Handle(EsUpdateJudgeCommand request, CancellationToken cancellationToken)
        {
            var validator       = new EsUpdateJudgeCommandValidator();
            var validatorResult = await validator.ValidateAsync(request);

            if (!validatorResult.IsValid)
            {
                return(new EsUpdateJudgeCommandResponse(validatorResult));
            }

            var judgedto = _mapper.Map <JudgeDto>(request);
            var judge    = _mapper.Map <Judge>(judgedto);

            var eventstoreResult = Get <JudgeAggregate>(judge.UniqueId.GetAggregateKey());

            if (!eventstoreResult.Success)
            {
                return(await Task.FromResult(new
                                             EsUpdateJudgeCommandResponse(eventstoreResult.RemoveGeneric())));
            }

            if ((eventstoreResult.Value.Version - 1) > judge.Version)
            {
                return(new EsUpdateJudgeCommandResponse
                           (ExecutionStatus.EventStoreConcurrencyError
                               (@$ "You sended old version. Your version {judge.Version}. Should be :{eventstoreResult.Value.Version - 1}")));
            }

            eventstoreResult.Value.Update(judge);
            _sessionForEventSourcing.Commit();

            return(new EsUpdateJudgeCommandResponse());
        }
Ejemplo n.º 22
0
 public void SetStatus(ExecutionStatus status, string details = null)
 {
     Status        = status;
     StatusDetails = !string.IsNullOrWhiteSpace(details)
         ? $"Step {_info.GroupPrefix}{_info.Number}: {details.Trim().Replace(Environment.NewLine, Environment.NewLine + "\t")}"
         : null;
 }
Ejemplo n.º 23
0
        public async Task Then_all_scenarios_with_status_should_be_VISIBLE(ExecutionStatus status, [VisibleFormat] bool visible)
        {
            var elements = Driver.FindAllScenarios().Where(s => s.HasClassName(status.ToString().ToLower())).ToArray();

            Assert.That(elements, Is.Not.Empty);
            Assert.That(elements.All(s => s.Displayed == visible));
        }
        public async Task <ExecutionStatus> Run(Judge entity, ByWhatId byWhatId)
        {
            using var connection = new SqliteConnection(_geekLemonContext.ConnectionString);

            //Nie ma SQL INjection
            var q2 = @"UPDATE Judges 
                SET Login = @Login, Password = @Password, BirthDate=@BirthDate  
                ,Name_First = @Name_First, Name_Last = @Name_Last
                WHERE Id = @Id; ";
            var q  = @"UPDATE Judges 
                SET Login = @Login, Password = @Password, BirthDate=@BirthDate  
                ,Name_First = @Name_First, Name_Last = @Name_Last
                WHERE UniqueId = @UniqueId; ";

            var temp = _mapper.Map <JudgeTemp>(entity);

            try
            {
                if (byWhatId == ByWhatId.CreatedId)
                {
                    q = q2;
                }

                var result = await connection.ExecuteAsync(q, temp);

                return(ExecutionStatus.DbOk());
            }
            catch (Exception ex)
            {
                return(ExecutionStatus.DbError(ex.Message));
            }
        }
        public ExecutionStatus Add <T>(T aggregate) where T : AggregateRoot
        {
            try
            {
                if (!IsTracked(aggregate.Key))
                {
                    _trackedAggregates.Add(aggregate.Key,
                                           new AggregateDescriptor
                    {
                        Aggregate = aggregate,
                        Version   = aggregate.Version
                    });
                }
                else if (_trackedAggregates[aggregate.Key].Aggregate != aggregate)
                {
                    throw new ConcurrencyException(aggregate.Key);
                }
            }
            catch (Exception ex)
            {
                if (ExecutionFlow.Options.ThrowExceptions)
                {
                    throw;
                }

                return(ExecutionStatus.EventStoreError(ex));
            }

            return(ExecutionStatus.EventStoreOk());
        }
Ejemplo n.º 26
0
 public static InvocationResult WithStatus(ExecutionStatus status)
 {
     return(new InvocationResult
     {
         Status = status
     });
 }
Ejemplo n.º 27
0
        public static D3SankeyDescription GetActualExecutionPlanD3Sankey(this ExecutionStatus executionStatus)
        {
            var nameToIdDictionary = executionStatus.JobDefinitionStructure.Nodes.Select((Structure, Idx) => new { Structure.NodeName, Idx }).ToDictionary(i => i.NodeName, i => i.Idx);

            return(new D3SankeyDescription
            {
                links = executionStatus.JobDefinitionStructure.StreamToNodeLinks.GroupJoin(
                    executionStatus.StreamStatisticCounters,
                    i => i.SourceNodeName,
                    i => i.SourceNodeName,
                    (link, stat) => new D3SankeyStatisticsLink
                {
                    source = nameToIdDictionary[link.SourceNodeName],
                    target = nameToIdDictionary[link.TargetNodeName],
                    value = stat.DefaultIfEmpty(new StreamStatisticCounter {
                        Counter = 0
                    }).Sum(i => i.Counter)
                }
                    ).ToList(),
                nodes = executionStatus.JobDefinitionStructure.Nodes.Select(i =>
                {
                    string color = "blue";
                    if (executionStatus.StreamStatisticErrors.Any(e => e.NodeName == i.NodeName))
                    {
                        color = "red";
                    }
                    return new D3SankeyStatisticsNode
                    {
                        id = nameToIdDictionary[i.NodeName],
                        name = i.NodeName,
                        color = color
                    };
                }).ToList()
            });
        }
Ejemplo n.º 28
0
 private static IHtmlNode GetStatus(ExecutionStatus status)
 {
     return(Html.Tag(Html5Tag.Span)
            .Class("status " + GetStatusClass(status))
            .Content(status.ToString())
            .SpaceAfter());
 }
Ejemplo n.º 29
0
        public ScenarioBuilder NewScenario(ExecutionStatus status)
        {
            var builder = new ScenarioBuilder(status);

            _scenarios.Add(builder);
            return(builder);
        }
        public static PlotlySankeyDescription GetActualExecutionPlanPlotlySankey(this ExecutionStatus executionStatus)
        {
            var nameToIdDictionary = executionStatus.JobDefinitionStructure.Nodes.Select((Structure, Idx) => new { Structure.NodeName, Idx }).ToDictionary(i => i.NodeName, i => i.Idx);
            var links = executionStatus.JobDefinitionStructure.StreamToNodeLinks.GroupJoin(
                executionStatus.StreamStatisticCounters,
                i => i.SourceNodeName,
                i => i.SourceNodeName,
                (link, stat) => new
            {
                source = nameToIdDictionary[link.SourceNodeName],
                target = nameToIdDictionary[link.TargetNodeName],
                value  = stat.DefaultIfEmpty(new StreamStatisticCounter {
                    Counter = 0
                }).Sum(i => i.Counter)
            }
                ).ToList();

            return(new PlotlySankeyDescription
            {
                NodeColors = executionStatus.JobDefinitionStructure.Nodes.OrderBy(i => nameToIdDictionary[i.NodeName]).Select(i =>
                {
                    if (executionStatus.StreamStatisticErrors.Any(e => e.NodeName == i.NodeName))
                    {
                        return "red";
                    }
                    return "blue";
                }).ToList(),
                NodeNames = executionStatus.JobDefinitionStructure.Nodes.OrderBy(i => nameToIdDictionary[i.NodeName]).Select(i => i.NodeName).ToList(),
                LinkSources = links.Select(i => i.source).ToList(),
                LinkTargets = links.Select(i => i.target).ToList(),
                LinkValues = links.Select(i => i.value).ToList()
            });
        }
Ejemplo n.º 31
0
 public void Update(long executionId, ExecutionStatus updated)
 {
     client.Request(Config.Wcf.OvermindApi.PostStatusUpdate, new StatusUpdateDto
     {
         ExecutionId = executionId,
         Updated = updated
     });
 }
Ejemplo n.º 32
0
 private void UpdateHub(long id, ExecutionStatus status)
 {
     var json = new
     {
         ExecutionId = id,
         Status = status.ToString()
     };
     hub.Context.Clients.updateStatus(json);
 }
 public void ChangeActiveModeStatus(ExecutionStatus status, IView updater)
 {
     if (this.registeredModeControllers.Contains(updater))
     {
         this.Status = status;
     }
     else
     {
         throw new ViewCtrlNotRegisteredException("View controller "  + updater.ToString() +" not regsitered");
     }
 }
Ejemplo n.º 34
0
 public Feed()
 {
     Entries = new ObservableCollection<Feed>();
     Guid = Guid.NewGuid();
     DownloadState = DownloadState.Initialized;
     Percentage = 0.0;
     Title = "";
     Description = "";
     ThumbnailUrl = "";
     _executionStatus = ExecutionStatus.Normal;
 }
 public void ChangeActiveMode(Modes newMode, IViewController updater)
 {
     //Set the modes status to Requested;
     if (this.registeredControllers.Contains(updater))
     {
         this.ActiveMode = newMode;
         this.Status = ExecutionStatus.Requested;
     }
     else
     {
         throw new UICtrlNotRegisteredException("UI controller " + updater.ToString() +" not registerd");
     }
 }
Ejemplo n.º 36
0
        public bool UpdateStatus(long id, ExecutionStatus status)
        {
            var execution = GetById(id);
            if (execution == null)
            {
                return false;
            }
            execution.Status = status;

            if (status == ExecutionStatus.Faulted || status == ExecutionStatus.Aborted || status == ExecutionStatus.Completed)
                execution.Finished = DateTime.UtcNow;

            Update(execution);
            UpdateHub(id, status);
            return true;
        }
Ejemplo n.º 37
0
        //-------------------------------------------------------------------------------------------------//
        public DriverGeneric(XmlNode xmlNodeEquipmentConfig, ExperimentSpecification specification)
        {
            const string STRLOG_MethodName = "DriverGeneric";

            Logfile.WriteCalled(null, STRLOG_MethodName);

            //
            // Initialise static variables
            //
            if (DriverGeneric.firstInstance == true)
            {
                DriverGeneric.initialised = false;
                DriverGeneric.online = false;
                DriverGeneric.statusMessage = STRLOG_NotInitialised;
                DriverGeneric.firstInstance = false;
            }

            //
            // Initialise local variables
            //
            this.xmlNodeEquipmentConfig = xmlNodeEquipmentConfig;
            this.specification = specification;
            this.lastError = null;
            this.running = false;
            this.executionStatus = ExecutionStatus.None;
            this.executionResultStatus = ExecutionStatus.None;

            //
            // Initialise execution times for this driver, won't used when overridden
            //
            this.executionTimes = new ExecutionTimes { initialise = 3, start = 5, run = 7, stop = 4, finalise = 2 };

            try
            {
                //
                // Create thread objects
                //
                if ((this.signalRunning = new Object()) == null)
                {
                    throw new ArgumentNullException(STRERR_signalRunning);
                }
            }
            catch (Exception ex)
            {
                // Log the message and throw the exception back to the caller
                Logfile.WriteError(ex.Message);
                throw;
            }

            Logfile.WriteCompleted(null, STRLOG_MethodName);
        }
Ejemplo n.º 38
0
 public AppWin_SPITool_PRO2()
 {
     byte[][] bufferArray = new byte[4][];
     byte[] buffer = new byte[3];
     buffer[0] = 8;
     buffer[1] = 0x7f;
     bufferArray[0] = buffer;
     bufferArray[1] = new byte[] { 0x21, 100, 0xa2 };
     byte[] buffer2 = new byte[3];
     buffer2[0] = 0x20;
     buffer2[1] = 0x7f;
     bufferArray[2] = buffer2;
     byte[] buffer3 = new byte[3];
     buffer3[0] = 8;
     buffer3[1] = 0x1f;
     bufferArray[3] = buffer3;
     this.PA_MODE_CMD = bufferArray;
     this._chipType = "";
     this._chipRev = "";
     this._myDev = new DeviceRegisterSet();
     this._tele = new Telegram(100);
     this._series = new TelegramContainer();
     this._appId = GlobalServices.uniqApplicationId(WDSApplicationType.SPITool_PRO2);
     this._formwidth = 0x3e9;
     this.vsb = new VScrollBar();
     this._currentVoltage = 2.4;
     this._interpreter = "base-tcl8.5-thread-win32-ix86.exe";
     this._execState = ExecutionStatus.Stopped;
     this.InitializeComponent();
     this.spcMainContainer.IsSplitterFixed = true;
     if ((SystemInformation.PrimaryMonitorSize.Height - 120) < 720)
     {
         base.Height = SystemInformation.PrimaryMonitorSize.Height - 140;
         Point point = new Point();
         this.vsb.Height = (base.ClientSize.Height - this.tsrMainToolStrip.Height) - this.spiStatusBar.Height;
         this.vsb.SmallChange = this.spcMainContainer.Height / 20;
         this.vsb.LargeChange = this.spcMainContainer.Height / 10;
         this.vsb.Minimum = 0;
         this.vsb.Maximum = (((this.spcMainContainer.Height - base.ClientSize.Height) + this.vsb.LargeChange) + this.spiStatusBar.Height) + this.tsrMainToolStrip.Height;
         this.vsb.ValueChanged += new EventHandler(this.vsb_ValueChanged);
         base.MouseWheel += new MouseEventHandler(this.mouseWheelRotated);
         base.Controls.Add(this.vsb);
         this._formwidth += this.vsb.Width;
         base.Width = this._formwidth;
         point.Y = this.tsrMainToolStrip.Height;
         point.X = (base.Width - this.vsb.Width) - 10;
         this.vsb.Location = point;
         this.vsb.Show();
         this.vsb.BringToFront();
     }
     if (!GlobalServices.isfeatureAllowed(GlobalServices.Features.NextGenerationPRO_EngExtra))
     {
         this.tbcCommandTypeSelector.TabPages.Remove(this.tbpRegisterEditor);
         this.tbcCommandTypeSelector.TabPages.Remove(this.tbpTclScriptCall);
         this.tbcCommandTypeSelector.TabPages.Remove(this.tbpRamLoad);
     }
     this.statusBarPanel4.ShowText = false;
     this.statusBarPanel4.StartPoint = 0L;
     this.statusBarPanel4.StepSize = 1L;
 }
        //---------------------------------------------------------------------------------------//
        /// <summary>
        /// 
        /// </summary>
        /// <param name="success"></param>
        /// <param name="successStatus"></param>
        /// <param name="failedStatus"></param>
        private void UpdateExecutionStatus(bool success, ExecutionStatus.Status successStatus, ExecutionStatus.Status failedStatus)
        {
            const String methodName = "UpdateExecutionStatus";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName,
                    String.Format(STRLOG_UpdateExecutionStatus_arg3, success, Enum.GetName(typeof(ExecutionStatus.Status), successStatus),
                    Enum.GetName(typeof(ExecutionStatus.Status), failedStatus)));

            lock (this.executionStatusLock)
            {
                /*
                 * Update result status if execution failed
                 */
                if (success == false)
                {
                    if (this.executionStatus.ResultStatus == ExecutionStatus.Status.None)
                    {
                        this.executionStatus.ResultStatus =
                                (this.cancelled == true) ? ExecutionStatus.Status.Cancelled : ExecutionStatus.Status.Failed;
                    }
                }

                /*
                 * Update result status if execution has completed
                 */
                if (successStatus == ExecutionStatus.Status.Completed)
                {
                    if (this.executionStatus.ResultStatus == ExecutionStatus.Status.None)
                    {
                        this.executionStatus.ResultStatus = ExecutionStatus.Status.Completed;
                    }
                }

                /*
                 * Update execute status only after updating result status
                 */
                this.executionStatus.ExecuteStatus = (success == true) ? successStatus : failedStatus;

                /*
                 * Get the time remaining
                 */
                int timeRemaining = 0;
                switch (this.executionStatus.ExecuteStatus)
                {
                    case ExecutionStatus.Status.Initialising:
                        timeRemaining = this.executionTimes.Initialise
                                + this.executionTimes.Start
                                + this.executionTimes.Run
                                + this.executionTimes.Stop
                                + this.executionTimes.Finalise;
                        break;
                    case ExecutionStatus.Status.Starting:
                        timeRemaining = this.executionTimes.Start
                                + this.executionTimes.Run
                                + this.executionTimes.Stop
                                + this.executionTimes.Finalise;
                        break;
                    case ExecutionStatus.Status.Running:
                        timeRemaining = this.executionTimes.Run
                                + this.executionTimes.Stop
                                + this.executionTimes.Finalise;
                        break;
                    case ExecutionStatus.Status.Stopping:
                        timeRemaining = this.executionTimes.Stop
                                + this.executionTimes.Finalise;
                        break;
                    case ExecutionStatus.Status.Finalising:
                        timeRemaining =
                                this.executionTimes.Finalise;
                        break;
                    case ExecutionStatus.Status.Completed:
                        break;
                }

                /*
                 * Set the time remaining in the execution status and renew the expected completion time
                 */
                this.executionStatus.TimeRemaining = timeRemaining;
                this.completionTime = DateTime.Now.AddSeconds(timeRemaining);

                Logfile.WriteCompleted(logLevel, STR_ClassName, methodName);
            }
        }
        //---------------------------------------------------------------------------------------//
        /// <summary>
        /// 
        /// </summary>
        /// <param name="labEquipmentConfiguration"></param>
        public DriverGeneric(LabEquipmentConfiguration labEquipmentConfiguration)
        {
            const String methodName = "DriverGeneric";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            try
            {
                /*
                 * Check that parameters are valid
                 */
                if (labEquipmentConfiguration == null)
                {
                    throw new ArgumentNullException(LabEquipmentConfiguration.ClassName);
                }

                /*
                 * Get the driver configuration from the XML String
                 */
                XmlDocument xmlDocument = XmlUtilities.GetDocumentFromString(labEquipmentConfiguration.GetXmlDriverConfiguration(this.DriverName));
                XmlNode nodeRoot = XmlUtilities.GetRootNode(xmlDocument, LabConsts.STRXML_Driver);

                /*
                 * Get the execution times for each of the driver states
                 */
                XmlNode xmlNodeExecutionTimes = XmlUtilities.GetChildNode(nodeRoot, LabConsts.STRXML_ExecutionTimes);
                this.executionTimes = ExecutionTimes.ToObject(XmlUtilities.ToXmlString(xmlNodeExecutionTimes));

                /*
                 * Get the experiment results XML template
                 */
                XmlNode xmlNodeExperimentResults = XmlUtilities.GetChildNode(nodeRoot, LabConsts.STRXML_ExperimentResults);
                this.xmlExperimentResultsTemplate = XmlUtilities.ToXmlString(xmlNodeExperimentResults);

                /*
                 * Initialise local variables
                 */
                this.completionTime = DateTime.Now;
                this.executionId = 0;
                this.executionStatusLock = new Object();
                this.executionStatus = new ExecutionStatus();
                this.executionStatus.ExecuteStatus = ExecutionStatus.Status.Created;
                this.executionStatus.TimeRemaining = this.executionTimes.TotalExecutionTime;
                this.cancelled = false;

                /*
                 * Save a copy of the driver XML node for the derived class
                 */
                this.xmlNodeDriver = nodeRoot.Clone();

                /*
                 * Get the experiment validation from the XML String
                 */
                xmlDocument = XmlUtilities.GetDocumentFromString(labEquipmentConfiguration.XmlValidation);
                nodeRoot = XmlUtilities.GetRootNode(xmlDocument, LabConsts.STRXML_Validation);

                /*
                 * Save a copy of the experiment validation XML node for the derived class
                 */
                this.xmlNodeValidation = nodeRoot.Clone();
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                throw ex;
            }

            String logMessage = String.Format(STRLOG_ExecutionStatus_arg5, executionStatus.ExecutionId,
                    Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ExecuteStatus),
                    Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ResultStatus),
                executionStatus.TimeRemaining, executionStatus.ErrorMessage);

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName, logMessage);
        }
Ejemplo n.º 41
0
        private ExecutionStatus ExecuteJavaScript(string code){
            
            ExecutionStatus c = new ExecutionStatus();

            try{
                c.javaScriptCode =  LoadJavaScriptLibrariesForExecution(code);
                c.result = _jsContext.Run(c.javaScriptCode);
            }
            catch(System.Exception ex){                
                c.ex = ex;                
            }
            return c;
        }
Ejemplo n.º 42
0
 /// <summary>
 /// Completes operation execution.
 /// </summary>
 public virtual void CompleteExecute()
 {
     _current = _next;
     _next = null;
     Status = ExecutionStatus.Completed;
 }
Ejemplo n.º 43
0
        /// <summary>
        /// OpenCL 1.1
        /// </summary>
        /// <param name="command_exec_callback_type"></param>
        /// <param name="pfn_notify"></param>
        /// <param name="user_data"></param>
        public void SetCallback(ExecutionStatus command_exec_callback_type, EventNotify pfn_notify, object user_data)
        {
            ErrorCode result;
            int callbackId = AddCallback(this,pfn_notify, user_data);

            result = OpenCL.SetEventCallback(EventID, (int)command_exec_callback_type, CallbackDelegate, (IntPtr)callbackId);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("SetEventCallback failed with error code " + result, result);
        }
 public virtual void Awake()
 {
     this.Status = ExecutionStatus.Requested;
     this.ActiveMode = Modes.Initialise;
 }
        //-------------------------------------------------------------------------------------------------//
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionId"></param>
        /// <returns></returns>
        public ExecutionStatus GetExecutionStatus(int executionId)
        {
            const string methodName = "GetExecutionStatus";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName,
                    String.Format(STRLOG_ExecutionId_arg, executionId));

            ExecutionStatus executionStatus = new ExecutionStatus();

            try
            {
                if (this.driver != null)
                {
                    /*
                     * Get the execution status and check the execution Id
                     */
                    executionStatus = this.driver.GetExecutionStatus();
                    if (executionStatus.ExecutionId != executionId && executionStatus.ExecutionId != 0)
                    {
                        throw new ApplicationException(String.Format(STRERR_InvalidExecutionId_arg, executionId));
                    }

                    /*
                     * Check if the experiment has completed
                     */
                    if (executionStatus.ExecuteStatus.Equals(ExecutionStatus.Status.Completed) == true)
                    {
                        /*
                         * Check if the experiment has completed successfully
                         */
                        if (executionStatus.ResultStatus.Equals(ExecutionStatus.Status.Completed) == false)
                        {
                            /*
                             * The driver is no longer needed
                             */
                            this.driver = null;
                        }

                        /*
                         * Experiment has completed but the results are yet to be retrieved
                         */
                        this.ResumePowerdown();
                    }
                    else
                    {
                        /*
                         *  Update the execution time including the time until the LabEquipment is ready
                         */
                        executionStatus.TimeRemaining = executionStatus.TimeRemaining + this.GetTimeUntilReady();
                    }
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
            }

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName,
                    String.Format(STRLOG_ExecutionStatus_arg5, executionStatus.ExecutionId,
                    Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ExecuteStatus),
                    Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ResultStatus),
                    executionStatus.TimeRemaining, executionStatus.ErrorMessage));

            return executionStatus;
        }
 /// <summary>
 /// Initializes new instance of <see cref="ExecutionStatusChangedEventArgs"/> class.
 /// </summary>
 /// <param name="newStatus">
 /// A value of <see cref="ExecutionStatus"/> that defines new status.
 /// </param>
 public ExecutionStatusChangedEventArgs(ExecutionStatus newStatus)
 {
     NewStatus = newStatus;
 }
Ejemplo n.º 47
0
        private void InitializeMembers()
        {
            this.eventId = 0;
            this.userGuid = Guid.Empty;
            this.jobGuid = Guid.Empty;
            this.contextGuid = Guid.Empty;
            this.eventSource = EventSource.None;
            this.eventSeverity = EventSeverity.Status;
            this.eventDateTime = DateTime.Now;
            this.eventOrder = 0;
            this.executionStatus = ExecutionStatus.Executing;
            this.operation = string.Empty;
            this.entityGuid = Guid.Empty;
            this.entityGuidFrom = Guid.Empty;
            this.entityGuidTo = Guid.Empty;
            this.exceptionType = null;
            this.site = null;
            this.message = null;
            this.stackTrace = null;

            this.userData = new Dictionary<string, object>();
            this.exception = null;
        }
Ejemplo n.º 48
0
        private void CopyMembers(Event old)
        {
            this.eventId = old.eventId;
            this.userGuid = old.userGuid;
            this.jobGuid = old.jobGuid;
            this.contextGuid = old.contextGuid;
            this.eventSource = old.eventSource;
            this.eventSeverity = old.eventSeverity;
            this.eventDateTime = old.eventDateTime;
            this.eventOrder = old.eventOrder;
            this.executionStatus = old.executionStatus;
            this.operation = old.operation;
            this.entityGuid = old.entityGuid;
            this.entityGuidFrom = old.entityGuidFrom;
            this.entityGuidTo = old.entityGuidTo;
            this.exceptionType = old.exceptionType;
            this.site = old.site;
            this.message = old.message;
            this.stackTrace = old.stackTrace;

            this.userData = new Dictionary<string, object>(old.userData);
            this.exception = old.exception;
        }
Ejemplo n.º 49
0
        public int LoadFromDataReader(SqlDataReader dr)
        {
            int o = -1;

            this.eventId = dr.GetInt64(++o);
            this.userGuid = dr.GetGuid(++o);
            this.jobGuid = dr.GetGuid(++o);
            this.contextGuid = dr.GetGuid(++o);
            this.eventSource = (EventSource)dr.GetInt32(++o);
            this.eventSeverity = (EventSeverity)dr.GetInt32(++o);
            this.eventDateTime = dr.GetDateTime(++o);
            this.eventOrder = dr.GetInt64(++o);
            this.executionStatus = (ExecutionStatus)dr.GetInt32(++o);
            this.operation = dr.GetString(++o);
            this.entityGuid = dr.GetGuid(++o);
            this.entityGuidFrom = dr.GetGuid(++o);
            this.entityGuidTo = dr.GetGuid(++o);
            this.exceptionType = dr.IsDBNull(++o) ? null : dr.GetString(o);
            this.message = dr.IsDBNull(++o) ? null : dr.GetString(o);
            this.site = dr.IsDBNull(++o) ? null : dr.GetString(o);
            this.stackTrace = dr.IsDBNull(++o) ? null : dr.GetString(o);
            this.exception = null;

            return o;
        }
Ejemplo n.º 50
0
        /// <summary>
        /// OpenCL 1.1
        /// </summary>
        /// <param name="_event"></param>
        /// <param name="execution_status"></param>
        public void SetUserEventStatus(ExecutionStatus execution_status)
        {
            ErrorCode result;

            result = OpenCL.SetUserEventStatus(EventID, execution_status);
            if (result != ErrorCode.SUCCESS)
                throw new OpenCLException("SetUserEventStatus failed with error code " + result, result);
        }
        //-------------------------------------------------------------------------------------------------//
        /// <summary>
        /// 
        /// </summary>
        /// <param name="xmlSpecification"></param>
        /// <returns>ExecutionStatus</returns>
        public ExecutionStatus StartExecution(String xmlSpecification)
        {
            const string methodName = "StartExecution";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            ExecutionStatus executionStatus;

            try
            {
                /*
                 * Check if an experiment is already running
                 */
                if (this.driver != null)
                {
                    executionStatus = this.driver.GetExecutionStatus();
                    if (executionStatus.ExecuteStatus != ExecutionStatus.Status.Completed)
                    {
                        throw new ApplicationException(STRERR_AlreadyExecuting);
                    }
                }

                /*
                 * Create an instance of LabExperimentSpecification and get the setup Id
                 */
                LabExperimentSpecification labExperimentSpecification = LabExperimentSpecification.XmlParse(xmlSpecification);

                /*
                 * Get the driver for the setup Id and validate the experiment specification
                 */
                this.driver = this.GetDriver(labExperimentSpecification.SetupId);
                Validation validation = this.driver.Validate(xmlSpecification);
                if (validation.Accepted == false)
                {
                    throw new ApplicationException(validation.ErrorMessage);
                }

                /*
                 * Generate a random number for the execution Id
                 */
                Random random = new Random();
                this.driver.ExecutionId = random.Next();

                /*
                 * Start the driver executing but this may require powering up the equipment first
                 */
                if (this.SuspendPowerdown() == false)
                {
                    throw new ApplicationException(STRERR_FailedToStartExecution);
                }

                /*
                 * Tell the thread that there is an experiment to execute
                 */
                this.signalStartExecution.Notify();

                /*
                 * Get the execution status and update the execution time including the time until the LabEquipment is ready
                 */
                executionStatus = this.driver.GetExecutionStatus();
                executionStatus.TimeRemaining = executionStatus.TimeRemaining + this.GetTimeUntilReady();

            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
                executionStatus = new ExecutionStatus();
                executionStatus.ResultStatus = ExecutionStatus.Status.Failed;
                executionStatus.ErrorMessage = ex.Message;
            }

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName,
                    String.Format(STRLOG_ExecutionStatus_arg5, executionStatus.ExecutionId,
                    Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ExecuteStatus),
                    Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ResultStatus),
                    executionStatus.TimeRemaining, executionStatus.ErrorMessage));

            return executionStatus;
        }
Ejemplo n.º 52
0
        //=================================================================================================//
        private void DriverThread()
        {
            const string STRLOG_MethodName = "DriverThread";

            Logfile.WriteCalled(this.logLevel, STRLOG_ClassName, STRLOG_MethodName);

            Trace.WriteLine("DriverGeneric.DriverThread:");

            try
            {
                //
                // Initialise state machine
                //
                this.lastError = null;
                this.executionStatus = ExecutionStatus.Initialising;
                this.executionResultStatus = ExecutionStatus.None;
                this.running = true;

                //
                // Wait a moment before signalling
                //
                Thread.Sleep(1000);
                lock (this.signalRunning)
                {
                    Monitor.Pulse(this.signalRunning);
                }

                //
                // State machine loop
                //
                while (this.running == true)
                {
                    int seconds;

                    //Trace.WriteLine("executingStatus: " + this.executingStatus.ToString());

                    switch (this.executionStatus)
                    {
                        case ExecutionStatus.Initialising:
                            //
                            // Determine the time at which execution is expected to complete
                            //
                            seconds = this.executionTimes.initialise + this.executionTimes.start + this.executionTimes.run +
                                this.executionTimes.stop + this.executionTimes.finalise;
                            this.executionCompletionTime = DateTime.Now + TimeSpan.FromSeconds(seconds);

                            //
                            // Execute this part of the driver
                            //
                            if (this.ExecuteInitialising() == false)
                            {
                                this.executionResultStatus = ExecutionStatus.Failed;
                                this.executionStatus = ExecutionStatus.Completed;
                                break;
                            }

                            this.executionStatus = ExecutionStatus.Starting;
                            break;

                        case ExecutionStatus.Starting:
                            //
                            // Determine the time at which execution is expected to complete
                            //
                            seconds = this.executionTimes.start + this.executionTimes.run +
                                this.executionTimes.stop + this.executionTimes.finalise;
                            this.executionCompletionTime = DateTime.Now + TimeSpan.FromSeconds(seconds);

                            //
                            // Execute this part of the driver
                            //
                            if (this.ExecuteStarting() == false)
                            {
                                this.executionResultStatus = ExecutionStatus.Failed;
                                this.executionStatus = ExecutionStatus.Stopping;
                                break;
                            }

                            this.executionStatus = ExecutionStatus.Running;
                            break;

                        case ExecutionStatus.Running:
                            //
                            // Determine the time at which execution is expected to complete
                            //
                            seconds = this.executionTimes.run +
                                this.executionTimes.stop + this.executionTimes.finalise;
                            this.executionCompletionTime = DateTime.Now + TimeSpan.FromSeconds(seconds);

                            //
                            // Execute this part of the driver
                            //
                            if (this.ExecuteRunning() == false)
                            {
                                this.executionResultStatus = ExecutionStatus.Failed;
                                this.executionStatus = ExecutionStatus.Stopping;
                                break;
                            }

                            this.executionStatus = ExecutionStatus.Stopping;
                            break;

                        case ExecutionStatus.Stopping:
                            //
                            // Determine the time at which execution is expected to complete
                            //
                            seconds = this.executionTimes.stop + this.executionTimes.finalise;
                            this.executionCompletionTime = DateTime.Now + TimeSpan.FromSeconds(seconds);

                            //
                            // Execute this part of the driver
                            //
                            if (this.ExecuteStopping() == false)
                            {
                                this.executionResultStatus = ExecutionStatus.Failed;
                            }

                            this.executionStatus = ExecutionStatus.Finalising;
                            break;

                        case ExecutionStatus.Finalising:
                            //
                            // Determine the time at which execution is expected to complete
                            //
                            seconds = this.executionTimes.finalise;
                            this.executionCompletionTime = DateTime.Now + TimeSpan.FromSeconds(seconds);

                            //
                            // Execute this part of the driver
                            //
                            if (this.ExecuteFinalising() == false)
                            {
                                this.executionResultStatus = ExecutionStatus.Failed;
                            }

                            this.executionStatus = ExecutionStatus.Done;
                            break;

                        case ExecutionStatus.Done:
                            this.running = false;
                            break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logfile.WriteError(ex.Message);
            }

            //
            // Update execution result if all was successful
            //
            if (this.executionResultStatus == ExecutionStatus.None)
            {
                this.executionResultStatus = ExecutionStatus.Completed;
            }

            //
            // Now, execution is completed
            //
            this.executionStatus = ExecutionStatus.Completed;

            String logMessage = STRLOG_ExecutingStatus + this.executionStatus.ToString() +
                Logfile.STRLOG_Spacer + STRLOG_ResultStatus + this.executionResultStatus.ToString();

            Trace.WriteLine("DriverGeneric.DriverThread: Completed");

            Logfile.WriteCompleted(this.logLevel, STRLOG_ClassName, STRLOG_MethodName, logMessage);
        }
Ejemplo n.º 53
0
 public void Execute(Test.AccessionOrder accessionOrder, YellowstonePathology.Business.Test.Surgical.SurgicalTestOrder panelSetOrderSurgical, Business.User.SystemIdentity systemIdentity, ExecutionStatus executionStatus)
 {
     this.m_AccessionOrder = accessionOrder;
     this.m_PanelSetOrderSurgical = panelSetOrderSurgical;
     this.m_SystemIdentity = systemIdentity;
     this.m_ExecutionStatus = executionStatus;
     this.m_Rule.Execute(this.m_ExecutionStatus);
 }
Ejemplo n.º 54
0
        private void tclExecutionEventHandler(Telegram replyTelegram)
        {
            try
            {
                bool flag;
                try
                {
                    flag = (bool) replyTelegram.UserData[0];
                    object[] senderInfo = replyTelegram.SenderInfo;
                }
                catch
                {
                    flag = false;
                }
                switch (replyTelegram.type)
                {
                    case TelegramType.OutputMessage:
                        if (replyTelegram.UserDataExt.hasStoredValue("SenderInfo"))
                        {
                            this.showLocalLog("< " + ((string) replyTelegram.UserDataExt.StoredUserData["SenderInfo"]), false);
                        }
                        break;

                    case TelegramType.ErrorMessage:
                        if (replyTelegram.UserDataExt.hasStoredValue("SenderInfo"))
                        {
                            this.showLocalLog("< ***ERROR*** " + ((string) replyTelegram.UserDataExt.StoredUserData["SenderInfo"]), false);
                        }
                        break;

                    case TelegramType.ExecutionTimeout:
                        if (!flag)
                        {
                            this.showLocalLog("< Timeout! Script killed!", false);
                        }
                        break;
                }
                if (flag)
                {
                    switch (replyTelegram.type)
                    {
                        case TelegramType.PortHandlerTerminated:
                            this.DefaultTelegramFromPortHandler(replyTelegram);
                            return;

                        case TelegramType.OutputMessage:
                            if (replyTelegram.UserDataExt.hasStoredValue("SenderInfo"))
                            {
                                this.rtbOutput.AppendText(((string) replyTelegram.UserDataExt.StoredUserData["SenderInfo"]) + "\n");
                                this.rtbOutput.ScrollToCaret();
                                this.tbcOutput.SelectedTab = this.tbpOutput;
                            }
                            return;

                        case TelegramType.ErrorMessage:
                            if (replyTelegram.UserDataExt.hasStoredValue("SenderInfo"))
                            {
                                this.rtbError.AppendText(((string) replyTelegram.UserDataExt.StoredUserData["SenderInfo"]) + "\n");
                                this.rtbError.ScrollToCaret();
                                this.tbcOutput.SelectedTab = this.tbpError;
                            }
                            return;

                        case TelegramType.ExecutionTimeout:
                            this.btnStartStopTclScript.Image = Resources.stop_16x16;
                            this.btnStartStopTclScript.Enabled = true;
                            this.lblTimeoutWarning.Text = this.lblTimeoutWarning.Text.Replace("<TIME>", this.nudScriptTimeout.Value.ToString());
                            this.lblTimeoutWarning.Visible = true;
                            this._execState = ExecutionStatus.TimeOut;
                            return;

                        case TelegramType.Terminated:
                            this.btnStartStopTclScript.Image = Resources.exec_16x16;
                            this.btnStartStopTclScript.Enabled = true;
                            this.lblTimeoutWarning.Visible = false;
                            this._execState = ExecutionStatus.Stopped;
                            return;
                    }
                }
            }
            catch (Exception exception)
            {
                _log.Error("Error at tclExecutionEventHandler:" + exception.Message);
            }
        }
Ejemplo n.º 55
0
 public EventStatusEventArgs(ExecutionStatus status)
 {
     _status = status;
 }
Ejemplo n.º 56
0
 private void TestUserEventCallback(Event e, ExecutionStatus executionStatus, object userData)
 {
     TestUserEventCallbackCalled = true;
 }
Ejemplo n.º 57
0
        /// <summary>
        /// Tries to start operation execution.
        /// It is possible to retrying execution several times.
        /// Interface implementation is responsible for counting the attempts.
        /// </summary>
        public virtual void StartExecute()
        {
            if (_current != this)
            {
                _next = _current;
                _current = this;
            }

            Status = ExecutionStatus.Started;
        }
        //---------------------------------------------------------------------------------------//
        /// <summary>
        /// 
        /// </summary>
        /// <returns>ExecutionStatus</returns>
        public ExecutionStatus GetExecutionStatus()
        {
            const String methodName = "GetExecutionStatus";
            Logfile.WriteCalled(logLevel, STR_ClassName, methodName);

            ExecutionStatus execStatus = new ExecutionStatus();

            /*
             * Copy over the execution status
             */
            lock (this.executionStatusLock)
            {
                execStatus.ExecutionId = this.executionId;
                execStatus.ExecuteStatus = this.executionStatus.ExecuteStatus;
                execStatus.ResultStatus = this.executionStatus.ResultStatus;
                execStatus.ErrorMessage = this.executionStatus.ErrorMessage;
            }

            /*
             * Update the time remaining
             */
            int timeRemaining;
            switch (execStatus.ExecuteStatus)
            {
                case ExecutionStatus.Status.Created:
                    timeRemaining = this.executionTimes.TotalExecutionTime;
                    break;

                case ExecutionStatus.Status.Initialising:
                case ExecutionStatus.Status.Starting:
                case ExecutionStatus.Status.Running:
                case ExecutionStatus.Status.Stopping:
                case ExecutionStatus.Status.Finalising:
                    /*
                     * Get the time in seconds from now until the expected completion time
                     */
                    TimeSpan timeSpan = this.completionTime - DateTime.Now;
                    timeRemaining = Convert.ToInt32(timeSpan.TotalSeconds);

                    /*
                     * Ensure time remaining is greater than zero
                     */
                    if (timeRemaining < 1)
                    {
                        timeRemaining = 1;
                    }
                    break;

                case ExecutionStatus.Status.Done:
                case ExecutionStatus.Status.Completed:
                case ExecutionStatus.Status.Failed:
                case ExecutionStatus.Status.Cancelled:
                    timeRemaining = 0;
                    break;

                default:
                    timeRemaining = -1;
                    break;
            }
            execStatus.TimeRemaining = timeRemaining;

            String logMessage = String.Format(STRLOG_ExecutionStatus_arg5, executionStatus.ExecutionId,
                Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ExecuteStatus),
                Enum.GetName(typeof(ExecutionStatus.Status), executionStatus.ResultStatus),
                executionStatus.TimeRemaining, executionStatus.ErrorMessage);

            Logfile.WriteCompleted(logLevel, STR_ClassName, methodName, logMessage);

            return execStatus;
        }
Ejemplo n.º 59
0
 public void SetUserEventStatus(ExecutionStatus status)
 {
     UnsafeNativeMethods.SetUserEventStatus(Handle, status);
 }
Ejemplo n.º 60
0
 /// <summary>
 /// OpenCL 1.1
 /// </summary>
 /// <param name="_event"></param>
 /// <param name="execution_status"></param>
 /// <returns></returns>
 public static ErrorCode SetUserEventStatus(cl_event _event, ExecutionStatus execution_status)
 {
     return OpenCLAPI.clSetUserEventStatus(_event, execution_status);
 }