public IHttpActionResult GetQueuedTests() { QueuedTestsModel queuedTestsModel = new QueuedTestsModel(); var currentQueuedTests = queuedTestsModel.QueuedTests.ToList(); return(Ok(currentQueuedTests)); }
public IHttpActionResult GetPreferences(string appName, string testerName, bool queue = false) { var userPreferences = new vUserPreferenceModel(); var preferences = new vUserPreference(); /* * * BrowserName * Environment * EnvironmentUrl * Username * Stack Trace * Console Log * Utilization * Write to dB * */ if (queue) { var queuedTest = new QueuedTestsModel(); var newestQueueItem = queuedTest.QueuedTests.FirstOrDefault(); var applicationEnvironmentsModel = new vApplicationEnvironmentsModel(); var applicationEnvironment = applicationEnvironmentsModel.vApplicationEnvironments.FirstOrDefault( x => x.ApplicationName == appName && x.Environment == newestQueueItem.Environment); preferences = new vUserPreference { TesterName = newestQueueItem.UserName, ApplicationName = newestQueueItem.ApplicationName, Environment = newestQueueItem.Environment, WriteToDatabase = true, StackTrace = newestQueueItem.StackTrace, Utilization = newestQueueItem.Utilization, BrowserConsoleLog = newestQueueItem.ConsoleLog, EnvironmentUrl = applicationEnvironment.Url, RemoteDriver = true }; } else { preferences = userPreferences.vUserPreferences.FirstOrDefault(x => x.TesterName == testerName && x.ApplicationName == appName.ToUpper()); } return(Ok(preferences)); }
public QueueHub() { 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. QueuedTestsModel queuedTests = new QueuedTestsModel(); var allQueuedTests = queuedTests.QueuedTests.OrderByDescending(x => x.Id).ToListAsync(); var queue = allQueuedTests.Result.ToList(); var jsonSerializer = new JavaScriptSerializer(); var serializedData = jsonSerializer.Serialize(queue); string timeNow = DateTime.Now.ToString(); //Sending the server time to all the connected clients on the client method SendServerTime() Clients.All.GetQueue(queue); //Delaying by 3 seconds. await Task.Delay(60000); } }, TaskCreationOptions.LongRunning ); }
public HttpStatusCode AddToQueue([FromBody] string data) { try { JsonSerializer serializer = new JsonSerializer(); JsonReader reader = new JsonTextReader(new StringReader(data)); QueuedTestExtra myQueueWithExtra = serializer.Deserialize <QueuedTestExtra>(reader); ApplicationNameTestListModel applicationNameTestListModel = new ApplicationNameTestListModel(); var allTestsForApp = applicationNameTestListModel.ApplicationNameTestLists.Where( x => x.ApplicationName == myQueueWithExtra.ApplicationName).ToList(); QueuedTestsModel myModel = new QueuedTestsModel(); QueuedTest myQyQueuedTest; if (myQueueWithExtra.RunAllApi) { var allApiTests = allTestsForApp.Where(x => x.TestName.Contains("API")).ToList(); foreach (var item in allApiTests) { myQyQueuedTest = new QueuedTest { Id = myQueueWithExtra.Id, QueuedDateTime = myQueueWithExtra.QueuedDateTime, ApplicationName = myQueueWithExtra.ApplicationName, ConsoleLog = myQueueWithExtra.ConsoleLog, Environment = myQueueWithExtra.Environment, StackTrace = myQueueWithExtra.StackTrace, TestName = item.TestName, UserName = myQueueWithExtra.UserName, Utilization = myQueueWithExtra.Utilization }; myModel.QueuedTests.Add(myQyQueuedTest); } } if (myQueueWithExtra.RunAllGui) { var allGuiTests = allTestsForApp.Where(x => !x.TestName.Contains("API")).ToList(); foreach (var item in allGuiTests) { myQyQueuedTest = new QueuedTest { Id = myQueueWithExtra.Id, QueuedDateTime = myQueueWithExtra.QueuedDateTime, ApplicationName = myQueueWithExtra.ApplicationName, ConsoleLog = myQueueWithExtra.ConsoleLog, Environment = myQueueWithExtra.Environment, StackTrace = myQueueWithExtra.StackTrace, TestName = item.TestName, UserName = myQueueWithExtra.UserName, Utilization = myQueueWithExtra.Utilization }; myModel.QueuedTests.Add(myQyQueuedTest); } } if (myQueueWithExtra.RunAllApi == false && myQueueWithExtra.RunAllGui == false) { myQyQueuedTest = new QueuedTest { Id = myQueueWithExtra.Id, QueuedDateTime = myQueueWithExtra.QueuedDateTime, ApplicationName = myQueueWithExtra.ApplicationName, ConsoleLog = myQueueWithExtra.ConsoleLog, Environment = myQueueWithExtra.Environment, StackTrace = myQueueWithExtra.StackTrace, TestName = myQueueWithExtra.TestName, UserName = myQueueWithExtra.UserName, Utilization = myQueueWithExtra.Utilization }; myModel.QueuedTests.Add(myQyQueuedTest); } myModel.SaveChanges(); return(HttpStatusCode.OK); } catch (Exception ex) { return(HttpStatusCode.BadRequest); } }