private static async void Notify(Account usrAcc, HarvestingData.Datum hrvData) { try { var bot = new TelegramBot(accessToken: ConfigurationManager.AppSettings[name: "accessKey"]); var reqAction = new SendMessage(chatId: usrAcc.OwnedByUser, text: "The account: \n" + StringUtils.GetResultsWithHyphen(usrAcc.EncodedAddress) + " harvested a new block. \n" + "http://explorer.ournem.com/#/s_block?height=" + hrvData.height + "\nFees included: " + (hrvData.totalFee / 1000000)); await bot.MakeRequestAsync(request : reqAction); } catch (Exception e) { if (e.Message.Contains("blocked")) { AccountUtils.DeleteAccountsByUser(usrAcc.OwnedByUser); NodeUtils.DeleteUserNodes(usrAcc.OwnedByUser); UserUtils.DeleteUser(usrAcc.OwnedByUser); } } }
private static void ScanBlocks(Account userAccount) { try { var aClient = new AccountClient(Con); aClient.BeginGetHarvestingInfo(ar => { try { if (ar.Content.data != null) { foreach (var t in ar.Content.data) { if (ar.Content.data.Count <= 0 || userAccount.LastBlockHarvestedHeight >= t?.height) { continue; } userAccount.LastBlockHarvestedHeight = t?.height; AccountUtils.UpdateAccount( usrAcc: userAccount); var hb = new AccountHarvestedSummary() { BlockHeight = t.height, FeesEarned = t.totalFee, MonitoredAccount = userAccount.EncodedAddress, DateOfInput = DateTime.Now, OwnedByUser = userAccount.OwnedByUser }; try { if (userAccount.CheckBlocks) { SummaryUtils.AddHBSummary(s: hb); Notify(usrAcc: userAccount, hrvData: t); } } catch (Exception e) { if (e.Message.Contains("blocked")) { AccountUtils.DeleteAccountsByUser(userAccount.OwnedByUser); NodeUtils.DeleteUserNodes(userAccount.OwnedByUser); UserUtils.DeleteUser(userAccount.OwnedByUser); } break; } } } } catch (Exception e) { Console.WriteLine(value: e); } }, userAccount.EncodedAddress); } catch (Exception e) { Console.WriteLine(value: e); } }