Пример #1
0
        public HuntHandler(string id, HunterProfile profile, string targetPath)
        {
            // Assign parameters
            _cachedProfile = profile;
            ID             = id;

            // Default properties
            Log = new ConcurrentBag <string>();

            HunterSessionOptions sessionOptions = 0;

            // Establish default set of options
            sessionOptions |= HunterSessionOptions.Events;
            sessionOptions |= HunterSessionOptions.Logging;
            sessionOptions |= HunterSessionOptions.Progress;
            sessionOptions |= HunterSessionOptions.Threaded;
            sessionOptions |= HunterSessionOptions.Analytics;


            // Create new session
            _session = new HunterSession(profile, ID, targetPath, Settings.DefaultConfig, sessionOptions);

            // Subscribe to events
            _session.OnComplete += OnComplete;
            _session.OnProcess  += OnProcess;
            _session.Log.AddLogEventHandler(OnLogEvent);
        }
Пример #2
0
        /// <summary>

        /// Try and create a submission based on the current candidate, it will only do

        /// this if the following conditions are met.

        ///     - Has to be resolved through the Resolve function

        ///     - Not a Directory

        ///     - Not an Archive

        ///     - Is a supported Submission file

        ///     - Not an unknown file type

        /// If the file is in an archive it may be uncompressed to a temporary folder

        /// for reading.

        /// </summary>

        /// <param name="session">The current session</param>

        /// <param name="submission">The a reference to the submission to return as</param>

        /// <returns></returns>
        public bool TryCreateSubmission(HunterSession session, out Submission submission)
        {
            // If we were unable to resolve, if its a directory, if its an archive, if its not a valid submission,
            // or if we just dont know the file type (unsupported), don't even bother.
            if (IsResolved == false || IsDirectory || IsArchive || !IsSubmission || FileType.Kind == FileKind.Unknown)
            {
                submission = null;
                return(false);
            }

            // @TODO Resolve if in archive
            if (IsArchivedFile)
            {
                if (Parent.IsExported == false)
                {
                    Parent.ExportFile(session.WorkingDirectory, false, session.Config.ProcessArchivesExtractOnlySubmissions);
                }

                ExportFile(Parent.ReadPath);
            }
            else
            {
                ExportFile(session.WorkingDirectory);
            }

            submission = new Submission(session, this);

            return(true);
        }
Пример #3
0
        internal Layout(HunterSession hunter, string title = "Galileo Report")
        {
            _session = hunter;

            // Reference the submissions differently
            foreach (Submissions.Submission s in _session.Submissions)
            {
                Submissions.Add(s.GUID, s);
            }

            // Create our head
            _headerComponent     = new HTML.Components.HeaderComponent(_session.Config.ProcessReportEmbedResources, title);
            _navbarComponent     = new HTML.Components.Navbar(_session.Profile.PackageVersion);
            _backgroundComponent = new HTML.Components.BackgroundComponent();

            _overviewSection    = new HTML.Sections.OverviewSection(_session, Submissions);
            _submissionsSection = new HTML.Sections.SubmissionsSection(_session, Submissions);
            _settingsSection    = new HTML.Sections.SettingsSection(_session.Config);

            // Create our tail section
            _copyrightComponent = new HTML.Components.CopyrightComponent();
            _customJSComponent  = new HTML.Components.CustomJavascriptComponent(_session.Config.ProcessReportEmbedResources);
            _customCSSComponent = new HTML.Components.CustomStylesheetComponent();
            _footerComponent    = new HTML.Components.FooterComponent();
        }
Пример #4
0
        /// <summary>

        /// Submission constructor

        /// </summary>

        /// <param name="session">Current session</param>

        /// <param name="candidate">Candidate to work with</param>
        internal Submission(HunterSession session, SubmissionCandidate candidate)
        {
            // Assign references
            _session   = session;
            _candidate = candidate;

            // Assign Defaults
            FirstName           = string.Empty;
            LastName            = string.Empty;
            StudentID           = string.Empty;
            ContentLength       = 0;
            ContentHash         = string.Empty;
            Content             = string.Empty;
            MetaLastModifiedBy  = string.Empty;
            MetaCreator         = string.Empty;
            MetaUsername        = string.Empty;
            MetaDateLastPrinted = DateTime.MinValue;
            MetaDateModified    = DateTime.MinValue;
            MetaDateCreated     = DateTime.MinValue;

            // Create our relative path based on the working directory (just remove it and add a directory character)
            _relativePath = AbsolutePath.Replace(session.WorkingDirectory, string.Empty);

            DetectName();

            // Figure out the processor
            _processor = candidate.FileType.CreateProcessor(this);

            // Do a quick check of the meta data filling out some of our details
            if (Processor != null)
            {
                Processor.Process();
            }

            // Check Processor
            if (!Processor.IsProcessed())
            {
                _session.Log.Add("- " + Markdown.Emphasis("Unable to process this submission. Please confirm that it is a supported file type."));
            }

            // Create Checks
            _checks = CheckFactory.CreateChecks(this, Processor.GetCheckTypes());



            // Create simple ID

            _guidHash = Core.Compare.Hash(_candidate.Guid.ToString()).Substring(0, 6);
        }
Пример #5
0
        internal OverviewSection(HunterSession session, Dictionary <Guid, Submissions.Submission> sortedSubmissions)
        {
            _session     = session;
            _submissions = sortedSubmissions;

            StringBuilder layout = new StringBuilder();

            layout.Append(CreateHeader());

            layout.Append(CreateSubmissionSummary());
            layout.Append(CreateCheckSummary());
            layout.Append(CreateDisabledChecksSummary());

            layout.Append(CreateFooter());

            _cache = layout.ToString();
        }
Пример #6
0
        internal SubmissionsSection(HunterSession session, Dictionary <Guid, Submissions.Submission> sortedSubmissions)
        {
            _session     = session;
            _submissions = sortedSubmissions;

            StringBuilder layout = new StringBuilder();

            layout.Append(CreateHeader());

            foreach (KeyValuePair <Guid, Submissions.Submission> s in sortedSubmissions)
            {
                if (s.Value.Processed)
                {
                    layout.Append(CreateSubmission(s.Value));
                }
            }
            layout.Append(CreateFooter());

            _cache = layout.ToString();
        }