Commit 9527fa3e by wangonghui

媒体资源添加修改

parent 6c361a41
...@@ -27,6 +27,12 @@ namespace VIZ.TVP.Domain ...@@ -27,6 +27,12 @@ namespace VIZ.TVP.Domain
/// </summary> /// </summary>
public CsvContext CsvContext { get; set; } public CsvContext CsvContext { get; set; }
/// <summary>
/// 媒体库配置文件
/// </summary>
public ConfigContext ConfigContext { get; set; }
/// <summary> /// <summary>
/// 销毁 /// 销毁
/// </summary> /// </summary>
......
...@@ -74,7 +74,7 @@ namespace VIZ.TVP.Module ...@@ -74,7 +74,7 @@ namespace VIZ.TVP.Module
} }
else if (ThumbnailHelper.IsVideo(fileModel.Path)) else if (ThumbnailHelper.IsVideo(fileModel.Path))
{ {
string strVedioPath = string.Format("{0}{1}", System.Environment.CurrentDirectory, "\\VedioImage\\Vedio.jpeg"); string strVedioPath = string.Format("{0}{1}", System.Environment.CurrentDirectory, "\\Resource\\VedioImage\\Vedio.jpeg");
Image vedioImage = Image.FromFile(strVedioPath); Image vedioImage = Image.FromFile(strVedioPath);
......
...@@ -49,15 +49,6 @@ namespace VIZ.TVP.Module ...@@ -49,15 +49,6 @@ namespace VIZ.TVP.Module
{ {
try try
{ {
//string newPath = "";
//if (File.Exists(Application.StartupPath + path))
//{
// newPath = Application.StartupPath + path;
//}
//else
//{//如果图片不存在,使用默认图片
// //newPath = Application.StartupPath + LocalConfig.defaultPicPath;
//}
FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
Image result = Image.FromStream(fs); Image result = Image.FromStream(fs);
fs.Close(); fs.Close();
...@@ -88,16 +79,27 @@ namespace VIZ.TVP.Module ...@@ -88,16 +79,27 @@ namespace VIZ.TVP.Module
return false; return false;
} }
} }
public static Boolean IsImageByName(string name) public static Boolean IsImageByName(string name)
{ {
int pos = name.LastIndexOf("."); try
if (name.Length - pos - 1 < 3) {
return false; if (name == null) return false;
int pos = name.LastIndexOf(".");
if (name.Length - pos - 1 < 3)
return false;
string ext = name.Substring(pos + 1, name.Length - pos - 1); string ext = name.Substring(pos + 1, name.Length - pos - 1);
string[] imge = { "jpg", "jpeg", "png", "gif", "bmp", "TIFF", "tif" }; string[] imge = { "jpg", "jpeg", "png", "gif", "bmp", "TIFF", "tif" };
return IsInIgnoreCase(ext, imge);
}
catch(Exception e)
{
return false;
}
return IsInIgnoreCase(ext, imge);
} }
private static bool IsInIgnoreCase(string source, params string[] list) private static bool IsInIgnoreCase(string source, params string[] list)
...@@ -159,10 +161,30 @@ namespace VIZ.TVP.Module ...@@ -159,10 +161,30 @@ namespace VIZ.TVP.Module
return isVideo; return isVideo;
} }
#endregion /// <summary>
/// 从完整路径中查找文件或文件夹名称
/// </summary>
/// <param name="path">完整路径</param>
/// <returns></returns>
public static string GetFileFolderName(string path)
{
// 如果没有路径,则返回空
if (string.IsNullOrEmpty(path))
return string.Empty;
// 使所有斜杠成反斜杠
var normalizedPath = path.Replace('/', '\\');
// 找到最后一个反斜杠就是路径
var lastIndex = normalizedPath.LastIndexOf('\\');
// 如果找不到反斜线,则返回路径本身
if (lastIndex <= 0)
return path;
// 最后一个反斜杠后返回名称
return path.Substring(lastIndex + 1);
}
#endregion
} }
} }
...@@ -273,30 +273,6 @@ namespace VIZ.TVP.Module ...@@ -273,30 +273,6 @@ namespace VIZ.TVP.Module
#endregion #endregion
/// <summary>
/// 从完整路径中查找文件或文件夹名称
/// </summary>
/// <param name="path">完整路径</param>
/// <returns></returns>
public static string GetFileFolderName(string path)
{
// 如果没有路径,则返回空
if (string.IsNullOrEmpty(path))
return string.Empty;
// 使所有斜杠成反斜杠
var normalizedPath = path.Replace('/', '\\');
// 找到最后一个反斜杠就是路径
var lastIndex = normalizedPath.LastIndexOf('\\');
// 如果找不到反斜线,则返回路径本身
if (lastIndex <= 0)
return path;
// 最后一个反斜杠后返回名称
return path.Substring(lastIndex + 1);
}
...@@ -369,7 +345,7 @@ namespace VIZ.TVP.Module ...@@ -369,7 +345,7 @@ namespace VIZ.TVP.Module
{ {
selectedFolderModel.Children.Add(new LFResourceFolderModel() selectedFolderModel.Children.Add(new LFResourceFolderModel()
{ {
Name = GetFileFolderName(directoryPath), Name = ThumbnailHelper.GetFileFolderName(directoryPath),
Path = directoryPath, Path = directoryPath,
FolderType = ResourceFolderType.Folder FolderType = ResourceFolderType.Folder
}); });
...@@ -446,7 +422,7 @@ namespace VIZ.TVP.Module ...@@ -446,7 +422,7 @@ namespace VIZ.TVP.Module
Files.ForEach(filePath => Files.ForEach(filePath =>
{ {
var ghFileModel = new LFResourceFileModel(); var ghFileModel = new LFResourceFileModel();
ghFileModel.Name = GetFileFolderName(filePath); ghFileModel.Name = ThumbnailHelper.GetFileFolderName(filePath);
ghFileModel.Path = filePath; ghFileModel.Path = filePath;
files.Add(ghFileModel); files.Add(ghFileModel);
......
...@@ -7,6 +7,7 @@ using System.Linq; ...@@ -7,6 +7,7 @@ using System.Linq;
using System.Net.Http; using System.Net.Http;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web.UI.WebControls;
namespace VIZ.TVP.Module namespace VIZ.TVP.Module
{ {
...@@ -36,9 +37,9 @@ namespace VIZ.TVP.Module ...@@ -36,9 +37,9 @@ namespace VIZ.TVP.Module
return responseBody; return responseBody;
} }
catch(Exception ex) catch (Exception ex)
{ {
log.Error(string.Format("{0}_{1}","获取媒体资源文件夹",ex.ToString())); log.Error(string.Format("{0}_{1}", "获取媒体资源文件夹", ex.ToString()));
return ""; return "";
} }
...@@ -72,7 +73,7 @@ namespace VIZ.TVP.Module ...@@ -72,7 +73,7 @@ namespace VIZ.TVP.Module
//} //}
//else //else
//{ //{
responseBody = await response.Content.ReadAsStringAsync(); responseBody = await response.Content.ReadAsStringAsync();
//} //}
return responseBody; return responseBody;
...@@ -105,7 +106,7 @@ namespace VIZ.TVP.Module ...@@ -105,7 +106,7 @@ namespace VIZ.TVP.Module
//} //}
//else //else
//{ //{
responseBody = await response.Content.ReadAsStringAsync(); responseBody = await response.Content.ReadAsStringAsync();
//} //}
return responseBody; return responseBody;
...@@ -139,7 +140,7 @@ namespace VIZ.TVP.Module ...@@ -139,7 +140,7 @@ namespace VIZ.TVP.Module
} }
/// <summary> /// <summary>
/// 获取图片 /// 获取图片
/// </summary> /// </summary>
...@@ -159,9 +160,42 @@ namespace VIZ.TVP.Module ...@@ -159,9 +160,42 @@ namespace VIZ.TVP.Module
return ms; return ms;
} }
}
/// <summary>
/// 上传图片
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="requestUri"></param>
/// <param name="path"></param>
/// <param name="fileName"></param>
/// <returns></returns>
public static async Task<T> PostImage<T>(string requestUri,string path,string fileName)
{
HttpClient client = new HttpClient();
var content = new MultipartFormDataContent();
content.Headers.Add("ContentType", $"multipart/form-data");
//添加字符串参数,参数名为qq
// content.Add(new StringContent("123456"), "qq");
//string path = Path.Combine(System.Environment.CurrentDirectory, "1.png");
//添加文件参数,参数名为files,文件名为123.png
var b = new ByteArrayContent(System.IO.File.ReadAllBytes(path));
content.Add(new ByteArrayContent(System.IO.File.ReadAllBytes(path)), "image", fileName);
var response = await client.PostAsync(requestUri, content);
var result = response.Content.ReadAsStringAsync().Result;
return JsonConvert.DeserializeObject<T>(result);
} }
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Module.Resource.MediaResource.Controller.Model
{
public class fileUploadResult
{
/// <summary>
/// 状态码:0-成功
/// </summary>
public string errCode
{
get;
set;
}
/// <summary>
/// 状态描述:0-成功
/// </summary>
public string message
{
get;
set;
}
/// <summary>
/// 状态描述:0-success
/// </summary>
public string status
{
get;
set;
}
/// <summary>
/// 设置文件信息
/// </summary>
public ms masterData = new ms();
}
}
<UserControl x:Class="VIZ.TVP.Module.CreateFolder"
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:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
d:DataContext="{d:DesignInstance Type=local:CreateProjectViewModel}"
d:Background="White"
xmlns:local="clr-namespace:VIZ.TVP.Module"
mc:Ignorable="d"
d:DesignHeight="200" d:DesignWidth="400">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="80"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TextBlock Text="文件名:" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="0,0,10,0"></TextBlock>
<TextBox Text="{Binding Path=FolderName}" Grid.Column="1" VerticalAlignment="Center" VerticalContentAlignment="Center"
AcceptsReturn="False" TextWrapping="NoWrap" Height="30" Margin="10,0,10,0"></TextBox>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="确定" Width="80" Height="30" Margin="10" Command="{Binding EnterCommand}"></Button>
<Button Content="取消" Width="80" Height="30" Margin="10" Command="{Binding CancelCommand}"></Button>
</StackPanel>
</Grid>
</UserControl>
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.TVP.Module
{
/// <summary>
/// Interaction logic for CreateFolder.xaml
/// </summary>
public partial class CreateFolder : UserControl
{
public CreateFolder()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new CreateFolderViewModel());
}
}
}
<dx:ThemedWindow
x:Class="VIZ.TVP.Module.CreateFolderWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:module="clr-namespace:VIZ.TVP.Module"
Title="创建文件夹" Height="240" Width="400" WindowStartupLocation="CenterScreen" WindowStyle="None" >
<Grid>
<module:CreateFolder x:Name="createFolderView"></module:CreateFolder>
</Grid>
</dx:ThemedWindow>
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.TVP.Module
{
/// <summary>
/// Interaction logic for CreateFolderWindow.xaml
/// </summary>
public partial class CreateFolderWindow : ThemedWindow
{
public CreateFolderWindow()
{
InitializeComponent();
}
}
}
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
<dxg:TreeViewControl.ContextMenu> <dxg:TreeViewControl.ContextMenu>
<ContextMenu> <ContextMenu>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFolderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFolderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="创建文件夹" Command="{Binding Path=PlacementTarget.DataContext.CreateFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除文件夹" Command="{Binding Path=PlacementTarget.DataContext.DeleteFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="移入文件夹" Command="{Binding Path=PlacementTarget.DataContext.MoveFloderCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu> </ContextMenu>
</dxg:TreeViewControl.ContextMenu> </dxg:TreeViewControl.ContextMenu>
<dxmvvm:Interaction.Behaviors> <dxmvvm:Interaction.Behaviors>
...@@ -112,8 +115,11 @@ ...@@ -112,8 +115,11 @@
<dxmvvm:EventToCommand EventName="Opened" Command="{Binding Path=FileContextMenuOpendCommand}"></dxmvvm:EventToCommand> <dxmvvm:EventToCommand EventName="Opened" Command="{Binding Path=FileContextMenuOpendCommand}"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors> </dxmvvm:Interaction.Behaviors>
<MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="刷新" Command="{Binding Path=PlacementTarget.DataContext.RefreshFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="添加文件" Command="{Binding Path=PlacementTarget.DataContext.CreateFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除文件" Command="{Binding Path=PlacementTarget.DataContext.DeleteFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="移动文件" Command="{Binding Path=PlacementTarget.DataContext.MoveFileCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator/> <Separator/>
<MenuItem Header="添加至场景模板" Command="{Binding Path=PlacementTarget.DataContext.AddProgramTemplateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <!--<MenuItem Header="添加至场景模板" Command="{Binding Path=PlacementTarget.DataContext.AddProgramTemplateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>-->
<MenuItem Header="复制路径" Command="{Binding Path=PlacementTarget.DataContext.CopyFilePathCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/> <MenuItem Header="复制路径" Command="{Binding Path=PlacementTarget.DataContext.CopyFilePathCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu> </ContextMenu>
</dxg:GridControl.ContextMenu> </dxg:GridControl.ContextMenu>
......
using DevExpress.Data.Mask.Internal;
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Framework.Plugin;
namespace VIZ.TVP.Module
{
public class CreateFolderViewModel : PluginViewModelBase
{
public CreateFolderViewModel()
{
EnterCommand = new VCommand(Enter);
CancelCommand = new VCommand(Cancel);
}
private string folderName;
public string FolderName
{
get { return folderName; }
set { folderName = value; this.RaisePropertyChanged(nameof(FolderName)); }
}
private bool isEnter;
/// <summary>
/// 是否确定
/// </summary>
public bool IsEnter
{
get { return isEnter; }
set { isEnter = value; this.RaisePropertyChanged(nameof(IsEnter)); }
}
public VCommand EnterCommand { get; set; }
public VCommand CancelCommand { get; set; }
/// <summary>
/// 确定
/// </summary>
private void Enter()
{
if (string.IsNullOrWhiteSpace(this.FolderName))
{
DXMessageBox.Show("请输入文件名");
return;
}
this.IsEnter = true;
this.GetWindow()?.Close();
}
/// <summary>
/// 取消
/// </summary>
private void Cancel()
{
this.IsEnter = false;
this.GetWindow()?.Close();
}
public override void Dispose()
{
}
}
}
using DevExpress.DirectX.Common.Direct2D;
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Module;
using VIZ.TVP.Domain;
namespace VIZ.TVP.Module
{
public class AppSetup_InitMedia : AppSetupBase
{
/// <summary>
/// 日志
/// </summary>
private static ILog log = LogManager.GetLogger(typeof(AppSetup_InitMedia));
public override string Detail { get; } = "应用程序启动 -- 初始化媒体资源库";
public override bool Setup(AppSetupContext context)
{
ApplicationDomainEx.DataBaseManager.ConfigContext = new Storage.ConfigContext();
this.LoadConfig();
return true;
}
/// <summary>
/// 加载插件配置
/// </summary>
private void LoadConfig()
{
string folder = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config");
if (!System.IO.Directory.Exists(folder))
{
System.IO.Directory.CreateDirectory(folder);
}
string path = System.IO.Path.Combine(folder, "MediaResouce.config");
ApplicationDomainEx.DataBaseManager.ConfigContext.LoadMediaConfig(path);
}
public override void Shutdown(AppSetupContext context)
{
}
}
}
...@@ -102,6 +102,14 @@ ...@@ -102,6 +102,14 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="Resource\MediaResource\View\CreateFolder.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Resource\MediaResource\View\CreateFolderWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SettingInner\Control\View\ControlSettingView.xaml"> <Page Include="SettingInner\Control\View\ControlSettingView.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -218,7 +226,15 @@ ...@@ -218,7 +226,15 @@
<Compile Include="Resource\MediaResource\Controller\MediaResourceFile\MediaResourceFileController.cs" /> <Compile Include="Resource\MediaResource\Controller\MediaResourceFile\MediaResourceFileController.cs" />
<Compile Include="Resource\MediaResource\Controller\MediaResourceFile\MediaResourceFileService.cs" /> <Compile Include="Resource\MediaResource\Controller\MediaResourceFile\MediaResourceFileService.cs" />
<Compile Include="Resource\MediaResource\Controller\Model\fileListResult.cs" /> <Compile Include="Resource\MediaResource\Controller\Model\fileListResult.cs" />
<Compile Include="Resource\MediaResource\Controller\Model\fileUploadResult.cs" />
<Compile Include="Resource\MediaResource\Controller\Model\ms.cs" /> <Compile Include="Resource\MediaResource\Controller\Model\ms.cs" />
<Compile Include="Resource\MediaResource\ViewModel\CreateFolderViewModel.cs" />
<Compile Include="Resource\MediaResource\View\CreateFolder.xaml.cs">
<DependentUpon>CreateFolder.xaml</DependentUpon>
</Compile>
<Compile Include="Resource\MediaResource\View\CreateFolderWindow.xaml.cs">
<DependentUpon>CreateFolderWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SettingInner\Control\ViewModel\ControlSettingViewModel.cs" /> <Compile Include="SettingInner\Control\ViewModel\ControlSettingViewModel.cs" />
<Compile Include="SettingInner\Control\View\ControlSettingView.xaml.cs"> <Compile Include="SettingInner\Control\View\ControlSettingView.xaml.cs">
<DependentUpon>ControlSettingView.xaml</DependentUpon> <DependentUpon>ControlSettingView.xaml</DependentUpon>
...@@ -319,6 +335,7 @@ ...@@ -319,6 +335,7 @@
<Compile Include="Common\View\TextInputView.xaml.cs"> <Compile Include="Common\View\TextInputView.xaml.cs">
<DependentUpon>TextInputView.xaml</DependentUpon> <DependentUpon>TextInputView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Setup\Provider\Setup\AppSetup_InitMedia.cs" />
<Compile Include="Take\ViewModel\TakeViewModel.cs" /> <Compile Include="Take\ViewModel\TakeViewModel.cs" />
<Compile Include="Take\View\TakeView.xaml.cs"> <Compile Include="Take\View\TakeView.xaml.cs">
<DependentUpon>TakeView.xaml</DependentUpon> <DependentUpon>TakeView.xaml</DependentUpon>
...@@ -422,5 +439,10 @@ ...@@ -422,5 +439,10 @@
<Folder Include="PluginPanel\Controller\" /> <Folder Include="PluginPanel\Controller\" />
<Folder Include="Program\Controller\" /> <Folder Include="Program\Controller\" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="Resource\VedioImage\Vedio.jpeg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>
\ No newline at end of file
using CsvHelper;
using log4net;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.TVP.Storage
{
public class ConfigContext
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(ConfigContext));
public Configuration configuration { get; set; }
/// <summary>
/// 加载插件配置
/// </summary>
/// <param name="path">文件路径</param>
public void LoadMediaConfig(string path)
{
if (File.Exists(path) == false)
{
{
string msg = string.Format("{0}路径下的文件未找到 ", path);
throw new FileNotFoundException(msg);
}
}
try
{
ExeConfigurationFileMap configFile = new ExeConfigurationFileMap();
configFile.ExeConfigFilename = path;
configuration = ConfigurationManager.OpenMappedExeConfiguration(configFile, ConfigurationUserLevel.None);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
}
}
...@@ -95,6 +95,7 @@ ...@@ -95,6 +95,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Config\ConfigContext.cs" />
<Compile Include="CSV\CsvContext.cs" /> <Compile Include="CSV\CsvContext.cs" />
<Compile Include="CSV\Plugin\Enum\PluginTypeEnum.cs" /> <Compile Include="CSV\Plugin\Enum\PluginTypeEnum.cs" />
<Compile Include="CSV\Plugin\PluginConfig.cs" /> <Compile Include="CSV\Plugin\PluginConfig.cs" />
......
...@@ -28,6 +28,10 @@ namespace VIZ.TVP ...@@ -28,6 +28,10 @@ namespace VIZ.TVP
// 初始化CSV // 初始化CSV
AppSetup.AppendSetup(new AppSetup_InitCSV()); AppSetup.AppendSetup(new AppSetup_InitCSV());
//初始化媒体库配置文件
AppSetup.AppendSetup(new AppSetup_InitMedia());
// 执行启动流程 // 执行启动流程
AppSetupContext context = AppSetup.Setup(); AppSetupContext context = AppSetup.Setup();
......
...@@ -122,6 +122,9 @@ ...@@ -122,6 +122,9 @@
<None Include="config\log.config"> <None Include="config\log.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
<None Include="config\MediaResouce.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="config\plugin_config.csv"> <None Include="config\plugin_config.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
......
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="url" value="http://localhost:9000/api/home/"/>
<add key="MediaFilter" value="(*.jpg,*.png,*.jpeg,*.bmp,*.gif,*.avi,*.mp4)|*.jgp;*.png;*.jpeg;*.bmp;*.gif;*.avi;*.mp4"/>
</appSettings>
</configuration>
\ No newline at end of file
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