Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            //日志初始化,必须要加这句(rpc内部依赖该日志组件)
            LoggerManager.InitLogger(new LogConfig()
            {
            });
            try
            {
                MqRpcConfig mqRpcConfig = new MqRpcConfig()
                {
                    MqAddress      = _mqAddress,
                    ApplicationId  = "demo测试131243",
                    RequestTimeOut = 30 * 1000
                };
                RpcManager rpcManager = new RpcManager(mqRpcConfig);
                rpcManager.RegisterAssembly(typeof(Program).Assembly);
                rpcManager.RegisterAssembly(typeof(Program).Assembly);
                rpcManager.StartServer();
                rpcManager.CreateClient();
                var rpcTestApi = DcpApiClientProxy.Create <IRpcTestApi>(true);

                var nativeTestInterface = rpcTestApi.Test(new UserInfo()
                {
                    Name = "asdfsadfsdf",
                    Des  = "234234234"
                });
                var jj = nativeTestInterface.Result;



                Console.WriteLine(Dynamic.Core.Runtime.SerializationUtility.ObjectToJson(jj));
                ///下面的是调用外部组件

                while (Console.ReadLine() != "exit")
                {
                    try
                    {
                        var ewrer  = DcpApiClientProxy.Create <IPrivilegeManageConstract>(true);
                        var wer333 = ewrer.GetUsersOfInfo(new Acb.Plugin.PrivilegeManage.Constract.Models.Dtos.User.UserQueryPageDto()
                        {
                            Page      = 1,
                            Size      = 1000,
                            userQuery = new Acb.Plugin.PrivilegeManage.Constract.Models.Dtos.User.UserQueryDto()
                            {
                                OpenId   = "o9MuI0-fi_eL8aKSlyTc1Bgjpprs",
                                SystemId = "161722f8658fc420c26408d635cd7f66",
                                State    = 1
                            }
                        });
                        var jjj    = wer333.Result;
                        var JJJsTR = Dynamic.Core.Runtime.SerializationUtility.ObjectToJson(jjj);
                        Console.WriteLine(JJJsTR);
                    }
                    catch (Exception ex)
                    {
                        var ere = ex.ToString();
                        Console.WriteLine(ere);
                    }


                    var abc = DcpApiClientProxy.Create <IPrivilegeManageConstract>(true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.ReadLine();
        }