Exemple #1
0
        public ActionResult CompleteVirtualCoinWithdraw(string withdrawUniqueID, string txid, CurrencyType currency)
        {
            try
            {
                var cmd = new CompleteVirtualCoinWithdraw(withdrawUniqueID, txid, 0, currency);
                this.CommandBus.Send(cmd);

                return Json(JsonResult.Success);
            }
            catch (CommandExecutionException ex)
            {
                return Json(new JsonResult(ex.ErrorCode));
            }
        }
        private static void SendCompleteCommand(CurrencyType currency, string withdrawUniqueID, string txid, decimal txfee)
        {
            try
            {
                var mqname = "NXTSendCompleteCommand";
                var channel = _mqpool.GetMQChannel(mqname);

                var exchangeAndQueueName = Utilities.GenerateVirtualCoinCompletePaymentExchangeAndQueueName();

                var cmd = new CompleteVirtualCoinWithdraw(withdrawUniqueID, txid, txfee, currency);

                var build = new BytesMessageBuilder(channel);
                build.WriteBytes(Encoding.UTF8.GetBytes(IoC.Resolve<IJsonSerializer>().Serialize(cmd)));
                ((IBasicProperties)build.GetContentHeader()).DeliveryMode = 2;
                try
                {
                    channel.BasicPublish(exchangeAndQueueName.Item1, string.Empty, ((IBasicProperties)build.GetContentHeader()), build.GetContentBody());
                }
                catch (EndOfStreamException ex)
                {
                    if (ex.Message.Equals("SharedQueue closed", StringComparison.OrdinalIgnoreCase))
                    {
                        channel = _mqpool.GetMQChannel(mqname);
                        channel.BasicPublish(exchangeAndQueueName.Item1, string.Empty, ((IBasicProperties)build.GetContentHeader()), build.GetContentBody());
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("提现处理完毕后,发送完成消息时出现错误:withdrawID={0},currency={1},txid={3}".FormatWith(withdrawUniqueID, currency, txid), ex);
                }
            }
            catch (Exception ex)
            {
                Log.Error("提现处理完毕后,发送完成消息时出现错误:withdrawID={0},currency={1},txid={3}".FormatWith(withdrawUniqueID, currency, txid), ex);
            }
        }