public bool AddNodeToChain(string userId, string multichainAddress, ref string message) { message = null; try { if (IncentiveScheme.GetType() == typeof(DescentralizedIncentiveScheme)) { //add node if (!((DescentralizedIncentiveScheme)IncentiveScheme).AddNodeToChain(multichainAddress)) { Log.ErrorFormat("Invalid Chain address: [{0}]", multichainAddress); message = "Invalid address!"; return(false); } //add association to user wallet if (!this.RepositoryRemote.AddUserMultichainNode(userId, multichainAddress)) { Log.Error("Cannot associate the multichain node to the user's wallet."); message = "Cannot associate block-chain node to user!"; return(false); } return(true); } message = "Your scheme must be changed to the descentralized version!"; return(false); } catch (Exception ex) { Log.Error(ex.Message); return(false); } }
public bool PayTask(string userId, out string transactionId, out bool hasfunds) { transactionId = null; hasfunds = false; try { if (!IncentiveScheme.PayTask(userId, out transactionId, out hasfunds)) { return(false); } if (hasfunds == false) { Console.WriteLine("[INFO - INCENTIVE ENGINE] - Insufficient funds!"); } else { Console.WriteLine("[INFO - INCENTIVE ENGINE] - Payment Registered with Success!"); } return(true); } catch (Exception ex) { Log.Error(ex.Message); return(false); } }
public bool GetUserTransactions(string userId, out List <Transaction> transactions) { transactions = null; try { //get user transaction based on the actual incentive scheme transactions = IncentiveScheme.GetUserTransactions(userId); if (transactions == null) { Log.Error("Transactions List IS NULL"); return(false); } return(true); } catch (Exception ex) { Log.Error(ex.Message); return(false); } }
public bool RegisterUser(out string userId, out string userAddress) { string transactionId; string errorMessage = null; userId = null; userAddress = null; try { if (!IncentiveScheme.RegisterUser(out transactionId, out userAddress, ref errorMessage)) { Log.Error(errorMessage); Console.WriteLine("[ERROR - INCENTIVE ENGINE] - Cannot save user creation transaction!"); } return(true); } catch (Exception ex) { Log.Error(ex.Message); return(false); } }