public async Task Refresh()
{
Workspace.IsBusy = true;
DocumentListModel docList = null;
try
{
if (this.IsSqlEditMode)
docList = await _model.GetDocuments(this.SqlText, null, this.MaxItems);
else
docList = await _model.GetDocuments(this.Filter.JoinedFilter, this.MaxItems);
}
catch (Exception e)
{
MessageBox.Show($"Error on performing query:{Environment.NewLine}{e.Message}");
}
if (docList != null)
{
var docs = new ObservableCollection<DocumentModel>(docList.Documents);
this.AvailableProperties.Clear();
foreach (var doc in docs)
{
foreach (var jp in doc.Json.Children())
{
addAvailableProperty(jp);
}
}
this.Documents = docs; //later - the Collection view is attached to PropertyChanged of this and needs the available properties
this.SqlText = docList.Sql;
updateSelectedViewInConfig();
}
Workspace.IsBusy = false;
}