Skip to content

Commit

Permalink
Extend startup with userrole check
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoulJacobs committed Feb 10, 2020
1 parent a6e4613 commit c4391c5
Showing 1 changed file with 74 additions and 69 deletions.
143 changes: 74 additions & 69 deletions M_omStartup.def
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Option Explicit
Public Function Main(Optional linkLocal As Boolean = False) As Integer
Dim FormName As String

'omUserFunctions.AuthenticateUser
omUserFunctions.AuthenticateUser
'omUserFunctions.UserLock
omMSAccessFunctions.MinimizeNavigationPane

Expand All @@ -18,6 +18,9 @@ Dim FormName As String
FormName = "StockCheck_List"
End If
End If
If gUser.UserRole.Name = "User" Then
FormName = "Project_List"
End If
DoCmd.OpenForm FormName
End Function

Expand All @@ -31,71 +34,73 @@ End Function
Public Function LinkSSMADatabaseSQLODBC() As Variant
omSSMAAConnector.LinkUsingSSMA ConnectionType:=SQLOBDC, SavePassword:=True, alwaysUpdate:=True
End Function
Public Function SyncUserMain() As Boolean
Dim LastSyncUser As Variant
Dim makeConnection As Boolean
'omSSMAAConnector.LinkUsingSSMA ConnectionType:=Default, alwaysUpdate:=True
gLogging.Enabled = True
Application.SetOption "Move after enter", 0
Application.SetOption "Auto compact", False
If InStr(1, CurrentProject.Name, "mbi_client") > 0 Then

gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true"
omSSMAAConnector.UpdateSSMAConnectionString Group:="mBIClientUser"
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > UpdateSSMAConnectionString for mBIClientUser"

LastSyncUser = omDefaultFunctions.GetSystemDefault("LastSyncUser")
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > LastSyncUser=" & LastSyncUser

makeConnection = True
If LastSyncUser = GetCurrentUserName Then
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > LastSyncUser = GetCurrentUserName"

If IsTableLocal("Users") And IsTableLocal("UserRoles") Then
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > LastSyncUser = GetCurrentUserName > IsTableLocal"
makeConnection = False
End If
End If
If makeConnection Then
MsgBox "Please make sure you are in the companies network or have an open VPN connection!", vbOKOnly
If IsConnectingPossible("Users") Then
OrderSheetSyncFunctions.SetupOrderSheet

gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > makeConnection=true > isConnectingPossible(users)"
omSSMAAConnector.LinkUsingSSMA Group:="mBIClientUser", ConnectionType:=SQLNCLI, SavePassword:=True
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > makeConnection=true > LinkUsingSSMA for mBIClientUser"
OrderSheetSyncFunctions.SyncData
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > makeConnection=true > SyncData"
End If
Else
OrderSheetFunctions.LoginCurrentUserName
End If
If gCurrentOrderSheetUser.Active Then
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > gCurrentOrderSheetUser.Active"
omDefaultFunctions.Initialize True
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > gCurrentOrderSheetUser.Active > omDefaultFunctions.Initialize True"
DoCmd.OpenForm "OrderSheet_List"
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > gCurrentOrderSheetUser.Active > OpenForm OrderSheet_List"
Else
omDefaultFunctions.SaveSystemDefault "LastSyncUser", Null
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > SetDefault LastSyncUser=null"

omSSMAAConnector.DeleteLinkTables
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > DeleteLinkTables"
omSSMAAConnector.DeleteSSMAATables
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > DeleteSSMAATables"
omSSMAAConnector.DeleteSSMAABackupTables
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > DeleteSSMAABackupTables"
Application.SetOption "Auto compact", True
gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > SetOption Auto Compact=true"
DoCmd.Quit acQuitSaveNone
End If
Else
omSSMAAConnector.LinkUsingSSMA Group:="mBI", ConnectionType:=SQLNCLI, SavePassword:=True
DeleteSSMAABackupTables
omDefaultFunctions.Initialize True
DoCmd.OpenForm "Flow"
End If
'gDefaults.Mode = ServerMode
'gSystemDefaults.Mode = LocalMode
End Function

'Public Function SyncUserMain() As Boolean
'Dim LastSyncUser As Variant
'Dim makeConnection As Boolean
' 'omSSMAAConnector.LinkUsingSSMA ConnectionType:=Default, alwaysUpdate:=True
' gLogging.Enabled = True
' Application.SetOption "Move after enter", 0
' Application.SetOption "Auto compact", False
' If InStr(1, CurrentProject.Name, "mbi_client") > 0 Then
'
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true"
' omSSMAAConnector.UpdateSSMAConnectionString Group:="mBIClientUser"
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > UpdateSSMAConnectionString for mBIClientUser"
'
' LastSyncUser = omDefaultFunctions.GetSystemDefault("LastSyncUser")
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > LastSyncUser=" & LastSyncUser
'
' makeConnection = True
' If LastSyncUser = GetCurrentUserName Then
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > LastSyncUser = GetCurrentUserName"
'
' If IsTableLocal("Users") And IsTableLocal("UserRoles") Then
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > LastSyncUser = GetCurrentUserName > IsTableLocal"
' makeConnection = False
' End If
' End If
' If makeConnection Then
' MsgBox "Please make sure you are in the companies network or have an open VPN connection!", vbOKOnly
' If IsConnectingPossible("Users") Then
' OrderSheetSyncFunctions.SetupOrderSheet
'
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > makeConnection=true > isConnectingPossible(users)"
' omSSMAAConnector.LinkUsingSSMA Group:="mBIClientUser", ConnectionType:=SQLNCLI, SavePassword:=True
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > makeConnection=true > LinkUsingSSMA for mBIClientUser"
' OrderSheetSyncFunctions.SyncData
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > makeConnection=true > SyncData"
' End If
' Else
' OrderSheetFunctions.LoginCurrentUserName
' End If
' If gCurrentOrderSheetUser.Active Then
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > gCurrentOrderSheetUser.Active"
' omDefaultFunctions.Initialize True
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > gCurrentOrderSheetUser.Active > omDefaultFunctions.Initialize True"
' DoCmd.OpenForm "OrderSheet_List"
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > gCurrentOrderSheetUser.Active > OpenForm OrderSheet_List"
' Else
' omDefaultFunctions.SaveSystemDefault "LastSyncUser", Null
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > SetDefault LastSyncUser=null"
'
' omSSMAAConnector.DeleteLinkTables
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > DeleteLinkTables"
' omSSMAAConnector.DeleteSSMAATables
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > DeleteSSMAATables"
' omSSMAAConnector.DeleteSSMAABackupTables
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > DeleteSSMAABackupTables"
' Application.SetOption "Auto compact", True
' gLogging.WriteToFile Description:="Startup > Main > mBI_Client=true > SetOption Auto Compact=true"
' DoCmd.Quit acQuitSaveNone
' End If
' Else
' omSSMAAConnector.LinkUsingSSMA Group:="mBI", ConnectionType:=SQLNCLI, SavePassword:=True
' DeleteSSMAABackupTables
' omDefaultFunctions.Initialize True
' DoCmd.OpenForm "Flow"
' End If
' 'gDefaults.Mode = ServerMode
' 'gSystemDefaults.Mode = LocalMode
'End Function
'

0 comments on commit c4391c5

Please sign in to comment.