in Tools/MultiplayerSessionHistoryViewer/Form1.cs [561:630]
private async Task SearchForHistoricalDocumentsAsync(QueryBundle queryBundle, bool addToStack)
{
this.tbSandbox.Text = queryBundle.Sandbox;
this.tbScid.Text = queryBundle.Scid;
this.tbTemplateName.Text = queryBundle.TemplateName;
this.tbQueryKey.Text = queryBundle.QueryKey;
this.cmbQueryType.SelectedIndex = queryBundle.QueryKeyIndex;
this.dateTimePicker1.Value = queryBundle.QueryFrom;
this.dateTimePicker2.Value = queryBundle.QueryTo;
string eToken = await ToolAuthentication.GetDevTokenSilentlyAsync(this.tbScid.Text, this.tbSandbox.Text);
this.lblExplanation.Text = "Searching for MPSD historical documents...";
Tuple<HttpStatusCode, string> response = null;
string continuationToken = null;
do
{
response = await this.QueryForHistoricalSessionDocuments(eToken, queryBundle, continuationToken);
if (response.Item1 == HttpStatusCode.OK)
{
continuationToken = response.Item2;
}
else
{
continuationToken = null;
}
}
while (continuationToken != null);
this.downloadPanel.Hide();
if (response.Item1 != HttpStatusCode.OK)
{
if (response.Item1 == HttpStatusCode.Unauthorized)
{
MessageBox.Show("Your auth token has expired. Re-try the query to get a new token", "Expired Token");
}
else if (response.Item1 == HttpStatusCode.InternalServerError)
{
MessageBox.Show("The server is busy. Please try again", QueryFailure);
}
else
{
MessageBox.Show(response.Item2, QueryFailure);
}
}
else
{
if (this.listView1.Items.Count == 0)
{
this.btnPriorQuery.Visible = this.queryStack.Count > 0; // show the back button following un unsuccesful query (if there was a prior successul one)
MessageBox.Show("No results found. Try expanding the query time window (if possible)\nor use different search criteria.", "Query Results");
}
else
{
if (addToStack)
{
this.queryStack.Push(queryBundle); // succesful query, so remember it
this.btnPriorQuery.Visible = this.queryStack.Count > 1;
}
else
{
this.btnPriorQuery.Visible = this.queryStack.Count > 0;
}
}
}
}