├── AutoConnectionSchoolWifi
├── FodyWeavers.xml
├── App.config
├── packages.config
├── Properties
│ ├── Settings.settings
│ ├── AssemblyInfo.cs
│ ├── Settings.Designer.cs
│ ├── Resources.Designer.cs
│ └── Resources.resx
├── src
│ ├── ConnectionStateCallBack.cs
│ ├── AbstractAutoConnection.cs
│ └── DefaultAutoConnection.cs
├── Program.cs
├── Form1.cs
├── Form1.Designer.cs
├── AutoConnectionSchoolWifi.csproj
├── Form1.resx
└── FodyWeavers.xsd
├── .gitignore
├── AutoConnectionSchoolWifi.sln
├── README.md
└── LICENSE
/AutoConnectionSchoolWifi/FodyWeavers.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ################################################################################
2 | # 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
3 | ################################################################################
4 |
5 | /AutoConnectionSchoolWifi/bin
6 | /AutoConnectionSchoolWifi/obj
7 | /.vs/AutoConnectionSchoolWifi/v16
8 | /packages
9 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/src/ConnectionStateCallBack.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace AutoConnectionSchoolWifi.src
8 | {
9 | interface ConnectionStateCallBack
10 | {
11 | void StateChange(String state);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace AutoConnectionSchoolWifi
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("AutoConnectionSchoolWifi")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("AutoConnectionSchoolWifi")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 会使此程序集中的类型
18 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("b608079f-53e7-4cc8-b5a2-1cf26082d815")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33 | //通过使用 "*",如下所示:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AutoConnectionSchoolWifi.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.29215.179
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoConnectionSchoolWifi", "AutoConnectionSchoolWifi\AutoConnectionSchoolWifi.csproj", "{B608079F-53E7-4CC8-B5A2-1CF26082D815}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {B608079F-53E7-4CC8-B5A2-1CF26082D815}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {B608079F-53E7-4CC8-B5A2-1CF26082D815}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {B608079F-53E7-4CC8-B5A2-1CF26082D815}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {B608079F-53E7-4CC8-B5A2-1CF26082D815}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {91D56313-3BF5-40D0-8F81-F3A8549B28F6}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Form1.cs:
--------------------------------------------------------------------------------
1 | using AutoConnectionSchoolWifi.src;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.ComponentModel;
5 | using System.Data;
6 | using System.Drawing;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 | using System.Windows.Forms;
12 |
13 | namespace AutoConnectionSchoolWifi
14 | {
15 | public partial class Form1 : Form , ConnectionStateCallBack
16 | {
17 |
18 | SynchronizationContext _syncContext = null;
19 |
20 | public Form1()
21 | {
22 | InitializeComponent();
23 | _syncContext = SynchronizationContext.Current;
24 | Start();
25 | }
26 |
27 | private void SetText(object text)
28 | {
29 | this.tb.Text += text.ToString() + "\r\n";
30 | MoveCurorLast();
31 | }
32 |
33 | private void MoveCurorLast()
34 | {
35 | //让文本框获取焦点
36 | this.tb.Focus();
37 | //设置光标的位置到文本尾
38 | this.tb.Select(this.tb.TextLength, 0);
39 | //滚动到控件光标处
40 | this.tb.ScrollToCaret();
41 | }
42 |
43 | public void StateChange(string state)
44 | {
45 | _syncContext.Post(SetText, state);
46 | }
47 |
48 | private void Start()
49 | {
50 | Thread th = new Thread(ThreadChild);
51 | th.Start(this);
52 |
53 | }
54 |
55 | static void ThreadChild(object callback)
56 | {
57 | try
58 | {
59 | var conn = new DefaultAutoConnection((ConnectionStateCallBack)callback);
60 | conn.Connection();
61 | }
62 | catch(Exception e)
63 | {
64 | MessageBox.Show(e.Message);
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # AutoConnectionSchoolWifi
2 | 哈尔滨信息工程学院自动连接校园WIFI
3 |
4 | [](https://github.com/itning/AutoConnectionSchoolWifi/stargazers)
5 | [](https://github.com/itning/AutoConnectionSchoolWifi/network/members)
6 | [](https://github.com/itning/AutoConnectionSchoolWifi/watchers)
7 | [](https://github.com/itning?tab=followers)
8 |
9 | [](https://github.com/itning/AutoConnectionSchoolWifi/issues)
10 | [](https://github.com/itning/AutoConnectionSchoolWifi/blob/master/LICENSE)
11 | [](https://github.com/itning/AutoConnectionSchoolWifi/commits)
12 | [](https://github.com/itning/AutoConnectionSchoolWifi/releases)
13 | [](https://github.com/itning/AutoConnectionSchoolWifi)
14 | [](http://hits.dwyl.io/itning/AutoConnectionSchoolWifi)
15 | [](https://github.com/itning/AutoConnectionSchoolWifi)
16 |
17 | **使用方法**
18 |
19 | 1. [下载EXE](https://github.com/itning/AutoConnectionSchoolWifi/releases)
20 | 2. 在用户目录新建文件 ``userinfo``
21 | 3. 文件写入 登录用户名 密码(用英文逗号分隔)
22 | 4. 运行即可
23 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace AutoConnectionSchoolWifi
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要修改
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.tb = new System.Windows.Forms.TextBox();
32 | this.SuspendLayout();
33 | //
34 | // tb
35 | //
36 | this.tb.Location = new System.Drawing.Point(12, 9);
37 | this.tb.Multiline = true;
38 | this.tb.Name = "tb";
39 | this.tb.ReadOnly = true;
40 | this.tb.Size = new System.Drawing.Size(225, 105);
41 | this.tb.TabIndex = 1;
42 | //
43 | // Form1
44 | //
45 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
46 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
47 | this.ClientSize = new System.Drawing.Size(251, 124);
48 | this.Controls.Add(this.tb);
49 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
50 | this.MaximizeBox = false;
51 | this.Name = "Form1";
52 | this.ShowIcon = false;
53 | this.Text = "WLAN自动登录";
54 | this.ResumeLayout(false);
55 | this.PerformLayout();
56 |
57 | }
58 |
59 | #endregion
60 | private System.Windows.Forms.TextBox tb;
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/src/AbstractAutoConnection.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Net.NetworkInformation;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows;
9 |
10 | namespace AutoConnectionSchoolWifi.src
11 | {
12 | abstract class AbstractAutoConnection
13 | {
14 | private ConnectionStateCallBack connectionStateCallBack;
15 |
16 | public AbstractAutoConnection(ConnectionStateCallBack connectionStateCallBack)
17 | {
18 | this.connectionStateCallBack = connectionStateCallBack;
19 | }
20 |
21 | public void Connection()
22 | {
23 | connectionStateCallBack.StateChange("正在准备...");
24 | if (CheckWifi())
25 | {
26 | if (Ping())
27 | {
28 | connectionStateCallBack.StateChange("已连接互联网...");
29 | }
30 | else
31 | {
32 | RedirectLogin();
33 | }
34 | }
35 | else
36 | {
37 | ConnectTrueWifi();
38 | if (Ping())
39 | {
40 | connectionStateCallBack.StateChange("已连接互联网...");
41 | }
42 | else
43 | {
44 | RedirectLogin();
45 | }
46 | }
47 | }
48 |
49 | public abstract bool CheckWifi();
50 |
51 | public abstract void ConnectTrueWifi();
52 |
53 | public bool Ping()
54 | {
55 | PingOptions pingOption = new PingOptions
56 | {
57 | DontFragment = true
58 | };
59 |
60 | int timeout = 1000;
61 | try
62 | {
63 | PingReply reply = new Ping().Send("www.baidu.com", timeout);
64 | if (reply.Status == IPStatus.Success)
65 | {
66 | return true;
67 | }
68 | else
69 | {
70 | return false;
71 | }
72 | }
73 | catch (PingException e)
74 | {
75 | connectionStateCallBack.StateChange(e.Message);
76 | return false;
77 | }
78 | }
79 |
80 | public abstract void RedirectLogin();
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace AutoConnectionSchoolWifi.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 强类型资源类,用于查找本地化字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的缓存 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AutoConnectionSchoolWifi.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 覆盖当前线程的 CurrentUICulture 属性
56 | /// 使用此强类型的资源类的资源查找。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/AutoConnectionSchoolWifi.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Debug
7 | AnyCPU
8 | {B608079F-53E7-4CC8-B5A2-1CF26082D815}
9 | WinExe
10 | AutoConnectionSchoolWifi
11 | AutoConnectionSchoolWifi
12 | v4.7.2
13 | 512
14 | true
15 | true
16 |
17 |
18 |
19 |
20 | AnyCPU
21 | true
22 | full
23 | false
24 | bin\Debug\
25 | DEBUG;TRACE
26 | prompt
27 | 4
28 |
29 |
30 | AnyCPU
31 | pdbonly
32 | true
33 | bin\Release\
34 | TRACE
35 | prompt
36 | 4
37 |
38 |
39 |
40 | ..\packages\Costura.Fody.4.1.0\lib\net40\Costura.dll
41 |
42 |
43 | ..\..\ManagedNativeWifi\ManagedNativeWifi\bin\Release\ManagedNativeWifi.dll
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | Form
60 |
61 |
62 | Form1.cs
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Form1.cs
71 |
72 |
73 | ResXFileCodeGenerator
74 | Resources.Designer.cs
75 | Designer
76 |
77 |
78 | True
79 | Resources.resx
80 |
81 |
82 |
83 | SettingsSingleFileGenerator
84 | Settings.Designer.cs
85 |
86 |
87 | True
88 | Settings.settings
89 | True
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
100 |
101 |
102 |
103 |
104 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/src/DefaultAutoConnection.cs:
--------------------------------------------------------------------------------
1 | using ManagedNativeWifi;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Diagnostics;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Net.Http;
8 | using System.Text;
9 | using System.Threading;
10 | using System.Threading.Tasks;
11 | using System.Windows;
12 | using System.Windows.Forms;
13 |
14 | namespace AutoConnectionSchoolWifi.src
15 | {
16 | class DefaultAutoConnection : AbstractAutoConnection
17 | {
18 | private ConnectionStateCallBack connectionStateCallBack;
19 |
20 | public DefaultAutoConnection(ConnectionStateCallBack connectionStateCallBack) : base(connectionStateCallBack)
21 | {
22 | this.connectionStateCallBack = connectionStateCallBack;
23 | }
24 |
25 | public override bool CheckWifi()
26 | {
27 | connectionStateCallBack.StateChange("检查WIFI是否连接...");
28 | foreach (var ssid in NativeWifi.EnumerateConnectedNetworkSsids())
29 | {
30 | if (ssid.ToString().Equals("HXGNET"))
31 | {
32 | connectionStateCallBack.StateChange("已连接HXGNET...");
33 | return true;
34 | }
35 | }
36 | connectionStateCallBack.StateChange("未连接HXGNET...");
37 | return false;
38 | }
39 |
40 | public override void ConnectTrueWifi()
41 | {
42 | connectionStateCallBack.StateChange("连接正确WIFI...");
43 | // 打开WLAN
44 | NativeWifi.TurnOnInterfaceRadio(NativeWifi.EnumerateInterfaces().FirstOrDefault().Id);
45 | while (true)
46 | {
47 | // 找到 WIFI
48 | var a = NativeWifi.EnumerateAvailableNetworks()
49 | .Where(x => !string.IsNullOrWhiteSpace(x.ProfileName))
50 | .OrderByDescending(x => x.SignalQuality)
51 | .Where(x => x.Ssid.ToString().Equals("HXGNET"))
52 | .FirstOrDefault();
53 | if (a == null)
54 | {
55 | connectionStateCallBack.StateChange("等待WIFI...");
56 | Thread.Sleep(500);
57 | continue;
58 | }
59 | // 连接
60 | NativeWifi.ConnectNetwork(a.Interface.Id, a.ProfileName, a.BssType);
61 | connectionStateCallBack.StateChange("已连接WIFI...");
62 | break;
63 | }
64 | }
65 |
66 | public override void RedirectLogin()
67 | {
68 | while (!CheckWifi())
69 | {
70 | connectionStateCallBack.StateChange("等待WIFI...");
71 | Thread.Sleep(500);
72 | }
73 | connectionStateCallBack.StateChange("自动登录准备...");
74 | HttpClient httpClient = new HttpClient();
75 | Task httpResponseMessage = httpClient.GetAsync("http://www.baidu.com");
76 | httpResponseMessage.Wait();
77 | HttpResponseMessage h = httpResponseMessage.Result;
78 | var b = h.Content.ReadAsStringAsync();
79 | b.Wait();
80 | String s = b.Result;
81 | var loginUrl = "";
82 | try
83 | {
84 | loginUrl = s.Substring(s.IndexOf("='") + 2, s.LastIndexOf("'<") - (s.IndexOf("='") + 2));
85 | }
86 | catch (Exception)
87 | {
88 | connectionStateCallBack.StateChange("已连接互联网...");
89 | return;
90 | }
91 |
92 | if (!loginUrl.StartsWith("http"))
93 | {
94 | connectionStateCallBack.StateChange("已连接互联网...");
95 | return;
96 | }
97 | connectionStateCallBack.StateChange("获取到的登录地址..." + loginUrl);
98 | string username = "";
99 | string password = "";
100 | try
101 | {
102 | string path = Directory.GetParent(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)).FullName;
103 | if (Environment.OSVersion.Version.Major >= 6)
104 | {
105 | path = Directory.GetParent(path).ToString();
106 | }
107 | connectionStateCallBack.StateChange("用户目录: "+path);
108 | var user = File.ReadAllText(path + "\\userinfo").Split(new Char[] { ',' });
109 | if (user.Length != 2)
110 | {
111 | connectionStateCallBack.StateChange("用户信息文件错误");
112 | return;
113 | }
114 | connectionStateCallBack.StateChange("用户名:"+ user[0]);
115 | connectionStateCallBack.StateChange("密码:"+ user[1]);
116 | username = user[0];
117 | password = user[1];
118 | }
119 | catch (Exception e)
120 | {
121 | connectionStateCallBack.StateChange(e.Message);
122 | return;
123 | }
124 |
125 | var formContent = new FormUrlEncodedContent(new[]
126 | {
127 | new KeyValuePair("userId", username),
128 | new KeyValuePair("passwd", password),
129 | new KeyValuePair("templatetype", "3"),
130 | new KeyValuePair("pageid", "21")
131 | });
132 |
133 | var cc = httpClient.PostAsync(loginUrl, formContent);
134 | cc.Wait();
135 | var dd = cc.Result;
136 | connectionStateCallBack.StateChange("登录结果..." + dd.StatusCode);
137 | }
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
--------------------------------------------------------------------------------
/AutoConnectionSchoolWifi/FodyWeavers.xsd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks
13 |
14 |
15 |
16 |
17 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.
18 |
19 |
20 |
21 |
22 | A list of unmanaged 32 bit assembly names to include, delimited with line breaks.
23 |
24 |
25 |
26 |
27 | A list of unmanaged 64 bit assembly names to include, delimited with line breaks.
28 |
29 |
30 |
31 |
32 | The order of preloaded assemblies, delimited with line breaks.
33 |
34 |
35 |
36 |
37 |
38 | This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.
39 |
40 |
41 |
42 |
43 | Controls if .pdbs for reference assemblies are also embedded.
44 |
45 |
46 |
47 |
48 | Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.
49 |
50 |
51 |
52 |
53 | As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.
54 |
55 |
56 |
57 |
58 | Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.
59 |
60 |
61 |
62 |
63 | Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.
64 |
65 |
66 |
67 |
68 | A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |
69 |
70 |
71 |
72 |
73 | A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.
74 |
75 |
76 |
77 |
78 | A list of unmanaged 32 bit assembly names to include, delimited with |.
79 |
80 |
81 |
82 |
83 | A list of unmanaged 64 bit assembly names to include, delimited with |.
84 |
85 |
86 |
87 |
88 | The order of preloaded assemblies, delimited with |.
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 | 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.
97 |
98 |
99 |
100 |
101 | A comma-separated list of error codes that can be safely ignored in assembly verification.
102 |
103 |
104 |
105 |
106 | 'false' to turn off automatic generation of the XML Schema file.
107 |
108 |
109 |
110 |
111 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2018 itning
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------