Advertisement
Guest User

Untitled

a guest
Mar 24th, 2020
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Public Sub ConnectMapGuide(pv_objUser As CObjUser, pv_strMgSessionID As String, pv_strMapName As String)
  2.     Try
  3.         Dim webConfigFilePath As String = Me.WebConfigFilePath
  4.         MapGuideApi.MgInitializeWebTier(webConfigFilePath)
  5.         Dim flag As Boolean = Operators.CompareString(pv_strMgSessionID, "", False) = 0
  6.         If flag Then
  7.             Dim userInformation As MgUserInformation = New MgUserInformation("Anonymous", "")
  8.             Dim mgSite As MgSite = New MgSite()
  9.             mgSite.Open(userInformation)
  10.             Me.m_strSessionID = mgSite.CreateSession()
  11.         Else
  12.             Dim userInformation2 As MgUserInformation = New MgUserInformation(pv_strMgSessionID)
  13.             Dim mgSiteConnection As MgSiteConnection = New MgSiteConnection()
  14.             mgSiteConnection.Open(userInformation2)
  15.             Me.m_mgResourceService = CType(mgSiteConnection.CreateService(0), MgResourceService)
  16.             Me.m_mgFeatureService = CType(mgSiteConnection.CreateService(2), MgFeatureService)
  17.             Me.m_mgMap.Open(Me.ResourceService, pv_strMapName)
  18.         End If
  19.     Catch ex As Exception
  20.         Me.errHandl.ErrorRaised(ex, pv_objUser, "MapGuide")
  21.         Dim flag As Boolean = Operators.CompareString(ex.Message, "Session has expired or is invalid. Please log in again.", False) = 0
  22.         If flag Then
  23.             Dim userInformation3 As MgUserInformation = New MgUserInformation("Anonymous", "")
  24.             Dim mgSite2 As MgSite = New MgSite()
  25.             mgSite2.Open(userInformation3)
  26.             Me.m_strSessionID = mgSite2.CreateSession()
  27.         End If
  28.     End Try
  29. End Sub
  30.  
  31. Public Function DoesResourceExist(pv_mgresourceIdentifier As MgResourceIdentifier, pv_mgresourceService As MgResourceService) As Boolean
  32.     Try
  33.         pv_mgresourceService.GetResourceContent(pv_mgresourceIdentifier)
  34.     Catch ex As Exception
  35.         Return False
  36.     End Try
  37.     Return True
  38. End Function
  39.  
  40.  
  41. Public Sub ChangeLayerVisibility(pv_objUser As CObjUser, pv_strLayerName As String, pv_blnVisible As Boolean)
  42.     Try
  43.         Dim layers As MgLayerCollection = Me.Map.GetLayers()
  44.         Dim mgLayer As MgLayer = CType(layers.GetItem(pv_strLayerName), MgLayer)
  45.         mgLayer.Visible = pv_blnVisible
  46.         mgLayer.DisplayInLegend = pv_blnVisible
  47.         Me.Map.Save(Me.ResourceService)
  48.     Catch pv_objExc As Exception
  49.         Me.errHandl.ErrorRaised(pv_objExc, pv_objUser, "")
  50.     End Try
  51. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement