Пример #1
0
 public IActionResult ReadWithdrawal(string contractAddress)
 {
     if (!string.IsNullOrEmpty(ConnectionId))
     {
         Task.Factory.StartNew(() =>
         {
             var hubContext = HubConnectionManager.GetHubContext <AuctusDemoHub>();
             try
             {
                 Withdrawal withdrawal = PensionFundsServices.ReadWithdrawal(contractAddress);
                 if (withdrawal == null || withdrawal.Completed)
                 {
                     hubContext.Clients.Client(ConnectionId).withdrawalCompleted(Json(withdrawal).Value);
                 }
                 else
                 {
                     hubContext.Clients.Client(ConnectionId).withdrawalUncompleted(Json(withdrawal).Value);
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError(new EventId(3), ex, string.Format("Erro on ReadWithdrawal {0}.", contractAddress));
                 hubContext.Clients.Client(ConnectionId).readWithdrawalError();
             }
         });
         return(Json(new { success = true }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
Пример #2
0
 public IActionResult ReadPayments(string contractAddress)
 {
     if (!string.IsNullOrEmpty(ConnectionId))
     {
         Task.Factory.StartNew(() =>
         {
             var hubContext = HubConnectionManager.GetHubContext <AuctusDemoHub>();
             try
             {
                 if (CanTransactWith(contractAddress))
                 {
                     try
                     {
                         Progress progress = PensionFundsServices.ReadPayments(contractAddress);
                         if (progress.Completed)
                         {
                             hubContext.Clients.Client(ConnectionId).paymentsCompleted(Json(progress).Value);
                         }
                         else
                         {
                             hubContext.Clients.Client(ConnectionId).paymentsUncompleted(Json(progress).Value);
                         }
                     }
                     finally
                     {
                         ReleaseTransactionWith(contractAddress);
                     }
                 }
                 else
                 {
                     hubContext.Clients.Client(ConnectionId).readPaymentsError();
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError(new EventId(2), ex, string.Format("Erro on ReadPayments {0}.", contractAddress));
                 hubContext.Clients.Client(ConnectionId).readPaymentsError();
             }
         });
         return(Json(new { success = true }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }
Пример #3
0
 public IActionResult CheckContractCreationTransaction(String transactionHash)
 {
     if (!string.IsNullOrEmpty(ConnectionId))
     {
         Task.Factory.StartNew(() =>
         {
             var hubContext = HubConnectionManager.GetHubContext <AuctusDemoHub>();
             try
             {
                 var pensionFundContract = PensionFundsServices.CheckContractCreationTransaction(transactionHash);
                 if (pensionFundContract.BlockNumber.HasValue)
                 {
                     hubContext.Clients.Client(ConnectionId).deployCompleted(Json(
                                                                                 new
                     {
                         Address         = pensionFundContract.Address,
                         BlockNumber     = pensionFundContract.BlockNumber,
                         TransactionHash = pensionFundContract.TransactionHash
                     }));
                 }
                 else
                 {
                     hubContext.Clients.Client(ConnectionId).deployUncompleted(pensionFundContract.TransactionHash);
                 }
             }
             catch (Exception ex)
             {
                 Logger.LogError(new EventId(1), ex, string.Format("Erro on CheckContractCreationTransaction {0}.", transactionHash));
                 hubContext.Clients.Client(ConnectionId).deployError();
             }
         });
         return(Json(new { success = true }));
     }
     else
     {
         return(Json(new { success = false }));
     }
 }