Commit af87145b by liulongfei

添加系统缓存数据库

parent d4770a55
......@@ -9,7 +9,7 @@ namespace VIZ.TVP.Connection
/// <summary>
/// 包装终结点管理器
/// </summary>
public interface ITVPEndpointManager
public interface ITVPEndpointManager : IDisposable
{
}
}
......@@ -10,6 +10,7 @@ using VIZ.Framework.Connection;
using VizConnectC;
using VIZ.Framework.Core;
using System.Web.WebSockets;
using VIZ.TVP.Domain;
namespace VIZ.TVP.Connection
{
......
......@@ -72,10 +72,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Protocol\ITVPEndpointManager.cs" />
<Compile Include="Protocol\VIZ\VizConnection.cs" />
<Compile Include="Protocol\VIZ\VizEndpointManager.cs" />
<Compile Include="TVPConnectionManager.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Connection\VIZ.Framework.Connection.csproj">
......
......@@ -23,5 +23,22 @@ namespace VIZ.TVP.Domain
/// 窗口管理器
/// </summary>
public static WindowManager WindowManager { get; private set; } = new WindowManager();
/// <summary>
/// 数据库管理器
/// </summary>
public static DataBaseManager DataBaseManager { get; private set; } = new DataBaseManager();
/// <summary>
/// 包装连接管理器
/// </summary>
public static TVPConnectionManager TVPConnectionManager { get; private set; } = new TVPConnectionManager();
/// <summary>
/// 当前项目领域
/// </summary>
public static ProjectDomain CurrentProjectDomain { get; set; }
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.TVP.Storage;
namespace VIZ.TVP.Domain
{
/// <summary>
/// 数据管理器
/// </summary>
public class DataBaseManager : IDisposable
{
/// <summary>
/// 缓存数据库
/// </summary>
public LiteDbContext LiteDbContext { get; set; }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Domain
{
/// <summary>
/// 包装连接管理器
/// </summary>
public class TVPConnectionManager : IDisposable
{
/// <summary>
/// 连接分组集合
/// </summary>
public ObservableCollection<TVPConnectionGroupModel> ConnectionGroups { get; private set; } = new ObservableCollection<TVPConnectionGroupModel>();
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
......@@ -4,13 +4,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Connection
namespace VIZ.TVP.Domain
{
/// <summary>
/// 包装连接管理器
/// 包装终结点管理器
/// </summary>
public static class TVPConnectionManager
public interface ITVPEndpointManager : IDisposable
{
}
}
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.Storage;
namespace VIZ.TVP.Domain
{
/// <summary>
/// 包装连接分组模型
/// </summary>
public class TVPConnectionGroupModel : ModelBase
{
#region GroupID -- 分组ID
private string groupID;
/// <summary>
/// 分组ID
/// </summary>
public string GroupID
{
get { return groupID; }
set { groupID = value; this.RaisePropertyChanged(nameof(GroupID)); }
}
#endregion
#region GroupDisplayName -- 分组显示名称
private string groupDisplayName;
/// <summary>
/// 分组显示名称
/// </summary>
public string GroupDisplayName
{
get { return groupDisplayName; }
set { groupDisplayName = value; this.RaisePropertyChanged(nameof(GroupDisplayName)); }
}
#endregion
#region Items -- 子项集合
private ObservableCollection<TVPConnectionModel> items = new ObservableCollection<TVPConnectionModel>();
/// <summary>
/// 子项集合
/// </summary>
public ObservableCollection<TVPConnectionModel> Items
{
get { return items; }
set { items = value; this.RaisePropertyChanged(nameof(Items)); }
}
#endregion
#region Type -- 连接类型
private TVPConnectionType type;
/// <summary>
/// 连接类型
/// </summary>
public TVPConnectionType Type
{
get { return type; }
set { type = value; this.RaisePropertyChanged(nameof(Type)); }
}
#endregion
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.TVP.Domain
{
/// <summary>
/// 包装连接模型
/// </summary>
public class TVPConnectionModel : ModelBase, IDisposable
{
#region ID -- 编号
private string id;
/// <summary>
/// 编号
/// </summary>
public string ID
{
get { return id; }
set { id = value; this.RaisePropertyChanged(nameof(ID)); }
}
#endregion
#region DisplayName -- 显示名称
private string displayName;
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName
{
get { return displayName; }
set { displayName = value; this.RaisePropertyChanged(nameof(DisplayName)); }
}
#endregion
#region IsEnabled -- 是否启用
private bool isEnabled;
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled
{
get { return isEnabled; }
set { isEnabled = value; this.RaisePropertyChanged(nameof(IsEnabled)); }
}
#endregion
#region IsConnected -- 是否处于连接状态
private bool isConnected;
/// <summary>
/// 是否处于连接状态
/// </summary>
public bool IsConnected
{
get { return isConnected; }
set { isConnected = value; this.RaisePropertyChanged(nameof(IsConnected)); }
}
#endregion
/// <summary>
/// 连接终结点
/// </summary>
public ITVPEndpointManager EndpointManager { get; set; }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
this.EndpointManager?.Dispose();
this.EndpointManager = null;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
namespace VIZ.TVP.Domain
{
/// <summary>
/// 项目领域
/// </summary>
public class ProjectDomain : IDisposable
{
/// <summary>
/// 项目名称
/// </summary>
public string ProjectName { get; set; }
/// <summary>
/// 项目文件地址
/// </summary>
public string ProjectFilePath { get; set; }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
}
}
}
......@@ -72,14 +72,20 @@
<Compile Include="ApplicationDomainEx.cs" />
<Compile Include="Enum\PluginIDs.cs" />
<Compile Include="Enum\ServiceKeys.cs" />
<Compile Include="Manager\DataBaseManager.cs" />
<Compile Include="Manager\PluginManager.cs" />
<Compile Include="Manager\TVPConnectionManager.cs" />
<Compile Include="Manager\WindowManager.cs" />
<Compile Include="Model\TVPConnection\ITVPEndpointManager.cs" />
<Compile Include="Model\TVPConnection\TVPConnectionGroupModel.cs" />
<Compile Include="Model\TVPConnection\TVPConnectionModel.cs" />
<Compile Include="Model\Resource\Enum\ResourceFileType.cs" />
<Compile Include="Model\Resource\Enum\ResourceFolderType.cs" />
<Compile Include="Model\Resource\GH\GHResourceFileModel.cs" />
<Compile Include="Model\Resource\GH\GHResourceFolderModel.cs" />
<Compile Include="Model\Resource\ResourceFileModelBase.cs" />
<Compile Include="Model\Resource\ResourceFolderModelBase.cs" />
<Compile Include="ProjectDomain.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;
using VIZ.Framework.Core;
using VIZ.Framework.Domain;
using VIZ.Framework.Connection;
using VIZ.Framework.Storage;
using VIZ.Framework.Module;
using VIZ.TVP.Domain;
namespace VIZ.TVP.Module
{
/// <summary>
/// 应用程序启动 -- 初始化LiteDB
/// </summary>
public class AppSetup_InitLiteDB : AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitLiteDB));
/// <summary>
/// 描述
/// </summary>
public override string Detail { get; } = "应用程序启动 -- 初始化LiteDB";
/// <summary>
/// 执行启动
/// </summary>
/// <param name="context">应用程序启动上下文</param>
/// <returns>是否成功执行</returns>
public override bool Setup(AppSetupContext context)
{
string folder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "db");
if (!System.IO.Directory.Exists(folder))
{
System.IO.Directory.CreateDirectory(folder);
}
string path = System.IO.Path.Combine(folder, "cache.db");
ApplicationDomainEx.DataBaseManager.LiteDbContext = new Storage.LiteDbContext(path);
return true;
}
/// <summary>
/// 执行关闭
/// </summary>
/// <param name="context">应用程序启动上下文</param>
public override void Shutdown(AppSetupContext context)
{
ApplicationDomainEx.DataBaseManager.LiteDbContext?.Dispose();
ApplicationDomainEx.DataBaseManager.LiteDbContext = null;
}
}
}
......@@ -156,8 +156,10 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="Setup\Provider\Setup\AppSetup_InitLiteDB.cs" />
<Compile Include="VizRender\Controller\VizController\IVizSupport.cs" />
<Compile Include="VizRender\Controller\VizController\VizController.cs" />
<Compile Include="VizRender\Model\VizConnectionModel.cs" />
<Compile Include="VizRender\ViewModel\VizRenderViewModel.cs" />
<Compile Include="VizRender\VizRenderPluginLifeCycle.cs" />
<Compile Include="VizResource\Controller\VizResourceFile\IVizResourceFileSupport.cs" />
......@@ -241,9 +243,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="Connection\" />
<Folder Include="Login\Service\" />
<Folder Include="Setup\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Module
{
/// <summary>
/// Viz连接模型
/// </summary>
public class VizConnectionModel
{
}
}
using LiteDB;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Storage
{
/// <summary>
/// 本地缓存数据库
/// </summary>
public class LiteDbContext : IDisposable
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(LiteDbContext));
/// <summary>
/// 数据库
/// </summary>
private ILiteDatabase Database;
/// <summary>
/// LiteDB数据库
/// </summary>
/// <param name="path">数据库路径</param>
public LiteDbContext(string path)
{
this.Path = path;
this.Database = new LiteDatabase(path);
// 包装连接
this.TVPConnectionGroup = this.Database.GetCollection<TVPConnectionGroupEntity>();
this.TVPConnection = this.Database.GetCollection<TVPConnectionEntity>();
}
/// <summary>
/// 数据库文件路径
/// </summary>
public string Path { get; private set; }
// -----------------------------------------------------------------------------------------------------------
// -- OpenCV --
// -----------------------------------------------------------------------------------------------------------
/// <summary>
/// 连接分组
/// </summary>
public ILiteCollection<TVPConnectionGroupEntity> TVPConnectionGroup { get; private set; }
/// <summary>
/// 连接
/// </summary>
public ILiteCollection<TVPConnectionEntity> TVPConnection { get; private set; }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
{
this.TVPConnectionGroup = null;
this.TVPConnection = null;
this.Database?.Dispose();
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Storage
{
/// <summary>
/// 包装连接类型
/// </summary>
public enum TVPConnectionType
{
/// <summary>
/// VIZ
/// </summary>
VIZ
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Storage
{
/// <summary>
/// 包装连接实体
/// </summary>
public class TVPConnectionEntity
{
/// <summary>
/// 编号
/// </summary>
[LiteDB.BsonId(true)]
public int Id { get; set; }
/// <summary>
/// 分组ID
/// </summary>
public int GroupId { get; set; }
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// IP地址
/// </summary>
public string IP { get; set; }
/// <summary>
/// 端口
/// </summary>
public int Port { get; set; }
/// <summary>
/// 是否启用
/// </summary>
public bool IsEnabled { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Storage
{
/// <summary>
/// 包装连接分组实体
/// </summary>
public class TVPConnectionGroupEntity
{
/// <summary>
/// 编号
/// </summary>
[LiteDB.BsonId(true)]
public int Id { get; set; }
/// <summary>
/// 显示名称
/// </summary>
public string DisplayName { get; set; }
/// <summary>
/// 连接类型
/// </summary>
public TVPConnectionType ConnectionType { get; set; }
}
}
......@@ -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>
......@@ -67,6 +70,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="LiteDB\Application\TVPConnection\Enum\TVPConnectionType.cs" />
<Compile Include="LiteDB\Application\TVPConnection\TVPConnectionEntity.cs" />
<Compile Include="LiteDB\Application\LiteDbContext.cs" />
<Compile Include="LiteDB\Application\TVPConnection\TVPConnectionGroupEntity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="XML\GH\Enum\GH_Category_Term_Enums.cs" />
<Compile Include="XML\GH\Enum\GH_Content_Type_Enums.cs" />
......
<?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" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net48" />
</packages>
\ No newline at end of file
......@@ -24,6 +24,7 @@ namespace VIZ.TVP
ApplicationThemeHelper.ApplicationThemeName = Theme.VS2019DarkName;
// TODO: AppSetup
AppSetup.AppendSetup(new AppSetup_InitLiteDB());
// 执行启动流程
AppSetupContext context = AppSetup.Setup();
......
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