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
8265a1e8
Commit
8265a1e8
authored
Feb 15, 2023
by
liulongfei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页加载逻辑调整
parent
081e5a6a
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
599 additions
and
143 deletions
+599
-143
VIZ.Package.Domain/ApplicationDomainEx.cs
+5
-0
VIZ.Package.Domain/Model/ControlObject/ControlObjectModel.cs
+14
-0
VIZ.Package.Domain/Model/Page/PageModelBase.cs
+1
-1
VIZ.Package.Module/ControlObject/FieldTree/ViewModel/FieldTreeViewModel.cs
+5
-5
VIZ.Package.Module/Main/Service/IMainViewService.cs
+6
-0
VIZ.Package.Module/Main/View/MainLoadingWindow.xaml
+17
-0
VIZ.Package.Module/Main/View/MainLoadingWindow.xaml.cs
+36
-0
VIZ.Package.Module/Main/View/MainTopView.xaml
+1
-1
VIZ.Package.Module/Main/View/MainView.xaml
+5
-1
VIZ.Package.Module/Main/ViewModel/MainViewModel.cs
+31
-0
VIZ.Package.Module/Page/Group/ViewModel/PageGroupViewModel.cs
+47
-9
VIZ.Package.Module/Page/Templage/Service/IPageTemplateService.cs
+2
-2
VIZ.Package.Module/Page/Templage/ViewModel/PageTemplateViewModel.cs
+93
-41
VIZ.Package.Module/Resource/GHResource/ViewModel/GHSceneViewModel.cs
+3
-1
VIZ.Package.Module/VIZ.Package.Module.csproj
+7
-0
VIZ.Package.Service/DB/ControlObject/ControlObjectService.cs
+74
-27
VIZ.Package.Service/VIZ.Package.Service.csproj
+3
-0
VIZ.Package.Service/Viz/VizCommandControlObjectService.cs
+98
-54
VIZ.Package.Service/Viz/VizControlObjectDownloadService.cs
+91
-0
VIZ.Package.Storage/Entity/ControlObject/ControlObjectEntity.cs
+46
-0
VIZ.Package.Storage/ProjectDbContext.cs
+13
-1
VIZ.Package.Storage/VIZ.Package.Storage.csproj
+1
-0
No files found.
VIZ.Package.Domain/ApplicationDomainEx.cs
View file @
8265a1e8
...
...
@@ -36,6 +36,11 @@ namespace VIZ.Package.Domain
public
static
Type
MainWindowType
{
get
;
set
;
}
/// <summary>
/// 主等待窗口
/// </summary>
public
static
Window
MainLoadingWindow
{
get
;
set
;
}
/// <summary>
/// 字段编辑窗口
/// </summary>
public
static
Window
FieldEditWindow
{
get
;
set
;
}
...
...
VIZ.Package.Domain/Model/ControlObject/ControlObjectModel.cs
View file @
8265a1e8
...
...
@@ -69,6 +69,20 @@ namespace VIZ.Package.Domain
#
endregion
#
region
FieldDetails
--
字段描述
private
string
fieldDetails
;
/// <summary>
/// 字段描述
/// </summary>
public
string
FieldDetails
{
get
{
return
fieldDetails
;
}
set
{
fieldDetails
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
FieldDetails
));
}
}
#
endregion
#
region
FieldNodes
--
字段节点集合
private
List
<
ControlFieldNodeModel
>
fieldNodes
=
new
List
<
ControlFieldNodeModel
>();
...
...
VIZ.Package.Domain/Model/Page/PageModelBase.cs
View file @
8265a1e8
...
...
@@ -72,7 +72,7 @@ namespace VIZ.Package.Domain
#
region
Layer
--
包装层
private
VizLayer
layer
;
private
VizLayer
layer
=
VizLayer
.
MAIN_LAYER
;
/// <summary>
/// 包装层
/// </summary>
...
...
VIZ.Package.Module/ControlObject/FieldTree/ViewModel/FieldTreeViewModel.cs
View file @
8265a1e8
...
...
@@ -137,13 +137,13 @@ namespace VIZ.Package.Module
ThreadHelper
.
SafeRun
(
action
:
()
=>
{
// 获取控制对象
ControlObjectModel
controlObject
=
this
.
vizCommandControlObjectService
.
GetControlObject
(
ApplicationDomainEx
.
PreviewConn
);
// 从本地数据库获取控制对象
ControlObjectEntity
entity
=
this
.
controlObjectService
.
GetControlObject
(
msg
.
Page
)?.
FirstOrDefault
();
ControlObjectModel
controlObject
=
new
ControlObjectModel
();
this
.
vizCommandControlObjectService
.
UpdateControlObjectModel
(
controlObject
,
entity
);
// 从本地数据库中获取字段
数据
// 从本地数据库中获取字段
值
List
<
ControlFieldEntity
>
fields
=
this
.
controlObjectService
.
GetControlFields
(
msg
.
Page
);
// 从本地数据库中更新值
controlObjectService
.
UpdateControlFieldValue
(
controlObject
.
AllFiledNodes
,
fields
);
WPFHelper
.
Invoke
(()
=>
...
...
VIZ.Package.Module/Main/Service/IMainViewService.cs
View file @
8265a1e8
...
...
@@ -21,5 +21,11 @@ namespace VIZ.Package.Module
/// 加载布局
/// </summary>
void
LoadLayout
();
/// <summary>
/// 设置主视图是否可用
/// </summary>
/// <param name="isEnabled">是否可用</param>
void
SetIsEnabled
(
bool
isEnabled
);
}
}
VIZ.Package.Module/Main/View/MainLoadingWindow.xaml
0 → 100644
View file @
8265a1e8
<Window x:Class="VIZ.Package.Module.MainLoadingWindow"
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:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
ShowInTaskbar="False"
mc:Ignorable="d" AllowsTransparency="True" Background="{x:Null}"
WindowStyle="None" WindowStartupLocation="CenterScreen"
Title="Loading" Height="140" Width="300">
<Grid>
<dx:WaitIndicator DeferedVisibility="True" Content="Loading..." />
</Grid>
</Window>
VIZ.Package.Module/Main/View/MainLoadingWindow.xaml.cs
0 → 100644
View file @
8265a1e8
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 MainLoadingWindow.xaml
/// </summary>
public
partial
class
MainLoadingWindow
:
Window
{
public
MainLoadingWindow
()
{
InitializeComponent
();
this
.
Closing
+=
MainLoadingWindow_Closing
;
}
private
void
MainLoadingWindow_Closing
(
object
sender
,
System
.
ComponentModel
.
CancelEventArgs
e
)
{
e
.
Cancel
=
true
;
this
.
Visibility
=
Visibility
.
Collapsed
;
}
}
}
VIZ.Package.Module/Main/View/MainTopView.xaml
View file @
8265a1e8
...
...
@@ -35,7 +35,7 @@
<Image Source="/VIZ.Package;component/logo.ico" Margin="2,5,2,2"
VerticalAlignment="Center"></Image>
<dxb:MainMenuControl Caption="MainMenu" VerticalAlignment="Center" Margin="
10
,0,0,0">
<dxb:MainMenuControl Caption="MainMenu" VerticalAlignment="Center" Margin="
5
,0,0,0">
<dxb:MainMenuControl.Resources>
<Style TargetType="dxb:BarSubItem">
<Setter Property="Margin" Value="0,0,3,0"></Setter>
...
...
VIZ.Package.Module/Main/View/MainView.xaml
View file @
8265a1e8
...
...
@@ -12,12 +12,15 @@
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:plugin="clr-namespace:VIZ.Package.Plugin;assembly=VIZ.Package.Plugin"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:local="clr-namespace:VIZ.Package.Module"
IsEnabled="{Binding Path=IsEnabled}"
d:DataContext="{d:DesignInstance Type=local:MainViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<fcore:Bool2BoolConverter x:Key="Bool2BoolConverter"></fcore:Bool2BoolConverter>
<DataTemplate DataType="{x:Type domain:PluginInfo}">
<plugin:PluginLoader ViewType="{Binding ViewType,Mode=OneWay}"></plugin:PluginLoader>
</DataTemplate>
...
...
@@ -55,4 +58,5 @@
AutoHideExpandMode="MouseDown">
<dxdo:LayoutGroup ItemsSource="{Binding ItemsSource}"></dxdo:LayoutGroup>
</dxdo:DockLayoutManager>
</UserControl>
VIZ.Package.Module/Main/ViewModel/MainViewModel.cs
View file @
8265a1e8
...
...
@@ -66,6 +66,20 @@ namespace VIZ.Package.Module
#
endregion
#
region
IsEnabled
--
是否可用
private
bool
isEnabled
=
true
;
/// <summary>
/// 是否可用
/// </summary>
public
bool
IsEnabled
{
get
{
return
isEnabled
;
}
set
{
isEnabled
=
value
;
this
.
RaisePropertyChanged
(
nameof
(
IsEnabled
));
}
}
#
endregion
// ============================================================
// Command
// ============================================================
...
...
@@ -177,6 +191,23 @@ namespace VIZ.Package.Module
view
.
dockLayoutManager
.
RestoreLayoutFromXml
(
path
);
}
/// <summary>
/// 设置主视图是否可用
/// </summary>
/// <param name="isEnabled">是否可用</param>
public
void
SetIsEnabled
(
bool
isEnabled
)
{
this
.
IsEnabled
=
isEnabled
;
if
(
ApplicationDomainEx
.
MainLoadingWindow
==
null
)
{
ApplicationDomainEx
.
MainLoadingWindow
=
new
MainLoadingWindow
();
ApplicationDomainEx
.
MainLoadingWindow
.
Owner
=
ApplicationDomainEx
.
MainWindow
;
}
ApplicationDomainEx
.
MainLoadingWindow
.
Visibility
=
isEnabled
?
System
.
Windows
.
Visibility
.
Collapsed
:
System
.
Windows
.
Visibility
.
Visible
;
}
// ============================================================
// Private Function
// ============================================================
...
...
VIZ.Package.Module/Page/Group/ViewModel/PageGroupViewModel.cs
View file @
8265a1e8
...
...
@@ -362,15 +362,7 @@ namespace VIZ.Package.Module
return
;
// 获取场景模板缩略图
foreach
(
var
model
in
this
.
SelectedPageGroupModel
.
Pages
)
{
var
bitmap
=
ghService
.
GetImage
(
model
.
ThumbnailUri
);
WPFHelper
.
BeginInvoke
(()
=>
{
model
.
ThumbnailBitmap
=
bitmap
;
});
}
this
.
BeginDownLoadIamge
(
this
.
SelectedPageGroupModel
.
Pages
.
ToList
<
PageModelBase
>());
});
}
...
...
@@ -447,8 +439,16 @@ namespace VIZ.Package.Module
ConnGroupModel
conn
=
ApplicationDomainEx
.
ConnGroups
?.
FirstOrDefault
(
p
=>
p
.
IsDefault
);
page
.
ConnGroupID
=
conn
!=
null
?
conn
.
GroupID
:
Guid
.
Empty
;
// 将模板控制对象拷贝值页控制对象
this
.
controlObjectService
.
CopyControlObjects
(
template
.
TemplateID
,
page
.
PageID
);
// 将模板控制字段拷贝至页控制字段
this
.
controlObjectService
.
CopyControlFields
(
template
.
TemplateID
,
page
.
PageID
);
// 添加页
this
.
SelectedPageGroupModel
.
Pages
.
Add
(
page
);
// 获取缩略图
if
(
page
.
ThumbnailBitmap
==
null
)
{
ThreadHelper
.
SafeRun
(()
=>
...
...
@@ -495,8 +495,16 @@ namespace VIZ.Package.Module
page
.
ConnGroupID
=
this
.
SelectedPageModel
.
ConnGroupID
;
page
.
PageNum
=
this
.
SelectedPageGroupModel
.
Pages
.
Max
(
p
=>
p
.
PageNum
)
+
1
;
// 将模板控制对象拷贝值页控制对象
this
.
controlObjectService
.
CopyControlObjects
(
this
.
SelectedPageModel
.
PageID
,
page
.
PageID
);
// 将模板控制字段拷贝至页控制字段
this
.
controlObjectService
.
CopyControlFields
(
this
.
SelectedPageModel
.
PageID
,
page
.
PageID
);
// 添加页
this
.
SelectedPageGroupModel
.
Pages
.
Add
(
page
);
// 获取缩略图
if
(
page
.
ThumbnailBitmap
==
null
)
{
ThreadHelper
.
SafeRun
(()
=>
...
...
@@ -556,5 +564,35 @@ namespace VIZ.Package.Module
{
this
.
ConnGroups
=
ApplicationDomainEx
.
ConnGroups
;
}
// ======================================================================================
// Private Function
// ======================================================================================
/// <summary>
/// 开始下载图片任务
/// </summary>
/// <param name="pages">页集合</param>
private
void
BeginDownLoadIamge
(
List
<
PageModelBase
>
pages
)
{
ThreadHelper
.
SafeRun
(()
=>
{
foreach
(
PageModelBase
page
in
pages
)
{
if
(
page
.
ThumbnailBitmap
!=
null
)
continue
;
if
(
string
.
IsNullOrWhiteSpace
(
page
.
ThumbnailUri
))
continue
;
var
bitmap
=
this
.
ghService
.
GetImage
(
page
.
ThumbnailUri
);
WPFHelper
.
BeginInvoke
(()
=>
{
page
.
ThumbnailBitmap
=
bitmap
;
});
}
});
}
}
}
VIZ.Package.Module/Page/Templage/Service/IPageTemplateService.cs
View file @
8265a1e8
...
...
@@ -16,7 +16,7 @@ namespace VIZ.Package.Module
/// <summary>
/// 添加场景模板
/// </summary>
/// <param name="fileModel
">文件模型
</param>
void
AddSceneTemplate
(
GHResourceFileModel
fileModel
);
/// <param name="fileModel
s">文件模型集合
</param>
void
AddSceneTemplate
(
List
<
GHResourceFileModel
>
fileModels
);
}
}
VIZ.Package.Module/Page/Templage/ViewModel/PageTemplateViewModel.cs
View file @
8265a1e8
...
...
@@ -86,6 +86,11 @@ namespace VIZ.Package.Module
/// </summary>
private
ControlObjectService
controlObjectService
=
new
ControlObjectService
();
/// <summary>
/// Viz控制对象下载服务
/// </summary>
private
VizControlObjectDownloadService
vizControlObjectDownloadService
=
new
VizControlObjectDownloadService
();
// ======================================================================================
// Property
// ======================================================================================
...
...
@@ -296,17 +301,6 @@ namespace VIZ.Package.Module
// 场景模板
var
sceneTemplateModels
=
this
.
pageService
.
LoadPageTemplates
().
ToObservableCollection
();
// 其他模板
var
otherTemplateModels
=
new
ObservableCollection
<
PageTemplateModel
>();
// 命令模板
PageTemplateModel
cmd
=
new
PageTemplateModel
();
cmd
.
PageType
=
PageType
.
Command
;
cmd
.
Remark
=
"命令模板"
;
cmd
.
EngineType
=
EngineType
.
Viz
;
cmd
.
ThumbnailBitmap
=
VIZ
.
Package
.
Module
.
Resource
.
Properties
.
Resources
.
cmd_template
;
otherTemplateModels
.
Add
(
cmd
);
// 更新界面
WPFHelper
.
BeginInvoke
(()
=>
{
...
...
@@ -316,15 +310,7 @@ namespace VIZ.Package.Module
});
// 获取场景模板缩略图
foreach
(
var
model
in
sceneTemplateModels
)
{
var
bitmap
=
ghService
.
GetImage
(
model
.
ThumbnailUri
);
WPFHelper
.
BeginInvoke
(()
=>
{
model
.
ThumbnailBitmap
=
bitmap
;
});
}
this
.
BeginDownLoadIamge
(
sceneTemplateModels
.
ToList
<
PageModelBase
>());
});
}
...
...
@@ -356,37 +342,102 @@ namespace VIZ.Package.Module
/// <summary>
/// 添加场景模板
/// </summary>
/// <param name="fileModel
">文件模型
</param>
public
void
AddSceneTemplate
(
GHResourceFileModel
fileModel
)
/// <param name="fileModel
s">文件模型集合
</param>
public
void
AddSceneTemplate
(
List
<
GHResourceFileModel
>
fileModels
)
{
// 如果场景中已经拥有该模板,那么不处理
if
(
this
.
SceneTemplateModels
.
Any
(
p
=>
p
.
Scene
==
fileModel
.
Name
))
return
;
List
<
PageModelBase
>
list
=
new
List
<
PageModelBase
>();
PageTemplateModel
model
=
new
PageTemplateModel
();
model
.
TemplateID
=
Guid
.
NewGuid
();
model
.
Scene
=
fileModel
.
Name
;
model
.
ScenePath
=
fileModel
.
Path
;
model
.
Layer
=
VizLayer
.
MAIN_LAYER
;
model
.
PageType
=
PageType
.
Scene
;
model
.
EngineType
=
EngineType
.
Viz
;
model
.
ThumbnailUri
=
fileModel
.
Thumbnail
;
model
.
ThumbnailBitmap
=
fileModel
.
ThumbnailBitmap
;
// 获取缩略图
if
(
model
.
ThumbnailBitmap
==
null
)
foreach
(
GHResourceFileModel
fileModel
in
fileModels
)
{
// 如果场景中已经拥有该模板,那么不处理
if
(
this
.
SceneTemplateModels
.
Any
(
p
=>
p
.
Scene
==
fileModel
.
Name
))
continue
;
PageTemplateModel
model
=
new
PageTemplateModel
();
model
.
TemplateID
=
Guid
.
NewGuid
();
model
.
Scene
=
fileModel
.
Name
;
model
.
ScenePath
=
fileModel
.
Path
;
model
.
Layer
=
VizLayer
.
MAIN_LAYER
;
model
.
PageType
=
PageType
.
Scene
;
model
.
EngineType
=
EngineType
.
Viz
;
model
.
ThumbnailUri
=
fileModel
.
Thumbnail
;
model
.
ThumbnailBitmap
=
fileModel
.
ThumbnailBitmap
;
list
.
Add
(
model
);
this
.
SceneTemplateModels
.
Add
(
model
);
}
// 开始下载缩略图
this
.
BeginDownLoadIamge
(
list
);
// 开始下载控制对象
this
.
BeginDownLoadControlObject
(
list
);
}
// ======================================================================================
// Private Function
// ======================================================================================
/// <summary>
/// 开始下载图片任务
/// </summary>
/// <param name="pages">页集合</param>
private
void
BeginDownLoadIamge
(
List
<
PageModelBase
>
pages
)
{
ThreadHelper
.
SafeRun
(()
=>
{
ThreadHelper
.
SafeRun
(()
=>
foreach
(
PageModelBase
page
in
pages
)
{
var
bitmap
=
this
.
ghService
.
GetImage
(
model
.
ThumbnailUri
);
if
(
page
.
ThumbnailBitmap
!=
null
)
continue
;
if
(
string
.
IsNullOrWhiteSpace
(
page
.
ThumbnailUri
))
continue
;
var
bitmap
=
this
.
ghService
.
GetImage
(
page
.
ThumbnailUri
);
WPFHelper
.
BeginInvoke
(()
=>
{
model
.
ThumbnailBitmap
=
bitmap
;
page
.
ThumbnailBitmap
=
bitmap
;
});
}
});
}
/// <summary>
/// 开始下载控制对象
/// </summary>
/// <param name="pages">页集合</param>
private
void
BeginDownLoadControlObject
(
List
<
PageModelBase
>
pages
)
{
Task
.
Run
(()
=>
{
IMainViewService
service
=
ApplicationDomainEx
.
ServiceManager
.
GetService
<
IMainViewService
>(
ViewServiceKeys
.
MAIN_VIEW_SERVICE
);
// 设置主窗口不可用
WPFHelper
.
Invoke
(()
=>
{
service
?.
SetIsEnabled
(
false
);
});
}
this
.
SceneTemplateModels
.
Add
(
model
);
// 下载页控制对象信息
try
{
this
.
vizControlObjectDownloadService
.
Load
(
pages
);
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
);
}
finally
{
// 恢复主窗口可用
WPFHelper
.
Invoke
(()
=>
{
service
?.
SetIsEnabled
(
true
);
});
}
});
}
}
}
\ No newline at end of file
VIZ.Package.Module/Resource/GHResource/ViewModel/GHSceneViewModel.cs
View file @
8265a1e8
...
...
@@ -57,10 +57,12 @@ namespace VIZ.Package.Module
if
(
service
==
null
)
return
;
List
<
GHResourceFileModel
>
list
=
new
List
<
GHResourceFileModel
>();
foreach
(
GHResourceFileModel
file
in
this
.
SelectedFileModels
)
{
service
.
AddSceneTemplate
(
file
);
list
.
Add
(
file
);
}
service
.
AddSceneTemplate
(
list
);
}
#
endregion
...
...
VIZ.Package.Module/VIZ.Package.Module.csproj
View file @
8265a1e8
...
...
@@ -118,6 +118,9 @@
<Compile Include="ControlObject\FieldEdit\ViewModel\FieldEditViewModelBase.cs" />
<Compile Include="ControlObject\FieldTree\Service\IFieldTreeService.cs" />
<Compile Include="Log\ViewModel\VizCommandWindowModel.cs" />
<Compile Include="Main\View\MainLoadingWindow.xaml.cs">
<DependentUpon>MainLoadingWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Main\ViewModel\MainConnViewModel.cs" />
<Compile Include="Main\View\MainConnView.xaml.cs">
<DependentUpon>MainConnView.xaml</DependentUpon>
...
...
@@ -399,6 +402,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\MainLoadingWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\MainConnView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
...
...
VIZ.Package.Service/DB/ControlObject/ControlObjectService.cs
View file @
8265a1e8
...
...
@@ -21,15 +21,7 @@ namespace VIZ.Package.Service
/// <param name="fields">控制字段</param>
public
void
SaveControlFields
(
PageModelBase
pageBase
,
IList
<
ControlFieldNodeModel
>
fields
)
{
Guid
id
=
Guid
.
Empty
;
if
(
pageBase
is
PageTemplateModel
template
)
{
id
=
template
.
TemplateID
;
}
else
if
(
pageBase
is
PageModel
page
)
{
id
=
page
.
PageID
;
}
Guid
id
=
this
.
GetTemplateIdOrPageId
(
pageBase
);
ILiteCollection
<
ControlFieldEntity
>
collection
=
ApplicationDomainEx
.
ProjectDbContext
.
GetControlFiled
(
id
);
...
...
@@ -56,15 +48,7 @@ namespace VIZ.Package.Service
/// <param name="fields">控制字段</param>
public
void
SaveControlFields
(
PageModelBase
pageBase
,
IList
<
ControlFieldEntity
>
fields
)
{
Guid
id
=
Guid
.
Empty
;
if
(
pageBase
is
PageTemplateModel
template
)
{
id
=
template
.
TemplateID
;
}
else
if
(
pageBase
is
PageModel
page
)
{
id
=
page
.
PageID
;
}
Guid
id
=
this
.
GetTemplateIdOrPageId
(
pageBase
);
ILiteCollection
<
ControlFieldEntity
>
collection
=
ApplicationDomainEx
.
ProjectDbContext
.
GetControlFiled
(
id
);
collection
.
DeleteAll
();
...
...
@@ -92,15 +76,7 @@ namespace VIZ.Package.Service
/// <returns>控制字段</returns>
public
List
<
ControlFieldEntity
>
GetControlFields
(
PageModelBase
pageBase
)
{
Guid
id
=
Guid
.
Empty
;
if
(
pageBase
is
PageTemplateModel
template
)
{
id
=
template
.
TemplateID
;
}
else
if
(
pageBase
is
PageModel
page
)
{
id
=
page
.
PageID
;
}
Guid
id
=
this
.
GetTemplateIdOrPageId
(
pageBase
);
ILiteCollection
<
ControlFieldEntity
>
collection
=
ApplicationDomainEx
.
ProjectDbContext
.
GetControlFiled
(
id
);
...
...
@@ -127,5 +103,76 @@ namespace VIZ.Package.Service
model
.
Value
=
entity
.
Value
;
}
}
/// <summary>
/// 保存控制对象
/// </summary>
/// <param name="pageBase">页或模板</param>
/// <param name="obj">控制对象</param>
public
void
SaveControlObject
(
PageModelBase
pageBase
,
ControlObjectModel
obj
)
{
Guid
id
=
this
.
GetTemplateIdOrPageId
(
pageBase
);
ILiteCollection
<
ControlObjectEntity
>
collection
=
ApplicationDomainEx
.
ProjectDbContext
.
GetControlObject
(
id
);
collection
.
DeleteAll
();
ControlObjectEntity
entity
=
new
ControlObjectEntity
();
entity
.
TreeNodeName
=
obj
.
TreeNodeName
;
entity
.
TreeNodePath
=
obj
.
TreeNodePath
;
entity
.
Description
=
obj
.
Description
;
entity
.
UseAllDirectors
=
obj
.
UseAllDirectors
;
entity
.
FieldDetails
=
obj
.
FieldDetails
;
collection
.
Insert
(
entity
);
}
/// <summary>
/// 拷贝控制对象
/// </summary>
/// <param name="srcID">源ID</param>
/// <param name="distID">目标ID</param>
public
void
CopyControlObjects
(
Guid
srcID
,
Guid
distID
)
{
ILiteCollection
<
ControlObjectEntity
>
srcCollection
=
ApplicationDomainEx
.
ProjectDbContext
.
GetControlObject
(
srcID
);
ILiteCollection
<
ControlObjectEntity
>
dstCollection
=
ApplicationDomainEx
.
ProjectDbContext
.
GetControlObject
(
distID
);
dstCollection
.
DeleteAll
();
dstCollection
.
Insert
(
srcCollection
.
FindAll
());
}
/// <summary>
/// 获取控制对象
/// </summary>
/// <param name="pageBase">页基类</param>
/// <returns>控制对象</returns>
public
List
<
ControlObjectEntity
>
GetControlObject
(
PageModelBase
pageBase
)
{
Guid
id
=
this
.
GetTemplateIdOrPageId
(
pageBase
);
ILiteCollection
<
ControlObjectEntity
>
collection
=
ApplicationDomainEx
.
ProjectDbContext
.
GetControlObject
(
id
);
return
collection
.
FindAll
().
ToList
();
}
/// <summary>
/// 获取模板ID或页ID
/// </summary>
/// <param name="pageBase">页基类</param>
/// <returns>模板ID或页ID</returns>
private
Guid
GetTemplateIdOrPageId
(
PageModelBase
pageBase
)
{
Guid
id
=
Guid
.
Empty
;
if
(
pageBase
is
PageTemplateModel
template
)
{
id
=
template
.
TemplateID
;
}
else
if
(
pageBase
is
PageModel
page
)
{
id
=
page
.
PageID
;
}
return
id
;
}
}
}
VIZ.Package.Service/VIZ.Package.Service.csproj
View file @
8265a1e8
...
...
@@ -60,12 +60,14 @@
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Web" />
<Reference Include="System.Windows" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="DB\Conn\ConnService.cs" />
...
...
@@ -75,6 +77,7 @@
<Compile Include="DB\Registry\RegistryService.cs" />
<Compile Include="Logic\Plugin\PluginService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Viz\VizControlObjectDownloadService.cs" />
<Compile Include="Viz\GHResourceService.cs" />
<Compile Include="Viz\GHService.cs" />
<Compile Include="Viz\VizCommandControlObjectService.cs" />
...
...
VIZ.Package.Service/Viz/VizCommandControlObjectService.cs
View file @
8265a1e8
...
...
@@ -2,6 +2,7 @@
using
System.Collections.Generic
;
using
System.Dynamic
;
using
System.Linq
;
using
System.Reflection
;
using
System.Text
;
using
System.Threading.Tasks
;
using
System.Web.UI.WebControls
;
...
...
@@ -34,6 +35,10 @@ namespace VIZ.Package.Service
VizControlFieldType
.
font
};
// =======================================================================
// public Function
// =======================================================================
/// <summary>
/// 获取控制对象List列定义
/// </summary>
...
...
@@ -211,65 +216,32 @@ namespace VIZ.Package.Service
// Step 5. 获取第一个控制对象的字段描述
string
fieldDetails
=
this
.
GetControlObjectResult
(
conn
,
obj
.
TreeNodePath
);
obj
.
FieldDetails
=
fieldDetails
??
string
.
Empty
;
foreach
(
string
fieldDetail
in
fieldDetails
.
Split
(
'\n'
))
{
// 返回示例: BTNAME:#10245*GEOM*TEXT:text:::-1:BTNAME:single_line, location_id=#10245, location=2/3/5
if
(
string
.
IsNullOrWhiteSpace
(
fieldDetail
))
continue
;
string
[]
pars
=
fieldDetail
.
Split
(
':'
);
string
num
=
pars
[
1
].
Split
(
'*'
).
FirstOrDefault
();
ControlFieldNodeModel
node
=
new
ControlFieldNodeModel
();
node
.
FieldIdentifier
=
pars
[
0
];
node
.
Route
=
node
.
FieldIdentifier
.
Split
(
'.'
).
ToList
();
node
.
Num
=
num
;
node
.
TypeSchema
=
pars
[
2
];
node
.
Type
=
this
.
GetControlFieldType
(
node
.
TypeSchema
);
node
.
Value
=
this
.
GetControlFieldValue
(
conn
,
obj
.
TreeNodePath
,
node
.
FieldIdentifier
);
if
(
pars
.
Length
>=
7
)
{
node
.
Description
=
pars
[
6
];
}
obj
.
AllFiledNodes
.
Add
(
node
);
}
// Step 6. 根据字段FieldIdentifier构建树形结构
int
count
=
1
;
List
<
ControlFieldNodeModel
>
fieldNodes
=
obj
.
AllFiledNodes
.
Where
(
p
=>
p
.
Route
.
Count
==
count
).
ToList
();
List
<
ControlFieldNodeModel
>
parents
=
fieldNodes
;
while
(
true
)
{
++
count
;
List
<
ControlFieldNodeModel
>
items
=
obj
.
AllFiledNodes
.
Where
(
p
=>
p
.
Route
.
Count
==
count
).
ToList
();
if
(
items
.
Count
==
0
)
break
;
foreach
(
ControlFieldNodeModel
item
in
items
)
{
string
parentFieldIdentifier
=
string
.
Join
(
"."
,
item
.
Route
.
Take
(
count
-
1
));
ControlFieldNodeModel
parent
=
parents
.
FirstOrDefault
(
p
=>
p
.
FieldIdentifier
==
parentFieldIdentifier
);
if
(
parent
==
null
)
continue
;
parent
.
Items
.
Add
(
item
);
}
parents
=
items
;
}
obj
.
FieldNodes
=
fieldNodes
;
// Step 6. 更新控制对象字段
this
.
UpdateControlObjectField
(
conn
,
obj
,
obj
.
FieldDetails
,
true
);
return
obj
;
}
/// <summary>
/// 更新控制对象模型
/// </summary>
/// <param name="model">模型</param>
/// <param name="entity">实体</param>
public
void
UpdateControlObjectModel
(
ControlObjectModel
model
,
ControlObjectEntity
entity
)
{
// Step 1. 获取第一个控制对象的信息
model
.
TreeNodePath
=
entity
.
TreeNodePath
;
model
.
TreeNodeName
=
entity
.
TreeNodeName
;
model
.
Description
=
entity
.
Description
;
model
.
UseAllDirectors
=
entity
.
UseAllDirectors
;
model
.
FieldDetails
=
entity
.
FieldDetails
??
string
.
Empty
;
this
.
UpdateControlObjectField
(
null
,
model
,
model
.
FieldDetails
,
false
);
}
/// <summary>
/// 获取控制对象参数
/// </summary>
/// <param name="conn">连接</param>
...
...
@@ -408,12 +380,16 @@ namespace VIZ.Package.Service
}
}
// =======================================================================
// Private Function
// =======================================================================
/// <summary>
/// 获取控制字段类型
/// </summary>
/// <param name="type">字段类型</param>
/// <returns>控制对象字段类型</returns>
p
ublic
VizControlFieldType
GetControlFieldType
(
string
type
)
p
rivate
VizControlFieldType
GetControlFieldType
(
string
type
)
{
if
(
type
==
"text"
)
return
VizControlFieldType
.
text
;
...
...
@@ -447,5 +423,73 @@ namespace VIZ.Package.Service
return
VizControlFieldType
.
none
;
}
/// <summary>
/// 更新控制对象字段
/// </summary>
/// <param name="conn">连接</param>
/// <param name="model">控制字段模型</param>
/// <param name="fieldDetails">字段描述</param>
/// <param name="isGetValueFromViz">是否从Viz获取字段值</param>
private
void
UpdateControlObjectField
(
ConnModel
conn
,
ControlObjectModel
model
,
string
fieldDetails
,
bool
isGetValueFromViz
)
{
foreach
(
string
fieldDetail
in
fieldDetails
.
Split
(
'\n'
))
{
// 返回示例: BTNAME:#10245*GEOM*TEXT:text:::-1:BTNAME:single_line, location_id=#10245, location=2/3/5
if
(
string
.
IsNullOrWhiteSpace
(
fieldDetail
))
continue
;
string
[]
pars
=
fieldDetail
.
Split
(
':'
);
string
num
=
pars
[
1
].
Split
(
'*'
).
FirstOrDefault
();
ControlFieldNodeModel
node
=
new
ControlFieldNodeModel
();
node
.
FieldIdentifier
=
pars
[
0
];
node
.
Route
=
node
.
FieldIdentifier
.
Split
(
'.'
).
ToList
();
node
.
Num
=
num
;
node
.
TypeSchema
=
pars
[
2
];
node
.
Type
=
this
.
GetControlFieldType
(
node
.
TypeSchema
);
if
(
isGetValueFromViz
)
{
node
.
Value
=
this
.
GetControlFieldValue
(
conn
,
model
.
TreeNodePath
,
node
.
FieldIdentifier
);
}
if
(
pars
.
Length
>=
7
)
{
node
.
Description
=
pars
[
6
];
}
model
.
AllFiledNodes
.
Add
(
node
);
}
// Step 6. 根据字段FieldIdentifier构建树形结构
int
count
=
1
;
List
<
ControlFieldNodeModel
>
fieldNodes
=
model
.
AllFiledNodes
.
Where
(
p
=>
p
.
Route
.
Count
==
count
).
ToList
();
List
<
ControlFieldNodeModel
>
parents
=
fieldNodes
;
while
(
true
)
{
++
count
;
List
<
ControlFieldNodeModel
>
items
=
model
.
AllFiledNodes
.
Where
(
p
=>
p
.
Route
.
Count
==
count
).
ToList
();
if
(
items
.
Count
==
0
)
break
;
foreach
(
ControlFieldNodeModel
item
in
items
)
{
string
parentFieldIdentifier
=
string
.
Join
(
"."
,
item
.
Route
.
Take
(
count
-
1
));
ControlFieldNodeModel
parent
=
parents
.
FirstOrDefault
(
p
=>
p
.
FieldIdentifier
==
parentFieldIdentifier
);
if
(
parent
==
null
)
continue
;
parent
.
Items
.
Add
(
item
);
}
parents
=
items
;
}
model
.
FieldNodes
=
fieldNodes
;
}
}
}
VIZ.Package.Service/Viz/VizControlObjectDownloadService.cs
0 → 100644
View file @
8265a1e8
using
log4net
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
using
VIZ.Framework.Core
;
using
VIZ.Package.Domain
;
using
VIZ.Package.Storage
;
namespace
VIZ.Package.Service
{
/// <summary>
/// Viz控制对象下载服务
/// </summary>
public
class
VizControlObjectDownloadService
{
/// <summary>
/// 日志
/// </summary>
private
readonly
static
ILog
log
=
LogManager
.
GetLogger
(
typeof
(
VizControlObjectDownloadService
));
/// <summary>
/// Viz命令控制对象服务
/// </summary>
private
VizCommandControlObjectService
vizCommandControlObjectService
=
new
VizCommandControlObjectService
();
/// <summary>
/// Viz命令服务
/// </summary>
private
VizCommandService
vizCommandService
=
new
VizCommandService
();
/// <summary>
/// 控制对象服务
/// </summary>
private
ControlObjectService
controlObjectService
=
new
ControlObjectService
();
/// <summary>
/// 加载
/// </summary>
/// <param name="pageBases"></param>
public
void
Load
(
List
<
PageModelBase
>
pageBases
)
{
// 停止更新
this
.
vizCommandService
.
SetEnabledUpdate
(
ApplicationDomainEx
.
PreviewConn
,
false
);
// 更新场景
foreach
(
PageModelBase
page
in
pageBases
)
{
try
{
Debug
.
WriteLine
(
$"加载场景 开始 [
{
page
.
Scene
}
]"
);
this
.
ExecuteLoadOnePage
(
page
);
Debug
.
WriteLine
(
$"加载场景 结束 [
{
page
.
Scene
}
]"
);
}
catch
(
Exception
ex
)
{
log
.
Error
(
ex
);
}
}
// 启用更新
this
.
vizCommandService
.
SetEnabledUpdate
(
ApplicationDomainEx
.
PreviewConn
,
true
);
}
/// <summary>
/// 执行加载
/// </summary>
/// <param name="pageBase">模板或页</param>
private
void
ExecuteLoadOnePage
(
PageModelBase
pageBase
)
{
if
(
pageBase
==
null
)
return
;
// 切换场景
this
.
vizCommandService
.
SetObject
(
ApplicationDomainEx
.
PreviewConn
,
pageBase
.
ScenePath
,
pageBase
.
Layer
);
// 获取控制对象
ControlObjectModel
controlObject
=
this
.
vizCommandControlObjectService
.
GetControlObject
(
ApplicationDomainEx
.
PreviewConn
);
// 保存控制对象到本地
this
.
controlObjectService
.
SaveControlObject
(
pageBase
,
controlObject
);
// 保存控制对象字段到本地
this
.
controlObjectService
.
SaveControlFields
(
pageBase
,
controlObject
.
AllFiledNodes
);
}
}
}
VIZ.Package.Storage/Entity/ControlObject/ControlObjectEntity.cs
0 → 100644
View file @
8265a1e8
using
LiteDB
;
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
VIZ.Package.Storage
{
/// <summary>
/// 控制对象实体
/// </summary>
public
class
ControlObjectEntity
{
/// <summary>
/// 编号
/// </summary>
[
BsonId
(
true
)]
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 所在场景节点名称
/// </summary>
public
string
TreeNodeName
{
get
;
set
;
}
/// <summary>
/// 所在场景节点路径
/// </summary>
public
string
TreeNodePath
{
get
;
set
;
}
/// <summary>
/// 描述
/// </summary>
public
string
Description
{
get
;
set
;
}
/// <summary>
/// 使用所有的控制器
/// </summary>
public
bool
UseAllDirectors
{
get
;
set
;
}
/// <summary>
/// 字段描述
/// </summary>
public
string
FieldDetails
{
get
;
set
;
}
}
}
VIZ.Package.Storage/ProjectDbContext.cs
View file @
8265a1e8
...
...
@@ -66,12 +66,24 @@ namespace VIZ.Package.Storage
/// <returns>控制字段</returns>
public
ILiteCollection
<
ControlFieldEntity
>
GetControlFiled
(
Guid
id
)
{
string
name
=
$"PAGE_
{
id
.
ToString
().
Replace
(
"-"
,
string
.
Empty
)}
"
;
string
name
=
$"PAGE_
CONTROL_FIELD_
{
id
.
ToString
().
Replace
(
"-"
,
string
.
Empty
)}
"
;
return
this
.
Database
.
GetCollection
<
ControlFieldEntity
>(
name
);
}
/// <summary>
/// 根据ID获取控制对象列表, ID 为 TemplateID 或者 PageID
/// </summary>
/// <param name="id">TemplateID 或者 PageID</param>
/// <returns>控制对象</returns>
public
ILiteCollection
<
ControlObjectEntity
>
GetControlObject
(
Guid
id
)
{
string
name
=
$"PAGE_CONTROL_OBJECT_
{
id
.
ToString
().
Replace
(
"-"
,
string
.
Empty
)}
"
;
return
this
.
Database
.
GetCollection
<
ControlObjectEntity
>(
name
);
}
/// <summary>
/// 销毁
/// </summary>
public
void
Dispose
()
...
...
VIZ.Package.Storage/VIZ.Package.Storage.csproj
View file @
8265a1e8
...
...
@@ -72,6 +72,7 @@
<Compile Include="Entity\Conn\ConnEntity.cs" />
<Compile Include="Entity\Conn\ConnGroupEntity.cs" />
<Compile Include="Entity\ControlObject\ControlFieldEntity.cs" />
<Compile Include="Entity\ControlObject\ControlObjectEntity.cs" />
<Compile Include="Entity\Page\PageEntityBase.cs" />
<Compile Include="Entity\Page\PageEntity.cs" />
<Compile Include="Entity\Page\PageGroupEntity.cs" />
...
...
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