Exemplo n.º 1
0
        public void Trigger()
        {
            //_ioc.Bus.Publish(new CustomsPaymentReportRequestMqMessage()
            //{
            //    DeclaredOrderNo = "DD19011700128756",
            //    SessionId = "fe2374-8fnejf97-9bcd5678",
            //    RequestTime = DateTime.Now
            //});



            var provider = new CustomsReportDataProvider();

            var data = AsyncHelper.RunSync(() => provider.GetReportData("DD19011700128756", _testSetting));



            var signStr = data.GetSignString();

            var signBytes = Encoding.UTF8.GetBytes(signStr);

            var sign    = new byte[172];
            var signLen = 200;



            var result = SignSdkApi.Sign(signBytes, signBytes.Length, sign, ref signLen, _testSetting.CertPassword);

            if (result == SignSdkApi.SignResult.SignSuccess)
            {
                data.signValue = Encoding.UTF8.GetString(sign);

                data.certNo = _testSetting.CertNo;

                var reporter = new CustomsPaymentReport();

                AsyncHelper.RunSync(() => reporter.Report(data));
            }


            Console.WriteLine($"签名 {Encoding.UTF8.GetString(sign)}");
        }
Exemplo n.º 2
0
        public async Task Handle(CustomsPaymentReportRequestMqMessage message)
        {
            try
            {
                var data = await _customsReportDataProvider.GetReportData(message.DeclaredOrderNo, _settings);


                var signStr = data.GetSignString();

                _logger.Info($"海关上报支付数据:[加签] 加签字符 {signStr}");

                var signBytes = Encoding.UTF8.GetBytes(signStr);

                var sign    = new byte[172];
                var signLen = 200;

                var result = SignSdkApi.Sign(signBytes, signBytes.Length, sign, ref signLen, _settings.CertPassword);

                if (result == SignSdkApi.SignResult.SignSuccess)
                {
                    data.signValue = Encoding.UTF8.GetString(sign);

                    data.certNo = _settings.CertNo;

                    _logger.Info($"海关上报支付数据:[加签] 签名 {data.signValue}");


                    await _reporter.Report(data);
                }
                else
                {
                    _logger.Error($"海关上报支付数据:[签名错误],MSG:{SignSdkApi.SignResult.GetResultMessage((int)result)}");
                }
            }
            catch (Exception ex)
            {
                _logger.Error($"海关上报支付数据:[上报异常],MSG:{ex.Message},\r\n Stack:{ex.StackTrace}");
            }
        }