Commit 9aa131c4 by liulongfei

节目单保存于读取

parent 64adaac7
......@@ -43,6 +43,20 @@ namespace VIZ.TVP.Domain
#endregion
#region ListID -- 所属节目单ID
private string listID;
/// <summary>
/// 所属节目单ID
/// </summary>
public string ListID
{
get { return listID; }
set { listID = value; this.RaisePropertyChanged(nameof(ListID)); }
}
#endregion
#region ProgramListModel -- 节目单模型
private ProgramListModel programListModel;
......@@ -169,6 +183,20 @@ namespace VIZ.TVP.Domain
#endregion
#region OrderIndex -- 排序索引
private int orderIndex;
/// <summary>
/// 排序索引
/// </summary>
public int OrderIndex
{
get { return orderIndex; }
set { orderIndex = value; this.RaisePropertyChanged(nameof(OrderIndex)); }
}
#endregion
// ---------------------------------------------------------------------
// 扩展属性
......@@ -201,5 +229,39 @@ namespace VIZ.TVP.Domain
this.Thumbnail = template.Thumbnail;
this.ThumbnailBitmap = template.ThumbnailBitmap;
}
/// <summary>
/// 从实体中获取属性
/// </summary>
public void PropertyFromEntity()
{
this.TemplateID = this.Entity.TemplateID;
this.ListID = this.Entity.ListID;
this.TemplateType = this.Entity.TemplateType;
this.SceneName = this.Entity.SceneName;
this.Remark = this.Entity.Remark;
this.Thumbnail = this.Entity.Thumbnail;
this.Layer = this.Entity.Layer;
this.EngineType = this.Entity.EngineType;
this.PluginID = this.Entity.PluginID;
this.OrderIndex = this.Entity.OrderIndex;
}
/// <summary>
/// 将属性填充至实体
/// </summary>
public void PropertyToEntity()
{
this.Entity.TemplateID = this.TemplateID;
this.Entity.ListID = this.ListID;
this.Entity.TemplateType = this.TemplateType;
this.Entity.SceneName = this.SceneName;
this.Entity.Remark = this.Remark;
this.Entity.Thumbnail = this.Thumbnail;
this.Entity.Layer = this.Layer;
this.Entity.EngineType = this.EngineType;
this.Entity.PluginID = this.PluginID;
this.Entity.OrderIndex = this.OrderIndex;
}
}
}
......@@ -56,6 +56,20 @@ namespace VIZ.TVP.Domain
#endregion
#region OrderIndex -- 排序索引
private int orderIndex;
/// <summary>
/// 排序索引
/// </summary>
public int OrderIndex
{
get { return orderIndex; }
set { orderIndex = value; this.RaisePropertyChanged(nameof(OrderIndex)); }
}
#endregion
#region Items -- 子项集合
private ObservableCollection<ProgramListItemModel> items = new ObservableCollection<ProgramListItemModel>();
......@@ -69,5 +83,25 @@ namespace VIZ.TVP.Domain
}
#endregion
/// <summary>
/// 从实体中获取属性
/// </summary>
public void PropertyFromEntity()
{
this.ListID = this.Entity.ListID;
this.Name = this.Entity.Name;
this.OrderIndex = this.Entity.OrderIndex;
}
/// <summary>
/// 将属性填充至实体
/// </summary>
public void PropertyToEntity()
{
this.Entity.ListID = this.ListID;
this.Entity.Name = this.Name;
this.Entity.OrderIndex = this.OrderIndex;
}
}
}
......@@ -126,6 +126,20 @@ namespace VIZ.TVP.Domain
#endregion
#region OrderIndex -- 排序索引
private int orderIndex;
/// <summary>
/// 排序索引
/// </summary>
public int OrderIndex
{
get { return orderIndex; }
set { orderIndex = value; this.RaisePropertyChanged(nameof(OrderIndex)); }
}
#endregion
// ---------------------------------------------------------------------
// 扩展属性
......@@ -143,5 +157,34 @@ namespace VIZ.TVP.Domain
#endregion
/// <summary>
/// 从实体中获取属性
/// </summary>
public void PropertyFromEntity()
{
this.TemplateID = this.Entity.TemplateID;
this.TemplateType = this.Entity.TemplateType;
this.SceneName = this.Entity.SceneName;
this.Thumbnail = this.Entity.Thumbnail;
this.Remark = this.Entity.Remark;
this.Layer = this.Entity.Layer;
this.EngineType = this.Entity.EngineType;
this.OrderIndex = this.Entity.OrderIndex;
}
/// <summary>
/// 将属性填充至实体
/// </summary>
public void PropertyToEntity()
{
this.Entity.TemplateID = this.TemplateID;
this.Entity.TemplateType = this.TemplateType;
this.Entity.SceneName = this.SceneName;
this.Entity.Thumbnail = this.Thumbnail;
this.Entity.Remark = this.Remark;
this.Entity.Layer = this.Layer;
this.Entity.EngineType = this.EngineType;
this.Entity.OrderIndex = this.OrderIndex;
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
......
......@@ -27,7 +27,7 @@
<dxmvvm:EventToCommand EventName="Loaded" Command="{Binding Path=LoadedCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<Grid>
<Grid IsEnabled="{Binding Path=HasProjectDomain}">
<Grid.RowDefinitions>
<RowDefinition Height="*" MinHeight="120"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
......@@ -46,6 +46,13 @@
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RowData.RowHandle,Converter={StaticResource RowHandleConverter}}"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="缩略图" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
......@@ -77,8 +84,21 @@
</dxg:GridControl>
</dx:DXTabItem>
<dx:DXTabItem Header="其他模板">
<dxg:GridControl ItemsSource="{Binding Path=OtherTemplateModels}" ShowBorder="False">
<dxg:GridControl ItemsSource="{Binding Path=OtherTemplateModels}" ShowBorder="False"
SelectedItem="{Binding Path=SelectedOtherTemplateModel,Mode=TwoWay}">
<dxg:GridControl.ContextMenu>
<ContextMenu>
<MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.OtherTemplateAddToListCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
<dxg:GridColumn Header="序号" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="40" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<TextBlock Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding RowData.RowHandle,Converter={StaticResource RowHandleConverter}}"></TextBlock>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
<dxg:GridColumn Header="缩略图" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
......@@ -107,7 +127,7 @@
</dxg:GridControl>
</dx:DXTabItem>
</dx:DXTabControl>
<dx:WaitIndicator DeferedVisibility="{Binding IsProgramTemplateLoading}" Content="Loading..." />
<GridSplitter VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Height="4"></GridSplitter>
<!-- 节目单 -->
<dx:DXTabControl Grid.Row="1" Margin="0,10,0,0"
......@@ -152,7 +172,7 @@
<dxg:GridColumn Header="缩略图" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False" Width="120" AllowResizing="False">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<Image Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
<Image Width="120" Source="{Binding Path=Row.ThumbnailBitmap,Converter={StaticResource Bitmap2ImageSourceConverter}}"></Image>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>
......@@ -163,6 +183,9 @@
</dxg:GridColumn.EditSettings>
</dxg:GridColumn>
<dxg:GridColumn Header="层" FieldName="Layer" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="false"></dxg:GridColumn>
<dxg:GridColumn Header="模板类型" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"
Binding="{Binding Path=TemplateType,Converter={StaticResource Enum2EnumDescriptionConverter}}">
</dxg:GridColumn>
<dxg:GridColumn Header="引擎类型" FieldName="EngineType" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
<dxg:GridColumn Header="插件" FieldName="PluginName" ReadOnly="True" AllowSorting="False" AllowColumnFiltering="False"></dxg:GridColumn>
</dxg:GridControl.Columns>
......@@ -188,5 +211,6 @@
</Style>
</dx:DXTabControl.ItemContainerStyle>
</dx:DXTabControl>
<dx:WaitIndicator DeferedVisibility="{Binding IsProgramListLoading}" Content="Loading..." Grid.Row="1" />
</Grid>
</UserControl>
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.TVP.Domain;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Service
{
......@@ -11,5 +15,122 @@ namespace VIZ.TVP.Service
/// </summary>
public class ProgramService : IProgramService
{
/// <summary>
/// 节目服务锁
/// </summary>
public static object lock_object = new object();
/// <summary>
/// 加载节目模板集合
/// </summary>
/// <returns>节目模板集合</returns>
public ObservableCollection<ProgramTemplateModel> LoadProgramTemplateModels()
{
List<ProgramTemplateModel> list = new List<ProgramTemplateModel>();
foreach (var entity in ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramTemplate.FindAll())
{
ProgramTemplateModel model = new ProgramTemplateModel(entity);
model.PropertyFromEntity();
list.Add(model);
}
return list.OrderBy(p => p.OrderIndex).ToObservableCollection();
}
/// <summary>
/// 保存节目模板集合
/// </summary>
/// <param name="models">节目模板集合</param>
public void SaveProgramTemplateModels(IList<ProgramTemplateModel> models)
{
lock (lock_object)
{
List<ProgramTemplateEntity> list = new List<ProgramTemplateEntity>();
for (int i = 0; i < models.Count; i++)
{
ProgramTemplateModel model = models[i];
model.OrderIndex = i;
model.PropertyToEntity();
list.Add(model.Entity);
}
ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramTemplate.DeleteAll();
ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramTemplate.Insert(list);
}
}
/// <summary>
/// 加载节目单集合
/// </summary>
/// <returns>节目单集合</returns>
public ObservableCollection<ProgramListModel> LoadProgramListModels()
{
List<ProgramListModel> list = new List<ProgramListModel>();
foreach (var entity in ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramList.FindAll())
{
ProgramListModel model = new ProgramListModel(entity);
model.PropertyFromEntity();
list.Add(model);
}
Dictionary<string, ProgramListModel> dic = list.ToDictionary(p => p.ListID, p => p);
foreach (var entity in ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramListItem.FindAll())
{
ProgramListItemModel model = new ProgramListItemModel(entity);
model.PropertyFromEntity();
if (!dic.TryGetValue(model.ListID, out ProgramListModel owner))
continue;
model.ProgramListModel = owner;
owner.Items.Add(model);
}
foreach (var model in list)
{
model.Items = model.Items.OrderBy(p => p.OrderIndex).ToObservableCollection();
}
return list.OrderBy(p => p.OrderIndex).ToObservableCollection();
}
/// <summary>
/// 保存节目单模型集合
/// </summary>
/// <param name="models">节目单模型集合</param>
public void SaveProgramListModels(IList<ProgramListModel> models)
{
lock (lock_object)
{
List<ProgramListEntity> listEntitys = new List<ProgramListEntity>();
List<ProgramListItemEntity> listItemEntitys = new List<ProgramListItemEntity>();
for (int i = 0; i < models.Count; i++)
{
ProgramListModel listModel = models[i];
listModel.OrderIndex = i;
listModel.PropertyToEntity();
listEntitys.Add(listModel.Entity);
for (int j = 0; j < listModel.Items.Count; j++)
{
ProgramListItemModel listItemModel = listModel.Items[j];
listItemModel.OrderIndex = j;
listItemModel.PropertyToEntity();
listItemEntitys.Add(listItemModel.Entity);
}
}
ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramListItem.DeleteAll();
ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramList.DeleteAll();
ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramListItem.Insert(listItemEntitys);
ApplicationDomainEx.CurrentProjectDomain.ProjectContext.ProgramList.Insert(listEntitys);
}
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Domain;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Service
{
......@@ -11,5 +14,28 @@ namespace VIZ.TVP.Service
/// </summary>
public interface IProgramService
{
/// <summary>
/// 加载节目模板集合
/// </summary>
/// <returns>节目模板集合</returns>
ObservableCollection<ProgramTemplateModel> LoadProgramTemplateModels();
/// <summary>
/// 保存节目模板集合
/// </summary>
/// <param name="models">节目模板集合</param>
void SaveProgramTemplateModels(IList<ProgramTemplateModel> models);
/// <summary>
/// 加载节目单集合
/// </summary>
/// <returns>节目单集合</returns>
ObservableCollection<ProgramListModel> LoadProgramListModels();
/// <summary>
/// 保存节目单模型集合
/// </summary>
/// <param name="models">节目单模型集合</param>
void SaveProgramListModels(IList<ProgramListModel> models);
}
}
......@@ -49,6 +49,9 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="LiteDB, Version=5.0.13.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.13\lib\net45\LiteDB.dll</HintPath>
</Reference>
<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>
</Reference>
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="LiteDB" version="5.0.13" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" />
</packages>
\ No newline at end of file
......@@ -26,5 +26,10 @@ namespace VIZ.TVP.Storage
/// 名称
/// </summary>
public string Name { get; set; }
/// <summary>
/// 排序索引
/// </summary>
public int OrderIndex { get; set; }
}
}
......@@ -30,7 +30,7 @@ namespace VIZ.TVP.Storage
/// <summary>
/// 模板类型
/// </summary>
public ProgramTemplateType TempalteType { get; set; }
public ProgramTemplateType TemplateType { get; set; }
/// <summary>
/// 场景名
......@@ -56,5 +56,15 @@ namespace VIZ.TVP.Storage
/// 引擎类型
/// </summary>
public TVPEngineType EngineType { get; set; }
/// <summary>
/// 插件ID
/// </summary>
public string PluginID { get; set; }
/// <summary>
/// 排序索引
/// </summary>
public int OrderIndex { get; set; }
}
}
......@@ -25,7 +25,7 @@ namespace VIZ.TVP.Storage
/// <summary>
/// 模板类型
/// </summary>
public ProgramTemplateType TempalteType { get; set; }
public ProgramTemplateType TemplateType { get; set; }
/// <summary>
/// 场景名
......@@ -51,5 +51,10 @@ namespace VIZ.TVP.Storage
/// 引擎类型
/// </summary>
public TVPEngineType EngineType { get; set; }
/// <summary>
/// 排序索引
/// </summary>
public int OrderIndex { get; set; }
}
}
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