Esempio n. 1
0
        static void Main(string[] args)
        {
            //ChannelFactory<IEvalService> factory = new ChannelFactory<IEvalService>("BasicHttpBinding_IEvalService");

            //IEvalService channel = factory.CreateChannel();

            var channel = new EvalServiceClient("BasicHttpBinding_IEvalService");

            try
            {
                channel.SubmitEval(new Eval {
                    Comments = "hepp", Submitter = "hopp", Timesent = DateTime.Now
                });

                foreach (var item in channel.GetEvals())
                {
                    Console.WriteLine(item.Comments + " " + item.Submitter + " " + item.Timesent);
                }
                Console.ReadKey();

                channel.Close();
            }
            catch (TimeoutException ex)
            {
                Console.WriteLine(ex.Message);
            }


            //((IClientChannel)channel).Close();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var client = new EvalServiceClient("WSHttpBinding_IEvalService");
            var cb     = new MessageInspectorBehavior();

            // Add the custom behaviour to the list of service behaviours.
            client.Endpoint.Behaviors.Add(cb);

            cb.OnMessageInspected += (src, e) =>
            {
                //if (e.MessageInspectionType == eMessageInspectionType.Request) request = e.Message;
                //else response = e.Message;
            };

            var eval = new Eval
            {
                Comments      = "InterOP",
                Id            = Guid.NewGuid().ToString(),
                Submitter     = "Daniel",
                TimeSubmitted = DateTime.Now
            };


            client.SubmitEval(eval);


            var allEvall = client.GetEvals();

            var test = 0;
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            EvalServiceClient evalServiceClient = new EvalServiceClient("NetTcpBinding_IEvalService");

            DetailedEval eval;

            eval            = new DetailedEval();
            eval.From       = "SJain";
            eval.Timespent  = System.DateTime.Now.ToString();
            eval.What       = "1.From Client";
            eval.additional = "1. Additional comments from Client";
            evalServiceClient.SubmitEvals(eval);

            eval            = new DetailedEval();
            eval.From       = "KJain";
            eval.Timespent  = System.DateTime.Now.ToString();
            eval.What       = "2. From Client ";
            eval.additional = "2. Additional comments from Client";
            evalServiceClient.SubmitEvals(eval);

            List <Evaluation> evalList = evalServiceClient.GetEvals();

            foreach (var Evaluation in evalList)
            {
                Console.WriteLine($"{Evaluation.What}");
            }
            Console.ReadLine();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            EvalServiceClient
                evalServiceClient = new EvalServiceClient();

            Eval
                eval;

            eval = new Eval {
                Comments = "CommentsField1", Submitter = "Submitter1", TimeSubmitted = DateTime.Now
            };
            evalServiceClient.SubmitEval(eval);
            eval = new Eval {
                Comments = "CommentsField2", Submitter = "Submitter2", TimeSubmitted = DateTime.Now
            };
            evalServiceClient.SubmitEval(eval);
            eval = new Eval {
                Comments = "CommentsField3", Submitter = "Submitter3", TimeSubmitted = DateTime.Now
            };
            evalServiceClient.SubmitEval(eval);

            Eval[]
            evals = evalServiceClient.GetEvals();

            foreach (Eval e in evals)
            {
                Console.WriteLine("{0}\t{1}\t{2}", e.Id, e.Submitter, e.TimeSubmitted);
            }

            evalServiceClient.Close();

            Console.ReadLine();
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            #region example using ChannelFactory<T> directly
            //ChannelFactory<IEvalService> cf =
            //    new ChannelFactory<IEvalService>("WSHttpBinding_IEvalService");
            //IEvalService channel = cf.CreateChannel();
            #endregion

            Console.WriteLine("Retrieving endpoints via MEX...");

            ServiceEndpointCollection endpoints =
                MetadataResolver.Resolve(typeof(IEvalService),
                    new EndpointAddress("http://localhost:8080/evals/mex"));

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

                try
                {
                    EvalServiceLibrary.Eval eval =
                        new EvalServiceLibrary.Eval("Aaron", "I'm really liking this");
                    channel.SubmitEval(eval);
                    channel.SubmitEval(eval);

                    List<EvalServiceLibrary.Eval> evals = channel.GetEvals();
                    Console.WriteLine("Number of evals: {0}", evals.Count);

                    #region async example
                    //channel.GetEvalsCompleted += new EventHandler<GetEvalsCompletedEventArgs>(channel_GetEvalsCompleted);
                    //channel.GetEvalsAsync();
                    //Console.WriteLine("Waiting...");
                    //Console.ReadLine();
                    #endregion

                    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();
                }
            }
        }
