Ejemplo n.º 1
0
        public IActionResult GetOrderInformation(int OrderID)
        {
            var result = shoppingRecord.GetOrderDescribe(OrderID).Result;

            if (result == null)
            {
                throw new Exception("没有找到这个账单");
            }
            result.CommodiItynformation = goods.GetGoodsDesc(result.GoodsID).Result;
            return(new JsonResult(result));
        }
Ejemplo n.º 2
0
 public IActionResult GetGoods()
 {
     return(new JsonResult(goods.GetGoodsDesc(1).Result));
 }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //本服务开放端口
            int silePort = 11113;
            //主简仓网关端口
            int gatewayPort = 30000;
            //主简仓开放端口
            int mainSiloPort = 11111;


            //由于向网关添加一个服务处理需要多一些时间
            //所以在程序运行后马上获取服务可能会抛出获取不到的异常
            //详情请看5、常见问题

            Console.WriteLine("Host And Client");
            if (Console.ReadLine() == "Host")
            {
                var host = StartHost(silePort, gatewayPort, mainSiloPort);
                while (true)
                {
                    string ReadLine = Console.ReadLine();
                    if (ReadLine == "Exit")
                    {
                        host.Result.StopAsync().Wait();
                        break;
                    }
                }
            }
            else
            {
                var client = StartClient(gatewayPort);
                while (true)
                {
                    string ReadLine = Console.ReadLine();
                    if (ReadLine == "Exit")
                    {
                        client.Result.Close();
                        break;
                    }
                    else if (ReadLine == "Goods")
                    {
                        try
                        {
                            IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                            Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(goods.GetGoodsDesc().Result));
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                        }
                    }
                    else if (ReadLine == "ShoppingRecord")
                    {
                        try
                        {
                            IShoppingRecord.IShoppingRecord shoppingRecord = client.Result.GetGrain <IShoppingRecord.IShoppingRecord>(0);
                            Console.WriteLine(shoppingRecord.GetShoppingRecordDescribe().Result);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                        }
                    }
                }
            }
        }