Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.TVP
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘龙飞
VIZ.TVP
Commits
511807e7
Commit
511807e7
authored
Jan 05, 2023
by
wangonghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
媒体资源库测试修改bug
parent
9527fa3e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
264 additions
and
122 deletions
+264
-122
VIZ.TVP.Module/Resource/LocalResource/Controller/LocalResourceFile/ThumbnailHelper.cs
+11
-0
VIZ.TVP.Module/Resource/MediaResource/Controller/MediaResourceFile/MediaResourceFileController.cs
+44
-17
VIZ.TVP.Module/Resource/MediaResource/Controller/MediaResourceFile/MediaResourceFileService.cs
+46
-51
VIZ.TVP.Module/Resource/MediaResource/Controller/Model/fileListResult.cs
+13
-0
VIZ.TVP.Module/Resource/MediaResource/Controller/Model/fileUploadResult.cs
+3
-0
VIZ.TVP.Module/Resource/MediaResource/Controller/Model/ms.cs
+12
-0
VIZ.TVP.Module/Resource/MediaResource/ViewModel/CreateFolderViewModel.cs
+6
-1
VIZ.TVP.Module/Resource/MediaResource/ViewModel/MediaResourceViewModel.cs
+129
-53
No files found.
VIZ.TVP.Module/Resource/LocalResource/Controller/LocalResourceFile/ThumbnailHelper.cs
View file @
511807e7
...
...
@@ -80,6 +80,11 @@ namespace VIZ.TVP.Module
}
}
/// <summary>
/// 根据名称判断是否为图片
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public
static
Boolean
IsImageByName
(
string
name
)
{
try
...
...
@@ -102,6 +107,12 @@ namespace VIZ.TVP.Module
}
/// <summary>
/// 不区分大小写进行判断
/// </summary>
/// <param name="source"></param>
/// <param name="list"></param>
/// <returns></returns>
private
static
bool
IsInIgnoreCase
(
string
source
,
params
string
[]
list
)
{
if
(
null
==
source
)
return
false
;
...
...
VIZ.TVP.Module/Resource/MediaResource/Controller/MediaResourceFile/MediaResourceFileController.cs
View file @
511807e7
...
...
@@ -48,6 +48,10 @@ namespace VIZ.TVP.Module
/// <summary>
/// 根目录
/// </summary>
public
string
RootPath
{
get
;
set
;
}
/// <summary>
/// 更新文件模型
/// </summary>
/// <param name="folder">文件夹</param>
...
...
@@ -84,7 +88,6 @@ namespace VIZ.TVP.Module
MHResourceFileModel
GHFile
=
new
MHResourceFileModel
();
if
(
ThumbnailHelper
.
IsImageByName
(
file
.
fileName
))
{
//GetFile
GHFile
.
Name
=
file
.
fileName
;
GHFile
.
Path
=
file
.
smallIconUrl
;
string
url
=
string
.
Format
(
"{0}GetFile?filePath={1}"
,
httpUrl
,
GHFile
.
Path
);
...
...
@@ -125,22 +128,27 @@ namespace VIZ.TVP.Module
});
}
//string oldFile, string newFile
public
async
void
MoveFile
(
string
oldPath
,
string
newPath
)
/// <summary>
/// 移动文件
/// </summary>
/// <param name="oldPath"></param>
/// <param name="newPath"></param>
public
async
Task
<
fileListResult
>
MoveFile
(
string
oldPath
,
string
newPath
)
{
string
header
=
string
.
Format
(
"{0}MoveFile?oldFile={1}&newFile={2}"
,
httpUrl
,
oldPath
,
newPath
);
var
errorMessage
=
await
MediaResourceFileService
.
PostAsyncJson
(
header
,
""
);
var
result
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
return
result
;
}
/// <summary>
/// 添加文件夹
/// </summary>
/// <param name="path"></param>
public
async
void
CreateFolder
(
string
path
)
public
async
Task
<
fileListResult
>
CreateFolder
(
string
path
)
{
string
header
=
string
.
Format
(
"{0}CreateFiles?
newDir
={1}"
,
httpUrl
,
path
);
var
strError
=
await
MediaResourceFileService
.
PostAsyncJson
(
header
,
""
);
string
header
=
string
.
Format
(
"{0}CreateFiles?
filePath
={1}"
,
httpUrl
,
path
);
var
result
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>
(
header
,
""
);
return
result
;
}
...
...
@@ -148,10 +156,11 @@ namespace VIZ.TVP.Module
/// 删除文件夹
/// </summary>
/// <param name="path"></param>
public
async
void
DeleteFolder
(
string
path
)
public
async
Task
<
fileListResult
>
DeleteFolder
(
string
path
)
{
string
header
=
string
.
Format
(
"{0}DeleteFiles?delDir={1}"
,
httpUrl
,
path
);
var
strError
=
await
MediaResourceFileService
.
PostAsyncJson
(
header
,
""
);
string
header
=
string
.
Format
(
"{0}DeleteFiles?filePath={1}"
,
httpUrl
,
path
);
var
result
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
return
result
;
}
/// <summary>
...
...
@@ -166,20 +175,37 @@ namespace VIZ.TVP.Module
fileUploadResult
upLoadResult
=
await
MediaResourceFileService
.
PostImage
<
fileUploadResult
>(
requestUri
,
filePath
,
fileName
);
if
(
upLoadResult
==
null
)
return
null
;
return
upLoadResult
;
}
public
async
void
DeleteFile
(
string
path
)
/// <summary>
/// 删除文件
/// </summary>
/// <param name="path"></param>
public
async
Task
<
fileListResult
>
DeleteFile
(
string
path
)
{
string
header
=
string
.
Format
(
"{0}DeleteFile?delFile={1}"
,
httpUrl
,
path
);
var
strError
=
await
MediaResourceFileService
.
PostAsyncJson
(
header
,
""
);
try
{
string
header
=
string
.
Format
(
"{0}DeleteFile?filePath={1}"
,
httpUrl
,
path
);
var
result
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
return
result
;
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
.
Message
);
return
null
;
}
}
/// <summary>
///获取文件
///获取文件
夹
/// </summary>
/// <returns></returns>
...
...
@@ -188,9 +214,10 @@ namespace VIZ.TVP.Module
// var config =
var
folderResult
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
string
.
Format
(
"{0}GetListFiles"
,
httpUrl
),
""
);
if
(
folderResult
==
null
)
return
null
;
RootPath
=
folderResult
.
rootPath
;
return
GetFolder
(
folderResult
.
masterData
);
}
...
...
VIZ.TVP.Module/Resource/MediaResource/Controller/MediaResourceFile/MediaResourceFileService.cs
View file @
511807e7
...
...
@@ -66,16 +66,7 @@ namespace VIZ.TVP.Module
HttpResponseMessage
response
=
await
client
.
PostAsync
(
url
,
content
);
response
.
EnsureSuccessStatusCode
();
string
responseBody
=
""
;
//if (Gzip)
//{
// GZipInputStream inputStream = new GZipInputStream(await response.Content.ReadAsStreamAsync());
// responseBody = new StreamReader(inputStream).ReadToEnd();
//}
//else
//{
responseBody
=
await
response
.
Content
.
ReadAsStringAsync
();
//}
return
responseBody
;
}
...
...
@@ -99,16 +90,7 @@ namespace VIZ.TVP.Module
HttpResponseMessage
response
=
await
client
.
GetAsync
(
url
);
response
.
EnsureSuccessStatusCode
();
//用来抛异常的
string
responseBody
=
""
;
//if (Gzip)
//{
// GZipInputStream inputStream = new GZipInputStream(await response.Content.ReadAsStreamAsync());
// responseBody = new StreamReader(inputStream).ReadToEnd();
//}
//else
//{
responseBody
=
await
response
.
Content
.
ReadAsStringAsync
();
//}
return
responseBody
;
}
...
...
@@ -122,9 +104,19 @@ namespace VIZ.TVP.Module
/// <returns>请求返回的目标对象</returns>
public
static
async
Task
<
T
>
PostObjectAsync
<
T
,
T2
>(
string
url
,
T2
obj
)
{
String
json
=
JsonConvert
.
SerializeObject
(
obj
);
string
responseBody
=
await
PostAsyncJson
(
url
,
json
);
//请求当前账户的信息
return
JsonConvert
.
DeserializeObject
<
T
>(
responseBody
);
//把收到的字符串序列化
try
{
String
json
=
JsonConvert
.
SerializeObject
(
obj
);
string
responseBody
=
await
PostAsyncJson
(
url
,
json
);
//请求当前账户的信息
return
JsonConvert
.
DeserializeObject
<
T
>(
responseBody
);
//把收到的字符串序列化
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
.
Message
);
return
default
(
T
);
}
}
/// <summary>
...
...
@@ -148,19 +140,26 @@ namespace VIZ.TVP.Module
/// <returns></returns>
public
static
async
Task
<
MemoryStream
>
GetImage
(
string
url
)
{
HttpClient
client
=
new
HttpClient
(
new
HttpClientHandler
()
{
UseCookies
=
false
});
HttpResponseMessage
response
=
await
client
.
GetAsync
(
url
);
response
.
EnsureSuccessStatusCode
();
//用来抛异常的
using
(
Stream
stream
=
response
.
Content
.
ReadAsStreamAsync
().
Result
)
try
{
MemoryStream
ms
=
new
MemoryStream
();
stream
.
CopyTo
(
ms
);
return
ms
;
HttpClient
client
=
new
HttpClient
(
new
HttpClientHandler
()
{
UseCookies
=
false
});
HttpResponseMessage
response
=
await
client
.
GetAsync
(
url
);
response
.
EnsureSuccessStatusCode
();
//用来抛异常的
using
(
Stream
stream
=
response
.
Content
.
ReadAsStreamAsync
().
Result
)
{
MemoryStream
ms
=
new
MemoryStream
();
stream
.
CopyTo
(
ms
);
return
ms
;
}
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
.
Message
);
return
null
;
}
}
/// <summary>
...
...
@@ -173,29 +172,25 @@ namespace VIZ.TVP.Module
/// <returns></returns>
public
static
async
Task
<
T
>
PostImage
<
T
>(
string
requestUri
,
string
path
,
string
fileName
)
{
try
{
HttpClient
client
=
new
HttpClient
();
var
content
=
new
MultipartFormDataContent
();
content
.
Headers
.
Add
(
"ContentType"
,
$"multipart/form-data"
);
var
b
=
new
ByteArrayContent
(
System
.
IO
.
File
.
ReadAllBytes
(
path
));
content
.
Add
(
new
ByteArrayContent
(
System
.
IO
.
File
.
ReadAllBytes
(
path
)),
"image"
,
fileName
);
var
response
=
await
client
.
PostAsync
(
requestUri
,
content
);
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
return
JsonConvert
.
DeserializeObject
<
T
>(
result
);
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
.
Message
);
return
default
(
T
);
}
HttpClient
client
=
new
HttpClient
();
var
content
=
new
MultipartFormDataContent
();
content
.
Headers
.
Add
(
"ContentType"
,
$"multipart/form-data"
);
//添加字符串参数,参数名为qq
// content.Add(new StringContent("123456"), "qq");
//string path = Path.Combine(System.Environment.CurrentDirectory, "1.png");
//添加文件参数,参数名为files,文件名为123.png
var
b
=
new
ByteArrayContent
(
System
.
IO
.
File
.
ReadAllBytes
(
path
));
content
.
Add
(
new
ByteArrayContent
(
System
.
IO
.
File
.
ReadAllBytes
(
path
)),
"image"
,
fileName
);
var
response
=
await
client
.
PostAsync
(
requestUri
,
content
);
var
result
=
response
.
Content
.
ReadAsStringAsync
().
Result
;
return
JsonConvert
.
DeserializeObject
<
T
>(
result
);
}
}
}
VIZ.TVP.Module/Resource/MediaResource/Controller/Model/fileListResult.cs
View file @
511807e7
...
...
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace
VIZ.TVP.Module
{
/// <summary>
/// 文件信息从提供媒体库服务的实体类拷贝出来的
/// </summary>
public
class
fileListResult
{
/// <summary>
...
...
@@ -35,6 +38,16 @@ namespace VIZ.TVP.Module
}
/// <summary>
/// 根目录
/// </summary>
public
string
rootPath
{
get
;
set
;
}
/// <summary>
/// 设置文件信息
/// </summary>
public
List
<
ms
>
masterData
=
new
List
<
ms
>();
...
...
VIZ.TVP.Module/Resource/MediaResource/Controller/Model/fileUploadResult.cs
View file @
511807e7
...
...
@@ -6,6 +6,9 @@ using System.Threading.Tasks;
namespace
VIZ.TVP.Module.Resource.MediaResource.Controller.Model
{
/// <summary>
/// 文件上传的实体对象
/// </summary>
public
class
fileUploadResult
{
/// <summary>
...
...
VIZ.TVP.Module/Resource/MediaResource/Controller/Model/ms.cs
View file @
511807e7
...
...
@@ -6,18 +6,30 @@ using System.Threading.Tasks;
namespace
VIZ.TVP.Module
{
/// <summary>
/// 文件信息从拷贝出来的
/// </summary>
public
class
ms
{
/// <summary>
/// 文件名称
/// </summary>
public
string
fileName
{
get
;
set
;
}
/// <summary>
/// 文件地址
/// </summary>
public
string
smallIconUrl
{
get
;
set
;
}
/// <summary>
/// 文件类型
/// </summary>
public
string
fileType
{
get
;
...
...
VIZ.TVP.Module/Resource/MediaResource/ViewModel/CreateFolderViewModel.cs
View file @
511807e7
...
...
@@ -13,7 +13,9 @@ namespace VIZ.TVP.Module
public
class
CreateFolderViewModel
:
PluginViewModelBase
{
/// <summary>
/// 初始化
/// </summary>
public
CreateFolderViewModel
()
{
EnterCommand
=
new
VCommand
(
Enter
);
...
...
@@ -22,6 +24,9 @@ namespace VIZ.TVP.Module
private
string
folderName
;
/// <summary>
/// 文件夹名称
/// </summary>
public
string
FolderName
{
get
{
return
folderName
;
}
...
...
VIZ.TVP.Module/Resource/MediaResource/ViewModel/MediaResourceViewModel.cs
View file @
511807e7
...
...
@@ -249,36 +249,18 @@ namespace VIZ.TVP.Module
{
try
{
//LocalInfoEntity info = ApplicationDomainEx.DataBaseManager.LocalInfo;
//string url = $"http://{info.GH_IP}:{info.GH_Port}/folders/";
//List<GHResourceFolderModel> list = this.ghResourceService.GetGHResourceFolders(url, null);
//WPFHelper.BeginInvoke(() =>
//{
// this.FolderModels = list.FirstOrDefault()?.Children.Select(p => (GHResourceFolderModel)p).ToObservableCollection();
// this.IsFolderLoading = false;
//});
//http://192.168.3.76:9000/api/home/GetListFiles
List
<
MHResourceFolderModel
>
list
=
await
this
.
mediaResourceFileController
.
GetMeiaResourceFolder
();
if
(
list
==
null
)
return
;
if
(
list
==
null
)
{
return
;
}
this
.
FolderModels
=
list
.
ToObservableCollection
();
//WPFHelper.BeginInvoke(() =>
//{
// this.FolderModels = list.FirstOrDefault()?.Children.Select(p => (GHResourceFolderModel)p).ToObservableCollection();
this
.
IsFolderLoading
=
false
;
// });
}
catch
(
Exception
ex
)
{
...
...
@@ -309,9 +291,7 @@ namespace VIZ.TVP.Module
return
;
this
.
mediaResourceFileController
.
DisposeFileModels
(
folder
);
folder
.
IsRefreshedFiles
=
false
;
this
.
mediaResourceFileController
.
UpdateFileModels
(
this
.
SelectedFolderModel
);
}
...
...
@@ -324,7 +304,7 @@ namespace VIZ.TVP.Module
/// <summary>
/// 创建文件夹
/// </summary>
private
void
CreateFloder
()
private
async
void
CreateFloder
()
{
CreateFolderWindow
floderView
=
new
CreateFolderWindow
();
...
...
@@ -335,15 +315,62 @@ namespace VIZ.TVP.Module
if
(
vm
==
null
||
!
vm
.
IsEnter
)
return
;
string
createPath
=
String
.
Format
(
"{0}\\{1}"
,
selectedFolderModel
.
Path
,
vm
.
FolderName
);
SelectedFolderModel
.
Children
.
Add
(
new
MHResourceFolderModel
()
if
(
this
.
FolderModels
==
null
)
return
;
string
createPath
=
""
;
//创建根目录文件夹
if
(
this
.
FolderModels
.
Count
==
0
)
{
Name
=
vm
.
FolderName
,
Path
=
createPath
,
FolderType
=
ResourceFolderType
.
Folder
});
createPath
=
string
.
Format
(
"{0}\\{1}"
,
this
.
mediaResourceFileController
.
RootPath
,
vm
.
FolderName
);
var
result
=
await
this
.
mediaResourceFileController
.
CreateFolder
(
createPath
);
if
(
result
!=
null
)
{
if
(
result
.
status
==
"0"
)
{
this
.
folderModels
.
Add
(
new
MHResourceFolderModel
()
{
Name
=
vm
.
FolderName
,
Path
=
createPath
,
FolderType
=
ResourceFolderType
.
Folder
});
}
else
{
log
.
Error
(
result
.
message
);
}
}
}
else
{
createPath
=
string
.
Format
(
"{0}\\{1}"
,
selectedFolderModel
.
Path
,
vm
.
FolderName
);
var
result
=
await
this
.
mediaResourceFileController
.
CreateFolder
(
createPath
);
if
(
result
!=
null
)
{
if
(
result
.
status
==
"0"
)
{
SelectedFolderModel
.
Children
.
Add
(
new
MHResourceFolderModel
()
{
Name
=
vm
.
FolderName
,
Path
=
createPath
,
FolderType
=
ResourceFolderType
.
Folder
,
Parent
=
selectedFolderModel
});
}
else
{
log
.
Error
(
result
.
message
);
}
}
}
this
.
mediaResourceFileController
.
CreateFolder
(
createPath
);
}
...
...
@@ -353,15 +380,36 @@ namespace VIZ.TVP.Module
public
VCommand
DeleteFloderCommand
{
get
;
set
;
}
private
void
DeleteFloder
()
private
async
void
DeleteFloder
()
{
if
((
DialogResult
)
DXMessageBox
.
Show
(
"是否此文件夹"
,
""
,
MessageBoxButton
.
YesNo
)
==
DialogResult
.
Yes
)
if
(
selectedFolderModel
!=
null
)
{
string
path
=
SelectedFolderModel
.
Path
;
SelectedFolderModel
.
Parent
.
Children
.
Remove
(
SelectedFolderModel
);
this
.
mediaResourceFileController
.
DeleteFolder
(
path
);
}
if
((
DialogResult
)
DXMessageBox
.
Show
(
"是否此文件夹"
,
""
,
MessageBoxButton
.
YesNo
)
==
DialogResult
.
Yes
)
{
string
path
=
SelectedFolderModel
.
Path
;
var
result
=
await
this
.
mediaResourceFileController
.
DeleteFolder
(
path
);
if
(
result
!=
null
)
{
if
(
SelectedFolderModel
.
Parent
!=
null
)
{
if
(
result
.
status
==
"0"
)
{
SelectedFolderModel
.
Parent
.
Children
.
Remove
(
SelectedFolderModel
);
}
else
{
log
.
Error
(
result
.
message
);
}
}
else
{
this
.
FolderModels
.
Remove
(
SelectedFolderModel
);
}
}
}
}
}
#
endregion
...
...
@@ -430,9 +478,6 @@ namespace VIZ.TVP.Module
}
}
}
//System.Windows.Forms.FileDialog fbd = new System.Windows.Forms.FileDialog();
//if (fbd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
// return;
}
#
endregion
创建文件
...
...
@@ -440,14 +485,25 @@ namespace VIZ.TVP.Module
public
VCommand
DeleteFileCommand
{
get
;
set
;
}
private
void
DeleteFile
()
private
async
void
DeleteFile
()
{
if
((
DialogResult
)
DXMessageBox
.
Show
(
"是否删除此文件"
,
""
,
MessageBoxButton
.
YesNo
)
==
DialogResult
.
Yes
)
{
this
.
mediaResourceFileController
.
DeleteFile
(
selectedFileModel
.
Path
);
var
result
=
await
this
.
mediaResourceFileController
.
DeleteFile
(
selectedFileModel
.
Path
);
if
(
result
!=
null
)
{
if
(
result
.
status
==
"0"
)
{
this
.
FileModels
.
Remove
(
this
.
SelectedFileModel
);
}
else
{
log
.
Error
(
result
.
message
);
}
}
this
.
FileModels
.
Remove
(
this
.
SelectedFileModel
);
}
}
...
...
@@ -464,19 +520,27 @@ namespace VIZ.TVP.Module
private
void
MoveFile
()
{
if
((
DialogResult
)
DXMessageBox
.
Show
(
"是否移动此文件"
,
""
,
MessageBoxButton
.
YesNo
)
==
DialogResult
.
Yes
)
if
(
selectedFileModel
!=
null
)
{
moveFilePath
=
selectedFileModel
.
Path
;
moveFileModel
=
selectedFileModel
;
if
((
DialogResult
)
DXMessageBox
.
Show
(
"是否移动此文件"
,
""
,
MessageBoxButton
.
YesNo
)
==
DialogResult
.
Yes
)
{
moveFilePath
=
selectedFileModel
.
Path
;
moveFileModel
=
selectedFileModel
;
}
}
}
public
VCommand
MoveFloderCommand
{
get
;
set
;
}
private
void
MoveFileFloder
()
/// <summary>
/// 移动文件到文件夹
/// </summary>
private
async
void
MoveFileFloder
()
{
if
(
string
.
IsNullOrEmpty
(
moveFilePath
))
{
...
...
@@ -487,12 +551,24 @@ namespace VIZ.TVP.Module
}
else
{
this
.
mediaResourceFileController
.
MoveFile
(
moveFilePath
,
selectedFolderModel
.
Path
);
var
result
=
await
this
.
mediaResourceFileController
.
MoveFile
(
moveFilePath
,
selectedFolderModel
.
Path
);
if
(
moveFileModel
!=
null
)
if
(
result
!=
null
)
{
this
.
FileModels
.
Add
(
moveFileModel
);
if
(
result
.
status
==
"0"
)
{
if
(
moveFileModel
!=
null
)
{
this
.
FileModels
.
Add
(
moveFileModel
);
}
}
else
{
log
.
Error
(
result
.
message
);
}
}
}
}
#
endregion
...
...
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