Esempio n. 6
0
        static void Main(string[] args)
        {
            #region example using ChannelFactory<T> directly
            //ChannelFactory<IEvalService> cf =
            //    new ChannelFactory<IEvalService>("WSHttpBinding_IEvalService");
            //IEvalService channel = cf.CreateChannel();
            #endregion

            Console.WriteLine("Retrieving endpoints via MEX...");

            ServiceEndpointCollection endpoints =
                MetadataResolver.Resolve(typeof(IEvalService),
                                         new EndpointAddress("http://localhost:8080/evals/mex"));

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

                try
                {
                    EvalServiceLibrary.Eval eval =
                        new EvalServiceLibrary.Eval("Aaron", "I'm really liking this");
                    channel.SubmitEval(eval);
                    channel.SubmitEval(eval);

                    List <EvalServiceLibrary.Eval> evals = channel.GetEvals();
                    Console.WriteLine("Number of evals: {0}", evals.Count);

                    #region async example
                    //channel.GetEvalsCompleted += new EventHandler<GetEvalsCompletedEventArgs>(channel_GetEvalsCompleted);
                    //channel.GetEvalsAsync();
                    //Console.WriteLine("Waiting...");
                    //Console.ReadLine();
                    #endregion

                    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();
                }
            }
        }
Esempio n. 7
0
        private static void GetAll(EvalServiceClient evalServiceClient)
        {
            List <Evaluation> evalList = evalServiceClient.GetEvals();

            foreach (var Evaluation in evalList)
            {
                Console.WriteLine($"{Evaluation.What}");
            }
        }
Esempio n. 8
0
        static void Main(string[] args)
        {
            EvalServiceClient esc = new EvalServiceClient("WSHttpBinding_IEvalService");
            esc.SubmitEval(new Eval() { Comments = "Coming from code behind", Submitter = "Semih", TimeSubmitted = DateTime.Now });

            Eval[] evals = esc.GetEvals();

            foreach (Eval item in evals)
            {
                Console.WriteLine(item.Comments + " - " + item.Submitter);
            }

            Console.ReadKey();
        }
Esempio n. 9
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);
        }
Esempio n. 10
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();
        }
Esempio n. 11
0
        static void Main(string[] args)
        {
            var client = new EvalServiceClient("BasicHttpBinding_IEvalService");
            client.SubmitEval(new Eval
                                 {
                                     Comments = "This came from code",
                                     Submitter = "Sean",
                                     TimeSubmitted = DateTime.Now
                                 });
            Console.WriteLine("Save success");
            Console.WriteLine("dfffsdf");
            Console.WriteLine("Load Evals");
            var evals = client.GetEvals();

            foreach (var eval in evals)
            {
                Console.WriteLine(eval.Comments);
            }
            Console.WriteLine("End load Evals");
            Console.Read();
        }
Esempio n. 12
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();
        }
Esempio n. 13
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();
        }
Esempio n. 14
0
        static void Main(string[] args)
        {
            // create a factory
            ///////////////////////////////////////////////////

            // factory by name
            ChannelFactory<IEvalService> factory1 = new ChannelFactory<IEvalService>("BasicHttpBinding_IEvalService");

            // factory by endpoint
            ChannelFactory<IEvalService> factory2 = new ChannelFactory<IEvalService>(new WSHttpBinding(), "http://localhost:8080/evals/wsconfig");

            // channel - basic, hidden IClientChannel
            ///////////////////////////////////////////////////
            IEvalService channel1 = factory1.CreateChannel();

            try
            {
                channel1.GetEvals();

                Eval eval = new Eval();
                eval.Submitter = "Jay";
                eval.Timesent = DateTime.Now;
                eval.Comments = "One eval to rule them alll!!!!!!!!!";

                channel1.SubmitEval(eval);
                channel1.SubmitEval(eval);

                Console.ReadLine();

                ((IClientChannel)channel1).Close();
            }
            catch (Exception)
            {
                ((IClientChannel)channel1).Abort();
            }

            // channel client - integrated IClientChannel
            ///////////////////////////////////////////////////
            ChannelFactory<IEvalServiceChannel> factory3 = new ChannelFactory<IEvalServiceChannel>("BasicHttpBinding_IEvalService");

            IEvalServiceChannel channel2 = factory3.CreateChannel();

            try
            {
                Eval[] evals = channel2.GetEvals();
                Console.WriteLine("Number of evals: {0}", evals.Length);

                Console.ReadLine();

                channel2.Close();
            }
            catch (Exception)
            {
                channel2.Abort();
            }

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

            try
            {
                Eval[] evals = client1.GetEvals();
                Console.WriteLine("Number of evals: {0}", evals.Length);

                Console.ReadLine();

                client1.Close();
            }
            catch (Exception)
            {
                client1.Abort();
            }
        }