Exemplo n.º 1
0
 public TesterResultUpdateWindow(TesterTest test)
 {
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
     InitializeComponent();
     this.testResult  = test;
     this.DataContext = testResult;
 }
Exemplo n.º 2
0
        void IBL.updateTest(int testNumber, TesterTest test, int testerID)
        {
            try
            {
                if (testNumber < Configuration.BeginningSerialTestNumber || testNumber > 99999999)
                {
                    throw new InvalidTestNumberException("Invalid test number.\n");
                }

                //to do: make sure the tester inserted all the grades fields in his feedback
                DO.Test originalTest = dlObject.getTest(testNumber);
                //to do: update the coming test fields - date, tester, exitAddress ect.
                //is the test over?
                if (new DateTime().SystemNow() < originalTest.TestDate.AddHours(originalTest.TestTime).AddMinutes(40))
                {
                    throw new FeedbackBeforeTestEndsException("You cannot give feedback before the test ends!\n");
                }
                //is the test done and got the grades already?
                if (originalTest.TestAlreadyDoneAndSealed)
                {
                    throw new TestHasBeenDoneAndSealedException("You cannot change details of a test after it has already got grades.\n");
                }
                //does the feedback make sense?
                if (!gradesMakeSense(test))
                {
                    throw new FeedbackMakesNoSenseException("Test feedback details do not make sense.\n");
                }
                test.TestAlreadyDoneAndSealed = true;
                dlObject.updateTest(testNumber, test.ToDOTest(testerID));
            }
            catch (Exception exception)
            {
                throw exception.ToBOException();
            }
        }
Exemplo n.º 3
0
        private void RunSitemapTest(WebResourceTest webResourceTest, IEnumerable <string> urls,
                                    int timeout, int testsCount, double interval, CancellationToken token, string connectionId)
        {
            this.UrlsFound(connectionId, urls.Count());

            for (int i = 0; i < urls.Count(); i++)
            {
                if (!token.IsCancellationRequested)
                {
                    string url = urls.ElementAt(i);

                    TesterTest test = this.tester.Analyzer.GetResult(url, timeout, testsCount);

                    bool saving = this.saver.SaveTestData(webResourceTest, test);

                    if (saving)
                    {
                        this.TestFinished(connectionId, i + 1);
                    }

                    Task.Delay(Convert.ToInt32(interval * 1000)).Wait();
                }
                else
                {
                    break;
                }
            }
        }
 public TesterResultUpdateWindow(TesterTest test)
 {
     this.FlowDirection    = FlowDirection.RightToLeft;
     WindowStartupLocation = WindowStartupLocation.CenterScreen;
     InitializeComponent();
     this.testResult  = test;
     this.DataContext = testResult;
 }
Exemplo n.º 5
0
        private IList <string> HtmlTest(WebResourceTest webResourceTest, Domain domain, IList <string> urlsForTest,
                                        ref List <string> testedUrls, int timeout, double interval, int testsCount, CancellationToken token, string connectionId)
        {
            IList <double> responseTimes;
            DateTime       responseDate;

            IList <string> urls        = new List <string>();
            IList <string> elementUrls = new List <string>();

            foreach (var url in urlsForTest)
            {
                if (token.IsCancellationRequested)
                {
                    break;
                }

                elementUrls = htmlTester.GetUrls(url, domain, testsCount, token, out responseTimes, out responseDate);

                if (token.IsCancellationRequested)
                {
                    break;
                }

                foreach (string elementUrl in elementUrls)
                {
                    if (!testedUrls.Contains(elementUrl) && !urlsForTest.Contains(elementUrl) && !urls.Contains(elementUrl))
                    {
                        urls.Add(elementUrl);
                    }
                }

                if (!testedUrls.Contains(url))
                {
                    TesterTest test = this.tester.Analyzer.GetResult(url, timeout, testsCount - responseTimes.Count());
                    for (int i = responseTimes.Count() - 1; i >= 0; i--)
                    {
                        test.TestsCount++;
                        test.TestResults.Insert(0, new TesterTestResult()
                        {
                            ResponseTime = responseTimes.ElementAt(i)
                        });
                    }
                    test.Date = responseDate;
                    bool saving = this.saver.SaveTestData(webResourceTest, test);

                    if (saving)
                    {
                        this.TestFinished(connectionId, testedUrls.Count + 1);
                    }

                    testedUrls.Add(url);

                    Task.Delay(Convert.ToInt32(interval * 1000)).Wait();
                }
            }

            return(urls);
        }
