Exemple #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);
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:Galileo.Core.HunterSession"/> class.
        /// </summary>
        /// <param name="profile">The <see cref="T:Galileo.Core.HunterProfile"/> to use for the session.</param>
        /// <param name="HandlerName"><see cref="T:Galileo.Client.HuntHandler"/>'s unique name.</param>
        /// <param name="workingDirectory">The working directory to search for submissions/candidates.</param>
        /// <param name="config">The <see cref="T:Galileo.Core.HunterConfig"/> to use when searching.</param>
        /// <param name="options">A set of options outlining features to use.</param>
        public HunterSession(HunterProfile profile, string HandlerName, string workingDirectory, HunterConfig config, HunterSessionOptions options = HunterSessionOptions.Any)
        {
            Name = HandlerName;

            //// options = options | HunterSessionOptions.Export;

            // Assign references
            _profile = profile;
            _options = options;
            _config  = config;

            // Create the Log.
            if (HasOption(HunterSessionOptions.Logging))
            {
                _log = new Log();
            }
            else
            {
                _log = new NullLog();
            }

            // Create the Analytics
            if (HasOption(HunterSessionOptions.Analytics))
            {
                _analytics = new GoogleAnalytics(profile.PackageVersion, true);
            }
            else
            {
                _analytics = new NullAnalytics();
            }

            // Setup the class variables to their default states
            _resolvedFiles      = new List <string>(1);
            _isAborting         = new AtomicBool(false);
            _isRunning          = new AtomicBool(false);
            _progressPercentage = 0.0f;
            _workUnitsCount     = 0;
            _workUnitsComplete  = 0;
            _processThread      = null;
            _candidates         = new SubmissionCandidates();
            _submissions        = new ConcurrentBag <Submission>();

            // Setup working directory
            SetWorkingDirectory(workingDirectory);


            if (HasOption(HunterSessionOptions.Export))
            {
                _exporter = new ContextExporter.TextFileContentWriter(System.IO.Path.Combine(workingDirectory, HunterConfig.GalileoDefaultDataFolder));
            }
            else
            {
                _exporter = new ContextExporter.NullContentExporter();
            }
        }
Exemple #3
0
        /// <summary>

        /// Does the session have an option enabled

        /// </summary>

        /// <param name="option">The option to check for</param>

        /// <returns></returns>
        public bool HasOption(HunterSessionOptions option)
        {
            return((_options & option) != 0);
        }