Exemplo n.º 1
0
        /// <summary>
        /// Validates the given metadata against the DeviceInspector Activity data.
        /// </summary>
        /// <param name="configurationData">The configuration data.</param>
        /// <returns>true if valid</returns>
        public bool ValidateMetadata(ref PluginConfigurationData configurationData)
        {
            bool validData = true;
            DeviceInspectorActivityData activityData = null;

            try
            {
                activityData = configurationData.GetMetadata <DeviceInspectorActivityData>();
            }
            catch
            {
                activityData = new DeviceInspectorActivityData();
                validData    = false;
            }

            configurationData = new PluginConfigurationData(activityData, DeviceInspectorConfigurationControl.Version);

            return(validData);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes the configuration control with the specified settings.
        /// </summary>
        /// <param name="configuration"></param>
        /// <param name="environment"></param>
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            _data = configuration.GetMetadata <DeviceInspectorActivityData>();

            assetSelectionControl.Initialize(configuration.Assets, Framework.Assets.AssetAttributes.None);

            //DefaultSetupData
            enablePassword_CheckBox.Checked = _data.EnableDefaultPW;

            //GeneralSettingsData
            var gendata = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(GeneralSettingsData));

            if (gendata != null)
            {
                generalSettingsControl.SetControl(_data.ComponentData); //Alternatively just sending gendata
            }
            var emailData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(EmailSettingsData));

            if (emailData != null)
            {
                emailSettingsControl.SetControl(_data.ComponentData);
            }
            var passWinData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(PasswordWindowsData));

            if (passWinData != null)
            {
                passwordWindowsControl.SetControl(_data.ComponentData);
            }
            var quickSetData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(QuickSetSettingsData));

            if (quickSetData != null)
            {
                quickSetControl.SetControl(_data.ComponentData);
            }

            var copyData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(CopySettingsData));

            if (copyData != null)
            {
                copyDefaultControl.SetControl(_data.ComponentData);
            }

            var printData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(PrintSettingsData));

            if (printData != null)
            {
                printDefaultControl.SetControl(_data.ComponentData);
            }

            var faxData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(FaxSettingsData));

            if (faxData != null)
            {
                faxDefaultControl.SetControl(_data.ComponentData);
            }

            var folderData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(FolderSettingsData));

            if (folderData != null)
            {
                folderDefaultControl.SetControl(_data.ComponentData);
            }

            var scanUsbData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(ScanUsbSettingData));

            if (scanUsbData != null)
            {
                scanToUsbDefaultControl.SetControl(_data.ComponentData);
            }

            var jobData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(JobSettingsData));

            if (jobData != null)
            {
                jobStorageDefaultControl.SetControl(_data.ComponentData);
            }

            var protocolData = _data.ComponentData.FirstOrDefault(x => x.GetType() == typeof(ProtocolSettingsData));

            if (protocolData != null)
            {
                protocolDefaultControl.SetControl(_data.ComponentData);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Execute the task of the DeviceConfiguration activity.
        /// </summary>
        /// <param name="executionData"></param>
        /// <returns></returns>
        public PluginExecutionResult Execute(PluginExecutionData executionData)
        {
            _executionData = executionData;
            _activityData  = executionData.GetMetadata <DeviceInspectorActivityData>();
            TimeSpan lockTimeout = TimeSpan.FromMinutes(5);
            TimeSpan holdTimeout = TimeSpan.FromMinutes(5);
            ConcurrentDictionary <string, DataPair <string> > verifiedResults = new ConcurrentDictionary <string, DataPair <string> >();

            if (!_executionData.Assets.OfType <IDeviceInfo>().Any())
            {
                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"));
            }

            ExecutionServices.SystemTrace.LogDebug("Beginning Update");

            try
            {
                //Parallel.ForEach(_executionData.Assets.OfType<IDeviceInfo>(),asset =>
                foreach (var asset in _executionData.Assets.OfType <IDeviceInfo>())
                {
                    JediDevice device = null;
                    try
                    {
                        try
                        {
                            device = DeviceConstructor.Create(asset) as JediDevice;
                        }
                        catch
                        {
                            device = DeviceFactory.Create(asset.Address) as JediDevice;
                        }

                        // Make sure the device is in a good state
                        var devicePrepManager = DevicePreparationManagerFactory.Create(device);
                        try
                        {
                            devicePrepManager.InitializeDevice(true);
                        }
                        catch (WebInspectorException webInspectorException)
                        {
                            //let's ignore initialise device errors, this might be due to inspection page in use,
                            //since we are not doing any control panel action, this should be ok
                            ExecutionServices.SystemTrace.LogDebug(webInspectorException.Message);
                        }


                        ExecutionServices.SystemTrace.LogDebug(
                            $"Processing {asset.AssetId} on thread {Thread.CurrentThread}");

                        AssetLockToken assetToken = new AssetLockToken(asset, lockTimeout, holdTimeout);

                        ExecutionServices.CriticalSection.Run(assetToken, () =>
                        {
                            ExecutionServices.SystemTrace.LogDebug(
                                $"Performing update on device {asset.AssetId} at address {asset.Address}");
                            var verifiedResult = UpdateDevice(device, asset);
                            verifiedResults.AddOrUpdate(asset.AssetId, verifiedResult, (key, oldvalue) => UpdateDevice(device, asset));
                        });
                    }
                    catch (DeviceCommunicationException deviceCommunicationException)
                    {
                        ExecutionServices.SystemTrace.LogDebug($"Unable to communicate with the device: {deviceCommunicationException.Message}");
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Device Communication", Value = false
                        },
                                                    (s, pair) => new DataPair <string>()
                        {
                            Key = "Device Communication", Value = false
                        });
                        device?.Dispose();
                    }
                    catch (Exception e)
                    {
                        ExecutionServices.SystemTrace.LogDebug(e);
                        verifiedResults.AddOrUpdate(asset.AssetId,
                                                    new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        },
                                                    (s, pair) => new DataPair <string> {
                            Key = "Failed Settings", Value = false
                        });
                        device?.Dispose();
                    }
                }
            }
            catch
            {
                return(new PluginExecutionResult(PluginResult.Error, "Error during Device Configuration Setup"));
            }

            foreach (var verifiedResult in verifiedResults)
            {
                UpdateStatus($"Device: {verifiedResult.Key} Result: {verifiedResult.Value.Value}, {verifiedResult.Value.Key}");
            }

            if (verifiedResults.Any(x => x.Value.Value == false))
            {
                return(new PluginExecutionResult(PluginResult.Failed));
            }


            return(new PluginExecutionResult(PluginResult.Passed));
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes the configuration control with default settings.
        /// </summary>
        /// <param name="environment"></param>
        public void Initialize(PluginEnvironment environment)
        {
            _data = new DeviceInspectorActivityData();

            assetSelectionControl.Initialize(Framework.Assets.AssetAttributes.None);
        }