-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6563447
Showing
132 changed files
with
88,269 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 14 | ||
VisualStudioVersion = 14.0.25420.1 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WeChatMVC", "WeChatMVC\WeChatMVC.csproj", "{F5CEA695-85A3-4A99-8F09-7A0F44CA3CFA}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{F5CEA695-85A3-4A99-8F09-7A0F44CA3CFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{F5CEA695-85A3-4A99-8F09-7A0F44CA3CFA}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{F5CEA695-85A3-4A99-8F09-7A0F44CA3CFA}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{F5CEA695-85A3-4A99-8F09-7A0F44CA3CFA}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
|
||
namespace WeChatMVC | ||
{ | ||
public class RouteConfig | ||
{ | ||
public static void RegisterRoutes(RouteCollection routes) | ||
{ | ||
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); | ||
|
||
routes.MapRoute( | ||
name: "Default", | ||
url: "{controller}/{action}/{id}", | ||
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } | ||
); | ||
|
||
routes.MapRoute( | ||
name: "useAPI", | ||
url: "api/{action}/{studentnum}/{pwd}", | ||
defaults: new { controller = "api", action = "action", id = UrlParameter.Optional }, | ||
constraints: new { studentnum = @"\d*" } | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
using System; | ||
using System.Text.RegularExpressions; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Net; | ||
using System.IO; | ||
using System.Xml; | ||
using System.Web; | ||
using System.Collections; | ||
using System.Net.Sockets; | ||
using System.Web.Mvc; | ||
|
||
namespace WeChatMVC.Controllers | ||
{ | ||
class MyHttpHelper | ||
{ | ||
static CookieContainer cookiecontainer = new CookieContainer(); | ||
static CookieCollection cookiecollection = new CookieCollection(); | ||
HttpWebRequest request; | ||
HttpWebResponse response; | ||
string html = string.Empty; | ||
public MyHttpHelper(string url) | ||
{ | ||
request = (HttpWebRequest)WebRequest.Create(url); | ||
request.CookieContainer = MyHttpHelper.cookiecontainer; | ||
cookiecontainer.Add(request.RequestUri, MyHttpHelper.cookiecollection); | ||
request.AllowAutoRedirect = false; | ||
request.KeepAlive = true; | ||
request.Accept = "*/*;"; | ||
request.UserAgent = "Mozilla/5.0"; | ||
request.ContentType = "application/x-www-form-urlencoded"; | ||
} | ||
public void HttpGet() | ||
{ | ||
GetResponse(); | ||
} | ||
public void HttpPost(string postcontent) | ||
{ | ||
byte[] bytes = Encoding.UTF8.GetBytes(postcontent); | ||
request.ContentLength = bytes.Length; | ||
Stream stream = request.GetRequestStream(); | ||
stream.Write(bytes, 0, bytes.Length); | ||
stream.Flush(); | ||
GetResponse(); | ||
} | ||
private void GetResponse() | ||
{ | ||
response = (HttpWebResponse)request.GetResponse(); | ||
ReadHtml(); | ||
EndCookie(); | ||
} | ||
private void ReadHtml() | ||
{ | ||
StreamReader sr = new StreamReader(response.GetResponseStream()); | ||
html = sr.ReadToEnd(); | ||
} | ||
private void EndCookie() | ||
{ | ||
cookiecollection = response.Cookies; | ||
} | ||
public override string ToString() | ||
{ | ||
return html; | ||
} | ||
} | ||
public class APIController : Controller | ||
{ | ||
// GET: API | ||
public string ty(string studentnum, string pwd) | ||
{ | ||
string post = "__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwULLTIxMjk4Nzk4MzUPZBYCZg9kFghmDxBkZBYBZmQCBQ8PFgIeBFRleHRlZGQCBg8PFgIfAAUSMjAxNC85LzE2IDExOjI1OjUyZGQCBw8PFgIfAAUSMjAzNC85LzE2IDExOjI1OjUyZGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFBWJ0bm9rg7wsmKWoIGv%2B2o6SEkUuPN0q80w%3D&dlljs=st&" + | ||
"txtuser=" + studentnum + | ||
"&txtpwd=" + pwd + | ||
"&__VIEWSTATEGENERATOR=5B21F7B0&__EVENTVALIDATION=%2FwEWCAKAvaGBDAKBwaG%2FAQLMrvvQDQLd8tGoBALWwdnoCALB2tiCDgKd%2B7q4BwL9kpmqCm3geVz7Uj28fz9x4hImTVbLX%2BiL&btnok.x=0&btnok.y=0"; | ||
|
||
MyHttpHelper httphelper = new MyHttpHelper(@"http://59.78.92.38:8888/sportscore/"); | ||
httphelper.HttpGet(); | ||
httphelper = new MyHttpHelper(@"http://59.78.92.38:8888/sportscore/"); | ||
httphelper.HttpPost(post); | ||
|
||
|
||
Regex re = new Regex("<span id=\"lblname\">\\s*(?<name>[^\\s]*)\\s*</span>[\\s\\S]*?<span id=\"lblmsg\">[\\s\\S]*?早操:[\\s\\S]*?>(?<morningexercises>\\d+)<[\\s\\S]*?课外活动1:[\\s\\S]*?>(?<outclassactivite1>\\d+)<[\\s\\S]*?</span>"); | ||
Match match = re.Match(httphelper.ToString()); | ||
GroupCollection gc = match.Groups; | ||
string name = gc["name"].Value; | ||
string morningexercise = gc["morningexercises"].Value; | ||
string outclassactivite1 = gc["outclassactivite1"].Value; | ||
|
||
return Get_Reply(Get_Score(studentnum, pwd)); | ||
} | ||
|
||
public JsonResult lib() | ||
{ | ||
Regex re = new Regex("(?<=>)\\d+(?=<)"); | ||
MyHttpHelper library = new MyHttpHelper(@"http://lib.ecust.edu.cn:8081/gateseat/lrp.aspx"); | ||
library.HttpGet(); | ||
MatchCollection mc = re.Matches(library.ToString()); | ||
JsonResult json = new JsonResult(); | ||
var data = new object[6]; | ||
for (int i = 1; i <= 6; i++) | ||
{ | ||
var used = mc[2 * i - 2].Value; | ||
var remain = mc[2 * i - 1].Value; | ||
data[i - 1] = new { used, remain }; | ||
} | ||
json.Data = data; | ||
json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; | ||
return json; | ||
} | ||
|
||
static string Get_Reply(string html) | ||
{ | ||
string reply = ""; | ||
|
||
Regex re = new Regex("<span id=\"lblname\">\\s*(?<name>[^\\s]*)\\s*</span>[\\s\\S]*?<span id=\"lblmsg\">[\\s\\S]*?早操:[\\s\\S]*?>(?<morningexercises>\\d+)<[\\s\\S]*?课外活动1:[\\s\\S]*?>(?<outclassactivite1>\\d+)<[\\s\\S]*?</span>"); | ||
Match match = re.Match(html); | ||
GroupCollection gc = match.Groups; | ||
string name = gc["name"].Value; | ||
string morningexercise = gc["morningexercises"].Value; | ||
string outclassactivite1 = gc["outclassactivite1"].Value; | ||
reply = name + "同学,您晨跑次数为:" + morningexercise + ",课外活动次数为:" + outclassactivite1; | ||
|
||
return reply; | ||
} | ||
static string Get_Score(string studentnum, string password) | ||
{ | ||
string html = ""; | ||
CookieCollection cc = new CookieCollection(); | ||
CookieContainer ccon = new CookieContainer(); | ||
HttpWebRequest hwr = (HttpWebRequest)WebRequest.Create(@"http://59.78.92.38:8888/sportscore/"); | ||
hwr.CookieContainer = ccon; | ||
HttpWebResponse hwro = (HttpWebResponse)hwr.GetResponse(); | ||
cc = hwro.Cookies; | ||
|
||
HttpWebRequest hwr2 = (HttpWebRequest)WebRequest.Create(@"http://59.78.92.38:8888/sportscore/"); | ||
hwr2.AllowAutoRedirect = false; | ||
hwr2.Method = "POST"; | ||
hwr2.CookieContainer = ccon; | ||
ccon.Add(hwr2.RequestUri, cc); | ||
hwr2.ContentType = "application/x-www-form-urlencoded"; | ||
string post = "__EVENTTARGET=&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwULLTIxMjk4Nzk4MzUPZBYCZg9kFghmDxBkZBYBZmQCBQ8PFgIeBFRleHRlZGQCBg8PFgIfAAUSMjAxNC85LzE2IDExOjI1OjUyZGQCBw8PFgIfAAUSMjAzNC85LzE2IDExOjI1OjUyZGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgEFBWJ0bm9rg7wsmKWoIGv%2B2o6SEkUuPN0q80w%3D&dlljs=st&" + | ||
"txtuser=10150111&txtpwd=660602" + | ||
"&__VIEWSTATEGENERATOR=5B21F7B0&__EVENTVALIDATION=%2FwEWCAKAvaGBDAKBwaG%2FAQLMrvvQDQLd8tGoBALWwdnoCALB2tiCDgKd%2B7q4BwL9kpmqCm3geVz7Uj28fz9x4hImTVbLX%2BiL&btnok.x=0&btnok.y=0"; | ||
byte[] bytes = Encoding.UTF8.GetBytes(post); | ||
hwr2.ContentLength = bytes.Length; | ||
Stream stream = hwr2.GetRequestStream(); | ||
stream.Write(bytes, 0, bytes.Length); | ||
stream.Flush(); | ||
|
||
HttpWebResponse hwro2 = (HttpWebResponse)hwr2.GetResponse(); | ||
|
||
|
||
StreamReader sr = new StreamReader(hwro2.GetResponseStream()); | ||
html = sr.ReadToEnd(); | ||
if (Regex.IsMatch(html, "Object moved")) | ||
{ | ||
HttpWebRequest hwr3 = (HttpWebRequest)WebRequest.Create(@"http://59.78.92.38:8888/sportscore/stScore.aspx"); | ||
hwr3.CookieContainer = ccon; | ||
ccon.Add(hwr3.RequestUri, cc); | ||
HttpWebResponse hwro3 = (HttpWebResponse)hwr3.GetResponse(); | ||
sr = new StreamReader(hwro3.GetResponseStream()); | ||
html = sr.ReadToEnd(); | ||
return html; | ||
} | ||
else | ||
throw new Exception("用户名或密码错误!"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
|
||
namespace WeChatMVC.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
// GET: Home | ||
public string Index() | ||
{ | ||
return "aaa"; | ||
} | ||
public ActionResult GetResult() | ||
{ | ||
return View("firstView"); | ||
} | ||
public string Posttest() | ||
{ | ||
return "IJIJI"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ Application Codebehind="Global.asax.cs" Inherits="WeChatMVC.MvcApplication" Language="C#" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using System.Web.Mvc; | ||
using System.Web.Routing; | ||
|
||
namespace WeChatMVC | ||
{ | ||
public class MvcApplication : System.Web.HttpApplication | ||
{ | ||
protected void Application_Start() | ||
{ | ||
AreaRegistration.RegisterAllAreas(); | ||
RouteConfig.RegisterRoutes(RouteTable.Routes); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的常规信息通过下列特性集 | ||
// 控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("WeChatMVC")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("Microsoft")] | ||
[assembly: AssemblyProduct("WeChatMVC")] | ||
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 会使此程序集中的类型 | ||
// 对 COM 组件不可见。如果需要 | ||
// 从 COM 访问此程序集中的某个类型,请针对该类型将 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID | ||
[assembly: Guid("f5cea695-85a3-4a99-8f09-7a0f44ca3cfa")] | ||
|
||
// 程序集的版本信息由下列四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 内部版本号 | ||
// 修订版本 | ||
// | ||
// 可以指定所有值,也可以使用“修订号”和“内部版本号”的默认值, | ||
// 方法是按如下所示使用 "*": | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
|
||
@{ | ||
Layout = null; | ||
} | ||
|
||
<!DOCTYPE html> | ||
|
||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width" /> | ||
<title>firstView</title> | ||
</head> | ||
<body> | ||
<div> | ||
<form action="/home/posttest" method="post"> | ||
<input id="Text1" type="text" /><input id="Submit1" type="submit" value="submit" /> | ||
</form> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0"?> | ||
|
||
<configuration> | ||
<configSections> | ||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> | ||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> | ||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
|
||
<system.web.webPages.razor> | ||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> | ||
<pages pageBaseType="System.Web.Mvc.WebViewPage"> | ||
<namespaces> | ||
<add namespace="System.Web.Mvc" /> | ||
<add namespace="System.Web.Mvc.Ajax" /> | ||
<add namespace="System.Web.Mvc.Html" /> | ||
<add namespace="System.Web.Routing" /> | ||
<add namespace="WeChatMVC" /> | ||
</namespaces> | ||
</pages> | ||
</system.web.webPages.razor> | ||
|
||
<appSettings> | ||
<add key="webpages:Enabled" value="false" /> | ||
</appSettings> | ||
|
||
<system.webServer> | ||
<handlers> | ||
<remove name="BlockViewHandler"/> | ||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> | ||
</handlers> | ||
</system.webServer> | ||
|
||
<system.web> | ||
<compilation> | ||
<assemblies> | ||
<add assembly="System.Web.Mvc, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> | ||
</assemblies> | ||
</compilation> | ||
</system.web> | ||
</configuration> |
Oops, something went wrong.