Пример #1
0
        /// <summary>
        /// Initializes this configuration control with the specified <see cref="PluginConfigurationData" />.
        /// </summary>
        /// <param name="configuration">The configuration data.</param>
        /// <param name="environment">Information about the plugin environment.</param>
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            _activityData            = configuration.GetMetadata <RebootActivityData>();
            _pluginConfigurationData = configuration;

            assetSelectionControl.Initialize(_pluginConfigurationData.Assets, AssetAttributes.ControlPanel);
            paperless_checkBox.Checked = _activityData.SetPaperless;
        }
        /// <summary>
        /// Executes this plugin's workflow using the specified <see cref="PluginExecutionData" />.
        /// </summary>
        /// <param name="executionData">The execution data.</param>
        /// <returns>A <see cref="PluginExecutionResult" /> indicating the outcome of the execution.</returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData     = executionData;
            _activityData      = executionData.GetMetadata <RebootActivityData>();
            _performanceLogger = new DeviceWorkflowLogger(_executionData);

            TimeSpan lockTimeout = TimeSpan.FromMinutes(10);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(60);


            UpdateStatus("Starting activity.");
            if (_executionData.Assets.OfType <IDeviceInfo>().Count() == 0)
            {
                return(new PluginExecutionResult(PluginResult.Failed, $"There were no assets retrieved.  If this is a count-based run, your reservation in asset inventory may have expired.", "DeviceInfo Asset error"));
            }

            PluginExecutionResult result = new PluginExecutionResult(PluginResult.Failed, "Failed to Start Reboot");


            try
            {
                var assetTokens = _executionData.Assets.OfType <IDeviceInfo>().Select(n => new AssetLockToken(n, lockTimeout, holdTimeout));
                _performanceLogger.RecordEvent(DeviceWorkflowMarker.DeviceLockBegin);

                ExecutionServices.CriticalSection.Run(assetTokens, selectedToken =>
                {
                    _performanceLogger.RecordEvent(DeviceWorkflowMarker.ActivityBegin);

                    IDeviceInfo asset = (selectedToken as AssetLockToken).AssetInfo as IDeviceInfo;
                    ExecutionServices.DataLogger.Submit(new ActivityExecutionAssetUsageLog(_executionData, asset));
                    IDevice device = DeviceConstructor.Create(asset);


                    ExecutionServices.SystemTrace.LogInfo($@"Rebooting {asset.AssetId}");
                    UpdateStatus($@"Rebooting {asset.AssetId}");

                    result = RebootDevice(device);


                    //If we rebooted AND we want to set PJL, do so
                    if (_activityData.SetPaperless)
                    {
                        //Wait for WS* to come back up. It's one of the last services
                        WaitForService(device);

                        Thread.Sleep(60000);
                        EnablePJL(device);
                        Thread.Sleep(1000);
                        SetPaperlessPrintMode(true, device);
                    }
                });
            }
            catch (Exception e)
            {
                ExecutionServices.SystemTrace.LogInfo(e);
                UpdateStatus(e.Message);
                result = new PluginExecutionResult(PluginResult.Failed, e.Message);
            }


            UpdateStatus("Finished activity.");
            UpdateStatus($"Result = {result.Result}");

            return(result);
        }
Пример #3
0
        /// <summary>
        /// Initializes this configuration control to default values.
        /// </summary>
        /// <param name="environment">Information about the plugin environment.</param>
        public void Initialize(PluginEnvironment environment)
        {
            _activityData = new RebootActivityData();

            assetSelectionControl.Initialize(AssetAttributes.ControlPanel);
        }