Skip to content

Commit

Permalink
Replace IE WebBrowser control With Edge control
Browse files Browse the repository at this point in the history
This change affects the login process only. Instead of using the outdated IE browser to display the login screen modern Edge browser is use. This control requires at least Edge version 88. As of 2020.11.20 the canary build of Edge is required, this should be default Edge version by mid December.
  • Loading branch information
tsunez committed Nov 23, 2020
1 parent 14c2bea commit 9af6292
Show file tree
Hide file tree
Showing 320 changed files with 119,001 additions and 63,485 deletions.
Binary file removed Build/.nuget/NuGet.exe
Binary file not shown.
6 changes: 0 additions & 6 deletions Build/.nuget/Nuget.Config

This file was deleted.

19 changes: 19 additions & 0 deletions Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -61,6 +63,15 @@
<Reference Include="Microsoft.Practices.ObjectBuilder">
<HintPath>..\References\Microsoft.Practices.ObjectBuilder.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.674.0, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\lib\net462\Microsoft.Web.WebView2.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.WinForms, Version=1.0.674.0, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\lib\net462\Microsoft.Web.WebView2.WinForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.674.0, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\lib\net462\Microsoft.Web.WebView2.Wpf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
Expand All @@ -77,8 +88,16 @@
</ItemGroup>
<ItemGroup>
<None Include="key.snk" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand Down
4 changes: 4 additions & 0 deletions Common/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.674-prerelease" targetFramework="net471" />
</packages>
26 changes: 4 additions & 22 deletions CxViewer.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.0
# Visual Studio Version 16
VisualStudioVersion = 16.0.30711.63
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CxViewerVSIX", "CxViewerVSIX\CxViewerVSIX.csproj", "{0D4CC225-7BF6-4EB8-9936-C6FD86FABCAB}"
EndProject
Expand Down Expand Up @@ -87,25 +87,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(TeamFoundationVersionControl) = preSolution
SccNumberOfProjects = 6
SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C}
SccTeamFoundationServer = http://tfs2013:8080/tfs/defaultcollection
SccLocalPath0 = .
SccProjectUniqueName1 = CxViewerVSIX\\CxViewerVSIX.csproj
SccProjectName1 = CxViewerVSIX
SccLocalPath1 = CxViewerVSIX
SccProjectUniqueName2 = Common\\Common.csproj
SccProjectName2 = Common
SccLocalPath2 = Common
SccProjectUniqueName3 = CxViewerColorButton\\ColorButton.csproj
SccProjectName3 = CxViewerColorButton
SccLocalPath3 = CxViewerColorButton
SccProjectUniqueName4 = CxViewerDgvFilterPopup\\DgvFilterPopup.csproj
SccProjectName4 = CxViewerDgvFilterPopup
SccLocalPath4 = CxViewerDgvFilterPopup
SccProjectUniqueName5 = CxViewerAction\\CxViewerAction.csproj
SccProjectName5 = CxViewerAction
SccLocalPath5 = CxViewerAction
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0A39564A-A58D-44FB-8E14-97D47A7E7F47}
EndGlobalSection
EndGlobal
32 changes: 29 additions & 3 deletions CxViewerAction/CxViewerAction.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<ApplicationIcon>Resources\cx.ico</ApplicationIcon>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -149,9 +151,17 @@
</Reference>
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
<Reference Include="Microsoft.Web.WebView2.Core, Version=1.0.674.0, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\lib\net462\Microsoft.Web.WebView2.Core.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.WinForms, Version=1.0.674.0, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\lib\net462\Microsoft.Web.WebView2.WinForms.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Web.WebView2.Wpf, Version=1.0.674.0, Culture=neutral, PublicKeyToken=2a8ab48044d2601e, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\lib\net462\Microsoft.Web.WebView2.Wpf.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
Expand Down Expand Up @@ -351,6 +361,12 @@
<Compile Include="Views\DockedView\ScanProcessCtrl.Designer.cs">
<DependentUpon>ScanProcessCtrl.cs</DependentUpon>
</Compile>
<Compile Include="Views\DockedView\WebViewLogin.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Views\DockedView\WebViewLogin.Designer.cs">
<DependentUpon>WebViewLogin.cs</DependentUpon>
</Compile>
<Compile Include="Views\EditRemarkPopUp.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -583,6 +599,9 @@
<DependentUpon>ScanProcessCtrl.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Views\DockedView\WebViewLogin.resx">
<DependentUpon>WebViewLogin.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Views\EditRemarkPopUp.resx">
<DependentUpon>EditRemarkPopUp.cs</DependentUpon>
<SubType>Designer</SubType>
Expand Down Expand Up @@ -692,6 +711,13 @@
<ProjectExtensions>
<VisualStudio />
</ProjectExtensions>
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.674-prerelease\build\Microsoft.Web.WebView2.targets'))" />
</Target>
<!--<Target Name="AfterBuild">
<PropertyGroup>
<DllName>$(AssemblyName).dll</DllName>
Expand Down
98 changes: 42 additions & 56 deletions CxViewerAction/Helpers/LoginHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ internal static LoginResult DoLoginWithoutForm(out bool cancelPressed, bool relo
static LoginResult TryDoLogin(out bool cancelPressed, bool relogin, bool showForm)
{
cancelPressed = false;

//TODO check what to do with this
if (_isLogged && !relogin)
{
Expand Down Expand Up @@ -308,77 +307,64 @@ public static LoginResult ExecuteLogin(LoginData login, out bool cancelPressed,
{
LoginResult loginResult = new LoginResult();
cancelPressed = !login.IsLogging;

if (login != null && login.IsLogging && (!_isLogged || relogin))
{
CxWebServiceClient client = null;

BackgroundWorkerHelper bg = new BackgroundWorkerHelper(delegate
try
{
try
{
client = new CxWebServiceClient(login);
}
catch (Exception e)
{
Logger.Create().Error(e.ToString());
System.Windows.Forms.MessageBox.Show(e.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK);
return;
}

if (client == null)
{
System.Windows.Forms.MessageBox.Show("Cannot connect to server", "Error", System.Windows.Forms.MessageBoxButtons.OK);
return;
}

// perform login
try
{
serverBaseUrl = login.ServerBaseUri;

bool loginSucceeded = DolLogin(login, client);
if (loginSucceeded) {
loginResult.IsSuccesfull = true;
loginResult.AuthenticationData = login;
}
_loginResult = loginResult;
}
catch (WebException ex)
{
Logger.Create().Error(ex.Message, ex);
loginResult.LoginResultType = LoginResultType.UnknownServerName;
loginResult.LoginResultMessage = ex.Message;
loginResult.IsSuccesfull = false;
}
catch (Exception ex)
{
Logger.Create().Error(ex.Message, ex);
loginResult.LoginResultType = LoginResultType.UnknownError;
loginResult.LoginResultMessage = ex.Message;
client = new CxWebServiceClient(login);
}
catch (Exception e)
{
Logger.Create().Error(e.ToString());
System.Windows.Forms.MessageBox.Show(e.Message, "Error", System.Windows.Forms.MessageBoxButtons.OK);
return null;
}
if (client == null)
{
System.Windows.Forms.MessageBox.Show("Cannot connect to server", "Error", System.Windows.Forms.MessageBoxButtons.OK);
return null;
}
// perform login
try
{
serverBaseUrl = login.ServerBaseUri;
bool loginSucceeded = DolLogin(login, client);
if (loginSucceeded) {
loginResult.IsSuccesfull = true;
loginResult.AuthenticationData = login;
}
finally
_loginResult = loginResult;
}
catch (WebException ex)
{
Logger.Create().Error(ex.Message, ex);
loginResult.LoginResultType = LoginResultType.UnknownServerName;
loginResult.LoginResultMessage = ex.Message;
loginResult.IsSuccesfull = false;
}
catch (Exception ex)
{
Logger.Create().Error(ex.Message, ex);
loginResult.LoginResultType = LoginResultType.UnknownError;
loginResult.LoginResultMessage = ex.Message;
}
finally
{
if (client != null)
{
if (client != null)
client.Close();
client.Close();
}

},
login.ReconnectInterval * 1000, login.ReconnectCount);

cancelPressed = !bg.DoWork(WAIT_DIALOG_PROGRESS_TEXT);
}
}

return loginResult;
}


public static bool DolLogin(LoginData login, CxWebServiceClient client)
{
bool loginSucceeded = false;
_oidcLoginHelper.resetLatestResult();
OidcLoginResult oidcLoginResult = _oidcLoginHelper.ConnectToIdentidyProvider(login.ServerBaseUri);

if (oidcLoginResult.IsSuccessful)
{
//Add logs for print Server url and AccessToken
Expand Down
31 changes: 7 additions & 24 deletions CxViewerAction/Helpers/OIDCLoginHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ namespace CxViewerAction.Helpers
public class OIDCLoginHelper
{
private readonly OidcLoginFrm _oidcLoginFrm = new OidcLoginFrm();
private readonly AutoResetEvent _oidcLoginEvent = new AutoResetEvent(false);
public static bool errorWasShown = false;

private OidcLoginResult _latestResult;
public static bool errorWasShown = false;

public OIDCLoginHelper()
{
_oidcLoginFrm.OidcLoginCtrl2.NavigationCompleted += OidcLoginCtrlOnNavigationCompleted;
_oidcLoginFrm.OidcLoginCtrl2.NavigationError += OidcLoginCtrlOnNavigationError;
_oidcLoginFrm.UserClosedForm += OnUserClosedForm;
_oidcLoginFrm.NavigationCompleted += OidcLoginCtrlOnNavigationCompleted;
_oidcLoginFrm.NavigationError += OidcLoginCtrlOnNavigationError;
_oidcLoginFrm.UserClosedForm += OnUserClosedForm;
_latestResult = new OidcLoginResult(false, string.Empty, null);
}

Expand All @@ -30,39 +28,24 @@ public void resetLatestResult()
private void OnUserClosedForm(object sender, EventArgs e)
{
_latestResult = new OidcLoginResult(false, "Exit", null);
_oidcLoginEvent.Set();
}

private void OidcLoginCtrlOnNavigationError(object sender, string errorMessage)
{
errorWasShown = true;
MessageBox.Show(errorMessage,"Error", MessageBoxButtons.OK);
_latestResult = new OidcLoginResult(false, errorMessage, null);
_oidcLoginEvent.Set();
}

private void OidcLoginCtrlOnNavigationCompleted(object sender, string code)
{
_latestResult = new OidcLoginResult(true, string.Empty, code);
_oidcLoginEvent.Set();
}

private void ConectAndWait(string baseServerUri)
{
_oidcLoginFrm.OidcLoginCtrl2.Invoke(new MethodInvoker(() =>
{
_oidcLoginFrm.Show();
_oidcLoginFrm.ConnectToIdentidyProvider(baseServerUri);
}));
_oidcLoginEvent.WaitOne();
_latestResult = new OidcLoginResult(true, string.Empty, code);
}

public OidcLoginResult ConnectToIdentidyProvider(string baseServerUri)
{

ConectAndWait(baseServerUri);

_oidcLoginFrm.CloseForm();
_oidcLoginFrm.ConnectToIdentidyProvider(baseServerUri);
_oidcLoginFrm.ShowDialog();
return _latestResult;
}

Expand Down
Loading

0 comments on commit 9af6292

Please sign in to comment.