예제 #1
0
        public async Task TestProgress(TestProgressMessage message)
        {
            //try
            //{
            //TODO do case wgeb testrunhistory is null
            if (message.TestRunHistoryId != null)
            {
                _testRunResultRepository.Create(new TestRunResult()
                {
                    TestRunHistoryId = message.TestRunHistoryId.Value,
                    CommandTestGuid  = message.CommandTestGuid,
                    IsSuccesful      = message.IsSuccesful
                });
                _unitOfWork.SaveChanges();
            }

            await Clients.Client(message.SenderConnectionId).SendAsync("TestProgress", message);

            //}
            //catch (Exception ex)
            //{
            //    //TODO log to db

            //    throw ex;
            //}
        }
        private async void HandleClientAsync(SmartSocketClient client)
        {
            while (client.IsConnected)
            {
                SocketMessage e = await client.ReceiveAsync();

                if (e != null)
                {
                    this.LastMessageTime = Environment.TickCount;
                    uint processId = 0;

                    if (e.Id == SmartSocketClient.ConnectedMessageId)
                    {
                        lock (this.SchedulerLock)
                        {
                            this.TestProcessesConnected++;
                            this.TestingProcessChannels.Add(e.Sender, client);
                        }
                    }
                    else if (e is BugFoundMessage)
                    {
                        BugFoundMessage bug = (BugFoundMessage)e;
                        processId = bug.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        if (this.IsVerbose)
                        {
                            Console.WriteLine($"... Bug report received from '{bug.Sender}'");
                        }

                        this.NotifyBugFound(processId);
                    }
                    else if (e is TestReportMessage)
                    {
                        TestReportMessage report = (TestReportMessage)e;
                        processId = report.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        if (this.IsVerbose)
                        {
                            Console.WriteLine($"... Test report received from '{report.Sender}'");
                        }

                        this.SetTestReport(report.TestReport, report.ProcessId);
                    }
                    else if (e is TestTraceMessage)
                    {
                        TestTraceMessage report = (TestTraceMessage)e;
                        processId = report.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        this.SaveTraceReport(report);
                    }
                    else if (e is TestProgressMessage)
                    {
                        TestProgressMessage progress = (TestProgressMessage)e;
                        processId = progress.ProcessId;
                        await client.SendAsync(new SocketMessage("ok", this.Configuration.TestingSchedulerEndPoint));

                        // todo: do something fun with progress info.
                    }
                }
            }
        }