public async Task <ClaimsIdentity> GenerateUserIdentityAsync(UserManager <ApplicationUser> manager) { // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie); // Add custom user claims here userIdentity.AddClaim(new Claim("RealName", RealName.ToString())); return(userIdentity); }
public void ConnectTest() { textBox1.Text = "正在连接到NCUT,如果长时间没有反应,请检查网络连接!\r\n\r\n"; pictureBox1.Show(); pictureBox2.Hide(); pictureBox3.Hide(); string str; button1.Enabled = false; button2.Enabled = false; button3.Enabled = false; button4.Enabled = false; button5.Enabled = false; button6.Enabled = false; str = GetHttpWebRequest("http://ip.ncut.edu.cn/"); //Console.WriteLine(str); //MessageBox.Show(str); textBox1.Text = "确保绿色指示灯闪烁一次,其它颜色指示灯关闭。\r\n\r\n\r\n" + str; // Regex r = new Regex("flow='"); string[] a = str.Split(';'); //string[] name = str.Split(';'); // Match m = r.Match(str); // if (m.Success) // { // Console.WriteLine("Found match at position " + m.Index); //输入匹配字符的位置 // } int res; //int idnum; try { string b = a[3]; string result2; string result1; result2 = GET(b); result1 = fanzhuan(result2); int.TryParse(result1, out res); string Usetime = a[2]; int time; result2 = GET(Usetime); Usetime = fanzhuan(result2); int.TryParse(Usetime, out time); TimeSpan ts = new TimeSpan(0, time, 0); //label8.Text = "有效使用时长*: " + ts.TotalMinutes + "小时 " ; label8.Text = "有效使用时长*: " + ts.Days + " 天 " + ts.Hours + " 小时 " + ts.Minutes + "分钟"; string name = a[27]; Regex reg = new Regex("[\u4e00-\u9fa5]+"); foreach (Match RealName in reg.Matches(name)) { name = RealName.ToString(); } //Console.WriteLine(RealName); string id = a[12]; string id1; string id2; id1 = GET(id); id2 = fanzhuan(id1); label7.Text = "ID: " + name + " (" + id2 + ")"; //res = int.Parse(b); //MessageBox.Show(b); int flow, flow1, flow0; flow = res; flow0 = flow % 1024; flow1 = flow - flow0; flow0 = flow0 * 1000; flow0 = flow0 - flow0 % 1024; string flow3 = "."; string detail; detail = "已使用流量 : " + flow1 / 1024 + flow3 + flow0 / 1024 + " M"; //MessageBox.Show(detail); //textBox2.Text = detail; label3.Text = detail; toolStripStatusLabel2.Text = "确保绿色指示灯闪烁一次,其它颜色指示灯关闭。"; string TextFlag = a[200]; if (res == 0 && name == "基本参数") { toolStripStatusLabel2.Text = "连接测试:连接失败请检查网络是否连接,或者是否登陆NCUT!"; pictureBox1.Hide(); pictureBox2.Hide(); pictureBox3.Show(); label8.Text = "ID"; label7.Text = "有效使用时长*:"; label3.Text = "已使用流量 :"; try { Ping usable = new Ping(); Console.WriteLine(usable.Send("192.168.254.251").Status); DialogResult dr = MessageBox.Show("Ping:" + usable.Send("192.168.254.251").Status + "!\r\n您可能并未登陆NCUT-AUTO,是否打开浏览器为您登陆?", "登陆提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { System.Diagnostics.Process.Start("http://ip.ncut.edu.cn/"); } } catch { DialogResult dr = MessageBox.Show("Ping:Fail" + "!\r\n您可能并未连接到NCUT-AUTO,请您打开网络和Internet设置。", "连接提示"); } } pictureBox1.Hide(); } catch (Exception ex) { toolStripStatusLabel2.Text = "连接测试:连接失败请检查网络是否连接,或者是否登陆NCUT!"; Console.WriteLine(ex.Message); label8.Text = "ID"; label7.Text = "有效使用时长*:"; label3.Text = "已使用流量 :"; pictureBox1.Hide(); pictureBox2.Hide(); pictureBox3.Show(); try { Ping usable = new Ping(); Console.WriteLine(usable.Send("192.168.254.251").Status); DialogResult dr = MessageBox.Show("Ping:" + usable.Send("192.168.254.251").Status + "!\r\n您可能并未登陆NCUT-AUTO,是否打开浏览器为您登陆?", "登陆提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { System.Diagnostics.Process.Start("http://ip.ncut.edu.cn/"); } } catch { DialogResult dr = MessageBox.Show("Ping:Fail" + "!\r\n您可能并未连接到NCUT-AUTO,请您打开网络和Internet设置。", "连接提示"); } } }
private void Fun() { string str; this.textBox1.Text = "正在连接到NCUT,如果长时间没有反应,请检查网络连接!"; str = GetHttpWebRequest("http://ip.ncut.edu.cn/"); this.textBox1.Text = "已经连接到NCUT(ip.ncut.edu.cn)!"; string[] a = str.Split(';'); int res; try { string b = a[3]; string result2; result2 = GET(b); result2 = fanzhuan(result2); int.TryParse(result2, out res); string Usetime = a[2]; int time; result2 = GET(Usetime); Usetime = fanzhuan(result2); int.TryParse(Usetime, out time); TimeSpan ts = new TimeSpan(0, time, 0); label8.Text = "有效使用时长*: " + ts.Days + " 天 " + ts.Hours + " 小时 " + ts.Minutes + "分钟"; string name = a[27]; Regex reg = new Regex("[\u4e00-\u9fa5]+"); foreach (Match RealName in reg.Matches(name)) { name = RealName.ToString(); } //Console.WriteLine(RealName); string id = a[12]; string id1; string id2; id1 = GET(id); id2 = fanzhuan(id1); label7.Text = "ID: " + name + " (" + id2 + ")"; int flow, flow1, flow0; flow = res; flow0 = flow % 1024; flow1 = flow - flow0; flow0 = flow0 * 1000; flow0 = flow0 - flow0 % 1024; string flow3 = "."; string detail; detail = "已使用流量 : " + flow1 / 1024 + flow3 + flow0 / 1024 + " M"; button1.Enabled = true; button2.Enabled = true; button3.Enabled = true; label3.Text = detail; string TextFlag = a[200];//未登录时数组会越界 //if (res == 0 && name == "基本参数") //{ // pictureBox1.Hide(); // pictureBox2.Hide(); // pictureBox3.Show(); // timer2.Stop(); // timer4.Stop(); // timer3.Stop(); // label7.Text = "-------------------"; // label8.Text = "-------------------"; // label3.Text = "-------------------"; // notifyIcon1.BalloonTipTitle = "注意"; // notifyIcon1.BalloonTipText = "您可能并未登陆NCUT-AUTO,请您打开浏览器重新登陆。"; // notifyIcon1.ShowBalloonTip(3000); //} } catch (Exception ex) { pictureBox1.Hide(); pictureBox2.Hide(); pictureBox3.Show(); timer2.Stop(); timer4.Stop(); timer3.Stop(); label7.Text = "-------------------"; label8.Text = "-------------------"; this.label3.Text = "-------------------"; notifyIcon1.BalloonTipTitle = "注意"; notifyIcon1.BalloonTipText = "您可能并未登陆NCUT-AUTO,请您打开浏览器重新登陆。"; notifyIcon1.ShowBalloonTip(3000); Console.WriteLine(ex.Message); } }