Esempio n. 1
0
 public HpacSimulationTask(HpacSimulationController controller, HpacSimulationActivityData activityData, IPrinterInfo device)
     : base()
 {
     _hpacController = controller;
     _taskConfig     = activityData;
     _device         = device;
 }
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            // Initialize the activity data by deserializing it from the configuration information.
            _configData   = configuration;
            _activityData = _configData.GetMetadata <HpacSimulationActivityData>();

            hpac_ServerComboBox.Initialize(_configData.Servers.SelectedServers.FirstOrDefault(), "HPAC");
            assetSelectionControl.Initialize(_configData.Assets, AssetAttributes.Printer);

            // Brute force initialization
            printAll_CheckBox.Checked = _activityData.PullAllDocuments;
            foreach (RadioButton button in authentication_GroupBox.Controls)
            {
                button.Checked = ((HpacAuthenticationMode)button.Tag == _activityData.HpacAuthenticationMode);
            }
        }
        private PluginExecutionResult ExecuteHandler(HpacSimulationActivityData activityData, IPrinterInfo assetInfo)
        {
            HpacSimulationTask hpacSimTask = new HpacSimulationTask(_hpacController, activityData, assetInfo);

            hpacSimTask.StatusUpdate += (s, e) => UpdateStatus(e.StatusMessage);

            try
            {
                hpacSimTask.Execute();
            }
            catch (EmptyQueueException ex)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, ex));
            }
            catch (PullPrintingSimulationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Error, ex));
            }

            return(new PluginExecutionResult(PluginResult.Passed));
        }
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData = executionData;
            HpacSimulationActivityData activityData = _executionData.GetMetadata <HpacSimulationActivityData>();
            PluginExecutionResult      result       = new PluginExecutionResult(PluginResult.Passed);

            IPrinterInfo assetInfo  = null;
            ServerInfo   hpacServer = null;

            try
            {
                assetInfo  = (IPrinterInfo)_executionData.Assets.GetRandom();
                hpacServer = _executionData.Servers.First();
                LogUsageData(assetInfo, hpacServer);
            }
            catch (ArgumentNullException ex)
            {
                return(new PluginExecutionResult(PluginResult.Error, ex));
            }
            catch (InvalidOperationException ex)
            {
                return(new PluginExecutionResult(PluginResult.Error, ex));
            }

            if (_hpacController == null)
            {
                _hpacController = new HpacSimulationController(_executionData.Environment.UserDnsDomain, hpacServer.HostName, _executionData.Credential);
            }

            UpdateUI(hpacServer.HostName, assetInfo.AssetId, activityData.PullAllDocuments);
            UpdateStatus("Starting HPAC Pull Activity...");

            //On error or skip, Implement Retries
            PluginRetryManager retryManager = new PluginRetryManager(_executionData, UpdateStatus);

            result = retryManager.Run(() => ExecuteHandler(activityData, assetInfo));

            return(result);
        }
 public void Initialize(PluginEnvironment environment)
 {
     _activityData = new HpacSimulationActivityData();
     assetSelectionControl.Initialize(AssetAttributes.Printer);
     hpac_ServerComboBox.Initialize("HPAC");
 }