Exemplo n.º 6
0
 private bool gradesMakeSense(TesterTest updatedTest)
 {
     if (updatedTest.PositiveFeedbackGradesPercentage() < Configuration.MinimumPercentsOfPositiveGrades &&
         updatedTest.TestScore == true)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 7
0
        private TesterTest GetTestResult(string url, int timeout, int testsCount)
        {
            IList <Task <TesterTestResult> > tasks       = new List <Task <TesterTestResult> >();
            IList <TesterTestResult>         testResults = new List <TesterTestResult>();

            TesterTest test = new TesterTest();

            for (int i = 0; i < testsCount; i++)
            {
                tasks.Add(Task <TesterTestResult> .Factory.StartNew(() =>
                {
                    TesterTestResult result = new TesterTestResult();
                    double time             = 0;

                    try
                    {
                        time          = this.GetConnectionTime(url, timeout);
                        result.Status = ConnectionStatus.Connected;
                    }
                    catch (WebException e)
                    {
                        if (e.Status == WebExceptionStatus.Timeout)
                        {
                            result.Status = ConnectionStatus.DisconnectedByTimeout;
                        }
                        else
                        {
                            result.Status = ConnectionStatus.Disconnected;
                        }
                    }
                    catch (NotSupportedException nse)
                    {
                        result.Status = ConnectionStatus.UrlIsNotSupported;
                    }
                    catch
                    {
                        result.Status = ConnectionStatus.Disconnected;
                    }
                    finally
                    {
                        result.ResponseTime = time;
                    }

                    return(result);
                }));
            }
            Task.WaitAll(tasks.ToArray());

            foreach (Task <TesterTestResult> task in tasks)
            {
                testResults.Add(task.Result);
            }

            test.TestResults = testResults;

            return(test);
        }
Exemplo n.º 8
0
        public TesterTest GetResult(string url, int timeout, int testsCount)
        {
            TesterTest test = new TesterTest();

            test            = this.GetTestResult(url, timeout, testsCount);
            test.Url        = url;
            test.TestsCount = testsCount;
            test.Date       = DateTime.Now;

            return(test);
        }
        public static double PositiveFeedbackGradesPercentage(this TesterTest test)
        {
            int numOfCreteriaTested = 6;
            int positiveGradesCount =
                Convert.ToInt32(test.DistanceKeeping)
                + Convert.ToInt32(test.ReverseParking)
                + Convert.ToInt32(test.LookingAtMirrors)
                + Convert.ToInt32(test.SignalsUsage)
                + Convert.ToInt32(test.PriorityGiving)
                + Convert.ToInt32(test.SpeedKeeping);

            return(positiveGradesCount * (100 / numOfCreteriaTested));
        }
 private void updateTestButtonClicked(object sender, RoutedEventArgs e)
 {
     try
     {
         Button button = sender as Button;
         UpdatedTest = button.Tag as TesterTest;
         bl.updateTest(UpdatedTest.TestNumber, UpdatedTest, TesterID);
         button.IsEnabled = false;
         MessageBox.Show("Test Feedback was updated in the system", "Feedback Saved", MessageBoxButton.OK, MessageBoxImage.Asterisk);
     }
     catch (Exception exception)
     {
         HandleExceptions.Handle(exception, this);
     }
 }
Exemplo n.º 11
0
        private void MenuItem_Click_UpdateTestResult(object sender, RoutedEventArgs e)
        {
            if (ListView_TesterTests.SelectedIndex == -1 || ListView_TesterTests.SelectedItem == null)
            {
                return;
            }
            TesterTest temp = (TesterTest)ListView_TesterTests.SelectedItem;

            if (temp.IsTesterUpdateStatus)
            {
                MessageBox.Show("כבר עידכנת תוצאות עבור מבחן זה!", "חסימת כפילויות", MessageBoxButton.OK, MessageBoxImage.Information,
                                MessageBoxResult.None, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign);
                return;
            }
            if (temp.IsTestAborted)
            {
                MessageBox.Show("אי אפשר לעדכן תוצאות עבור מבחן זה, היות והוא בוטל.", "מבחן בוטל", MessageBoxButton.OK, MessageBoxImage.Information,
                                MessageBoxResult.None, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign);
                return;
            }
            if (temp.DateOfTest > DateTime.Now)
            {
                MessageBox.Show("אי אפשר לעדכן תוצאה של מבחן שעדיין לא קרה.", "חריגת זמנים", MessageBoxButton.OK, MessageBoxImage.Information,
                                MessageBoxResult.None, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign);
                return;
            }
            TesterResultUpdateWindow testerResultUpdateWindow = new TesterResultUpdateWindow(temp);

            testerResultUpdateWindow.ShowDialog();
            try
            {
                tester = MainWindow.bl.GetTesterByID(tester.Id);
                this.ListView_TesterTests.ItemsSource = tester.TestList;
                TesterStatisticsBorder.DataContext    = tester.Statistics;
            }
            catch (KeyNotFoundException ex)
            {
                MessageBox.Show("שגיאה פנימית בחלון בוחן קיים בקליק ימני על עידכון מבחן.\n" + ex.Message, "שגיאה פנימית", MessageBoxButton.OK,
                                MessageBoxImage.Information, MessageBoxResult.None, MessageBoxOptions.RtlReading | MessageBoxOptions.RightAlign);
            }
        }
Exemplo n.º 12
0
        private void MenuItem_Click_UpdateTestResult(object sender, RoutedEventArgs e)
        {
            string ErrorList = "";

            if (TestsList.SelectedIndex == -1)
            {
                return;
            }
            TesterTest temp = (TesterTest)TestsList.SelectedItem;

            if (DateTime.Now == temp.DateOfTest && DateTime.Now.Hour < temp.HourOfTest || DateTime.Now < temp.DateOfTest)
            {
                ErrorList += "ERROR! You can not update test information before the intended date. \n";
            }
            if (temp.IsTesterUpdateStatus)
            {
                ErrorList += "ERROR! Test results have already been entered. You can not change the test details. \n";
            }
            if (temp.IsTestAborted)
            {
                ErrorList += "ERROR! The test has been canceled. details can not be updated for this test \n";
            }
            if (ErrorList == "")
            {
                TesterResultUpdateWindow testerResultUpdateWindow = new TesterResultUpdateWindow(temp);
                testerResultUpdateWindow.ShowDialog();
                try
                {
                    tester = MainWindow.bl.GetTesterByID(tester.Id);
                    this.TestsList.ItemsSource = tester.TestList;
                }
                catch (KeyNotFoundException ex)
                {
                    MessageBox.Show("Internal error on TesterViewTestsWindow at UpdateMenu");
                }
            }
            else
            {
                MessageBox.Show(ErrorList, "TesterWindow", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
 public static DO.Test ToDOTest(this TesterTest BOTesterTest, int testerID)
 {
     DO.Test converted = new DO.Test(
         BOTesterTest.TestNumber,
         testerID,
         BOTesterTest.TraineeID,
         BOTesterTest.TestDate,
         BOTesterTest.TestTime,
         BOTesterTest.ExitAddress.ToDOAddress(),
         BOTesterTest.TestAlreadyDoneAndSealed,
         BOTesterTest.DistanceKeeping,
         BOTesterTest.ReverseParking,
         BOTesterTest.LookingAtMirrors,
         BOTesterTest.SignalsUsage,
         BOTesterTest.PriorityGiving,
         BOTesterTest.SpeedKeeping,
         BOTesterTest.TestScore,
         BOTesterTest.TestersNote
         );
     return(converted);
 }
Exemplo n.º 14
0
        public bool SaveTestData(WebResourceTest webResourceTest, TesterTest test)
        {
            EntitiesAutomapperConfig.Configure();
            try
            {
                Test testEntity = new Test();

                testEntity = Mapper.Map <TesterTest, Test>(test);

                IEnumerable <SitemapResource> sitemaps = webResourceTest.WebResource.SitemapResources.Where((x) => x.Url == test.Url);

                if (sitemaps.Count() > 0)
                {
                    testEntity.SitemapResource = sitemaps.First();
                }
                else
                {
                    SitemapResource sitemap = new SitemapResource()
                    {
                        Url         = test.Url,
                        WebResource = webResourceTest.WebResource
                    };
                    testEntity.SitemapResource = sitemap;
                }

                webResourceTest.Tests.Add(testEntity);

                this.dataUnit.SaveChanges();

                return(true);
            }
            catch
            {
                return(false);
            }
        }