Testing database connection.

This commit is contained in:
Fey 2026-02-01 16:40:44 +01:00
parent c83d69a200
commit 20ee473fda
4 changed files with 427 additions and 307 deletions

View File

@ -6,7 +6,8 @@ using System.Threading.Tasks;
namespace Voile.Patchouli.Data namespace Voile.Patchouli.Data
{ {
public interface IVoileDataStorage public interface IVoileDataStorage
{ {
} bool Ping();
}
} }

View File

@ -1,6 +1,7 @@
using Microsoft.Data.Sqlite; using Microsoft.Data.Sqlite;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -12,7 +13,7 @@ namespace Voile.Storage.Sqlite
{ {
[VoilePlugin] [VoilePlugin]
[VoilePluginId(3)] [VoilePluginId(3)]
[DisplayName("SQLite")] [Voile.Patchouli.Reflection.DisplayName("SQLite")]
public class SqliteDataStorageFactory : IVoileDataStorageFactory public class SqliteDataStorageFactory : IVoileDataStorageFactory
{ {
public IVoileDataStorage CreateDataStorage() public IVoileDataStorage CreateDataStorage()
@ -20,6 +21,7 @@ namespace Voile.Storage.Sqlite
throw new NotImplementedException(); throw new NotImplementedException();
} }
[Description("The path to the SQLite database file. If it doesn't exist, it will be created")]
public string FilePath { get; set; } public string FilePath { get; set; }
private SqliteConnectionStringBuilder scsb; private SqliteConnectionStringBuilder scsb;

View File

@ -48,11 +48,15 @@
tabPagePickDataStorage = new TabPage(); tabPagePickDataStorage = new TabPage();
labelDataStorageHint = new Label(); labelDataStorageHint = new Label();
label5 = new Label(); label5 = new Label();
tabPageConfigureDataStorage = new TabPage();
dbSettingsErrorLabel = new Label();
dbTestTrafficLight = new PictureBox();
dbTestButton = new Button();
dbSettingsPropertyGrid = new PropertyGrid();
label6 = new Label();
buttonNext = new Button(); buttonNext = new Button();
buttonBack = new Button(); buttonBack = new Button();
openFileDialogCertificate = new OpenFileDialog(); openFileDialogCertificate = new OpenFileDialog();
tabPageConfigureDataStorage = new TabPage();
label6 = new Label();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
tabControl1.SuspendLayout(); tabControl1.SuspendLayout();
tabPageWelcome.SuspendLayout(); tabPageWelcome.SuspendLayout();
@ -60,6 +64,7 @@
((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox2).BeginInit();
tabPagePickDataStorage.SuspendLayout(); tabPagePickDataStorage.SuspendLayout();
tabPageConfigureDataStorage.SuspendLayout(); tabPageConfigureDataStorage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dbTestTrafficLight).BeginInit();
SuspendLayout(); SuspendLayout();
// //
// pictureBox1 // pictureBox1
@ -265,6 +270,64 @@
label5.TabIndex = 0; label5.TabIndex = 0;
label5.Text = resources.GetString("label5.Text"); label5.Text = resources.GetString("label5.Text");
// //
// tabPageConfigureDataStorage
//
tabPageConfigureDataStorage.Controls.Add(dbSettingsErrorLabel);
tabPageConfigureDataStorage.Controls.Add(dbTestTrafficLight);
tabPageConfigureDataStorage.Controls.Add(dbTestButton);
tabPageConfigureDataStorage.Controls.Add(dbSettingsPropertyGrid);
tabPageConfigureDataStorage.Controls.Add(label6);
tabPageConfigureDataStorage.Location = new Point(4, 24);
tabPageConfigureDataStorage.Name = "tabPageConfigureDataStorage";
tabPageConfigureDataStorage.Size = new Size(348, 384);
tabPageConfigureDataStorage.TabIndex = 3;
tabPageConfigureDataStorage.Text = "Configure Date Storage";
tabPageConfigureDataStorage.UseVisualStyleBackColor = true;
//
// dbSettingsErrorLabel
//
dbSettingsErrorLabel.AutoSize = true;
dbSettingsErrorLabel.Location = new Point(3, 70);
dbSettingsErrorLabel.Name = "dbSettingsErrorLabel";
dbSettingsErrorLabel.Size = new Size(77, 15);
dbSettingsErrorLabel.TabIndex = 9;
dbSettingsErrorLabel.Text = "TEST_RESULT";
//
// dbTestTrafficLight
//
dbTestTrafficLight.Image = Properties.Resources.SETUPAPI_18_1_32x32x4;
dbTestTrafficLight.Location = new Point(214, 70);
dbTestTrafficLight.Name = "dbTestTrafficLight";
dbTestTrafficLight.Size = new Size(32, 32);
dbTestTrafficLight.TabIndex = 8;
dbTestTrafficLight.TabStop = false;
//
// dbTestButton
//
dbTestButton.Location = new Point(252, 70);
dbTestButton.Name = "dbTestButton";
dbTestButton.Size = new Size(93, 32);
dbTestButton.TabIndex = 2;
dbTestButton.Text = "Test Settings";
dbTestButton.UseVisualStyleBackColor = true;
dbTestButton.Click += dbTestButton_Click;
//
// dbSettingsPropertyGrid
//
dbSettingsPropertyGrid.Location = new Point(3, 108);
dbSettingsPropertyGrid.Name = "dbSettingsPropertyGrid";
dbSettingsPropertyGrid.Size = new Size(342, 273);
dbSettingsPropertyGrid.TabIndex = 1;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(3, 0);
label6.Name = "label6";
label6.Size = new Size(38, 15);
label6.TabIndex = 0;
label6.Text = "label6";
//
// buttonNext // buttonNext
// //
buttonNext.Enabled = false; buttonNext.Enabled = false;
@ -293,25 +356,6 @@
openFileDialogCertificate.Filter = "X.509 Certificate (*.cer)|*.cer"; openFileDialogCertificate.Filter = "X.509 Certificate (*.cer)|*.cer";
openFileDialogCertificate.Title = "Open Voile License File"; openFileDialogCertificate.Title = "Open Voile License File";
// //
// tabPageConfigureDataStorage
//
tabPageConfigureDataStorage.Controls.Add(label6);
tabPageConfigureDataStorage.Location = new Point(4, 24);
tabPageConfigureDataStorage.Name = "tabPageConfigureDataStorage";
tabPageConfigureDataStorage.Size = new Size(348, 384);
tabPageConfigureDataStorage.TabIndex = 3;
tabPageConfigureDataStorage.Text = "Configure Date Storage";
tabPageConfigureDataStorage.UseVisualStyleBackColor = true;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(3, 0);
label6.Name = "label6";
label6.Size = new Size(38, 15);
label6.TabIndex = 0;
label6.Text = "label6";
//
// FirstRunWizard // FirstRunWizard
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
@ -338,6 +382,7 @@
tabPagePickDataStorage.PerformLayout(); tabPagePickDataStorage.PerformLayout();
tabPageConfigureDataStorage.ResumeLayout(false); tabPageConfigureDataStorage.ResumeLayout(false);
tabPageConfigureDataStorage.PerformLayout(); tabPageConfigureDataStorage.PerformLayout();
((System.ComponentModel.ISupportInitialize)dbTestTrafficLight).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }
@ -367,5 +412,9 @@
private Label labelDataStorageHint; private Label labelDataStorageHint;
private TabPage tabPageConfigureDataStorage; private TabPage tabPageConfigureDataStorage;
private Label label6; private Label label6;
private PropertyGrid dbSettingsPropertyGrid;
private Button dbTestButton;
private PictureBox dbTestTrafficLight;
private Label dbSettingsErrorLabel;
} }
} }

