private static void SubmitEval(IEvalService client) { Console.WriteLine(); Console.Write("Submitter: "); var submitter = Console.ReadLine(); Console.Write("Comments: "); var comments = Console.ReadLine(); var eval = new Eval { Submitter = submitter, Comments = comments, Timesent = DateTime.Now }; client.SubmitEval(eval); }
static void Main(string[] args) { var factory = new ChannelFactory <IEvalService>("http"); IEvalService channel = factory.CreateChannel(); var eval = new Eval() { Comment = "HallÄ ja", Submitter = "Dallas", TimeSent = DateTime.Now }; channel.SubmitEval(eval); Console.WriteLine("Success!"); var doneEval = channel.GetEvals(); foreach (var e in doneEval) { Console.WriteLine($"{e.Submitter} {e.TimeSent}"); Console.WriteLine($"{e.Comment}"); Console.WriteLine("--------------------------"); } Console.ReadKey(); factory.Close(); }
static void Main(string[] args) { try { IPHostEntry ips = Dns.GetHostEntry(Dns.GetHostName()); IPAddress _ipAddress = ips.AddressList[0]; string endPointAddr = "net.tcp://" + _ipAddress.ToString() + ":8000/EvalService"; NetTcpBinding tcpBinding = new NetTcpBinding(); tcpBinding.TransactionFlow = false; tcpBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign; tcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows; tcpBinding.Security.Mode = SecurityMode.None; EndpointAddress endpointAddress = new EndpointAddress(endPointAddr); Console.WriteLine("Attempt to connect to: " + endPointAddr); IEvalService proxy = ChannelFactory <IEvalService> .CreateChannel(tcpBinding, endpointAddress); using (proxy as IDisposable) { Eval eval; eval = new Eval { Comments = "CommentsField1", Submitter = "Submitter1", TimeSubmitted = DateTime.Now }; proxy.SubmitEval(eval); eval = new Eval { Comments = "CommentsField2", Submitter = "Submitter2", TimeSubmitted = DateTime.Now }; proxy.SubmitEval(eval); eval = new Eval { Comments = "CommentsField3", Submitter = "Submitter3", TimeSubmitted = DateTime.Now }; proxy.SubmitEval(eval); Eval[] evals = proxy.GetEvals(); foreach (Eval e in evals) { Console.WriteLine("{0}\t{1}\t{2}", e.Id, e.Submitter, e.TimeSubmitted); } } } catch (Exception eException) { Console.WriteLine("{1}{0}Message: \"{2}\"{3}{0}StackTrace:{0}{4}", Environment.NewLine, eException.GetType().FullName, eException.Message, eException.InnerException != null ? Environment.NewLine + "InnerException.Message: \"" + eException.InnerException.Message + "\"" : string.Empty, eException.StackTrace); } Console.ReadLine(); }
static void Main(string[] args) { WebChannelFactory <IEvalService> cf = new WebChannelFactory <IEvalService>( new Uri("http://localhost:8080/EvalService")); IEvalService client = cf.CreateChannel(); Console.WriteLine("Please enter one of following commands."); Console.WriteLine("submit"); Console.WriteLine("get"); Console.WriteLine("list"); Console.WriteLine("remove"); Console.WriteLine("exit"); var command = Console.ReadLine(); while (command != "Exit") { switch (command) { case "submit": Console.WriteLine("Enter comment"); var comment = Console.ReadLine(); Console.WriteLine("Enter Submitter"); var submitter = Console.ReadLine(); var eval = new Eval() { Comment = comment, Submitter = submitter, TimeSent = DateTime.Now }; client.SubmitEval(eval); Console.WriteLine("eval submitted"); command = null; break; case "get": Console.WriteLine("Enter a Eval ID:"); var evalId = Console.ReadLine(); var gottenEval = client.GetEval(evalId); Console.WriteLine((gottenEval != null) ? $" {gottenEval.Id}. {gottenEval.Submitter} said { gottenEval.Comment }" : "No Eval found"); Console.ReadLine(); command = null; break; case "list": Console.WriteLine("Enter name of submitter"); var submitterName = Console.ReadLine(); //if (!string.IsNullOrWhiteSpace(submitterName)) //{ var evalsBySubmitter = client.GetEvalBySubmitter(submitterName); if (evalsBySubmitter != null) { evalsBySubmitter.ForEach(e => Console.WriteLine($" {e.Id}. {e.Submitter} said { e.Comment }")); } else { Console.WriteLine("No Evals found by {0}", submitterName); } //} //else //{ // Console.WriteLine("Invalid input!"); //} Console.ReadLine(); command = null; break; case "remove": Console.WriteLine("Enter Id to remove Eval"); var idToRemove = Console.ReadLine(); client.RemoveEval(idToRemove); break; case "exit": Environment.Exit(-1); break; } Console.Clear(); Console.WriteLine("Please enter one of following commands."); Console.WriteLine("submit"); Console.WriteLine("get"); Console.WriteLine("list"); Console.WriteLine("remove"); Console.WriteLine("exit"); command = Console.ReadLine(); } }
static void Main(string[] args) { WebChannelFactory <IEvalService> cf = new WebChannelFactory <IEvalService>( new Uri("http://localhost:8089/evalservice")); IEvalService client = cf.CreateChannel(); while (true) { Console.WriteLine("[submit]"); Console.WriteLine("[get]"); Console.WriteLine("[list]"); Console.WriteLine("[remove]"); Console.WriteLine("[exit]"); Console.WriteLine("Enter a commando >> "); string comm = Console.ReadLine(); switch (comm) { case "submit": // getting all the required fields for the new eval to create Console.WriteLine("Who is the subbmitter? >> "); string submter = Console.ReadLine(); Console.WriteLine("enter comments in one string >> "); string comments = Console.ReadLine(); Console.WriteLine("Enter an unique id for the EVAL >> "); string id = Console.ReadLine(); // creating the EVAL Eval e = new Eval() { Comments = comments, Submitter = submter, TimeSent = DateTime.Now, Id = id, }; // subbmitting the new eval client.SubmitEval(e); Console.WriteLine("Created!"); break; case "get": Console.WriteLine("enter a id"); string input = Console.ReadLine(); Eval retrieved = client.GetEval(input); if (retrieved != null) { Console.WriteLine("Entered: "); Console.WriteLine(retrieved.Comments + ' ' + retrieved.Submitter); } else { Console.WriteLine("No Eval matching id: " + input); } break; case "list": Console.WriteLine("Enter a subbmitter >>"); string submitterInput = Console.ReadLine(); List <Eval> retrievedEvals = client.GetEvalsBySybmitter(submitterInput); if (retrievedEvals.Count != 0 || retrievedEvals == null) { foreach (var ev in retrievedEvals) { Console.WriteLine(ev.Submitter + " " + ev.Comments); Console.WriteLine("------------"); } } break; case "remove": Console.WriteLine("Id to remove >> "); string removeId = Console.ReadLine(); client.RemoveEval(removeId); break; default: Console.WriteLine("Command is not supported!"); break; } if (comm == "exit") { break; } Console.ReadKey(); } Console.WriteLine("exiting program"); }
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; 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.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(); } }