Web Apps – Login and Menu load improvements

I’ve made a number of changes to the core Web Apps product to tailor it more towards our needs. What I’m outlining below works for us, but the exact setup may not work for you. However, I am provided as a guideline should you want to use on your system.

When you log into web apps, the first page you see is the Menu Page. During login, each Controller is initialized which runs checks for user access rights, gets default setup values, etc. That makes sense, but why do we need to initialize items that we never use? And guess what happens each time you return to the menu during your session? Each and every controller is re-initialized.

Now, as I mentioned above, I have heavily customized Web Apps and our menu page doesn’t function as a ‘Menu’ but more of a landing page. I moved the navigation into the _Layout and RSReport files and added Bootstrap to the solution to handle collapsing into a mobile friendly menu. More on how to do that in a future post. See below…

By taking this over, I was free to ignore initializing the controllers for the areas that we don’t use, which is most of them. We primarily use Web Apps for timecard entry and approval, project maintenance, SSRS reports, and resource planning (soon), so that’s all I’m going to initialize. (I should mention that we DO NOT use messages as we found most of them to be redundant.)

To do this, go to the ‘Home Controller’ and find the Menu() function. There is a For Each that calls the initialization. I added a lambda expression to only initialize where the controllers are equal to what I defined. I also added a Session(“Initialized”) variable, which allows the initialization to run upon login, but after running, sets the Session(“Initialized”) variable to 1. This prevents the initialization from running again during that session. We already know most of this info, so why do we constantly need to refetch how many gridlines should be displayed in the timecard?

To find out what each controller is ‘called’, go to that particular controller and pull up the GetUrlSegment() function. As you can see, in the ProjectTimecardController, the GetUrlSegment() returns “ProjectTimecard”, so that’s the value I used above in the lambda expression. Do this for each controller you use.

Ok – now that we’ve done that, you may notice that some notifications on the menu page no longer show….to get around that, I am running my own stored procedure each time the menu page loads to get the info we deemed appropriate (basically an ‘Approval’ notice, a ‘Rejected TC’ notice, and a button that takes users directly to their current TC if they have one open. You can create your own stored procedure to meet your needs. Remember to add the procedure to the WebServiceLookup and WebServiceLookupIt tables in your sys database.

Example of how to run a stored procedure named ‘zsp_getMenuNotifications’ in Web Apps passing the Employee ID as a parameter and assigning the results to variables for use later in the controller or in the vbhtml files themselves:

If String.IsNullOrEmpty(Session("EmployeeID")) = False Then
    Dim employee As String = Session("EmployeeID")
    Dim lh As New LookupHelper
    Dim r As DataRowCollection = lh.GetLookupExtended("zsp_getMenuNotifications", {"@employee"}, {employee}, UIHelper.LoginSession, False)
        Session("CurTCExists") = "1900-01-01"
        Session("RejectedTCExist") = 0
        If r IsNot Nothing AndAlso r.Count > 0 Then
           Session("CurTCExists") = r(0).Item("pe_date")
           Session("AWW") = r(0).Item("AWW")
           Session("RejectedTCExist") = r(0).Item("rejected")
           Session("isMgr") = r(0).Item("ismgr")
           Session("DarkMode") = r(0).Item("darkmode")
           ViewData("ApprovalsExists") = If(Convert.ToInt16(r(0).Item("Approvals").ToString.Trim) > 0, True, False)
        End If
End If

The end result for us has been quicker login times and almost instant menu page loading.

Feel free to share...

Leave a Reply

Close Menu