Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
VIZ.Package
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.Package
Commits
b33a0d17
Commit
b33a0d17
authored
Jan 06, 2023
by
wangonghui
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
媒体库添加
parent
805ef1b0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
1496 additions
and
10 deletions
+1496
-10
VIZ.Package.Domain/ApplicationDomainEx.cs
+6
-0
VIZ.Package.Domain/Model/Resource/MH/MHResourceFileModel.cs
+129
-0
VIZ.Package.Domain/Model/Resource/MH/MHResourceFolderModel.cs
+46
-0
VIZ.Package.Domain/VIZ.Package.Domain.csproj
+2
-0
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ImageEdit/ImageEditPanel.xaml
+13
-1
VIZ.Package.Module/Resource/MediaResource/Controller/IMediaResourceFileSupport.cs
+38
-0
VIZ.Package.Module/Resource/MediaResource/Controller/MediaResourceFileController.cs
+266
-0
VIZ.Package.Module/Resource/MediaResource/Controller/MediaResourceFileService.cs
+195
-0
VIZ.Package.Module/Resource/MediaResource/Controller/Model/fileListResult.cs
+52
-0
VIZ.Package.Module/Resource/MediaResource/Controller/Model/fileUploadResult.cs
+46
-0
VIZ.Package.Module/Resource/MediaResource/Controller/Model/ms.cs
+40
-0
VIZ.Package.Module/Resource/MediaResource/Controller/ThumbnailHelper.cs
+204
-0
VIZ.Package.Module/Resource/MediaResource/View/CreateFolder.xaml
+30
-0
VIZ.Package.Module/Resource/MediaResource/View/CreateFolder.xaml.cs
+29
-0
VIZ.Package.Module/Resource/MediaResource/View/CreateFolderWindow.xaml
+13
-0
VIZ.Package.Module/Resource/MediaResource/View/CreateFolderWindow.xaml.cs
+28
-0
VIZ.Package.Module/Resource/MediaResource/View/MediaResourcePanel.xaml
+0
-0
VIZ.Package.Module/Resource/MediaResource/View/MediaResourcePanel.xaml.cs
+71
-0
VIZ.Package.Module/Resource/MediaResource/View/MediaResourceView.xaml
+28
-5
VIZ.Package.Module/Resource/MediaResource/View/MediaResourceView.xaml.cs
+1
-1
VIZ.Package.Module/Resource/MediaResource/ViewModel/CreateFolderViewModel.cs
+80
-0
VIZ.Package.Module/Resource/MediaResource/ViewModel/MediaResourcePanelViewModel.cs
+0
-0
VIZ.Package.Module/Resource/MediaResource/ViewModel/MediaResourceViewModel.cs
+13
-3
VIZ.Package.Module/Resource/VedioImage/Vedio.jpeg
+0
-0
VIZ.Package.Module/Setup/AppSetup_InitMedia.cs
+56
-0
VIZ.Package.Module/VIZ.Package.Module.csproj
+40
-0
VIZ.Package.Module/packages.config
+2
-0
VIZ.Package.Storage/Entity/Config/ConfigContext.cs
+53
-0
VIZ.Package.Storage/VIZ.Package.Storage.csproj
+1
-0
VIZ.Package/App.xaml.cs
+3
-0
VIZ.Package/VIZ.Package.csproj
+3
-0
VIZ.Package/config/MediaResouce.config
+8
-0
No files found.
VIZ.Package.Domain/ApplicationDomainEx.cs
View file @
b33a0d17
...
@@ -92,5 +92,11 @@ namespace VIZ.Package.Domain
...
@@ -92,5 +92,11 @@ namespace VIZ.Package.Domain
/// 当前页
/// 当前页
/// </summary>
/// </summary>
public
static
PageModelBase
CurrentPage
{
get
;
set
;
}
public
static
PageModelBase
CurrentPage
{
get
;
set
;
}
/// <summary>
/// 媒体库配置
/// </summary>
public
static
ConfigContext
MediaConfig
{
get
;
set
;
}
}
}
}
}
VIZ.Package.Domain/Model/Resource/MH/MHResourceFileModel.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Package.Storage
;
namespace
VIZ.Package.Domain
{
public
class
MHResourceFileModel
:
ResourceFileModelBase
,
IDisposable
{
/// <summary>
/// GH 节点
/// </summary>
public
GH_Entry_Node
EntryNode
{
get
;
set
;
}
#
region
FloderModel
--
所属文件夹模型
private
MHResourceFolderModel
floderModel
;
/// <summary>
/// 所属文件夹模型
/// </summary>
public
MHResourceFolderModel
FloderModel
{
get
{
return
floderModel
;
}
set
{
floderModel
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
FloderModel
));
}
}
#
endregion
#
region
Src
--
源
private
string
src
;
/// <summary>
/// 源
/// </summary>
public
string
Src
{
get
{
return
src
;
}
set
{
src
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Src
));
}
}
#
endregion
#
region
Thumbnail
--
缩略图
private
string
thumbnail
;
/// <summary>
/// 缩略图
/// </summary>
public
string
Thumbnail
{
get
{
return
thumbnail
;
}
set
{
thumbnail
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Thumbnail
));
}
}
#
endregion
#
region
MimeType
--
文件格式
private
string
mimeType
;
/// <summary>
/// 文件格式
/// </summary>
public
string
MimeType
{
get
{
return
mimeType
;
}
set
{
mimeType
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
MimeType
));
}
}
#
endregion
#
region
Path
--
路径
private
string
path
;
/// <summary>
/// 路径
/// </summary>
public
string
Path
{
get
{
return
path
;
}
set
{
path
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Path
));
}
}
#
endregion
#
region
ResourcePath
--
资源路径
/// <summary>
/// 资源路径
/// </summary>
public
string
ResourcePath
{
get
{
return
$"
{
this
.
FileType
}
*
{
this
.
Path
}
"
;
}
}
#
endregion
// ---------------------------------------------------------------------
// 扩展属性
#
region
ThumbnailBitmap
--
缩略图图片
private
Bitmap
thumbnailBitmap
;
/// <summary>
/// 缩略图图片
/// </summary>
public
Bitmap
ThumbnailBitmap
{
get
{
return
thumbnailBitmap
;
}
set
{
thumbnailBitmap
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
ThumbnailBitmap
));
}
}
#
endregion
// ---------------------------------------------------------------------
// 方法
/// <summary>
/// 销毁
/// </summary>
public
void
Dispose
()
{
this
.
ThumbnailBitmap
?.
Dispose
();
this
.
ThumbnailBitmap
=
null
;
}
}
}
VIZ.Package.Domain/Model/Resource/MH/MHResourceFolderModel.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Package.Storage
;
namespace
VIZ.Package.Domain
{
public
class
MHResourceFolderModel
:
ResourceFolderModelBase
{
/// <summary>
/// GH 节点
/// </summary>
public
GH_Entry_Node
EntryNode
{
get
;
set
;
}
#
region
Path
--
路径
private
string
path
;
/// <summary>
/// 路径
/// </summary>
public
string
Path
{
get
{
return
path
;
}
set
{
path
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Path
));
}
}
#
endregion
#
region
Files
--
文件集合
private
ObservableCollection
<
MHResourceFileModel
>
files
;
/// <summary>
/// 文件集合
/// </summary>
public
ObservableCollection
<
MHResourceFileModel
>
Files
{
get
{
return
files
;
}
set
{
files
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
Files
));
}
}
#
endregion
}
}
VIZ.Package.Domain/VIZ.Package.Domain.csproj
View file @
b33a0d17
...
@@ -98,6 +98,8 @@
...
@@ -98,6 +98,8 @@
<Compile Include="Model\Resource\Enum\ResourceFolderType.cs" />
<Compile Include="Model\Resource\Enum\ResourceFolderType.cs" />
<Compile Include="Model\Resource\GH\GHResourceFileModel.cs" />
<Compile Include="Model\Resource\GH\GHResourceFileModel.cs" />
<Compile Include="Model\Resource\GH\GHResourceFolderModel.cs" />
<Compile Include="Model\Resource\GH\GHResourceFolderModel.cs" />
<Compile Include="Model\Resource\MH\MHResourceFileModel.cs" />
<Compile Include="Model\Resource\MH\MHResourceFolderModel.cs" />
<Compile Include="Model\Resource\ResourceDragData.cs" />
<Compile Include="Model\Resource\ResourceDragData.cs" />
<Compile Include="Model\Resource\ResourceFileModelBase.cs" />
<Compile Include="Model\Resource\ResourceFileModelBase.cs" />
<Compile Include="Model\Resource\ResourceFolderModelBase.cs" />
<Compile Include="Model\Resource\ResourceFolderModelBase.cs" />
...
...
VIZ.Package.Module/ControlObject/FieldEdit/Edit/ImageEdit/ImageEditPanel.xaml
View file @
b33a0d17
...
@@ -51,7 +51,19 @@
...
@@ -51,7 +51,19 @@
</local:GHResourcePanel>
</local:GHResourcePanel>
</dx:DXTabItem>
</dx:DXTabItem>
<dx:DXTabItem Header="媒资库">
<dx:DXTabItem Header="媒资库">
<!-- 媒体资源面板 -->
<local:MediaResourcePanel x:Name="mhResourcePanel">
<local:MediaResourcePanel.FolderContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFolderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</local:MediaResourcePanel.FolderContextMenu>
<local:MediaResourcePanel.FileContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</local:MediaResourcePanel.FileContextMenu>
</local:MediaResourcePanel>
</dx:DXTabItem>
</dx:DXTabItem>
</dx:DXTabControl>
</dx:DXTabControl>
...
...
VIZ.Package.Module/Resource/MediaResource/Controller/IMediaResourceFileSupport.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Package.Domain
;
namespace
VIZ.Package.Module
{
public
interface
IMediaResourceFileSupport
{
/// <summary>
/// 文件夹目录集合
/// </summary>
ObservableCollection
<
MHResourceFolderModel
>
FolderModels
{
get
;
set
;
}
/// <summary>
/// 当前选中的文件夹
/// </summary>
MHResourceFolderModel
SelectedFolderModel
{
get
;
set
;
}
/// <summary>
/// 文件集合
/// </summary>
ObservableCollection
<
MHResourceFileModel
>
FileModels
{
get
;
set
;
}
/// <summary>
/// 选中的文件模型
/// </summary>
MHResourceFileModel
SelectedFileModel
{
get
;
set
;
}
/// <summary>
/// 是否正在加载文件
/// </summary>
bool
IsFileLoading
{
get
;
set
;
}
}
}
VIZ.Package.Module/Resource/MediaResource/Controller/MediaResourceFileController.cs
0 → 100644
View file @
b33a0d17
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Configuration
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain
;
namespace
VIZ.Package.Module
{
public
class
MediaResourceFileController
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
MediaResourceFileController
));
public
static
AppSettingsSection
config
=
ApplicationDomainEx
.
MediaConfig
.
configuration
.
AppSettings
;
private
static
string
httpUrl
=
config
.
Settings
[
"url"
].
Value
.
ToString
();
/// <summary>
/// VIZ资源缩略图控制器
/// </summary>
/// <param name="support">支持</param>
public
MediaResourceFileController
(
IMediaResourceFileSupport
support
)
{
this
.
Support
=
support
;
}
/// <summary>
/// 支持
/// </summary>
public
IMediaResourceFileSupport
Support
{
get
;
private
set
;
}
/// <summary>
/// 根目录
/// </summary>
public
string
RootPath
{
get
;
set
;
}
/// <summary>
/// 更新文件模型
/// </summary>
/// <param name="folder">文件夹</param>
public
void
UpdateFileModels
(
MHResourceFolderModel
folder
)
{
// 文件夹对象不存在
if
(
folder
==
null
)
{
this
.
Support
.
FileModels
=
null
;
this
.
Support
.
SelectedFileModel
=
null
;
return
;
}
//// 已经获取过文件
if
(
folder
.
IsRefreshedFiles
)
{
this
.
Support
.
FileModels
=
folder
.
Files
;
return
;
}
WPFHelper
.
BeginInvoke
(
async
()
=>
{
string
header
=
string
.
Format
(
"{0}GetListFile?filePath={1}"
,
httpUrl
,
folder
.
Path
);
var
FileResult
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
List
<
MHResourceFileModel
>
list
=
new
List
<
MHResourceFileModel
>();
// folder.Files = new System.Collections.ObjectModel.ObservableCollection<GHResourceFileModel>();
foreach
(
var
file
in
FileResult
.
masterData
)
{
try
{
MHResourceFileModel
GHFile
=
new
MHResourceFileModel
();
if
(
ThumbnailHelper
.
IsImageByName
(
file
.
fileName
))
{
GHFile
.
Name
=
file
.
fileName
;
GHFile
.
Path
=
file
.
smallIconUrl
;
string
url
=
string
.
Format
(
"{0}GetFile?filePath={1}"
,
httpUrl
,
GHFile
.
Path
);
var
fileResult
=
await
MediaResourceFileService
.
GetImage
(
url
);
GHFile
.
FileType
=
ResourceFileType
.
IMAGE
;
Image
img
=
Bitmap
.
FromStream
(
fileResult
);
img
=
ThumbnailHelper
.
GetThumbnail
(
img
,
100
,
200
);
Bitmap
bmp
=
new
Bitmap
(
img
);
GHFile
.
ThumbnailBitmap
=
bmp
;
list
.
Add
(
GHFile
);
}
else
if
(
ThumbnailHelper
.
IsVideo
(
file
.
fileName
))
{
GHFile
.
Name
=
file
.
fileName
;
GHFile
.
Path
=
file
.
smallIconUrl
;
string
strVedioPath
=
string
.
Format
(
"{0}{1}"
,
System
.
Environment
.
CurrentDirectory
,
"\\Resource\\VedioImage\\Vedio.jpeg"
);
Image
vedioImage
=
Image
.
FromFile
(
strVedioPath
);
vedioImage
=
ThumbnailHelper
.
GetThumbnail
(
vedioImage
,
100
,
200
);
Bitmap
vedioBtm
=
new
Bitmap
(
vedioImage
);
GHFile
.
ThumbnailBitmap
=
vedioBtm
;
GHFile
.
FileType
=
ResourceFileType
.
Video
;
list
.
Add
(
GHFile
);
}
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
.
Message
);
}
}
folder
.
Files
=
list
.
ToObservableCollection
();
this
.
Support
.
FileModels
=
folder
.
Files
;
});
}
/// <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
result
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
return
result
;
}
/// <summary>
/// 添加文件夹
/// </summary>
/// <param name="path"></param>
public
async
Task
<
fileListResult
>
CreateFolder
(
string
path
)
{
string
header
=
string
.
Format
(
"{0}CreateFiles?filePath={1}"
,
httpUrl
,
path
);
var
result
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
return
result
;
}
/// <summary>
/// 删除文件夹
/// </summary>
/// <param name="path"></param>
public
async
Task
<
fileListResult
>
DeleteFolder
(
string
path
)
{
string
header
=
string
.
Format
(
"{0}DeleteFiles?filePath={1}"
,
httpUrl
,
path
);
var
result
=
await
MediaResourceFileService
.
PostObjectAsync
<
fileListResult
,
string
>(
header
,
""
);
return
result
;
}
/// <summary>
/// 创建文件
/// </summary>
/// <param name="filePath"></param>
/// <param name="fileName"></param>
/// <returns></returns>
public
async
Task
<
fileUploadResult
>
CreateFile
(
string
filePath
,
string
fileName
)
{
string
requestUri
=
string
.
Format
(
"{0}UplodFile?filePath={1}"
,
httpUrl
,
this
.
Support
.
SelectedFolderModel
.
Path
+
"\\"
);
fileUploadResult
upLoadResult
=
await
MediaResourceFileService
.
PostImage
<
fileUploadResult
>(
requestUri
,
filePath
,
fileName
);
if
(
upLoadResult
==
null
)
return
null
;
return
upLoadResult
;
}
/// <summary>
/// 删除文件
/// </summary>
/// <param name="path"></param>
public
async
Task
<
fileListResult
>
DeleteFile
(
string
path
)
{
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>
public
async
Task
<
List
<
MHResourceFolderModel
>>
GetMeiaResourceFolder
()
{
// 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
);
}
/// <summary>
/// 获取文件夹
/// </summary>
/// <param name="foldersDatas"></param>
/// <returns></returns>
private
List
<
MHResourceFolderModel
>
GetFolder
(
List
<
ms
>
foldersDatas
)
{
List
<
MHResourceFolderModel
>
listFolderModel
=
new
List
<
MHResourceFolderModel
>();
foreach
(
var
floderData
in
foldersDatas
)
{
if
(
floderData
.
fileType
==
"floder"
)
{
MHResourceFolderModel
child
=
new
MHResourceFolderModel
();
child
.
Name
=
floderData
.
fileName
;
child
.
FolderType
=
ResourceFolderType
.
Folder
;
child
.
Path
=
floderData
.
smallIconUrl
;
List
<
MHResourceFolderModel
>
children_list
=
GetFolder
(
floderData
.
m
);
foreach
(
MHResourceFolderModel
item
in
children_list
)
{
child
.
Children
.
Add
(
item
);
item
.
Parent
=
child
;
}
listFolderModel
.
Add
(
child
);
}
}
return
listFolderModel
;
}
/// <summary>
/// 销毁文件模型
/// </summary>
public
void
DisposeFileModels
(
MHResourceFolderModel
folder
)
{
if
(
folder
==
null
||
folder
.
Files
==
null
||
folder
.
Files
.
Count
==
0
)
return
;
foreach
(
MHResourceFileModel
file
in
folder
.
Files
)
{
file
.
Dispose
();
}
}
}
}
VIZ.Package.Module/Resource/MediaResource/Controller/MediaResourceFileService.cs
0 → 100644
View file @
b33a0d17
using
DevExpress.XtraPrinting.Native.WebClientUIControl
;
using
log4net
;
using
Newtonsoft.Json
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Net.Http
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Package.Module
{
public
class
MediaResourceFileService
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
MediaResourceFileService
));
/// <summary>
/// 使用post方法异步请求
/// </summary>
/// <param name="url">目标链接</param>
/// <param name="json">发送的参数字符串,只能用json</param>
/// <returns>返回的字符串</returns>
public
static
async
Task
<
string
>
PostAsyncJson
(
string
url
,
string
json
)
{
try
{
HttpClient
client
=
new
HttpClient
();
HttpContent
content
=
new
StringContent
(
json
);
content
.
Headers
.
ContentType
=
new
System
.
Net
.
Http
.
Headers
.
MediaTypeHeaderValue
(
"application/json"
);
HttpResponseMessage
response
=
await
client
.
PostAsync
(
url
,
content
);
response
.
EnsureSuccessStatusCode
();
string
responseBody
=
await
response
.
Content
.
ReadAsStringAsync
();
return
responseBody
;
}
catch
(
Exception
ex
)
{
log
.
Error
(
string
.
Format
(
"{0}_{1}"
,
"获取媒体资源文件夹"
,
ex
.
ToString
()));
return
""
;
}
}
/// <summary>
/// 使用post方法异步请求
/// </summary>
/// <param name="url">目标链接</param>
/// <param name="data">发送的参数字符串</param>
/// <returns>返回的字符串</returns>
public
static
async
Task
<
string
>
PostAsync
(
string
url
,
string
data
,
Dictionary
<
string
,
string
>
header
=
null
,
bool
Gzip
=
false
)
{
HttpClient
client
=
new
HttpClient
(
new
HttpClientHandler
()
{
UseCookies
=
false
});
HttpContent
content
=
new
StringContent
(
data
);
if
(
header
!=
null
)
{
client
.
DefaultRequestHeaders
.
Clear
();
foreach
(
var
item
in
header
)
{
client
.
DefaultRequestHeaders
.
Add
(
item
.
Key
,
item
.
Value
);
}
}
HttpResponseMessage
response
=
await
client
.
PostAsync
(
url
,
content
);
response
.
EnsureSuccessStatusCode
();
string
responseBody
=
""
;
responseBody
=
await
response
.
Content
.
ReadAsStringAsync
();
return
responseBody
;
}
/// <summary>
/// 使用get方法异步请求
/// </summary>
/// <param name="url">目标链接</param>
/// <returns>返回的字符串</returns>
public
static
async
Task
<
string
>
GetAsync
(
string
url
,
Dictionary
<
string
,
string
>
header
=
null
,
bool
Gzip
=
false
)
{
HttpClient
client
=
new
HttpClient
(
new
HttpClientHandler
()
{
UseCookies
=
false
});
if
(
header
!=
null
)
{
client
.
DefaultRequestHeaders
.
Clear
();
foreach
(
var
item
in
header
)
{
client
.
DefaultRequestHeaders
.
Add
(
item
.
Key
,
item
.
Value
);
}
}
HttpResponseMessage
response
=
await
client
.
GetAsync
(
url
);
response
.
EnsureSuccessStatusCode
();
//用来抛异常的
string
responseBody
=
""
;
responseBody
=
await
response
.
Content
.
ReadAsStringAsync
();
return
responseBody
;
}
/// <summary>
/// 使用post返回异步请求直接返回对象
/// </summary>
/// <typeparam name="T">返回对象类型</typeparam>
/// <typeparam name="T2">请求对象类型</typeparam>
/// <param name="url">请求链接</param>
/// <param name="obj">请求对象数据</param>
/// <returns>请求返回的目标对象</returns>
public
static
async
Task
<
T
>
PostObjectAsync
<
T
,
T2
>(
string
url
,
T2
obj
)
{
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>
/// 使用Get返回异步请求直接返回对象
/// </summary>
/// <typeparam name="T">请求对象类型</typeparam>
/// <param name="url">请求链接</param>
/// <returns>返回请求的对象</returns>
public
static
async
Task
<
T
>
GetObjectAsync
<
T
>(
string
url
)
{
string
responseBody
=
await
GetAsync
(
url
);
//请求当前账户的信息
return
JsonConvert
.
DeserializeObject
<
T
>(
responseBody
);
//把收到的字符串序列化
}
/// <summary>
/// 获取图片
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public
static
async
Task
<
MemoryStream
>
GetImage
(
string
url
)
{
try
{
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>
/// 上传图片
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="requestUri"></param>
/// <param name="path"></param>
/// <param name="fileName"></param>
/// <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
);
}
}
}
}
VIZ.Package.Module/Resource/MediaResource/Controller/Model/fileListResult.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Package.Module
{
public
class
fileListResult
{
/// <summary>
/// 状态码:0-成功
/// </summary>
public
string
errCode
{
get
;
set
;
}
/// <summary>
/// 状态描述:0-成功
/// </summary>
public
string
message
{
get
;
set
;
}
/// <summary>
/// 状态描述:0-success
/// </summary>
public
string
status
{
get
;
set
;
}
/// <summary>
/// 根目录
/// </summary>
public
string
rootPath
{
get
;
set
;
}
/// <summary>
/// 设置文件信息
/// </summary>
public
List
<
ms
>
masterData
=
new
List
<
ms
>();
}
}
VIZ.Package.Module/Resource/MediaResource/Controller/Model/fileUploadResult.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Package.Module
{
/// <summary>
/// 文件上传的实体对象
/// </summary>
public
class
fileUploadResult
{
/// <summary>
/// 状态码:0-成功
/// </summary>
public
string
errCode
{
get
;
set
;
}
/// <summary>
/// 状态描述:0-成功
/// </summary>
public
string
message
{
get
;
set
;
}
/// <summary>
/// 状态描述:0-success
/// </summary>
public
string
status
{
get
;
set
;
}
/// <summary>
/// 设置文件信息
/// </summary>
public
ms
masterData
=
new
ms
();
}
}
VIZ.Package.Module/Resource/MediaResource/Controller/Model/ms.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Package.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
;
set
;
}
public
List
<
ms
>
m
=
new
List
<
ms
>();
}
}
VIZ.Package.Module/Resource/MediaResource/Controller/ThumbnailHelper.cs
0 → 100644
View file @
b33a0d17
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Package.Module
{
public
class
ThumbnailHelper
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
ThumbnailHelper
));
/// <summary>
/// 生成高清缩略图片方法
/// </summary>
/// <param name="image"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public
static
Image
GetThumbnail
(
Image
image
,
int
width
,
int
height
)
{
Bitmap
bmp
=
new
Bitmap
(
width
,
height
);
//从Bitmap创建一个System.Drawing.Graphics
System
.
Drawing
.
Graphics
gr
=
System
.
Drawing
.
Graphics
.
FromImage
(
bmp
);
//设置
gr
.
SmoothingMode
=
System
.
Drawing
.
Drawing2D
.
SmoothingMode
.
HighQuality
;
//下面这个也设成高质量
gr
.
CompositingQuality
=
System
.
Drawing
.
Drawing2D
.
CompositingQuality
.
HighQuality
;
//下面这个设成High
gr
.
InterpolationMode
=
System
.
Drawing
.
Drawing2D
.
InterpolationMode
.
HighQualityBicubic
;
//把原始图像绘制成上面所设置宽高的缩小图
System
.
Drawing
.
Rectangle
rectDestination
=
new
Rectangle
(
0
,
0
,
width
,
height
);
gr
.
DrawImage
(
image
,
rectDestination
,
0
,
0
,
image
.
Width
,
image
.
Height
,
GraphicsUnit
.
Pixel
);
return
bmp
;
}
/// <summary>
/// 获取图片
/// </summary>
/// <param name="path"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <returns></returns>
public
static
Image
GetImage
(
string
path
,
int
width
,
int
height
)
{
try
{
FileStream
fs
=
new
FileStream
(
path
,
FileMode
.
Open
,
FileAccess
.
Read
,
FileShare
.
ReadWrite
);
Image
result
=
Image
.
FromStream
(
fs
);
fs
.
Close
();
result
=
GetThumbnail
(
result
,
width
,
height
);
return
result
;
}
catch
(
Exception
e
)
{
return
null
;
}
}
#
region
---
图片文件检测
public
static
Boolean
IsImage
(
string
path
)
{
try
{
if
(
IsImageByName
(
path
))
{
System
.
Drawing
.
Image
img
=
System
.
Drawing
.
Image
.
FromFile
(
path
);
return
true
;
}
return
false
;
}
catch
(
Exception
e
)
{
return
false
;
}
}
/// <summary>
/// 根据名称判断是否为图片
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
public
static
Boolean
IsImageByName
(
string
name
)
{
try
{
if
(
name
==
null
)
return
false
;
int
pos
=
name
.
LastIndexOf
(
"."
);
if
(
name
.
Length
-
pos
-
1
<
3
)
return
false
;
string
ext
=
name
.
Substring
(
pos
+
1
,
name
.
Length
-
pos
-
1
);
string
[]
imge
=
{
"jpg"
,
"jpeg"
,
"png"
,
"gif"
,
"bmp"
,
"TIFF"
,
"tif"
};
return
IsInIgnoreCase
(
ext
,
imge
);
}
catch
(
Exception
e
)
{
return
false
;
}
}
/// <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
;
IEnumerable
<
string
>
en
=
list
.
Where
(
i
=>
string
.
Compare
(
i
,
source
,
StringComparison
.
OrdinalIgnoreCase
)
==
0
);
return
en
.
Count
()
==
0
?
false
:
true
;
}
/// <summary>
/// 读取图片文件
/// </summary>
/// <param name="path">图片文件路径</param>
/// <returns>图片文件</returns>
private
Bitmap
ReadImageFile
(
String
path
)
{
Bitmap
bitmap
=
null
;
try
{
FileStream
fileStream
=
File
.
OpenRead
(
path
);
Int32
filelength
=
0
;
filelength
=
(
int
)
fileStream
.
Length
;
Byte
[]
image
=
new
Byte
[
filelength
];
fileStream
.
Read
(
image
,
0
,
filelength
);
System
.
Drawing
.
Image
result
=
System
.
Drawing
.
Image
.
FromStream
(
fileStream
);
fileStream
.
Close
();
bitmap
=
new
Bitmap
(
result
);
}
catch
(
Exception
ex
)
{
// 异常输出
}
return
bitmap
;
}
/// <summary>
/// 是否是视频
/// </summary>
/// <param name="filePath"></param>
/// <returns></returns>
public
static
bool
IsVideo
(
string
filePath
)
{
bool
isVideo
=
false
;
string
fileName
=
filePath
;
IList
<
string
>
formateList
=
new
List
<
string
>
{
"avi"
,
"flv"
,
"mpg"
,
"mpeg"
,
"mpe"
,
"m1v"
,
"m2v"
,
"mpv2"
,
"mp2v"
,
"dat"
,
"ts"
,
"tp"
,
"tpr"
,
"pva"
,
"pss"
,
"mp4"
,
"m4v"
,
"m4p"
,
"m4b"
,
"3gp"
,
"3gpp"
,
"3g2"
,
"3gp2"
,
"ogg"
,
"mov"
,
"qt"
,
"amr"
,
"rm"
,
"ram"
,
"rmvb"
,
"rpm"
};
string
[]
Namesuffix
=
fileName
.
Split
(
'.'
);
if
(
Namesuffix
.
Length
>
1
)
{
if
(
formateList
.
Contains
(
Namesuffix
[
1
]))
{
isVideo
=
true
;
}
}
return
isVideo
;
}
/// <summary>
/// 从完整路径中查找文件或文件夹名称
/// </summary>
/// <param name="path">完整路径</param>
/// <returns></returns>
public
static
string
GetFileFolderName
(
string
path
)
{
// 如果没有路径,则返回空
if
(
string
.
IsNullOrEmpty
(
path
))
return
string
.
Empty
;
// 使所有斜杠成反斜杠
var
normalizedPath
=
path
.
Replace
(
'/'
,
'\\'
);
// 找到最后一个反斜杠就是路径
var
lastIndex
=
normalizedPath
.
LastIndexOf
(
'\\'
);
// 如果找不到反斜线,则返回路径本身
if
(
lastIndex
<=
0
)
return
path
;
// 最后一个反斜杠后返回名称
return
path
.
Substring
(
lastIndex
+
1
);
}
#
endregion
}
}
VIZ.Package.Module/Resource/MediaResource/View/CreateFolder.xaml
0 → 100644
View file @
b33a0d17
<UserControl x:Class="VIZ.Package.Module.CreateFolder"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
d:DataContext="{d:DesignInstance Type=local:CreateFolderViewModel}"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="80"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="文件名:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<TextBox Text="{Binding Path=FolderName}" Grid.Column="1" VerticalAlignment="Center" VerticalContentAlignment="Center"
AcceptsReturn="False" TextWrapping="NoWrap" Height="30" Margin="10,0,10,0"></TextBox>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="确定" Width="80" Height="30" Margin="10" Command="{Binding EnterCommand}"></Button>
<Button Content="取消" Width="80" Height="30" Margin="10" Command="{Binding CancelCommand}"></Button>
</StackPanel>
</Grid>
</UserControl>
VIZ.Package.Module/Resource/MediaResource/View/CreateFolder.xaml.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
using
VIZ.Framework.Core
;
namespace
VIZ.Package.Module
{
/// <summary>
/// Interaction logic for CreateFolder.xaml
/// </summary>
public
partial
class
CreateFolder
:
UserControl
{
public
CreateFolder
()
{
InitializeComponent
();
WPFHelper
.
BindingViewModel
(
this
,
new
CreateFolderViewModel
());
}
}
}
VIZ.Package.Module/Resource/MediaResource/View/CreateFolderWindow.xaml
0 → 100644
View file @
b33a0d17
<dx:ThemedWindow
x:Class="VIZ.Package.Module.CreateFolderWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:module="clr-namespace:VIZ.Package.Module"
Title="创建文件夹" Height="240" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None" >
<Grid>
<module:CreateFolder x:Name="createFolderView"></module:CreateFolder>
</Grid>
</dx:ThemedWindow>
VIZ.Package.Module/Resource/MediaResource/View/CreateFolderWindow.xaml.cs
0 → 100644
View file @
b33a0d17
using
DevExpress.Xpf.Core
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Shapes
;
namespace
VIZ.Package.Module
{
/// <summary>
/// Interaction logic for CreateFolderWindow.xaml
/// </summary>
public
partial
class
CreateFolderWindow
:
ThemedWindow
{
public
CreateFolderWindow
()
{
InitializeComponent
();
}
}
}
VIZ.Package.Module/Resource/MediaResource/View/MediaResourcePanel.xaml
0 → 100644
View file @
b33a0d17
This diff is collapsed.
Click to expand it.
VIZ.Package.Module/Resource/MediaResource/View/MediaResourcePanel.xaml.cs
0 → 100644
View file @
b33a0d17
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Windows
;
using
System.Windows.Controls
;
using
System.Windows.Data
;
using
System.Windows.Documents
;
using
System.Windows.Input
;
using
System.Windows.Media
;
using
System.Windows.Media.Imaging
;
using
System.Windows.Navigation
;
using
System.Windows.Shapes
;
using
VIZ.Framework.Core
;
namespace
VIZ.Package.Module
{
/// <summary>
/// Interaction logic for MediaResourcePanel.xaml
/// </summary>
public
partial
class
MediaResourcePanel
:
UserControl
{
public
MediaResourcePanel
()
{
InitializeComponent
();
WPFHelper
.
BindingViewModel
(
this
,
new
MediaResourcePanelViewModel
());
}
#
region
FolderContextMenu
--
文件夹右键菜单
/// <summary>
/// 文件夹右键菜单
/// </summary>
public
ContextMenu
FolderContextMenu
{
get
{
return
(
ContextMenu
)
GetValue
(
FolderContextMenuProperty
);
}
set
{
SetValue
(
FolderContextMenuProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for FolderContextMenu. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
FolderContextMenuProperty
=
DependencyProperty
.
Register
(
"FolderContextMenu"
,
typeof
(
ContextMenu
),
typeof
(
MediaResourcePanel
),
new
PropertyMetadata
(
null
));
#
endregion
#
region
FileContextMenu
--
文件右键菜单
/// <summary>
/// 文件右键菜单
/// </summary>
public
ContextMenu
FileContextMenu
{
get
{
return
(
ContextMenu
)
GetValue
(
FileContextMenuProperty
);
}
set
{
SetValue
(
FileContextMenuProperty
,
value
);
}
}
/// <summary>
/// Using a DependencyProperty as the backing store for FileContextMenu. This enables animation, styling, binding, etc...
/// </summary>
public
static
readonly
DependencyProperty
FileContextMenuProperty
=
DependencyProperty
.
Register
(
"FileContextMenu"
,
typeof
(
ContextMenu
),
typeof
(
MediaResourcePanel
),
new
PropertyMetadata
(
null
));
#
endregion
}
}
VIZ.Package.Module/Resource/MediaResource/View/MediaResourceView.xaml
View file @
b33a0d17
...
@@ -4,10 +4,32 @@
...
@@ -4,10 +4,32 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:local="clr-namespace:VIZ.Package.Module"
mc:Ignorable="d"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<TextBlock Text="媒资库" VerticalAlignment="Center" HorizontalAlignment="Center"
<Grid Background="Transparent">
FontSize="36" Foreground="Red"></TextBlock>
<!-- 媒体资源面板 -->
<local:MediaResourcePanel>
<local:MediaResourcePanel.FolderContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFolderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="创建文件夹" Command="{Binding Path=PlacementTarget.DataContext.CreateFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除文件夹" Command="{Binding Path=PlacementTarget.DataContext.DeleteFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="移入文件夹" Command="{Binding Path=PlacementTarget.DataContext.MoveFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</local:MediaResourcePanel.FolderContextMenu>
<local:MediaResourcePanel.FileContextMenu>
<ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="添加文件" Command="{Binding Path=PlacementTarget.DataContext.CreateFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除文件" Command="{Binding Path=PlacementTarget.DataContext.DeleteFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="移动文件" Command="{Binding Path=PlacementTarget.DataContext.MoveFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<!--<Separator/>-->
</ContextMenu>
</local:MediaResourcePanel.FileContextMenu>
</local:MediaResourcePanel>
</Grid>
</Grid>
</UserControl>
</UserControl>
\ No newline at end of file
VIZ.Package.Module/Resource/MediaResource/View/MediaResourceView.xaml.cs
View file @
b33a0d17
...
@@ -24,8 +24,8 @@ namespace VIZ.Package.Module
...
@@ -24,8 +24,8 @@ namespace VIZ.Package.Module
public
MediaResourceView
()
public
MediaResourceView
()
{
{
InitializeComponent
();
InitializeComponent
();
WPFHelper
.
BindingViewModel
(
this
,
new
MediaResourceViewModel
());
WPFHelper
.
BindingViewModel
(
this
,
new
MediaResourceViewModel
());
}
}
}
}
}
}
VIZ.Package.Module/Resource/MediaResource/ViewModel/CreateFolderViewModel.cs
0 → 100644
View file @
b33a0d17
using
DevExpress.Xpf.Core
;
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
namespace
VIZ.Package.Module
{
public
class
CreateFolderViewModel
:
ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private
static
readonly
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
CreateFolderViewModel
));
/// <summary>
/// 初始化
/// </summary>
public
CreateFolderViewModel
()
{
EnterCommand
=
new
VCommand
(
Enter
);
CancelCommand
=
new
VCommand
(
Cancel
);
}
private
string
folderName
;
/// <summary>
/// 文件夹名称
/// </summary>
public
string
FolderName
{
get
{
return
folderName
;
}
set
{
folderName
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
FolderName
));
}
}
private
bool
isEnter
;
/// <summary>
/// 是否确定
/// </summary>
public
bool
IsEnter
{
get
{
return
isEnter
;
}
set
{
isEnter
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
IsEnter
));
}
}
public
VCommand
EnterCommand
{
get
;
set
;
}
public
VCommand
CancelCommand
{
get
;
set
;
}
/// <summary>
/// 确定
/// </summary>
private
void
Enter
()
{
if
(
string
.
IsNullOrWhiteSpace
(
this
.
FolderName
))
{
DXMessageBox
.
Show
(
"请输入文件名"
);
return
;
}
this
.
IsEnter
=
true
;
this
.
GetWindow
()?.
Close
();
}
/// <summary>
/// 取消
/// </summary>
private
void
Cancel
()
{
this
.
IsEnter
=
false
;
this
.
GetWindow
()?.
Close
();
}
}
}
VIZ.Package.Module/Resource/MediaResource/ViewModel/MediaResourcePanelViewModel.cs
0 → 100644
View file @
b33a0d17
This diff is collapsed.
Click to expand it.
VIZ.Package.Module/Resource/MediaResource/ViewModel/MediaResourceViewModel.cs
View file @
b33a0d17
using
System
;
using
DevExpress.Mvvm.Xpf
;
using
DevExpress.Xpf.Core
;
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
using
System.Configuration
;
using
System.Drawing
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Threading.Tasks
;
using
System.Windows
;
using
System.Windows.Forms
;
using
VIZ.Framework.Core
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain
;
namespace
VIZ.Package.Module
namespace
VIZ.Package.Module
{
{
/// <summary>
/// <summary>
/// 媒体资源视图模型
/// 媒体资源视图模型
/// </summary>
/// </summary>
public
class
MediaResourceViewModel
:
ViewModelBase
public
class
MediaResourceViewModel
:
MediaResourcePanelViewModel
{
{
}
}
}
}
VIZ.Package.Module/Resource/VedioImage/Vedio.jpeg
0 → 100644
View file @
b33a0d17
13.3 KB
VIZ.Package.Module/Setup/AppSetup_InitMedia.cs
0 → 100644
View file @
b33a0d17
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Module
;
using
VIZ.Package.Domain
;
namespace
VIZ.Package.Module
{
/// <summary>
/// 媒体库配置文件
/// </summary>
public
class
AppSetup_InitMedia
:
AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
AppSetup_InitMedia
));
public
override
string
Detail
{
get
;
}
=
"应用程序启动 -- 初始化媒体资源库"
;
public
override
bool
Setup
(
AppSetupContext
context
)
{
ApplicationDomainEx
.
MediaConfig
=
new
Storage
.
ConfigContext
();
this
.
LoadConfig
();
return
true
;
}
/// <summary>
/// 加载插件配置
/// </summary>
private
void
LoadConfig
()
{
string
folder
=
System
.
IO
.
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"config"
);
if
(!
System
.
IO
.
Directory
.
Exists
(
folder
))
{
System
.
IO
.
Directory
.
CreateDirectory
(
folder
);
}
string
path
=
System
.
IO
.
Path
.
Combine
(
folder
,
"MediaResouce.config"
);
ApplicationDomainEx
.
MediaConfig
.
LoadMediaConfig
(
path
);
}
public
override
void
Shutdown
(
AppSetupContext
context
)
{
}
}
}
VIZ.Package.Module/VIZ.Package.Module.csproj
View file @
b33a0d17
...
@@ -66,6 +66,9 @@
...
@@ -66,6 +66,9 @@
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<Reference Include="log4net, Version=2.0.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
<HintPath>..\packages\log4net.2.0.14\lib\net45\log4net.dll</HintPath>
</Reference>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Data" />
...
@@ -180,8 +183,26 @@
...
@@ -180,8 +183,26 @@
</Compile>
</Compile>
<Compile Include="Resource\GHResource\Core\GHResourceFileDoubleClickEventArgs.cs" />
<Compile Include="Resource\GHResource\Core\GHResourceFileDoubleClickEventArgs.cs" />
<Compile Include="Resource\GHResource\Core\GHResourceSelectedFileChangedEventArgs.cs" />
<Compile Include="Resource\GHResource\Core\GHResourceSelectedFileChangedEventArgs.cs" />
<Compile Include="Resource\MediaResource\Controller\IMediaResourceFileSupport.cs" />
<Compile Include="Resource\MediaResource\Controller\MediaResourceFileController.cs" />
<Compile Include="Resource\MediaResource\Controller\MediaResourceFileService.cs" />
<Compile Include="Resource\MediaResource\Controller\Model\fileListResult.cs" />
<Compile Include="Resource\MediaResource\Controller\Model\fileUploadResult.cs" />
<Compile Include="Resource\MediaResource\Controller\Model\ms.cs" />
<Compile Include="Resource\MediaResource\Controller\ThumbnailHelper.cs" />
<Compile Include="Resource\MediaResource\MediaResourcePluginLifeCycle.cs" />
<Compile Include="Resource\MediaResource\MediaResourcePluginLifeCycle.cs" />
<Compile Include="Resource\MediaResource\ViewModel\CreateFolderViewModel.cs" />
<Compile Include="Resource\MediaResource\ViewModel\MediaResourcePanelViewModel.cs" />
<Compile Include="Resource\MediaResource\ViewModel\MediaResourceViewModel.cs" />
<Compile Include="Resource\MediaResource\ViewModel\MediaResourceViewModel.cs" />
<Compile Include="Resource\MediaResource\View\CreateFolder.xaml.cs">
<DependentUpon>CreateFolder.xaml</DependentUpon>
</Compile>
<Compile Include="Resource\MediaResource\View\CreateFolderWindow.xaml.cs">
<DependentUpon>CreateFolderWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Resource\MediaResource\View\MediaResourcePanel.xaml.cs">
<DependentUpon>MediaResourcePanel.xaml</DependentUpon>
</Compile>
<Compile Include="Resource\MediaResource\View\MediaResourceView.xaml.cs">
<Compile Include="Resource\MediaResource\View\MediaResourceView.xaml.cs">
<DependentUpon>MediaResourceView.xaml</DependentUpon>
<DependentUpon>MediaResourceView.xaml</DependentUpon>
</Compile>
</Compile>
...
@@ -260,6 +281,7 @@
...
@@ -260,6 +281,7 @@
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml.cs">
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\TextListCellEdit.xaml.cs">
<DependentUpon>TextListCellEdit.xaml</DependentUpon>
<DependentUpon>TextListCellEdit.xaml</DependentUpon>
</Compile>
</Compile>
<Compile Include="Setup\AppSetup_InitMedia.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
...
@@ -355,6 +377,18 @@
...
@@ -355,6 +377,18 @@
<SubType>Designer</SubType>
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<Generator>MSBuild:Compile</Generator>
</Page>
</Page>
<Page Include="Resource\MediaResource\View\CreateFolder.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resource\MediaResource\View\CreateFolderWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resource\MediaResource\View\MediaResourcePanel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resource\MediaResource\View\MediaResourceView.xaml">
<Page Include="Resource\MediaResource\View\MediaResourceView.xaml">
<SubType>Designer</SubType>
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<Generator>MSBuild:Compile</Generator>
...
@@ -474,5 +508,10 @@
...
@@ -474,5 +508,10 @@
<Name>VIZ.Package.Storage</Name>
<Name>VIZ.Package.Storage</Name>
</ProjectReference>
</ProjectReference>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<None Include="Resource\VedioImage\Vedio.jpeg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
</Project>
\ No newline at end of file
VIZ.Package.Module/packages.config
View file @
b33a0d17
...
@@ -2,4 +2,5 @@
...
@@ -2,4 +2,5 @@
<
packages
>
<
packages
>
<
package
id
=
"LiteDB"
version
=
"5.0.15"
targetFramework
=
"net48"
/>
<
package
id
=
"LiteDB"
version
=
"5.0.15"
targetFramework
=
"net48"
/>
<
package
id
=
"log4net"
version
=
"2.0.14"
targetFramework
=
"net48"
/>
<
package
id
=
"log4net"
version
=
"2.0.14"
targetFramework
=
"net48"
/>
<
package
id
=
"Newtonsoft.Json"
version
=
"13.0.1"
targetFramework
=
"net48"
/>
</
packages
>
</
packages
>
\ No newline at end of file
VIZ.Package.Storage/Entity/Config/ConfigContext.cs
0 → 100644
View file @
b33a0d17
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Configuration
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Package.Storage
{
/// <summary>
/// 媒体库配置文件
/// </summary>
public
class
ConfigContext
{
/// <summary>
/// 日志
/// </summary>
private
readonly
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
ConfigContext
));
public
Configuration
configuration
{
get
;
set
;
}
/// <summary>
/// 加载插件配置
/// </summary>
/// <param name="path">文件路径</param>
public
void
LoadMediaConfig
(
string
path
)
{
if
(
File
.
Exists
(
path
)
==
false
)
{
{
string
msg
=
string
.
Format
(
"{0}路径下的文件未找到 "
,
path
);
throw
new
FileNotFoundException
(
msg
);
}
}
try
{
ExeConfigurationFileMap
configFile
=
new
ExeConfigurationFileMap
();
configFile
.
ExeConfigFilename
=
path
;
configuration
=
ConfigurationManager
.
OpenMappedExeConfiguration
(
configFile
,
ConfigurationUserLevel
.
None
);
}
catch
(
Exception
ex
)
{
throw
new
Exception
(
ex
.
Message
);
}
}
}
}
VIZ.Package.Storage/VIZ.Package.Storage.csproj
View file @
b33a0d17
...
@@ -67,6 +67,7 @@
...
@@ -67,6 +67,7 @@
<Reference Include="System.Xml" />
<Reference Include="System.Xml" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="Entity\Config\ConfigContext.cs" />
<Compile Include="Entity\Conn\ConnEntity.cs" />
<Compile Include="Entity\Conn\ConnEntity.cs" />
<Compile Include="Entity\Conn\ConnGroupEntity.cs" />
<Compile Include="Entity\Conn\ConnGroupEntity.cs" />
<Compile Include="Entity\ControlObject\ControlDynamicFieldEntity.cs" />
<Compile Include="Entity\ControlObject\ControlDynamicFieldEntity.cs" />
...
...
VIZ.Package/App.xaml.cs
View file @
b33a0d17
...
@@ -26,6 +26,9 @@ namespace VIZ.Package
...
@@ -26,6 +26,9 @@ namespace VIZ.Package
// 初始化LiteDB
// 初始化LiteDB
AppSetup
.
AppendSetup
(
new
AppSetup_InitLiteDB
());
AppSetup
.
AppendSetup
(
new
AppSetup_InitLiteDB
());
//初始化媒体资源配置文件
AppSetup
.
AppendSetup
(
new
AppSetup_InitMedia
());
// 执行启动流程
// 执行启动流程
AppSetupContext
context
=
AppSetup
.
Setup
();
AppSetupContext
context
=
AppSetup
.
Setup
();
...
...
VIZ.Package/VIZ.Package.csproj
View file @
b33a0d17
...
@@ -130,6 +130,9 @@
...
@@ -130,6 +130,9 @@
<None Include="config\log.config">
<None Include="config\log.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</None>
<None Include="config\MediaResouce.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<Generator>SettingsSingleFileGenerator</Generator>
...
...
VIZ.Package/config/MediaResouce.config
0 → 100644
View file @
b33a0d17
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
configuration
>
<
appSettings
>
<
add
key
=
"url"
value
=
"http://localhost:9000/api/home/"
/>
<
add
key
=
"MediaFilter"
value
=
"(*.jpg,*.png,*.jpeg,*.bmp,*.gif,*.avi,*.mp4)|*.jgp;*.png;*.jpeg;*.bmp;*.gif;*.avi;*.mp4"
/>
</
appSettings
>
</
configuration
>
\ 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