Beispiel #1
0
        private async static Task CallQueryCustomer(INodeClient nodeClient)
        {
            System.Console.WriteLine("------------------------------QueryCustomer----------------------------------");

            try
            {
                var result = await nodeClient.CallServiceAsync(10001, 4, null, typeof(List <Customer>), 1000 * 3, null);

                var customers = (List <Customer>)result.ReturnVal;
                foreach (var customer in customers)
                {
                    System.Console.WriteLine($"Result=Id: {customer.Id}, Name: {customer.Name}, Birthday: {customer.Birthday.ToString("yyyy-MM-dd")}");
                }
            }
            catch (RequestTimeoutExcption ex)
            {
                System.Console.WriteLine($"Timeout: RequestId={ex.Request.Id}");
            }
            catch (ServiceCallException ex)
            {
                System.Console.WriteLine($"Service call exception: ExceptionId={ex.ExceptionId}, ExceptionMessage={ex.Message}");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"Error: {ex.Message}");
            }
        }
Beispiel #2
0
        private async static Task CallAddCustomer(INodeClient nodeClient)
        {
            System.Console.WriteLine("------------------------------AddCustomer----------------------------------");

            try
            {
                var customer1 = new Customer()
                {
                    Id       = 1,
                    Name     = "Michael",
                    Birthday = new DateTime(1999, 1, 1)
                };
                var task1 = nodeClient.CallServiceAsync(10001, 2, new object[] { customer1 }, null, 1000 * 3, null);

                var customer2 = new Customer()
                {
                    Id       = 2,
                    Name     = "Jane",
                    Birthday = new DateTime(2001, 5, 10)
                };
                var task2 = nodeClient.CallServiceAsync(10001, 2, new object[] { customer2 }, null, 1000 * 3, null);

                await Task.WhenAll(task1, task2);

                System.Console.WriteLine($"Add customer success");
            }
            catch (RequestTimeoutExcption ex)
            {
                System.Console.WriteLine($"Timeout: RequestId={ex.Request.Id}");
            }
            catch (ServiceCallException ex)
            {
                System.Console.WriteLine($"Service call exception: ExceptionId={ex.ExceptionId}, ExceptionMessage={ex.Message}");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"Error: {ex.Message}");
            }
        }
Beispiel #3
0
        private async static Task CallGetServiceName(INodeClient nodeClient)
        {
            System.Console.WriteLine("------------------------------GetServiceName----------------------------------");

            try
            {
                var result = await nodeClient.CallServiceAsync(10001, 1, null, typeof(string), 1000 * 3, null);

                System.Console.WriteLine($"Result={result.ReturnVal}");
            }
            catch (RequestTimeoutExcption ex)
            {
                System.Console.WriteLine($"Timeout: RequestId={ex.Request.Id}");
            }
            catch (ServiceCallException ex)
            {
                System.Console.WriteLine($"Service call exception: ExceptionId={ex.ExceptionId}, ExceptionMessage={ex.Message}");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"Error: {ex.Message}");
            }
        }
Beispiel #4
0
        private async static Task CallRemoveAllCustomer(INodeClient nodeClient)
        {
            System.Console.WriteLine("------------------------------RemoveAllCustomer----------------------------------");

            try
            {
                await nodeClient.CallServiceAsync(10001, 6, null, null, 1000 * 3, null);

                System.Console.WriteLine($"Remove all customer success");
            }
            catch (RequestTimeoutExcption ex)
            {
                System.Console.WriteLine($"Timeout: RequestId={ex.Request.Id}");
            }
            catch (ServiceCallException ex)
            {
                System.Console.WriteLine($"Service call exception: ExceptionId={ex.ExceptionId}, ExceptionMessage={ex.Message}");
            }
            catch (Exception ex)
            {
                System.Console.WriteLine($"Error: {ex.Message}");
            }
        }