Пример #1
0
        PluginExecutionData IPluginFrameworkSimulator.CreateExecutionData(PluginConfigurationData configurationData)
        {
            if (configurationData == null)
            {
                throw new ArgumentNullException(nameof(configurationData));
            }

            PluginExecutionContext executionContext = new PluginExecutionContext
            {
                ActivityExecutionId = SequentialGuid.NewGuid(),
                SessionId           = SessionId,
                UserName            = UserName,
                UserPassword        = UserPassword
            };

            // Retrieve all selected assets, then add any badge boxes associated with those assets
            var selectedAssets = PluginConfigurationTransformer.GetExecutionAssets(configurationData, _assetInventory);
            var badgeBoxes     = _assetInventory.GetBadgeBoxes(selectedAssets);
            AssetInfoCollection executionAssets = new AssetInfoCollection(selectedAssets.Union(badgeBoxes).ToList());

            // Set job media mode
            if (PaperlessMode != JobMediaMode.Unknown)
            {
                foreach (DeviceInfo deviceInfo in selectedAssets.Where(n => n.Attributes.HasFlag(AssetAttributes.Printer)))
                {
                    using (var device = DeviceConstructor.Create(deviceInfo))
                    {
                        try
                        {
                            DeviceSettingsManagerFactory.Create(device).SetJobMediaMode(PaperlessMode);
                        }
                        catch
                        {
                            //Did not set paperless mode.  Ignore error.
                            System.Diagnostics.Debug.WriteLine($"Error setting paperless mode.  {executionAssets.ToString()}");
                        }
                    }
                }
            }

            return(new PluginExecutionData
                   (
                       configurationData.GetMetadata(),
                       configurationData.MetadataVersion,
                       executionAssets,
                       PluginConfigurationTransformer.GetExecutionDocuments(configurationData, _documentLibrary),
                       PluginConfigurationTransformer.GetExecutionServers(configurationData, _assetInventory),
                       PluginConfigurationTransformer.GetExecutionPrintQueues(configurationData, _assetInventory),
                       (this as IPluginFrameworkSimulator).Environment,
                       executionContext,
                       new PluginRetrySettingDictionary(RetrySettings),
                       new ExternalCredentialInfoCollection(_assetInventory.GetExternalCredentials(executionContext.UserName))
                   ));
        }
Пример #2
0
        PluginExecutionData IPluginFrameworkSimulator.CreateExecutionData(PluginConfigurationData configurationData)
        {
            if (configurationData == null)
            {
                throw new ArgumentNullException(nameof(configurationData));
            }

            PluginExecutionContext executionContext = new PluginExecutionContext
            {
                ActivityExecutionId = SequentialGuid.NewGuid(),
                SessionId           = SessionId,
                UserName            = UserName,
                UserPassword        = UserPassword
            };

            // Retrieve all selected assets, then add any badge boxes associated with those assets
            var selectedAssets = PluginConfigurationTransformer.GetExecutionAssets(configurationData, _assetInventory);
            var badgeBoxes     = GetBadgeBoxes(selectedAssets);
            AssetInfoCollection executionAssets = new AssetInfoCollection(selectedAssets.Union(badgeBoxes).ToList());

            foreach (DeviceInfo ai in selectedAssets)
            {
                string          ip = ai.Address;
                AssetAttributes aa = ai.Attributes;

                if (aa.HasFlag(AssetAttributes.Printer))
                {
                    SetPaperlessPrintMode(ai.Address, ai.AdminPassword);
                }
            }

            return(new PluginExecutionData
                   (
                       configurationData.GetMetadata(),
                       configurationData.MetadataVersion,
                       executionAssets,
                       PluginConfigurationTransformer.GetExecutionDocuments(configurationData, _documentLibrary),
                       PluginConfigurationTransformer.GetExecutionServers(configurationData, _assetInventory),
                       PluginConfigurationTransformer.GetExecutionPrintQueues(configurationData, _assetInventory),
                       (this as IPluginFrameworkSimulator).Environment,
                       executionContext,
                       new PluginRetrySettingDictionary(RetrySettings)
                   ));
        }