Пример #1
0
        public void StartWatching()
        {
            ClientFacade facade = new ClientFacade();
            List<Submit> submits = facade.GetUnprocessedSubmits();

            //start watching new submits
            StartNewSubmits(submits);

            //set the timer to start periodically watching
            _timer = new System.Timers.Timer();
            _timer.Interval = GetPollingInterval();
            _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
            _timer.Start();
        }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            string textToSubmit = this.richTextBox2.Text;

            ClientFacade facade = new ClientFacade();

            Team team = new Team() {Id=1, Name="Team01", Password="******"};

            team = facade.AuthenticateTeam(team);

            Submit submit = new Submit();
            submit.Team = team;
            submit.Data = new UTF8Encoding().GetBytes(textToSubmit);
            submit.AssignmentEnrollment = new AssignmentEnrollment() {Id=1, Team = team};
            submit.TournamentAssignment = new TournamentAssignment() { Id = 1 };
            submit.SubmitDate = DateTime.Now;
            submit.FileName = "HelloWorld.cs";

            facade.SaveSubmit(submit);
        }
Пример #3
0
        private static void SaveStatusToDatabase(Submit submit, ValidationResult result)
        {
            string teamName = submit.Team.Name;
            string assignmentName = submit.TournamentAssignment.Assignment.Name;

            string details = "";
            foreach (string detail in result.Messages)
            {
                details += detail;
            }
            if (details.Length > 1000)
            {
                details = details.Substring(0, 999);
            }

            ClientFacade facade = new ClientFacade();

            //process result
            switch (result.Status)
            {
                case SubmitStatusCode.Unknown:
                    facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorUnknown, details, DateTime.Now);
                    break;
                case SubmitStatusCode.CompilationError:
                    facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorCompilation, details, DateTime.Now);
                    break;
                case SubmitStatusCode.ValidationError:
                    facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorValidation, details, DateTime.Now);
                    break;
                case SubmitStatusCode.TestError:
                    facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorTesting, details, DateTime.Now);
                    break;
                case SubmitStatusCode.ServerError:
                    facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.ErrorServer, details, DateTime.Now);
                    break;
                case SubmitStatusCode.Success:
                    facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.Success, details, DateTime.Now);
                    break;
                default:
                    break;
            }
        }
Пример #4
0
 private void _timer_Elapsed(object sender, ElapsedEventArgs e)
 {
     ClientFacade facade = new ClientFacade();
     List<Submit> submits = facade.GetUnprocessedSubmits();
     StartNewSubmits(submits);
     TerminateOldSubmits();
     TraceStatus();
 }
Пример #5
0
        private static void ProcessTeamSubmit(ValidationProcess validationProcess, SystemSettings sysSettings)
        {
            Submit submit = validationProcess.Submit;
            string teamName = submit.Team.Name;
            string assignmentName = submit.TournamentAssignment.Assignment.Name;

            Log(string.Format("Processing teamsubmit {0} for assignment {1}", teamName, assignmentName));

            //create the processor
            SubmitValidator validator = new SubmitValidator(new MoCS.BuildService.Business.FileSystemWrapper(), new ExecuteCmd());
            validationProcess.SetProcessor(validator);

            //prepare directory and files for processing
            string teamSubmitDirName = CreateTeamDirectory(sysSettings, teamName, submit.TournamentAssignment.Assignment);
            ClientFacade facade = new ClientFacade();
            MoCS.Business.Objects.Assignment assignment = facade.GetAssignmentById(submit.TournamentAssignment.Assignment.Id, true);
            CopyFiles(assignment, submit, teamSubmitDirName, sysSettings);

            //START PROCESSING

            //settings that are read from the assignment
            AssignmentSettings assignmentSettings = SettingsFactory.CreateAssignmentSettings(assignment, assignmentName);
            //settings that are from the submitprocess/team submit
            SubmitSettings submitSettings = SettingsFactory.CreateSubmitSettings(teamName, teamSubmitDirName, assignmentName);

            //set status of submit to 'processing'
            facade.UpdateSubmitStatusDetails(submit.Id, SubmitStatus.Processing, "This submitted is currently processed.", DateTime.Now);

            ValidationResult result = validator.Process(sysSettings, assignmentSettings, submitSettings);
            validationProcess.Result = result;

            Log(result.Status + " for " + submit.Team.Name + " on " + submit.TournamentAssignment.Assignment.Name);

            //save the new status to the database
            SaveStatusToDatabase(validationProcess.Submit, result);

            // Delete nunit.framework.dll from the submit dir to keep things clean
            CleanupFiles(teamSubmitDirName);
        }