Esempio n. 1
0
        static void Main(string[] args)
        {
            NetTcpBinding binding = new NetTcpBinding();
            string        address = "net.tcp://localhost:9999/WCFService";

            using (WCFClient proxy = new WCFClient(binding, new EndpointAddress(new Uri(address))))
            {
                proxy.AddDB();
                proxy.ModifyDB(9);
                proxy.DeleteEntityDB();
                proxy.DeleteDB();
                proxy.GetBill();
            }

            Console.ReadLine();
        }
Esempio n. 2
0
        // TODO:
        public static void Menu(WCFClient proxy)
        {
            while (true)
            {
                Console.Clear();
                Console.WriteLine("1. GetBill.");
                Console.WriteLine("2. ModifyID.");
                Console.WriteLine("3. ModifyReading.");
                Console.WriteLine("4. DeleteEntity.");
                Console.WriteLine("5. DeleteDB.");
                Console.WriteLine("6. AddDB.");
                Console.WriteLine("-----------------------");
                Console.Write("Enter your choice: ");

                int choice = 0;
                if (!int.TryParse(Console.ReadLine(), out choice))
                {
                    continue;
                }
                int    id = 0, newID = 0;
                double newReading = 0;

                switch (choice)
                {
                case 1:
                    Console.Write("Enter ID: ");
                    if (int.TryParse(Console.ReadLine(), out id))
                    {
                        proxy.GetBill(id);
                    }
                    break;

                case 2:
                    Console.Write("Enter ID: ");
                    if (int.TryParse(Console.ReadLine(), out id))
                    {
                        Console.Write("Enter new id: ");
                        if (int.TryParse(Console.ReadLine(), out newID))
                        {
                            proxy.ModifyID(newID, id);
                        }
                    }
                    break;

                case 3:
                    Console.Write("Enter ID: ");
                    if (int.TryParse(Console.ReadLine(), out id))
                    {
                        Console.Write("Enter new reading: ");
                        if (double.TryParse(Console.ReadLine(), out newReading))
                        {
                            proxy.ModifyReading(newReading, id);
                        }
                    }
                    break;

                case 4:
                    Console.Write("Enter ID: ");
                    if (int.TryParse(Console.ReadLine(), out id))
                    {
                        proxy.DeleteEntityDB(id);
                    }
                    break;

                case 5:
                    proxy.DeleteDB();
                    break;

                case 6:
                    Console.Write("Enter ID: ");
                    if (int.TryParse(Console.ReadLine(), out id))
                    {
                        Console.Write("Enter full name: ");
                        var name = Console.ReadLine();
                        Console.Write("Enter reading: ");
                        if (double.TryParse(Console.ReadLine(), out newReading))
                        {
                            proxy.AddDB(id, name, newReading);
                        }
                    }
                    break;

                default:
                    break;
                }
                Console.Write("Press <enter> continue...");
                Console.ReadLine();
            }
        }