mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-26 03:58:45 +08:00
Created interface IConnectionsUpdateChecker and modified SqlConnectionsUpdateChecker to implement it
This commit is contained in:
11
mRemoteV1/Config/Connections/IConnectionsUpdateChecker.cs
Normal file
11
mRemoteV1/Config/Connections/IConnectionsUpdateChecker.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public interface IConnectionsUpdateChecker
|
||||
{
|
||||
bool IsUpdateAvailable();
|
||||
|
||||
void IsUpdateAvailableAsync();
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ namespace mRemoteNG.Config.Connections
|
||||
|
||||
private void SqlUpdateTimer_SqlUpdateTimerElapsed()
|
||||
{
|
||||
_sqlUpdateChecker.IsDatabaseUpdateAvailableAsync();
|
||||
_sqlUpdateChecker.IsUpdateAvailableAsync();
|
||||
}
|
||||
|
||||
private void SQLUpdateCheckFinished(bool updateIsAvailable)
|
||||
|
||||
@@ -8,7 +8,7 @@ using mRemoteNG.Config.DatabaseConnectors;
|
||||
|
||||
namespace mRemoteNG.Config.Connections
|
||||
{
|
||||
public class SqlConnectionsUpdateChecker : IDisposable
|
||||
public class SqlConnectionsUpdateChecker : IDisposable, IConnectionsUpdateChecker
|
||||
{
|
||||
private readonly SqlDatabaseConnector _sqlConnector;
|
||||
private readonly SqlCommand _sqlQuery;
|
||||
@@ -25,21 +25,7 @@ namespace mRemoteNG.Config.Connections
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void IsDatabaseUpdateAvailableAsync()
|
||||
{
|
||||
var t = new Thread(IsDatabaseUpdateAvailableDelegate);
|
||||
t.SetApartmentState(ApartmentState.STA);
|
||||
t.Start();
|
||||
}
|
||||
|
||||
private void IsDatabaseUpdateAvailableDelegate()
|
||||
{
|
||||
IsDatabaseUpdateAvailable();
|
||||
}
|
||||
|
||||
public bool IsDatabaseUpdateAvailable()
|
||||
public bool IsUpdateAvailable()
|
||||
{
|
||||
ConnectToSqlDb();
|
||||
ExecuteQuery();
|
||||
@@ -47,6 +33,15 @@ namespace mRemoteNG.Config.Connections
|
||||
RaiseUpdateCheckFinishedEvent(updateIsAvailable);
|
||||
return updateIsAvailable;
|
||||
}
|
||||
|
||||
public void IsUpdateAvailableAsync()
|
||||
{
|
||||
var threadStart = new ThreadStart(() => IsUpdateAvailable());
|
||||
var thread = new Thread(threadStart);
|
||||
thread.SetApartmentState(ApartmentState.STA);
|
||||
thread.Start();
|
||||
}
|
||||
|
||||
private void ConnectToSqlDb()
|
||||
{
|
||||
try
|
||||
|
||||
@@ -127,6 +127,7 @@
|
||||
<Compile Include="App\Update\UpdateFile.cs" />
|
||||
<Compile Include="App\Update\UpdateInfo.cs" />
|
||||
<Compile Include="App\Windows.cs" />
|
||||
<Compile Include="Config\Connections\IConnectionsUpdateChecker.cs" />
|
||||
<Compile Include="Config\Connections\SqlUpdateAvailableEventArgs.cs" />
|
||||
<Compile Include="Config\Serializers\ActiveDirectoryDeserializer.cs" />
|
||||
<Compile Include="Config\Serializers\CsvConnectionsSerializerMremotengFormat.cs" />
|
||||
|
||||
Reference in New Issue
Block a user