Public Class Server Dim strConn As String = XmlSetting.Read("identity", "connectionstring") Dim sqlData As SqlService = New SqlService() Dim ds As DataSet Dim dt As DataTable Dim dr As DataRow Dim dv As DataView Dim strSql As String Dim appAssembly As System.Reflection.Assembly Dim htmpath As String Dim smarket As String = XmlSetting.Read("identity", "smarket") Dim sdistrict As String = XmlSetting.Read("identity", "sdistrict") Dim username As String = XmlSetting.Read("identity", "username") Dim soffice As String Dim sforce As String = XmlSetting.Read("identity", "sforce") Dim srepid As String = XmlSetting.Read("identity", "srepid") Dim password As String = XmlSetting.Read("appsettings", "password") Dim certpath As String = XmlSetting.Read("identity", "certpath") Dim vdomain As String = XmlSetting.Read("identity", "vdomain") Dim servpath As String = XmlSetting.Read("identity", "servpath") Dim nearfullpath As String = "https://" + vdomain + servpath Dim mainpath As String = nearfullpath + "sss/" Dim proxypath As String = XmlSetting.Read("identity", "proxypath") Dim proxyport As Integer = CType(XmlSetting.Read("identity", "proxyport"), Integer) Dim sCookie1 As Cookie = New Cookie("XXX") Dim sCookie2 As Cookie = New Cookie("XXX") Dim sCookie3 As Cookie = New Cookie("XXX") Dim sCookie4 As Cookie Dim sCookie5 As Cookie = New Cookie("awacs_u", username, servpath, vdomain) Dim sCookie6 As Cookie Dim sCookie7 As Cookie = New Cookie("awacs_r", srepid, servpath, vdomain) Dim sCookieContainer As CookieContainer = New CookieContainer() Sub New() MyBase.new() appAssembly = System.Reflection.Assembly.GetCallingAssembly htmpath = appAssembly.CodeBase htmpath = htmpath.Substring(8) htmpath = Path.GetDirectoryName(htmpath).Replace("bin", "") End Sub Public Function HttpGetHtml(ByVal url As String, ByVal office As String) As String Dim strID As String = "" Dim sr As StreamReader Dim req As HttpWebRequest Dim res As HttpWebResponse Dim cer As X509Certificate ' I received a different kind of certificate so I had to import it and then export the type that .NET supported Dim proxy As WebProxy ' a proxy is a computer with an address that is in front of the actual server you want to reach. It can check the certification. Dim strError As String ' if you checked for the address of the actual server it would not exist on the internet possibly like in this case. Dim strCookies As String proxy = New WebProxy(proxypath, proxyport) ' the proxy and the webrequest work together to get to the real url req = WebRequest.Create(url) ' this is the server providing the service sCookieContainer.Add(sCookie1) sCookieContainer.Add(sCookie2) sCookieContainer.Add(sCookie3) soffice = office sCookie4 = New Cookie("XXX", soffice, servpath, vdomain) sCookieContainer.Add(sCookie4) sCookieContainer.Add(sCookie5) strID = TryReadFile(htmpath + "id.txt") sCookie6 = New Cookie("awacs_password", strID, servpath, vdomain) sCookieContainer.Add(sCookie6) sCookieContainer.Add(sCookie7) req.CookieContainer = sCookieContainer cer = X509Certificate.CreateFromCertFile(certpath) req.ClientCertificates.Add(cer) req.Proxy = proxy req.Method = "GET" ' sometimes a post will be required for just certain pages for some detailed reason. The signin and post are slight variations of this code. req.ContentType = "application/x-www-form-urlencoded" ' the next 4 lines may or may not be important in your case req.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;)" req.KeepAlive = True req.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*" res = CType(req.GetResponse(), HttpWebResponse) sr = New StreamReader(res.GetResponseStream) ' this is the actual connection to the other server Dim strHtmlx As String = sr.ReadToEnd strID = Me.Getstring(res.Headers.ToString, "awacs_password", 15, 16) ' get password out of the header TryWriteFile(strID, htmpath + "id.txt") ' here I have to try to write until I succeed since many user may be hitting this at once. res.Close() Return strHtmlx ' the returned string is an entire html page which I will be screen scraping to build my own pages for my own control of the service. End Function
Srch = "name=" + Quote + "sso" del1 = "value=" + Quote del2 = Quote + " >" rv.sso = curServer.GetDelString(Html, Srch, del1, del2) Session("phonchoi") = rv Dim al1 As ArrayList = New ArrayList() Dim r1 As Regex = New Regex("", RegexOptions.IgnoreCase) Dim mc As MatchCollection Dim m As Match Dim strSubHtml As String strSubHtml = curServer.GetDelString(strHtml, "") mc = r1.Matches(strSubHtml) For Each m In mc al1.Add(m.ToString.Substring(20, 3)) Next m session("page1") = al1 server.transfer("page2.aspx")
User Comments
No comments posted yet.