Controlling the exception thrown when trying to do operations on CHE and opening the login window when the cookie is expired.

This commit is contained in:
Adrià Ariste 2020-03-25 11:28:19 +01:00
Родитель c86927066d
Коммит d5dbfdfe6f
2 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -1419,6 +1419,32 @@ namespace LCS.Forms
ChangeProjectMenuItem_Click(null, null);
}
public void LoginToLCS()
{
WebBrowserHelper.FixBrowserVersion();
using var form = new Login();
form.ShowDialog();
if (form.Cancelled) return;
_cookies = GetUriCookieContainer();
if (_cookies == null) return;
_httpClientHelper = new HttpClientHelper(_cookies)
{
LcsUrl = _lcsUrl,
LcsUpdateUrl = _lcsUpdateUrl,
LcsDiagUrl = _lcsDiagUrl
};
if (_selectedProject != null)
{
_httpClientHelper.ChangeLcsProjectId(_selectedProject.Id.ToString());
_httpClientHelper.LcsProjectTypeId = _selectedProject.ProjectTypeId;
}
changeProjectMenuItem.Enabled = true;
cheInstanceContextMenu.Enabled = true;
saasInstanceContextMenu.Enabled = true;
logoutToolStripMenuItem.Enabled = true;
loginToLcsMenuItem.Enabled = false;
}
private void LogonToApplicationToolStripMenuItem_Click(object sender, EventArgs e)
{
Cursor = Cursors.WaitCursor;

Просмотреть файл

@ -12,10 +12,12 @@ namespace LCS
switch (e.Exception.Source)
{
case "System.Net.Http" when e.Exception.Message == $"Response status code does not indicate success: 498 ().":
case "mscorlib" when e.Exception.InnerException.Message == $"Response status code does not indicate success: 498 ().":
MessageBox.Show("Please login to LCS again. Your cookie is probably invalid or expired.");
var mainForm = GetMainForm();
mainForm.Cursor = Cursors.Default;
mainForm.SetLoginButtonEnabled();
mainForm.LoginToLCS();
break;
default: