private static void DeletePrinter()
        {
            var client      = new GoogleCloudPrintClient(provider, token);
            var listRequest = new ListRequest {
                Proxy = proxy
            };
            var listResponse = client.ListPrinterAsync(listRequest).Result;

            if (listResponse.Printers != null && listResponse.Printers.Any())
            {
                for (int i = 0; i < listResponse.Printers.Count(); i++)
                {
                    Console.WriteLine($"{i + 1}. {listResponse.Printers.ElementAt(i).DisplayName}");
                }
                Console.Write("Please choose a printer to delete: ");
                int option = -1;
                if (int.TryParse(Console.ReadLine(), out option))
                {
                    var printer       = listResponse.Printers.ElementAt(option - 1);
                    var deleteRequest = new DeleteRequest {
                        PrinterId = printer.Id
                    };
                    var deleteResponse = client.DeletePrinterAsync(deleteRequest).Result;
                    Console.WriteLine($"Delete: {deleteResponse.Success}");
                }
            }
            else
            {
                Console.WriteLine("There is no printer to delete!");
            }
        }
Beispiel #2
0
        public bool DeletePrinter(string printerId)
        {
            var request = new DeleteRequest
            {
                PrinterId = printerId
            };
            var client = new GoogleCloudPrintClient(OAuth2Provider, RefreshToken.Value);

            return(client.DeletePrinterAsync(request).Result.Success);
        }
Beispiel #3
0
        public void Cleanup()
        {
            // Cleanup the environment
            var listRequest = new ListRequest {
                Proxy = Proxy.Value
            };
            var client = new GoogleCloudPrintClient(OAuth2Provider, RefreshToken.Value);
            var lists  = client.ListPrinterAsync(listRequest).Result;

            foreach (var p in lists.Printers)
            {
                var deleteRequest = new DeleteRequest {
                    PrinterId = p.Id
                };
                var success = client.DeletePrinterAsync(deleteRequest).Result;
            }
        }