Esempio n. 1
0
        public static async Task ListFeatures()
        {
            Channel channel = new Channel("127.0.0.1:50051", ChannelCredentials.Insecure);
            var     client  = new EmployeeService.EmployeeServiceClient(channel);

            try
            {
                using (var call = client.GetEmployees(new EmployeeRequest {
                    Id = 1
                }))
                {
                    var           responseStream = call.ResponseStream;
                    StringBuilder responseLog    = new StringBuilder("Result: ");

                    while (await responseStream.MoveNext())
                    {
                        Employee employee = responseStream.Current;
                        responseLog.Append(employee.ToString());
                    }
                    Console.WriteLine(responseLog.ToString());
                }
            }
            catch (RpcException e)
            {
                Console.WriteLine("RPC failed " + e);
                throw;
            }
        }
Esempio n. 2
0
        // GET: Employee
        public ActionResult Index()
        {
            ViewBag.Connection = GetServerName();
            EmployeeService.EmployeeServiceClient client = new EmployeeService.EmployeeServiceClient();
            var employees = client.GetEmployees().OrderBy(e => e.Id).ToList();

            return(View(employees));
        }