in Tools/MultiplayerSessionHistoryViewer/Form1.cs [848:930]
private void LoadSessionHistoryToolStripMenuItem_Click(object sender, EventArgs e)
{
HistoricalDocument document = null;
var openFileDialog = new OpenFileDialog()
{
Filter = SessionHistoryFileFilter
};
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
using (StreamReader sr = new StreamReader(openFileDialog.FileName))
{
string fileContents = sr.ReadToEnd();
try
{
document = JsonConvert.DeserializeObject<HistoricalDocument>(fileContents);
}
catch (JsonSerializationException)
{
MessageBox.Show("Could not deserialize the file to a\nHistorical Document.", "Load Document Error");
}
}
}
if (document != null)
{
this.listView1.Items.Clear();
this.InitViews();
string[] arr = new string[QueryResultColumnCount]
{
document.SessionName,
document.Branch,
document.NumSnapshots.ToString(),
document.LastModified,
document.IsExpired.ToString(),
document.ActivityId
};
ListViewItem lvi = new ListViewItem(arr);
this.listView1.Items.Add(lvi);
foreach (DocumentStateSnapshot snapshot in document.DocumentSnapshots)
{
string hashKey = this.snapshotCache.GetHashString(
document.SessionName,
document.Branch,
snapshot.Change);
string snapshotBody;
if (snapshot.Change != SessionHistory.MaxChangeValue)
{
if (!this.snapshotCache.TryGetSnapshot(hashKey, out snapshotBody))
{
snapshotBody = snapshot.Body;
this.snapshotCache.AddSnapshotToCache(hashKey, snapshot.Body);
}
}
string[] lv2arr = new string[DocumentMetadataColumnCount]
{
snapshot.Change == SessionHistory.MaxChangeValue ? "expired" : snapshot.Change.ToString(),
snapshot.ModifiedByXuids,
snapshot.Timestamp.ToString(),
snapshot.TitleId,
snapshot.ServiceId,
snapshot.CorrelationId,
snapshot.ChangeDetails
};
ListViewItem lvi2 = new ListViewItem(lv2arr);
this.listView2.Items.Add(lvi2);
}
this.lblDocCount.Text = "1 document [offline]";
this.DisplayChangesInfo();
this.showingOfflineSession = true;
this.saveSessionHistoryToolStripMenuItem.Visible = false;
}
}