Azure functions – final–part 37
So , I said, now just retrieve data – and put on database:
try
{
log.Info(“trying to save”);
ISave save = new SaveSqlServer(null);
await save.Save(data.ToArray());
}
catch(Exception ex)
{
log.Error($”ERROR !! {ex.Message}”);
}
This gives me a new whole error:
ERROR !! Could not load type ‘System.IAsyncDisposable’ from assembly ‘netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51’.
Ok. Coming from start: What I want ? To save recent data into the database and checking at regular times. How to do that ? Simple . Just call https://infovalutar.azurewebsites.net/api/v1.0/save/LoadAndSaveAll
Good. So this should be the code:
log.Info($”LOAD from website: {DateTime.Now}”);
Console.WriteLine(“————————!!”);
var url = “https://infovalutar.azurewebsites.net/api/v1.0/save/LoadAndSaveAll”;
var http = new HttpClient();
var data = await http.GetStringAsync(url);
log.Info($”obtaining data {data}”);
And … it works flawless! – For BNR – for ECB it shows just a record. That is somehow strange – the coding was almost the same
Now it is time to wrote some more tests -and to find if ECB is loading more than 1 record. Yes, it is.
Then the problem is when saving? Or when loading ?
I have the result of saving :
public class ResultsLoadBankData
{
public string Bank { get; internal set; }
public int NrRecords { get; internal set; }
public bool HasSuccess { get; internal set; }
public string ErrorMessage { get; internal set; }
}
And I modified to this
public class ResultsLoadBankData
{
public string Bank { get; internal set; }
public int NrRecordsLoaded { get; internal set; }
public int NrRecordsSaved { get; internal set; }public bool HasSuccess { get; internal set; }
public string ErrorMessage { get; internal set; }
}
Also , there were many other small modifications when loading data.
Infovalutar
And one hour passes...(This is the result of 1 hour per day auto-challenge as a full cycle developer for an exchange rates application)
( You can see the sources at https://github.com/ignatandrei/InfoValutar/ )
Leave a Reply