private async Task <ResponceDataSet> ExecuteProcedure() { int countTry = 3; while (countTry > 0) { countTry--; try { _log.Info("DwhStoreProcedureChannel.ExecuteProcedure() - calling DWH client...", Metainfo); ResponceDataSet response = await _dwhClient.Call(new Dictionary <string, string>(), Metainfo, "report"); _log.Info("DwhStoreProcedureChannel.ExecuteProcedure() - successfully received response.", new { Procedure = Metainfo, Response = response }); return(response); } catch (Exception ex) { Log.Error(ex, context: $"Procedure: {Metainfo}"); if (countTry <= 0) { throw; } } await Task.Delay(5000); } throw new Exception("Cannot execute store procedure"); }
protected override async Task DoTimer() { ResponceDataSet response = await _dwhClient.Call(new Dictionary <string, string>(), Metainfo, "report"); var report = response.Data.Tables .Cast <DataTable>() .ToArray(); var table = report.FirstOrDefault(); if (table == null || table.Rows.Count <= 0) { return; } var str = new StringBuilder(); str.AppendLine($"please do these actions at cryptofacilities.com"); str.AppendLine(); foreach (DataRow row in table.Rows) { if (row[table.Columns[0].ColumnName].ToString() == "Adjustment_Required_($)") { var value = decimal.Parse(row[table.Columns[2].ColumnName].ToString()); str.AppendLine($"* Position Adjustment Required at {Math.Round(value, 2)} $, asset: {row[table.Columns[1].ColumnName]}. "); } if (row[table.Columns[0].ColumnName].ToString() == "Margin_Adjustment_Required_($)") { var value = decimal.Parse(row[table.Columns[2].ColumnName].ToString()); str.AppendLine($"* Margin Adjustment Required at {Math.Round(value, 2)}, asset: {row[table.Columns[1].ColumnName]}. "); } } await SendMessage(str.ToString()); }