Пример #1
0
        /// <summary>
        /// Initializes this configuration control to default values.
        ///
        /// <seealso cref="PluginEnvironment"/>
        /// </summary>
        /// <param name="environment">Information about the plug-in environment.</param>
        public void Initialize(PluginEnvironment environment)
        {
            // Initialize the activity data.
            _data = new DriverlessPrintingActivityData();
            print_assetSelectionControl.Initialize(AssetAttributes.Printer);
            var allExtensions = ConfigurationServices.DocumentLibrary.GetExtensions();
            var prns          = allExtensions.Where(n => n.FileType.Equals("raw", StringComparison.OrdinalIgnoreCase));

            print_documentSelectionControl.Initialize(prns);
        }
Пример #2
0
        /// <summary>
        /// Provides plug-in configuration data for an existing activity, including plug-in
        /// specific metadata, a metadata version, and selections of assets and documents.
        ///
        /// The custom metadata can be retrieved from the configuration using one of the
        /// <c>GetMetadata</c> methods, which return either a deserialized object or the XML. This
        /// data is then used to populate the configuration control. Asset and Document information
        /// can be retrieved using <see cref="ConfigurationServices"/>. The metadata version is
        /// included for forwards compatibility.
        ///
        /// <seealso cref="ConfigurationServices"/>
        /// </summary>
        /// <param name="configuration">The configuration data.</param>
        /// <param name="environment">Information about the plug-in environment.</param>
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            // Initialize the activity data by deserializing it from an existing copy of the
            // configuration information.
            _data = configuration.GetMetadata <DriverlessPrintingActivityData>();
            var allExtensions = ConfigurationServices.DocumentLibrary.GetExtensions();
            var prns          = allExtensions.Where(n => n.FileType.Equals("raw", StringComparison.OrdinalIgnoreCase));

            print_assetSelectionControl.Initialize(configuration.Assets, AssetAttributes.Printer);
            print_documentSelectionControl.Initialize(configuration.Documents, prns);
            printProtocol_comboBox.SelectedItem = _data.PrintMethod;
            shuffle_CheckBox.Checked            = _data.ShuffleDocuments;
            jobseparator_checkBox.Checked       = _data.PrintJobSeparator;
            jobStorage_checkBox.Checked         = _data.PinProtected;
            pin_numericUpDown.Value             = _data.Pin < 1000 ? 1000 : _data.Pin;
        }
Пример #3
0
        /// <summary>
        /// This method should return a new <see cref="PluginConfigurationData"/> object containing
        /// all the configuration from the control. (This is the same object used in Initialize.)
        /// Custom metadata is passed into the constructor, either as XML or an object that will be
        /// serialized. The metadata version can be set to any value other than null.
        ///
        /// Selection data for assets and documents is set using the Assets and Documents
        /// properties. Plug-ins that will not make use of Assets and/or Documents can ignore these
        /// properties.
        ///
        /// <seealso cref="PluginConfigurationData"/>
        /// </summary>
        /// <returns>The configuration data.</returns>
        public PluginConfigurationData GetConfiguration()
        {
            _data = new DriverlessPrintingActivityData()
            {
                PrintJobSeparator = jobseparator_checkBox.Checked,
                ShuffleDocuments  = shuffle_CheckBox.Checked,
                PrintMethod       = (PrintMethod)printProtocol_comboBox.SelectedItem,
                PinProtected      = jobStorage_checkBox.Checked,
                Pin = (int)pin_numericUpDown.Value
            };

            return(new PluginConfigurationData(_data, "1.0")
            {
                Assets = print_assetSelectionControl.AssetSelectionData,
                Documents = print_documentSelectionControl.DocumentSelectionData
            });
        }
Пример #4
0
        /// <summary>
        /// Executes this plug-in'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;
            _performanceLogger = new DeviceWorkflowLogger(_executionData);
            _activityData      = _executionData.GetMetadata <DriverlessPrintingActivityData>();
            var printer = executionData.Assets.OfType <PrintDeviceInfo>().FirstOrDefault();

            if (printer == null)
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "No assets available for execution."));
            }
            if (!printer.Attributes.HasFlag(AssetAttributes.Printer))
            {
                return(new PluginExecutionResult(PluginResult.Skipped, "The device has no print capability."));
            }
            var address = printer.Address;

            var iteratorMode = _activityData.ShuffleDocuments
                ? CollectionSelectorMode.ShuffledRoundRobin
                : CollectionSelectorMode.Random;
            var      documentIterator = new DocumentCollectionIterator(iteratorMode);
            var      document         = documentIterator.GetNext(executionData.Documents);
            FileInfo localFile        = ExecutionServices.FileRepository.GetFile(document);

            if (_activityData.PinProtected)
            {
                AddPinProtection(localFile, _activityData.Pin);
            }

            if (_activityData.PrintMethod == PrintMethod.Random)
            {
                Random newRandom = new Random(4);
                var    randomInt = newRandom.Next(0, 999) % 4;
                _activityData.PrintMethod = (PrintMethod)randomInt;
            }

            _performanceLogger.RecordEvent(DeviceWorkflowMarker.PrintJobBegin);
            UpdateStatus($"Printing {document.FileName} via {_activityData.PrintMethod}.");
            switch (_activityData.PrintMethod)
            {
            default:
                Print9100(address, localFile);
                break;

            case PrintMethod.Ftp:
                PrintFtp(address, "admin", printer.AdminPassword, localFile, true);
                break;

            case PrintMethod.Ipp:
                PrintIpp(address, localFile);
                break;

            case PrintMethod.Ews:
                PrintEws(address, printer.AdminPassword, localFile);
                break;
            }
            _performanceLogger.RecordEvent(DeviceWorkflowMarker.PrintJobEnd);
            _performanceLogger.RecordExecutionDetail(DeviceWorkflowMarker.PrintJobEnd, _activityData.PrintMethod.ToString());
            ActivityExecutionDocumentUsageLog documentLog = new ActivityExecutionDocumentUsageLog(executionData, document);

            ExecutionServices.DataLogger.Submit(documentLog);

            if (_activityData.PrintJobSeparator)
            {
                UpdateStatus("Printing Job Separator.");
                PrintJobSeparator(address);
            }
            localFile.Delete();
            return(_result);
        }