Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
EduSpider
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
viitto
EduSpider
Commits
2c01b41d
Commit
2c01b41d
authored
May 25, 2022
by
liudong1993
Browse files
Options
Browse Files
Download
Plain Diff
1
parents
af974ff8
852eb413
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
573 additions
and
45 deletions
+573
-45
ICourseRepository.cs
EduSpider.IRepository/ICourseRepository.cs
+19
-5
ICourseStudentRepository.cs
EduSpider.IRepository/ICourseStudentRepository.cs
+21
-0
ICourseTeacherRepository.cs
EduSpider.IRepository/ICourseTeacherRepository.cs
+21
-0
IStudentRepository.cs
EduSpider.IRepository/IStudentRepository.cs
+18
-0
ICourseService.cs
EduSpider.IServices/ICourseService.cs
+18
-1
RB_Course_Student.cs
EduSpider.Model/Entity/RB_Course_Student.cs
+43
-0
RB_Course_Teacher.cs
EduSpider.Model/Entity/RB_Course_Teacher.cs
+43
-0
CourseQuery.cs
EduSpider.Model/Query/CourseQuery.cs
+25
-0
CourseRepository.cs
EduSpider.Repository/CourseRepository.cs
+64
-3
CourseStudentRepository.cs
EduSpider.Repository/CourseStudentRepository.cs
+24
-0
CourseTeacherRepository.cs
EduSpider.Repository/CourseTeacherRepository.cs
+24
-0
StudentRepository.cs
EduSpider.Repository/StudentRepository.cs
+10
-5
CourseService.cs
EduSpider.Services/CourseService.cs
+31
-0
JObjectHelper.cs
EduSpider.Utility/JObjectHelper.cs
+25
-0
CourseController.cs
EduSpider.WebApi/Controllers/CourseController.cs
+7
-2
EduSpider.WebApi.csproj
EduSpider.WebApi/EduSpider.WebApi.csproj
+2
-1
appsettings.json
EduSpider.WebApi/appsettings.json
+1
-1
EduSpider.sln
EduSpider.sln
+2
-2
EduSpider.csproj
EduSpider/EduSpider.csproj
+4
-0
ClassInAccountManager.cs
EduSpider/Spiders/ClassInRule/ClassInAccountManager.cs
+1
-1
ClassInFlow.cs
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
+3
-3
CourseManager.cs
EduSpider/Spiders/ClassInRule/CourseManager.cs
+107
-14
StudentManager.cs
EduSpider/Spiders/ClassInRule/StudentManager.cs
+60
-7
No files found.
EduSpider.IRepository/ICourseRepository.cs
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
System
;
using
EduSpider.Model.Query
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VTX.FW.Config
;
using
VTX.FW.DB
;
...
...
@@ -19,6 +16,23 @@ namespace EduSpider.Repository
/// </summary>
/// <param name="courses"></param>
/// <returns></returns>
public
bool
BatchSetCourse
(
List
<
RB_Course
>
courses
);
public
bool
BatchSetCourseRepository
(
List
<
RB_Course
>
courses
);
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePageRepository
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
);
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseListRepository
(
CourseQuery
query
);
}
}
EduSpider.IRepository/ICourseStudentRepository.cs
0 → 100644
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
System.Collections.Generic
;
using
VTX.FW.Config
;
using
VTX.FW.DB
;
namespace
EduSpider.Repository
{
/// <summary>
/// 课程学员关联仓储接口
/// </summary>
public
interface
ICourseStudentRepository
:
IDBRepository
<
RB_Course_Student
>,
IDependency
{
/// <summary>
/// 批量新增课程学员
/// </summary>
/// <param name="courses"></param>
/// <returns></returns>
public
bool
BatchSetCourseStudentRepository
(
List
<
RB_Course_Student
>
courses
);
}
}
EduSpider.IRepository/ICourseTeacherRepository.cs
0 → 100644
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
System.Collections.Generic
;
using
VTX.FW.Config
;
using
VTX.FW.DB
;
namespace
EduSpider.Repository
{
/// <summary>
/// 课程老师关联仓储接口
/// </summary>
public
interface
ICourseTeacherRepository
:
IDBRepository
<
RB_Course_Teacher
>,
IDependency
{
/// <summary>
/// 批量新增课程老师
/// </summary>
/// <param name="courses"></param>
/// <returns></returns>
public
bool
BatchSetCourseTeacherRepository
(
List
<
RB_Course_Teacher
>
courses
);
}
}
EduSpider.IRepository/IStudentRepository.cs
0 → 100644
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
System.Collections.Generic
;
using
VTX.FW.Config
;
using
VTX.FW.DB
;
namespace
EduSpider.IRepository
{
public
interface
IStudentRepository
:
IDBRepository
<
RB_Student
>,
IDependency
{
/// <summary>
/// 批量操作学生资料
/// </summary>
/// <param name="students"></param>
/// <returns></returns>
public
bool
BatchSetStudent
(
List
<
RB_Student
>
students
);
}
}
EduSpider.IServices/ICourseService.cs
View file @
2c01b41d
using
System
;
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -12,6 +14,21 @@ namespace EduSpider.IServices
/// </summary>
public
interface
ICourseService
:
IDependency
{
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePage
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
);
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseList
(
CourseQuery
query
);
}
}
EduSpider.Model/Entity/RB_Course_Student.cs
0 → 100644
View file @
2c01b41d
using
System
;
using
VTX.FW.Attr
;
namespace
EduSpider.Model.Entity
{
/// <summary>
/// 课程学员关联表实体类
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Course_Student
{
/// <summary>
/// 主键编号
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 学员编号
/// </summary>
public
int
uid
{
get
;
set
;
}
/// <summary>
/// 学员姓名
/// </summary>
public
string
name
{
get
;
set
;
}
/// <summary>
/// 学员账号
/// </summary>
public
string
account
{
get
;
set
;
}
/// <summary>
/// 学员头像
/// </summary>
public
string
logo
{
get
;
set
;
}
/// <summary>
/// 课程编号
/// </summary>
public
int
courseId
{
get
;
set
;
}
}
}
EduSpider.Model/Entity/RB_Course_Teacher.cs
0 → 100644
View file @
2c01b41d
using
System
;
using
VTX.FW.Attr
;
namespace
EduSpider.Model.Entity
{
/// <summary>
/// 课程实体类
/// </summary>
[
Serializable
]
[
DB
(
ConnectionName
=
"DefaultConnection"
)]
public
class
RB_Course_Teacher
{
/// <summary>
/// 主键编号
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 教师编号
/// </summary>
public
int
uid
{
get
;
set
;
}
/// <summary>
/// 电话
/// </summary>
public
string
phone
{
get
;
set
;
}
/// <summary>
/// 头像
/// </summary>
public
string
logo
{
get
;
set
;
}
/// <summary>
/// 姓名
/// </summary>
public
string
name
{
get
;
set
;
}
/// <summary>
/// 课程编号
/// </summary>
public
int
courseId
{
get
;
set
;
}
}
}
EduSpider.Model/Query/CourseQuery.cs
0 → 100644
View file @
2c01b41d
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
EduSpider.Model.Query
{
/// <summary>
/// 课程查询实体类
/// </summary>
public
class
CourseQuery
{
/// <summary>
/// 课程编号
/// </summary>
public
int
courseId
{
get
;
set
;
}
/// <summary>
/// 课程名称
/// </summary>
public
string
courseName
{
get
;
set
;
}
}
}
EduSpider.Repository/CourseRepository.cs
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
EduSpider.Repository.Base
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VTX.FW.DB.Dapper
;
namespace
EduSpider.Repository
{
...
...
@@ -18,11 +18,72 @@ namespace EduSpider.Repository
/// </summary>
/// <param name="courses"></param>
/// <returns></returns>
public
bool
BatchSetCourse
(
List
<
RB_Course
>
courses
)
public
bool
BatchSetCourse
Repository
(
List
<
RB_Course
>
courses
)
{
bool
flag
;
flag
=
base
.
BatchInsert
(
courses
,
isReplace
:
true
);
return
flag
;
}
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseListRepository
(
CourseQuery
query
)
{
var
parameters
=
new
DynamicParameters
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@"
SELECT A.*
FROM RB_Course AS A
WHERE 1=1
"
);
if
(
query
!=
null
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
query
.
courseName
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @courseName "
,
nameof
(
RB_Course
.
courseName
));
parameters
.
Add
(
"courseName"
,
"%"
+
query
.
courseName
.
Trim
()
+
"%"
);
}
if
(
query
.
courseId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Course
.
courseId
),
query
.
courseId
);
}
}
return
base
.
Get
<
RB_Course
>(
builder
.
ToString
(),
parameters
).
ToList
();
}
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePageRepository
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
)
{
var
parameters
=
new
DynamicParameters
();
StringBuilder
builder
=
new
StringBuilder
();
builder
.
AppendFormat
(
@"
SELECT A.*
FROM RB_Course AS A
WHERE 1=1
"
);
if
(
query
!=
null
)
{
if
(!
string
.
IsNullOrWhiteSpace
(
query
.
courseName
))
{
builder
.
AppendFormat
(
" AND A.{0} LIKE @courseName "
,
nameof
(
RB_Course
.
courseName
));
parameters
.
Add
(
"courseName"
,
"%"
+
query
.
courseName
.
Trim
()
+
"%"
);
}
if
(
query
.
courseId
>
0
)
{
builder
.
AppendFormat
(
" AND A.{0}={1} "
,
nameof
(
RB_Course
.
courseId
),
query
.
courseId
);
}
}
return
base
.
GetPage
<
RB_Course
>(
pageIndex
,
pageSize
,
out
rowsCount
,
builder
.
ToString
(),
parameters
).
ToList
();
}
}
}
EduSpider.Repository/CourseStudentRepository.cs
0 → 100644
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
EduSpider.Repository.Base
;
using
System.Collections.Generic
;
namespace
EduSpider.Repository
{
/// <summary>
/// 课程学员关联仓储层
/// </summary>
public
class
CourseStudentRepository
:
BaseRepository
<
RB_Course_Student
>,
ICourseStudentRepository
{
/// <summary>
/// 批量新增课程学员
/// </summary>
/// <param name="courses"></param>
/// <returns></returns>
public
bool
BatchSetCourseStudentRepository
(
List
<
RB_Course_Student
>
courses
)
{
bool
flag
;
flag
=
base
.
BatchInsert
(
courses
,
isReplace
:
true
);
return
flag
;
}
}
}
EduSpider.Repository/CourseTeacherRepository.cs
0 → 100644
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
EduSpider.Repository.Base
;
using
System.Collections.Generic
;
namespace
EduSpider.Repository
{
/// <summary>
/// 课程老师关联仓储层
/// </summary>
public
class
CourseTeacherRepository
:
BaseRepository
<
RB_Course_Teacher
>,
ICourseTeacherRepository
{
/// <summary>
/// 批量新增课程老师
/// </summary>
/// <param name="courses"></param>
/// <returns></returns>
public
bool
BatchSetCourseTeacherRepository
(
List
<
RB_Course_Teacher
>
courses
)
{
bool
flag
;
flag
=
base
.
BatchInsert
(
courses
,
isReplace
:
true
);
return
flag
;
}
}
}
EduSpider.Repository/StudentRepository.cs
View file @
2c01b41d
using
System
;
using
EduSpider.IRepository
;
using
EduSpider.Model.Entity
;
using
EduSpider.Repository.Base
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
EduSpider.Repository
{
public
class
StudentRepository
public
class
StudentRepository
:
BaseRepository
<
RB_Student
>,
IStudentRepository
{
public
bool
BatchSetStudent
(
List
<
RB_Student
>
students
)
{
bool
flag
;
flag
=
base
.
BatchInsert
(
students
,
isReplace
:
true
);
return
flag
;
}
}
}
EduSpider.Services/CourseService.cs
View file @
2c01b41d
using
EduSpider.IServices
;
using
EduSpider.Model.Entity
;
using
EduSpider.Model.Query
;
using
EduSpider.Repository
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VTX.FW.Attr
;
namespace
EduSpider.Services
{
...
...
@@ -13,6 +17,33 @@ namespace EduSpider.Services
/// </summary>
public
class
CourseService
:
ICourseService
{
/// <summary>
/// 课程仓储接口
/// </summary>
[
Autowired
]
public
ICourseRepository
CourseRepository
{
get
;
set
;
}
/// <summary>
/// 获取课程列表
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCourseList
(
CourseQuery
query
)
{
return
CourseRepository
.
GetCourseListRepository
(
query
);
}
/// <summary>
/// 获取课程分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="rowsCount"></param>
/// <param name="query"></param>
/// <returns></returns>
public
List
<
RB_Course
>
GetCoursePage
(
int
pageIndex
,
int
pageSize
,
out
long
rowsCount
,
CourseQuery
query
)
{
return
CourseRepository
.
GetCoursePageRepository
(
pageIndex
,
pageSize
,
out
rowsCount
,
query
);
}
}
}
EduSpider.Utility/JObjectHelper.cs
0 → 100644
View file @
2c01b41d
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
EduSpider.Utility
{
public
static
class
JObjectHelper
{
public
static
(
bool
flag
,
JObject
val
)
TryToJObject
(
this
string
str
)
{
try
{
return
(
true
,
JObject
.
Parse
(
str
));
}
catch
(
Exception
)
{
return
(
false
,
new
JObject
());
}
}
}
}
EduSpider.WebApi/Controllers/CourseController.cs
View file @
2c01b41d
...
...
@@ -13,6 +13,11 @@ namespace EduSpider.WebApi.Controllers
public
class
CourseController
:
BaseController
{
/// <summary>
/// 课程仓储接口
/// </summary>
[
Autowired
]
public
ICourseService
CourseService
{
get
;
set
;
}
/// <summary>
/// 获取课程列表
...
...
@@ -23,8 +28,8 @@ namespace EduSpider.WebApi.Controllers
public
ApiResult
GetCoursePage
()
{
return
ApiResult
.
Success
(
data
:
""
,
message
:
"成功!"
);
var
list
=
CourseService
.
GetCoursePage
(
1
,
1000
,
out
_
,
new
Model
.
Query
.
CourseQuery
());
return
ApiResult
.
Success
(
data
:
list
,
message
:
"成功!"
);
}
}
}
EduSpider.WebApi/EduSpider.WebApi.csproj
View file @
2c01b41d
...
...
@@ -15,7 +15,8 @@
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugarCore" Version="5.0.8.3" />
<PackageReference Include="StackExchange.Redis" Version="2.0.601" />
<PackageReference Include="VTX.FW" Version="1.1.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.3" />
<PackageReference Include="VTX.FW" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
...
...
EduSpider.WebApi/appsettings.json
View file @
2c01b41d
...
...
@@ -23,7 +23,7 @@
],
//ַ
"ConnectionStrings"
:
{
"DefaultConnection"
:
"server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_
user
;CharSet=utf8mb4; Convert Zero Datetime=true; "
,
"DefaultConnection"
:
"server=192.168.10.214;user id=reborn;password=Reborn@2018;database=reborn_
think
;CharSet=utf8mb4; Convert Zero Datetime=true; "
,
"DefaultConnectionPName"
:
"MySql.Data.MySqlClient"
}
}
EduSpider.sln
View file @
2c01b41d
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 1
6
VisualStudioVersion = 1
6.0.31729.503
# Visual Studio Version 1
7
VisualStudioVersion = 1
7.1.32210.238
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EduSpider.Model", "EduSpider.Model\EduSpider.Model.csproj", "{58B2199B-FE72-4F48-972D-F7FE32A28A0F}"
EndProject
...
...
EduSpider/EduSpider.csproj
View file @
2c01b41d
...
...
@@ -17,10 +17,14 @@
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="zh_CN.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Spiders\EasterLineRule\AccountManagerHelper.cs" />
<Content Include="Spiders\EasterLineRule\CookiesHelper.cs" />
<Content Include="Spiders\EasterLineRule\PassengerHelper.cs" />
...
...
EduSpider/Spiders/ClassInRule/ClassInAccountManager.cs
View file @
2c01b41d
...
...
@@ -24,7 +24,7 @@ namespace TicketSpider.Spiders.ClassInRule
private
static
object
lockerSafe
=
new
object
();
private
static
string
_loginCookies
=
"locationArgumentLang=zh-CN; sensorsdata2015jssdkcross={\"distinct_id\":\"12780052\",\"first_id\":\"180e074a47f92f-06489d0bb8915b-6b3e555b-1327104-180e074a4805d2\",\"props\":{\"$latest_traffic_source_type\":\"直接流量\",\"$latest_search_keyword\":\"未取到值_直接打开\",\"$latest_referrer\":\"\"},\"$device_id\":\"180e074a47f92f-06489d0bb8915b-6b3e555b-1327104-180e074a4805d2\"}; _eeos_uid=12780052; _eeos_useraccount=18140082327; _eeos_userlogo=/upload/images/20200126/709df9532bee722f2268_70.jpg; _eeos_domain=.eeo.cn; _eeos_sid=12780052; _eeos_nsid=kspGu2gfMu+U2EFgLpSGyg==; __tk_id=5792ca4f7a6655c40c4431fbdb729da4; PHPSESSID=l5aanmebp5lvpcbg630ccfha37; _eeos_traffic=EqlIOFq4S2hz5FTTtHzNUViBYcWCixrJYMCF6Y5yJuD8eq8ZwPvVSHMvUkLFA5lzNoaTrDBpGhEY7ykZ9lwMAsNJoNiDt2xKQBr9csRmiBE="
;
private
static
string
_loginCookies
=
null
;
//
"locationArgumentLang=zh-CN; sensorsdata2015jssdkcross={\"distinct_id\":\"12780052\",\"first_id\":\"180e074a47f92f-06489d0bb8915b-6b3e555b-1327104-180e074a4805d2\",\"props\":{\"$latest_traffic_source_type\":\"直接流量\",\"$latest_search_keyword\":\"未取到值_直接打开\",\"$latest_referrer\":\"\"},\"$device_id\":\"180e074a47f92f-06489d0bb8915b-6b3e555b-1327104-180e074a4805d2\"}; _eeos_uid=12780052; _eeos_useraccount=18140082327; _eeos_userlogo=/upload/images/20200126/709df9532bee722f2268_70.jpg; _eeos_domain=.eeo.cn; _eeos_sid=12780052; _eeos_nsid=kspGu2gfMu+U2EFgLpSGyg==; __tk_id=5792ca4f7a6655c40c4431fbdb729da4; PHPSESSID=l5aanmebp5lvpcbg630ccfha37; _eeos_traffic=EqlIOFq4S2hz5FTTtHzNUViBYcWCixrJYMCF6Y5yJuD8eq8ZwPvVSHMvUkLFA5lzNoaTrDBpGhEY7ykZ9lwMAsNJoNiDt2xKQBr9csRmiBE=";
private
static
bool
_openHeartTimer
=
false
;
...
...
EduSpider/Spiders/ClassInRule/ClassInFlow.cs
View file @
2c01b41d
...
...
@@ -23,10 +23,10 @@ namespace TicketSpider.Spiders.ClassInRule
loginCookies
=
"_eeos_uid=12780052; _eeos_useraccount=18140082327; _eeos_userlogo=%2Fupload%2Fimages%2F20200126%2F709df9532bee722f2268_70.jpg; _eeos_domain=.eeo.cn; _eeos_remember=1; _eeos_sid=12780052; _eeos_nsid=kspGu2gfMu%2BU2EFgLpSGyg%3D%3D; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2212780052%22%2C%22first_id%22%3A%22180f59907abbed-081e4952c5b26f-12333272-2073600-180f59907acbc8%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%9B%B4%E6%8E%A5%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC_%E7%9B%B4%E6%8E%A5%E6%89%93%E5%BC%80%22%2C%22%24latest_referrer%22%3A%22%22%7D%2C%22%24device_id%22%3A%22180f59907abbed-081e4952c5b26f-12333272-2073600-180f59907acbc8%22%7D; _eeos_traffic=EqlIOFq4S2hz5FTTtHzNUViBYcWCixrJYMCF6Y5yJuD8eq8ZwPvVSHMvUkLFA5lzNoaTrDBpGhFOuRmo3R6CQ5GeSsJx1IEakyt2K%2B3ifco%3D; PHPSESSID=3etqs18ka2s425omq6uqsus8s2; __tk_id=7a20b97a04709afc3137ec211e756d5f"
;
Console
.
WriteLine
(
"开始获取
老师
信息"
);
Console
.
WriteLine
(
"开始获取
学员
信息"
);
//new StudentManager().RunAsync(loginCookies);
//new Student
Manager().RunCourse(loginCookies);
new
TeacherManager
().
RunTeacher
(
loginCookies
);
new
Course
Manager
().
RunCourse
(
loginCookies
);
}
}
}
EduSpider/Spiders/ClassInRule/CourseManager.cs
View file @
2c01b41d
...
...
@@ -7,6 +7,7 @@ using System.Collections.Generic;
using
System.Linq
;
using
System.Net.Http
;
using
System.Text
;
using
System.Threading
;
using
VTX.FW.Helper
;
namespace
EduSpider.Spiders.ClassInRule
...
...
@@ -22,13 +23,16 @@ namespace EduSpider.Spiders.ClassInRule
public
async
void
RunCourse
(
string
cookie
)
{
int
perpage
=
20
;
var
pageCount
=
1
;
var
request
=
Utility
.
HttpHelper
.
GenerateHttp
(
cookie
);
string
paramStr
=
string
.
Format
(
"page={0}&perpage={1}&courseState=1"
,
"1"
,
perpage
);
string
queryStr
=
"page={0}&perpage={1}"
;
string
paramStr
=
string
.
Format
(
queryStr
,
pageCount
,
perpage
);
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
ICourseRepository
courseRepository
=
new
CourseRepository
();
int
totalCount
=
0
;
Console
.
WriteLine
(
string
.
Format
(
"开始第{0}次获取课程数据"
,
pageCount
));
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/course.ajax.php?action=getCourseList"
,
content
);
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
List
<
RB_Course
>
list
=
new
();
if
(!
string
.
IsNullOrWhiteSpace
(
result
))
{
JObject
rootObj
=
JObject
.
Parse
(
result
);
...
...
@@ -36,37 +40,81 @@ namespace EduSpider.Spiders.ClassInRule
{
JObject
dataObj
=
JObject
.
Parse
(
rootObj
.
GetString
(
"data"
));
var
totalNum
=
dataObj
.
GetInt
(
"totalCourseNum"
);
var
pageCount
=
1
;
var
tempList
=
ParseJson
(
dataObj
.
GetString
(
"courseList"
));
if
(
tempList
!=
null
&&
tempList
.
Count
>
0
)
{
courseRepository
.
BatchSetCourseRepository
(
tempList
);
totalCount
+=
tempList
.
Count
();
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
pageCount
,
totalCount
));
foreach
(
var
item
in
tempList
)
{
RunCourseStudent
(
cookie
,
item
.
courseId
);
}
}
if
(
totalNum
%
perpage
==
0
)
{
pageCount
=
totalNum
%
perpage
;
pageCount
=
totalNum
/
perpage
;
}
else
{
pageCount
=
totalNum
%
perpage
+
1
;
pageCount
=
totalNum
/
perpage
+
1
;
}
if
(
totalNum
>
perpage
)
{
for
(
var
i
=
2
;
i
<=
pageCount
;
i
++)
{
Thread
.
Sleep
(
1000
*
2
);
Console
.
WriteLine
(
string
.
Format
(
"第{0}/{1}次获取课程数据"
,
i
,
pageCount
));
paramStr
=
string
.
Format
(
queryStr
,
i
,
perpage
);
var
sub_content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
var
sub_response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/course.ajax.php?action=getCourseList"
,
sub_content
);
var
sub_result
=
sub_response
.
Content
.
ReadAsStringAsync
().
Result
;
if
(!
string
.
IsNullOrWhiteSpace
(
sub_result
))
{
JObject
sub_rootObj
=
JObject
.
Parse
(
sub_result
);
if
(!
string
.
IsNullOrWhiteSpace
(
sub_rootObj
.
GetString
(
"data"
)))
{
JObject
sub_dataObj
=
JObject
.
Parse
(
sub_rootObj
.
GetString
(
"data"
));
var
subtempList
=
ParseJson
(
sub_dataObj
.
GetString
(
"courseList"
));
if
(
subtempList
!=
null
&&
subtempList
.
Count
>
0
)
{
courseRepository
.
BatchSetCourseRepository
(
subtempList
);
totalCount
+=
subtempList
.
Count
();
Console
.
WriteLine
(
string
.
Format
(
"第{0}次,导入完成{1}条."
,
i
,
totalCount
));
foreach
(
var
sItem
in
subtempList
)
{
RunCourseStudent
(
cookie
,
sItem
.
courseId
);
}
}
}
}
}
}
}
}
ICourseRepository
courseRepository
=
new
CourseRepository
();
courseRepository
.
BatchSetCourse
(
list
);
Console
.
WriteLine
(
"result"
,
result
);
}
/// <summary>
/// JSON字符串转课程列表
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public
List
<
RB_Course
>
ParseJson
(
string
data
)
{
//dataObj.GetString("courseList")
List
<
RB_Course
>
list
=
new
List
<
RB_Course
>();
JArray
courseArray
=
JArray
.
Parse
(
data
);
JArray
courseArray
=
JArray
.
Parse
(
data
);
if
(
courseArray
!=
null
&&
courseArray
.
Count
>
0
)
{
foreach
(
var
jItem
in
courseArray
)
{
JObject
courseObj
=
JObject
.
Parse
(
jItem
.
ToString
());
var
expiryTime
=
ConvertHelper
.
UnixToDateTime
(
courseObj
.
GetInt
(
"expiryTime"
));
if
(
ConvertHelper
.
FormatTime
(
expiryTime
)
==
"1970-01-01 08:00:00"
)
{
expiryTime
=
new
DateTime
(
0001
,
01
,
01
);
}
list
.
Add
(
new
RB_Course
()
{
courseId
=
courseObj
.
GetInt
(
"courseId"
),
...
...
@@ -74,7 +122,7 @@ namespace EduSpider.Spiders.ClassInRule
beginTime
=
ConvertHelper
.
UnixToDateTime
(
courseObj
.
GetInt
(
"beginTime"
)),
completeNum
=
courseObj
.
GetInt
(
"completeNum"
),
totalClassNum
=
courseObj
.
GetInt
(
"totalClassNum"
),
expiryTime
=
ConvertHelper
.
UnixToDateTime
(
courseObj
.
GetInt
(
"expiryTime"
))
,
expiryTime
=
expiryTime
,
liveNum
=
courseObj
.
GetInt
(
"liveNum"
),
recordNum
=
courseObj
.
GetInt
(
"recordNum"
),
openNum
=
courseObj
.
GetInt
(
"openNum"
),
...
...
@@ -92,8 +140,53 @@ namespace EduSpider.Spiders.ClassInRule
});
;
}
}
return
list
;
}
/// <summary>
/// 获取课程学员列表
/// </summary>
public
async
void
RunCourseStudent
(
string
cookie
,
int
courseId
)
{
var
request
=
Utility
.
HttpHelper
.
GenerateHttp
(
cookie
);
string
queryStr
=
"courseId={0}"
;
string
paramStr
=
string
.
Format
(
queryStr
,
courseId
);
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
ICourseStudentRepository
courseStudentRepository
=
new
CourseStudentRepository
();
Console
.
WriteLine
(
string
.
Format
(
"开始获取{0}课程学员数据"
,
courseId
));
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/student.ajax.php?action=getCourseStudentList"
,
content
);
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
List
<
RB_Course_Student
>
list
=
new
List
<
RB_Course_Student
>();
if
(!
string
.
IsNullOrWhiteSpace
(
result
))
{
JObject
rootObj
=
JObject
.
Parse
(
result
);
if
(!
string
.
IsNullOrWhiteSpace
(
rootObj
.
GetString
(
"data"
)))
{
JArray
courseStudentArray
=
JArray
.
Parse
(
rootObj
.
GetString
(
"data"
));
if
(
courseStudentArray
!=
null
&&
courseStudentArray
.
Count
>
0
)
{
foreach
(
var
jItem
in
courseStudentArray
)
{
JObject
courseStuObj
=
JObject
.
Parse
(
jItem
.
ToString
());
list
.
Add
(
new
RB_Course_Student
()
{
id
=
courseStuObj
.
GetInt
(
"id"
),
uid
=
courseStuObj
.
GetInt
(
"uid"
),
name
=
courseStuObj
.
GetString
(
"name"
),
account
=
courseStuObj
.
GetString
(
"account"
),
logo
=
courseStuObj
.
GetString
(
"logo"
),
courseId
=
courseId
});
}
}
}
}
if
(
list
!=
null
&&
list
.
Count
>
0
)
{
courseStudentRepository
.
BatchSetCourseStudentRepository
(
list
);
}
}
}
}
EduSpider/Spiders/ClassInRule/StudentManager.cs
View file @
2c01b41d
using
EduSpider.Model.Entity
;
using
EduSpider.IRepository
;
using
EduSpider.Model.Entity
;
using
EduSpider.Repository
;
using
EduSpider.Utility.Enum
;
using
EduSpider.Utility
;
using
Newtonsoft.Json
;
using
Newtonsoft.Json.Linq
;
using
System
;
using
System.Collections.Generic
;
...
...
@@ -12,18 +14,69 @@ namespace EduSpider.Spiders.ClassInRule
{
public
class
StudentManager
{
private
static
readonly
IStudentRepository
courseRepository
=
new
StudentRepository
();
public
async
void
RunAsync
(
string
cookie
)
{
var
request
=
Utility
.
HttpHelper
.
GenerateHttp
(
cookie
);
var
paramStr
=
"page=1&perpage=20&isdel=0"
;
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/student.ajax.php?action=getSchoolStudentListByPage"
,
content
);
int
pageIndex
=
1
,
pageCount
=
1
,
pageSize
=
500
;
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
}
while
(
pageIndex
<=
pageCount
)
{
Console
.
WriteLine
(
$"正在查询第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
var
paramStr
=
$"page=
{
pageIndex
}
&perpage=
{
pageSize
}
&isdel=0"
;
var
content
=
new
StringContent
(
paramStr
,
System
.
Text
.
Encoding
.
UTF8
,
"application/x-www-form-urlencoded"
);
var
response
=
await
request
.
PostAsync
(
"https://console.eeo.cn/saasajax/student.ajax.php?action=getSchoolStudentListByPage"
,
content
);
var
resultStr
=
response
.
Content
.
ReadAsStringAsync
().
Result
??
string
.
Empty
;
var
result
=
resultStr
.
TryToJObject
();
if
(
result
.
flag
)
{
var
data
=
(
result
.
val
.
ContainsKey
(
"data"
)
?
result
.
val
[
"data"
]
:
new
JObject
())
as
JObject
;
if
(
data
.
ContainsKey
(
"totalStudentNum"
))
{
#
region
更新
PageCount
if
(
pageIndex
==
1
)
{
pageCount
=
(
int
)
Math
.
Ceiling
(
data
.
GetDecimal
(
"totalStudentNum"
)
/
pageSize
);
}
#
endregion
#
region
组装实体
var
stus
=
new
List
<
RB_Student
>();
var
stuArray
=
(
data
[
"studentList"
]
as
JArray
);
foreach
(
JObject
x
in
stuArray
)
{
stus
.
Add
(
new
RB_Student
()
{
AddTime
=
ConvertHelper
.
UnixToDateTime
(
x
.
GetString
(
"addTime"
)),
StudentAccount
=
x
.
GetString
(
"studentAccount"
),
Isdel
=
x
.
GetInt
(
"isdel"
,
0
),
IsGroup
=
x
.
GetInt
(
"isGroup"
,
0
),
StudId
=
x
.
GetInt
(
"studId"
,
0
),
Progress
=
x
.
GetString
(
"progress"
),
PublicResourceStatus
=
x
.
GetInt
(
"publicResourceStatus"
,
0
),
ServeState
=
x
.
GetInt
(
"serveState"
,
0
),
StudentName
=
x
.
GetString
(
"studentName"
),
StudentUid
=
x
.
GetInt
(
"studentUid"
,
0
),
Stuno
=
x
.
GetString
(
"stuno"
),
});
}
courseRepository
.
BatchSetStudent
(
stus
);
Console
.
WriteLine
(
$"已导入第
{
pageIndex
}
-
{
pageSize
}
页学员信息"
);
#
endregion
}
}
pageIndex
++;
}
Console
.
WriteLine
(
"学员同步完成"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment