Example #1
0
        static void Main(string[] args)
        {
            EvalServiceClient client =
                new EvalServiceClient("NetTcpBinding_IEvalService");

            Eval eval = new Eval();

            eval.Submitter = "Bob";
            eval.Timesent  = DateTime.Now;
            eval.Comments  = "Hope this works!";

            client.SubmitEval(eval);

            Console.WriteLine("Number of evals: {0}",
                              client.GetEvals().Length);
        }
Example #2
0
        public static void Main(string[] args)
        {
            // var cf = new ChannelFactory<IEvalServiceChannel>("NetNamedPipeBinding_IEvalService");
            // var channel = cf.CreateChannel();
            var endpoints = MetadataResolver.Resolve(
                typeof(IEvalService),
                new EndpointAddress("http://localhost:8080/evals/mex"));

            foreach (var se in endpoints)
            {
                var channel = new EvalServiceClient(se.Binding, se.Address);

                // var channel = new EvalServiceClient("WSHttpBinding_IEvalService");
                try
                {
                    var eval = new Eval();
                    eval.Submitter = "Howard";
                    eval.Timesent  = DateTime.Now;
                    eval.Comments  = "I'm thinking this...";

                    channel.SubmitEval(eval);
                    channel.SubmitEval(eval);
                    var evals = channel.GetEvals();
                    Console.WriteLine("Number of evals: {0}", evals.Count);
                    channel.Close();
                }
                catch (FaultException fe)
                {
                    Console.WriteLine("FaultException handler: {0}", fe.GetType());
                    channel.Abort();
                }
                catch (CommunicationException ce)
                {
                    Console.WriteLine("CommunicationException handler: {0}", ce.GetType());
                    channel.Abort();
                }
                catch (TimeoutException te)
                {
                    Console.WriteLine("TimeoutException handler: {0}", te.GetType());
                    channel.Abort();
                }
            }

            Console.ReadLine();
        }
Example #3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Press <Enter> to run the client...");
            Console.ReadLine();

            EvalServiceClient client = new EvalServiceClient("BasicHttpBinding_IEvalService");

            Eval eval = new Eval();

            eval.Comments      = "This came from code!";
            eval.Submitter     = "Aaron";
            eval.TimeSubmitted = DateTime.Now;

            client.SubmitEval(eval);

            Eval[] evals = client.GetEvals();
            foreach (Eval ev in evals)
            {
                Console.WriteLine(ev.Comments);
            }

            Console.ReadLine();
        }
Example #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("########################################");
            Console.WriteLine("# WCF Simple Client 1.0 by HarryGG");
            Console.WriteLine("########################################" + Environment.NewLine);

            string selection = "Type: 1 to add comment, 2 to view comments, 3 to exit";

            Console.WriteLine(selection);
            Console.Write(">");
            string action  = Console.ReadLine();
            string comment = null;
            string name    = null;
            //EvalServiceClient WSHttpBinding_client = new EvalServiceClient("WSHttpBinding_IEvalService");
            EvalServiceClient WSHttpBinding_client = new EvalServiceClient();

            try
            {
                while (action != "3" && action != "exit")
                {
                    switch (action)
                    {
                    case "1":
                        Console.WriteLine("Write comment and hit <Enter> to submit:");
                        comment = Console.ReadLine();
                        Console.WriteLine("Write your name and hit <Enter> to submit:");
                        name = Console.ReadLine();

                        Eval eval = new Eval();
                        eval.Comments      = comment;
                        eval.Submitter     = name;
                        eval.TimeSubmitted = DateTime.Now;

                        System.ServiceModel.Configuration.ClientSection clientSection =
                            (System.ServiceModel.Configuration.ClientSection)ConfigurationManager.GetSection("system.serviceModel/client");
                        System.ServiceModel.Configuration.ChannelEndpointElement endpoint = clientSection.Endpoints[0];

                        //string endpointStr = endpoint.Address.ToString();

                        Console.WriteLine("Submitting comment to endpoint ");    // + endpointStr);
                        WSHttpBinding_client.SubmitEval(eval);
                        Console.WriteLine("Comment submitted!" + Environment.NewLine);

                        Console.WriteLine(selection);
                        Console.Write(">");
                        action = Console.ReadLine();
                        break;

                    case "2":
                        Console.WriteLine("Getting list of submitted comments...");
                        Eval[] evals = WSHttpBinding_client.GetEvals();

                        int i = 0;
                        if (evals.Length > 0)
                        {
                            Console.WriteLine(evals.Length + " comments retrieved successfully:");
                            Console.WriteLine(Environment.NewLine);
                            foreach (Eval ev in evals)
                            {
                                Console.WriteLine(++i + ": " + ev.Comments + " from user " + ev.Submitter);
                            }
                        }
                        else
                        {
                            Console.WriteLine(Environment.NewLine);
                            Console.WriteLine("No comments found! I suggest you first add some comments!");
                        }
                        Console.WriteLine(Environment.NewLine);

                        Console.WriteLine(selection);
                        Console.Write(">");
                        action = Console.ReadLine();
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }

            Console.WriteLine("*********************************************************");
            //Console.WriteLine(selection);
            //Console.Write(">");
            //action = Console.ReadLine();
        }
        static void Main(string[] args)
        {
            Console.WriteLine("*** Evaluation Client Application ***\n");

            EvalServiceClient client = new EvalServiceClient("BasicHttpBinding_IEvalService");

            Console.WriteLine("Please enter a command: ");
            string command = Console.ReadLine();

            while (!command.Equals("exit"))
            {
                switch (command)
                {
                case "submit":

                    Console.WriteLine("Please enter your name:");
                    string name = Console.ReadLine();
                    Console.WriteLine("Please enter your comments:");
                    string comments = Console.ReadLine();

                    Eval eval = new Eval();
                    eval.TimeSent  = DateTime.Now;
                    eval.Submitter = name;
                    eval.Comments  = comments;

                    client.SubmitEval(eval);

                    Console.WriteLine("Evaluation submitted! \n");
                    break;

                case "get":
                    Console.WriteLine("Please enter the eval id:");
                    string id = Console.ReadLine();

                    Eval fe = client.GetEval(id);
                    Console.WriteLine("{0} -- {1} said: {2} (id {3}) \n", fe.TimeSent, fe.Submitter, fe.Comments, fe.Id);
                    break;

                case "list":
                    Console.WriteLine("Please enter the submitter name:");
                    name = Console.ReadLine();

                    List <Eval> evals = client.GetEvalBySubmitter(name);

                    evals.ForEach(e => Console.WriteLine("{0} -- {1} said: {2} (id {3})", e.TimeSent, e.Submitter, e.Comments, e.Id));
                    Console.WriteLine();
                    break;

                case "remove":
                    Console.WriteLine("Please enter the eval id:");
                    id = Console.ReadLine();

                    client.RemoveEval(id);

                    Console.WriteLine("Evaluation {0} removed! \n", id);
                    break;

                default:
                    Console.WriteLine("Unsupported command.");
                    break;
                }

                Console.WriteLine("Please eneter a command: ");
                command = Console.ReadLine();
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** Evaluation Client Application ***\n");

            //EvalServiceClient client =
            //    new EvalServiceClient("BasicHttpBinding_IEvalService");

            WebChannelFactory <IEvalService> cf =
                new WebChannelFactory <IEvalService>(
                    new Uri("http://localhost:8080/evalservice"));
            IEvalService client = cf.CreateChannel();

            Console.WriteLine("Please enter a command: ");
            string command = Console.ReadLine();

            while (!command.Equals("exit"))
            {
                switch (command)
                {
                case "submit":

                    Console.WriteLine("Please enter your name:");
                    string name = Console.ReadLine();
                    Console.WriteLine("Please enter your comments:");
                    string comments = Console.ReadLine();

                    Eval eval = new Eval();
                    eval.Timesent  = DateTime.Now;
                    eval.Submitter = name;
                    eval.Comments  = comments;

                    var resp = client.SubmitEval(eval);

                    Console.WriteLine("Evaluation submitted! Response is: " + resp + "\n");
                    break;

                case "get":
                    Console.WriteLine("Please enter the eval id:");
                    string id = Console.ReadLine();

                    Eval fe = client.GetEval(id);
                    Console.WriteLine("{0} -- {1} said: {2} (id {3})\n", fe.Timesent, fe.Submitter, fe.Comments, fe.Id);
                    break;

                case "list":

                    Console.WriteLine("Please enter the submitter name:");
                    name = Console.ReadLine();

                    List <Eval> evals = client.GetEvalsBySubmitter(name);

                    evals.ForEach(e => Console.WriteLine("{0} -- {1} said: {2} (id {3})", e.Timesent, e.Submitter, e.Comments, e.Id));
                    Console.WriteLine();
                    break;

                case "remove":

                    Console.WriteLine("Please enter the eval id:");
                    id = Console.ReadLine();

                    client.RemoveEval(id);

                    Console.WriteLine("Evaluation {0} removed!\n", id);
                    break;

                default:
                    Console.WriteLine("Unsupported command.");
                    break;
                }

                Console.WriteLine("Please enter a command: ");
                command = Console.ReadLine();
            }
        }