Hello
Can anyone help me please?
I run a taxi fare calculator website and I want to put in place some code that stops the calculator being used more than 5 times if the user is not a member of a particular member role.
I have written and tested this on my dev server and it works perfectly. BUT when I upload it to the live site it doesnt work...
Can anyone think why this would be? I have made 100% sure the names of the roles are identical on the dev machine as the live machine....
Here is the code. Can anyone help me find out why it wont work on the live site please?
Thanks, Trev
'Return the number of times this person has used the calculator
'Get the ip address of the user
Dim IPAddress As String = Request.UserHostAddress.ToString'Run a query to find out how many times this ip address has used the calculator
Dim IPQueries As DataSet = TaxiRoute.DataProvider.Instance.GetNumberOfEnquiriesByIPAddress(IPAddress)'If the ip address has been used before, how many times?
If IPQueries.Tables(0).Rows.Count <> 0 Then 'if this is the first time then there will be no records returned from the sp
'The number of enquiries is needed as an integer for later use.. it's in the table at 0,1
Dim CountOfEnquiries As Integer = IPQueries.Tables(0).Rows(0).ItemArray(1)'Now find out what roles, if any, the user is member of
Dim mRoles As New DotNetNuke.Entities.Users.OnlineUserInfoDim mUserRoles As New DotNetNuke.Security.Roles.RoleControllerDim mUser As DotNetNuke.Entities.Users.UserInfo = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo'Setup a flag to carry authorisation state with a default of false
Dim Authorised As Boolean = False
'Traverse through roles to see if they are in an authorised role
For Each i As String In mUserRoles.GetRolesByUser(mUser.UserID, mRoles.PortalID)If i.ToString() = "Silver Package Taxi Companies Monthly Subscription" Or i.ToString() = "Silver Package Taxi Companies Yearly Subscription" Then
Authorised =
True
End If
Next
'Check the users role and the number of enquiries and disable if wrong
If CountOfEnquiries > 5 And Authorised = False Then 'if they have done more than 5 queries and are not a silver member then disable.
ButtonGetRoute.Enabled =
False
LabelRouteMessage.Text =
"You have exceeded your daily allowance of enquiries. You must be logged in as a Silver Member to be able to make more than 5 enquiries a day."
End If
End If