static void RegisterPrinter()
 {
     try
     {
         var client = new GoogleCloudPrintClient(provider, token);
         var pq     = GetSelectedQueue();
         if (pq != null)
         {
             //string capabilities = GetCapabilitiesFromPrintQueue(pq);
             string capabilities = File.ReadAllText("cdd.txt");
             var    request      = new RegisterRequest
             {
                 Name = pq.FullName,
                 DefaultDisplayName = pq.FullName,
                 Proxy        = proxy,
                 Capabilities = capabilities,
                 UseCdd       = true
             };
             var googlePrinter = client.RegisterPrinterAsync(request).Result;
             Console.WriteLine($"Success: {googlePrinter.Success}");
         }
     }
     catch (System.AggregateException ex)
     {
         if (ex.InnerExceptions.Any())
         {
             Console.WriteLine(ex.InnerExceptions.First().Message);
         }
     }
 }
示例#2
0
        public Printer RegisterPrinter(string name)
        {
            var request = new RegisterRequest
            {
                Name         = name,
                Proxy        = Proxy.Value,
                Capabilities = Cdd.Value.ToCapabilities(),
                UseCdd       = true
            };
            var client = new GoogleCloudPrintClient(OAuth2Provider, RefreshToken.Value);

            return(client.RegisterPrinterAsync(request).Result.Printers[0]);
        }
示例#3
0
        private static void RegisterPrinter()
        {
            try
            {
                var client = new GoogleCloudPrintClient(provider, token);
                var pqs    = GetPrintQueues();

                for (int i = 0; i < pqs.Count(); i++)
                {
                    Console.WriteLine("{0}. {1}", i, pqs.ElementAt(i).Key);
                }
                Console.Write("Select 1 printer to register: ");
                int index = Convert.ToInt32(Console.ReadLine());

                var request = new RegisterRequest
                {
                    Name = pqs.ElementAt(index).Key,
                    DefaultDisplayName = pqs.ElementAt(index).Key,
                    Proxy        = proxy,
                    Capabilities = File.ReadAllText(pqs.ElementAt(index).Value),
                    UseCdd       = false
                };

                Console.WriteLine("Prepare to register: {0} to {1}\n{2}", request.Name, request.Proxy, request.Capabilities.Substring(0, 32));
                Console.ReadLine();
                var googlePrinter = client.RegisterPrinterAsync(request).Result;
                Console.WriteLine($"Success: {googlePrinter.Success}");
            }
            catch (System.AggregateException ex)
            {
                if (ex.InnerExceptions.Any())
                {
                    Console.WriteLine(ex.InnerExceptions.First().Message);
                }
            }
        }