check user

This commit is contained in:
Luc Vandenbroucke 2021-06-23 11:49:38 +02:00
parent 221cbac13f
commit fbe7f26170
6 changed files with 57 additions and 16 deletions

View file

@ -3,7 +3,7 @@
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?define eDosStation_TargetDir=$(var.eDosStation.TargetDir)?>
<?define syncEdosLocal_TargetDir=$(var.syncEdosLocal.TargetDir)?>
<Product Id="*" Name="eDosStation" Language="1033" Version="2.1.0.0" Manufacturer="SCK CEN Luc Vandenbroucke" UpgradeCode="24e037ca-edbb-49d5-85d4-3a93dd7d10d8">
<Product Id="*" Name="eDosStation" Language="1033" Version="2.2.0.0" Manufacturer="SCK CEN Luc Vandenbroucke" UpgradeCode="24e037ca-edbb-49d5-85d4-3a93dd7d10d8">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Comments="EPD lees software en synchronisatie tussen local en remote database" InstallPrivileges="elevated" Platform="x86" Description="eDosStation 1.6.1" />
<Media Id="1" EmbedCab="yes" Cabinet="cab" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

View file

@ -6,7 +6,7 @@
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:local="clr-namespace:eDosStation"
mc:Ignorable="d"
Title="About" Height="600" Width="800" FontFamily="Segoe UI"
Title="About" Height="658.389" Width="800" FontFamily="Segoe UI"
WindowStartupLocation="CenterScreen" WindowStyle="SingleBorderWindow" WindowState="Normal" >
<Grid>
<Grid.RowDefinitions>
@ -48,6 +48,16 @@
</Paragraph>
</TableCell>
</TableRow>
<TableRow>
<TableCell >
<Paragraph TextAlignment="Right" Margin="0,0,20,0" >Local sql alias</Paragraph>
</TableCell>
<TableCell>
<Paragraph>
<Run BaselineAlignment="Bottom" x:Name="localSql" Text="sql"/>
</Paragraph>
</TableCell>
</TableRow>
<TableRow>
<TableCell >
<Paragraph TextAlignment="Right" Margin="0,0,20,0" >Check users quiz</Paragraph>

View file

@ -36,8 +36,12 @@ namespace eDosStation
private void ReadAlias()
{
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\MSSQLServer\\Client\\ConnectTo");
remoteSql.Text= key.GetValue("eDos").ToString();
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\MSSQLServer\\Client\\ConnectTo",false))
{
remoteSql.Text = key.GetValue("eDos").ToString();
localSql.Text = key.GetValue("eDosLocal").ToString();
}
}
}
}

View file

@ -552,9 +552,12 @@ namespace eDosStation
exceeded = (((DataSet1.GetTaskInfoRow)o.Row).MarginExceeded);
}
if (_User == null) { TaskOK.Content = "Badge"; TaskOK.Tag = "B"; }
else if (_User.AccessAllow != true) { TaskOK.Content = "No Access"; TaskOK.Tag = "A"; }
else if (_User.VisitIDLocked >0 ) { TaskOK.Content = "Locked"; TaskOK.Tag = "L"; }
else if (!_User.AllOk)
{
if (_User.AccessAllow != true) { TaskOK.Content = "No Access"; TaskOK.Tag = "A"; }
else if (_User.VisitIDLocked > 0) { TaskOK.Content = "Locked"; TaskOK.Tag = "L"; }
else if (exceeded == true) { TaskOK.Content = "No Margin"; TaskOK.Tag = "M"; }
}
else
{
TaskOK.Content = "OK"; TaskOK.Tag = "O";

View file

@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.1.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyVersion("2.2.0.0")]
[assembly: AssemblyFileVersion("2.2.0.0")]

View file

@ -267,25 +267,49 @@ namespace syncEdosLocal
}
static void Main(string[] args)
{
//Sync need both
var SourceCoStr = System.Configuration.ConfigurationManager.ConnectionStrings["eDosConnectionString"].ConnectionString;
var LocalCoStr = System.Configuration.ConfigurationManager.ConnectionStrings["LocalConnectionString"].ConnectionString;
spLog = new spl("SynceDosLocal");
Bulker = new LSWLib.Bulker(spLog, true);
messages = Bulker.messages;
messages.AppendLine(spLog.GetStartInfoString());
//Sync need both
var SourceCoStr = new SqlConnectionStringBuilder(System.Configuration.ConfigurationManager.ConnectionStrings["eDosConnectionString"].ConnectionString);
var LocalCoStr = new SqlConnectionStringBuilder(System.Configuration.ConfigurationManager.ConnectionStrings["LocalConnectionString"].ConnectionString);
SourceCoStr.TrustServerCertificate = LocalCoStr.TrustServerCertificate= true;
SourceCoStr.ApplicationName = LocalCoStr.ApplicationName = "eDosSync";
SourceCoStr.WorkstationID = LocalCoStr.WorkstationID = Environment.MachineName;
string reDos = string.Empty;
string reDosLocal = string.Empty;
try
{
using (System.Data.SqlClient.SqlConnection eDosLocalCon = new SqlConnection(LocalCoStr))
using (var key = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\WOW6432Node\\Microsoft\\MSSQLServer\\Client\\ConnectTo"))
{
reDos = key.GetValue("eDos").ToString();
reDosLocal = key.GetValue("eDos").ToString();
}
} catch (System.Exception ex)
{
spLog.setErrorException(ex);
spLog.WriteSplunkLog("init", spLog.splunkSeverity, null, spLog.splunkError);
messages.AppendLine($"Error reading reg key");
}
messages.AppendLine($"Remote {SourceCoStr.DataSource} db {SourceCoStr.InitialCatalog} Logon= { SourceCoStr.UserID} alias:{ reDos }");
messages.AppendLine($"Local {LocalCoStr.DataSource} db {LocalCoStr.InitialCatalog} Logon= { LocalCoStr.UserID} alias:{ reDosLocal }");
try
{
using (System.Data.SqlClient.SqlConnection eDosLocalCon = new SqlConnection(LocalCoStr.ConnectionString))
{
eDosLocalCon.Open();
int? StationID = Bulker.SqlCommands.ExecProcScalar("Get Station ID", eDosLocalCon, "GetID_LocalStation", true, ref error) as int?;
Result = new cResult(StationID, eDosLocalCon, spLog);
using (System.Data.SqlClient.SqlConnection eDosCon = new SqlConnection(SourceCoStr))
using (System.Data.SqlClient.SqlConnection eDosCon = new SqlConnection(SourceCoStr.ConnectionString))
{
eDosCon.InfoMessage += Connection_InfoMessage;
DoorloopToDo(eDosCon, LocalCoStr, iMessage, ref error, ref warning, ref messages);
DoorloopToDo(eDosCon, LocalCoStr.ConnectionString, iMessage, ref error, ref warning, ref messages);
DoorloopVisits(eDosLocalCon, eDosCon, Bulker.spLog, ref error);
}
Result.Write();