示例#1
0
 public EndpointManager(PathManager pathManager, PluginEnvironment environment)
 {
     PathManager  = pathManager;
     _environment = environment;
 }
示例#2
0
        internal void Exercise(DirtyDeviceActivityData activityData, NetworkCredential userCredential, PluginEnvironment environment)
        {
            _activityData   = activityData;
            _userCredential = userCredential;

            string localMachineName    = NetUtil.GetFQDN();
            string fileShareServerName = $"{activityData.DigitalSend.OutputFolder.ServerHostName}.{environment.UserDnsDomain}";
            var    externalFacingProtocolSpecificPath = activityData.DigitalSend.OutputFolder.MonitorLocation;
            var    correspondingSharePath             = $@"\\{fileShareServerName}\{externalFacingProtocolSpecificPath.Replace("/", @"\")}";

            EndpointPath fileSharePath = new EndpointPath(
                DestinationType.NetworkFolder,
                fileShareServerName,
                null,
                externalFacingProtocolSpecificPath,
                correspondingSharePath);

            EndpointPath ftpPath = new EndpointPath(
                DestinationType.Ftp,
                localMachineName,
                null,
                externalFacingProtocolSpecificPath,
                correspondingSharePath);

            EndpointPath httpPath = new EndpointPath(
                DestinationType.Http,
                localMachineName,
                EndpointManager.HttpPort,
                externalFacingProtocolSpecificPath,
                correspondingSharePath);

            var pathManager = new PathManager(fileSharePath, ftpPath, httpPath);

            _endpointManager = new EndpointManager(pathManager, environment);
            _endpointManager.UpdateStatus += (s, e) => _owner.OnUpdateStatus(s, e.StatusMessage);

            // eschew "all inspectable pages are in use" exception
            foreach (var protocol in new[] { DestinationType.Ftp, DestinationType.Http, DestinationType.NetworkFolder })
            {
                for (var attempt = 1; attempt <= MaxRetryCount; attempt++)
                {
                    _owner.OnUpdateStatus(this, $"");
                    _preparationManager.InitializeDevice(true);
                    try
                    {
                        ExecuteScanToDestination(protocol);
                        // If we got this far successfully, we are done.  We do not need to retry.
                        break;
                    }
                    catch (Exception x)
                    {
                        _owner.OnUpdateStatus(this, $"  Digital send failed.  (Device: {_deviceDat.Address}; Protocol: {protocol}; Error: {x.Message})");
                        if (attempt >= MaxRetryCount)
                        {
                            throw;
                        }
                        _owner.OnUpdateStatus(this, $"  Will attempt {MaxRetryCount - attempt} more times.");
                    }
                }
            }
            _owner.OnUpdateStatus(this, string.Empty);
            _preparationManager.InitializeDevice(true);
        }