Client: added Browser-error-page
This commit is contained in:
@@ -78,7 +78,13 @@ namespace Client.Config
|
||||
//ReadConfig Url compositing
|
||||
Config.ConnectionConfig.ReadConfigUrl = "http://" + Config.ConnectionConfig.ServerUrl + ":" + Config.ConnectionConfig.ServerPort + "/" + Constants.ConfigPage;
|
||||
Config.ConnectionConfig.StartingUrl = "http://" + Config.ConnectionConfig.ServerUrl + ":" + Config.ConnectionConfig.ServerPort + "/" + Constants.StartingPage;
|
||||
|
||||
|
||||
//ErrorPage content
|
||||
if (File.Exists(Constants.errorPageFile))
|
||||
Config.ConnectionConfig.ErrorPage = File.ReadAllText(Constants.errorPageFile);
|
||||
else
|
||||
throw new Exception(@"File Error: """ + Constants.errorPageFile + @""" not found");
|
||||
|
||||
}
|
||||
|
||||
private static void ValidationHandler(object sender, ValidationEventArgs e)
|
||||
|
||||
@@ -15,6 +15,6 @@ namespace Client.Config.SubModels
|
||||
public string ReadConfigUrl { get; set; }
|
||||
public Boolean DeleteCahceFolderOnStartup { get; set; }
|
||||
public Boolean BypassReadConfiguration { get; set; }
|
||||
|
||||
public string ErrorPage { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,5 +44,10 @@
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="error.pg">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -68,6 +68,10 @@ namespace Client.Utils
|
||||
|
||||
public const string StartingPage = "index.html";
|
||||
public const string ConfigPage = "api/configuration/client";
|
||||
public const string errorPageFile = @"./error.pg";
|
||||
public const string errorPageUrl = @"error://error/";
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -37,6 +37,7 @@ namespace CMS_Client.Browser_Tools
|
||||
AddFunction("maximizeForm").Execute += maximizeForm;
|
||||
AddFunction("closeForm").Execute += closeForm;
|
||||
AddFunction("forceStepFocus").Execute += forceStepFocus;
|
||||
AddFunction("reloadBrokenPage").Execute += reloadBrokenPage;
|
||||
|
||||
AddFunction("setNcWindowState").Execute += setNcWindowState;
|
||||
AddFunction("getNcWindowState").Execute += getNcWindowState;
|
||||
@@ -47,7 +48,6 @@ namespace CMS_Client.Browser_Tools
|
||||
AddFunction("startNewProcess").Execute += startNewProcess;
|
||||
AddFunction("openOrStartProcess").Execute += openOrStartProcess;
|
||||
AddFunction("isVirtualKeybConfigured").Execute += isVirtualKeybConfigured;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -99,12 +99,19 @@ namespace CMS_Client.Browser_Tools
|
||||
//Invoke method if is needed or call the method in STD mode
|
||||
mainForm.Close();
|
||||
}
|
||||
|
||||
//Reload Broken Page
|
||||
private void reloadBrokenPage(object sender, CfrV8HandlerExecuteEventArgs e)
|
||||
{
|
||||
//Invoke method if is needed or call the method in STD mode
|
||||
mainForm.reloadBrokenPage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region NC_BEHAVIOUR_METHODS
|
||||
|
||||
|
||||
public void setNcWindowState(object sender, CfrV8HandlerExecuteEventArgs e)
|
||||
{
|
||||
if (e.Arguments.Count() == 0)
|
||||
|
||||
@@ -254,9 +254,7 @@
|
||||
<ItemGroup>
|
||||
<None Include="Resources\Client_Icon.ico" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Microsoft\Win32\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
|
||||
+37
-7
@@ -12,6 +12,7 @@ using System.Diagnostics;
|
||||
using CMS_Client.Browser_Tools;
|
||||
using Chromium.Remote;
|
||||
using Chromium.Remote.Event;
|
||||
using System.IO;
|
||||
|
||||
namespace CMS_Client.View
|
||||
{
|
||||
@@ -33,6 +34,7 @@ namespace CMS_Client.View
|
||||
private static IntPtr NcHandle;
|
||||
private int X = 0, Y = 0;
|
||||
private bool CntrlPressed;
|
||||
private string BrokenUrl;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region WINDOW_START_&_BEHAVIOUR_METHOD
|
||||
@@ -191,7 +193,6 @@ namespace CMS_Client.View
|
||||
ChromiumWebBrowser.RemoteProcessCreated += (e) =>{e.RenderProcessHandler.OnFocusedNodeChanged += BrowserNodeChanged;};
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -202,14 +203,16 @@ namespace CMS_Client.View
|
||||
{
|
||||
//Set the Load-Error global variable to TRUE
|
||||
LoadingError.Error = true;
|
||||
LoadingError.ErrorInfo = e.ErrorCode.GetTypeCode() + " - " + e.ErrorText;
|
||||
LoadingError.ErrorInfo = e.ErrorCode.GetHashCode() + " - " + e.ErrorText;
|
||||
if(e.FailedUrl != Constants.errorPageUrl)
|
||||
this.BrokenUrl = e.FailedUrl;
|
||||
|
||||
//write the error in the Title Bar
|
||||
SetWindowTitle(LoadingError.ErrorInfo);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//On browser Load-Changed. Event Handler called by Browser
|
||||
private void BrowserLoadsChanged(object sender, CfxOnLoadingStateChangeEventArgs e)
|
||||
{
|
||||
@@ -224,7 +227,9 @@ namespace CMS_Client.View
|
||||
|
||||
//If is an Error Show the Error page
|
||||
if (LoadingError.Error && !LoadingError.ErrorInfo.Contains("ERR_ABORTED"))
|
||||
MessageBox.Show("Error While Loading the Page: " + LoadingError.ErrorInfo + "\nPress:\n - F5: reload the Page\n - F1: Back to last Page");
|
||||
{
|
||||
Browser.LoadString(Config.ConnectionConfig.ErrorPage, Constants.errorPageUrl);
|
||||
}
|
||||
|
||||
//Set focus on the page
|
||||
BrowserFocus();
|
||||
@@ -272,13 +277,18 @@ namespace CMS_Client.View
|
||||
if (Config.ClientConfig.DeveloperMode)
|
||||
{
|
||||
if (e.Event.WindowsKeyCode == (int)Keys.F1)
|
||||
Browser.Browser.GoBack();
|
||||
Browser.GoBack();
|
||||
|
||||
if (e.Event.WindowsKeyCode == (int)Keys.F2)
|
||||
Browser.Browser.GoForward();
|
||||
Browser.GoForward();
|
||||
|
||||
if (e.Event.WindowsKeyCode == (int)Keys.F5)
|
||||
Browser.Browser.ReloadIgnoreCache();
|
||||
{
|
||||
if (Browser.Url.AbsoluteUri != Constants.errorPageUrl)
|
||||
Browser.Browser.ReloadIgnoreCache();
|
||||
else
|
||||
Browser.LoadUrl(this.BrokenUrl);
|
||||
}
|
||||
|
||||
if (e.Event.WindowsKeyCode == (int)Keys.F10)
|
||||
ShowChromeVersion();
|
||||
@@ -398,11 +408,31 @@ namespace CMS_Client.View
|
||||
NcWindow.hideVirtualKeyboard();
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region INVOKES_&_OTHER_METHODS
|
||||
|
||||
//Reload Broken Url
|
||||
public void reloadBrokenPage()
|
||||
{
|
||||
if (!this.IsDisposed)
|
||||
{
|
||||
if (this.InvokeRequired)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if(!String.IsNullOrWhiteSpace(this.BrokenUrl))
|
||||
Browser.LoadUrl(this.BrokenUrl);
|
||||
});
|
||||
else
|
||||
{
|
||||
if (!String.IsNullOrWhiteSpace(this.BrokenUrl))
|
||||
Browser.LoadUrl(this.BrokenUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Show MainWindow Method
|
||||
private void ShowWindow()
|
||||
|
||||
Reference in New Issue
Block a user