Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Education
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
黄奎
Education
Commits
8143c125
Commit
8143c125
authored
Feb 23, 2022
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
870c9819
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
112 additions
and
5 deletions
+112
-5
FileHelper.cs
Edu.Common/Plugin/FileHelper.cs
+79
-5
CourseModule.cs
Edu.Module.Course/CourseModule.cs
+24
-0
Program.cs
Edu.Test/Program.cs
+8
-0
LoginController.cs
Edu.WebApi/Controllers/User/LoginController.cs
+1
-0
No files found.
Edu.Common/Plugin/FileHelper.cs
View file @
8143c125
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.IO
;
using
System.Text
;
using
System.Text.RegularExpressions
;
namespace
Edu.Common.Plugin
{
...
...
@@ -16,16 +17,89 @@ namespace Edu.Common.Plugin
/// <param name="path"></param>
/// <param name="serverPath"></param>
/// <returns></returns>
public
static
List
<
FileItem
>
GetFileAllPath
(
string
path
,
string
savePath
)
public
static
List
<
FileItem
>
GetFileAllPath
(
string
path
,
string
savePath
)
{
List
<
FileItem
>
fileList
=
new
List
<
FileItem
>();
DirectoryInfo
rootFolder
=
new
DirectoryInfo
(
path
);
if
(
rootFolder
!=
null
)
{
int
leval
=
0
;
GetDirectoryAndFile
(
path
,
leval
,
fileList
);
foreach
(
var
item
in
fileList
)
{
string
str
=
@"录音 [0123456789]*"
;
Regex
reg
=
new
Regex
(
str
);
var
fileNameArray
=
Regex
.
Split
(
item
.
FileName
,
str
);
string
newFileName
=
item
.
FileName
;
if
(
fileNameArray
!=
null
&&
fileNameArray
.
Length
>
0
)
{
newFileName
=
fileNameArray
.
Length
>
1
?
fileNameArray
[
1
]
:
fileNameArray
[
0
];
}
string
newPathFileName
=
savePath
+
@"\"
+
newFileName
.
TrimStart
().
TrimEnd
();
File
.
Copy
(
item
.
FileUrl
,
newPathFileName
,
true
);
item
.
FileUrl
=
newPathFileName
;
}
return
fileList
;
}
/// <summary>
/// 获取所有文件
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public
static
List
<
FileItem
>
GetFileList
(
string
path
)
{
List
<
FileItem
>
fileList
=
new
List
<
FileItem
>();
DirectoryInfo
theFolder
=
new
DirectoryInfo
(
@path
);
//遍历文件
foreach
(
FileInfo
NextFile
in
theFolder
.
GetFiles
())
{
string
extName
=
Path
.
GetExtension
(
NextFile
.
Name
).
ToLower
();
if
(
extName
==
".mp3"
)
{
fileList
.
Add
(
new
FileItem
()
{
FileName
=
NextFile
.
Name
,
FileUrl
=
NextFile
.
FullName
});
}
}
return
fileList
;
}
/// <summary>
/// 列出path路径对应的文件夹中的子文件夹和文件
/// 然后再递归列出子文件夹内的文件和文件夹
/// </summary>
/// <param name="path">需要列出内容的文件夹的路径</param>
/// <param name="leval">当前递归层级,用于控制输出前导空格的数量</param>
private
static
void
GetDirectoryAndFile
(
string
path
,
int
leval
,
List
<
FileItem
>
list
)
{
DirectoryInfo
theFolder
=
new
DirectoryInfo
(
@path
);
leval
++;
//遍历文件
foreach
(
FileInfo
NextFile
in
theFolder
.
GetFiles
())
{
for
(
int
i
=
0
;
i
<
leval
;
i
++)
{
string
extName
=
Path
.
GetExtension
(
NextFile
.
Name
).
ToLower
();
if
(
extName
==
".mp3"
)
{
list
.
Add
(
new
FileItem
()
{
FileName
=
NextFile
.
Name
,
FileUrl
=
NextFile
.
FullName
});
}
}
}
//遍历文件夹
foreach
(
DirectoryInfo
NextFolder
in
theFolder
.
GetDirectories
())
{
for
(
int
i
=
0
;
i
<
leval
;
i
++)
{
GetDirectoryAndFile
(
NextFolder
.
FullName
,
leval
,
list
);
}
}
}
}
/// <summary>
...
...
Edu.Module.Course/CourseModule.cs
View file @
8143c125
...
...
@@ -1198,6 +1198,30 @@ namespace Edu.Module.Course
}
}
/// <summary>
/// 重新更新课程单词URL
/// </summary>
public
void
RunWordsUrlModule
()
{
var
list
=
course_WordsRepository
.
GetCourseWordsListRepository
(
new
RB_Course_Words_Extend
()
{});
string
newPath
=
@"G:\NewWords"
;
var
fileList
=
Common
.
Plugin
.
FileHelper
.
GetFileList
(
newPath
);
if
(
list
!=
null
&&
list
.
Count
>
0
&&
fileList
!=
null
&&
fileList
.
Count
>
0
)
{
Dictionary
<
string
,
object
>
fileds
=
new
Dictionary
<
string
,
object
>();
foreach
(
var
item
in
list
)
{
var
tempWords
=
fileList
.
Where
(
qitem
=>
qitem
.
FileName
==
item
.
WordContent
+
".mp3"
)?.
FirstOrDefault
();
if
(
tempWords
!=
null
)
{
fileds
.
Clear
();
fileds
.
Add
(
nameof
(
RB_Course_Words_Extend
.
FileUrl
),
tempWords
.
FileUrl
);
bool
flag
=
course_WordsRepository
.
Update
(
fileds
,
new
WhereHelper
(
nameof
(
RB_Course_Words_Extend
.
Id
),
item
.
Id
));
}
}
}
}
/// <summary>
/// 获取课程章节列表
/// </summary>
...
...
Edu.Test/Program.cs
View file @
8143c125
using
Edu.Repository.Course
;
using
System
;
namespace
Edu.Test
...
...
@@ -11,6 +12,13 @@ namespace Edu.Test
//filePath = @"C:/Users/qiaoyajun/Desktop/EduWordTemplate.doc";
//filePath = @"C:/Users/qiaoyajun/Desktop/EduWordTemplate.doc";
//var data = Common.Data.QuestionHelper.GetWordQuestionData(filePath);
//string newPath = @"G:\NewWords";
//string filePath = @"G:\Words";
//var list = Common.Plugin.FileHelper.GetFileAllPath(filePath, newPath);
//string str = Common.Plugin.JsonHelper.Serialize(list);
// Console.WriteLine(str);
Console
.
ReadKey
();
}
}
}
Edu.WebApi/Controllers/User/LoginController.cs
View file @
8143c125
...
...
@@ -63,6 +63,7 @@ namespace Edu.WebApi.Controllers.User
[
AllowAnonymous
]
public
ApiResult
Test
()
{
courseModule
.
RunWordsUrlModule
();
return
ApiResult
.
Success
();
}
...
...
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