private void GetNewResource()
        {
            string newResourceId = string.Empty;
            string serverName    = string.Empty;

            //using (AssetSelectionForm form = new AssetSelectionForm(DeviceCapabilities.Print))
            using (RemotePrintQueueSelectionForm form = new RemotePrintQueueSelectionForm(false))
            {
                //form.MultiSelect = false;
                form.ShowDialog(this);
                if (form.DialogResult == DialogResult.OK)
                {
                    var temp = form.SelectedPrintQueues.FirstOrDefault();
                    RemotePrintQueueInfo info = ((RemotePrintQueueInfo)temp);
                    //resourceId = form.SelectedPrintQueues.FirstOrDefault().QueueName;
                    //serverName = form.SelectedPrintQueues.FirstOrDefault();
                    newResourceId = info.QueueName;
                    serverName    = info.ServerHostName;


                    //newResourceId = form.SelectedPrintQueues.FirstOrDefault().QueueName;
                    BulkPrintQueueUpdate(newResourceId, serverName);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Constructs the full printer name for the specified <see cref="RemotePrintQueueInfo" />.
        /// </summary>
        /// <param name="queueInfo">The <see cref="RemotePrintQueueInfo" /> object.</param>
        /// <returns>The full printer name for the specified <see cref="RemotePrintQueueInfo" />.</returns>
        public static string GetPrinterName(this RemotePrintQueueInfo queueInfo)
        {
            if (queueInfo == null)
            {
                throw new ArgumentNullException(nameof(queueInfo));
            }

            return(string.Format(@"\\{0}\{1}", queueInfo.ServerHostName, queueInfo.QueueName));
        }
Beispiel #3
0
        private static void LogServer(PluginExecutionData executionData, PrintQueueInfo printQueue)
        {
            RemotePrintQueueInfo remoteQueue = printQueue as RemotePrintQueueInfo;

            if (remoteQueue != null)
            {
                var log = new ActivityExecutionServerUsageLog(executionData, remoteQueue.ServerHostName);
                ExecutionServices.DataLogger.Submit(log);
            }
        }
Beispiel #4
0
 /// <summary>
 /// Set the selected asset.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Email_ComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (email_ComboBox.SelectedItem != null)
     {
         RemotePrintQueueInfo printQueue = (RemotePrintQueueInfo)email_ComboBox.SelectedItem;
         _selectedAsset      = ConfigurationServices.AssetInventory.GetAsset(printQueue.AssociatedAssetId);
         device_TextBox.Text = printQueue.AssociatedAssetId;
     }
     OnConfigurationChanged(sender, e);
 }
            public PrintQueueRow(PrintQueueInfo queue)
            {
                QueueName   = queue.QueueName;
                PrintServer = "Client";
                QueueType   = "Local";
                Device      = queue.AssociatedAssetId;

                RemotePrintQueueInfo remoteQueue = queue as RemotePrintQueueInfo;

                if (remoteQueue != null)
                {
                    PrintServer = remoteQueue.ServerHostName;
                    QueueType   = "Remote";
                }
            }
        /// <summary>
        /// Retrieves <see cref="RemotePrintQueueInfo" /> for all remote print queues in the inventory.
        /// </summary>
        /// <returns><see cref="RemotePrintQueueInfo" /> for all remote print queues in the inventory.</returns>
        public IEnumerable <RemotePrintQueueInfo> GetRemotePrintQueues()
        {
            List <RemotePrintQueueInfo> printQueues = new List <RemotePrintQueueInfo>();
            ServerInfoCollection        servers     = GetServers();

            DatabaseQuery(Resources.SelectPrintQueues, record =>
            {
                RemotePrintQueueInfo printQueueInfo = new RemotePrintQueueInfo
                                                      (
                    (Guid)record["RemotePrintQueueId"],
                    record["Name"] as string,
                    servers.First(n => n.ServerId == (Guid)record["PrintServerId"]),
                    record["AssociatedAssetId"] as string
                                                      );
                printQueues.Add(printQueueInfo);
            });

            return(printQueues);
        }
        private void EditBlank_Button_Click(object sender, EventArgs e)
        {
            string resourceId = string.Empty;
            string serverName = string.Empty;

            using (RemotePrintQueueSelectionForm form = new RemotePrintQueueSelectionForm(false))
            {
                form.ShowDialog(this);
                if (form.DialogResult == DialogResult.OK)
                {
                    var temp = form.SelectedPrintQueues.FirstOrDefault();
                    RemotePrintQueueInfo info = ((RemotePrintQueueInfo)temp);
                    //resourceId = form.SelectedPrintQueues.FirstOrDefault().QueueName;
                    //serverName = form.SelectedPrintQueues.FirstOrDefault();
                    resourceId = info.QueueName;
                    serverName = info.ServerHostName;
                    UpdateBlankPrintQueues(resourceId, serverName);
                }
                form.Refresh();
            }
        }
Beispiel #8
0
            public PrintQueueRow(PrintQueueInfo queue)
            {
                QueueName   = queue.QueueName;
                PrintServer = "Client";
                QueueType   = "Local";
                Device      = queue.AssociatedAssetId;

                RemotePrintQueueInfo remoteQueue = queue as RemotePrintQueueInfo;

                if (remoteQueue != null)
                {
                    PrintServer = remoteQueue.ServerHostName;
                    QueueType   = "Remote";
                }

                DynamicLocalPrintQueueInfo dynamicLocalQueue = queue as DynamicLocalPrintQueueInfo;

                if (dynamicLocalQueue != null)
                {
                    QueueName = string.Format("{0}\\{1} on {2}", dynamicLocalQueue.PrintDriver.PackageName, dynamicLocalQueue.PrintDriver.DriverName, dynamicLocalQueue.AssociatedAssetId);
                }
            }
Beispiel #9
0
 /// <summary>
 /// Removes the specified print queue from the inventory.
 /// </summary>
 /// <param name="printQueue">The print queue to remove from the inventory.</param>
 public void RemoveRemotePrintQueue(RemotePrintQueueInfo printQueue) => _printQueues.Remove(printQueue);
Beispiel #10
0
 /// <summary>
 /// Adds the specified print queue to the inventory.
 /// </summary>
 /// <param name="printQueue">The print queue to add to the inventory.</param>
 public void AddRemotePrintQueue(RemotePrintQueueInfo printQueue) => _printQueues.Add(printQueue);
Beispiel #11
0
        private static PrintQueue GetCitrixPrintQueue(PrintQueueInfo printQueueInfo)
        {
            // Special handling for Citrix session queues - they are connections to a remote server,
            // but don't show up when querying the local server for a list of queues.
            // Connect to the queue directly by parsing the queue name
            LocalPrintQueueInfo localPrintQueueInfo = printQueueInfo as LocalPrintQueueInfo;

            if (localPrintQueueInfo != null)
            {
                LogDebug("Attempting to parse Citrix session queue.");
                var match = Regex.Match(localPrintQueueInfo.QueueName, @"^\\\\([\S\s]+)\\([\S\s]+)$");
                if (match.Success)
                {
                    LogDebug("Parse success.");
                    var serverName = match.Groups[1];
                    var queueName  = match.Groups[2];

                    LogDebug($"Server Name: {serverName}");
                    LogDebug($"Queue Name: {queueName}");

                    PrintServer server = new PrintServer($@"\\{serverName}");
                    return(new PrintQueue(server, localPrintQueueInfo.QueueName));
                }
                else
                {
                    LogDebug("Parse failure.");
                }
            }

            // When Citrix auto-generates a print queue on the Citrix server, it creates a queue with the
            // same name as the local print queue on the client machine, but appends some session information
            // to the end.  To find the real name of the print queue on the Citrix server, we need to
            // find a print queue installed on the system that starts with the same text generated by the base class.
            LogDebug($"Looking for {printQueueInfo.QueueName}");

            List <string> queueNames = PrintQueueController.GetPrintQueues().Select(n => n.FullName).ToList();
            string        clientName = Environment.GetEnvironmentVariable("CLIENTNAME");

            RemotePrintQueueInfo remotePrintQueueInfo = printQueueInfo as RemotePrintQueueInfo;

            if (remotePrintQueueInfo != null)
            {
                string citrixQueueName = queueNames.FirstOrDefault(
                    n => n.StartsWith(remotePrintQueueInfo.QueueName, StringComparison.OrdinalIgnoreCase) &&
                    n.Contains(remotePrintQueueInfo.ServerHostName, StringComparison.OrdinalIgnoreCase) &&
                    n.Contains(clientName, StringComparison.OrdinalIgnoreCase));

                if (citrixQueueName != null)
                {
                    LogDebug($"Found Citrix queue {citrixQueueName}");
                    return(PrintQueueController.GetPrintQueue(citrixQueueName));
                }
                else
                {
                    LogDebug($"Did not find mapped queue.  Looking for directly attached queue.");
                    return(PrintQueueController.GetPrintQueue(remotePrintQueueInfo.GetPrinterName()));
                }
            }

            DynamicLocalPrintQueueInfo dynamicPrintQueueInfo = printQueueInfo as DynamicLocalPrintQueueInfo;

            if (dynamicPrintQueueInfo != null)
            {
                string citrixQueueName = queueNames.FirstOrDefault(
                    n => n.StartsWith(dynamicPrintQueueInfo.QueueName, StringComparison.OrdinalIgnoreCase) &&
                    n.Contains(clientName, StringComparison.OrdinalIgnoreCase));
                if (citrixQueueName != null)
                {
                    LogDebug($"Found Citrix queue {citrixQueueName}");
                    return(PrintQueueController.GetPrintQueue(citrixQueueName));
                }
                else
                {
                    throw new PrintQueueNotFoundException($"Could not find mapped queue for {dynamicPrintQueueInfo.QueueName}");
                }
            }

            // Default to the usual behavior
            return(PrintQueueController.Connect(printQueueInfo));
        }