public ManifestDocumentAgent(Guid scenarioId)
        {
            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                // Retrieve document usage data for all enabled activities in the specified session
                var activities = (from documentUsage in context.VirtualResourceMetadataDocumentUsages
                                  let data = documentUsage.DocumentSelectionData
                                             let metadata = documentUsage.VirtualResourceMetadata
                                                            let resource = metadata.VirtualResource
                                                                           where resource.EnterpriseScenarioId == scenarioId &&
                                                                           resource.Enabled == true &&
                                                                           metadata.Enabled == true &&
                                                                           data != null
                                                                           select new { Id = metadata.VirtualResourceMetadataId, Documents = data }).ToList();

                foreach (var activity in activities)
                {
                    DocumentSelectionData documentSelectionData = GetSelectionData(activity.Documents);
                    _activityDocuments.Add(activity.Id, GetDocuments(documentSelectionData));
                }
            }

            var documentIds = _activityDocuments.Values.SelectMany(n => n).Distinct().ToList();

            using (DocumentLibraryContext context = DbConnect.DocumentLibraryContext())
            {
                var documents = context.TestDocuments.Where(n => documentIds.Contains(n.TestDocumentId)).ToDocumentCollection();
                _documents.AddRange(documents);
            }
        }
            private static string GetDocumentDisplayString(PluginConfigurationData configurationData)
            {
                DocumentSelectionData documents = configurationData.Documents;

                if (documents != null)
                {
                    switch (documents.SelectionMode)
                    {
                    case DocumentSelectionMode.SpecificDocuments:
                        return(documents?.SelectedDocuments?.Count > 0 ? $"Documents: {documents.SelectedDocuments.Count} documents selected" : null);

                    case DocumentSelectionMode.DocumentSet:
                        return($"Documents: Document Set '{documents.DocumentSetName}' selected");

                    case DocumentSelectionMode.DocumentQuery:
                        return("Documents: Query criteria selection");

                    default:
                        return("Documents: Unknown selection mode");
                    }
                }
                else
                {
                    return(null);
                }
            }
Exemplo n.º 3
0
        /// <summary>
        /// Transforms <see cref="DocumentSelectionData" /> from a <see cref="PluginConfigurationData" /> object into a
        /// corresponding <see cref="DocumentCollection" /> using data from the specified <see cref="IDocumentLibrary" />.
        /// </summary>
        /// <param name="configurationData">The <see cref="PluginConfigurationData" />.</param>
        /// <param name="documentLibrary">The <see cref="IDocumentLibrary" />.</param>
        /// <returns>An <see cref="DocumentCollection" /> object.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="configurationData" /> is null.
        /// <para>or</para>
        /// <paramref name="documentLibrary" /> is null.
        /// </exception>
        public static DocumentCollection GetExecutionDocuments(PluginConfigurationData configurationData, IDocumentLibrary documentLibrary)
        {
            if (configurationData == null)
            {
                throw new ArgumentNullException(nameof(configurationData));
            }

            if (documentLibrary == null)
            {
                throw new ArgumentNullException(nameof(documentLibrary));
            }

            DocumentSelectionData documentSelectionData = configurationData.Documents ?? new DocumentSelectionData();
            DocumentCollection    documents             = null;

            switch (documentSelectionData.SelectionMode)
            {
            case DocumentSelectionMode.SpecificDocuments:
                var selected = documentLibrary.GetDocuments().Where(n => documentSelectionData.SelectedDocuments.Contains(n.DocumentId));
                documents = new DocumentCollection(selected.ToList());
                break;

            case DocumentSelectionMode.DocumentSet:
                var documentSet = documentLibrary.GetDocumentSets().First(n => n.Name == documentSelectionData.DocumentSetName);
                documents = documentSet.Documents;
                break;

            case DocumentSelectionMode.DocumentQuery:
                documents = documentLibrary.GetDocuments(documentSelectionData.DocumentQuery);
                break;
            }

            return(documents);
        }
        public void Initialize(PluginEnvironment environment)
        {
            _activityData          = new PrintQueueManagementActivityData();
            _documentSelectionData = new DocumentSelectionData();

            LoadDocuments();
        }
 /// <summary>
 /// Initializes this configuration control with the specified <see cref="DocumentSelectionData" />.
 /// </summary>
 public void Initialize(DocumentSelectionData docData, PrintQueueSelectionData queueData, int delay, bool shuffle, bool usePrintServerNotification)
 {
     ConfigureControls(delay, shuffle, usePrintServerNotification);
     documentSelectionControl.Initialize(docData);
     LoadPrintQueues(queueData.SelectedPrintQueues);
     RefreshQueueDataGrid();
 }
