Commit 2968871b by liulongfei

1. 添加图标、

2. 页删除逻辑
parent 3f2a4b6a
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 页删除消息
/// </summary>
public class PageDeleteMessage
{
/// <summary>
/// 页
/// </summary>
public PageModelBase Page { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 页分组删除消息
/// </summary>
public class PageGroupDeleteMessage
{
/// <summary>
/// 页分组
/// </summary>
public PageGroupModel PageGroup { get; set; }
}
}
...@@ -38,7 +38,6 @@ namespace VIZ.Package.Domain ...@@ -38,7 +38,6 @@ namespace VIZ.Package.Domain
private set { view = value; this.RaisePropertyChanged(nameof(View)); } private set { view = value; this.RaisePropertyChanged(nameof(View)); }
} }
#endregion #endregion
#region ID -- 编号 #region ID -- 编号
...@@ -148,7 +147,15 @@ namespace VIZ.Package.Domain ...@@ -148,7 +147,15 @@ namespace VIZ.Package.Domain
public double Interval public double Interval
{ {
get { return interval; } get { return interval; }
set { interval = value; this.RaisePropertyChanged(nameof(Interval)); } set
{
interval = Math.Max(2, value);
this.RaisePropertyChanged(nameof(Interval));
if (this.TimerInfo == null)
return;
this.TimerInfo.Interval = TimeSpan.FromSeconds(value);
}
} }
#endregion #endregion
...@@ -181,6 +188,20 @@ namespace VIZ.Package.Domain ...@@ -181,6 +188,20 @@ namespace VIZ.Package.Domain
#endregion #endregion
#region PageModel -- 所属页模型
private PageModel pageModel;
/// <summary>
/// 所属页模型
/// </summary>
public PageModel PageModel
{
get { return pageModel; }
set { pageModel = value; this.RaisePropertyChanged(nameof(PageModel)); }
}
#endregion
/// <summary> /// <summary>
/// 计时器信息 /// 计时器信息
/// </summary> /// </summary>
......
...@@ -86,6 +86,8 @@ ...@@ -86,6 +86,8 @@
<Compile Include="Message\ControlObject\ControlFieldChangedMessage.cs" /> <Compile Include="Message\ControlObject\ControlFieldChangedMessage.cs" />
<Compile Include="Message\Log\ErrorLogMessage.cs" /> <Compile Include="Message\Log\ErrorLogMessage.cs" />
<Compile Include="Message\Log\VizCommandLogMessage.cs" /> <Compile Include="Message\Log\VizCommandLogMessage.cs" />
<Compile Include="Message\Page\PageDeleteMessage.cs" />
<Compile Include="Message\Page\PageGroupDeleteMessage.cs" />
<Compile Include="Message\Page\PageOpenMessage.cs" /> <Compile Include="Message\Page\PageOpenMessage.cs" />
<Compile Include="Message\Page\PageInitedMessage.cs" /> <Compile Include="Message\Page\PageInitedMessage.cs" />
<Compile Include="Message\Project\ProjectSaveMessage.cs" /> <Compile Include="Message\Project\ProjectSaveMessage.cs" />
......
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
<Setter TargetName="icon" Property="Background" Value="#AA4E4BDE"></Setter> <Setter TargetName="icon" Property="Background" Value="#AA4E4BDE"></Setter>
</Trigger> </Trigger>
<Trigger Property="IsEnabled" Value="False"> <Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.4"></Setter> <Setter Property="Opacity" Value="0.2"></Setter>
</Trigger> </Trigger>
</ControlTemplate.Triggers> </ControlTemplate.Triggers>
</ControlTemplate> </ControlTemplate>
......
...@@ -231,5 +231,23 @@ ...@@ -231,5 +231,23 @@
<Resource Include="Icons\icon_pause_32x32.png" /> <Resource Include="Icons\icon_pause_32x32.png" />
<Resource Include="Icons\icon_play_32x32.png" /> <Resource Include="Icons\icon_play_32x32.png" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Resource Include="Icons\top_icon_save_20x20.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\top_icon_create_20x20.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\top_icon_open_20x20.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\top_icon_close_20x20.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\top_icon_layout_20x20.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\top_icon_about_20x20.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
...@@ -17,9 +17,17 @@ ...@@ -17,9 +17,17 @@
<TextBlock Text="项目:" Margin="10,0,0,0" Opacity="0.6"></TextBlock> <TextBlock Text="项目:" Margin="10,0,0,0" Opacity="0.6"></TextBlock>
<TextBlock Text="{Binding ProjectName}" Margin="10,0,0,0" <TextBlock Text="{Binding ProjectName}" Margin="10,0,0,0"
ToolTip="{Binding ProjectName}"></TextBlock> ToolTip="{Binding ProjectName}"></TextBlock>
<!-- 场景 -->
<TextBlock Text="场景:" Margin="40,0,0,0" Opacity="0.6"></TextBlock> <TextBlock Text="场景:" Margin="40,0,0,0" Opacity="0.6"></TextBlock>
<TextBlock Text="{Binding Scene}" Margin="10,0,0,0" <TextBlock Text="{Binding Scene}" Margin="10,0,0,0"
ToolTip="{Binding Scene}"></TextBlock> ToolTip="{Binding Scene}"></TextBlock>
<!-- 页编号 -->
<TextBlock Text="页编号:" Margin="40,0,0,0" Opacity="0.6"></TextBlock>
<TextBlock Text="{Binding PageNum, StringFormat={}{0:D4}}" Margin="10,0,0,0">
<TextBlock.ToolTip>
<TextBlock Text="{Binding PageNum, StringFormat={}{0:D4}}" Margin="2,0,2,0"></TextBlock>
</TextBlock.ToolTip>
</TextBlock>
</StackPanel> </StackPanel>
<!-- 命令组 --> <!-- 命令组 -->
......
...@@ -30,20 +30,26 @@ ...@@ -30,20 +30,26 @@
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<dxb:MainMenuControl Caption="MainMenu" VerticalAlignment="Center"> <dxb:MainMenuControl Caption="MainMenu" VerticalAlignment="Center">
<dxb:BarSubItem Content="项目" IsEnabled="{Binding Path=IsVizPreviewReady}"> <dxb:BarSubItem Content="项目" IsEnabled="{Binding Path=IsVizPreviewReady}">
<dxb:BarButtonItem Content="新建" Command="{Binding Path=CreateProjectCommand}" /> <dxb:BarButtonItem Content="新建" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_create_20x20.png"
<dxb:BarButtonItem Content="打开" Command="{Binding Path=OpenProjectCommand}" /> Command="{Binding Path=CreateProjectCommand}" />
<dxb:BarButtonItem Content="保存" Command="{Binding Path=SaveProjectCommand}" /> <dxb:BarButtonItem Content="打开" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_open_20x20.png"
<dxb:BarButtonItem Content="关闭" Command="{Binding Path=CloseProjectCommand}" /> Command="{Binding Path=OpenProjectCommand}" />
<dxb:BarButtonItem Content="保存" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_save_20x20.png"
Command="{Binding Path=SaveProjectCommand}" />
<dxb:BarButtonItem Content="关闭" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_close_20x20.png"
Command="{Binding Path=CloseProjectCommand}" />
</dxb:BarSubItem> </dxb:BarSubItem>
<dxb:BarSubItem Content="设置" Command="{Binding Path=SettingCommand}"> <dxb:BarSubItem Content="设置" Command="{Binding Path=SettingCommand}">
</dxb:BarSubItem> </dxb:BarSubItem>
<dxb:BarSubItem Content="视图" ItemLinksSource="{Binding Path=ItemsSource}" ItemTemplate="{StaticResource ViewItemTemplate}"> <dxb:BarSubItem Content="视图" ItemLinksSource="{Binding Path=ItemsSource}" ItemTemplate="{StaticResource ViewItemTemplate}">
</dxb:BarSubItem> </dxb:BarSubItem>
<dxb:BarSubItem Content="布局"> <dxb:BarSubItem Content="布局">
<dxb:BarButtonItem Content="重置布局" Command="{Binding Path=ResetLayoutCommand}" /> <dxb:BarButtonItem Content="重置布局" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_layout_20x20.png"
Command="{Binding Path=ResetLayoutCommand}" />
</dxb:BarSubItem> </dxb:BarSubItem>
<dxb:BarSubItem Content="帮助"> <dxb:BarSubItem Content="帮助">
<dxb:BarButtonItem Content="关于" Command="{Binding Path=AboutCommand}"/> <dxb:BarButtonItem Content="关于" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_about_20x20.png"
Command="{Binding Path=AboutCommand}"/>
</dxb:BarSubItem> </dxb:BarSubItem>
</dxb:MainMenuControl> </dxb:MainMenuControl>
</StackPanel> </StackPanel>
......
...@@ -5,6 +5,7 @@ using System.Text; ...@@ -5,6 +5,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain; using VIZ.Package.Domain;
using VIZ.Package.Storage;
namespace VIZ.Package.Module namespace VIZ.Package.Module
{ {
...@@ -76,6 +77,20 @@ namespace VIZ.Package.Module ...@@ -76,6 +77,20 @@ namespace VIZ.Package.Module
#endregion #endregion
#region PageNum -- 页号
private int? pageNum;
/// <summary>
/// 页号
/// </summary>
public int? PageNum
{
get { return pageNum; }
set { pageNum = value; this.RaisePropertyChanged(nameof(PageNum)); }
}
#endregion
// ====================================================================== // ======================================================================
// Command // Command
// ====================================================================== // ======================================================================
...@@ -151,6 +166,14 @@ namespace VIZ.Package.Module ...@@ -151,6 +166,14 @@ namespace VIZ.Package.Module
private void OnPageOpenMessage(PageOpenMessage msg) private void OnPageOpenMessage(PageOpenMessage msg)
{ {
this.Scene = msg.Page?.Scene; this.Scene = msg.Page?.Scene;
if (msg.Page is PageModel page)
{
this.PageNum = page.PageNum;
}
else
{
this.PageNum = null;
}
} }
} }
} }
...@@ -261,7 +261,12 @@ namespace VIZ.Package.Module ...@@ -261,7 +261,12 @@ namespace VIZ.Package.Module
if (DXMessageBox.Show($"是否删除分组【{this.SelectedPageGroupModel.GroupName}】?", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes) if (DXMessageBox.Show($"是否删除分组【{this.SelectedPageGroupModel.GroupName}】?", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return; return;
PageGroupModel group = this.SelectedPageGroupModel;
this.PageGroupModels.Remove(this.SelectedPageGroupModel); this.PageGroupModels.Remove(this.SelectedPageGroupModel);
PageGroupDeleteMessage msg = new PageGroupDeleteMessage();
msg.PageGroup = group;
ApplicationDomainEx.MessageManager.Send(msg);
} }
#endregion #endregion
...@@ -284,7 +289,12 @@ namespace VIZ.Package.Module ...@@ -284,7 +289,12 @@ namespace VIZ.Package.Module
if (DXMessageBox.Show($"是否删除项【{this.SelectedPageModel.Scene}】", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes) if (DXMessageBox.Show($"是否删除项【{this.SelectedPageModel.Scene}】", "提示", MessageBoxButton.YesNo) != MessageBoxResult.Yes)
return; return;
PageModel page = this.SelectedPageModel;
this.SelectedPageGroupModel.Pages.Remove(this.SelectedPageModel); this.SelectedPageGroupModel.Pages.Remove(this.SelectedPageModel);
PageDeleteMessage msg = new PageDeleteMessage();
msg.Page = page;
ApplicationDomainEx.MessageManager.Send(msg);
} }
#endregion #endregion
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
</dxmvvm:Interaction.Behaviors> </dxmvvm:Interaction.Behaviors>
<Grid> <Grid>
<fcommon:NavigationControl ItemsSource="{Binding ItemsSource}" <fcommon:NavigationControl ItemsSource="{Binding ItemsSource}" CreateMode="RealTime"
SelectedValue="{Binding Path=SelectedValue,Mode=OneWay}"></fcommon:NavigationControl> SelectedValue="{Binding Path=SelectedValue,Mode=OneWay}"></fcommon:NavigationControl>
</Grid> </Grid>
</UserControl> </UserControl>
...@@ -52,6 +52,8 @@ namespace VIZ.Package.Module ...@@ -52,6 +52,8 @@ namespace VIZ.Package.Module
{ {
ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage); ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage);
ApplicationDomainEx.MessageManager.Register<PageInitedMessage>(this, this.OnPageInitedMessage); ApplicationDomainEx.MessageManager.Register<PageInitedMessage>(this, this.OnPageInitedMessage);
ApplicationDomainEx.MessageManager.Register<PageDeleteMessage>(this, this.OnPageDeleteMessage);
ApplicationDomainEx.MessageManager.Register<PageGroupDeleteMessage>(this, this.OnPageGroupDeleteMessage);
} }
// ======================================================================== // ========================================================================
...@@ -192,6 +194,41 @@ namespace VIZ.Package.Module ...@@ -192,6 +194,41 @@ namespace VIZ.Package.Module
this.SelectedValue = config; this.SelectedValue = config;
} }
/// <summary>
/// 页删除消息
/// </summary>
/// <param name="msg">消息</param>
private void OnPageDeleteMessage(PageDeleteMessage msg)
{
if (msg.Page == null)
return;
PluginNavigationConfig config = this.ItemsSource.FirstOrDefault(p => p.PageModel == msg.Page);
if (config == null)
return;
this.ItemsSource.Remove(config);
}
/// <summary>
/// 页分组删除消息
/// </summary>
/// <param name="msg">消息</param>
private void OnPageGroupDeleteMessage(PageGroupDeleteMessage msg)
{
if (msg.PageGroup == null || msg.PageGroup.Pages == null)
return;
foreach (PageModel page in msg.PageGroup.Pages)
{
PluginNavigationConfig config = this.ItemsSource.FirstOrDefault(p => p.PageModel == page);
if (config == null)
continue;
this.ItemsSource.Remove(config);
}
}
// ======================================================================== // ========================================================================
// Public Function // Public Function
// ======================================================================== // ========================================================================
......
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
<dxg:GridColumn Header="插件" FieldName="PluginID" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False"> <dxg:GridColumn Header="插件" FieldName="PluginID" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.EditSettings> <dxg:GridColumn.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding Path=PluginInfos}" IsTextEditable="False" <dxe:ComboBoxEditSettings ItemsSource="{Binding Path=PluginInfos}" IsTextEditable="False"
SelectItemWithNullValue="True"
DisplayMember="Name" ValueMember="ID"></dxe:ComboBoxEditSettings> DisplayMember="Name" ValueMember="ID"></dxe:ComboBoxEditSettings>
</dxg:GridColumn.EditSettings> </dxg:GridColumn.EditSettings>
</dxg:GridColumn> </dxg:GridColumn>
......
...@@ -122,7 +122,13 @@ namespace VIZ.Package.Module ...@@ -122,7 +122,13 @@ namespace VIZ.Package.Module
this.Mappings = list; this.Mappings = list;
// 插件信息 // 插件信息
this.PluginInfos = ApplicationDomainEx.PluginInfos.Where(p => p.PluginType == PluginType.Page && p.Group != ApplicationConstants.APPLICATION_GROUP_NAME).ToList(); var plugins = ApplicationDomainEx.PluginInfos.Where(
p => p.PluginType == PluginType.Page &&
p.Group != ApplicationConstants.APPLICATION_GROUP_NAME &&
p.Group == ApplicationDomainEx.VizConfig.PluginGroup).ToList();
plugins.Insert(0, PluginInfo.NONE);
this.PluginInfos = plugins;
} }
#endregion #endregion
......
...@@ -58,12 +58,17 @@ ...@@ -58,12 +58,17 @@
<dxe:TextEditSettings AcceptsReturn="False"></dxe:TextEditSettings> <dxe:TextEditSettings AcceptsReturn="False"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings> </dxg:GridColumn.EditSettings>
</dxg:GridColumn> </dxg:GridColumn>
<dxg:GridColumn Header="更新间隔(秒)" FieldName="Interval" AllowResizing="False" Width="100">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings MaskType="Numeric" HorizontalContentAlignment="Left"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="预览更新时间" ReadOnly="True" <dxg:GridColumn Header="预览更新时间" ReadOnly="True"
AllowResizing="False" Width="100"> AllowResizing="False" Width="100">
<dxg:GridColumn.CellTemplate> <dxg:GridColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=Row.PreviewUpdateTime,StringFormat=hh:mm:ss}" <TextBlock Text="{Binding Path=Row.PreviewUpdateTime,StringFormat=hh:mm:ss}"
VerticalAlignment="Center"></TextBlock> VerticalAlignment="Center" Margin="3,0,3,0"></TextBlock>
</DataTemplate> </DataTemplate>
</dxg:GridColumn.CellTemplate> </dxg:GridColumn.CellTemplate>
</dxg:GridColumn> </dxg:GridColumn>
...@@ -72,7 +77,7 @@ ...@@ -72,7 +77,7 @@
<dxg:GridColumn.CellTemplate> <dxg:GridColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Text="{Binding Path=Row.TakeUpdateTime,StringFormat=hh:mm:ss}" <TextBlock Text="{Binding Path=Row.TakeUpdateTime,StringFormat=hh:mm:ss}"
VerticalAlignment="Center"></TextBlock> VerticalAlignment="Center" Margin="3,0,3,0"></TextBlock>
</DataTemplate> </DataTemplate>
</dxg:GridColumn.CellTemplate> </dxg:GridColumn.CellTemplate>
</dxg:GridColumn> </dxg:GridColumn>
......
...@@ -7,6 +7,7 @@ using System.Collections.ObjectModel; ...@@ -7,6 +7,7 @@ using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.Hosting;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain; using VIZ.Package.Domain;
using VIZ.Package.Plugin; using VIZ.Package.Plugin;
...@@ -29,6 +30,9 @@ namespace VIZ.Package.Module ...@@ -29,6 +30,9 @@ namespace VIZ.Package.Module
// 初始化命令 // 初始化命令
this.InitCommand(); this.InitCommand();
// 初始化消息
this.InitMessage();
// 注册服务 // 注册服务
ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.PACKAGE_TASK_SERVICE, this); ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.PACKAGE_TASK_SERVICE, this);
} }
...@@ -42,6 +46,15 @@ namespace VIZ.Package.Module ...@@ -42,6 +46,15 @@ namespace VIZ.Package.Module
this.StopCommand = new VCommand<PackageTaskModel>(this.Stop); this.StopCommand = new VCommand<PackageTaskModel>(this.Stop);
} }
/// <summary>
/// 初始化消息
/// </summary>
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<PageDeleteMessage>(this, this.OnPageDeleteMessage);
ApplicationDomainEx.MessageManager.Register<PageGroupDeleteMessage>(this, this.OnPageGroupDeleteMessage);
}
// ============================================================== // ==============================================================
// Service & Controller // Service & Controller
// ============================================================== // ==============================================================
...@@ -115,6 +128,45 @@ namespace VIZ.Package.Module ...@@ -115,6 +128,45 @@ namespace VIZ.Package.Module
#endregion #endregion
// ============================================================== // ==============================================================
// Message
// ==============================================================
/// <summary>
/// 页删除消息
/// </summary>
/// <param name="msg">消息</param>
private void OnPageDeleteMessage(PageDeleteMessage msg)
{
if (msg.Page == null)
return;
var query = this.ItemsSource.Where(p => p.PageModel == msg.Page).ToList();
foreach (PackageTaskModel task in query)
{
this.Cancel(task);
}
}
/// <summary>
/// 页分组删除消息
/// </summary>
/// <param name="msg">消息</param>
private void OnPageGroupDeleteMessage(PageGroupDeleteMessage msg)
{
if (msg.PageGroup == null || msg.PageGroup.Pages == null)
return;
foreach (PageModel page in msg.PageGroup.Pages)
{
var query = this.ItemsSource.Where(p => p.PageModel == page).ToList();
foreach (PackageTaskModel task in query)
{
this.Cancel(task);
}
}
}
// ==============================================================
// Public Function // Public Function
// ============================================================== // ==============================================================
...@@ -129,24 +181,58 @@ namespace VIZ.Package.Module ...@@ -129,24 +181,58 @@ namespace VIZ.Package.Module
if (this.ItemsSource.Contains(task)) if (this.ItemsSource.Contains(task))
return; return;
IPluginService pluginService = ApplicationDomainEx.ServiceManager.GetService<IPluginService>(ViewServiceKeys.PLUGIN_SERVICE);
task.PageModel = pluginService.GetPageModelFromView(task.View);
this.ItemsSource.Add(task); this.ItemsSource.Add(task);
}
string key = $"PackageTask_{task.ID}";
task.TimerInfo = ApplicationDomainEx.TimerManager.Register(key, task.Interval, () =>
{
// 任务没有在运行状态 || 任务不可以执行
if (!task.IsRunning || !task.CanExecute)
return;
// 上预览
if (task.IsPreviewEnabled && ApplicationDomainEx.PreviewConn != null && ApplicationDomainEx.PreviewConn.IsConnected)
{
try
{
task.PreviewUpdateAction?.Invoke(ApplicationDomainEx.PreviewConn);
WPFHelper.Invoke(() =>
{
task.PreviewUpdateTime = DateTime.Now;
});
}
catch (Exception ex)
{
log.Error(ex);
WPFHelper.Invoke(() =>
{
task.ErrorMessage = ex.Message;
});
}
}
string key = $"PackageTask_{task.ID}"; // 上版
task.TimerInfo = ApplicationDomainEx.TimerManager.Register(key, task.Interval, () => if (task.IsTakeEnabled)
{ {
// 任务没有在运行状态 || 任务不可以执行 ConnGroupModel group = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.GroupID == task.PageModel.ConnGroupID);
if (!task.IsRunning || !task.CanExecute) if (group == null)
return; return;
// 上预览 foreach (var item in group.Items)
if (task.IsPreviewEnabled && ApplicationDomainEx.PreviewConn != null && ApplicationDomainEx.PreviewConn.IsConnected)
{ {
if (!item.IsEnabled || !item.IsConnected)
continue;
try try
{ {
task.PreviewUpdateAction(ApplicationDomainEx.PreviewConn); task.TakeUpdateAction(item);
WPFHelper.Invoke(() => WPFHelper.Invoke(() =>
{ {
task.PreviewUpdateTime = DateTime.Now; task.TakeUpdateTime = DateTime.Now;
}); });
} }
catch (Exception ex) catch (Exception ex)
...@@ -158,47 +244,8 @@ namespace VIZ.Package.Module ...@@ -158,47 +244,8 @@ namespace VIZ.Package.Module
}); });
} }
} }
}
// 上版 });
if (task.IsTakeEnabled)
{
IPluginService pluginService = ApplicationDomainEx.ServiceManager.GetService<IPluginService>(ViewServiceKeys.PLUGIN_SERVICE);
if (pluginService == null)
return;
PageModel page = pluginService.GetPageModelFromView(task.View);
if (page == null)
return;
ConnGroupModel group = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.GroupID == page.ConnGroupID);
if (group == null)
return;
foreach (var item in group.Items)
{
if (!item.IsEnabled || !item.IsConnected)
continue;
try
{
task.TakeUpdateAction(item);
WPFHelper.Invoke(() =>
{
task.TakeUpdateTime = DateTime.Now;
});
}
catch (Exception ex)
{
log.Error(ex);
WPFHelper.Invoke(() =>
{
task.ErrorMessage = ex.Message;
});
}
}
}
});
}
} }
/// <summary> /// <summary>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment