From 5797341a7312a4631bf659ee8fd31893009a883c Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 5 Jun 2018 13:20:04 +0200 Subject: [PATCH] jj: fix unique constraint for TBPM_FILES_USER_NOT_INDEXED --- .../DD_DMSLiteDataSet.Designer.vb | 52 ++++++++++++++++- app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xsd | 56 ++++++++++++------- app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xss | 38 ++++++------- app/DD_PM_WINDREAM/frmValidator.vb | 5 +- 4 files changed, 108 insertions(+), 43 deletions(-) diff --git a/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.Designer.vb b/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.Designer.vb index 9b51bca..7705b1c 100644 --- a/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.Designer.vb +++ b/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.Designer.vb @@ -16963,7 +16963,7 @@ Namespace DD_DMSLiteDataSetTableAdapters _ Private Sub InitCommandCollection() - Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(2) {} + Me._commandCollection = New Global.System.Data.SqlClient.SqlCommand(3) {} Me._commandCollection(0) = New Global.System.Data.SqlClient.SqlCommand() Me._commandCollection(0).Connection = Me.Connection Me._commandCollection(0).CommandText = "SELECT USR_NAME, PROFIL_ID, FILE_PATH FROM TBPM_FILES_USER_NOT_INDEXED" @@ -16981,6 +16981,15 @@ Namespace DD_DMSLiteDataSetTableAdapters Me._commandCollection(2).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@User", Global.System.Data.SqlDbType.VarChar, 50, Global.System.Data.ParameterDirection.Input, 0, 0, "USR_NAME", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) Me._commandCollection(2).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@PROFIL_ID", Global.System.Data.SqlDbType.Int, 4, Global.System.Data.ParameterDirection.Input, 0, 0, "PROFIL_ID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) Me._commandCollection(2).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@FILE_PATH", Global.System.Data.SqlDbType.VarChar, 500, Global.System.Data.ParameterDirection.Input, 0, 0, "FILE_PATH", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._commandCollection(3) = New Global.System.Data.SqlClient.SqlCommand() + Me._commandCollection(3).Connection = Me.Connection + Me._commandCollection(3).CommandText = "SELECT COUNT(*) AS Expr1"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"FROM TBPM_FILES_USER_NOT_INDEXED"&Global.Microsoft.VisualBasic.ChrW(13)&Global.Microsoft.VisualBasic.ChrW(10)&"WHE"& _ + "RE (USR_NAME = @USERNAME) AND (PROFIL_ID = @PROFIL_ID) AND (FILE_PATH = @"& _ + "FILE_PATH)" + Me._commandCollection(3).CommandType = Global.System.Data.CommandType.Text + Me._commandCollection(3).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@USERNAME", Global.System.Data.SqlDbType.VarChar, 50, Global.System.Data.ParameterDirection.Input, 0, 0, "USR_NAME", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._commandCollection(3).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@PROFIL_ID", Global.System.Data.SqlDbType.Int, 4, Global.System.Data.ParameterDirection.Input, 0, 0, "PROFIL_ID", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) + Me._commandCollection(3).Parameters.Add(New Global.System.Data.SqlClient.SqlParameter("@FILE_PATH", Global.System.Data.SqlDbType.VarChar, 500, Global.System.Data.ParameterDirection.Input, 0, 0, "FILE_PATH", Global.System.Data.DataRowVersion.Current, false, Nothing, "", "", "")) End Sub _ + Public Overloads Overridable Function FileExists(ByVal USERNAME As String, ByVal PROFIL_ID As Global.System.Nullable(Of Integer), ByVal FILE_PATH As String) As Global.System.Nullable(Of Integer) + Dim command As Global.System.Data.SqlClient.SqlCommand = Me.CommandCollection(3) + If (USERNAME Is Nothing) Then + command.Parameters(0).Value = Global.System.DBNull.Value + Else + command.Parameters(0).Value = CType(USERNAME,String) + End If + If (PROFIL_ID.HasValue = true) Then + command.Parameters(1).Value = CType(PROFIL_ID.Value,Integer) + Else + command.Parameters(1).Value = Global.System.DBNull.Value + End If + If (FILE_PATH Is Nothing) Then + command.Parameters(2).Value = Global.System.DBNull.Value + Else + command.Parameters(2).Value = CType(FILE_PATH,String) + End If + Dim previousConnectionState As Global.System.Data.ConnectionState = command.Connection.State + If ((command.Connection.State And Global.System.Data.ConnectionState.Open) _ + <> Global.System.Data.ConnectionState.Open) Then + command.Connection.Open + End If + Dim returnValue As Object + Try + returnValue = command.ExecuteScalar + Finally + If (previousConnectionState = Global.System.Data.ConnectionState.Closed) Then + command.Connection.Close + End If + End Try + If ((returnValue Is Nothing) _ + OrElse (returnValue.GetType Is GetType(Global.System.DBNull))) Then + Return New Global.System.Nullable(Of Integer)() + Else + Return New Global.System.Nullable(Of Integer)(CType(returnValue,Integer)) + End If + End Function End Class ''' diff --git a/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xsd b/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xsd index efdee89..591dbaf 100644 --- a/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xsd +++ b/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xsd @@ -1191,6 +1191,20 @@ VALUES (@User,@PROFIL_ID,@FILE_PATH) + + + + SELECT COUNT(*) AS Expr1 +FROM TBPM_FILES_USER_NOT_INDEXED +WHERE (USR_NAME = @USERNAME) AND (PROFIL_ID = @PROFIL_ID) AND (FILE_PATH = @FILE_PATH) + + + + + + + + @@ -1942,7 +1956,7 @@ WHERE (GUID = @GUID) - + @@ -1987,7 +2001,7 @@ WHERE (GUID = @GUID) - + @@ -2090,7 +2104,7 @@ WHERE (GUID = @GUID) - + @@ -2186,7 +2200,7 @@ WHERE (GUID = @GUID) - + @@ -2237,7 +2251,7 @@ WHERE (GUID = @GUID) - + @@ -2267,7 +2281,7 @@ WHERE (GUID = @GUID) - + @@ -2290,7 +2304,7 @@ WHERE (GUID = @GUID) - + @@ -2380,7 +2394,7 @@ WHERE (GUID = @GUID) - + @@ -2453,7 +2467,7 @@ WHERE (GUID = @GUID) - + @@ -2489,7 +2503,7 @@ WHERE (GUID = @GUID) - + @@ -2504,7 +2518,7 @@ WHERE (GUID = @GUID) - + @@ -2525,7 +2539,7 @@ WHERE (GUID = @GUID) - + @@ -2633,7 +2647,7 @@ WHERE (GUID = @GUID) - + @@ -2706,7 +2720,7 @@ WHERE (GUID = @GUID) - + @@ -2757,7 +2771,7 @@ WHERE (GUID = @GUID) - + @@ -2849,7 +2863,7 @@ WHERE (GUID = @GUID) - + @@ -2980,11 +2994,11 @@ WHERE (GUID = @GUID) - - - - - + + + + + \ No newline at end of file diff --git a/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xss b/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xss index b2e2270..bca091e 100644 --- a/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xss +++ b/app/DD_PM_WINDREAM/DD_DMSLiteDataSet.xss @@ -4,27 +4,27 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. --> - + - + - + - - - - - - - - - - - + + + + + + + + + + + - + 461 @@ -36,7 +36,7 @@ - + 343 @@ -52,7 +52,7 @@ - + 515 @@ -64,7 +64,7 @@ - + 844 @@ -80,7 +80,7 @@ - + 141 diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index 93344b5..b1ae704 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -2820,9 +2820,10 @@ Public Class frmValidator 'Das Dokument freigeben TBPM_PROFILE_FILESTableAdapter.CmdSETWORK(False, "", CURRENT_DOC_GUID) + If TBPM_FILES_USER_NOT_INDEXEDTableAdapter.FileExists(Environment.UserName, CURRENT_ProfilGUID, Document_Path) = 0 Then + TBPM_FILES_USER_NOT_INDEXEDTableAdapter.cmdInsert(Environment.UserName, CURRENT_ProfilGUID, Document_Path) + End If - - TBPM_FILES_USER_NOT_INDEXEDTableAdapter.cmdInsert(Environment.UserName, CURRENT_ProfilGUID, Document_Path) If LogErrorsOnly = False Then ClassLogger.Add(" >> Dokument freigegeben", False) ClassLogger.Add("", False) Load_Next_Document(False)