From d6c5e16d0892be9ad0fd3a9a906208c512e9ce9b Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 13 Jun 2019 13:17:35 +0200 Subject: [PATCH] add profile_id placeholder --- app/DD_PM_WINDREAM/ClassFinalizeDoc.vb | 2 +- app/DD_PM_WINDREAM/clsPatterns.vb | 31 +++++-------------- app/DD_PM_WINDREAM/frmMain.vb | 8 ++--- app/DD_PM_WINDREAM/frmMassValidator.vb | 2 +- .../frmSQL_DESIGNER.Designer.vb | 22 ++++++------- app/DD_PM_WINDREAM/frmValidator.vb | 2 +- 6 files changed, 26 insertions(+), 41 deletions(-) diff --git a/app/DD_PM_WINDREAM/ClassFinalizeDoc.vb b/app/DD_PM_WINDREAM/ClassFinalizeDoc.vb index 52c8816..70882af 100644 --- a/app/DD_PM_WINDREAM/ClassFinalizeDoc.vb +++ b/app/DD_PM_WINDREAM/ClassFinalizeDoc.vb @@ -37,7 +37,7 @@ ' LOGGER.Info("Unexpected Error in Checking control values for Variable SQL Result - ERROR: " & ex.Message) ' End Try 'Next - Dim sql_Statement = clsPatterns.ReplaceUserValues(dr.Item("SQL_COMMAND"), USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID) + Dim sql_Statement = clsPatterns.ReplaceUserValues(dr.Item("SQL_COMMAND"), USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID) sql_Statement = clsPatterns.ReplaceInternalValues(sql_Statement) sql_Statement = clsPatterns.ReplaceWindreamIndicies(sql_Statement, WMObject) diff --git a/app/DD_PM_WINDREAM/clsPatterns.vb b/app/DD_PM_WINDREAM/clsPatterns.vb index bca74fe..49ed186 100644 --- a/app/DD_PM_WINDREAM/clsPatterns.vb +++ b/app/DD_PM_WINDREAM/clsPatterns.vb @@ -17,7 +17,6 @@ Public Class clsPatterns ' Complex patterns that rely on a datasource like a Database or Windream Public Const PATTERN_WMI = "WMI" Public Const PATTERN_CTRL = "CTRL" - Public Const PATTERN_PRO = "PRO" ' Simple patterns that only rely on .NET functions Public Const PATTERN_INT = "INT" ' Simple patterns that rely on Data from the TBDD_USER table @@ -28,20 +27,19 @@ Public Class clsPatterns Public Const USER_VALUE_EMAIL = "EMAIL" Public Const USER_VALUE_SHORTNAME = "SHORTNAME" Public Const USER_VALUE_USER_ID = "USER_ID" + Public Const USER_VALUE_PROFILE_ID = "PROFILE_ID" Public Const INT_VALUE_USERNAME = "USERNAME" Public Const INT_VALUE_MACHINE = "MACHINE" Public Const INT_VALUE_DOMAIN = "DOMAIN" Public Const INT_VALUE_DATE = "DATE" - Public Const PRO_VALUE_PROFILE_ID = "PROFILE_ID" - Public Const MAX_TRY_COUNT = 100 Private Shared regex As Regex = New Regex("{#(\w+)#([\w\s_-]+)}+") - Private Shared allPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL, PATTERN_USER, PATTERN_INT, PATTERN_PRO} + Private Shared allPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL, PATTERN_USER, PATTERN_INT} Private Shared complexPatterns As New List(Of String) From {PATTERN_WMI, PATTERN_CTRL} - Private Shared simplePatterns As New List(Of String) From {PATTERN_USER, PATTERN_INT, PATTERN_PRO} + Private Shared simplePatterns As New List(Of String) From {PATTERN_USER, PATTERN_INT} ''' ''' Wraps a pattern-type and -value in the common format: {#type#value} @@ -58,8 +56,7 @@ Public Class clsPatterns result = ReplaceInternalValues(result) result = ReplaceControlValues(result, panel) If Not IsNothing(document) Then result = ReplaceWindreamIndicies(result, document) - If Not IsNothing(profileId) AndAlso profileId > 0 Then result = ReplaceProfileValues(result, profileId) - result = ReplaceUserValues(result, prename, surname, shortname, email, userId) + result = ReplaceUserValues(result, prename, surname, shortname, email, userId, profileId) Return result Catch ex As Exception @@ -99,7 +96,7 @@ Public Class clsPatterns End Try End Function - Public Shared Function ReplaceUserValues(input As String, prename As Object, surname As Object, shortname As Object, email As Object, userId As Object) As String + Public Shared Function ReplaceUserValues(input As String, prename As Object, surname As Object, shortname As Object, email As Object, userId As Object, profileId As Object) As String Try Dim result = input @@ -123,29 +120,17 @@ Public Class clsPatterns result = ReplacePattern(input, PATTERN_USER, email) End While - Return result - Catch ex As Exception - LOGGER.Error(ex) - LOGGER.Info("Error in ReplaceUserValues:" & ex.Message) - End Try - End Function - - Public Shared Function ReplaceProfileValues(Input As String, profileId As Object) - Try - Dim result = Input - - While ContainsPatternAndValue(result, PATTERN_PRO, PRO_VALUE_PROFILE_ID) - ReplacePattern(result, PATTERN_PRO, profileId) + While ContainsPatternAndValue(result, PATTERN_USER, USER_VALUE_PROFILE_ID) + result = ReplacePattern(input, PATTERN_USER, profileId) End While Return result Catch ex As Exception LOGGER.Error(ex) - LOGGER.Info("Error in ReplaceProfileValues:" & ex.Message) + LOGGER.Info("Error in ReplaceUserValues:" & ex.Message) End Try End Function - Public Shared Function ReplaceControlValues(input As String, panel As Panel) As String Try Dim result = input diff --git a/app/DD_PM_WINDREAM/frmMain.vb b/app/DD_PM_WINDREAM/frmMain.vb index 54639ca..0404442 100644 --- a/app/DD_PM_WINDREAM/frmMain.vb +++ b/app/DD_PM_WINDREAM/frmMain.vb @@ -478,7 +478,7 @@ Public Class frmMain Dim sqlchart = row.Item("SQL_COMMAND") sqlchart = clsPatterns.ReplaceInternalValues(sqlchart) - sqlchart = clsPatterns.ReplaceUserValues(sqlchart, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID) + sqlchart = clsPatterns.ReplaceUserValues(sqlchart, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID) sqlchart = sqlchart.ToString.ToUpper.Replace("@USER_ID", USER_ID) sqlchart = sqlchart.ToString.ToUpper.Replace("@USER", USER_USERNAME) @@ -594,7 +594,7 @@ Public Class frmMain Dim sql = foundRows(0)("SQL_VIEW") sql = clsPatterns.ReplaceInternalValues(sql) - sql = clsPatterns.ReplaceUserValues(sql, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID) + sql = clsPatterns.ReplaceUserValues(sql, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID) sql = sql.Replace("@USER_ID", USER_ID) sql = sql.Replace("@USERNAME", Environment.UserName) @@ -730,7 +730,7 @@ Public Class frmMain Dim sql = CURRENT_DT_CONFIG.Rows(0).Item("SQL_PROFILE_MAIN_VIEW") sql = clsPatterns.ReplaceInternalValues(sql) - sql = clsPatterns.ReplaceUserValues(sql, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID) + sql = clsPatterns.ReplaceUserValues(sql, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID) ' this needs to stay for backwards compatibility sql = sql.Replace("@USER_ID", USER_ID) @@ -1185,7 +1185,7 @@ Public Class frmMain End If oSQLOverview = clsPatterns.ReplaceInternalValues(oSQLOverview) - oSQLOverview = clsPatterns.ReplaceUserValues(oSQLOverview, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID) + oSQLOverview = clsPatterns.ReplaceUserValues(oSQLOverview, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID) oSQLOverview = oSQLOverview.Replace("@USER_ID", USER_ID) oSQLOverview = oSQLOverview.Replace("@USERNAME", Environment.UserName) diff --git a/app/DD_PM_WINDREAM/frmMassValidator.vb b/app/DD_PM_WINDREAM/frmMassValidator.vb index 3ccc248..b7ab5e6 100644 --- a/app/DD_PM_WINDREAM/frmMassValidator.vb +++ b/app/DD_PM_WINDREAM/frmMassValidator.vb @@ -1007,7 +1007,7 @@ Public Class frmMassValidator Continue For End If - sql = clsPatterns.ReplaceUserValues(sqlStatement, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID) + sql = clsPatterns.ReplaceUserValues(sqlStatement, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID) sql = clsPatterns.ReplaceInternalValues(sql) LOGGER.Debug(">>> sql after ReplaceInternalValues: " & sql) 'sql = ClassPatterns.ReplaceInternalValues(sqlStatement) diff --git a/app/DD_PM_WINDREAM/frmSQL_DESIGNER.Designer.vb b/app/DD_PM_WINDREAM/frmSQL_DESIGNER.Designer.vb index 2831bd0..1c70c9e 100644 --- a/app/DD_PM_WINDREAM/frmSQL_DESIGNER.Designer.vb +++ b/app/DD_PM_WINDREAM/frmSQL_DESIGNER.Designer.vb @@ -23,8 +23,8 @@ Partial Class frmSQL_DESIGNER _ Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container() - Dim DataGridViewCellStyle7 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() - Dim DataGridViewCellStyle8 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle11 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() + Dim DataGridViewCellStyle12 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmSQL_DESIGNER)) Me.DD_DMSLiteDataSet = New DD_PM_WINDREAM.DD_DMSLiteDataSet() Me.TableAdapterManager = New DD_PM_WINDREAM.DD_DMSLiteDataSetTableAdapters.TableAdapterManager() @@ -180,8 +180,8 @@ Partial Class frmSQL_DESIGNER ' Me.dgvResult.AllowUserToAddRows = False Me.dgvResult.AllowUserToDeleteRows = False - DataGridViewCellStyle7.BackColor = System.Drawing.Color.Cyan - Me.dgvResult.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle7 + DataGridViewCellStyle11.BackColor = System.Drawing.Color.Cyan + Me.dgvResult.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle11 Me.dgvResult.Anchor = CType(((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _ Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.dgvResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize @@ -195,8 +195,8 @@ Partial Class frmSQL_DESIGNER ' Me.dgvPlaceholders.AllowUserToAddRows = False Me.dgvPlaceholders.AllowUserToDeleteRows = False - DataGridViewCellStyle8.BackColor = System.Drawing.Color.Cyan - Me.dgvPlaceholders.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle8 + DataGridViewCellStyle12.BackColor = System.Drawing.Color.Cyan + Me.dgvPlaceholders.AlternatingRowsDefaultCellStyle = DataGridViewCellStyle12 Me.dgvPlaceholders.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) Me.dgvPlaceholders.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize Me.dgvPlaceholders.Columns.AddRange(New System.Windows.Forms.DataGridViewColumn() {Me.colPlaceholder, Me.colReplace}) @@ -336,14 +336,14 @@ Partial Class frmSQL_DESIGNER Me.Label2.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label2.Location = New System.Drawing.Point(442, 67) Me.Label2.Name = "Label2" - Me.Label2.Size = New System.Drawing.Size(97, 16) + Me.Label2.Size = New System.Drawing.Size(112, 16) Me.Label2.TabIndex = 98 - Me.Label2.Text = "Windowsdaten:" + Me.Label2.Text = "Umgebungsdaten:" ' 'cmbUser ' Me.cmbUser.FormattingEnabled = True - Me.cmbUser.Items.AddRange(New Object() {"PRENAME", "SURNAME", "SHORTNAME", "EMAIL", "USER_ID"}) + Me.cmbUser.Items.AddRange(New Object() {"PRENAME", "SURNAME", "SHORTNAME", "EMAIL", "USER_ID", "PROFILE_ID"}) Me.cmbUser.Location = New System.Drawing.Point(681, 86) Me.cmbUser.Name = "cmbUser" Me.cmbUser.Size = New System.Drawing.Size(194, 21) @@ -355,9 +355,9 @@ Partial Class frmSQL_DESIGNER Me.Label3.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label3.Location = New System.Drawing.Point(678, 67) Me.Label3.Name = "Label3" - Me.Label3.Size = New System.Drawing.Size(95, 16) + Me.Label3.Size = New System.Drawing.Size(118, 16) Me.Label3.TabIndex = 98 - Me.Label3.Text = "Benutzerdaten:" + Me.Label3.Text = "Anwendungsdaten:" ' 'btnAddUser ' diff --git a/app/DD_PM_WINDREAM/frmValidator.vb b/app/DD_PM_WINDREAM/frmValidator.vb index c010a6f..35b76a3 100644 --- a/app/DD_PM_WINDREAM/frmValidator.vb +++ b/app/DD_PM_WINDREAM/frmValidator.vb @@ -504,7 +504,7 @@ Public Class frmValidator Continue For End If - sql = clsPatterns.ReplaceUserValues(sqlStatement, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID) + sql = clsPatterns.ReplaceUserValues(sqlStatement, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID) sql = clsPatterns.ReplaceInternalValues(sql) LOGGER.Debug(">>> sql after ReplaceInternalValues: " & sql) 'sql = ClassPatterns.ReplaceInternalValues(sqlStatement)