Exemplo n.º 1
0
        public static SystemSettings CreateSystemSettings()
        {
            //settings that are used on server side
            SystemSettings sysSettings = new SystemSettings();

            string cscPath = ConfigurationManager.AppSettings["CscPath"];
            string nunitAssemblyPath = ConfigurationManager.AppSettings["NunitAssemblyPath"];
            string nunitConsolePath = ConfigurationManager.AppSettings["NunitConsolePath"];

            //no final slash allowed on nunitPath
            if (nunitAssemblyPath.EndsWith(@"\"))
            {
                nunitAssemblyPath = nunitAssemblyPath.Substring(0, nunitAssemblyPath.Length - 1);
            }

            //no final slash allowed on nunitPath
            if (nunitConsolePath.EndsWith(@"\"))
            {
                nunitConsolePath = nunitConsolePath.Substring(0, nunitAssemblyPath.Length - 1);
            }

            sysSettings.CscPath = cscPath;
            sysSettings.NunitAssemblyPath = nunitAssemblyPath;
            sysSettings.NunitConsolePath = nunitConsolePath;
            sysSettings.NunitTimeOut = int.Parse(ConfigurationManager.AppSettings["ProcessingTimeOut"]);

            sysSettings.AssignmentsBasePath = ConfigurationManager.AppSettings["AssignmentBasePath"];
            return sysSettings;
        }
Exemplo n.º 2
0
        /// <summary>
        /// the main processing method. 
        /// </summary>
        /// <param name="sysSettings"></param>
        /// <param name="assignmentSettings"></param>
        /// <param name="submitSettings"></param>
        /// <returns></returns>
        public SubmitResult Process(SystemSettings sysSettings, AssignmentSettings assignmentSettings, SubmitSettings submitSettings)
        {
            SubmitResult submitResult = new SubmitResult();

            BatchFileCreator batchfileCreator = new BatchFileCreator(sysSettings, submitSettings, _fileSystem);
            string buildFilePath = batchfileCreator.CreateBuildFile();
            string testFilePath = batchfileCreator.CreateTestFile();

            submitResult = CompileAssembly(buildFilePath, batchfileCreator.OutputLogPath);
            //in case of an error, directly return
            if (submitResult.Status == SubmitStatusCode.CompilationError)
            {
                return submitResult;
            }

            //check businessrules
            submitResult = CheckBusinessRules(batchfileCreator.OutputDllPath, assignmentSettings);
            if (submitResult.Status == SubmitStatusCode.ValidationError)
            {
                return submitResult;
            }

            submitResult = TestAssembly(batchfileCreator.BatchfileTestPath, batchfileCreator.TestLogPath);

            if (submitResult.Status == SubmitStatusCode.TestError)
            {
                return submitResult;
            }

            submitResult.Status = SubmitStatusCode.Success;

            return submitResult;
        }
Exemplo n.º 3
0
 public SubmitWatcher()
 {
     //create a synchronized wrapper around the hashtable
     Hashtable ht2 = new Hashtable();
     _runningSubmitsHT = Hashtable.Synchronized(ht2);
     _systemSettings = SettingsFactory.CreateSystemSettings();
     _fileSystem = new MoCS.BuildService.Business.FileSystemWrapper();
 }
Exemplo n.º 4
0
        private void Init(SystemSettings sysSettings, SubmitSettings submitSettings, IFileSystem fileSystem)
        {
            _sysSettings = sysSettings;
            _submitSettings = submitSettings;
            _fileSystem = fileSystem;

            OutputDllPath = Path.Combine(_submitSettings.BasePath, _submitSettings.GetDllName());
            SourcesPath = Path.Combine(_submitSettings.BasePath, "*.cs");
            OutputLogPath = Path.Combine(_submitSettings.BasePath, "build.log");
            BatchfileCompilePath = Path.Combine(submitSettings.BasePath, "buildit.bat");

            BatchfileTestPath = Path.Combine(submitSettings.BasePath, "testit.bat");
            NUnitConsolePath = Path.Combine(sysSettings.NunitConsolePath, "nunit-console.exe");
            TestLogPath = Path.Combine(submitSettings.BasePath, "testlog.xml");
        }
Exemplo n.º 5
0
 public BatchFileCreator(SystemSettings sysSettings, SubmitSettings submitSettings, IFileSystem fileSystem)
 {
     Init(sysSettings, submitSettings, fileSystem);
 }
Exemplo n.º 6
0
 public BatchFileCreator(SystemSettings sysSettings, SubmitSettings submitSettings, IFileSystem fileSystem)
 {
     Init(sysSettings, submitSettings, fileSystem);
 }
Exemplo n.º 7
0
        private static void CopyFiles(Assignment assignment, Submit submit, string teamSubmitDirName, SystemSettings systemSettings)
        {
            MoCS.BuildService.Business.FileSystemWrapper fileSystem = new Business.FileSystemWrapper();

            // Copy nunit.framework.dll to this directory
            fileSystem.FileCopy(Path.Combine(systemSettings.NunitAssemblyPath, "nunit.framework.dll"),
                        Path.Combine(teamSubmitDirName, "nunit.framework.dll"), true);

            //copy the file to this directory
            using (Stream target = fileSystem.FileOpenWrite(Path.Combine(teamSubmitDirName, submit.FileName)))
            {
                try
                {
                    target.Write(submit.Data, 0, submit.Data.Length);
                }
                finally
                {
                    target.Flush();
                }
            }

            // Copy the interface file
            //delete the file if it existed already
            AssignmentFile interfaceFile = assignment.AssignmentFiles.Find(af => af.Name == "InterfaceFile");

            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, interfaceFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, interfaceFile.FileName),
                        Path.Combine(teamSubmitDirName, interfaceFile.FileName));

            //copy the server testfile
            //delete the file if it existed already
            AssignmentFile serverTestFile = assignment.AssignmentFiles.Find(af => af.Name == "NunitTestFileServer");

            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, serverTestFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, serverTestFile.FileName),
                        Path.Combine(teamSubmitDirName, serverTestFile.FileName));

            //copy additional serverfiles
            List<AssignmentFile> serverFilesToCopy = assignment.AssignmentFiles.FindAll(af => af.Name == "ServerFileToCopy");
            foreach (AssignmentFile serverFileToCopy in serverFilesToCopy)
            {

                fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, serverFileToCopy.FileName));

                fileSystem.FileCopy(Path.Combine(assignment.Path, serverFileToCopy.FileName),
                            Path.Combine(teamSubmitDirName, serverFileToCopy.FileName));
            }

            //copy the client testfile
            AssignmentFile clientTestFile = assignment.AssignmentFiles.Find(af => af.Name == "NunitTestFileClient");

            //delete the file if it existed already
            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, clientTestFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, clientTestFile.FileName),
                        Path.Combine(teamSubmitDirName, clientTestFile.FileName));
        }
Exemplo n.º 8
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);
        }
Exemplo n.º 9
0
        private static string CreateTeamDirectory(SystemSettings sysSettings, string teamName, Assignment assignment)
        {
            MoCS.BuildService.Business.FileSystemWrapper fileSystem = new Business.FileSystemWrapper();

            string resultBasePath = ConfigurationManager.AppSettings["ResultBasePath"];
            if (!resultBasePath.EndsWith(@"\"))
            {
                resultBasePath += @"\";
            }

            //prepare processing
            //create a new directory for the basepath
            fileSystem.CreateDirectoryIfNotExists(resultBasePath);

            //create a directory for the assignment
            fileSystem.CreateDirectoryIfNotExists(resultBasePath + assignment.Name);

            string teamDirName = teamName + "_" + DateTime.Now.ToString("ddMMyyyy_HHmmss");
            string teamSubmitDirName = resultBasePath + assignment.Name + @"\" + teamDirName;
            //create a new directory for the teamsubmit
            fileSystem.CreateDirectory(teamSubmitDirName);

            return teamSubmitDirName;
        }