Saturday, November 26, 2016

Enterprise Application setup part 1/3

App Setup Section: Overview For a professional enterprise wide application, several critical tasks need to be accomplished at application's setup. They can loosely be defined as: setup: Define system wide settings like default output folder, printer settings and other configurable setting that will be used throughout the application's life cycle display a splash screen: Display application setting like application name, major/minor version info while giving the user something pretty to look at prompt to login a user: verify that the user is actually allowed to use the application and force him/her to enter a user id and password and be authenticated by the database - either MS Access or preferable a true enterprise wide database like MS SQL Server In reality, this is an expansive topic that covers a lot of ground so there will be separate blog posts to cover how to make a splash screen and validate a user's credentials via a login screen Section: Setup Global/PUblic variables are defined in modGlobals. Generally, these should be public constants and public variabls but MS Access has a known bug that values in public variables are lost if the application goes in BREAK mode so the TempVars variables will be used instead. Variable Name Data Type Note gbApp_SetupOccurred Boolean Flag indicates if setup occurred. Used to coordinate if certain menu options are enabled/disabled gstrUserName String The login of the user. Usually a call in the Windows API TempVars(“UserAccessLevel”) Variant User Access level which is configured per application. Basic values can be Read or Read/Write or finer level of permissions Dependencies modGlobal Public Const ERR_MSG_REQUIRED_FIELD_MISSING As String = _ "Required field. Can't be blank or missing." Public Const ERR_MSG_INVALID_START_DATE As String _ = "Invalid Start Date or must be less than ending Date" Public Const ERR_MSG_BLANK_NAME As String = "Required value -must supply a name" Public Const ERR_MSG_NO_RIGHTS_TO_FUNCTION As String = "Not enough priveleges to run this command. " & _ "Please contact system administrator for more assistance" Public Const ERR_MSG_EXISTS_IN_QUEUE As String = "No need to try again because it is all ready in the queue of pending changes." '===================================================== Public Const APP_NAME As String = "ProductivityTool" 'Public APP_PATH As String 'Public APP_INPUT_PATH As String 'Public APP_OUTPUT_PATH As String 'Public Const APP_PATH As String = CurrentProject.Path 'Public Const APP_INPUT_PATH As String = AddBS(APP_PATH) & "Input" 'Public Const APP_OUTPUT_PATH As String = AddBS(APP_PATH) & "Output" Public Const APP_LOCAL_APP_PATH As String = "C:\My Documents\My App" Public Const APP_LOCAL_INPUT_PATH As String = APP_LOCAL_APP_PATH & "\" & "Input" Public Const APP_LOCAL_OUTPUT_PATH As String = APP_LOCAL_APP_PATH & "\" & "Output" Public Const COMPANY_NAME As String = "Deutsche Bank AG" 'Public gbDEBUG_MODE As Boolean Public gbApp_SetupOccurred As Boolean Public Const MASK_DATE As String = "mm/dd/yyyy" Public Const MASK_MONEY As String = "$#,##0.00;($#,##0.00)" Public Const MASK_HOLDINGS As String = "#,##0;(#,##0)" Public lngMyEmpID As Long Public gstrUserName As String 'Public gUserAccessLevel As UserRole How Public Sub StartUp() 'will rename to init globals 'will read from INI file to get path for executable Dim objCatalog As Object 'ADOX.Catalog Dim objTable As Object 'ADOX.Table Dim strAppPath As String On Error Resume Next Set objCatalog = CreateObject("ADOX.Catalog") 'Set objCatalog = New ADOX.Catalog Set objCatalog.ActiveConnection = CurrentProject.Connection 'Set objTable = New ADOX.Table Set objTable = CreateObject("ADOX.Table") objTable.Name = "DailyWork" Set objTable.ParentCatalog = objCatalog Set objTable = objCatalog.Tables("DailyWork") strAppPath = JustPathfromFileName(objTable.Properties("Jet OLEDB:Link DataSource")) Application.TempVars.Add "AppPath", strAppPath gbApp_SetupOccurred = True 'getAppPath() 'Call SetErrorFilePath(CurrentProject.Path) 'log errors here Call SetErrorFilePath(strAppPath) 'log errors here gbDEBUG_MODE = Len(Dir$(AddBS(CurrentProject.Path) & "debug.ini")) > 0 'gsREG_APP= 'APP_NAME = "CPLI App" End Sub

1 comment:

brittanymlemay said...

I read that Post and got it fine and informative. devsdata.com