Exemplo n.º 6
0
 private void simulatorConfiguration_LinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     using (SimulatorConfigurationForm form = new SimulatorConfigurationForm(AutomationPause, UseAdf, AdfDocuments))
     {
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             AutomationPause = form.AutomationPause;
             UseAdf          = form.UseAdf;
             AdfDocuments    = form.AdfDocuments;
         }
     }
 }
Exemplo n.º 7
0
        private static bool ValidateDocumentUsage(VirtualResourceMetadataDocumentUsage docUsage, DocumentLibraryContext context)
        {
            bool result = true;

            if (docUsage != null)
            {
                DocumentSelectionData docSelection = Serializer.Deserialize <DocumentSelectionData>(XElement.Parse(docUsage.DocumentSelectionData));
                foreach (Guid docId in docSelection.SelectedDocuments)
                {
                    result &= context.TestDocuments.Any(d => d.TestDocumentId == docId);
                }
            }
            return(result);
        }
        public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
        {
            _activityData          = configuration?.GetMetadata <PrintQueueManagementActivityData>();
            _documentSelectionData = configuration?.Documents;

            DynamicLocalPrintQueueDefinition definition = configuration?.PrintQueues.SelectedPrintQueues.First() as DynamicLocalPrintQueueDefinition;
            IPrinterInfo printDevice = ConfigurationServices.AssetInventory.GetAsset(definition.AssetId) as IPrinterInfo;

            _printDriver         = ConfigurationServices.AssetInventory.AsInternal().GetPrintDrivers().First(n => n.PrintDriverId == definition.PrintDriverId);
            _localPrintQueueInfo = new DynamicLocalPrintQueueInfo(printDevice, _printDriver, definition.PrinterPort, definition.PrintDriverConfiguration);

            LoadDocuments();
            LoadUi();
        }
        private DocumentIdCollection GetDocuments(DocumentSelectionData documentSelectionData)
        {
            switch (documentSelectionData.SelectionMode)
            {
            case DocumentSelectionMode.SpecificDocuments:
                return(documentSelectionData.SelectedDocuments);

            case DocumentSelectionMode.DocumentSet:
                return(GetDocumentsFromSet(documentSelectionData.DocumentSetName));

            case DocumentSelectionMode.DocumentQuery:
                return(GetDocumentsFromQuery(documentSelectionData.DocumentQuery));

            default:
                return(new DocumentIdCollection());
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SimulatorConfigurationForm" /> class.
        /// </summary>
        /// <param name="automationPause">The automation pause to display.</param>
        /// <param name="useAdf">if set to <c>true</c> select the ADF document option.</param>
        /// <param name="adfDocuments">The ADF documents to select.</param>
        public SimulatorConfigurationForm(TimeSpan automationPause, bool useAdf, DocumentSelectionData adfDocuments)
            : this()
        {
            pause_NumericUpDown.Value   = (int)automationPause.TotalMilliseconds;
            scanAdf_RadioButton.Checked = useAdf;

            var allExtensions = ConfigurationServices.DocumentLibrary.GetExtensions();
            var jpegs         = allExtensions.Where(n => n.FileType.Equals("jpeg", StringComparison.OrdinalIgnoreCase));

            if (adfDocuments != null)
            {
                documentSelectionControl.Initialize(adfDocuments, jpegs);
            }
            else
            {
                documentSelectionControl.Initialize(jpegs);
            }
        }