From 348bf1dfb387079d9cec5337efcb2f1d03de09b4 Mon Sep 17 00:00:00 2001 From: HearSilent Date: Mon, 27 Feb 2017 01:13:07 +0800 Subject: [PATCH] Add auto detect email method --- Windows/KUAS WiFi/LoginFrm.vb | 27 ++++++++++++++++++-- Windows/KUAS WiFi/My Project/AssemblyInfo.vb | 4 +-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Windows/KUAS WiFi/LoginFrm.vb b/Windows/KUAS WiFi/LoginFrm.vb index 3497cf6..181403f 100644 --- a/Windows/KUAS WiFi/LoginFrm.vb +++ b/Windows/KUAS WiFi/LoginFrm.vb @@ -133,8 +133,31 @@ Public Class LoginFrm Private Sub login(_host As String) Dim parameters As IDictionary(Of String, String) = New Dictionary(Of String, String)() - parameters.Add("username", System.Uri.EscapeDataString(User.Text)) - parameters.Add("userpwd", System.Uri.EscapeDataString(Pwd.Text)) + Dim username As String = User.Text + Dim password As String = Pwd.Text + + If (username.EndsWith("@kuas.edu.tw")) Then + username = username + ElseIf (username.EndsWith("@gm.kuas.edu.tw")) Then + username = username + ElseIf (username.Length() = 10 And Not username.Substring(0, 2).Equals("09")) Then + If (Convert.ToInt32(username.Substring(1, 3) <= 102)) Then + username += "@kuas.edu.tw" + Else + username += "@gm.kuas.edu.tw" + End If + ElseIf (username.Length() = 5) Then + username += "@kuas.edu.tw" + ElseIf (username.Contains("@") And Not username.Contains("@guest")) Then + username = username + Else + username += IIf(username.Contains("@guest"), "", "@guest") + End If + + Debug.Print(username) + + parameters.Add("username", System.Uri.EscapeDataString(username)) + parameters.Add("userpwd", System.Uri.EscapeDataString(password)) parameters.Add("login", "") parameters.Add("orig_referer", "") diff --git a/Windows/KUAS WiFi/My Project/AssemblyInfo.vb b/Windows/KUAS WiFi/My Project/AssemblyInfo.vb index 308e85a..4aabab8 100644 --- a/Windows/KUAS WiFi/My Project/AssemblyInfo.vb +++ b/Windows/KUAS WiFi/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' 指定為預設值: ' - - + +