Esempio n. 1
0
        public bool Check()
        {
            var cfg       = new ConfigMonitor(Tid);
            var sParaTemp = new SortedDictionary <string, string>
            {
                { "partner", cfg.partner },
                { "seller_id", cfg.seller_id },
                { "_input_charset", cfg.input_charset.ToLower() },
                { "service", "alipay.wap.create.direct.pay.by.user" },
                { "payment_type", "1" },
                { "sign_type", "RSA" },
                { "notify_url", "http://baidu.com" },
                { "return_url", "http://baidu.com" },
                { "it_b_pay", "30m" },
                { "out_trade_no", new Random().Next(111111, 999999).ToString() },
                { "subject", "会员商品" },
                { "total_fee", "0.01" },
                { "body", "会员商品" }
            };
            //需要封装TokenUrl(异步回调地址)
            //同步支付成功界面跳转地址
            //我们的订单号
            //商品名称(根据商品id查询商品名称)
            //价格(已传入的为准,无就从数据库读取)
            //商品名称(备注)
            var result = new Submit(Tid, cfg).BuildRequest(sParaTemp, "get", "OK");

            AliPayForm = result;
            return(true);
            //var result = new Submit(Tid, cfg).BuildRequestParameters(sParaTemp);
            //throw new NotImplementedException("未实现支付宝通道状态判断");
            //return true;
        }
Esempio n. 2
0
        public ClusterController(ClientConfiguration clientConfig,
                                 Func <IConnectionPool, IIOService> ioServiceFactory,
                                 Func <PoolConfiguration, IPEndPoint, IConnectionPool> connectionPoolFactory,
                                 Func <string, string, IConnectionPool, ITypeTranscoder, ISaslMechanism> saslFactory,
                                 IByteConverter converter,
                                 ITypeTranscoder transcoder)
        {
            _clientConfig          = clientConfig;
            _ioServiceFactory      = ioServiceFactory;
            _connectionPoolFactory = connectionPoolFactory;
            _saslFactory           = saslFactory;
            Converter  = converter;
            Transcoder = transcoder;
            Initialize();

            if (clientConfig.EnableDeadServiceUriPing)
            {
                _clusterMonitor = new ClusterMonitor(this);
                _clusterMonitor.StartMonitoring();
            }

            LastConfigCheckedTime = DateTime.Now;
            if (Configuration.EnableConfigHeartBeat)
            {
                _configMonitor = new ConfigMonitor(this);
                _configMonitor.StartMonitoring();
            }

            _configThread = new Thread(ProcessConfig)
            {
                Name         = "CT",
                IsBackground = true
            };
            _configThread.Start();
        }
        public async Task Test_StartMonitoring()
        {
            var clientConfig = new ClientConfiguration
            {
                Servers = new List <Uri>
                {
                    new Uri("http://10.111.160.101:8091"),
                    new Uri("http://10.111.160.102:8091"),
                    new Uri("http://10.111.160.104:8091")
                },
                BucketConfigs = new Dictionary <string, BucketConfiguration>
                {
                    {
                        "default", new BucketConfiguration
                        {
                            BucketName = "default",
                            Username   = "******",
                            Password   = ""
                        }
                    },
                    {
                        "travel-sample", new BucketConfiguration
                        {
                            BucketName = "travel-sample",
                            Username   = "******",
                            Password   = ""
                        }
                    },
                },
                HeartbeatConfigInterval        = 500,
                OperationTracingEnabled        = false,
                OrphanedResponseLoggingEnabled = false
            };

            clientConfig.Initialize();
            var configProvider = new Mock <IConfigProvider>();
            var controller     = new Mock <IClusterController>();

            controller.Setup(x => x.Configuration).Returns(clientConfig);
            controller.Setup(x => x.ConfigProviders).Returns(new List <IConfigProvider> {
                configProvider.Object
            });

            var cts     = new CancellationTokenSource();
            var monitor = new ConfigMonitor(controller.Object, cts);

            monitor.StartMonitoring();

            await Task.Delay(3000);

            controller.Verify(x => x.LastConfigCheckedTime, Times.AtLeast(1));
            monitor.Dispose();
        }
        public void Test_Dispose()
        {
            var clientConfig = new ClientConfiguration
            {
                Servers = new List <Uri>
                {
                    new Uri("http://10.111.160.101:8091"),
                    new Uri("http://10.111.160.102:8091"),
                    new Uri("http://10.111.160.104:8091")
                },
                BucketConfigs = new Dictionary <string, BucketConfiguration>
                {
                    {
                        "default", new BucketConfiguration
                        {
                            BucketName = "default",
                            Username   = "******",
                            Password   = ""
                        }
                    },
                    {
                        "travel-sample", new BucketConfiguration
                        {
                            BucketName = "travel-sample",
                            Username   = "******",
                            Password   = ""
                        }
                    }
                },
                HeartbeatConfigInterval = 1000
            };

            clientConfig.Initialize();
            var configProvider = new Mock <IConfigProvider>();
            var controller     = new Mock <IClusterController>();

            controller.Setup(x => x.Configuration).Returns(clientConfig);
            controller.Setup(x => x.ConfigProviders).Returns(new List <IConfigProvider> {
                configProvider.Object
            });

            var cts     = new CancellationTokenSource();
            var monitor = new ConfigMonitor(controller.Object, cts);

            monitor.StartMonitoring();
            Thread.Sleep(1500);
            monitor.Dispose();
            Assert.IsTrue(cts.IsCancellationRequested);
        }