Exemplo n.º 1
0
        public async Task <List <UsageDataViewModel> > GetAllUsageData()
        {
            List <UsageDataViewModel> result = new List <UsageDataViewModel>();
            var client = new UsageDataServices.UsageDataServicesClient(channel);
            var reply  = await client.GetAllUsageDataAsync(new Empty());

            result = reply.UsageDatas.Select(x => new UsageDataViewModel()
            {
                MeterUsage = x.Meterusage, Time = Convert.ToDateTime(x.Time)
            }).ToList();

            return(result);
        }
Exemplo n.º 2
0
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            using var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client = new UsageDataServices.UsageDataServicesClient(channel);
            var reply  = await client.GetAllUsageDataAsync(new Empty());

            int count = 0;

            foreach (var item in reply.UsageDatas)
            {
                Console.WriteLine(count + " = " + item.Meterusage + " - " + item.Time);
                count++;
            }


            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }