Testing database connection.
This commit is contained in:
parent
c83d69a200
commit
20ee473fda
@ -8,5 +8,6 @@ namespace Voile.Patchouli.Data
|
|||||||
{
|
{
|
||||||
public interface IVoileDataStorage
|
public interface IVoileDataStorage
|
||||||
{
|
{
|
||||||
|
bool Ping();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
91
Voile/FirstRunWizard.Designer.cs
generated
91
Voile/FirstRunWizard.Designer.cs
generated
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -10,6 +10,7 @@ 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;
|
||||||
|
|
||||||
@ -34,6 +35,8 @@ namespace Voile
|
|||||||
private X509Certificate licenseCertificate;
|
private X509Certificate licenseCertificate;
|
||||||
private bool sharewareMode;
|
private bool sharewareMode;
|
||||||
private VoilePluginInfo selectedDataStorage;
|
private VoilePluginInfo selectedDataStorage;
|
||||||
|
private IVoileDataStorageFactory voileDataStorageFactory;
|
||||||
|
private bool dataStorageConnectionSucessful;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -122,6 +125,13 @@ namespace Voile
|
|||||||
//TODO: Hier zusätzlich Lizenzvalidierung einfügen.
|
//TODO: Hier zusätzlich Lizenzvalidierung einfügen.
|
||||||
buttonNext.Enabled = selectedDataStorage != null;
|
buttonNext.Enabled = selectedDataStorage != null;
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
dbSettingsErrorLabel.Text = "";
|
||||||
|
if (voileDataStorageFactory == null)
|
||||||
|
{
|
||||||
|
dbSettingsPropertyGrid.SelectedObject = selectedDataStorage.GetPluginInstance();
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
MessageBox.Show("Could not find handler for the current tab page.");
|
MessageBox.Show("Could not find handler for the current tab page.");
|
||||||
return;
|
return;
|
||||||
@ -214,10 +224,13 @@ namespace Voile
|
|||||||
{
|
{
|
||||||
if (currentTabPage == 0)
|
if (currentTabPage == 0)
|
||||||
{
|
{
|
||||||
|
//Wir sind auf der Willkommensseite, hier wird ausgewählt ob Anfänger oder Experte.
|
||||||
|
//Es wird nach der Lizenz gefragt
|
||||||
DisplayTabPage(1);
|
DisplayTabPage(1);
|
||||||
}
|
}
|
||||||
else if (currentTabPage == 1)
|
else if (currentTabPage == 1)
|
||||||
{
|
{
|
||||||
|
//Hier soll der Nutzer auswählen ob einfach oder schwierig.
|
||||||
if (beginnerMode)
|
if (beginnerMode)
|
||||||
{
|
{
|
||||||
//TODO: Automatisch SQLite und Directory Storage auswählen
|
//TODO: Automatisch SQLite und Directory Storage auswählen
|
||||||
@ -227,6 +240,11 @@ namespace Voile
|
|||||||
DisplayTabPage(2);
|
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)
|
||||||
@ -309,5 +327,55 @@ namespace Voile
|
|||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user