Commit b2f323f9 by liulongfei

添加任务面板

parent 08d3b117
...@@ -61,6 +61,11 @@ namespace VIZ.Package.Domain ...@@ -61,6 +61,11 @@ namespace VIZ.Package.Domain
/// </summary> /// </summary>
public const string COMMAND = "COMMAND"; public const string COMMAND = "COMMAND";
/// <summary>
/// 包装任务
/// </summary>
public const string PACKAGE_TASK = "PACKAGE_TASK";
// ======================================================================== // ========================================================================
/// <summary> /// <summary>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 包装任务状态
/// </summary>
public enum PackageTaskStatus
{
/// <summary>
/// 停止
/// </summary>
Stop,
/// <summary>
/// 执行
/// </summary>
Runing,
/// <summary>
/// 错误
/// </summary>
Error
}
}
...@@ -45,5 +45,15 @@ namespace VIZ.Package.Domain ...@@ -45,5 +45,15 @@ namespace VIZ.Package.Domain
/// 插件服务 /// 插件服务
/// </summary> /// </summary>
public const string PLUGIN_SERVICE = "PLUGIN_SERVICE"; public const string PLUGIN_SERVICE = "PLUGIN_SERVICE";
/// <summary>
/// 控制服务
/// </summary>
public const string CONTROL_SERVICE = "CONTROL_SERVICE";
/// <summary>
/// 包装任务服务
/// </summary>
public const string PACKAGE_TASK_SERVICE = "PACKAGE_TASK_SERVICE";
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.Package.Domain
{
/// <summary>
/// 包装任务接口
/// </summary>
public interface IPackageTaskInterface
{
/// <summary>
/// 预览更新
/// </summary>
/// <param name="task">任务</param>
void PreviewUpdate(PackageTaskModel task);
/// <summary>
/// 上版更新
/// </summary>
/// <param name="task">任务</param>
void TakeUpdate(PackageTaskModel task);
/// <summary>
/// 销毁
/// </summary>
/// <param name="task">任务</param>
void Dispose(PackageTaskModel task);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.Package.Domain
{
/// <summary>
/// 包装任务模型
/// </summary>
public class PackageTaskModel : ModelBase, IDisposable
{
/// <summary>
/// 包装任务模型
/// </summary>
/// <param name="view">插件视图</param>
public PackageTaskModel(IPluginView view)
{
this.View = view;
}
#region View -- 插件视图
private IPluginView view;
/// <summary>
/// 插件视图
/// </summary>
public IPluginView View
{
get { return view; }
private set { view = value; this.RaisePropertyChanged(nameof(View)); }
}
#endregion
#region ID -- 编号
private int id;
/// <summary>
/// 编号
/// </summary>
public int ID
{
get { return id; }
set { id = value; this.RaisePropertyChanged(nameof(ID)); }
}
#endregion
#region Name -- 名称
private string name;
/// <summary>
/// 名称
/// </summary>
public string Name
{
get { return name; }
set { name = value; this.RaisePropertyChanged(nameof(Name)); }
}
#endregion
#region Remark -- 备注
private string remark;
/// <summary>
/// 备注
/// </summary>
public string Remark
{
get { return remark; }
set { remark = value; this.RaisePropertyChanged(nameof(Remark)); }
}
#endregion
#region IsEnabled -- 是否启用
private bool isEnabled;
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled
{
get { return isEnabled; }
set { isEnabled = value; this.RaisePropertyChanged(nameof(IsEnabled)); }
}
#endregion
#region Status -- 状态
private PackageTaskStatus status;
/// <summary>
/// 状态
/// </summary>
public PackageTaskStatus Status
{
get { return status; }
set { status = value; this.RaisePropertyChanged(nameof(Status)); }
}
#endregion
#region ErrorMessage -- 错误消息
private string errorMessage;
/// <summary>
/// 错误消息
/// </summary>
public string ErrorMessage
{
get { return errorMessage; }
set { errorMessage = value; this.RaisePropertyChanged(nameof(ErrorMessage)); }
}
#endregion
#region PreviewUpdateTime -- 预览更新时间
private DateTime? previewUpdateTime;
/// <summary>
/// 预览更新时间
/// </summary>
public DateTime? PreviewUpdateTime
{
get { return previewUpdateTime; }
set { previewUpdateTime = value; this.RaisePropertyChanged(nameof(PreviewUpdateTime)); }
}
#endregion
#region TakeUpdateTime -- 上版更新时间
private DateTime? takeUpdateTime;
/// <summary>
/// 上版更新时间
/// </summary>
public DateTime? TakeUpdateTime
{
get { return takeUpdateTime; }
set { takeUpdateTime = value; this.RaisePropertyChanged(nameof(TakeUpdateTime)); }
}
#endregion
/// <summary>
/// 包装任务接口
/// </summary>
public IPackageTaskInterface PackageTaskInterface { get; set; }
/// <summary>
/// 预览更新行为
/// </summary>
public Action<ConnModel> PreviewUpdateAction { get; set; }
/// <summary>
/// 上版更新行为
/// </summary>
public Action<ConnModel> TakeUpdateAction { get; set; }
/// <summary>
/// 预览更新
/// </summary>
public void PreviewUpdate()
{
if (!this.IsEnabled || this.PreviewUpdateAction == null)
return;
this.PackageTaskInterface?.PreviewUpdate(this);
this.PreviewUpdateTime = DateTime.Now;
}
/// <summary>
/// 上版更新
/// </summary>
public void TakeUpdate()
{
if (!this.IsEnabled || this.TakeUpdateAction == null)
return;
this.PackageTaskInterface?.TakeUpdate(this);
this.TakeUpdateTime = DateTime.Now;
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
this.PackageTaskInterface?.Dispose(this);
}
}
}
...@@ -15,25 +15,25 @@ namespace VIZ.Package.Domain ...@@ -15,25 +15,25 @@ namespace VIZ.Package.Domain
/// 上版 /// 上版
/// </summary> /// </summary>
/// <param name="conns">连接</param> /// <param name="conns">连接</param>
void TakIn(ConnModel conns); void TakIn(ConnModel conn);
/// <summary> /// <summary>
/// 继续 /// 继续
/// </summary> /// </summary>
/// <param name="conns">连接</param> /// <param name="conn">连接</param>
void TakeContinue(ConnModel conns); void TakeContinue(ConnModel conn);
/// <summary> /// <summary>
/// 下版子 /// 下版子
/// </summary> /// </summary>
/// <param name="conns">连接</param> /// <param name="conn">连接</param>
void TakeOut(ConnModel conns); void TakeOut(ConnModel conn);
/// <summary> /// <summary>
/// 更新 /// 更新
/// </summary> /// </summary>
/// <param name="conns">连接</param> /// <param name="conn">连接</param>
void TakeUpdate(ConnModel conns); void TakeUpdate(ConnModel conn);
/// <summary> /// <summary>
/// 预览上版子 /// 预览上版子
......
...@@ -77,8 +77,10 @@ ...@@ -77,8 +77,10 @@
<Compile Include="Core\GridColumnDefinition.cs" /> <Compile Include="Core\GridColumnDefinition.cs" />
<Compile Include="Enum\ConnGroupStatus.cs" /> <Compile Include="Enum\ConnGroupStatus.cs" />
<Compile Include="Enum\ModulePluginIds.cs" /> <Compile Include="Enum\ModulePluginIds.cs" />
<Compile Include="Enum\PackageTaskStatus.cs" />
<Compile Include="Enum\ViewServiceKeys.cs" /> <Compile Include="Enum\ViewServiceKeys.cs" />
<Compile Include="Info\VizTreeNodeInfo.cs" /> <Compile Include="Info\VizTreeNodeInfo.cs" />
<Compile Include="Interface\Task\IPackageTaskInterface.cs" />
<Compile Include="Message\Application\ApplicationClosedMessage.cs" /> <Compile Include="Message\Application\ApplicationClosedMessage.cs" />
<Compile Include="Message\Application\ApplicationClosingMessage.cs" /> <Compile Include="Message\Application\ApplicationClosingMessage.cs" />
<Compile Include="Message\Conn\ConnChangedMessage.cs" /> <Compile Include="Message\Conn\ConnChangedMessage.cs" />
...@@ -112,6 +114,7 @@ ...@@ -112,6 +114,7 @@
<Compile Include="Model\Resource\ResourceFileModelBase.cs" /> <Compile Include="Model\Resource\ResourceFileModelBase.cs" />
<Compile Include="Model\Resource\ResourceFolderModelBase.cs" /> <Compile Include="Model\Resource\ResourceFolderModelBase.cs" />
<Compile Include="Model\Setting\SettingPageModel.cs" /> <Compile Include="Model\Setting\SettingPageModel.cs" />
<Compile Include="Model\Task\PackageTaskModel.cs" />
<Compile Include="Plugin\IPluginLifeCycle.cs" /> <Compile Include="Plugin\IPluginLifeCycle.cs" />
<Compile Include="Plugin\IPluginSettingView.cs" /> <Compile Include="Plugin\IPluginSettingView.cs" />
<Compile Include="Plugin\IPluginView.cs" /> <Compile Include="Plugin\IPluginView.cs" />
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// 控制服务
/// </summary>
public interface IControlService : IService
{
}
}
...@@ -15,7 +15,7 @@ namespace VIZ.Package.Module ...@@ -15,7 +15,7 @@ namespace VIZ.Package.Module
/// <summary> /// <summary>
/// 控制视图模型 /// 控制视图模型
/// </summary> /// </summary>
public class ControlViewModel : ViewModelBase public class ControlViewModel : ViewModelBase, IControlService
{ {
/// <summary> /// <summary>
/// 日志 /// 日志
...@@ -26,6 +26,9 @@ namespace VIZ.Package.Module ...@@ -26,6 +26,9 @@ namespace VIZ.Package.Module
{ {
// 初始化命令 // 初始化命令
this.InitCommand(); this.InitCommand();
// 注册服务
ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.CONTROL_SERVICE, this);
} }
/// <summary> /// <summary>
...@@ -170,7 +173,7 @@ namespace VIZ.Package.Module ...@@ -170,7 +173,7 @@ namespace VIZ.Package.Module
{ {
this.vizCommandControlObjectService.SetControlObject(conn, obj); this.vizCommandControlObjectService.SetControlObject(conn, obj);
} }
view?.TakeOut(conn); view?.TakeUpdate(conn);
}); });
} }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Common;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// 插件导航配置
/// </summary>
public class PluginNavigationConfig : NavigationConfig
{
/// <summary>
/// 页模型
/// </summary>
public PageModel PageModel { get; set; }
/// <summary>
/// 插件信息
/// </summary>
public PluginInfo PluginInfo { get; set; }
}
}
...@@ -3,7 +3,9 @@ using System.Collections.Generic; ...@@ -3,7 +3,9 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using VIZ.Framework.Common;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain;
namespace VIZ.Package.Module namespace VIZ.Package.Module
{ {
...@@ -17,5 +19,25 @@ namespace VIZ.Package.Module ...@@ -17,5 +19,25 @@ namespace VIZ.Package.Module
/// </summary> /// </summary>
/// <returns>当前插件视图</returns> /// <returns>当前插件视图</returns>
object GetCurrentPluginView(); object GetCurrentPluginView();
/// <summary>
/// 根据视图获取页ID
/// </summary>
/// <param name="view">视图</param>
/// <returns>页ID</returns>
PageModel GetPageModelFromView(IPluginView view);
/// <summary>
/// 获取所有的插件视图
/// </summary>
/// <returns>插件视图</returns>
List<IPluginView> GetPluginViews();
/// <summary>
/// 获取插件视图
/// </summary>
/// <typeparam name="T">插件视图类型</typeparam>
/// <returns>插件视图</returns>
List<T> GetPluginViews<T>() where T : class, IPluginView;
} }
} }
...@@ -47,11 +47,11 @@ namespace VIZ.Package.Module ...@@ -47,11 +47,11 @@ namespace VIZ.Package.Module
#region SelectedValue -- 当前选择项 #region SelectedValue -- 当前选择项
private NavigationConfig selectedValue; private PluginNavigationConfig selectedValue;
/// <summary> /// <summary>
/// 当前选择项 /// 当前选择项
/// </summary> /// </summary>
public NavigationConfig SelectedValue public PluginNavigationConfig SelectedValue
{ {
get { return selectedValue; } get { return selectedValue; }
set { selectedValue = value; this.RaisePropertyChanged(nameof(SelectedValue)); } set { selectedValue = value; this.RaisePropertyChanged(nameof(SelectedValue)); }
...@@ -61,11 +61,11 @@ namespace VIZ.Package.Module ...@@ -61,11 +61,11 @@ namespace VIZ.Package.Module
#region ItemsSource -- 数据源 #region ItemsSource -- 数据源
private ObservableCollection<NavigationConfig> itemsSource = new ObservableCollection<NavigationConfig>(); private ObservableCollection<PluginNavigationConfig> itemsSource = new ObservableCollection<PluginNavigationConfig>();
/// <summary> /// <summary>
/// 数据源 /// 数据源
/// </summary> /// </summary>
public ObservableCollection<NavigationConfig> ItemsSource public ObservableCollection<PluginNavigationConfig> ItemsSource
{ {
get { return itemsSource; } get { return itemsSource; }
set { itemsSource = value; this.RaisePropertyChanged(nameof(ItemsSource)); } set { itemsSource = value; this.RaisePropertyChanged(nameof(ItemsSource)); }
...@@ -124,7 +124,7 @@ namespace VIZ.Package.Module ...@@ -124,7 +124,7 @@ namespace VIZ.Package.Module
// 页拥有插件 // 页拥有插件
PageModel page = msg.Page as PageModel; PageModel page = msg.Page as PageModel;
NavigationConfig config = this.ItemsSource.FirstOrDefault(p => p.Key == page.PageID.ToString()); PluginNavigationConfig config = this.ItemsSource.FirstOrDefault(p => p.Key == page.PageID.ToString());
if (config != null) if (config != null)
{ {
this.SelectedValue = config; this.SelectedValue = config;
...@@ -135,9 +135,12 @@ namespace VIZ.Package.Module ...@@ -135,9 +135,12 @@ namespace VIZ.Package.Module
if (plugin == null) if (plugin == null)
return; return;
config = new NavigationConfig(); config = new PluginNavigationConfig();
config.Key = page.PageID.ToString(); config.Key = page.PageID.ToString();
config.ViewType = plugin.ViewType; config.ViewType = plugin.ViewType;
config.PageModel = page;
config.PluginInfo = plugin;
this.ItemsSource.Add(config); this.ItemsSource.Add(config);
this.SelectedValue = config; this.SelectedValue = config;
...@@ -160,5 +163,78 @@ namespace VIZ.Package.Module ...@@ -160,5 +163,78 @@ namespace VIZ.Package.Module
return target; return target;
} }
/// <summary>
/// 根据视图获取页模型
/// </summary>
/// <param name="view">视图</param>
/// <returns>页ID</returns>
public PageModel GetPageModelFromView(IPluginView view)
{
foreach (PluginNavigationConfig config in this.ItemsSource)
{
config.View.TryGetTarget(out object target);
if (target == null)
continue;
IPluginView item = target as IPluginView;
if (item == null)
continue;
if (item == view)
return config.PageModel;
}
return null;
}
/// <summary>
/// 获取所有的插件视图
/// </summary>
/// <returns>插件视图</returns>
public List<IPluginView> GetPluginViews()
{
List<IPluginView> list = new List<IPluginView>();
foreach (NavigationConfig config in this.ItemsSource)
{
config.View.TryGetTarget(out object target);
if (target == null)
continue;
IPluginView item = target as IPluginView;
if (item == null)
continue;
list.Add(item);
}
return list;
}
/// <summary>
/// 获取插件视图
/// </summary>
/// <typeparam name="T">插件视图类型</typeparam>
/// <returns>插件视图</returns>
public List<T> GetPluginViews<T>() where T : class, IPluginView
{
List<T> list = new List<T>();
foreach (NavigationConfig config in this.ItemsSource)
{
config.View.TryGetTarget(out object target);
if (target == null)
continue;
T item = target as T;
if (item == null)
continue;
list.Add(item);
}
return list;
}
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
namespace VIZ.Package.Module
{
/// <summary>
/// 包装任务插件
/// </summary>
public class PackageTaskPluginLifeCycle : IPluginLifeCycle
{
/// <summary>
/// 插件分组
/// </summary>
public const string PLUGIN_GROUP = ApplicationConstants.APPLICATION_GROUP_NAME;
/// <summary>
/// 插件ID
/// </summary>
/// <remarks>
/// 插件ID不能包含点号
/// </remarks>
public const string PLUGIN_ID = ModulePluginIds.PACKAGE_TASK;
/// <summary>
/// 插件名称
/// </summary>
public const string PLUGIN_NAME = "任务";
/// <summary>
/// 注册
/// </summary>
/// <returns>插件信息</returns>
public PluginInfo Register()
{
PluginInfo info = new PluginInfo();
info.Group = PLUGIN_GROUP;
info.ID = PLUGIN_ID;
info.Name = PLUGIN_NAME;
info.ViewType = typeof(PackageTaskView);
return info;
}
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
namespace VIZ.Package.Module
{
/// <summary>
/// 包装任务服务
/// </summary>
public interface IPackageTaskService : IService
{
/// <summary>
/// 注册任务
/// </summary>
/// <param name="task">任务</param>
void Register(PackageTaskModel task);
/// <summary>
/// 取消任务
/// </summary>
/// <param name="task">任务</param>
void Cancel(PackageTaskModel task);
}
}
<UserControl x:Class="VIZ.Package.Module.PackageTaskView"
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:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors"
xmlns:dxb="http://schemas.devexpress.com/winfx/2008/xaml/bars"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:fcore="clr-namespace:VIZ.Framework.Core;assembly=VIZ.Framework.Core"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:storage="clr-namespace:VIZ.Package.Storage;assembly=VIZ.Package.Storage"
xmlns:resource="clr-namespace:VIZ.Package.Module.Resource;assembly=VIZ.Package.Module.Resource"
xmlns:local="clr-namespace:VIZ.Package.Module"
xmlns:domain="clr-namespace:VIZ.Package.Domain;assembly=VIZ.Package.Domain"
d:DataContext="{d:DesignInstance Type=local:PackageTaskViewModel}"
mc:Ignorable="d"
d:DesignHeight="45" d:DesignWidth="800">
<UserControl.Resources>
</UserControl.Resources>
<Grid>
<dxg:GridControl ItemsSource="{Binding Path=ItemsSource}" ShowBorder="False">
<dxg:GridControl.Columns>
<dxg:GridColumn Header="编号" FieldName="ID" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="名称" FieldName="Name" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="备注" FieldName="Remark" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:TextEditSettings AcceptsReturn="False"></dxe:TextEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="状态" FieldName="Status" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="预览更新时间" ReadOnly="True">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Row.PreviewUpdateTime,StringFormat=yyyy-MM-dd hh:mm:ss}"
VerticalAlignment="Center"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="更新时间" ReadOnly="True">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Row.TakeUpdateTime,StringFormat=yyyy-MM-dd hh:mm:ss}"
VerticalAlignment="Center"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="是否启用" FieldName="IsEnabled" AllowSorting="False" AllowColumnFiltering="False">
<dxg:GridColumn.EditSettings>
<dxe:CheckEditSettings HorizontalContentAlignment="Left"></dxe:CheckEditSettings>
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView IsColumnMenuEnabled="False"
AllowEditing="True" ShowIndicator="False"
NavigationStyle="Cell" ShowVerticalLines="False"
ShowGroupPanel="False" EditorShowMode="MouseUp"
AllowDragDrop="True"
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowTargetInfoInDragDropHint="false">
</dxg:TableView>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</UserControl>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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>
/// PackageTaskView.xaml 的交互逻辑
/// </summary>
public partial class PackageTaskView : UserControl
{
public PackageTaskView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new PackageTaskViewModel());
}
}
}
using DevExpress.Data;
using DevExpress.Mvvm.POCO;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Plugin;
using VIZ.Package.Service;
namespace VIZ.Package.Module
{
/// <summary>
/// 包装任务视图模型
/// </summary>
public class PackageTaskViewModel : ViewModelBase, IPackageTaskService, IPackageTaskInterface
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(PackageTaskViewModel));
public PackageTaskViewModel()
{
// 初始化命令
this.InitCommand();
// 注册服务
ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.PACKAGE_TASK_SERVICE, this);
}
/// <summary>
/// 初始化命令
/// </summary>
private void InitCommand()
{
}
// ==============================================================
// Service & Controller
// ==============================================================
/// <summary>
/// Viz引擎命令服务
/// </summary>
private VizCommandService vizCommandService = new VizCommandService();
/// <summary>
/// Viz引擎控制对象服务
/// </summary>
private VizCommandControlObjectService vizCommandControlObjectService = new VizCommandControlObjectService();
// ==============================================================
// Property
// ==============================================================
#region ItemsSource -- 任务源
private ObservableCollection<PackageTaskModel> itemsSource = new ObservableCollection<PackageTaskModel>();
/// <summary>
/// 任务源
/// </summary>
public ObservableCollection<PackageTaskModel> ItemsSource
{
get { return itemsSource; }
set { itemsSource = value; this.RaisePropertyChanged(nameof(ItemsSource)); }
}
#endregion
// ==============================================================
// Command
// ==============================================================
// ==============================================================
// Public Function
// ==============================================================
/// <summary>
/// 注册任务
/// </summary>
/// <param name="task">任务</param>
public void Register(PackageTaskModel task)
{
lock (this.ItemsSource)
{
if (this.ItemsSource.Contains(task))
return;
task.PackageTaskInterface = this;
this.ItemsSource.Add(task);
}
}
/// <summary>
/// 取消任务
/// </summary>
/// <param name="task">任务</param>
public void Cancel(PackageTaskModel task)
{
lock (this.ItemsSource)
{
if (this.ItemsSource.Contains(task))
{
task.IsEnabled = false;
this.ItemsSource.Remove(task);
}
}
}
/// <summary>
/// 预览更新
/// </summary>
/// <param name="task">任务</param>
public void PreviewUpdate(PackageTaskModel task)
{
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.PreviewUpdateAction(item);
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
/// <summary>
/// 上版更新
/// </summary>
/// <param name="task">任务</param>
public void TakeUpdate(PackageTaskModel task)
{
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);
}
catch (Exception ex)
{
log.Error(ex);
}
}
}
/// <summary>
/// 销毁
/// </summary>
/// <param name="task">任务</param>
public void Dispose(PackageTaskModel task)
{
this.Cancel(task);
}
}
}
\ No newline at end of file
...@@ -104,6 +104,7 @@ ...@@ -104,6 +104,7 @@
<Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\FontListCellEdit.xaml.cs"> <Compile Include="ControlObject\FieldEdit\Edit\ListEdit\CellEdit\FontListCellEdit.xaml.cs">
<DependentUpon>FontListCellEdit.xaml</DependentUpon> <DependentUpon>FontListCellEdit.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Control\Service\IControlService.cs" />
<Compile Include="Log\ViewModel\ErrorLogWindowModel.cs" /> <Compile Include="Log\ViewModel\ErrorLogWindowModel.cs" />
<Compile Include="Log\View\ErrorLogWindow.xaml.cs"> <Compile Include="Log\View\ErrorLogWindow.xaml.cs">
<DependentUpon>ErrorLogWindow.xaml</DependentUpon> <DependentUpon>ErrorLogWindow.xaml</DependentUpon>
...@@ -128,6 +129,7 @@ ...@@ -128,6 +129,7 @@
<Compile Include="Page\Group\Widgets\PageNumberEdit.xaml.cs"> <Compile Include="Page\Group\Widgets\PageNumberEdit.xaml.cs">
<DependentUpon>PageNumberEdit.xaml</DependentUpon> <DependentUpon>PageNumberEdit.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Plugin\Model\PluginNavigationConfig.cs" />
<Compile Include="Plugin\Service\IPluginService.cs" /> <Compile Include="Plugin\Service\IPluginService.cs" />
<Compile Include="Resource\MediaResource\Controller\Model\ms.cs" /> <Compile Include="Resource\MediaResource\Controller\Model\ms.cs" />
<Compile Include="Resource\MediaResource\Core\MHResourceFileDoubleClickEventArgs.cs" /> <Compile Include="Resource\MediaResource\Core\MHResourceFileDoubleClickEventArgs.cs" />
...@@ -338,6 +340,12 @@ ...@@ -338,6 +340,12 @@
<Compile Include="Log\View\VizCommandWindow.xaml.cs"> <Compile Include="Log\View\VizCommandWindow.xaml.cs">
<DependentUpon>VizCommandWindow.xaml</DependentUpon> <DependentUpon>VizCommandWindow.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Task\PackageTask\PackageTaskPluginLifeCycle.cs" />
<Compile Include="Task\PackageTask\Service\IPackageTaskService.cs" />
<Compile Include="Task\PackageTask\ViewModel\PackageTaskViewModel.cs" />
<Compile Include="Task\PackageTask\View\PackageTaskView.xaml.cs">
<DependentUpon>PackageTaskView.xaml</DependentUpon>
</Compile>
<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>
...@@ -545,6 +553,10 @@ ...@@ -545,6 +553,10 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Task\PackageTask\View\PackageTaskView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Themes\Generic.xaml"> <Page Include="Themes\Generic.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
......
...@@ -13,6 +13,8 @@ using System.Windows.Media.Imaging; ...@@ -13,6 +13,8 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Module;
namespace VIZ.Package.TestPlugin namespace VIZ.Package.TestPlugin
{ {
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"> d:DesignHeight="450" d:DesignWidth="800">
<Grid> <Grid>
<TextBlock Text="TestPagePlugin" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="Red" <Button Width="240" Height="60" Click="Button_Click" Content="包装任务触发"></Button>
FontSize="36"></TextBlock>
</Grid> </Grid>
</UserControl> </UserControl>
...@@ -13,19 +13,111 @@ using System.Windows.Media.Imaging; ...@@ -13,19 +13,111 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using VIZ.Framework.Core; using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Module;
namespace VIZ.Package.TestPlugin namespace VIZ.Package.TestPlugin
{ {
/// <summary> /// <summary>
/// TestPageView.xaml 的交互逻辑 /// TestPageView.xaml 的交互逻辑
/// </summary> /// </summary>
public partial class TestPageView : UserControl public partial class TestPageView : UserControl, IPluginView
{ {
public TestPageView() public TestPageView()
{ {
InitializeComponent(); InitializeComponent();
WPFHelper.BindingViewModel(this, new TestPageViewModel()); WPFHelper.BindingViewModel(this, new TestPageViewModel());
this.Loaded += TestModuleView_Loaded;
}
private PackageTaskModel task;
private void TestModuleView_Loaded(object sender, RoutedEventArgs e)
{
if (this.task != null)
return;
this.task = new PackageTaskModel(this);
this.task.PreviewUpdateAction = this.OnPreviewUpdate;
this.task.TakeUpdateAction = this.OnTakeUpdate;
IPackageTaskService service = ApplicationDomainEx.ServiceManager.GetService<IPackageTaskService>(ViewServiceKeys.PACKAGE_TASK_SERVICE);
if (service == null)
return;
service.Register(this.task);
}
private void OnPreviewUpdate(ConnModel conn)
{
}
private void OnTakeUpdate(ConnModel conn)
{
}
/// <summary>
/// 上版
/// </summary>
/// <param name="conns">连接</param>
public void TakIn(ConnModel conns)
{ }
/// <summary>
/// 继续
/// </summary>
/// <param name="conn">连接</param>
public void TakeContinue(ConnModel conn)
{ }
/// <summary>
/// 下版子
/// </summary>
/// <param name="conn">连接</param>
public void TakeOut(ConnModel conn)
{ }
/// <summary>
/// 更新
/// </summary>
/// <param name="conn">连接</param>
public void TakeUpdate(ConnModel conn)
{ }
/// <summary>
/// 预览上版子
/// </summary>
/// <param name="conn">连接</param>
public void PreviewIn(ConnModel conn)
{ }
/// <summary>
/// 预览继续
/// </summary>
/// <param name="conn">连接</param>
public void PreviewContinue(ConnModel conn)
{ }
/// <summary>
/// 预览下版
/// </summary>
/// <param name="conn">连接</param>
public void PreviewOut(ConnModel conn)
{ }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{ }
private void Button_Click(object sender, RoutedEventArgs e)
{
this.task?.PreviewUpdate();
} }
} }
} }
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