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
e2d7a01f
Commit
e2d7a01f
authored
Jan 11, 2023
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
下载修改
parent
55717a45
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
21 deletions
+36
-21
QuestionController.cs
Edu.WebApi/Controllers/Course/QuestionController.cs
+36
-21
No files found.
Edu.WebApi/Controllers/Course/QuestionController.cs
View file @
e2d7a01f
...
@@ -16,6 +16,7 @@ using System.IO;
...
@@ -16,6 +16,7 @@ using System.IO;
using
System.Linq
;
using
System.Linq
;
using
System.Net
;
using
System.Net
;
using
System.Text.RegularExpressions
;
using
System.Text.RegularExpressions
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
namespace
Edu.WebApi.Controllers.Course
namespace
Edu.WebApi.Controllers.Course
...
@@ -1371,21 +1372,20 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -1371,21 +1372,20 @@ namespace Edu.WebApi.Controllers.Course
foreach
(
Match
subItem
in
iframe_matchs
)
foreach
(
Match
subItem
in
iframe_matchs
)
{
{
string
newUrl
=
""
;
string
newUrl
=
""
;
var
tempArray
=
subItem
.
Value
.
Split
(
new
char
[]
{
' '
,
' '
});
if
(
subItem
.
Value
.
Contains
(
"src"
))
foreach
(
var
tItem
in
tempArray
)
{
{
if
(
tItem
.
IndexOf
(
"src"
)
!=
-
1
)
var
srcArray
=
subItem
.
Value
.
Split
(
new
string
[]
{
"url="
},
StringSplitOptions
.
None
);
if
(
srcArray
!=
null
&&
srcArray
.
Length
>
0
&&
srcArray
.
Length
==
2
)
{
{
var
imageArray
=
tItem
.
Split
(
new
string
[]
{
"url=
"
},
StringSplitOptions
.
None
);
var
sourceArray
=
srcArray
[
1
].
Split
(
new
string
[]
{
".mp3
"
},
StringSplitOptions
.
None
);
if
(
imageArray
!=
null
&&
imageArray
.
Length
>
0
&&
imageArray
.
Length
==
2
)
if
(
sourceArray
!=
null
&&
sourceArray
.
Length
>
0
)
{
{
string
tempUrl
=
imageArray
[
1
].
Substring
(
0
,
imageArray
[
1
].
Length
-
1
)
;
var
tempUrl
=
sourceArray
[
0
]
+
".mp3"
;
newUrl
=
System
.
Web
.
HttpUtility
.
UrlDecode
(
tempUrl
);
newUrl
=
System
.
Web
.
HttpUtility
.
UrlDecode
(
tempUrl
);
}
}
}
}
}
}
string
key
=
"[音频"
+
index
+
"]"
;
string
key
=
"[音频"
+
index
+
"]"
;
fileList
.
Add
(
new
FileItem
()
fileList
.
Add
(
new
FileItem
()
{
{
FileName
=
key
,
FileName
=
key
,
...
@@ -1412,17 +1412,17 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -1412,17 +1412,17 @@ namespace Edu.WebApi.Controllers.Course
MatchCollection
iframe_matchs
=
Regex
.
Matches
(
newSubTitle
,
iframeRule
);
MatchCollection
iframe_matchs
=
Regex
.
Matches
(
newSubTitle
,
iframeRule
);
foreach
(
Match
iframeItem
in
iframe_matchs
)
foreach
(
Match
iframeItem
in
iframe_matchs
)
{
{
string
newUrl
=
""
;
string
newUrl1
=
""
;
var
tempArray
=
iframeItem
.
Value
.
Split
(
new
char
[]
{
' '
,
' '
});
if
(
iframeItem
.
Value
.
Contains
(
"src"
))
foreach
(
var
tItem
in
tempArray
)
{
{
if
(
tItem
.
IndexOf
(
"src"
)
!=
-
1
)
var
srcArray1
=
iframeItem
.
Value
.
Split
(
new
string
[]
{
"url="
},
StringSplitOptions
.
None
);
if
(
srcArray1
!=
null
&&
srcArray1
.
Length
>
0
&&
srcArray1
.
Length
==
2
)
{
{
var
imageArray
=
tItem
.
Split
(
new
string
[]
{
"url=
"
},
StringSplitOptions
.
None
);
var
sourceArray1
=
srcArray1
[
1
].
Split
(
new
string
[]
{
".mp3
"
},
StringSplitOptions
.
None
);
if
(
imageArray
!=
null
&&
imageArray
.
Length
>
0
&&
imageArray
.
Length
==
2
)
if
(
sourceArray1
!=
null
&&
sourceArray1
.
Length
>
0
)
{
{
string
tempUrl
=
imageArray
[
1
].
Substring
(
0
,
imageArray
[
1
].
Length
-
1
)
;
var
tempUrl
=
sourceArray1
[
0
]
+
".mp3"
;
newUrl
=
System
.
Web
.
HttpUtility
.
UrlDecode
(
tempUrl
);
newUrl
1
=
System
.
Web
.
HttpUtility
.
UrlDecode
(
tempUrl
);
}
}
}
}
}
}
...
@@ -1431,7 +1431,7 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -1431,7 +1431,7 @@ namespace Edu.WebApi.Controllers.Course
fileList
.
Add
(
new
FileItem
()
fileList
.
Add
(
new
FileItem
()
{
{
FileName
=
key
,
FileName
=
key
,
FileUrl
=
newUrl
,
FileUrl
=
newUrl
1
,
});
});
index
++;
index
++;
}
}
...
@@ -1448,15 +1448,23 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -1448,15 +1448,23 @@ namespace Edu.WebApi.Controllers.Course
}
}
var
wordFile
=
Common
.
Plugin
.
WordTemplateHelper
.
UrlToWordFile
(
url
,
path_server
,
savePath
,
fileName
);
var
wordFile
=
Common
.
Plugin
.
WordTemplateHelper
.
UrlToWordFile
(
url
,
path_server
,
savePath
,
fileName
);
foreach
(
var
item
in
fileList
)
var
tasks
=
new
List
<
Task
>();
for
(
int
index
=
0
;
index
<
fileList
.
Count
;
index
++)
{
{
if
(!
string
.
IsNullOrEmpty
(
item
.
FileUrl
))
if
(!
string
.
IsNullOrEmpty
(
fileList
[
index
]
.
FileUrl
))
{
{
WebClient
mywebclient
=
new
WebClient
();
tasks
.
Add
(
Task
.
Factory
.
StartNew
(
o
=>
mywebclient
.
DownloadFile
(
item
.
FileUrl
,
savePath
+
item
.
FileName
+
".mp3"
);
{
mywebclient
.
Dispose
();
int
value
=
(
int
)
o
;
DownLoadFile
(
fileList
[
value
],
savePath
);
},
index
));
Thread
.
Sleep
(
500
);
}
}
}
}
if
(
tasks
!=
null
&&
tasks
.
Count
>
0
)
{
Task
.
WaitAll
(
tasks
.
ToArray
());
}
Common
.
Plugin
.
ZipHelper
.
Zip
(
savePath
,
savePath2
+
zipFileName
,
ref
messageTip
);
Common
.
Plugin
.
ZipHelper
.
Zip
(
savePath
,
savePath2
+
zipFileName
,
ref
messageTip
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
@@ -1465,5 +1473,12 @@ namespace Edu.WebApi.Controllers.Course
...
@@ -1465,5 +1473,12 @@ namespace Edu.WebApi.Controllers.Course
}
}
return
ApiResult
.
Success
(
data
:
fileUrl
);
return
ApiResult
.
Success
(
data
:
fileUrl
);
}
}
private
void
DownLoadFile
(
FileItem
item
,
string
savePath
)
{
WebClient
mywebclient
=
new
WebClient
();
mywebclient
.
DownloadFile
(
item
.
FileUrl
,
savePath
+
item
.
FileName
+
".mp3"
);
mywebclient
.
Dispose
();
}
}
}
}
}
\ No newline at end of file
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