private void FinishExperiment()
        {
            eyeTracker.StopTracking();
            eyeTracker.ClearTracking();
            eyeTracker.Stop();

            foreach (Slide_Answer sa in Test.Slide_Answer)
            {
                Db.Slide_Answer.Add(sa);
            }
            Test.LastStep = Test.Test_Definition.EyeTrackerStep;
            if (Test.LastStep == Test.NumSteps)
            {
                Test.status_cd = "TRM";
                Test.end_time  = DateTime.Now;
            }
            Db.SaveChanges();

            ((App)App.Current).Log(Severity.Info, String.Format("Eyetracker test for {0} successfully completed.", Test.Candidate.personal_code));

            Mouse.OverrideCursor = null;
            Close();
        }
Ejemplo n.º 2
0
        public int Read(String filePath, bool mergeReplace)
        {
            if (!File.Exists(filePath))
            {
                return((int)ReturnCodes.FileNotFound);
            }

            String fileExtension = Path.GetExtension(filePath);

            if (!fileExtension.ToUpper().Equals(".TXT") && !fileExtension.ToUpper().Equals(".IDF"))
            {
                return((int)ReturnCodes.WrongFileExtension);
            }

            String fileName = Path.GetFileNameWithoutExtension(filePath);

            String[] nameParts = fileName.Split('-');

            if (nameParts.Count() != 3)
            {
                return((int)ReturnCodes.MalformedFileName);
            }

            if (!nameParts[0].Equals(Test.Candidate.personal_code))
            {
                return((int)ReturnCodes.WrongCandidate);
            }

            int testId = int.Parse(nameParts[1]);

            if (Test == null)
            {
                Test = db.Tests.FirstOrDefault(t => t.id == testId);
            }

            if (Test.id != testId)
            {
                return((int)ReturnCodes.WrongTest);
            }

            int          slideNum    = int.Parse(nameParts[2]);
            Slide_Answer slideAnswer = Test.Slide_Answer.FirstOrDefault(sa => sa.Slide.num == slideNum);

            if (slideAnswer == null)
            {
                return((int)ReturnCodes.MalformedFileName);
            }

            if (db.Tracking.FirstOrDefault(t => t.test_id == Test.id && t.slide_id == slideAnswer.slide_id) != null)
            {
                if (mergeReplace)
                {
                    db.SaveChanges();
                    db.Database.ExecuteSqlCommand("delete from tracking where test_id = {0} and slide_id = {1}", Test.id, slideAnswer.slide_id);
                }
                else
                {
                    return((int)ReturnCodes.DataPresent);
                }
            }

            FileStream stream = new FileStream(filePath, FileMode.Open);

            if (filePath.ToUpper().EndsWith(".IDF"))
            {
                return(ReadIdf(stream, slideAnswer));
            }
            else if (filePath.ToUpper().EndsWith(".TXT"))
            {
                return(ReadTxt(stream, slideAnswer));
            }
            else
            {
                return((int)ReturnCodes.WrongFileExtension);
            }
        }
Ejemplo n.º 3
0
 private void bnSave_Click(object sender, RoutedEventArgs e)
 {
     db.SaveChanges();
 }