Exemple #1
0
        static void Main(string[] args)
        {
            //本服务开放端口
            int silePort = 11112;
            //主简仓网关端口
            int gatewayPort = 30000;
            //主简仓开放端口
            int mainSiloPort = 11111;
            var host         = StartHost(silePort, gatewayPort, mainSiloPort);


            var client = StartClient(gatewayPort);


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


            while (true)
            {
                string ReadLine = Console.ReadLine();
                if (ReadLine == "Exit")
                {
                    host.Result.StopAsync().Wait();
                    client.Result.Close();
                    break;
                }
                else if (ReadLine == "Goods")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        Console.WriteLine(goods.GetGoodsDescribe().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);
                    }
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            //本服务开放端口
            int silePort = 11113;
            //主简仓网关端口
            int gatewayPort = 30000;
            //主简仓开放端口
            int mainSiloPort = 11111;

            ///定时器对象
            IGrainReminder grainReminder = null;
            //由于向网关添加一个服务处理需要多一些时间
            //所以在程序运行后马上获取服务可能会抛出获取不到的异常
            //详情请看5、常见问题
            var host   = StartHost(silePort, gatewayPort, mainSiloPort);
            var client = StartClient(gatewayPort);

            while (true)
            {
                string ReadLine = Console.ReadLine();
                if (ReadLine == "Exit")
                {
                    host.Result.StopAsync().Wait();
                    client.Result.Close();
                    break;
                }
                else if (ReadLine == "Goods")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        Console.WriteLine(goods.GetGoodsDescribe().Result);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsList")
                {
                    try
                    {
                        IGoods.IGoods             goods     = client.Result.GetGrain <IGoods.IGoods>(0);
                        List <Entity.GoodsEntity> arrayList = goods.GetGoodsList().Result;
                        Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(arrayList));
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsStartTimer")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        //grainReminder = goods.StartTimerTest().Result;
                        //goods.StartTimerTestString("Test");
                        goods.StartTimer();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("服务暂时还没有启动完成 请稍后再试" + e.Message);
                    }
                }
                else if (ReadLine == "GoodsStopTimer")
                {
                    try
                    {
                        IGoods.IGoods goods = client.Result.GetGrain <IGoods.IGoods>(0);
                        //goods.StopTimerTest(grainReminder).Wait();
                        goods.StopTimerTest("Test");
                    }
                    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);
                    }
                }
            }
        }
 public OrderController()
 {
     this.shoppingRecord = this.GetServer <IShoppingRecord.IShoppingRecord>();
     this.goods          = this.GetServer <IGoods.IGoods>();
 }