View File

@ -10,304 +10,372 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using Voile.Patchouli.Data;
using Voile.Patchouli.Reflection; using Voile.Patchouli.Reflection;
using Voile.Properties; using Voile.Properties;
namespace Voile namespace Voile
{ {
public partial class FirstRunWizard : Form public partial class FirstRunWizard : Form
{ {
public FirstRunWizard() public FirstRunWizard()
{ {
InitializeComponent(); InitializeComponent();
DisplayTabPage(0); DisplayTabPage(0);
} }
private TabPage[] allPages; private TabPage[] allPages;
private int currentTabPage; private int currentTabPage;
private Stack<int> pastPages; private Stack<int> pastPages;
private bool beginnerMode; private bool beginnerMode;
private FileInfo licenceCertificateFileInfo; private FileInfo licenceCertificateFileInfo;
private byte[] licenseBuffer; private byte[] licenseBuffer;
private int licenseState; private int licenseState;
private X509Certificate licenseCertificate; private X509Certificate licenseCertificate;
private bool sharewareMode; private bool sharewareMode;
private VoilePluginInfo selectedDataStorage; private VoilePluginInfo selectedDataStorage;
private IVoileDataStorageFactory voileDataStorageFactory;
private bool dataStorageConnectionSucessful;
public void DisplayTabPage(int target, bool isGoingBack = false) public void DisplayTabPage(int target, bool isGoingBack = false)
{ {
if (pastPages == null) if (pastPages == null)
pastPages = new Stack<int>(); pastPages = new Stack<int>();
else else
pastPages.Push(target); pastPages.Push(target);
if (allPages == null) if (allPages == null)
{ {
allPages = new TabPage[tabControl1.TabPages.Count]; allPages = new TabPage[tabControl1.TabPages.Count];
for (int i = 0; i < tabControl1.TabPages.Count; i++) for (int i = 0; i < tabControl1.TabPages.Count; i++)
{ {
allPages[i] = tabControl1.TabPages[i]; allPages[i] = tabControl1.TabPages[i];
} }
} }
tabControl1.TabPages.Clear(); tabControl1.TabPages.Clear();
tabControl1.TabPages.Add(allPages[target]); tabControl1.TabPages.Add(allPages[target]);
currentTabPage = target; currentTabPage = target;
RefreshView(); RefreshView();
} }
void RefreshView() void RefreshView()
{ {
buttonBack.Enabled = false; buttonBack.Enabled = false;
buttonNext.Enabled = false; buttonNext.Enabled = false;
if (pastPages != null) if (pastPages != null)
{ {
if (pastPages.Count > 0) if (pastPages.Count > 0)
{ {
buttonBack.Enabled = true; buttonBack.Enabled = true;
} }
} }
switch (currentTabPage) switch (currentTabPage)
{ {
case 0: case 0:
beginnerMode = radioButtonAmBegginer.Checked; beginnerMode = radioButtonAmBegginer.Checked;
buttonNext.Enabled = radioButtonAmBegginer.Checked || radioButtonAmExpert.Checked; buttonNext.Enabled = radioButtonAmBegginer.Checked || radioButtonAmExpert.Checked;
break; break;
case 1: case 1:
//Lizenzstatus validieren. //Lizenzstatus validieren.
buttonValidateLicense.Enabled = ((licenceCertificateFileInfo != null) & radioButtonHasLicense.Checked); buttonValidateLicense.Enabled = ((licenceCertificateFileInfo != null) & radioButtonHasLicense.Checked);
buttonLoadLicenseFile.Enabled = radioButtonHasLicense.Checked; buttonLoadLicenseFile.Enabled = radioButtonHasLicense.Checked;
pictureBox2.Visible = radioButtonHasLicense.Checked; pictureBox2.Visible = radioButtonHasLicense.Checked;
if (pictureBox2.Visible) if (pictureBox2.Visible)
{ {
switch(licenseState) switch (licenseState)
{ {
case 0: //Noch nichts geladen. case 0: //Noch nichts geladen.
pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4; //Fragezeichen pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4; //Fragezeichen
break; break;
case 1: //Root cert konnte nicht geladen werden. case 1: //Root cert konnte nicht geladen werden.
case 2: //Lizenz file konnte nicht geladen werden. case 2: //Lizenz file konnte nicht geladen werden.
case 3: //Lizenzzertifikat wurde nicht von sophia.net ausgestellt. case 3: //Lizenzzertifikat wurde nicht von sophia.net ausgestellt.
case 4: //Lizennzertifikat enthält keine sophia.net extensions case 4: //Lizennzertifikat enthält keine sophia.net extensions
case 5: //sophia.net extension ist leer case 5: //sophia.net extension ist leer
case 7: //sophia.net extension hat ungültige länge case 7: //sophia.net extension hat ungültige länge
pictureBox2.Image = Resources.TRFFC10C_1_32x32x4; //rote Ampel pictureBox2.Image = Resources.TRFFC10C_1_32x32x4; //rote Ampel
break; break;
case 6: //gültige lizenz case 6: //gültige lizenz
pictureBox2.Image = Resources.TRFFC10A_1_32x32x4; //grüne Ampel pictureBox2.Image = Resources.TRFFC10A_1_32x32x4; //grüne Ampel
break; break;
case 8: case 8:
default: default:
pictureBox2.Image = Resources.iblicense_133_1_32x32x4; //Ausrufezeichen pictureBox2.Image = Resources.iblicense_133_1_32x32x4; //Ausrufezeichen
licenseState = 8; licenseState = 8;
break; break;
} }
} }
//Können wir weiter machen? //Können wir weiter machen?
sharewareMode = radioButtonNoLicense.Checked; sharewareMode = radioButtonNoLicense.Checked;
buttonNext.Enabled = (sharewareMode) | (licenseState == 6); buttonNext.Enabled = (sharewareMode) | (licenseState == 6);
break; break;
case 2: case 2:
labelDataStorageHint.Text = " "; labelDataStorageHint.Text = " ";
if (!dataStorageRadioButtonsGenerated) if (!dataStorageRadioButtonsGenerated)
GenerateDataStorageRadioButtons(); GenerateDataStorageRadioButtons();
//TODO: Hier zusätzlich Lizenzvalidierung einfügen. //TODO: Hier zusätzlich Lizenzvalidierung einfügen.
buttonNext.Enabled = selectedDataStorage != null; buttonNext.Enabled = selectedDataStorage != null;
break; break;
default: case 3:
MessageBox.Show("Could not find handler for the current tab page."); dbSettingsErrorLabel.Text = "";
return; if (voileDataStorageFactory == null)
} {
} dbSettingsPropertyGrid.SelectedObject = selectedDataStorage.GetPluginInstance();
}
break;
default:
MessageBox.Show("Could not find handler for the current tab page.");
return;
}
}
private bool dataStorageRadioButtonsGenerated; private bool dataStorageRadioButtonsGenerated;
private RadioButton[] dataStorageRadioButtons; private RadioButton[] dataStorageRadioButtons;
private void GenerateDataStorageRadioButtons() private void GenerateDataStorageRadioButtons()
{ {
VoilePluginManager pluginManager = VoilePluginManager.GetInstance(); VoilePluginManager pluginManager = VoilePluginManager.GetInstance();
IReadOnlyList<VoilePluginInfo> dataStoragePlugins = pluginManager.GetDataStorages(); IReadOnlyList<VoilePluginInfo> dataStoragePlugins = pluginManager.GetDataStorages();
dataStorageRadioButtons = new RadioButton[dataStoragePlugins.Count]; dataStorageRadioButtons = new RadioButton[dataStoragePlugins.Count];
int top = labelDataStorageHint.Top; int top = labelDataStorageHint.Top;
top += labelDataStorageHint.Height; top += labelDataStorageHint.Height;
int left = labelDataStorageHint.Left; int left = labelDataStorageHint.Left;
for (int i = 0; i < dataStorageRadioButtons.Length; i++) for (int i = 0; i < dataStorageRadioButtons.Length; i++)
{ {
RadioButton childRadioButton = new RadioButton(); RadioButton childRadioButton = new RadioButton();
childRadioButton.Parent = tabPagePickDataStorage; childRadioButton.Parent = tabPagePickDataStorage;
if (dataStoragePlugins[i].Incomplete) if (dataStoragePlugins[i].Incomplete)
childRadioButton.Enabled = false; childRadioButton.Enabled = false;
string radioButtonLabel = dataStoragePlugins[i].DisplayName; string radioButtonLabel = dataStoragePlugins[i].DisplayName;
if (dataStoragePlugins[i].NeededEntitlement.HasValue) if (dataStoragePlugins[i].NeededEntitlement.HasValue)
radioButtonLabel += " (needs license)"; radioButtonLabel += " (needs license)";
childRadioButton.AutoSize = true; childRadioButton.AutoSize = true;
childRadioButton.Text = radioButtonLabel; childRadioButton.Text = radioButtonLabel;
if (selectedDataStorage != null) if (selectedDataStorage != null)
childRadioButton.Checked = (selectedDataStorage.Id == dataStoragePlugins[i].Id); childRadioButton.Checked = (selectedDataStorage.Id == dataStoragePlugins[i].Id);
childRadioButton.Top = top; childRadioButton.Top = top;
childRadioButton.Left = left; childRadioButton.Left = left;
childRadioButton.Tag = dataStoragePlugins[i]; childRadioButton.Tag = dataStoragePlugins[i];
top += childRadioButton.Height; top += childRadioButton.Height;
dataStorageRadioButtons[i] = childRadioButton; dataStorageRadioButtons[i] = childRadioButton;
dataStorageRadioButtons[i].CheckedChanged += OnDataStrorageSelected; dataStorageRadioButtons[i].CheckedChanged += OnDataStrorageSelected;
} }
dataStorageRadioButtonsGenerated = true; dataStorageRadioButtonsGenerated = true;
} }
private void OnDataStrorageSelected(object? sender, EventArgs e) private void OnDataStrorageSelected(object? sender, EventArgs e)
{ {
RadioButton senderUnboxed = sender as RadioButton; RadioButton senderUnboxed = sender as RadioButton;
if (senderUnboxed == null) if (senderUnboxed == null)
throw new Voile.Common.VoileException("Could not unbox sender."); throw new Voile.Common.VoileException("Could not unbox sender.");
VoilePluginInfo pluginInfo = senderUnboxed.Tag as VoilePluginInfo; VoilePluginInfo pluginInfo = senderUnboxed.Tag as VoilePluginInfo;
if (pluginInfo == null) if (pluginInfo == null)
throw new Common.VoileException("Could not unbox plugin info"); throw new Common.VoileException("Could not unbox plugin info");
selectedDataStorage = pluginInfo; selectedDataStorage = pluginInfo;
RefreshView(); RefreshView();
} }
private void radioButton3_CheckedChanged(object sender, EventArgs e) private void radioButton3_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void radioButtonAmBegginer_CheckedChanged(object sender, EventArgs e) private void radioButtonAmBegginer_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void radioButtonAmExpert_CheckedChanged(object sender, EventArgs e) private void radioButtonAmExpert_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void radioButtonNoLicense_CheckedChanged(object sender, EventArgs e) private void radioButtonNoLicense_CheckedChanged(object sender, EventArgs e)
{ {
RefreshView(); RefreshView();
} }
private void pictureBox2_Click(object sender, EventArgs e) private void pictureBox2_Click(object sender, EventArgs e)
{ {
} }
private void buttonNext_Click(object sender, EventArgs e) private void buttonNext_Click(object sender, EventArgs e)
{ {
if (currentTabPage == 0) if (currentTabPage == 0)
{ {
DisplayTabPage(1); //Wir sind auf der Willkommensseite, hier wird ausgewählt ob Anfänger oder Experte.
} //Es wird nach der Lizenz gefragt
else if (currentTabPage == 1) DisplayTabPage(1);
{ }
if (beginnerMode) else if (currentTabPage == 1)
{ {
//TODO: Automatisch SQLite und Directory Storage auswählen //Hier soll der Nutzer auswählen ob einfach oder schwierig.
} if (beginnerMode)
else {
{ //TODO: Automatisch SQLite und Directory Storage auswählen
DisplayTabPage(2); }
} else
} {
} DisplayTabPage(2);
}
}
else if (currentTabPage == 2)
{
//Hier soll der Nutzer auswählen, welche DB verwendet werden soll.
DisplayTabPage(3);
}
}
private void buttonLoadLicenseFile_Click(object sender, EventArgs e) private void buttonLoadLicenseFile_Click(object sender, EventArgs e)
{ {
if (openFileDialogCertificate.ShowDialog() == DialogResult.OK) if (openFileDialogCertificate.ShowDialog() == DialogResult.OK)
{ {
licenceCertificateFileInfo = new FileInfo(openFileDialogCertificate.FileName); licenceCertificateFileInfo = new FileInfo(openFileDialogCertificate.FileName);
licenseBuffer = File.ReadAllBytes(licenceCertificateFileInfo.FullName); licenseBuffer = File.ReadAllBytes(licenceCertificateFileInfo.FullName);
textBox1.Text = licenceCertificateFileInfo.FullName; textBox1.Text = licenceCertificateFileInfo.FullName;
licenseState = 0; licenseState = 0;
pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4; pictureBox2.Image = Resources.SETUPAPI_18_1_32x32x4;
} }
RefreshView(); RefreshView();
} }
private void buttonValidateLicense_Click(object sender, EventArgs e) private void buttonValidateLicense_Click(object sender, EventArgs e)
{ {
VoileContext voileContext = VoileContext.GetContext(); VoileContext voileContext = VoileContext.GetContext();
if (voileContext.SophiaNetRootCertificate == null) if (voileContext.SophiaNetRootCertificate == null)
{ {
try try
{ {
byte[] sophianetCertBuffer = Resources.sophianet_cert; byte[] sophianetCertBuffer = Resources.sophianet_cert;
voileContext.SophiaNetRootCertificate = SophiaNetDrmApi.ImportCertificate(sophianetCertBuffer); voileContext.SophiaNetRootCertificate = SophiaNetDrmApi.ImportCertificate(sophianetCertBuffer);
} }
catch (Exception ex) catch (Exception ex)
{ {
licenseState = 1; licenseState = 1;
RefreshView(); RefreshView();
return; return;
} }
} }
try try
{ {
licenseCertificate = SophiaNetDrmApi.ImportCertificate(licenseBuffer); licenseCertificate = SophiaNetDrmApi.ImportCertificate(licenseBuffer);
} }
catch (Exception f) catch (Exception f)
{ {
licenseState = 2; licenseState = 2;
RefreshView(); RefreshView();
return; return;
} }
bool certificateChainValid = SophiaNetDrmApi.ValidateCertificateChain(licenseCertificate, voileContext.SophiaNetRootCertificate); bool certificateChainValid = SophiaNetDrmApi.ValidateCertificateChain(licenseCertificate, voileContext.SophiaNetRootCertificate);
if (!certificateChainValid) if (!certificateChainValid)
{ {
licenseState = 3; licenseState = 3;
RefreshView(); RefreshView();
return; return;
} }
byte[] sophiaNetExtensionBuffer; byte[] sophiaNetExtensionBuffer;
try try
{ {
sophiaNetExtensionBuffer = SophiaNetDrmApi.GetSophiaNetExtensionFromCertificate(licenseCertificate); sophiaNetExtensionBuffer = SophiaNetDrmApi.GetSophiaNetExtensionFromCertificate(licenseCertificate);
} }
catch (Exception g) catch (Exception g)
{ {
licenseState = 4; licenseState = 4;
RefreshView(); RefreshView();
return; return;
} }
if (sophiaNetExtensionBuffer.Length == 0) if (sophiaNetExtensionBuffer.Length == 0)
{ {
licenseState = 5; licenseState = 5;
RefreshView(); RefreshView();
return; return;
} }
if (sophiaNetExtensionBuffer.Length % 16 != 0) if (sophiaNetExtensionBuffer.Length % 16 != 0)
{ {
licenseState = 7; licenseState = 7;
RefreshView(); RefreshView();
return; return;
} }
licenseState = 6; licenseState = 6;
RefreshView(); RefreshView();
return; return;
} }
}
private void dbTestButton_Click(object sender, EventArgs e)
{
dataStorageConnectionSucessful = false;
if (voileDataStorageFactory == null)
{
IVoileDataStorageFactory newDs = selectedDataStorage.GetPluginInstance() as IVoileDataStorageFactory;
if (newDs == null)
{
dbSettingsErrorLabel.Text = "The selected plugin is not a Data Storage plugin. This is a bug in voile, please report it.";
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return;
}
voileDataStorageFactory = newDs;
}
IVoileDataStorage dataStorage = null;
try
{
dataStorage = voileDataStorageFactory.CreateDataStorage();
}
catch (Exception ex)
{
dbSettingsErrorLabel.Text = ex.Message;
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return;
}
try
{
Exception pingResult = dataStorage.Ping();
if (pingResult != null)
{
dbSettingsErrorLabel.Text = pingResult.Message;
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return;
}
}
catch (Exception ex2)
{
dbSettingsErrorLabel.Text = ex2.Message;
dbTestTrafficLight.Image = Resources.TRFFC10C_1_32x32x4;
return;
}
dbSettingsErrorLabel.Text = "Database connection sucessful!";
pictureBox2.Image = Resources.TRFFC10A_1_32x32x4; //grüne Ampel
dataStorageConnectionSucessful = true;
}
}
} }