Skip to content

Commit

Permalink
Added an error dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
lextm committed Apr 3, 2023
1 parent 1b67264 commit 3340910
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
11 changes: 6 additions & 5 deletions JexusManager/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ private void btnRemoveSite_Click(object sender, EventArgs e)
return;
}

if (!(selectedNode.Tag is global::Microsoft.Web.Administration.Site node))
if (!(selectedNode.Tag is Site node))
{
return;
}
Expand Down Expand Up @@ -504,7 +504,7 @@ private void Form1FormClosing(object sender, FormClosingEventArgs e)
var conflict = AsyncHelper.RunSync(() => ((JexusServerManager)serverNode.ServerManager).ByeAsync());
if (Environment.MachineName != conflict)
{
MessageBox.Show(string.Format("The server is also connected to {0}. Making changes on multiple clients might corrupt server configuration.", conflict), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
UIService.ShowMessage(string.Format("The server is also connected to {0}. Making changes on multiple clients might corrupt server configuration.", conflict), Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
Expand All @@ -522,7 +522,7 @@ private void Form1FormClosing(object sender, FormClosingEventArgs e)
message.AppendLine("Could not connect to the specified computer.")
.AppendLine()
.AppendFormat("Details: {0}", previous?.Message ?? last.Message);
MessageBox.Show(message.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
UIService.ShowMessage(message.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Expand Down Expand Up @@ -946,7 +946,7 @@ internal void ConnectToServer()
message.AppendLine("Could not connect to the specified computer.")
.AppendLine()
.AppendFormat("Details: {0}", last?.Message);
MessageBox.Show(message.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
UIService.ShowMessage(message.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}

Expand Down Expand Up @@ -1051,6 +1051,7 @@ private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs
return;
}

// TODO: disable this so that config file errors can be investigated.
if (server.ServerManager == null && e.Button == MouseButtons.Right)
{
treeView1_NodeMouseDoubleClick(sender, e);
Expand Down Expand Up @@ -1080,7 +1081,7 @@ private void btnRestartSite_Click(object sender, EventArgs e)
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, Name, MessageBoxButtons.OK, MessageBoxIcon.Error);
UIService.ShowError(ex, string.Empty, Name, false);
}

btnRestartSite.Enabled = true;
Expand Down
21 changes: 11 additions & 10 deletions JexusManager/Tree/ServerTreeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public override void HandleDoubleClick(MainForm mainForm)
{
if (readOnly)
{
MessageBox.Show("Elevation is required. Please run Jexus Manager as administrator.");
MainForm.UIService.ShowMessage("Elevation is required. Please run Jexus Manager as administrator.", Text);
return;
}

Expand Down Expand Up @@ -180,10 +180,10 @@ public override void HandleDoubleClick(MainForm mainForm)
if (Mode == WorkingMode.Jexus)
{
var server = (JexusServerManager)ServerManager;
var version = AsyncHelper.RunSync(() => server.GetVersionAsync());
var version = AsyncHelper.RunSync(server.GetVersionAsync);
if (version == null)
{
MessageBox.Show("Authentication failed.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
MainForm.UIService.ShowMessage("Authentication failed.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
ServerManager = null;
_status = NodeStatus.Default;
mainForm.DisconnectButton.Enabled = true;
Expand All @@ -193,7 +193,7 @@ public override void HandleDoubleClick(MainForm mainForm)
if (version < JexusServerManager.MinimumServerVersion)
{
var toContinue =
MessageBox.Show(
MainForm.UIService.ShowMessage(
$"The server version is {version}, while minimum compatible version is {JexusServerManager.MinimumServerVersion}. Making changes might corrupt server configuration. Do you want to continue?",
Text,
MessageBoxButtons.YesNoCancel,
Expand All @@ -207,10 +207,10 @@ public override void HandleDoubleClick(MainForm mainForm)
}
}

var conflict = AsyncHelper.RunSync(() => server.HelloAsync());
var conflict = AsyncHelper.RunSync(server.HelloAsync);
if (Environment.MachineName != conflict)
{
MessageBox.Show(
MainForm.UIService.ShowMessage(
$"The server is also connected to {conflict}. Making changes on multiple clients might corrupt server configuration.",
Text,
MessageBoxButtons.OK,
Expand Down Expand Up @@ -246,7 +246,7 @@ public override void HandleDoubleClick(MainForm mainForm)
message.AppendLine("Could not connect to the specified computer.")
.AppendLine()
.AppendFormat("Details: {0}", last?.Message);
MessageBox.Show(message.ToString(), mainForm.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
MainForm.UIService.ShowMessage(message.ToString(), Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
HandleServerConnectionFailed();
}
finally
Expand Down Expand Up @@ -276,7 +276,7 @@ public override void LoadPanels(MainForm mainForm, ServiceContainer serviceConta
{
if (readOnly)
{
MessageBox.Show("Elevation is required. Please run Jexus Manager as administrator.");
MainForm.UIService.ShowMessage("Elevation is required. Please run Jexus Manager as administrator.", Text);
return;
}

Expand Down Expand Up @@ -351,7 +351,7 @@ public bool LoadServer(ContextMenuStrip poolsMenu, ContextMenuStrip sitesMenu, C
{
if (readOnly)
{
MessageBox.Show("Elevation is required. Please run Jexus Manager as administrator.");
MainForm.UIService.ShowMessage("Elevation is required. Please run Jexus Manager as administrator.", Text);
return false;
}

Expand All @@ -368,8 +368,9 @@ public bool LoadServer(ContextMenuStrip poolsMenu, ContextMenuStrip sitesMenu, C
};
Nodes.Add(PoolsNode);
}
catch (Exception)
catch (Exception ex)
{
MainForm.UIService.ShowError(ex, string.Empty, Text, false);
return false;
}

Expand Down

0 comments on commit 3340910

Please sign in to comment.