Пример #1
0
        public RunningResults SelfCheck(DirectoryInfo sandboxDir)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            var imageName      = sandboxDir.Name;
            var srcDirectory   = new DirectoryInfo(Path.GetFullPath(Path.Combine(sandboxDir.FullName, "sample/src/")));
            var zipBytes       = AbstractExerciseBlock.ToZip(srcDirectory, new[] { "node_modules", ".idea" });
            var submissionFile = new FileInfo(Path.GetFullPath(Path.Combine(sandboxDir.FullName, "sample/submission.json")));
            var submission     = JsonConvert.DeserializeObject <CommandRunnerSubmission>(File.ReadAllText(submissionFile.FullName));

            submission.Id              = Utils.NewNormalizedGuid();
            submission.ZipFileData     = zipBytes;
            submission.DockerImageName = imageName;
            var res = sandboxRunner.Run(submission);

            log.Info(res);
            return(res);
        }
Пример #2
0
        public RunningResults SelfCheck(DirectoryInfo sandboxDir)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
            var imageName    = sandboxDir.Name;
            var srcDirectory = new DirectoryInfo(Path.GetFullPath(Path.Combine(sandboxDir.FullName, "sample/src/")));
            var zipBytes     = ZipUtils.CreateZipFromDirectory(new List <string> {
                srcDirectory.FullName
            }, new List <string> {
                "node_modules", ".idea"
            }, null, Encoding.UTF8).ToArray();
            var submissionFile = new FileInfo(Path.GetFullPath(Path.Combine(sandboxDir.FullName, "sample/submission.json")));
            var submission     = JsonConvert.DeserializeObject <CommandRunnerSubmission>(File.ReadAllText(submissionFile.FullName));

            submission.Id              = Utils.NewNormalizedGuid();
            submission.ZipFileData     = zipBytes;
            submission.DockerImageName = imageName;
            var res = sandboxRunner.Run(submission);

            log.Info("SelfCheck result: {Result}", JsonConvert.SerializeObject(res));
            return(res);
        }