Exemplo n.º 1
0
        public IHttpActionResult GetTestRuns(int amount)
        {
            vTestRunsFlatModel testRunsModel = new vTestRunsFlatModel();
            var testRuns = testRunsModel.vTestRunsFlats.Take(amount).OrderByDescending(x => x.TestRunKey);

            return(Ok(testRuns));
        }
Exemplo n.º 2
0
        public MyHub()
        {
            // Create a Long running task to do an infinite loop which will keep sending the server time
            // to the clients every 3 seconds.
            var taskTimer = Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    // TODO: Create if statement so that if current test run key does not equal newest test run key... don't refresh.
                    vTestRunsFlatModel newModel = new vTestRunsFlatModel();
                    var b = newModel.vTestRunsFlats.OrderByDescending(x => x.TestRunKey).Take(100).ToListAsync();
                    var z = b.Result.ToList();

                    foreach (var item in z)
                    {
                        switch (item.TestRunStatus)
                        {
                        case "Pass":
                            {
                                item.Icon = "fa-check-circle";
                                break;
                            }

                        case "Info":
                            {
                                item.Icon = "Info Icon";
                                break;
                            }

                        case "Fail":
                            {
                                item.Icon = "Fail Icon";
                                break;
                            }

                        case "Warning":
                            {
                                item.Icon = "Warning Icon";
                                break;
                            }

                        default:
                            {
                                break;
                            }
                        }
                    }

                    var jsonSerializer = new JavaScriptSerializer();
                    var zz             = jsonSerializer.Serialize(z);

                    string timeNow = DateTime.Now.ToString();
                    //Sending the server time to all the connected clients on the client method SendServerTime()
                    Clients.All.SendServerTime(z);

                    //Delaying by 3 seconds.
                    await Task.Delay(60000);
                }
            }, TaskCreationOptions.LongRunning
                                                  );
        }