commit
8f4ea4666a
738 changed files with 31381 additions and 0 deletions
@ -0,0 +1,11 @@ |
|||
/packages/ |
|||
/*/packages/ |
|||
/*/*/packages/ |
|||
/*/bin/ |
|||
/*/*/bin/ |
|||
/*/obj/ |
|||
/*/*/obj/ |
|||
/build_64/ |
|||
/数据库/*.ldf |
|||
/数据库/*.mdf |
|||
/build_64/ |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,9 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<appSettings> |
|||
<add key="url" value="http://1000my.cn:8080/update/ConUpdate.xml"/> |
|||
</appSettings> |
|||
<startup> |
|||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> |
|||
</startup> |
|||
</configuration> |
|||
@ -0,0 +1,8 @@ |
|||
<Application x:Class="ConUpdate.App" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
Startup="Application_Startup"> |
|||
<Application.Resources> |
|||
|
|||
</Application.Resources> |
|||
</Application> |
|||
@ -0,0 +1,50 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Configuration; |
|||
using System.Data; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using System.Windows; |
|||
|
|||
namespace ConUpdate |
|||
{ |
|||
/// <summary>
|
|||
/// App.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class App : Application |
|||
{ |
|||
internal string info = ""; |
|||
private LogHelper log = new LogHelper(); |
|||
private void Application_Startup(object sender, StartupEventArgs e) |
|||
{ |
|||
//http://1000my.cn:8080/update/ConUpdate.xml
|
|||
try |
|||
{ |
|||
if (e.Args.Count() > 0) |
|||
{ |
|||
log.WriteInfoFile("收到" + e.Args[0].ToString()); |
|||
info = e.Args[0].ToString(); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteInfoFile(ex.ToString()); |
|||
} |
|||
{ |
|||
MainWindow win = new MainWindow(); |
|||
win.Show(); |
|||
} |
|||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); |
|||
Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); |
|||
} |
|||
|
|||
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) |
|||
{ |
|||
} |
|||
|
|||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) |
|||
{ |
|||
Exception ex = (Exception)e.ExceptionObject; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,261 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Net; |
|||
using System.IO; |
|||
using System.Xml; |
|||
using ConUpdate.ViewModel; |
|||
using System.Configuration; |
|||
|
|||
namespace ConUpdate |
|||
{ |
|||
class CommonMethod |
|||
{ |
|||
private LogHelper log = new LogHelper(); |
|||
/// <summary>
|
|||
/// 是否需要更新
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public List<XmlNodeItem> IsUpdate(out string currentVersion) |
|||
{ |
|||
List<XmlNodeItem> updateList = new List<XmlNodeItem>(); |
|||
try |
|||
{ |
|||
string localPath = Directory.GetCurrentDirectory() + "\\ScreenVersion.txt"; |
|||
|
|||
FileStream fs = new FileStream(localPath, FileMode.Open); |
|||
using (StreamReader sr = new StreamReader(fs)) |
|||
{ |
|||
string temp = sr.ReadLine(); |
|||
currentVersion = temp.Substring(temp.LastIndexOf("V")); |
|||
} |
|||
fs.Close(); |
|||
|
|||
log.WriteInfoFile("服务器配置文件地址:" + ConfigurationManager.AppSettings["url"]); |
|||
List<XmlNodeItem> versionList = XmlReader(ConfigurationManager.AppSettings["url"]); |
|||
|
|||
foreach (var item in versionList) |
|||
{ |
|||
if (currentVersion != item.Title) |
|||
updateList.Add(item); |
|||
else |
|||
break; |
|||
} |
|||
return updateList; |
|||
} |
|||
catch |
|||
{ |
|||
currentVersion = ""; |
|||
return updateList; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 开始更新
|
|||
/// </summary>
|
|||
/// <param name="prog"></param>
|
|||
public void StartUpdate(XmlNodeItem versionItem, ProgressViewModel viewModel) |
|||
{ |
|||
try |
|||
{ |
|||
List<string> fileList = GetDirectoryContents(versionItem.Url); |
|||
List<string> copyfile = new List<string>(); |
|||
List<string> sourcefile = new List<string>(); |
|||
viewModel.Title = "正在更新版本..."; |
|||
viewModel.MaxValue = 100; |
|||
viewModel.CurrentProgress = 1; |
|||
viewModel.Val = 0; |
|||
viewModel.Message = viewModel.CurrentProgress + "/" + fileList.Count; |
|||
|
|||
for (int i = 0; i < fileList.Count; i++) |
|||
{ |
|||
try |
|||
{ |
|||
string remoteFile = versionItem.Url + "/" + fileList[i]; |
|||
string localFile = Directory.GetCurrentDirectory() + "\\" + fileList[i]; |
|||
string dir = localFile.Remove(localFile.LastIndexOf("\\")) + "\\updatetemp"; |
|||
|
|||
viewModel.CurrentProgress = i + 1; |
|||
viewModel.Message = viewModel.CurrentProgress + "/" + fileList.Count; |
|||
|
|||
if (!Directory.Exists(dir)) |
|||
Directory.CreateDirectory(dir); |
|||
if (!Directory.Exists(localFile.Remove(localFile.LastIndexOf("\\")))) |
|||
Directory.CreateDirectory(localFile.Remove(localFile.LastIndexOf("\\"))); |
|||
if (File.Exists(localFile)) |
|||
{ |
|||
string tempfile = localFile.Remove(localFile.LastIndexOf("\\")) + "\\updatetemp\\" + fileList[i].Replace("\\", "/").Substring(fileList[i].LastIndexOf("/") + 1, fileList[i].Length - fileList[i].LastIndexOf("/") - 1); |
|||
if (File.Exists(tempfile)) |
|||
{ |
|||
File.Delete(tempfile); |
|||
} |
|||
log.WriteInfoFile("正在移动:"+localFile); |
|||
File.Move(localFile, tempfile); |
|||
copyfile.Add(tempfile); |
|||
sourcefile.Add(localFile); |
|||
File.Delete(localFile); |
|||
} |
|||
|
|||
WebRequest request = WebRequest.Create(remoteFile); |
|||
WebResponse respone = request.GetResponse(); |
|||
Stream netStream = respone.GetResponseStream(); |
|||
Stream fileStream = new FileStream(localFile, FileMode.Create); |
|||
long totalDownloadedByte = 0; |
|||
byte[] read = new byte[1024]; |
|||
int realReadLen = netStream.Read(read, 0, read.Length); |
|||
while (realReadLen > 0) |
|||
{ |
|||
totalDownloadedByte = realReadLen + totalDownloadedByte; |
|||
fileStream.Write(read, 0, realReadLen); |
|||
realReadLen = netStream.Read(read, 0, read.Length); |
|||
|
|||
viewModel.Val = ((totalDownloadedByte / respone.ContentLength) * 100); |
|||
} |
|||
netStream.Close(); |
|||
fileStream.Close(); |
|||
} |
|||
catch(Exception ex) |
|||
{ |
|||
log.WriteInfoFile(ex.ToString()); |
|||
for (int j = 0; j < copyfile.Count; j++) |
|||
{ |
|||
if (File.Exists(copyfile[j])) |
|||
{ |
|||
if (File.Exists(sourcefile[j])) |
|||
{ |
|||
File.Delete(sourcefile[j]); |
|||
|
|||
} |
|||
File.Move(copyfile[j], sourcefile[j]); |
|||
} |
|||
} |
|||
|
|||
return; |
|||
} |
|||
} |
|||
log.WriteInfoFile("更新完成!" ); |
|||
} |
|||
catch(Exception ex) |
|||
{ |
|||
log.WriteInfoFile(ex.ToString()); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取路径下所有文件路径
|
|||
/// </summary>
|
|||
/// <param name="url"></param>
|
|||
/// <param name="deep"></param>
|
|||
/// <returns></returns>
|
|||
private List<string> GetDirectoryContents(string remotePath) |
|||
{ |
|||
List<string> fileNames = new List<string>(); |
|||
string filePath = remotePath + "/config.txt"; |
|||
|
|||
WebRequest request = WebRequest.Create(filePath); |
|||
WebResponse respone = request.GetResponse(); |
|||
|
|||
Stream netStream = respone.GetResponseStream(); |
|||
StreamReader sr = new StreamReader(netStream, Encoding.UTF8); |
|||
string lineStr = sr.ReadLine(); |
|||
while (!string.IsNullOrEmpty(lineStr)) |
|||
{ |
|||
fileNames.Add(lineStr.Replace("\0", "")); |
|||
lineStr = sr.ReadLine(); |
|||
} |
|||
|
|||
netStream.Close(); |
|||
sr.Close(); |
|||
|
|||
//Stream fs = new FileStream(localPath, FileMode.Create);
|
|||
|
|||
//int readBytes = netStream.Read(buffer, 0, buffer.Length);
|
|||
//while (readBytes > 0)
|
|||
//{
|
|||
// fs.Write(buffer, 0, buffer.Length);
|
|||
// readBytes = netStream.Read(buffer, 0, buffer.Length);
|
|||
//}
|
|||
//netStream.Close();
|
|||
//fs.Close();
|
|||
|
|||
//if (File.Exists(localPath))
|
|||
//{
|
|||
// string[] names = File.ReadAllLines(localPath, Encoding.UTF8);
|
|||
// foreach (var item in names)
|
|||
// fileNames.Add(item.Replace("\0", ""));
|
|||
//}
|
|||
|
|||
return fileNames; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 读取xml文件
|
|||
/// </summary>
|
|||
/// <param name="url"></param>
|
|||
/// <returns></returns>
|
|||
private List<XmlNodeItem> XmlReader(string url) |
|||
{ |
|||
|
|||
List<XmlNodeItem> nodeList = new List<XmlNodeItem>(); |
|||
try |
|||
{ |
|||
XmlDocument doc = new XmlDocument(); |
|||
doc.Load(url); //加载Xml文件
|
|||
XmlElement rootElem = doc.DocumentElement; //获取根节点
|
|||
XmlNodeList itemNodes = rootElem.GetElementsByTagName("item"); //获取item子节点集合
|
|||
foreach (XmlNode node in itemNodes) |
|||
{ |
|||
XmlNodeItem item = new XmlNodeItem(); |
|||
XmlNodeList subTitleNodes = ((XmlElement)node).GetElementsByTagName("title"); //获取title子XmlElement集合
|
|||
XmlNodeList subDateNodes = ((XmlElement)node).GetElementsByTagName("date"); //获取date子XmlElement集合
|
|||
XmlNodeList subUrlNodes = ((XmlElement)node).GetElementsByTagName("url"); //获取url子XmlElement集合
|
|||
XmlNodeList subConfigNodes = ((XmlElement)node).GetElementsByTagName("iscopyconfig"); //获取iscopyconfig子XmlElement集合
|
|||
XmlNodeList subDescribtionNodes = ((XmlElement)node).GetElementsByTagName("describtion"); //获取describtion子XmlElement集合
|
|||
if (subTitleNodes.Count == 1) |
|||
item.Title = subTitleNodes[0].InnerText; |
|||
if (subDateNodes.Count == 1) |
|||
item.Date = subDateNodes[0].InnerText; |
|||
if (subUrlNodes.Count == 1) |
|||
item.Url = subUrlNodes[0].InnerText; |
|||
if (subConfigNodes.Count == 1) |
|||
item.IsCopyConfig = subConfigNodes[0].InnerText; |
|||
if (subDescribtionNodes.Count == 1) |
|||
item.Describtion = subDescribtionNodes[0].InnerText; |
|||
|
|||
nodeList.Add(item); |
|||
} |
|||
|
|||
return nodeList; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteInfoFile(ex.ToString()); |
|||
return nodeList; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 比较两个数组是否相等
|
|||
/// </summary>
|
|||
/// <param name="b1"></param>
|
|||
/// <param name="b2"></param>
|
|||
/// <returns></returns>
|
|||
private int CompareBytes(byte[] b1, byte[] b2) |
|||
{ |
|||
if (b1 == null || b2 == null) |
|||
return -1; |
|||
if (b1.Length != b2.Length) |
|||
return -1; |
|||
else |
|||
{ |
|||
for (int i = 0; i < b1.Length; i++) |
|||
{ |
|||
if (b1[i] != b2[i]) |
|||
return -1; |
|||
} |
|||
return 0; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,123 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> |
|||
<PropertyGroup> |
|||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> |
|||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> |
|||
<ProjectGuid>{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}</ProjectGuid> |
|||
<OutputType>WinExe</OutputType> |
|||
<AppDesignerFolder>Properties</AppDesignerFolder> |
|||
<RootNamespace>ConUpdate</RootNamespace> |
|||
<AssemblyName>ConUpdate</AssemblyName> |
|||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> |
|||
<FileAlignment>512</FileAlignment> |
|||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> |
|||
<WarningLevel>4</WarningLevel> |
|||
<TargetFrameworkProfile /> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugSymbols>true</DebugSymbols> |
|||
<DebugType>full</DebugType> |
|||
<Optimize>false</Optimize> |
|||
<OutputPath>bin\Debug\</OutputPath> |
|||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> |
|||
<PlatformTarget>AnyCPU</PlatformTarget> |
|||
<DebugType>pdbonly</DebugType> |
|||
<Optimize>true</Optimize> |
|||
<OutputPath>..\Container\bin\Release\</OutputPath> |
|||
<DefineConstants>TRACE</DefineConstants> |
|||
<ErrorReport>prompt</ErrorReport> |
|||
<WarningLevel>4</WarningLevel> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"> |
|||
<PlatformTarget>x64</PlatformTarget> |
|||
<OutputPath>bin\x64\Debug\</OutputPath> |
|||
</PropertyGroup> |
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'"> |
|||
<PlatformTarget>x64</PlatformTarget> |
|||
<OutputPath>bin\x64\Release\</OutputPath> |
|||
</PropertyGroup> |
|||
<ItemGroup> |
|||
<Reference Include="System" /> |
|||
<Reference Include="System.Configuration" /> |
|||
<Reference Include="System.Data" /> |
|||
<Reference Include="System.Windows.Forms" /> |
|||
<Reference Include="System.Xml" /> |
|||
<Reference Include="Microsoft.CSharp" /> |
|||
<Reference Include="System.Core" /> |
|||
<Reference Include="System.Xml.Linq" /> |
|||
<Reference Include="System.Data.DataSetExtensions" /> |
|||
<Reference Include="System.Xaml"> |
|||
<RequiredTargetFramework>4.0</RequiredTargetFramework> |
|||
</Reference> |
|||
<Reference Include="WindowsBase" /> |
|||
<Reference Include="PresentationCore" /> |
|||
<Reference Include="PresentationFramework" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<ApplicationDefinition Include="App.xaml"> |
|||
<Generator>MSBuild:Compile</Generator> |
|||
<SubType>Designer</SubType> |
|||
</ApplicationDefinition> |
|||
<Compile Include="ViewModel\ProgressViewModel.cs" /> |
|||
<Compile Include="ViewModel\ViewModelBase.cs" /> |
|||
<Compile Include="XmlNodeItem.cs" /> |
|||
<Page Include="MainWindow.xaml"> |
|||
<Generator>MSBuild:Compile</Generator> |
|||
<SubType>Designer</SubType> |
|||
</Page> |
|||
<Compile Include="App.xaml.cs"> |
|||
<DependentUpon>App.xaml</DependentUpon> |
|||
<SubType>Code</SubType> |
|||
</Compile> |
|||
<Compile Include="CommonMethod.cs" /> |
|||
<Compile Include="LogHelper.cs" /> |
|||
<Compile Include="MainWindow.xaml.cs"> |
|||
<DependentUpon>MainWindow.xaml</DependentUpon> |
|||
<SubType>Code</SubType> |
|||
</Compile> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Compile Include="Properties\AssemblyInfo.cs"> |
|||
<SubType>Code</SubType> |
|||
</Compile> |
|||
<Compile Include="Properties\Resources.Designer.cs"> |
|||
<AutoGen>True</AutoGen> |
|||
<DesignTime>True</DesignTime> |
|||
<DependentUpon>Resources.resx</DependentUpon> |
|||
</Compile> |
|||
<Compile Include="Properties\Settings.Designer.cs"> |
|||
<AutoGen>True</AutoGen> |
|||
<DependentUpon>Settings.settings</DependentUpon> |
|||
<DesignTimeSharedInput>True</DesignTimeSharedInput> |
|||
</Compile> |
|||
<EmbeddedResource Include="Properties\Resources.resx"> |
|||
<Generator>ResXFileCodeGenerator</Generator> |
|||
<LastGenOutput>Resources.Designer.cs</LastGenOutput> |
|||
</EmbeddedResource> |
|||
<None Include="Properties\Settings.settings"> |
|||
<Generator>SettingsSingleFileGenerator</Generator> |
|||
<LastGenOutput>Settings.Designer.cs</LastGenOutput> |
|||
</None> |
|||
<AppDesigner Include="Properties\" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<None Include="App.config" /> |
|||
</ItemGroup> |
|||
<ItemGroup> |
|||
<Resource Include="qm.ico" /> |
|||
</ItemGroup> |
|||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> |
|||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. |
|||
Other similar extension points exist, see Microsoft.Common.targets. |
|||
<Target Name="BeforeBuild"> |
|||
</Target> |
|||
<Target Name="AfterBuild"> |
|||
</Target> |
|||
--> |
|||
</Project> |
|||
@ -0,0 +1,6 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<ProjectView>ShowAllFiles</ProjectView> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,151 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.IO; |
|||
|
|||
namespace ConUpdate |
|||
{ |
|||
class LogHelper |
|||
{ |
|||
/**/ |
|||
/// <summary>
|
|||
/// 写入日志文件
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
public string WriteInfoFile(string input) |
|||
{ |
|||
try |
|||
{ |
|||
if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\UpdateLogs")) |
|||
Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\UpdateLogs"); |
|||
/**/ |
|||
///指定日志文件的目录
|
|||
string fname = Directory.GetCurrentDirectory() + "\\UpdateLogs\\LogFile(" + DateTime.Today.Date.ToString("yyyy-MM-dd") + ").txt"; |
|||
/**/ |
|||
///定义文件信息对象
|
|||
|
|||
FileInfo finfo = new FileInfo(fname); |
|||
|
|||
if (!finfo.Exists) |
|||
{ |
|||
FileStream fs; |
|||
fs = File.Create(fname); |
|||
fs.Close(); |
|||
finfo = new FileInfo(fname); |
|||
} |
|||
|
|||
/**/ |
|||
///判断文件是否存在以及是否大于2K
|
|||
if (finfo.Length > 1024 * 1024 * 10) |
|||
{ |
|||
/**/ |
|||
///文件超过10MB则重命名
|
|||
File.Move(Directory.GetCurrentDirectory() + "\\UpdateLogs\\LogFile.txt", Directory.GetCurrentDirectory() + "\\UpdateLogs\\" + "LogFile{" + Guid.NewGuid() + "}.txt"); |
|||
/**/ |
|||
///删除该文件
|
|||
//finfo.Delete();
|
|||
} |
|||
//finfo.AppendText();
|
|||
/**/ |
|||
///创建只写文件流
|
|||
|
|||
using (FileStream fs = finfo.OpenWrite()) |
|||
{ |
|||
/**/ |
|||
///根据上面创建的文件流创建写数据流
|
|||
StreamWriter w = new StreamWriter(fs); |
|||
|
|||
/**/ |
|||
///设置写数据流的起始位置为文件流的末尾
|
|||
w.BaseStream.Seek(0, SeekOrigin.End); |
|||
|
|||
/**/ |
|||
///写入“Log Entry : ”
|
|||
w.Write("\n\rLog Entry : "); |
|||
|
|||
/**/ |
|||
///写入当前系统时间并换行
|
|||
w.Write("{0} {1} \n\r", DateTime.Now.ToLongTimeString(), |
|||
DateTime.Now.ToLongDateString()); |
|||
|
|||
/**/ |
|||
///写入日志内容并换行
|
|||
w.Write(input + "\n\r"); |
|||
|
|||
/**/ |
|||
///写入------------------------------------“并换行
|
|||
//w.Write("------------------------------------\n\r");
|
|||
|
|||
/**/ |
|||
///清空缓冲区内容,并把缓冲区内容写入基础流
|
|||
w.Flush(); |
|||
|
|||
/**/ |
|||
///关闭写数据流
|
|||
w.Close(); |
|||
|
|||
return "0"; |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
return ex.Message + ex.StackTrace; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 删除 fileName 文件夹里一个月之前的日志
|
|||
/// </summary>
|
|||
/// <param name="fileName"></param>
|
|||
/// <param name="month"></param>
|
|||
public void DeleteFiles(string fileName = "") |
|||
{ |
|||
try |
|||
{ |
|||
if (string.IsNullOrEmpty(fileName)) |
|||
fileName = Directory.GetCurrentDirectory() + "\\UpdateLogs"; |
|||
if (!Directory.Exists(fileName))//若文件夹不存在则返回
|
|||
return; |
|||
DirectoryInfo dir = new DirectoryInfo(fileName); |
|||
//不是目录
|
|||
|
|||
if (dir == null) |
|||
return; |
|||
//DateTime DT = dir.CreationTime;
|
|||
|
|||
FileSystemInfo[] files = dir.GetFileSystemInfos(); |
|||
for (int i = 0; i < files.Length; i++) |
|||
{ |
|||
FileInfo file = files[i] as FileInfo; |
|||
//是文件
|
|||
if (file != null) |
|||
{ |
|||
DateTime DT = file.CreationTime; |
|||
if (DateTime.Now.Month - DT.Month >= 1) |
|||
{ |
|||
file.Delete(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
DirectoryInfo dir1 = files[i] as DirectoryInfo; |
|||
if (dir1 != null) |
|||
{ |
|||
DateTime DT = dir1.CreationTime; |
|||
if (DateTime.Now.Month - DT.Month >= 1) |
|||
{ |
|||
//dir1.Delete();
|
|||
System.IO.Directory.Delete(fileName + "\\" + dir1.Name, true); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
<Window x:Class="ConUpdate.MainWindow" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
Height="50" Width="472" Background="{x:Null}" AllowsTransparency="True" WindowStartupLocation="CenterScreen" ShowInTaskbar="False" ResizeMode="NoResize" Loaded="Window_Loaded" Closed="Window_Closed" WindowStyle="None"> |
|||
|
|||
<Grid> |
|||
<Border Background="#FFB4B2B2" BorderBrush="Black" BorderThickness="1"> |
|||
<Canvas> |
|||
<ProgressBar Height="28" HorizontalAlignment="Left" Name="pbDown" VerticalAlignment="Top" Width="470" Maximum="{Binding MaxValue}" Value="{Binding Val}"/> |
|||
<TextBlock TextAlignment="Right" Name="tbMessage" Text="{Binding Message}" Width="145" Canvas.Top="32" Canvas.Left="325" FontSize="12"></TextBlock> |
|||
<TextBlock TextAlignment="Left" Text="{Binding Title}" FontSize="12" Canvas.Top="32" Width="300"></TextBlock> |
|||
</Canvas> |
|||
</Border> |
|||
</Grid> |
|||
</Window> |
|||
@ -0,0 +1,149 @@ |
|||
using ConUpdate.ViewModel; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
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; |
|||
|
|||
namespace ConUpdate |
|||
{ |
|||
/// <summary>
|
|||
/// MainWindow.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class MainWindow : Window |
|||
{ |
|||
private CommonMethod common = new CommonMethod(); |
|||
private ProgressViewModel pvm = new ProgressViewModel(); |
|||
private LogHelper log = new LogHelper(); |
|||
App app = ((App)Application.Current); |
|||
bool killexe = false; |
|||
public MainWindow() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
|
|||
private void Window_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
log.WriteInfoFile("Loading..."); |
|||
this.DataContext = pvm; |
|||
|
|||
try |
|||
{ |
|||
log.DeleteFiles(); |
|||
List<XmlNodeItem> updateList = new List<XmlNodeItem>(); |
|||
Action ac = new Action(() => |
|||
{ |
|||
string currentVersion = string.Empty; |
|||
updateList = common.IsUpdate(out currentVersion); |
|||
}); |
|||
ac.BeginInvoke((o) => |
|||
{ |
|||
if (updateList.Count > 0) |
|||
{ |
|||
killExE(); |
|||
Thread.Sleep(2000); |
|||
common.StartUpdate(updateList[0], pvm); |
|||
} |
|||
this.Dispatcher.Invoke(new Action(() => |
|||
{ |
|||
this.Close(); |
|||
})); |
|||
}, updateList); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteInfoFile(ex.Message + ex.StackTrace); |
|||
} |
|||
} |
|||
|
|||
|
|||
private void killExE() |
|||
{ |
|||
try |
|||
{ |
|||
Process[] pro = Process.GetProcesses(); |
|||
for (int i = 0; i < pro.Length; i++) |
|||
{ |
|||
if (pro[i].ProcessName.ToLower() == "pcscreensavers.exe") |
|||
{ |
|||
pro[i].Kill();//结束进程
|
|||
killexe = true; |
|||
|
|||
log.WriteInfoFile("进程关闭"); |
|||
return; |
|||
} |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteInfoFile(ex.ToString()); |
|||
} |
|||
} |
|||
private void Window_Closed(object sender, EventArgs e) |
|||
{ |
|||
//if (killexe)
|
|||
{ |
|||
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent(); |
|||
//创建Windows用户主题
|
|||
System.Windows.Forms.Application.EnableVisualStyles(); |
|||
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity); |
|||
//判断当前登录用户是否为管理员
|
|||
if (!principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) |
|||
{ |
|||
//创建启动对象
|
|||
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); |
|||
//设置运行文件
|
|||
startInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
startInfo.FileName = startInfo.WorkingDirectory + "/Container.exe"; //设置启动参数
|
|||
startInfo.Arguments = app.info + "&true"; |
|||
log.WriteInfoFile("发送" + startInfo.Arguments); |
|||
//设置启动动作,确保以管理员身份运行
|
|||
startInfo.Verb = "runas"; |
|||
//如果不是管理员,则启动UAC
|
|||
//log.WriteLogFile("工作路径:" + startInfo.WorkingDirectory, "APPError");
|
|||
System.Diagnostics.Process.Start(startInfo); |
|||
//退出
|
|||
System.Windows.Forms.Application.Exit(); |
|||
|
|||
//System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|||
//p.StartInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
//p.StartInfo.FileName = p.StartInfo.WorkingDirectory + "/PCScreenSavers.exe";
|
|||
//p.StartInfo.Arguments = app.info;
|
|||
//p.StartInfo.Verb = "runas";
|
|||
//p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
|
|||
//p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
|
|||
//p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
|||
//p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
|
|||
////p.ProcessNa = "PCScreenUpdate";
|
|||
//p.StartInfo.CreateNoWindow = false;//不显示程序窗口
|
|||
//p.Start();//启动程序
|
|||
} |
|||
else |
|||
{ |
|||
System.Diagnostics.Process p = new System.Diagnostics.Process(); |
|||
p.StartInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
p.StartInfo.FileName = p.StartInfo.WorkingDirectory + "/Container.exe"; |
|||
p.StartInfo.Arguments = app.info + "&true"; |
|||
log.WriteInfoFile("发送" + p.StartInfo.Arguments); |
|||
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
|
|||
p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
|
|||
p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
|||
p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
|
|||
p.StartInfo.CreateNoWindow = false;//不显示程序窗口
|
|||
p.Start();//启动程序
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System.Reflection; |
|||
using System.Resources; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
using System.Windows; |
|||
|
|||
// 有关程序集的常规信息通过以下
|
|||
// 特性集控制。更改这些特性值可修改
|
|||
// 与程序集关联的信息。
|
|||
[assembly: AssemblyTitle("ConUpdate")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("Microsoft")] |
|||
[assembly: AssemblyProduct("ConUpdate")] |
|||
[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] |
|||
[assembly: AssemblyTrademark("")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
|||
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
|||
// 则将该类型上的 ComVisible 特性设置为 true。
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
//若要开始生成可本地化的应用程序,请在
|
|||
//<PropertyGroup> 中的 .csproj 文件中
|
|||
//设置 <UICulture>CultureYouAreCodingWith</UICulture>。 例如,如果您在源文件中
|
|||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
|
|||
//对以下 NeutralResourceLanguage 特性的注释。 更新
|
|||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
|||
|
|||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
|||
|
|||
|
|||
[assembly: ThemeInfo( |
|||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
|||
//(在页面或应用程序资源词典中
|
|||
// 未找到某个资源的情况下使用)
|
|||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
|||
//(在页面、应用程序或任何主题特定资源词典中
|
|||
// 未找到某个资源的情况下使用)
|
|||
)] |
|||
|
|||
|
|||
// 程序集的版本信息由下面四个值组成:
|
|||
//
|
|||
// 主版本
|
|||
// 次版本
|
|||
// 生成号
|
|||
// 修订号
|
|||
//
|
|||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
|||
// 方法是按如下所示使用“*”:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -0,0 +1,63 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// 此代码由工具生成。
|
|||
// 运行时版本:4.0.30319.42000
|
|||
//
|
|||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
|||
// 重新生成代码,这些更改将会丢失。
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace ConUpdate.Properties { |
|||
using System; |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
|||
/// </summary>
|
|||
// 此类是由 StronglyTypedResourceBuilder
|
|||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
|||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
|||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] |
|||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
internal class Resources { |
|||
|
|||
private static global::System.Resources.ResourceManager resourceMan; |
|||
|
|||
private static global::System.Globalization.CultureInfo resourceCulture; |
|||
|
|||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
|||
internal Resources() { |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Resources.ResourceManager ResourceManager { |
|||
get { |
|||
if (object.ReferenceEquals(resourceMan, null)) { |
|||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ConUpdate.Properties.Resources", typeof(Resources).Assembly); |
|||
resourceMan = temp; |
|||
} |
|||
return resourceMan; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 重写当前线程的 CurrentUICulture 属性,对
|
|||
/// 使用此强类型资源类的所有资源查找执行重写。
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Globalization.CultureInfo Culture { |
|||
get { |
|||
return resourceCulture; |
|||
} |
|||
set { |
|||
resourceCulture = value; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<root> |
|||
<!-- |
|||
Microsoft ResX Schema |
|||
|
|||
Version 2.0 |
|||
|
|||
The primary goals of this format is to allow a simple XML format |
|||
that is mostly human readable. The generation and parsing of the |
|||
various data types are done through the TypeConverter classes |
|||
associated with the data types. |
|||
|
|||
Example: |
|||
|
|||
... ado.net/XML headers & schema ... |
|||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|||
<resheader name="version">2.0</resheader> |
|||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|||
</data> |
|||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|||
<comment>This is a comment</comment> |
|||
</data> |
|||
|
|||
There are any number of "resheader" rows that contain simple |
|||
name/value pairs. |
|||
|
|||
Each data row contains a name, and value. The row also contains a |
|||
type or mimetype. Type corresponds to a .NET class that support |
|||
text/value conversion through the TypeConverter architecture. |
|||
Classes that don't support this are serialized and stored with the |
|||
mimetype set. |
|||
|
|||
The mimetype is used for serialized objects, and tells the |
|||
ResXResourceReader how to depersist the object. This is currently not |
|||
extensible. For a given mimetype the value must be set accordingly: |
|||
|
|||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|||
that the ResXResourceWriter will generate, however the reader can |
|||
read any of the formats listed below. |
|||
|
|||
mimetype: application/x-microsoft.net.object.binary.base64 |
|||
value : The object must be serialized with |
|||
: System.Serialization.Formatters.Binary.BinaryFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.soap.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|||
value : The object must be serialized into a byte array |
|||
: using a System.ComponentModel.TypeConverter |
|||
: and then encoded with base64 encoding. |
|||
--> |
|||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|||
<xsd:element name="root" msdata:IsDataSet="true"> |
|||
<xsd:complexType> |
|||
<xsd:choice maxOccurs="unbounded"> |
|||
<xsd:element name="metadata"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
<xsd:attribute name="type" type="xsd:string" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="assembly"> |
|||
<xsd:complexType> |
|||
<xsd:attribute name="alias" type="xsd:string" /> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="data"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
|||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="resheader"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:choice> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:schema> |
|||
<resheader name="resmimetype"> |
|||
<value>text/microsoft-resx</value> |
|||
</resheader> |
|||
<resheader name="version"> |
|||
<value>2.0</value> |
|||
</resheader> |
|||
<resheader name="reader"> |
|||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<resheader name="writer"> |
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
</root> |
|||
@ -0,0 +1,26 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// 此代码由工具生成。
|
|||
// 运行时版本:4.0.30319.42000
|
|||
//
|
|||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
|||
// 重新生成代码,这些更改将会丢失。
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace ConUpdate.Properties { |
|||
|
|||
|
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")] |
|||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
|||
|
|||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
|||
|
|||
public static Settings Default { |
|||
get { |
|||
return defaultInstance; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<?xml version='1.0' encoding='utf-8'?> |
|||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
|||
<Profiles> |
|||
<Profile Name="(Default)" /> |
|||
</Profiles> |
|||
<Settings /> |
|||
</SettingsFile> |
|||
@ -0,0 +1,67 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
|
|||
namespace ConUpdate.ViewModel |
|||
{ |
|||
class ProgressViewModel : ViewModelBase |
|||
{ |
|||
private int currentProgress = 0; |
|||
private int maxValue = 0; |
|||
private double val = 0.00; |
|||
private string message = string.Empty; |
|||
private string title = string.Empty; |
|||
|
|||
|
|||
public double Val |
|||
{ |
|||
get { return val; } |
|||
set |
|||
{ |
|||
val = value; |
|||
OnPropertyChanged("Val"); |
|||
} |
|||
} |
|||
|
|||
public string Title |
|||
{ |
|||
get { return title; } |
|||
set |
|||
{ |
|||
title = value; |
|||
OnPropertyChanged("Title"); |
|||
} |
|||
} |
|||
|
|||
public int CurrentProgress |
|||
{ |
|||
get { return currentProgress; } |
|||
set |
|||
{ |
|||
currentProgress = value; |
|||
OnPropertyChanged("CurrentProgress"); |
|||
} |
|||
} |
|||
|
|||
public int MaxValue |
|||
{ |
|||
get { return maxValue; } |
|||
set |
|||
{ |
|||
maxValue = value; |
|||
OnPropertyChanged("MaxValue"); |
|||
} |
|||
} |
|||
|
|||
public string Message |
|||
{ |
|||
get { return message; } |
|||
set |
|||
{ |
|||
message = value; |
|||
OnPropertyChanged("Message"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,19 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.ComponentModel; |
|||
|
|||
namespace ConUpdate.ViewModel |
|||
{ |
|||
class ViewModelBase : INotifyPropertyChanged |
|||
{ |
|||
public event PropertyChangedEventHandler PropertyChanged; |
|||
|
|||
protected virtual void OnPropertyChanged(string propertyName) |
|||
{ |
|||
if (PropertyChanged != null) |
|||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,61 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
|
|||
namespace ConUpdate |
|||
{ |
|||
class XmlNodeItem |
|||
{ |
|||
private string title = string.Empty; |
|||
private string date = string.Empty; |
|||
private string url = string.Empty; |
|||
private string isCopyConfig = string.Empty; |
|||
private string describtion = string.Empty; |
|||
|
|||
/// <summary>
|
|||
/// 标题
|
|||
/// </summary>
|
|||
public string Title |
|||
{ |
|||
get { return title; } |
|||
set { title = value; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 日期
|
|||
/// </summary>
|
|||
public string Date |
|||
{ |
|||
get { return date; } |
|||
set { date = value; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 地址
|
|||
/// </summary>
|
|||
public string Url |
|||
{ |
|||
get { return url; } |
|||
set { url = value; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 是否替换配置文件
|
|||
/// </summary>
|
|||
public string IsCopyConfig |
|||
{ |
|||
get { return isCopyConfig; } |
|||
set { isCopyConfig = value; } |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 描述
|
|||
/// </summary>
|
|||
public string Describtion |
|||
{ |
|||
get { return describtion; } |
|||
set { describtion = value; } |
|||
} |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,53 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio 15 |
|||
VisualStudioVersion = 15.0.28010.2003 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Container", "Container\Container.csproj", "{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}" |
|||
ProjectSection(ProjectDependencies) = postProject |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01} = {DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01} |
|||
EndProjectSection |
|||
EndProject |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConUpdate", "ConUpdate\ConUpdate.csproj", "{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Debug|x64 = Debug|x64 |
|||
Debug|x86 = Debug|x86 |
|||
Release|Any CPU = Release|Any CPU |
|||
Release|x64 = Release|x64 |
|||
Release|x86 = Release|x86 |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Debug|x64.ActiveCfg = Debug|x64 |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Debug|x64.Build.0 = Debug|x64 |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Debug|x86.ActiveCfg = Debug|Any CPU |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Debug|x86.Build.0 = Debug|Any CPU |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Debug|x86.Deploy.0 = Debug|Any CPU |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Release|x64.ActiveCfg = Release|x64 |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Release|x64.Build.0 = Release|x64 |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Release|x86.ActiveCfg = Release|x86 |
|||
{DAE19E2F-B2BB-4778-B0F2-5FC48DC5975A}.Release|x86.Build.0 = Release|x86 |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Debug|x64.ActiveCfg = Debug|x64 |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Debug|x64.Build.0 = Debug|x64 |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Debug|x86.ActiveCfg = Debug|Any CPU |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Release|x64.ActiveCfg = Release|x64 |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Release|x64.Build.0 = Release|x64 |
|||
{DF0EAD54-D31A-4C8A-ADF3-D4963C1DED01}.Release|x86.ActiveCfg = Release|x64 |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {85DCECB3-CF29-4484-8CF1-B55638B3B124} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
Binary file not shown.
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<configuration> |
|||
<appSettings> |
|||
<add key="HttpUrl" value=""/> |
|||
<add key="kioskUrl" value="http://192.168.1.98:8018"/> |
|||
<!--<add key="websocketUrl" value="ws://192.168.1.128:7181"/>--> |
|||
<!-- websocketUrlForVoice:语音websocket--> |
|||
<add key="websocketUrlForVoice" value="ws://192.168.1.128:7181"/> |
|||
<!--websocketForLive: 直播websocket--> |
|||
<add key="websocketForLive" value="ws://121.37.146.236:8098"/> |
|||
<!--websocketForFace: 跟人脸做对接,主要用于富广告的对接--> |
|||
<add key="websocketForFace" value="ws://127.0.0.1:7179"/> |
|||
<!--websocketForKiosk: 跟H5对接屏保启动返回首页、和导视版本--> |
|||
<add key="websocketForKiosk" value="ws://127.0.0.1:7178"/> |
|||
<add key="websocketProgramPort" value="7182"/> |
|||
<add key="isvoiceup" value="0"/> |
|||
<add key="ClientSettingsProvider.ServiceUri" value=""/> |
|||
<add key="OBSPath" value=""/> |
|||
</appSettings> |
|||
<startup> |
|||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/> |
|||
</startup> |
|||
<system.web> |
|||
<membership defaultProvider="ClientAuthenticationMembershipProvider"> |
|||
<providers> |
|||
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri=""/> |
|||
</providers> |
|||
</membership> |
|||
<roleManager defaultProvider="ClientRoleProvider" enabled="true"> |
|||
<providers> |
|||
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400"/> |
|||
</providers> |
|||
</roleManager> |
|||
</system.web> |
|||
</configuration> |
|||
@ -0,0 +1,10 @@ |
|||
<Application x:Class="Container.App" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
Startup="Application_Startup"> |
|||
<Application.Resources> |
|||
<FontFamily x:Key="DINProRegular">/Container;Component/Resources/DINPro-Regular.otf#DINPro</FontFamily> |
|||
<FontFamily x:Key="CNRegular">/Container;Component/Resources/SourceHanSansCN-Regular.otf#Source Han Sans CN</FontFamily> |
|||
<FontFamily x:Key="BrownStd">/Container;Component/Resources/BROWNSTD REGULAR.otf#BrownStd</FontFamily> |
|||
</Application.Resources> |
|||
</Application> |
|||
@ -0,0 +1,328 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Configuration; |
|||
using System.Data; |
|||
using System.Linq; |
|||
using System.Threading.Tasks; |
|||
using System.Windows; |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using Container.Services; |
|||
using System.Diagnostics; |
|||
using Container.ChildWindows; |
|||
using Container.Viewmodel; |
|||
using Container.Win; |
|||
using Container.SaversViewModel; |
|||
using System.Threading; |
|||
|
|||
namespace Container |
|||
{ |
|||
/// <summary>
|
|||
/// App.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class App : Application |
|||
{ |
|||
internal string shutdowntime; |
|||
internal AppListModel NowNeedPlayApp;//当前时间段需要播放的app(时间轴或默认)
|
|||
internal string mallCode = ""; |
|||
internal string mallRegKey = ""; |
|||
internal string configurl = "http://192.168.0.250"; |
|||
internal string configHttpUrl = ""; |
|||
internal string SecurityKey = CommonLib.StringDecode("==wchF2UNFVO4cjN1QzMyEDM"); |
|||
|
|||
internal string configstartexe = ""; |
|||
internal string configwebsocket = "ws://192.168.0.250:8080"; |
|||
internal string configport = "8888"; |
|||
internal string BuildingID = ""; |
|||
internal string Floor = ""; |
|||
internal string HttpUrl = "";//
|
|||
internal string LocalIP = "";//本机IP
|
|||
internal string DeviceType = "";//设备类型
|
|||
internal string appUrl = "";//下载应用程序的路径
|
|||
internal string appName = "";//应用下载文件名
|
|||
//internal List<ExeModel> NowAppList = new List<ExeModel>();
|
|||
internal bool appClick = false;//应用下载文件名
|
|||
|
|||
internal string NowAppType = "";//当前应用类型,exe、html。。
|
|||
internal string deviceid = "";//设备编号
|
|||
internal string devicemark = "";//设备备注
|
|||
internal List<Building> Buildinginfo = new List<Building>();//楼栋列表
|
|||
internal List<DeviceType> DeviceTypeList = new List<DeviceType>();//设备类型字典
|
|||
internal List<AppListModel> AppList = new List<AppListModel>(); |
|||
internal List<AppTimeModel> AppTimeList = new List<AppTimeModel>(); |
|||
internal List<Floor> Floors = new List<Floor>();//楼层列表
|
|||
//internal string Programname = "";//默认启动的程序名
|
|||
internal string AppPlayDir = "";//需要播放的应用所在的文件夹名
|
|||
internal string AppPlayName = "";//需要播放的应用启动文件名
|
|||
internal string CurAppPlayName = "";//当前应用名称
|
|||
internal string AppPlayNameCH = "";//中文名称
|
|||
internal string Appversion = "";//应用版本号
|
|||
internal string Containerversion = "";//容器版本号
|
|||
//internal bool AppUpdate = false;//是否已更新
|
|||
//internal string AppDownCode = "";//应用下线
|
|||
//internal ExeModel Appdowninfo = new ExeModel();//应用下载对象
|
|||
//internal ExeModel AppStartinfo = new ExeModel();//应用启动对象
|
|||
internal AppListModel AppPlayinfo = new AppListModel();//当前应用对象
|
|||
//internal List<ExeModel> exeinfo = new List<ExeModel>();//应用列表
|
|||
//internal string icourl = "";//应用图标路径
|
|||
//internal InsertADModel insertAD=new InsertADModel();
|
|||
internal string bgPath = ""; |
|||
internal BGPage pageBg; |
|||
//internal string defaultFile = "";
|
|||
internal Screensaver screensaver = new Screensaver() { EffectType = 1, ScreenEffect = 1, ScreenFile = "", ScreenType = 0 ,ScreenTime=30}; |
|||
//internal int screenTime = 30;
|
|||
internal RabbitMQModel rabbitMQ = new RabbitMQModel(); |
|||
|
|||
internal bool isStartScreen = false; |
|||
Class_Log log = new Class_Log(); |
|||
internal List<SubTitle> TopSubTitle = new List<SubTitle> { }; |
|||
internal List<SubTitle> BottomSubTitle = new List<SubTitle> { }; |
|||
internal int TopSubTitleIndex = 0; |
|||
internal int BottomSubTitleIndex = 0; |
|||
//internal string kioskUrl = "";
|
|||
internal static bool Downloaddone = false; |
|||
internal int currentIndex = 0; |
|||
//internal WindowView view;
|
|||
//internal Screensaver screensaver = new Screensaver() { EffectType = 1, ScreenEffect = 1, ScreenFile = "", ScreenType = 0 };
|
|||
internal NavViewModel navModel = new NavViewModel(); |
|||
System.Threading.Mutex mutex; |
|||
internal bool isProgramServer = false; |
|||
internal bool isProgramSync = false; |
|||
internal bool isSendSync = false; |
|||
internal string websocketProgramIP = string.Empty; |
|||
internal WebsocketForProgramServer websocketForProgramServer = null; |
|||
internal WebSocketForProgram webSocketForProgram = null; |
|||
internal string kioskUrl = ""; |
|||
internal bool IsCanConnect = true; |
|||
internal Live live = new Live(); |
|||
internal CurrentLive curLive = new CurrentLive(); |
|||
internal bool LiveReload = false; |
|||
internal bool isLoadLive = false; |
|||
internal DateTime? CloseServerTime = null; |
|||
internal List<PlayProg> playProgList = new List<PlayProg>(); |
|||
internal List<ShutDownProg> shutDownProgList = new List<ShutDownProg>(); |
|||
internal string BGFile = string.Empty; |
|||
internal string defaultCity = string.Empty; |
|||
internal bool isCheckServerTime = false; |
|||
internal string kioskVersion = ""; |
|||
internal string screenshotUserName = ""; |
|||
//internal bool isStartHeat = false;
|
|||
|
|||
internal bool IsDownScreen = false; |
|||
internal string screenConfig = string.Empty; |
|||
internal int downErrorTime = 0; |
|||
internal string FileServerPath = string.Empty; |
|||
internal string OBSPath = string.Empty; |
|||
internal double ScreenWidth = 0; |
|||
internal double ScreenHeight = 0; |
|||
internal bool isStartGetProg = false; |
|||
string info = ""; |
|||
public MainWindow main; |
|||
|
|||
private void Application_Startup(object sender, StartupEventArgs e) |
|||
{ |
|||
Class_Log clog = new Class_Log(); |
|||
bool ret; |
|||
mutex = new System.Threading.Mutex(true, "WpfMuerterrrterterttex11", out ret); |
|||
if (!ret) |
|||
{ |
|||
// MessageBox.Show("程序已启动");
|
|||
Environment.Exit(0); |
|||
} |
|||
|
|||
try |
|||
{ |
|||
this.configHttpUrl = ConfigurationManager.AppSettings["HttpUrl"]; |
|||
if (!string.IsNullOrEmpty(this.configHttpUrl)) |
|||
{ |
|||
this.HttpUrl = this.configHttpUrl; |
|||
this.configurl = this.configHttpUrl; |
|||
} |
|||
|
|||
bool update = true; |
|||
clog.WriteLogFile("收到:" + e.Args.Count(), "Loadargs"); |
|||
if (e.Args.Count() > 0) |
|||
{ |
|||
clog.WriteLogFile("收到:" + e.Args[0].ToString(), "Loadargs"); |
|||
string[] inf = e.Args[0].ToString().Split('&'); |
|||
clog.WriteLogFile("inf.Count():" + inf.Count().ToString(), "Loadargs"); |
|||
if (inf.Count() > 1) |
|||
update = false; |
|||
} |
|||
if (update) |
|||
{ |
|||
//System.Security.Principal.WindowsIdentity identity1 = System.Security.Principal.WindowsIdentity.GetCurrent();
|
|||
////创建Windows用户主题
|
|||
//System.Windows.Forms.Application.EnableVisualStyles();
|
|||
//System.Security.Principal.WindowsPrincipal principal1 = new System.Security.Principal.WindowsPrincipal(identity1);
|
|||
////判断当前登录用户是否为管理员
|
|||
//if (!principal1.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator))
|
|||
//{
|
|||
// //创建启动对象
|
|||
// System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
|
|||
// //设置运行文件
|
|||
// startInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
// startInfo.FileName = startInfo.WorkingDirectory + "/ConUpdate.exe"; //设置启动参数
|
|||
// startInfo.Arguments = info;
|
|||
// //设置启动动作,确保以管理员身份运行
|
|||
// startInfo.Verb = "runas";
|
|||
// //如果不是管理员,则启动UAC
|
|||
// //log.WriteLogFile("工作路径:" + startInfo.WorkingDirectory, "APPError");
|
|||
// System.Diagnostics.Process.Start(startInfo);
|
|||
// //退出
|
|||
// System.Windows.Forms.Application.Exit();
|
|||
|
|||
// //System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|||
// //p.StartInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
// //p.StartInfo.FileName = p.StartInfo.WorkingDirectory + "/PCScreenSavers.exe";
|
|||
// //p.StartInfo.Arguments = app.info;
|
|||
// //p.StartInfo.Verb = "runas";
|
|||
// //p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
|
|||
// //p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
|
|||
// //p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
|||
// //p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
|
|||
// ////p.ProcessNa = "PCScreenUpdate";
|
|||
// //p.StartInfo.CreateNoWindow = false;//不显示程序窗口
|
|||
// //p.Start();//启动程序
|
|||
//}
|
|||
//else
|
|||
//{
|
|||
// System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|||
// p.StartInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
// p.StartInfo.FileName = p.StartInfo.WorkingDirectory + "/ConUpdate.exe";
|
|||
// p.StartInfo.Arguments = info;
|
|||
// p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
|
|||
// p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
|
|||
// p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
|||
// p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
|
|||
// p.StartInfo.CreateNoWindow = false;//不显示程序窗口
|
|||
// p.Start();//启动程序
|
|||
//}
|
|||
StartConUpdate(info); |
|||
Environment.Exit(0); |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
clog.WriteLogFile(ex.ToString()); |
|||
} |
|||
try |
|||
{ |
|||
System.Security.Principal.WindowsIdentity identity = System.Security.Principal.WindowsIdentity.GetCurrent(); |
|||
//创建Windows用户主题
|
|||
System.Windows.Forms.Application.EnableVisualStyles(); |
|||
Class_Log log = new Class_Log(); |
|||
|
|||
System.Security.Principal.WindowsPrincipal principal = new System.Security.Principal.WindowsPrincipal(identity); |
|||
//判断当前登录用户是否为管理员
|
|||
if (!principal.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) |
|||
{ |
|||
//创建启动对象
|
|||
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); |
|||
//设置运行文件
|
|||
startInfo.FileName = System.Windows.Forms.Application.ExecutablePath; |
|||
|
|||
startInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
//设置启动参数
|
|||
startInfo.Arguments = String.Join(" ", e); |
|||
//设置启动动作,确保以管理员身份运行
|
|||
startInfo.Verb = "runas"; |
|||
//如果不是管理员,则启动UAC
|
|||
System.Diagnostics.Process.Start(startInfo); |
|||
//退出
|
|||
System.Windows.Forms.Application.Exit(); |
|||
} |
|||
else |
|||
{ |
|||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); |
|||
Application.Current.DispatcherUnhandledException += new System.Windows.Threading.DispatcherUnhandledExceptionEventHandler(Current_DispatcherUnhandledException); |
|||
MainWindow win = new MainWindow(); |
|||
main = win; |
|||
win.Show(); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
clog.WriteLogFile(ex.ToString()); |
|||
// MessageBox.Show("程序启动失败");
|
|||
} |
|||
} |
|||
|
|||
|
|||
private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e) |
|||
{ |
|||
log.WriteLogFile(e.Exception.Message + e.Exception.StackTrace, "APPError"); |
|||
log.WriteLogFile("---111--" + e.ToString(), "APPError"); |
|||
StartConUpdate(info); |
|||
Environment.Exit(0); |
|||
} |
|||
|
|||
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) |
|||
{ |
|||
Exception ex = (Exception)e.ExceptionObject; |
|||
log.WriteLogFile(ex.Message + ex.StackTrace, "APPError"); |
|||
log.WriteLogFile("-----"+ex.ToString(), "APPError"); |
|||
StartConUpdate(info); |
|||
Environment.Exit(0); |
|||
} |
|||
|
|||
void App_Startup(object sender, StartupEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
private void StartConUpdate(string info) { |
|||
System.Security.Principal.WindowsIdentity identity1 = System.Security.Principal.WindowsIdentity.GetCurrent(); |
|||
//创建Windows用户主题
|
|||
System.Windows.Forms.Application.EnableVisualStyles(); |
|||
System.Security.Principal.WindowsPrincipal principal1 = new System.Security.Principal.WindowsPrincipal(identity1); |
|||
//判断当前登录用户是否为管理员
|
|||
if (!principal1.IsInRole(System.Security.Principal.WindowsBuiltInRole.Administrator)) |
|||
{ |
|||
//创建启动对象
|
|||
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); |
|||
//设置运行文件
|
|||
startInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
startInfo.FileName = startInfo.WorkingDirectory + "/ConUpdate.exe"; //设置启动参数
|
|||
startInfo.Arguments = info; |
|||
//设置启动动作,确保以管理员身份运行
|
|||
startInfo.Verb = "runas"; |
|||
//如果不是管理员,则启动UAC
|
|||
//log.WriteLogFile("工作路径:" + startInfo.WorkingDirectory, "APPError");
|
|||
System.Diagnostics.Process.Start(startInfo); |
|||
//退出
|
|||
System.Windows.Forms.Application.Exit(); |
|||
|
|||
//System.Diagnostics.Process p = new System.Diagnostics.Process();
|
|||
//p.StartInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
//p.StartInfo.FileName = p.StartInfo.WorkingDirectory + "/PCScreenSavers.exe";
|
|||
//p.StartInfo.Arguments = app.info;
|
|||
//p.StartInfo.Verb = "runas";
|
|||
//p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
|
|||
//p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
|
|||
//p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
|||
//p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
|
|||
////p.ProcessNa = "PCScreenUpdate";
|
|||
//p.StartInfo.CreateNoWindow = false;//不显示程序窗口
|
|||
//p.Start();//启动程序
|
|||
} |
|||
else |
|||
{ |
|||
System.Diagnostics.Process p = new System.Diagnostics.Process(); |
|||
p.StartInfo.WorkingDirectory = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
p.StartInfo.FileName = p.StartInfo.WorkingDirectory + "/ConUpdate.exe"; |
|||
p.StartInfo.Arguments = info; |
|||
p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
|
|||
p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
|
|||
p.StartInfo.RedirectStandardOutput = true;//由调用程序获取输出信息
|
|||
p.StartInfo.RedirectStandardError = true;//重定向标准错误输出
|
|||
p.StartInfo.CreateNoWindow = false;//不显示程序窗口
|
|||
p.Start();//启动程序
|
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,564 @@ |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.IO.Compression; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Windows; |
|||
|
|||
namespace Container.Business |
|||
{ |
|||
public class DownLoadMethod |
|||
{ |
|||
private Class_Log log = new Class_Log(); |
|||
private App app = ((App)Application.Current); |
|||
//public bool DownLoadZip(string url, string downloadFolder, string md5, out string errorMsg, bool isback = true, bool isupdate = true)
|
|||
//{
|
|||
// bool flag = false;
|
|||
// errorMsg = string.Empty;
|
|||
// try
|
|||
// {
|
|||
// if (!Directory.Exists(downloadFolder))
|
|||
// {
|
|||
// Directory.CreateDirectory(downloadFolder);
|
|||
// }
|
|||
// WebClientPro webClient = new WebClientPro(30 * 60 * 1000);
|
|||
// string fileName = url.Substring(url.Replace("\\", "/").Replace(@"\", "/").LastIndexOf('/') + 1);
|
|||
// if (fileName.Contains("?"))
|
|||
// {
|
|||
// fileName = fileName.Substring(0, fileName.IndexOf('?'));
|
|||
// }
|
|||
// string downUrl = downloadFolder + @"\" + fileName;
|
|||
// //下载更新包
|
|||
// webClient.DownloadFile(url, downUrl);
|
|||
// string localMD5 = GetMD5HashFromFile(downUrl);
|
|||
// if (!string.IsNullOrEmpty(md5) && md5 != localMD5)
|
|||
// {
|
|||
// errorMsg = "MD5校验不合格";
|
|||
// File.Delete(downUrl);
|
|||
// return flag;
|
|||
// }
|
|||
|
|||
// string UpdateReleasePath = downloadFolder + @"/temp/";
|
|||
// //解压更新包至指定路径
|
|||
// if (Directory.Exists(UpdateReleasePath))
|
|||
// {
|
|||
// DeleteDir(UpdateReleasePath, 1);
|
|||
// Directory.CreateDirectory(UpdateReleasePath);
|
|||
// }
|
|||
// ZipFile.ExtractToDirectory(downUrl, UpdateReleasePath);
|
|||
// string mainpropath = downloadFolder + @"\Main";
|
|||
// DirectoryInfo di = new DirectoryInfo(mainpropath);//正式包路径
|
|||
// DirectoryInfo di2 = new DirectoryInfo(UpdateReleasePath);//更新包解压路径
|
|||
|
|||
|
|||
|
|||
// if (isback)
|
|||
// {
|
|||
// DirectoryInfo source = new DirectoryInfo(downloadFolder);
|
|||
// DirectoryInfo[] dirs = source.GetDirectories();
|
|||
|
|||
// foreach (DirectoryInfo dir in dirs)
|
|||
// {
|
|||
// log.WriteLogFile(mainpropath + "----" + dir.Name.Length + "----" + mainpropath.Length, "更新");
|
|||
// if (dir.Name.Contains("Main") && dir.Name.Length > 4)
|
|||
// {
|
|||
// DeleteDir(dir.FullName, 1);
|
|||
// }
|
|||
// }
|
|||
// DirectoryInfo diback = new DirectoryInfo(mainpropath + DateTime.Now.ToString("yyyyMMddHHmmss"));//正式包路径
|
|||
// MoveDirectory(di, diback, true); //复制子目录
|
|||
// }
|
|||
// if (isupdate)
|
|||
// {
|
|||
// MoveDirectory(di2, di, true); //复制子目录
|
|||
// }
|
|||
|
|||
// flag = true;
|
|||
// }
|
|||
// catch (Exception e)
|
|||
// {
|
|||
// flag = false;
|
|||
// errorMsg = e.Message;
|
|||
// log.WriteLogFile(e.ToString(), "DownLoadZipError");
|
|||
// }
|
|||
// return flag;
|
|||
//}
|
|||
|
|||
/// <summary>
|
|||
/// 获取文件MD5 哈希码
|
|||
/// </summary>
|
|||
/// <param name="fileName"></param>
|
|||
/// <returns></returns>
|
|||
public string GetMD5HashFromFile(string fileName) |
|||
{ |
|||
try |
|||
{ |
|||
FileStream file = new FileStream(fileName, FileMode.Open); |
|||
System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider(); |
|||
byte[] retVal = md5.ComputeHash(file); |
|||
file.Close(); |
|||
|
|||
StringBuilder sb = new StringBuilder(); |
|||
for (int i = 0; i < retVal.Length; i++) |
|||
{ |
|||
sb.Append(retVal[i].ToString("x2")); |
|||
} |
|||
return sb.ToString(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile("GetMD5HashFromFile() fail, error:" + ex.ToString(), "downloaderror"); |
|||
return ""; |
|||
} |
|||
} |
|||
|
|||
public static string ReadContext(string path) |
|||
{ |
|||
|
|||
try |
|||
{ |
|||
if (File.Exists(path)) |
|||
{ |
|||
FileStream fs = new FileStream(path, FileMode.Open); |
|||
StreamReader sr = new StreamReader(fs, System.Text.Encoding.UTF8); |
|||
string context = sr.ReadToEnd(); |
|||
fs.Close(); |
|||
sr.Close(); |
|||
sr.Dispose(); |
|||
fs.Dispose(); |
|||
|
|||
return context; |
|||
} |
|||
else |
|||
{ |
|||
return ""; |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Class_Log log = new Class_Log(); |
|||
log.WriteLogFile(ex.ToString(), "Temp113"); |
|||
ReadContext(path); |
|||
return ""; |
|||
} |
|||
} |
|||
|
|||
public void DeleteDir(string srcPath, int isSelf = 0) |
|||
{ |
|||
try |
|||
{ |
|||
if (!Directory.Exists(srcPath)) |
|||
{ |
|||
return; |
|||
} |
|||
DirectoryInfo dir = new DirectoryInfo(srcPath); |
|||
FileSystemInfo[] fileinfo = dir.GetFileSystemInfos(); //返回目录中所有文件和子目录
|
|||
foreach (FileSystemInfo i in fileinfo) |
|||
{ |
|||
try |
|||
{ |
|||
if (i is DirectoryInfo) //判断是否文件夹
|
|||
{ |
|||
DirectoryInfo subdir = new DirectoryInfo(i.FullName); |
|||
subdir.Delete(true); //删除子目录和文件
|
|||
} |
|||
else |
|||
{ |
|||
//如果 使用了 streamreader 在删除前 必须先关闭流 ,否则无法删除 sr.close();
|
|||
File.Delete(i.FullName); //删除指定文件
|
|||
} |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
|
|||
|
|||
} |
|||
} |
|||
if (isSelf == 1) |
|||
{ |
|||
dir.Delete(); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
log.WriteLogFile("DeleteDir:" + e.Message, "downloaderror"); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 拷贝目录内容
|
|||
/// </summary>
|
|||
/// <param name="source">源目录</param>
|
|||
/// <param name="destination">目的目录</param>
|
|||
/// <param name="copySubDirs">是否拷贝子目录</param>
|
|||
public void CopyDirectory(DirectoryInfo source, DirectoryInfo destination, bool copySubDirs) |
|||
{ |
|||
|
|||
if (!destination.Exists) |
|||
{ |
|||
destination.Create(); //目标目录若不存在就创建
|
|||
} |
|||
FileInfo[] files = source.GetFiles(); |
|||
foreach (FileInfo file in files) |
|||
{ |
|||
file.CopyTo(Path.Combine(destination.FullName, file.Name), true); //复制目录中所有文件,替换相同文件
|
|||
} |
|||
if (copySubDirs) |
|||
{ |
|||
DirectoryInfo[] dirs = source.GetDirectories(); |
|||
foreach (DirectoryInfo dir in dirs) |
|||
{ |
|||
string destinationDir = Path.Combine(destination.FullName, dir.Name); |
|||
CopyDirectory(dir, new DirectoryInfo(destinationDir), copySubDirs); //复制子目录
|
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 拷贝目录内容,删除本身
|
|||
/// </summary>
|
|||
/// <param name="source">源目录</param>
|
|||
/// <param name="destination">目的目录</param>
|
|||
/// <param name="copySubDirs">是否拷贝子目录</param>
|
|||
public void MoveDirectory(DirectoryInfo source, DirectoryInfo destination, bool copySubDirs) |
|||
{ |
|||
if (!destination.Exists) |
|||
{ |
|||
destination.Create(); //目标目录若不存在就创建
|
|||
} |
|||
FileInfo[] files = source.GetFiles(); |
|||
foreach (FileInfo file in files) |
|||
{ |
|||
file.CopyTo(Path.Combine(destination.FullName, file.Name), true); //复制目录中所有文件,替换相同文件
|
|||
file.Delete(); |
|||
} |
|||
|
|||
if (copySubDirs) |
|||
{ |
|||
DirectoryInfo[] dirs = source.GetDirectories(); |
|||
|
|||
foreach (DirectoryInfo dir in dirs) |
|||
{ |
|||
string destinationDir = Path.Combine(destination.FullName, dir.Name); |
|||
MoveDirectory(dir, new DirectoryInfo(destinationDir), copySubDirs); //复制子目录
|
|||
} |
|||
if (source.GetDirectories().Length == 0) |
|||
source.Delete(); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
bool done = false; |
|||
private string outLinePath = AppDomain.CurrentDomain.BaseDirectory + "/OutlineFiles"; |
|||
public bool DownLoadScreenConfig(List<ScheduleModel> ScheduleList, string configStr) |
|||
{ |
|||
if (!done) |
|||
{ |
|||
done = true; |
|||
log.WriteLogFile("开始下载", "exelog"); |
|||
try |
|||
{ |
|||
int downerrorCount = 0; |
|||
foreach (var resource in ScheduleList) |
|||
{ |
|||
if (resource == null || resource.schedule == null || resource.schedule.Count == 0) |
|||
{ |
|||
continue; |
|||
} |
|||
foreach (var item in resource.schedule) |
|||
{ |
|||
if (item != null && item.programs != null) |
|||
{ |
|||
foreach (var itemprogram in item.programs) |
|||
{ |
|||
if (itemprogram.backgroundMaterialInfo != null) |
|||
{ |
|||
var localFileName = string.Empty; |
|||
if (localFileName.Contains('?')) |
|||
{ |
|||
localFileName = itemprogram.backgroundMaterialInfo.fileHash + itemprogram.backgroundMaterialInfo.filePath.Substring(itemprogram.backgroundMaterialInfo.filePath.LastIndexOf("."), itemprogram.backgroundMaterialInfo.filePath.LastIndexOf("?") - itemprogram.backgroundMaterialInfo.filePath.LastIndexOf(".")); |
|||
} |
|||
else |
|||
{ |
|||
localFileName = itemprogram.backgroundMaterialInfo.fileHash + itemprogram.backgroundMaterialInfo.filePath.Substring(itemprogram.backgroundMaterialInfo.filePath.LastIndexOf(".")); |
|||
} |
|||
bool flag = DownLoadFile(itemprogram.backgroundMaterialInfo.filePath, localFileName, itemprogram.backgroundMaterialInfo.fileHash); |
|||
if (!flag) |
|||
{ |
|||
downerrorCount += 1; |
|||
} |
|||
} |
|||
foreach (var itemcomponent in itemprogram.components) |
|||
{ |
|||
if (itemcomponent.materials != null) |
|||
{ |
|||
foreach (var material in itemcomponent.materials) |
|||
{ |
|||
if (string.IsNullOrEmpty(material.fileUrl)) |
|||
{ |
|||
continue; |
|||
} |
|||
var localFileName = string.Empty; |
|||
if (localFileName.Contains('?')) |
|||
{ |
|||
localFileName = material.fileHash + material.fileUrl.Substring(material.fileUrl.LastIndexOf("."), material.fileUrl.LastIndexOf("?") - material.fileUrl.LastIndexOf(".")); |
|||
} |
|||
else |
|||
{ |
|||
localFileName = material.fileHash + material.fileUrl.Substring(material.fileUrl.LastIndexOf(".")); |
|||
} |
|||
bool flag = DownLoadFile(material.fileUrl, localFileName, material.fileHash); |
|||
if (!flag) |
|||
{ |
|||
downerrorCount += 1; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
if (downerrorCount > 0) |
|||
{ |
|||
done = false; |
|||
return false; |
|||
} |
|||
else |
|||
{ |
|||
bool flag = Write(outLinePath + "/temp/screenconfig.txt", configStr); |
|||
if (flag) |
|||
{ |
|||
//DeleteDir(outLinePath + "/Main", 0);
|
|||
DirectoryInfo di = new DirectoryInfo(outLinePath + "/Main");//正式包路径
|
|||
DirectoryInfo di2 = new DirectoryInfo(outLinePath + "/temp");//更新包解压路径
|
|||
MergeDirectory(di2, di, true); |
|||
done = false; |
|||
return true; |
|||
} |
|||
else |
|||
{ |
|||
done = false; |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
done = false; |
|||
return false; |
|||
} |
|||
finally |
|||
{ |
|||
done = false; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
private bool DownLoadFile(string filePath, string localFileName, string hash) |
|||
{ |
|||
try |
|||
{ |
|||
filePath = app.FileServerPath + filePath; |
|||
filePath = filePath.Replace(@"\", @"/"); |
|||
var tempFolder = outLinePath + "/temp"; |
|||
var mainFolder = outLinePath + "/Main"; |
|||
if (!Directory.Exists(tempFolder)) |
|||
{ |
|||
Directory.CreateDirectory(tempFolder); |
|||
} |
|||
if (!File.Exists(tempFolder + "/" + localFileName)) |
|||
{ |
|||
if (!File.Exists(mainFolder + "/" + localFileName)) |
|||
{ |
|||
if (File.Exists(tempFolder + "/" + localFileName)) |
|||
{ |
|||
return true; |
|||
} |
|||
if (File.Exists(tempFolder + "/" + localFileName + ".temp")) |
|||
File.Delete(tempFolder + "/" + localFileName + ".temp"); |
|||
using (Stream fileStream = new FileStream(tempFolder + "/" + localFileName + ".temp", FileMode.OpenOrCreate)) |
|||
{ |
|||
try |
|||
{ |
|||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(filePath); |
|||
request.AddRange(fileStream.Length); |
|||
|
|||
HttpWebResponse respone = (HttpWebResponse)request.GetResponse(); |
|||
using (Stream netStream = respone.GetResponseStream()) |
|||
{ |
|||
long totalDownloadedByte = 0; |
|||
byte[] read = new byte[1024]; |
|||
int realReadLen = netStream.Read(read, 0, read.Length); |
|||
while (realReadLen > 0) |
|||
{ |
|||
totalDownloadedByte = realReadLen + totalDownloadedByte; |
|||
|
|||
fileStream.Write(read, 0, realReadLen); |
|||
realReadLen = netStream.Read(read, 0, read.Length); |
|||
|
|||
System.Windows.Forms.Application.DoEvents(); |
|||
} |
|||
netStream.Close(); |
|||
} |
|||
if (fileStream.Length != respone.ContentLength) |
|||
{ |
|||
log.WriteLogFile("文件未下载完毕", "文件"); |
|||
} |
|||
fileStream.Close(); |
|||
log.WriteLogFile("下载完成" + tempFolder + "/" + localFileName, "exelog"); |
|||
File.Move(tempFolder + "/" + localFileName + ".temp", tempFolder + "/" + localFileName); |
|||
|
|||
|
|||
|
|||
var fileHash = GetMD5HashFromFile(tempFolder + "/" + localFileName); |
|||
if (fileHash != hash) |
|||
{ |
|||
log.WriteLogFile("localFile " + fileHash + " getHash:" + hash, "exelog"); |
|||
File.Delete(tempFolder + "/" + localFileName); |
|||
log.WriteLogFile("FileHash对比不一致,须删除重新下载" + tempFolder + "/" + localFileName, "exelog"); |
|||
return false; |
|||
} |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
fileStream.Close(); |
|||
log.WriteLogFile("下载失败" + tempFolder + "/" + localFileName + ex.ToString(), "exelog"); |
|||
File.Delete(tempFolder + "/" + localFileName + ".temp"); |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
File.Copy(mainFolder + "/" + localFileName, tempFolder + "/" + localFileName); |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
log.WriteLogFile(e.ToString(), "OutLineLog"); |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public bool Write(string path, string configStr) |
|||
{ |
|||
try |
|||
{ |
|||
if (!Directory.Exists(outLinePath + "/temp")) |
|||
{ |
|||
Directory.CreateDirectory(outLinePath + "/temp"); |
|||
} |
|||
FileStream fs = new FileStream(path, FileMode.Create); |
|||
StreamWriter sw = new StreamWriter(fs); |
|||
//开始写入
|
|||
sw.Write(configStr); |
|||
//清空缓冲区
|
|||
sw.Flush(); |
|||
//关闭流
|
|||
sw.Close(); |
|||
fs.Close(); |
|||
return true; |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
|
|||
return false; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 拷贝目录内容,删除本身
|
|||
/// </summary>
|
|||
/// <param name="source">源目录</param>
|
|||
/// <param name="destination">目的目录</param>
|
|||
/// <param name="copySubDirs">是否拷贝子目录</param>
|
|||
public void MergeDirectory(DirectoryInfo source, DirectoryInfo destination, bool copySubDirs) |
|||
{ |
|||
if (!destination.Exists) |
|||
{ |
|||
destination.Create(); //目标目录若不存在就创建
|
|||
} |
|||
if (!source.Exists) |
|||
{ |
|||
source.Create(); //目标目录若不存在就创建
|
|||
} |
|||
FileInfo[] sourceFiles = source.GetFiles(); |
|||
FileInfo[] destinationFiles = destination.GetFiles(); |
|||
foreach (var item in sourceFiles) |
|||
{ |
|||
if (item.Extension.Contains("txt")) |
|||
{ |
|||
item.CopyTo(Path.Combine(destination.FullName, item.Name), true); |
|||
} |
|||
else if ((!File.Exists(Path.Combine(destination.FullName, item.Name)))) |
|||
{ |
|||
CopyTo(item, Path.Combine(destination.FullName, item.Name)); |
|||
//item.CopyTo(Path.Combine(destination.FullName, item.Name),true);
|
|||
} |
|||
} |
|||
|
|||
foreach (var item in destinationFiles) |
|||
{ |
|||
if (!File.Exists(Path.Combine(source.FullName, item.Name))) |
|||
{ |
|||
try |
|||
{ |
|||
item.Delete(); |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
|
|||
|
|||
} |
|||
} |
|||
} |
|||
DeleteDir(source.FullName, 1); |
|||
} |
|||
|
|||
private void CopyTo(FileInfo tempFile, string mainFilePath) |
|||
{ |
|||
try |
|||
{ |
|||
string fileTempMD5 = GetMD5HashFromFile(tempFile.FullName); |
|||
tempFile.CopyTo(mainFilePath, true); |
|||
string fileMainMD5 = GetMD5HashFromFile(mainFilePath); |
|||
if (fileTempMD5 != fileMainMD5) |
|||
{ |
|||
File.Delete(mainFilePath); |
|||
CopyTo(tempFile, mainFilePath); |
|||
} |
|||
else |
|||
{ |
|||
File.Delete(tempFile.FullName); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
log.WriteLogFile(e.ToString(), "copyError"); |
|||
if (File.Exists(mainFilePath)) |
|||
{ |
|||
File.Delete(mainFilePath); |
|||
} |
|||
CopyTo(tempFile, mainFilePath); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,569 @@ |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using Container.Services; |
|||
using Container.Viewmodel; |
|||
using Newtonsoft.Json; |
|||
using Newtonsoft.Json.Linq; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Windows; |
|||
using System.Xml; |
|||
|
|||
namespace Container.Business |
|||
{ |
|||
public class ItemInfo |
|||
{ |
|||
public int id { get; set; } |
|||
|
|||
public string img { get; set; } |
|||
|
|||
public int time { get; set; } |
|||
|
|||
public string effect { get; set; } |
|||
|
|||
//public string text { get; set; }
|
|||
|
|||
public string screenmatch { get; set; } |
|||
|
|||
public string code { get; set; } |
|||
public string launchtime { get; set; } |
|||
public string expirydate { get; set; } |
|||
public string protype { get; set; } |
|||
public string xaxis { get; set; } |
|||
|
|||
public string yaxis { get; set; } |
|||
|
|||
public string devNum { get; set; } |
|||
|
|||
public string floorOrder { get; set; } |
|||
public string applets { get; set; } |
|||
|
|||
public ShopInfo shopInfo { get; set; } |
|||
} |
|||
|
|||
public class ShopInfo |
|||
{ |
|||
public string FloorName { get; set; } |
|||
|
|||
public string ShopName { get; set; } |
|||
|
|||
public string LogoPath { get; set; } |
|||
|
|||
public string Angle { get; set; } |
|||
|
|||
public string houseNum { get; set; } |
|||
public string shopFormatIcon { get; set; } |
|||
public string shopFormatName { get; set; } |
|||
} |
|||
public class JService |
|||
{ |
|||
App app = ((App)Application.Current); |
|||
//private string localIP = app.LocalIP;
|
|||
//private string remoteAddress = ConfigurationManager.AppSettings["RemoteAddress"];
|
|||
Class_Log Mylog = new Class_Log(); |
|||
public delegate void ScreenConfigDelegate(); |
|||
public static event ScreenConfigDelegate ScreenConfigReceiveEvent; |
|||
///// <summary>
|
|||
///// 绑定ip
|
|||
///// </summary>
|
|||
//public bool BindIp()
|
|||
//{
|
|||
// string urlString = string.Format("http://{0}/shanjing/interFace/kioskBinding.do?ip={1}", remoteAddress, localIP);
|
|||
// string ret = GetHttpResponse(urlString);
|
|||
|
|||
// if (string.IsNullOrEmpty(ret))
|
|||
// return false;
|
|||
// else
|
|||
// return true;
|
|||
//}
|
|||
public string WriteToConfig(List<ItemInfo> itemList, string code) |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
XmlDocument doc = new XmlDocument(); // 创建dom对象
|
|||
|
|||
XmlElement root = doc.CreateElement("root"); // 创建根节点
|
|||
|
|||
doc.AppendChild(root); // 加入到xml document
|
|||
XmlElement FillItem; // 创建FillItem元素
|
|||
|
|||
FillItem = doc.CreateElement("code"); |
|||
FillItem.InnerText = code; |
|||
root.AppendChild(FillItem); // 添加到xml document
|
|||
FillItem = doc.CreateElement("items"); |
|||
if (itemList != null && itemList.Count > 0) |
|||
{ |
|||
for (int i = 0; i < itemList.Count; i++) |
|||
{ |
|||
XmlElement Node = doc.CreateElement("item"); |
|||
Node.SetAttribute("id", itemList[i].id.ToString()); |
|||
Node.SetAttribute("img", itemList[i].img); |
|||
Node.SetAttribute("time", itemList[i].time.ToString()); |
|||
Node.SetAttribute("effect", itemList[i].effect); |
|||
Node.SetAttribute("screenmatch", itemList[i].screenmatch); |
|||
Node.SetAttribute("launchtime", itemList[i].launchtime); |
|||
Node.SetAttribute("expirydate", itemList[i].expirydate); |
|||
Node.SetAttribute("protype", itemList[i].protype); |
|||
Node.SetAttribute("code", itemList[i].code); |
|||
Node.SetAttribute("xaxis", itemList[i].xaxis); |
|||
Node.SetAttribute("yaxis", itemList[i].yaxis); |
|||
Node.SetAttribute("floorOrder", itemList[i].floorOrder); |
|||
Node.SetAttribute("devNum", itemList[i].devNum); |
|||
Node.SetAttribute("applets", itemList[i].applets); |
|||
Node.SetAttribute("floorName", itemList[i].shopInfo == null ? "" : itemList[i].shopInfo.FloorName); |
|||
Node.SetAttribute("shopName", itemList[i].shopInfo == null ? "" : itemList[i].shopInfo.ShopName); |
|||
Node.SetAttribute("logoPath", itemList[i].shopInfo == null ? "" : itemList[i].shopInfo.LogoPath); |
|||
Node.SetAttribute("houseNum", itemList[i].shopInfo == null ? "" : itemList[i].shopInfo.houseNum); |
|||
Node.SetAttribute("shopFormatIcon", itemList[i].shopInfo == null ? "" : itemList[i].shopInfo.shopFormatIcon); |
|||
Node.SetAttribute("shopFormatName", itemList[i].shopInfo == null ? "" : itemList[i].shopInfo.shopFormatName); |
|||
|
|||
FillItem.AppendChild(Node); |
|||
} |
|||
} |
|||
root.AppendChild(FillItem); |
|||
|
|||
|
|||
|
|||
MemoryStream stream = new MemoryStream(); |
|||
XmlTextWriter writer = new XmlTextWriter(stream, null); |
|||
writer.Formatting = System.Xml.Formatting.Indented; |
|||
doc.Save(writer); |
|||
StreamReader sr = new StreamReader(stream, Encoding.UTF8); |
|||
|
|||
stream.Position = 0; |
|||
|
|||
string XMLString = sr.ReadToEnd(); |
|||
Mylog.WriteLogFile(XMLString, "XMLString"); |
|||
sr.Close(); |
|||
writer.Flush(); |
|||
writer.Close(); |
|||
stream.Flush(); |
|||
stream.Close(); |
|||
|
|||
return XMLString; |
|||
|
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Mylog.WriteLogFile(ex.ToString(), "JServiceErrorLog"); |
|||
return ""; |
|||
} |
|||
} |
|||
/// <summary>
|
|||
/// 获取后台图片或视频资源地址
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public bool GetOutLineResource() |
|||
{ |
|||
bool flag = false; |
|||
try |
|||
{ |
|||
string MethodStr = "/Api/Programme/DevProgrammeList"; |
|||
var data = new { DevCode = app.deviceid }; |
|||
var ret = MyHttpClient.CryptPost(MethodStr, data, app.HttpUrl); |
|||
Mylog.WriteLogFile(ret, "HttpClient"); |
|||
//ret= DownLoadMethod.ReadContext(AppDomain.CurrentDomain.BaseDirectory + "/OutlineFiles/1.txt");
|
|||
if (!string.IsNullOrEmpty(ret)) |
|||
{ |
|||
app.isStartGetProg = false; |
|||
string oldConfig = DownLoadMethod.ReadContext(AppDomain.CurrentDomain.BaseDirectory + "/OutlineFiles/Main/screenconfig.txt"); |
|||
if (ret != oldConfig) |
|||
{ |
|||
|
|||
var Jo = JObject.Parse(ret); |
|||
string code = Jo.Value<string>("code"); |
|||
if (code == "200") |
|||
{ |
|||
if (app.IsDownScreen) |
|||
{ |
|||
app.screenConfig = ret; |
|||
} |
|||
else |
|||
{ |
|||
app.downErrorTime = 0; |
|||
DownScreen(ret); |
|||
} |
|||
return true; |
|||
//DownLoadMethod downLoadMethod = new DownLoadMethod();
|
|||
//flag = downLoadMethod.DownLoadScreenConfig(itemList, ret);
|
|||
//if (flag) {
|
|||
|
|||
//}
|
|||
} |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
if (app.isStartGetProg) |
|||
{ |
|||
Thread.Sleep(30000); |
|||
GetOutLineResource(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Mylog.WriteLogFile(ex.ToString(), "JServiceErrorLog"); |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
private void DownScreen(string revScreen) |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
var Jo = JObject.Parse(revScreen); |
|||
List<ScheduleModel> itemList = Jo.Value<JArray>("data").ToObject<List<ScheduleModel>>(); |
|||
|
|||
Action action = new Action(() => |
|||
{ |
|||
// List<ProgModel> itemList = Jo.Value<JArray>("data").ToObject<List<ProgModel>>();
|
|||
app.IsDownScreen = true; |
|||
DownLoadMethod downLoadMethod = new DownLoadMethod(); |
|||
bool flag = downLoadMethod.DownLoadScreenConfig(itemList, revScreen); |
|||
if (flag) |
|||
{ |
|||
ScreenConfigReceiveEvent?.Invoke(); |
|||
if (!string.IsNullOrEmpty(app.screenConfig)) |
|||
{ |
|||
|
|||
DownScreen(app.screenConfig); |
|||
app.screenConfig = string.Empty; |
|||
app.downErrorTime = 0; |
|||
} |
|||
else |
|||
{ |
|||
app.IsDownScreen = false; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
|
|||
if (!string.IsNullOrEmpty(app.screenConfig)) |
|||
{ |
|||
DownScreen(app.screenConfig); |
|||
app.screenConfig = string.Empty; |
|||
app.downErrorTime = 0; |
|||
} |
|||
else |
|||
{ |
|||
if (app.downErrorTime < 100) |
|||
{ |
|||
Thread.Sleep(1000); |
|||
DownScreen(revScreen); |
|||
app.downErrorTime++; |
|||
} |
|||
else |
|||
{ |
|||
app.downErrorTime = 0; |
|||
app.IsDownScreen = false; |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
//config.WriteToScreenConfig();
|
|||
}); |
|||
action.BeginInvoke(null, null); |
|||
|
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
Mylog.WriteLogFile(e.ToString(), "HttpClientError"); |
|||
} |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 获取天气
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public WeatherViewModel GetEnvironmental(string city) |
|||
{ |
|||
WeatherViewModel weather = new WeatherViewModel(); |
|||
try |
|||
{ |
|||
|
|||
//string urlString = string.Format("{0}/API/CDN/GetEnvironmentalData", app.kioskUrl);
|
|||
//string ret = GetHttpResponse(urlString);
|
|||
HttpClient httpclient = new HttpClient(); |
|||
StringBuilder sb = new StringBuilder(); |
|||
sb.Append("{\"city\":\"" + city + "\"}"); |
|||
httpclient.message = sb.ToString(); |
|||
httpclient.url = "http://saas.1000my.com:8999/API/Weather/GetWeather"; |
|||
string ret = httpclient.PostMoths(httpclient.message, httpclient.url); |
|||
|
|||
|
|||
if (!string.IsNullOrEmpty(ret)) |
|||
{ |
|||
Dictionary<string, Object> dic = JsonConvert.DeserializeObject<Dictionary<string, Object>>(ret); |
|||
if (!string.IsNullOrEmpty(dic["data"].ToString()) && dic["code"].ToString() == "200") |
|||
{ |
|||
Dictionary<string, Object> dicdata = JsonConvert.DeserializeObject<Dictionary<string, Object>>(dic["data"].ToString()); |
|||
weather.aqi = dicdata["realAqi"].ToString(); |
|||
weather.humidity = dicdata["humidity"].ToString(); |
|||
weather.pm25 = dicdata["aqi"].ToString(); |
|||
weather.temperature = dicdata["temperature_Now"].ToString(); |
|||
weather.windPower = dicdata["wind_Power"].ToString(); |
|||
weather.status = dicdata["status"].ToString(); |
|||
} |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Mylog.WriteLogFile("天气获取失败" + ex.ToString(), "JServiceErrorLog"); |
|||
} |
|||
return weather; |
|||
} |
|||
|
|||
public void SetPlayRecord() |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
|
|||
StringBuilder record = new StringBuilder(); |
|||
string fpath = Directory.GetCurrentDirectory() + "\\record\\"; |
|||
if (!Directory.Exists(fpath)) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
string fname = Directory.GetCurrentDirectory() + "\\record\\Record.txt"; |
|||
FileInfo finfo = new FileInfo(fname); |
|||
Mylog.WriteLogFile("文件地址" + fname, "UploadPlayRecord"); |
|||
if (!finfo.Exists) |
|||
{ |
|||
return; |
|||
} |
|||
else |
|||
{ |
|||
StreamReader sr = new StreamReader(fname, Encoding.Default); |
|||
String line; |
|||
while ((line = sr.ReadLine()) != null) |
|||
{ |
|||
record.Append(line.ToString()); |
|||
} |
|||
sr.Close(); |
|||
|
|||
if (!string.IsNullOrEmpty(record.ToString())) |
|||
{ |
|||
var array = JArray.Parse("[" + record + "]"); |
|||
//var list = Jo.Value<JArray>("data").ToObject<List<SubTitle>>();
|
|||
var data = new { DevCode = app.deviceid, List = array }; |
|||
Mylog.WriteLogFile("文件地址" + JsonConvert.SerializeObject(data), "UploadPlayRecord"); |
|||
string MethodStr = "/API/ProgramStatistics/UploadPlayRecord"; |
|||
var ret = MyHttpClient.CryptPost(MethodStr, data); |
|||
if (!string.IsNullOrEmpty(ret)) |
|||
{ |
|||
var Jo = JObject.Parse(ret); |
|||
string code = Jo.Value<string>("code"); |
|||
|
|||
if (code == "200") |
|||
{ |
|||
File.Delete(fname); |
|||
|
|||
} |
|||
else |
|||
{ |
|||
Mylog.WriteLogFile("上传节目播放统计错误" + ret, "UploadPlayRecordError"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
Mylog.WriteLogFile("上传节目播放统计错误" + e.ToString(), "UploadPlayRecordError"); |
|||
} |
|||
|
|||
} |
|||
public void GetSubTitle() |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
|
|||
string MethodStr = "/API/Subtitle/GetDevSubtitle"; |
|||
var data = new { Code = app.deviceid }; |
|||
var ret = MyHttpClient.CryptPost(MethodStr, data); |
|||
if (!string.IsNullOrEmpty(ret)) |
|||
{ |
|||
var Jo = JObject.Parse(ret); |
|||
string code = Jo.Value<string>("code"); |
|||
|
|||
if (code == "200") |
|||
{ |
|||
try |
|||
{ |
|||
List<SubTitle> itemList = Jo.Value<JArray>("data").ToObject<List<SubTitle>>(); |
|||
//Mylog.WriteLogFile("-data---" + JsonConvert.SerializeObject(Data), "Subtitle");
|
|||
//List<SubTitle> itemList = JsonConvert.DeserializeObject<>(Data);
|
|||
var groupList = itemList.GroupBy(i => i.location).Select(g => (new { Name = g.Key, List = g })).ToList(); |
|||
app.TopSubTitle.Clear(); |
|||
app.BottomSubTitle.Clear(); |
|||
foreach (var item in groupList) |
|||
{ |
|||
if (item.Name == "top") |
|||
{ |
|||
app.TopSubTitle = item.List.ToList(); |
|||
app.TopSubTitleIndex = 0; |
|||
} |
|||
else |
|||
{ |
|||
app.BottomSubTitle = item.List.ToList(); |
|||
app.BottomSubTitleIndex = 0; |
|||
} |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
app.TopSubTitle.Clear(); |
|||
app.BottomSubTitle.Clear(); |
|||
app.BottomSubTitleIndex = 0; |
|||
app.TopSubTitleIndex = 0; |
|||
Mylog.WriteLogFile("-----error----" + e.Message, "Subtitle"); |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
app.TopSubTitle.Clear(); |
|||
app.BottomSubTitle.Clear(); |
|||
app.BottomSubTitleIndex = 0; |
|||
app.TopSubTitleIndex = 0; |
|||
Mylog.WriteLogFile("-----error----" + e.Message, "Subtitle"); |
|||
} |
|||
} |
|||
|
|||
public void GetSyncDev() |
|||
{ |
|||
Class_Log log = new Class_Log(); |
|||
try |
|||
{ |
|||
log.WriteLogFile("获取", "GetSyncDev"); |
|||
string MethodStr = "/API/Dev/GetSyncDev"; |
|||
var data = new { Code = app.deviceid }; |
|||
var ret = MyHttpClient.CryptPost(MethodStr, data); |
|||
log.WriteLogFile(ret, "GetSyncDev"); |
|||
if (!string.IsNullOrEmpty(ret)) |
|||
{ |
|||
var Jo = JObject.Parse(ret); |
|||
string code = Jo.Value<string>("code"); |
|||
|
|||
if (code == "200") |
|||
{ |
|||
try |
|||
{ |
|||
var dicData = Jo.Value<JObject>("data"); |
|||
if (dicData != null) |
|||
{ |
|||
//app.deviceid = dicData["code"].ToString();
|
|||
string ip = dicData["ip"].ToString(); |
|||
log.WriteLogFile(ip, "GetSyncDev"); |
|||
log.WriteLogFile("------" + app.websocketProgramIP, "GetSyncDev"); |
|||
if (app.websocketProgramIP != ip) |
|||
{ |
|||
app.websocketProgramIP = ip; |
|||
if (app.isProgramServer) |
|||
{ |
|||
if (app.websocketForProgramServer == null) |
|||
{ |
|||
app.websocketForProgramServer = new WebsocketForProgramServer(); |
|||
} |
|||
app.websocketForProgramServer.CloasSocket(); |
|||
app.isProgramServer = false; |
|||
} |
|||
else |
|||
{ |
|||
string AddressIP = string.Empty; |
|||
foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList) |
|||
{ |
|||
if (_IPAddress.AddressFamily.ToString() == "InterNetwork") |
|||
{ |
|||
AddressIP = _IPAddress.ToString(); |
|||
} |
|||
} |
|||
if (AddressIP == ip) |
|||
{ |
|||
app.isProgramServer = true; |
|||
if (app.websocketForProgramServer == null) |
|||
{ |
|||
app.websocketForProgramServer = new WebsocketForProgramServer(); |
|||
} |
|||
app.websocketForProgramServer.openSocket(); |
|||
} |
|||
} |
|||
app.isProgramSync = false; |
|||
if (app.webSocketForProgram == null) |
|||
{ |
|||
app.webSocketForProgram = new WebSocketForProgram(); |
|||
} |
|||
app.webSocketForProgram.ReloadWebSocket(); |
|||
log.WriteLogFile("app.isProgramSync--" + app.isProgramSync, "GetSyncDev"); |
|||
} |
|||
else |
|||
{ |
|||
if (!app.isProgramSync) |
|||
{ |
|||
if (app.webSocketForProgram == null) |
|||
{ |
|||
app.webSocketForProgram = new WebSocketForProgram(); |
|||
} |
|||
app.webSocketForProgram.ReloadWebSocket(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
Mylog.WriteLogFile("-----error----" + e.Message, "GetSyncDevError"); |
|||
} |
|||
|
|||
} |
|||
else |
|||
{ |
|||
if (app.isProgramServer) |
|||
{ |
|||
if (app.websocketForProgramServer == null) |
|||
{ |
|||
app.websocketForProgramServer = new WebsocketForProgramServer(); |
|||
} |
|||
app.websocketForProgramServer.CloasSocket(); |
|||
app.isProgramServer = false; |
|||
} |
|||
if (app.isProgramSync) |
|||
{ |
|||
if (app.webSocketForProgram == null) |
|||
{ |
|||
app.webSocketForProgram = new WebSocketForProgram(); |
|||
} |
|||
app.webSocketForProgram.CloseWebSocket(); |
|||
app.isProgramSync = false; |
|||
} |
|||
|
|||
} |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile(e.ToString(), "GetSyncDevError"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,138 @@ |
|||
using Container.Common; |
|||
using Newtonsoft.Json; |
|||
using RabbitMQ.Client; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Windows; |
|||
|
|||
namespace Container.Business |
|||
{ |
|||
public class MqServer |
|||
{ |
|||
private static App app = ((App)Application.Current); |
|||
//public static RabbitConfig config;
|
|||
public static ConnectionFactory factory = new ConnectionFactory |
|||
{ |
|||
|
|||
UserName = app.rabbitMQ.UserName, |
|||
Password = app.rabbitMQ.Password, |
|||
HostName = app.rabbitMQ.HostName, |
|||
Port = app.rabbitMQ.Port, |
|||
}; |
|||
static IModel models = null; |
|||
private static Class_Log _log = new Class_Log(); |
|||
static string exchangeName = "topic"; |
|||
static string exchangeName_temp = "topic_immediately"; |
|||
public MqServer() |
|||
{ |
|||
Create(); |
|||
} |
|||
static public bool Create() |
|||
{ |
|||
|
|||
factory.AutomaticRecoveryEnabled = true; |
|||
//创建连接
|
|||
var conn = factory.CreateConnection(); |
|||
conn.CallbackException += Connetion_CallbackException; |
|||
conn.RecoverySucceeded += Connetion_RecoverySucceeded; |
|||
conn.ConnectionRecoveryError += Connetion_ConnectionRecoveryError; |
|||
conn.ConnectionBlocked += Connetion_ConnectionBlocked; |
|||
conn.ConnectionUnblocked += Connetion_ConnectionUnblocked; |
|||
//连接关闭的时候
|
|||
conn.ConnectionShutdown += Connetion_ConnectionShutdown; |
|||
{ |
|||
models = conn.CreateModel(); |
|||
|
|||
//声明持久消息队列
|
|||
models.ExchangeDeclare(exchangeName, "topic", true, false, null); |
|||
//声明即时消息队列
|
|||
models.ExchangeDeclare(exchangeName_temp, "topic", true, false, null); |
|||
//models.ExchangeDeclare("topic_temp", "topic", true, false, null);
|
|||
//models.QueueDelete();
|
|||
//models.QueueDeclare("deviceInfo", true, false, false, null);
|
|||
//Console.WriteLine("生产者启动成功");
|
|||
_log.WriteLogFile("Start-"+"消息中心启动成功", "MqServer"); |
|||
//for (int i = 0; i < 5; i++)
|
|||
//{
|
|||
// models.BasicPublish("message", "myRabbit", mandatory: true, null, Encoding.UTF8.GetBytes(i + ""));
|
|||
//}
|
|||
} |
|||
return true; |
|||
} |
|||
private static bool Publish(string Msg, string routingKey = "default", bool isDurable = false) |
|||
{ |
|||
try |
|||
{ |
|||
_log.WriteLogFile(routingKey); |
|||
_log.WriteLogFile(Msg); |
|||
models.BasicPublish(exchange: isDurable ? exchangeName : exchangeName_temp, routingKey: "device." + routingKey, mandatory: true, body: Encoding.UTF8.GetBytes(Msg)); |
|||
//Console.WriteLine("推送消息成功");
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
_log.WriteLogFile(routingKey+ex.Message, "MqServer"); |
|||
} |
|||
return true; |
|||
} |
|||
/// <summary>
|
|||
/// 发布消息
|
|||
/// </summary>
|
|||
/// <param name="module"></param>
|
|||
/// <param name="content"></param>
|
|||
/// <param name="Queue"></param>
|
|||
/// <param name="isDurable">是否持久化</param>
|
|||
/// <returns></returns>
|
|||
public static void PublishMessage(string module, object content, string[] Queue, bool isDurable = true) |
|||
{ |
|||
try |
|||
{ |
|||
string msg = JsonConvert.SerializeObject(new { content, module, MallCode = app.mallCode }); |
|||
if (Queue.Length == 0) |
|||
Publish(msg, isDurable: isDurable); |
|||
else |
|||
foreach (var item in Queue) |
|||
{ |
|||
Publish(msg, item, isDurable); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq--" + "PublishMessage"+ex.Message, "MqServer"); |
|||
} |
|||
} |
|||
|
|||
private static void Connetion_ConnectionShutdown(object sender, ShutdownEventArgs e) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq--"+ "Connetion_ConnectionShutdown", "MqServer"); |
|||
|
|||
} |
|||
|
|||
private static void Connetion_ConnectionUnblocked(object sender, EventArgs e) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq--" + "Connetion_ConnectionUnblocked", "MqServer"); |
|||
} |
|||
|
|||
private static void Connetion_ConnectionBlocked(object sender, RabbitMQ.Client.Events.ConnectionBlockedEventArgs e) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq--" + "Connetion_ConnectionBlocked", "MqServer"); |
|||
} |
|||
|
|||
private static void Connetion_ConnectionRecoveryError(object sender, RabbitMQ.Client.Events.ConnectionRecoveryErrorEventArgs e) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq--" + "Connetion_ConnectionRecoveryError", "MqServer"); |
|||
} |
|||
|
|||
private static void Connetion_RecoverySucceeded(object sender, EventArgs e) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq--" + "Connetion_RecoverySucceeded", "MqServer"); |
|||
} |
|||
|
|||
private static void Connetion_CallbackException(object sender, RabbitMQ.Client.Events.CallbackExceptionEventArgs e) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq--" + "Connetion_CallbackException", "MqServer"); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,626 @@ |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using Newtonsoft.Json.Linq; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using System.Windows; |
|||
using Transitionals; |
|||
|
|||
namespace Container.Business |
|||
{ |
|||
class OutLine |
|||
{ |
|||
App app = ((App)Application.Current); |
|||
private string outLinePath = Environment.CurrentDirectory + "/OutlineFiles"; |
|||
//private string localIP = ConfigurationManager.AppSettings["LocalIP"];
|
|||
//private string remoteAddress = ConfigurationManager.AppSettings["RemoteAddress"];
|
|||
private List<string> needDel = new List<string>(); |
|||
private List<string> needDownLoad = new List<string>(); |
|||
Class_Log log = new Class_Log(); |
|||
private static readonly object lockHelper = new object(); |
|||
private static OutLine OutLineInstance = null; |
|||
|
|||
private OutLine() |
|||
{ |
|||
} |
|||
|
|||
public static OutLine CreateInstance() |
|||
{ |
|||
if (OutLineInstance == null) |
|||
{ |
|||
lock (lockHelper) |
|||
{ |
|||
if (OutLineInstance == null) |
|||
{ |
|||
OutLineInstance = new OutLine(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return OutLineInstance; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 通过对比本地和网络数据来看是否需要下载或更改播单
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public void DownOutLineFiles(ScreenSavers resource) |
|||
{ |
|||
try |
|||
{ |
|||
if (resource == null) |
|||
return; |
|||
DirectoryInfo dir = new DirectoryInfo(outLinePath); |
|||
List<string> localFilesPath = new List<string>(); |
|||
List<string> remoteFilesPath = new List<string>(); |
|||
needDownLoad.Clear(); |
|||
needDel.Clear(); |
|||
|
|||
if (dir.Exists) |
|||
{ |
|||
FileInfo[] fiList = dir.GetFiles(); |
|||
foreach (var item in fiList) |
|||
{ |
|||
if (!Path.GetExtension(item.FullName).Contains("temp")) |
|||
{ |
|||
localFilesPath.Add(item.FullName); |
|||
} |
|||
} |
|||
|
|||
} |
|||
else |
|||
Directory.CreateDirectory(outLinePath); |
|||
|
|||
if (resource.ResList.Count > 0) |
|||
{ |
|||
foreach (var item in resource.ResList) |
|||
remoteFilesPath.Add(item.img); |
|||
|
|||
} |
|||
//else
|
|||
// return;
|
|||
|
|||
foreach (var item in remoteFilesPath) |
|||
{ |
|||
var httpPath = item.Substring(0, item.IndexOf("://") + 3); |
|||
var fileBackPath = item.Substring(item.IndexOf("://") + 3).Replace("//", "/").Replace("\\", "/"); |
|||
var file = httpPath + fileBackPath; |
|||
var names = file.Split('/'); |
|||
var fileName = file; |
|||
if (names.Length > 0) |
|||
{ |
|||
fileName = names[names.Length - 2]; |
|||
} |
|||
if (localFilesPath.FindAll(p => p.Contains(fileName)).Count <= 0) |
|||
{ |
|||
//if (!localFilesPath.Contains(fileName)) {
|
|||
needDownLoad.Add(item); |
|||
} |
|||
//if (localFilesPath.FindAll(p => p.EndsWith(Path.GetFileName(item))).Count <= 0)
|
|||
// needDownLoad.Add(item);
|
|||
} |
|||
|
|||
foreach (var item in localFilesPath) |
|||
{ |
|||
if (remoteFilesPath.FindAll(p => p.Contains(Path.GetFileNameWithoutExtension(item))).Count <= 0) |
|||
{ |
|||
needDel.Add(item); |
|||
} |
|||
//if (remoteFilesPath.FindAll(p => p.EndsWith(Path.GetFileName(item))).Count <= 0)
|
|||
// needDel.Add(item);
|
|||
} |
|||
if (needDel.Count > 1 || needDownLoad.Count > 0 || !File.Exists(Environment.CurrentDirectory + "/OutlineFiles" + "/temp.xml")) |
|||
DownLoadFiles(resource); |
|||
else |
|||
{ |
|||
if (resource.ResList.Count < 0) |
|||
return; |
|||
foreach (var item in resource.ResList) |
|||
{ |
|||
var httpPath = item.img.Substring(0, item.img.IndexOf("://") + 3); |
|||
var fileBackPath = item.img.Substring(item.img.IndexOf("://") + 3).Replace("//", "/").Replace("\\", "/"); |
|||
item.img = httpPath + fileBackPath; |
|||
log.WriteLogFile("原图片地址" + item.img, "image"); |
|||
if (item.img.Contains("/")) |
|||
{ |
|||
var names = item.img.Split('/'); |
|||
log.WriteLogFile("names个数" + names.Length, "image"); |
|||
if (names.Length > 0) |
|||
{ |
|||
item.img = outLinePath + "/" + names[names.Length - 2] + names[names.Length - 1].Substring(names[names.Length - 1].LastIndexOf('.')); |
|||
} |
|||
else |
|||
{ |
|||
item.img = outLinePath + item.img.Substring(item.img.LastIndexOf("/")); |
|||
} |
|||
log.WriteLogFile("下载后地址" + item.img, "image"); |
|||
} |
|||
|
|||
else |
|||
item.img = outLinePath + item.img; |
|||
} |
|||
|
|||
//string xmlPath = outLinePath + "/temp.xml";
|
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
////写入离线配置文件
|
|||
//using (Stream fs = new FileStream(xmlPath, FileMode.Create))
|
|||
//{
|
|||
// StreamWriter sw = new StreamWriter(fs);
|
|||
// sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource));
|
|||
// sw.Close();
|
|||
// fs.Close();
|
|||
//}
|
|||
|
|||
ScreenSavers result = new ScreenSavers(); |
|||
if (File.Exists(outLinePath + "/temp.xml")) |
|||
{ |
|||
using (StreamReader sr = new StreamReader(outLinePath + "/temp.xml")) |
|||
{ |
|||
result = CommonMethod.DeserializeXML<ScreenSavers>(sr.ReadToEnd()); |
|||
sr.Close(); |
|||
} |
|||
if (result != null) |
|||
{ |
|||
ScreenSavers result1 = new ScreenSavers(); |
|||
if (!result.Equals(resource)) |
|||
{ |
|||
string xmlPath = outLinePath + "/temp.xml"; |
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
//写入离线配置文件
|
|||
using (Stream fs = new FileStream(xmlPath, FileMode.Create)) |
|||
{ |
|||
StreamWriter sw = new StreamWriter(fs); |
|||
sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource)); |
|||
sw.Close(); |
|||
fs.Close(); |
|||
} |
|||
App.Downloaddone = true; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
string xmlPath = outLinePath + "/temp.xml"; |
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
//写入离线配置文件
|
|||
using (Stream fs = new FileStream(xmlPath, FileMode.Create)) |
|||
{ |
|||
StreamWriter sw = new StreamWriter(fs); |
|||
sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource)); |
|||
sw.Close(); |
|||
fs.Close(); |
|||
} |
|||
App.Downloaddone = true; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
string xmlPath = outLinePath + "/temp.xml"; |
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
//写入离线配置文件
|
|||
using (Stream fs = new FileStream(xmlPath, FileMode.Create)) |
|||
{ |
|||
StreamWriter sw = new StreamWriter(fs); |
|||
sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource)); |
|||
sw.Close(); |
|||
fs.Close(); |
|||
} |
|||
App.Downloaddone = true; |
|||
} |
|||
return; |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 通过对比本地和网络数据来看是否需要删除过期文件
|
|||
/// </summary>
|
|||
/// <param name="resource"></param>
|
|||
public void DeleteOutTimeFiles(ScreenSavers resource) |
|||
{ |
|||
try |
|||
{ |
|||
if (resource == null) |
|||
return; |
|||
DirectoryInfo dir = new DirectoryInfo(outLinePath); |
|||
List<string> localFilesPath = new List<string>(); |
|||
List<string> remoteFilesPath = new List<string>(); |
|||
needDel.Clear(); |
|||
|
|||
if (dir.Exists) |
|||
{ |
|||
FileInfo[] fiList = dir.GetFiles(); |
|||
foreach (var item in fiList) |
|||
{ |
|||
if (!Path.GetExtension(item.FullName).Contains("temp")) |
|||
{ |
|||
localFilesPath.Add(item.FullName); |
|||
} |
|||
} |
|||
|
|||
} |
|||
else |
|||
return; |
|||
|
|||
if (resource.ResList.Count > 0) |
|||
{ |
|||
foreach (var item in resource.ResList) |
|||
remoteFilesPath.Add(item.img); |
|||
} |
|||
else |
|||
return; |
|||
|
|||
foreach (var item in localFilesPath) |
|||
{ |
|||
if (remoteFilesPath.FindAll(p => p.Contains(Path.GetFileNameWithoutExtension(item))).Count <= 0) |
|||
{ |
|||
needDel.Add(item); |
|||
} |
|||
//if (remoteFilesPath.FindAll(p => p.EndsWith(Path.GetFileName(item))).Count <= 0)
|
|||
// needDel.Add(item);
|
|||
} |
|||
|
|||
//删除多余的文件
|
|||
if (needDel.Count > 1) |
|||
{ |
|||
for (int i = 0; i < needDel.Count; i++) |
|||
{ |
|||
try |
|||
{ |
|||
if (File.Exists(needDel[i]) && Path.GetFileName(needDel[i]) != "temp.xml") |
|||
File.Delete(needDel[i]); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取后台图片或视频资源地址
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public List<Tuple<ResInfo, Transition>> GetResource() |
|||
{ |
|||
try |
|||
{ |
|||
List<Tuple<ResInfo, Transition>> tpList = new List<Tuple<ResInfo, Transition>>(); |
|||
|
|||
while (!File.Exists(outLinePath + "/temp.xml"))//等待更新播放单
|
|||
{ |
|||
Thread.Sleep(200); |
|||
} |
|||
|
|||
ScreenSavers result = new ScreenSavers(); |
|||
using (StreamReader sr = new StreamReader(outLinePath + "/temp.xml")) |
|||
{ |
|||
//MessageBox.Show(sr.ReadToEnd());
|
|||
result = CommonMethod.DeserializeXML<ScreenSavers>(sr.ReadToEnd()); |
|||
sr.Close(); |
|||
} |
|||
var curDate = DateTime.Now; |
|||
var list = result.ResList.Where(i => !string.IsNullOrEmpty(i.img) && Convert.ToDateTime(i.launchtime) < curDate && Convert.ToDateTime(i.expirydate) > curDate.AddDays(-1)).ToList(); |
|||
if (list == null || list.Count == 0) |
|||
return tpList; |
|||
|
|||
foreach (var item in list) |
|||
{ |
|||
if (!string.IsNullOrEmpty(item.img)) |
|||
{ |
|||
Transition t = CommonMethod.GetTransition(item.effect); |
|||
Tuple<ResInfo, Transition> tp = new Tuple<ResInfo, Transition>(item, t); |
|||
tpList.Add(tp); |
|||
} |
|||
} |
|||
|
|||
return tpList; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
public List<ProgModel> LoadScreenConfig() |
|||
{ |
|||
string outLinePath = AppDomain.CurrentDomain.BaseDirectory + "/OutlineFiles"; |
|||
if (!Directory.Exists(outLinePath + "/Main")) |
|||
{ |
|||
return null; |
|||
} |
|||
else |
|||
{ |
|||
if (File.Exists(outLinePath + "/Main/screenconfig.txt")) |
|||
{ |
|||
string rev = DownLoadMethod.ReadContext(outLinePath + "/Main/screenconfig.txt"); |
|||
if (!string.IsNullOrEmpty(rev)) |
|||
{ |
|||
var Jo = JObject.Parse(rev); |
|||
string code = Jo.Value<string>("code"); |
|||
if (code == "200") |
|||
{ |
|||
List<ScheduleModel> itemList = Jo.Value<JArray>("data").ToObject<List<ScheduleModel>>(); |
|||
var Schedule = itemList.Where(i => i.date == DateTime.Now.ToString("yyyy-MM-dd")).FirstOrDefault(); |
|||
if (Schedule != null) |
|||
{ |
|||
return Schedule.schedule; |
|||
} |
|||
else |
|||
{ |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
else |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
return null; |
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 下载离线数据
|
|||
/// </summary>
|
|||
/// <param name="viewModel"></param>
|
|||
/// <returns></returns>
|
|||
bool done = false; |
|||
private bool DownLoadFiles(ScreenSavers resource) |
|||
{ |
|||
if (!done) |
|||
{ |
|||
done = true; |
|||
log.WriteLogFile("开始下载", "exelog"); |
|||
try |
|||
{ |
|||
if (needDownLoad.Count > 0) |
|||
{ |
|||
|
|||
//下载缺少的文件
|
|||
for (int i = 0; i < needDownLoad.Count; i++) |
|||
{ |
|||
log.WriteLogFile(needDownLoad[i], "downfile"); |
|||
try |
|||
{ |
|||
var httpPath = needDownLoad[i].Substring(0, needDownLoad[i].IndexOf("://") + 3); |
|||
var fileBackPath = needDownLoad[i].Substring(needDownLoad[i].IndexOf("://") + 3).Replace("//", "/").Replace("\\", "/"); |
|||
needDownLoad[i] = httpPath + fileBackPath; |
|||
string localFile = string.Empty; |
|||
if (needDownLoad[i].Contains("/")) |
|||
{ |
|||
var names = needDownLoad[i].Split('/'); |
|||
if (names.Length > 0) |
|||
{ |
|||
localFile = outLinePath + "/" + names[names.Length - 2] + names[names.Length - 1].Substring(names[names.Length - 1].LastIndexOf('.')); |
|||
} |
|||
else |
|||
{ |
|||
localFile = outLinePath + needDownLoad[i].Substring(needDownLoad[i].LastIndexOf("/")); |
|||
} |
|||
} |
|||
|
|||
else |
|||
localFile = outLinePath + needDownLoad[i]; |
|||
|
|||
if (!File.Exists(localFile))//&& !File.Exists(localFile + ".temp")
|
|||
{ |
|||
log.WriteLogFile("开始下载" + localFile, "exelog"); |
|||
if (File.Exists(localFile + ".temp")) |
|||
File.Delete(localFile + ".temp"); |
|||
using (Stream fileStream = new FileStream(localFile + ".temp", FileMode.OpenOrCreate)) |
|||
{ |
|||
try |
|||
{ |
|||
//fileStream.Seek(fileStream.Length, SeekOrigin.Current);
|
|||
//HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://" + app.HttpUrl + needDownLoad[i]);
|
|||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(needDownLoad[i]); |
|||
request.AddRange(fileStream.Length); |
|||
|
|||
HttpWebResponse respone = (HttpWebResponse)request.GetResponse(); |
|||
using (Stream netStream = respone.GetResponseStream()) |
|||
{ |
|||
long totalDownloadedByte = 0; |
|||
byte[] read = new byte[1024]; |
|||
int realReadLen = netStream.Read(read, 0, read.Length); |
|||
while (realReadLen > 0) |
|||
{ |
|||
totalDownloadedByte = realReadLen + totalDownloadedByte; |
|||
|
|||
fileStream.Write(read, 0, realReadLen); |
|||
realReadLen = netStream.Read(read, 0, read.Length); |
|||
|
|||
System.Windows.Forms.Application.DoEvents(); |
|||
} |
|||
netStream.Close(); |
|||
} |
|||
if (fileStream.Length != respone.ContentLength) |
|||
{ |
|||
log.WriteLogFile("文件未下载完毕", "文件"); |
|||
} |
|||
fileStream.Close(); |
|||
log.WriteLogFile("下载完成" + localFile, "exelog"); |
|||
File.Move(localFile + ".temp", localFile); |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile("下载失败" + localFile + ex.ToString(), "exelog"); |
|||
File.Delete(localFile + ".temp"); |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
done = false; |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
done = false; |
|||
//MessageBox.Show("http://" + remoteAddress + needDownLoad[i]+"文件下载失败"+ex.ToString());
|
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
|
|||
foreach (var item in resource.ResList) |
|||
{ |
|||
item.img = item.img.Replace("\\", "/"); |
|||
if (item.img.Contains("/")) |
|||
{ |
|||
var names = item.img.Split('/'); |
|||
if (names.Length > 0) |
|||
{ |
|||
item.img = outLinePath + "/" + names[names.Length - 2] + names[names.Length - 1].Substring(names[names.Length - 1].LastIndexOf('.')); |
|||
} |
|||
else |
|||
{ |
|||
item.img = outLinePath + item.img.Substring(item.img.LastIndexOf("/")); |
|||
} |
|||
} |
|||
|
|||
else |
|||
item.img = outLinePath + item.img; |
|||
//item.img = item.img.Replace("\\", "/");
|
|||
//if (item.img.Contains("/"))
|
|||
// item.img = outLinePath + item.img.Substring(item.img.LastIndexOf("/"));
|
|||
//else
|
|||
// item.img = outLinePath + item.img;
|
|||
} |
|||
if (resource.ResList.Count < 0) |
|||
{ |
|||
done = false; |
|||
return false; |
|||
} |
|||
//string xmlPath = outLinePath + "/temp.xml";
|
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
////写入离线配置文件
|
|||
//using (Stream fs = new FileStream(xmlPath, FileMode.Create))
|
|||
//{
|
|||
// StreamWriter sw = new StreamWriter(fs);
|
|||
// sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource));
|
|||
// sw.Close();
|
|||
// fs.Close();
|
|||
//}
|
|||
|
|||
ScreenSavers result = new ScreenSavers(); |
|||
if (File.Exists(outLinePath + "/temp.xml")) |
|||
{ |
|||
using (StreamReader sr = new StreamReader(outLinePath + "/temp.xml")) |
|||
{ |
|||
result = CommonMethod.DeserializeXML<ScreenSavers>(sr.ReadToEnd()); |
|||
sr.Close(); |
|||
} |
|||
ScreenSavers result1 = new ScreenSavers(); |
|||
if (result != null) |
|||
{ |
|||
if (!result.Equals(resource)) |
|||
{ |
|||
string xmlPath = outLinePath + "/temp.xml"; |
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
//写入离线配置文件
|
|||
using (Stream fs = new FileStream(xmlPath, FileMode.Create)) |
|||
{ |
|||
StreamWriter sw = new StreamWriter(fs); |
|||
sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource)); |
|||
sw.Close(); |
|||
fs.Close(); |
|||
} |
|||
App.Downloaddone = true; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
string xmlPath = outLinePath + "/temp.xml"; |
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
//写入离线配置文件
|
|||
using (Stream fs = new FileStream(xmlPath, FileMode.Create)) |
|||
{ |
|||
StreamWriter sw = new StreamWriter(fs); |
|||
sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource)); |
|||
sw.Close(); |
|||
fs.Close(); |
|||
} |
|||
App.Downloaddone = true; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
string xmlPath = outLinePath + "/temp.xml"; |
|||
//if (File.Exists(xmlPath))
|
|||
// File.Delete(xmlPath);
|
|||
|
|||
//写入离线配置文件
|
|||
using (Stream fs = new FileStream(xmlPath, FileMode.Create)) |
|||
{ |
|||
StreamWriter sw = new StreamWriter(fs); |
|||
sw.Write(CommonMethod.SerializeXML<ScreenSavers>(resource)); |
|||
sw.Close(); |
|||
fs.Close(); |
|||
} |
|||
App.Downloaddone = true; |
|||
} |
|||
done = false; |
|||
return true; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
|
|||
log.WriteLogFile(ex.ToString(), "OutLineLog"); |
|||
done = false; |
|||
return false; |
|||
} |
|||
finally |
|||
{ |
|||
done = false; |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,56 @@ |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using Transitionals; |
|||
|
|||
namespace Container.Business |
|||
{ |
|||
public class PlayBackManage |
|||
{ |
|||
private JService jService = new JService(); |
|||
private OutLine outLine = OutLine.CreateInstance(); |
|||
//private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|||
Class_Log log = new Class_Log(); |
|||
App app = ((App)System.Windows.Application.Current); |
|||
/// <summary>
|
|||
/// 获取后台图片或视频资源地址
|
|||
/// </summary
|
|||
/// <returns></returns>
|
|||
public List<ProgModel> GetResource() |
|||
{ |
|||
//Action ac = new Action(() =>//静默下载离线文件
|
|||
//{
|
|||
// log.WriteLogFile("GetResource()下载离线文件", "exelog");
|
|||
// bool flag= jService.GetOutLineResource();
|
|||
//});
|
|||
//ac.BeginInvoke(null, null);
|
|||
|
|||
return outLine.LoadScreenConfig(); |
|||
} |
|||
|
|||
public void DownResource() { |
|||
Action ac = new Action(() =>//静默下载离线文件
|
|||
{ |
|||
log.WriteLogFile("GetResource()下载离线文件", "exelog"); |
|||
app.isStartGetProg = true; |
|||
bool flag = jService.GetOutLineResource(); |
|||
}); |
|||
ac.BeginInvoke(null, null); |
|||
} |
|||
|
|||
|
|||
///// <summary>
|
|||
///// 获取屏保切换间隔
|
|||
///// </summary>
|
|||
///// <returns></returns>
|
|||
//public int GetInterval()
|
|||
//{
|
|||
// return jService.GetInterval();
|
|||
//}
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,432 @@ |
|||
using Container.Common; |
|||
using Container.Services; |
|||
using Newtonsoft.Json; |
|||
using RabbitMQ.Client; |
|||
using RabbitMQ.Client.Events; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
using System.Windows; |
|||
|
|||
|
|||
namespace Container.Business |
|||
{ |
|||
public class RabbitHostedService |
|||
{ |
|||
|
|||
private readonly IConnection connection; |
|||
private static App app = ((App)Application.Current); |
|||
private readonly IModel channel; |
|||
static Class_Log _log = new Class_Log(); |
|||
public delegate void WebSocketReceiveDelegate(string type, string message); |
|||
public static event WebSocketReceiveDelegate WebSocketReceiveEvent; |
|||
private HttpClient httpclient = new HttpClient(); |
|||
private Class_Config con = new Class_Config(); |
|||
public RabbitHostedService() |
|||
{ |
|||
try |
|||
{ |
|||
var factory = new ConnectionFactory() |
|||
{ |
|||
UserName = app.rabbitMQ.UserName, |
|||
Password = app.rabbitMQ.Password, |
|||
HostName = app.rabbitMQ.HostName, |
|||
Port = app.rabbitMQ.Port, |
|||
}; |
|||
this.connection = factory.CreateConnection(); |
|||
this.channel = connection.CreateModel(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
//Console.WriteLine($"RabbitListener init error,ex:{ex.Message}");
|
|||
_log.WriteLogFile("rabbitMq"+"init error:" + ex.Message, "RabbitHosted"); |
|||
} |
|||
} |
|||
|
|||
public Task StartAsync(CancellationToken cancellationToken) |
|||
{ |
|||
Register(); |
|||
return Task.CompletedTask; |
|||
} |
|||
|
|||
|
|||
// 注册消费者监听在这里
|
|||
public void Register() |
|||
{ |
|||
//Console.WriteLine($"RabbitListener register,routeKey:{RouteKey}");
|
|||
if (string.IsNullOrEmpty(app.deviceid)) |
|||
{ |
|||
_log.WriteLogFile("rabbitMq"+ "设备未注册", "RabbitHosted"); |
|||
return; |
|||
} |
|||
_log.WriteLogFile("rabbitMq"+ "已连接连接到服务器", "RabbitHosted"); |
|||
//交换机名称
|
|||
String exchangeName = "topic_immediately"; |
|||
//声明交换机
|
|||
//channel.ExchangeDeclare(exchange: exchangeName, type: "topic", durable: true);
|
|||
//channel.ExchangeDeclare(exchange: "topic.default", type: "topic", durable: true);
|
|||
//消息队列名称
|
|||
String queueName = "device."+ app.deviceid; |
|||
//声明队列
|
|||
channel.QueueDeclare(queue: queueName, durable: false, exclusive: false, autoDelete: true, arguments: null); |
|||
//将队列与交换机进行绑定
|
|||
//foreach (var routeKey in args)
|
|||
//{//匹配多个路由
|
|||
// channel.QueueBind(queue: queueName, exchange: exchangeName, routingKey: routeKey);
|
|||
//}
|
|||
//channel.QueueBind(queue: queueName, exchange: "topic.default", routingKey: "");
|
|||
channel.QueueBind(queue: queueName, exchange: exchangeName, routingKey: queueName); |
|||
//声明为手动确认
|
|||
channel.BasicQos(0, 1, false); |
|||
//定义消费者
|
|||
var consumer = new EventingBasicConsumer(channel); |
|||
consumer.Received += (model, ea) => |
|||
{ |
|||
var body = ea.Body; |
|||
var message = Encoding.UTF8.GetString(body); |
|||
var result = Process(message); |
|||
if (result) |
|||
{ |
|||
channel.BasicAck(ea.DeliveryTag, false); |
|||
} |
|||
}; |
|||
//开启监听
|
|||
channel.BasicConsume(queue: queueName, autoAck: false, consumer: consumer); |
|||
} |
|||
|
|||
// 处理消息的方法
|
|||
public virtual bool Process(string msg) |
|||
{ |
|||
try |
|||
{ |
|||
string type = ""; |
|||
_log.WriteLogFile(msg,"rabbit"); |
|||
Dictionary<string, Object> diccontent = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, Object>>(msg.ToLower()); |
|||
if (diccontent["content"] != null) |
|||
{ |
|||
Dictionary<string, Object> dic = JsonConvert.DeserializeObject<Dictionary<string, Object>>(diccontent["content"].ToString()); |
|||
if (dic["content"] != null && dic["senderid"] != null) |
|||
{ |
|||
Dictionary<string, Object> Commands = JsonConvert.DeserializeObject<Dictionary<string, Object>>(dic["content"].ToString()); |
|||
|
|||
if (!string.IsNullOrEmpty(Commands["type"].ToString())) |
|||
{ |
|||
type = Commands["type"].ToString(); |
|||
} |
|||
if (type.Trim().Equals("apppublish")) |
|||
{ |
|||
AppListModel model = new AppListModel(); |
|||
model.AppID = string.IsNullOrEmpty(Commands["appid"].ToString()) ? "" : Commands["appid"].ToString(); |
|||
model.AppType = string.IsNullOrEmpty(Commands["apptype"].ToString()) ? "" : Commands["apptype"].ToString(); |
|||
|
|||
//model.AppUrl = string.IsNullOrEmpty(Commands["appurl"].ToString()) ? "" : Commands["appurl"].ToString();
|
|||
model.Code = string.IsNullOrEmpty(Commands["code"].ToString()) ? "" : Commands["code"].ToString(); |
|||
model.Logo = string.IsNullOrEmpty(Commands["logo"].ToString()) ? "" : Commands["logo"].ToString(); |
|||
model.Name = string.IsNullOrEmpty(Commands["name"].ToString()) ? "" : Commands["name"].ToString(); |
|||
model.ShelfTime = (Commands["shelftime"] == null || string.IsNullOrEmpty(Commands["shelftime"].ToString())) ? "" : Commands["shelftime"].ToString(); |
|||
model.Default = string.IsNullOrEmpty(Commands["default"].ToString()) ? "false" : Commands["default"].ToString(); |
|||
model.File = Commands["file"]==null ? "" : Commands["file"].ToString(); |
|||
model.PackageName = Commands["packagename"]==null ? "" : Commands["packagename"].ToString(); |
|||
model.PlatformType = Commands["platformtype"]==null ? "" : Commands["platformtype"].ToString(); |
|||
model.Startup = Commands["startup"]==null ? "" : Commands["startup"].ToString(); |
|||
model.Version = Commands["version"]==null ? "" : Commands["version"].ToString(); |
|||
bool flag = httpclient.DownLoadIcon(ref model.Logo); |
|||
if (!string.IsNullOrEmpty(model.File)) |
|||
{ |
|||
httpclient.DownLoadFiles(model.File, ref model.File); |
|||
} |
|||
if (!string.IsNullOrEmpty(model.Startup) && (model.Startup.ToLower().StartsWith("https://") || model.Startup.ToLower().StartsWith("http://"))) |
|||
{ |
|||
model.Startup = _log.WriteAppStart(model.Name, model.Startup); |
|||
} |
|||
con.WriteToExeConfig(model); |
|||
app.AppList.Add(model); |
|||
//_log.WriteLogFile("发布应用", "WebSocketLog");
|
|||
//app.AppUpdate = false;
|
|||
//if (!string.IsNullOrEmpty(Commands["appname"].ToString()))
|
|||
//{
|
|||
// app.appName = Commands["appname"].ToString();
|
|||
// app.Appdowninfo.exename = Commands["appname"].ToString();
|
|||
//}
|
|||
//if (!string.IsNullOrEmpty(Commands["filepath"].ToString()))
|
|||
//{
|
|||
// app.appUrl = Commands["filepath"].ToString();
|
|||
|
|||
//}
|
|||
//if (!string.IsNullOrEmpty(Commands["appnameen"].ToString()))
|
|||
//{
|
|||
// app.Appdowninfo.exestartname = Commands["appnameen"].ToString();
|
|||
//}
|
|||
//if (!string.IsNullOrEmpty(Commands["iconfilepath"].ToString()))
|
|||
//{
|
|||
// app.icourl = Commands["iconfilepath"].ToString();
|
|||
//}
|
|||
//if (!string.IsNullOrEmpty(Commands["appid"].ToString()))
|
|||
//{
|
|||
// app.Appdowninfo.AppID = Commands["appid"].ToString();
|
|||
//}
|
|||
//if (!string.IsNullOrEmpty(Commands["version"].ToString()))
|
|||
//{
|
|||
// app.Appdowninfo.Version = Commands["version"].ToString();
|
|||
//}
|
|||
//if (!string.IsNullOrEmpty(Commands["default"].ToString()))
|
|||
//{
|
|||
// app.Appdowninfo.Default = Convert.ToBoolean(Commands["default"]);
|
|||
//}
|
|||
} |
|||
else if (type.Trim().Equals("cloud-screenshot")) |
|||
{ |
|||
app.screenshotUserName = string.IsNullOrEmpty(Commands["parameter"].ToString()) ? "" : Commands["parameter"].ToString(); |
|||
} |
|||
else if (type.Trim().Equals("appdown")) |
|||
{ |
|||
var code = Commands["code"].ToString(); |
|||
var defaultCode= Commands["defaultapp"].ToString(); |
|||
if (!string.IsNullOrEmpty(code)) |
|||
{ |
|||
var appmodel = app.AppList.Where(i => i.Code == code).FirstOrDefault(); |
|||
var appList = app.AppList; |
|||
app.AppList.Remove(appmodel); |
|||
foreach (var item in app.AppList) |
|||
{ |
|||
if (item.Code == defaultCode) { |
|||
item.Default = Boolean.TrueString; |
|||
} |
|||
|
|||
} |
|||
//con.RemoveExeConfig(appmodel.Code, ref appmodel.File, ref appmodel.Logo, ref appmodel.Startup);
|
|||
//if (!string.IsNullOrEmpty(appmodel.File) && Directory.Exists(appmodel.File))
|
|||
//{
|
|||
// Directory.Delete(appmodel.File);
|
|||
//}
|
|||
|
|||
//if (!string.IsNullOrEmpty(appmodel.Logo) && File.Exists(appmodel.Logo))
|
|||
//{
|
|||
// File.Delete(appmodel.Logo);
|
|||
//}
|
|||
|
|||
//if (!string.IsNullOrEmpty(appmodel.Logo) && File.Exists(appmodel.Startup))
|
|||
//{
|
|||
// File.Delete(appmodel.Startup);
|
|||
//}
|
|||
var nowTimeSlot = app.AppTimeList.Where(i => i.AppCode != code&&i.AppCode!=defaultCode).ToList(); |
|||
if (nowTimeSlot.Count < app.AppTimeList.Count) { |
|||
app.AppTimeList = nowTimeSlot; |
|||
con.WriteToAppTimeConfig(app.AppTimeList); |
|||
} |
|||
} |
|||
//app.AppDownCode = "";
|
|||
//app.DefaultAppCode = "";
|
|||
//if (!string.IsNullOrEmpty(Commands["appid"].ToString()))
|
|||
//{
|
|||
// app.AppDownCode = Commands["appid"].ToString();
|
|||
//}
|
|||
//if (!string.IsNullOrEmpty(Commands["defaultappcode"].ToString()))
|
|||
//{
|
|||
// app.DefaultAppCode = Commands["defaultappcode"].ToString();
|
|||
//}
|
|||
} |
|||
else if (type.Trim().Equals("apptimeset")) |
|||
{ |
|||
HttpMessage httpMessage = new HttpMessage(); |
|||
httpMessage.LoadAppTimeConfig(); |
|||
//app.DefaultAppCode = "";
|
|||
//if (!string.IsNullOrEmpty(Commands["defaultappcode"].ToString()))
|
|||
//{
|
|||
// app.DefaultAppCode = Commands["defaultappcode"].ToString();
|
|||
//}
|
|||
} |
|||
else if (type.Trim().Equals("appupdate")) |
|||
{ |
|||
AppListModel model = new AppListModel(); |
|||
model.AppID = string.IsNullOrEmpty(Commands["appid"].ToString()) ? "" : Commands["appid"].ToString(); |
|||
model.AppType = string.IsNullOrEmpty(Commands["apptype"].ToString()) ? "" : Commands["apptype"].ToString(); |
|||
|
|||
//model.AppUrl = string.IsNullOrEmpty(Commands["appurl"].ToString()) ? "" : Commands["appurl"].ToString();
|
|||
model.Code = string.IsNullOrEmpty(Commands["code"].ToString()) ? "" : Commands["code"].ToString(); |
|||
model.Logo = string.IsNullOrEmpty(Commands["logo"].ToString()) ? "" : Commands["logo"].ToString(); |
|||
model.Name = string.IsNullOrEmpty(Commands["name"].ToString()) ? "" : Commands["name"].ToString(); |
|||
model.ShelfTime = (Commands["shelftime"] == null || string.IsNullOrEmpty(Commands["shelftime"].ToString())) ? "" : Commands["shelftime"].ToString(); |
|||
model.Default = string.IsNullOrEmpty(Commands["default"].ToString()) ? "false" : Commands["default"].ToString(); |
|||
model.File = Commands["file"] == null ? "" : Commands["file"].ToString(); |
|||
model.PackageName = Commands["packagename"] == null ? "" : Commands["packagename"].ToString(); |
|||
model.PlatformType = Commands["platformtype"] == null ? "" : Commands["platformtype"].ToString(); |
|||
model.Startup = Commands["startup"] == null ? "" : Commands["startup"].ToString(); |
|||
model.Version = Commands["version"] == null ? "" : Commands["version"].ToString(); |
|||
bool flag = httpclient.DownLoadIcon(ref model.Logo); |
|||
var appModel = app.AppList.Where(i => i.Code == model.Code).FirstOrDefault(); |
|||
if ((appModel == null || appModel.Version != model.Version) && !string.IsNullOrEmpty(model.File)) |
|||
{ |
|||
httpclient.DownLoadFiles(model.File, ref model.File); |
|||
} |
|||
if (!string.IsNullOrEmpty(model.Startup) && (model.Startup.ToLower().StartsWith("https://") || model.Startup.ToLower().StartsWith("http://"))) |
|||
{ |
|||
model.Startup = _log.WriteAppStart(model.Name, model.Startup); |
|||
} |
|||
con.WriteToExeConfig(model); |
|||
foreach (var item in app.AppList) |
|||
{ |
|||
if (item.Code == model.Code) { |
|||
item.AppID = model.AppID; |
|||
item.AppType = model.AppType; |
|||
item.Default = model.Default; |
|||
item.File = model.File; |
|||
item.Logo = model.Logo; |
|||
item.Name = model.Name; |
|||
item.PackageName = model.PackageName; |
|||
item.PlatformType = model.PlatformType; |
|||
item.ShelfTime = model.ShelfTime; |
|||
item.Startup = model.Startup; |
|||
item.Version = model.Version; |
|||
} |
|||
} |
|||
} |
|||
else if (type.Trim().Equals("appclock")) |
|||
{ |
|||
//if (!string.IsNullOrEmpty(Commands["data"].ToString()))
|
|||
//{
|
|||
// Dictionary<string, Object> data = JsonConvert.DeserializeObject<Dictionary<string, Object>>(Commands["data"].ToString());
|
|||
// if (!string.IsNullOrEmpty(data["startapp"].ToString()))
|
|||
// {
|
|||
// Dictionary<string, string> startapp = JsonConvert.DeserializeObject<Dictionary<string, string>>(data["startapp"].ToString());
|
|||
// if (!string.IsNullOrEmpty(startapp["filename"].ToString()))
|
|||
// {
|
|||
// app.AppPlayDir = startapp["filename"].ToString();
|
|||
// app.AppStartinfo.exepath = startapp["appnameen"].ToString();
|
|||
|
|||
// if (!string.IsNullOrEmpty(startapp["appnameen"].ToString()))
|
|||
// {
|
|||
// //app.AppPlayName = startapp["appnameen"].ToString();
|
|||
// app.AppStartinfo.exestartname = startapp["appnameen"].ToString();
|
|||
// }
|
|||
|
|||
// if (!string.IsNullOrEmpty(startapp["appid"].ToString()))
|
|||
// {
|
|||
// app.AppStartinfo.AppID = startapp["appid"].ToString();
|
|||
// }
|
|||
// if (!string.IsNullOrEmpty(startapp["appname"].ToString()))
|
|||
// {
|
|||
// app.AppStartinfo.exename = startapp["appname"].ToString();
|
|||
// }
|
|||
// }
|
|||
// else
|
|||
// {
|
|||
// if (!string.IsNullOrEmpty(data["endapp"].ToString()))
|
|||
// {
|
|||
// Dictionary<string, string> endapp = JsonConvert.DeserializeObject<Dictionary<string, string>>(data["endapp"].ToString());
|
|||
// if (!string.IsNullOrEmpty(endapp["name"].ToString()))
|
|||
// {
|
|||
// app.AppStartinfo.exename = "";
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
|
|||
//}
|
|||
} |
|||
else if (type.Trim().Equals("insertad")) |
|||
{ |
|||
//if (!string.IsNullOrEmpty(Commands["data"].ToString()))
|
|||
//{
|
|||
// Dictionary<string, Object> data = JsonConvert.DeserializeObject<Dictionary<string, Object>>(Commands["data"].ToString());
|
|||
// if (!string.IsNullOrEmpty(data["filepath"].ToString()))
|
|||
// {
|
|||
// //Dictionary<string, string> admodel = JsonConvert.DeserializeObject<Dictionary<string, string>>(data["admodel"].ToString());
|
|||
// //if (!string.IsNullOrEmpty(data["filepath"].ToString()))
|
|||
// //{
|
|||
// app.insertAD.Duration = Convert.ToInt32(data["duration"]);
|
|||
// app.insertAD.FilePath = data["filepath"].ToString();
|
|||
// //}
|
|||
// }
|
|||
|
|||
//}
|
|||
} |
|||
else if (type.Trim().Equals("addown")) |
|||
{ |
|||
//app.insertAD.Duration = 0;
|
|||
//app.insertAD.FilePath = "";
|
|||
} |
|||
else if (type.Trim().Equals("devnumedit")) |
|||
{ |
|||
if (!string.IsNullOrEmpty(Commands["devnum"].ToString())) |
|||
{ |
|||
app.devicemark = Commands["devnum"].ToString(); |
|||
} |
|||
} |
|||
else if (type.Trim().Equals("bgset")) |
|||
{ |
|||
if (!string.IsNullOrEmpty(Commands["filepath"].ToString())) |
|||
{ |
|||
app.bgPath = Commands["filepath"].ToString(); |
|||
} |
|||
} |
|||
else if (type.Trim().Equals("screensaver")) |
|||
{ |
|||
app.screensaver.ScreenTime = 30; |
|||
if (!string.IsNullOrEmpty(Commands["time"].ToString())) |
|||
{ |
|||
app.screensaver.ScreenTime = Convert.ToInt32(Commands["time"]); |
|||
} |
|||
string fileName = string.Empty; |
|||
if (!string.IsNullOrEmpty(Commands["screenfilepath"].ToString())) |
|||
{ |
|||
string path = Commands["screenfilepath"].ToString(); |
|||
if (!string.IsNullOrEmpty(path)) |
|||
{ |
|||
httpclient.DownLoadImage(path, "exefile/PCScreen/config", ref fileName); |
|||
} |
|||
} |
|||
Class_Config config = new Class_Config(); |
|||
string screentype = "0"; |
|||
if (!string.IsNullOrEmpty(Commands["screentype"].ToString())) |
|||
{ |
|||
screentype = Commands["screentype"].ToString(); |
|||
} |
|||
|
|||
string screeneffect = "0"; |
|||
if (!string.IsNullOrEmpty(Commands["screeneffect"].ToString())) |
|||
{ |
|||
screeneffect = Commands["screeneffect"].ToString(); |
|||
} |
|||
|
|||
string effecttype = "0"; |
|||
if (!string.IsNullOrEmpty(Commands["effecttype"].ToString())) |
|||
{ |
|||
effecttype = Commands["effecttype"].ToString(); |
|||
} |
|||
config.WriteToScreenConfig(screentype, screeneffect, fileName, effecttype); |
|||
} |
|||
else if (type.Trim().Equals("shutdowntime")) |
|||
{ |
|||
app.shutdowntime = Commands["parameter"].ToString(); |
|||
} |
|||
} |
|||
} |
|||
if (WebSocketReceiveEvent != null) |
|||
{ |
|||
WebSocketReceiveEvent(type, ""); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
_log.WriteLogFile(ex.ToString(), "WebSocketLog"); |
|||
|
|||
} |
|||
return true; |
|||
} |
|||
|
|||
public void DeRegister() |
|||
{ |
|||
this.connection.Close(); |
|||
} |
|||
public Task StopAsync(CancellationToken cancellationToken) |
|||
{ |
|||
this.connection.Close(); |
|||
return Task.CompletedTask; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,11 @@ |
|||
<Window x:Class="Container.ChildWindows.BGPage" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:local="clr-namespace:Container.ChildWindows" |
|||
Title="BGPage" Top="0" Left="0" Loaded="BGPage_Load" WindowStyle="None" ResizeMode="NoResize"> |
|||
<Canvas x:Name="bgPage"> |
|||
|
|||
</Canvas> |
|||
</Window> |
|||
@ -0,0 +1,91 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
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.Shapes; |
|||
using Container.Common; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// BGPage.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class BGPage : Window |
|||
{ |
|||
Class_Log log = new Class_Log(); |
|||
App app = ((App)System.Windows.Application.Current); |
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern IntPtr FindWindow(string IpClassName, string IpWindowName); |
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uflags); |
|||
|
|||
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); //窗体置顶
|
|||
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); //取消窗体置顶
|
|||
public static readonly IntPtr HWND_BOTTOM = new IntPtr(1); //取消窗体置顶
|
|||
public const uint SWP_NOMOVE = 0x0002; //不调整窗体位置
|
|||
public const uint SWP_NOSIZE = 0x0001; //不调整窗体大小
|
|||
public BGPage() |
|||
{ |
|||
InitializeComponent(); |
|||
|
|||
} |
|||
|
|||
public void LoadImage(string pageUrl) { |
|||
if (string.IsNullOrEmpty(pageUrl)) { |
|||
this.Width = 0; |
|||
this.Height = 0; |
|||
this.bgPage.Width = 0; |
|||
this.bgPage.Height = 0; |
|||
|
|||
this.WindowState = WindowState.Minimized; |
|||
} |
|||
else |
|||
{ |
|||
this.Width = app.ScreenWidth; |
|||
this.Height = app.ScreenHeight; |
|||
this.bgPage.Width = app.ScreenWidth; |
|||
this.bgPage.Height = app.ScreenHeight; |
|||
this.WindowState = WindowState.Maximized; |
|||
if (File.Exists(pageUrl) == true) |
|||
{ |
|||
|
|||
Uri uri = new Uri(pageUrl, UriKind.Absolute); |
|||
ImageBrush ib = new ImageBrush(); |
|||
ib.ImageSource = new BitmapImage(uri); |
|||
this.bgPage.Background = ib; |
|||
} |
|||
} |
|||
IntPtr WinMain = FindWindow(null, "MainWindow"); //Win_h5Page是我的程序中需要置顶的窗体的名字
|
|||
if (WinMain != null) |
|||
{ |
|||
SetWindowPos(WinMain, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
|||
|
|||
} |
|||
IntPtr Win = FindWindow(null, "BGPage"); //Win_h5Page是我的程序中需要置顶的窗体的名字
|
|||
if (Win != null) |
|||
{ |
|||
SetWindowPos(Win, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
|||
|
|||
} |
|||
} |
|||
|
|||
private void BGPage_Load(object sender, RoutedEventArgs e) |
|||
{ |
|||
|
|||
|
|||
//log.WriteLogFile("信发是否启用:" + pcstart.ToString());
|
|||
// IntPtr Win = FindWindow(null, "ADInsert"); //取消置顶
|
|||
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,74 @@ |
|||
<Window x:Class="Container.ChildWindows.GetUrl" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
Title="设备信息" Height="500" Width="400" Topmost="True" Loaded="Services_Loaded" Closed="Win_Closed" WindowStyle="None" AllowsTransparency="True"> |
|||
|
|||
<Canvas x:Name="Mainp"> |
|||
<Canvas x:Name="deviceinfo" Visibility="Visible" Height="500" Width="400" > |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/background.jpg"/> |
|||
</Canvas.Background> |
|||
<TextBox x:Name="Text_RegKey" FontSize="12" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="237" Height="39" Canvas.Left="127" Canvas.Top="83" BorderThickness="0" Background="White"/> |
|||
<Label x:Name="Label_RegKey" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="商场激活码" Canvas.Top="92" Canvas.Left="54"/> |
|||
|
|||
|
|||
|
|||
<!--<TextBox x:Name="Text_HttpUrl" FontSize="12" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="237" Height="39" Canvas.Left="127" Canvas.Top="148" BorderThickness="0" Background="White"/>--> |
|||
<!--<Label x:Name="Label_WsUrl" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="Http地址" Canvas.Top="157" Canvas.Left="64"/>--> |
|||
|
|||
<!--<TextBox x:Name="Text_WsUrl" FontSize="12" Foreground="Black" Background="White" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="237" Height="39" Canvas.Top="203" Canvas.Left="127" BorderThickness="0"/>--> |
|||
|
|||
<!--<Label x:Name="Label_ExePath" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="Websocket地址" Canvas.Top="212" Canvas.Left="26"/>--> |
|||
<Label x:Name="Label_HttpUrl" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="应用程序路径" Canvas.Top="157" Canvas.Left="40"/> |
|||
<TextBox x:Name="Text_ExePath" FontSize="12" GotFocus="ExeFile_Click" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="237" Height="39" Canvas.Top="148" Canvas.Left="127" BorderThickness="0"> |
|||
<TextBox.Resources> |
|||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="1" Stretch="None" AlignmentX="Left"> |
|||
<VisualBrush.Visual> |
|||
<TextBox Width="237" Height="39" BorderThickness="0" Foreground="#C0C0C0" Background="White" FontSize="10" VerticalContentAlignment="Center" VerticalAlignment="Center" Text="可选" /> |
|||
</VisualBrush.Visual> |
|||
</VisualBrush> |
|||
</TextBox.Resources> |
|||
<TextBox.Style> |
|||
<Style TargetType="TextBox"> |
|||
<Style.Triggers> |
|||
<Trigger Property="Text" Value="{x:Null}"> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
<Trigger Property="Text" Value=""> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</TextBox.Style> |
|||
</TextBox> |
|||
|
|||
<Label x:Name="lab_msg" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Foreground="Red" Content="Label" Visibility="Hidden" Canvas.Top="209" Width="400" Height="27"/> |
|||
|
|||
|
|||
<Button x:Name="ButtonOK" Canvas.Left="154" Canvas.Top="261" Width="91" Height="27" Click="Button_Click"> |
|||
<Button.Style> |
|||
<Style TargetType="{x:Type Button}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Button}"> |
|||
<Canvas Name="cvs" Background="Transparent" Canvas.Top="351" Width="91" Height="27"> |
|||
<Image Name="Img" Source="../image/Btn_OK.jpg" Height="27" Width="91"/> |
|||
<TextBlock Name="tbSale" FontWeight="Bold" Foreground="Transparent" Width="91" Canvas.Top="7" FontFamily="HYQiHei" Height="27" FontSize="15" TextAlignment="Center" Text="完成"></TextBlock> |
|||
</Canvas> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsPressed" Value="True"> |
|||
<Setter Property="Background" Value="#b6b6b6" TargetName="cvs" /> |
|||
<Setter Property="Foreground" Value="White" TargetName="tbSale" /> |
|||
<Setter Property="Visibility" Value="Hidden" TargetName="Img" /> |
|||
|
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</Button.Style> |
|||
</Button> |
|||
</Canvas> |
|||
</Canvas> |
|||
</Window> |
|||
@ -0,0 +1,190 @@ |
|||
using Container.Common; |
|||
using Container.Services; |
|||
using Microsoft.Win32; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
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.Shapes; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// GetUrl.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class GetUrl : Window |
|||
{ |
|||
App app = ((App)System.Windows.Application.Current); |
|||
Class_Config config = new Class_Config(); |
|||
Class_Log log = new Class_Log(); |
|||
public GetUrl() |
|||
{ |
|||
InitializeComponent(); |
|||
this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; |
|||
} |
|||
|
|||
private void Button_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
lab_msg.Visibility = System.Windows.Visibility.Hidden; |
|||
if (string.IsNullOrEmpty(this.Text_RegKey.Text)) |
|||
{ |
|||
lab_msg.Content = "请填写商场激活码。"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
//if (string.IsNullOrEmpty(this.Text_HttpUrl.Text))
|
|||
//{
|
|||
// lab_msg.Content = "请填写Http地址。";
|
|||
// lab_msg.Visibility = System.Windows.Visibility.Visible;
|
|||
// return;
|
|||
//}
|
|||
//if (string.IsNullOrEmpty(this.Text_WsUrl.Text))
|
|||
//{
|
|||
// lab_msg.Content = "请填写Websocket地址。";
|
|||
// lab_msg.Visibility = System.Windows.Visibility.Visible;
|
|||
// return;
|
|||
//}
|
|||
if (string.IsNullOrEmpty(this.Text_ExePath.Text)) |
|||
{ |
|||
//if (MessageBox.Show("确认不填写应用程序路径?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.No)
|
|||
//{
|
|||
// lab_msg.Content = "请填写应用程序路径。";
|
|||
// lab_msg.Visibility = System.Windows.Visibility.Visible;
|
|||
// return;
|
|||
//}
|
|||
} |
|||
|
|||
else if (!File.Exists(this.Text_ExePath.Text.ToString()) && !this.Text_ExePath.Text.ToString().Contains("http")) |
|||
{ |
|||
lab_msg.Content = "未找到应用程序,请确认路径是否正确。"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
app.mallRegKey = this.Text_RegKey.Text.ToString(); |
|||
//app.configurl = this.Text_HttpUrl.Text.ToString();
|
|||
//app.HttpUrl = this.Text_HttpUrl.Text.ToString();
|
|||
//app.configwebsocket = this.Text_WsUrl.Text.ToString();
|
|||
app.configstartexe = this.Text_ExePath.Text.ToString(); |
|||
HttpMessage httpclient = new HttpMessage(); |
|||
string Errorlog = string.Empty; |
|||
string mallCode = string.Empty; |
|||
var flag = httpclient.CheckMallRegKey(app.mallRegKey, ref mallCode, ref Errorlog); |
|||
if (!flag) |
|||
{ |
|||
lab_msg.Content = Errorlog; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
} |
|||
else |
|||
{ |
|||
lab_msg.Visibility = System.Windows.Visibility.Hidden; |
|||
app.mallCode = mallCode; |
|||
config.WriteToInitialConfig(); |
|||
ServiceInfo info = new ServiceInfo(); |
|||
this.ButtonOK.Visibility = System.Windows.Visibility.Hidden; |
|||
info.ShowDialog(); |
|||
if (info.DialogResult == true) |
|||
{ |
|||
this.DialogResult = info.DialogResult; |
|||
} |
|||
else |
|||
{ |
|||
this.ButtonOK.Visibility = System.Windows.Visibility.Visible; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "GetUrlErrorLog"); |
|||
} |
|||
} |
|||
|
|||
private void Services_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
//this.Text_HttpUrl.Text = app.HttpUrl;
|
|||
this.Text_RegKey.Text = app.mallRegKey; |
|||
//this.Text_WsUrl.Text = app.configwebsocket;
|
|||
this.Text_ExePath.Text = app.configstartexe; |
|||
} |
|||
|
|||
private void Win_Closed(object sender, EventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
string startup = log.Writestart(); |
|||
if (string.IsNullOrEmpty(startup)) |
|||
{ |
|||
MessageBox.Show("创建启动文件失败"); |
|||
return; |
|||
} |
|||
//string startup = System.Windows.Forms.Application.ExecutablePath; //取得程序路径
|
|||
RegistryKey rKey = Registry.LocalMachine; |
|||
//开机自动运行
|
|||
RegistryKey autoRun = rKey.CreateSubKey(@"SOFTWARE\wow6432node\microsoft\windows\currentversion\run"); |
|||
log.WriteLogFile(@"打开注册表SOFTWARE\wow6432node\microsoft\windows\currentversion\run成功", "RegistryKey"); |
|||
try |
|||
{ |
|||
autoRun.SetValue("Container", startup); |
|||
rKey.Close(); |
|||
log.WriteLogFile(@"创建注册表启动项成功", "RegistryKey"); |
|||
} |
|||
catch (Exception exp) |
|||
{ |
|||
|
|||
MessageBox.Show("创建开机自启动失败:" + exp.Message.ToString() + "请手动设置开机自启动"); |
|||
log.WriteLogFile(exp.Message.ToString(), "RegistryKey"); |
|||
} |
|||
int pp = startup.LastIndexOf("\\"); |
|||
startup = startup.Substring(0, pp); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
MessageBox.Show("创建开机自启动失败:" + ex.Message.ToString() + "请手动设置开机自启动"); |
|||
//if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["MessageShow"]))
|
|||
//{
|
|||
// MessageBox.Show(ex.Message.ToString());
|
|||
//}
|
|||
//else if (ConfigurationManager.AppSettings["MessageShow"].ToLower().Trim().Equals("true"))
|
|||
//{
|
|||
// MessageBox.Show(ex.Message.ToString());
|
|||
//}
|
|||
log.WriteLogFile(ex.Message.ToString(), "RegistryKey"); |
|||
|
|||
} |
|||
} |
|||
|
|||
private void ExeFile_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
OpenFileDialog openFile = new OpenFileDialog();//实例化打开对话框对象
|
|||
openFile.Filter = "应用程序|*.bat;*.exe";//设置打开文件筛选器
|
|||
// openExcel.FileName = "";
|
|||
openFile.Multiselect = false;//设置打开对话框中不能多选
|
|||
openFile.CheckFileExists = true; //验证路径有效性
|
|||
openFile.CheckPathExists = true; //验证文件有效性
|
|||
string strName = string.Empty; |
|||
if (openFile.ShowDialog() == true) |
|||
{ |
|||
strName = openFile.FileName; |
|||
} |
|||
|
|||
if (strName == "") |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
Text_ExePath.Text = openFile.FileName;//显示选择的Exe文件
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,69 @@ |
|||
<Window x:Class="Container.ChildWindows.GetUrlForLocal" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
Title="设备信息" Height="500" Topmost="True" Width="400" Loaded="Services_Loaded" Closed="Win_Closed" WindowStyle="None" AllowsTransparency="True"> |
|||
<Canvas x:Name="Mainp"> |
|||
<Canvas x:Name="deviceinfo" Visibility="Visible" Height="500" Width="400" > |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/background.jpg"/> |
|||
</Canvas.Background> |
|||
<Label x:Name="Label_HttpUrl" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="应用程序路径" Canvas.Top="265" Canvas.Left="40"/> |
|||
|
|||
<TextBox x:Name="Text_HttpUrl" FontSize="12" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="237" Height="39" Canvas.Left="127" Canvas.Top="123" BorderThickness="0" Background="White"/> |
|||
<Label x:Name="Label_WsUrl" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="Http地址" Canvas.Top="132" Canvas.Left="64"/> |
|||
|
|||
<TextBox x:Name="Text_WsUrl" FontSize="12" Foreground="Black" Background="White" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="237" Height="39" Canvas.Top="189" Canvas.Left="127" BorderThickness="0"/> |
|||
|
|||
<Label x:Name="Label_ExePath" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="Websocket地址" Canvas.Top="198" Canvas.Left="26"/> |
|||
|
|||
<TextBox x:Name="Text_ExePath" FontSize="12" GotFocus="ExeFile_Click" Foreground="Black" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="237" Height="39" Canvas.Top="254" Canvas.Left="127" BorderThickness="0"> |
|||
<TextBox.Resources> |
|||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="1" Stretch="None" AlignmentX="Left"> |
|||
<VisualBrush.Visual> |
|||
<TextBox Width="237" Height="39" BorderThickness="0" Foreground="#C0C0C0" Background="White" FontSize="10" VerticalContentAlignment="Center" VerticalAlignment="Center" Text="可选" /> |
|||
</VisualBrush.Visual> |
|||
</VisualBrush> |
|||
</TextBox.Resources> |
|||
<TextBox.Style> |
|||
<Style TargetType="TextBox"> |
|||
<Style.Triggers> |
|||
<Trigger Property="Text" Value="{x:Null}"> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
<Trigger Property="Text" Value=""> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</TextBox.Style> |
|||
</TextBox> |
|||
<Label x:Name="lab_msg" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Foreground="Red" Content="Label" Visibility="Hidden" Canvas.Top="319" Width="400" Height="27"/> |
|||
|
|||
|
|||
<Button x:Name="ButtonOK" Canvas.Left="154" Canvas.Top="351" Width="91" Height="27" Click="Button_Click"> |
|||
<Button.Style> |
|||
<Style TargetType="{x:Type Button}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Button}"> |
|||
<Canvas Name="cvs" Background="Transparent" Canvas.Top="351" Width="91" Height="27"> |
|||
<Image Name="Img" Source="../image/Btn_OK.jpg" Height="27" Width="91"/> |
|||
<TextBlock Name="tbSale" FontWeight="Bold" Foreground="Transparent" Width="91" Canvas.Top="7" FontFamily="HYQiHei" Height="27" FontSize="15" TextAlignment="Center" Text="完成"></TextBlock> |
|||
</Canvas> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsPressed" Value="True"> |
|||
<Setter Property="Background" Value="#b6b6b6" TargetName="cvs" /> |
|||
<Setter Property="Foreground" Value="White" TargetName="tbSale" /> |
|||
<Setter Property="Visibility" Value="Hidden" TargetName="Img" /> |
|||
|
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</Button.Style> |
|||
</Button> |
|||
</Canvas> |
|||
</Canvas> |
|||
</Window> |
|||
@ -0,0 +1,172 @@ |
|||
using Container.Common; |
|||
using Container.Services; |
|||
using Microsoft.Win32; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
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.Shapes; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// GetUrlForLocal.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class GetUrlForLocal : Window |
|||
{ |
|||
App app = ((App)System.Windows.Application.Current); |
|||
Class_Config config = new Class_Config(); |
|||
Class_Log log = new Class_Log(); |
|||
public GetUrlForLocal() |
|||
{ |
|||
InitializeComponent(); |
|||
this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; |
|||
} |
|||
|
|||
private void Button_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
lab_msg.Visibility = System.Windows.Visibility.Hidden; |
|||
if (string.IsNullOrEmpty(this.Text_HttpUrl.Text)) |
|||
{ |
|||
lab_msg.Content = "请填写Http地址。"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
if (string.IsNullOrEmpty(this.Text_WsUrl.Text)) |
|||
{ |
|||
lab_msg.Content = "请填写Websocket地址。"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
if (string.IsNullOrEmpty(this.Text_ExePath.Text)) |
|||
{ |
|||
//if (MessageBox.Show("确认不填写应用程序路径?", "提示", MessageBoxButton.YesNo) == MessageBoxResult.No)
|
|||
//{
|
|||
// lab_msg.Content = "请填写应用程序路径。";
|
|||
// lab_msg.Visibility = System.Windows.Visibility.Visible;
|
|||
// return;
|
|||
//}
|
|||
} |
|||
|
|||
else if (!File.Exists(this.Text_ExePath.Text.ToString()) && !this.Text_ExePath.Text.ToString().Contains("http")) |
|||
{ |
|||
lab_msg.Content = "未找到应用程序,请确认路径是否正确。"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
app.configurl = this.Text_HttpUrl.Text.ToString(); |
|||
app.HttpUrl = this.Text_HttpUrl.Text.ToString(); |
|||
app.configwebsocket = this.Text_WsUrl.Text.ToString(); |
|||
HttpMessage httpclient = new HttpMessage(); |
|||
string Errorlog = string.Empty; |
|||
string mallCode = string.Empty; |
|||
//var flag = httpclient.CheckMallRegKey(app.mallRegKey, ref mallCode, ref Errorlog);
|
|||
app.mallCode = mallCode; |
|||
app.configstartexe = this.Text_ExePath.Text.ToString(); |
|||
config.WriteToInitialConfig(); |
|||
ServiceInfo info = new ServiceInfo(); |
|||
this.ButtonOK.Visibility = System.Windows.Visibility.Hidden; |
|||
info.ShowDialog(); |
|||
if (info.DialogResult == true) |
|||
{ |
|||
this.DialogResult = info.DialogResult; |
|||
} |
|||
else |
|||
{ |
|||
this.ButtonOK.Visibility = System.Windows.Visibility.Visible; |
|||
} |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "GetUrlErrorLog"); |
|||
} |
|||
} |
|||
|
|||
private void Services_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
this.Text_HttpUrl.Text = app.HttpUrl; |
|||
this.Text_WsUrl.Text = app.configwebsocket; |
|||
this.Text_ExePath.Text = app.configstartexe; |
|||
} |
|||
|
|||
private void Win_Closed(object sender, EventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
string startup = log.Writestart(); |
|||
if (string.IsNullOrEmpty(startup)) |
|||
{ |
|||
MessageBox.Show("创建启动文件失败"); |
|||
return; |
|||
} |
|||
//string startup = System.Windows.Forms.Application.ExecutablePath; //取得程序路径
|
|||
RegistryKey rKey = Registry.LocalMachine; |
|||
//开机自动运行
|
|||
RegistryKey autoRun = rKey.CreateSubKey(@"SOFTWARE\wow6432node\microsoft\windows\currentversion\run"); |
|||
log.WriteLogFile(@"打开注册表SOFTWARE\wow6432node\microsoft\windows\currentversion\run成功", "RegistryKey"); |
|||
try |
|||
{ |
|||
autoRun.SetValue("Container", startup); |
|||
rKey.Close(); |
|||
log.WriteLogFile(@"创建注册表启动项成功", "RegistryKey"); |
|||
} |
|||
catch (Exception exp) |
|||
{ |
|||
|
|||
MessageBox.Show("创建开机自启动失败:" + exp.Message.ToString() + "请手动设置开机自启动"); |
|||
log.WriteLogFile(exp.Message.ToString(), "RegistryKey"); |
|||
} |
|||
int pp = startup.LastIndexOf("\\"); |
|||
startup = startup.Substring(0, pp); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
MessageBox.Show("创建开机自启动失败:" + ex.Message.ToString() + "请手动设置开机自启动"); |
|||
//if (string.IsNullOrEmpty(ConfigurationManager.AppSettings["MessageShow"]))
|
|||
//{
|
|||
// MessageBox.Show(ex.Message.ToString());
|
|||
//}
|
|||
//else if (ConfigurationManager.AppSettings["MessageShow"].ToLower().Trim().Equals("true"))
|
|||
//{
|
|||
// MessageBox.Show(ex.Message.ToString());
|
|||
//}
|
|||
log.WriteLogFile(ex.Message.ToString(), "RegistryKey"); |
|||
|
|||
} |
|||
} |
|||
|
|||
private void ExeFile_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
OpenFileDialog openFile = new OpenFileDialog();//实例化打开对话框对象
|
|||
openFile.Filter = "应用程序|*.bat;*.exe";//设置打开文件筛选器
|
|||
// openExcel.FileName = "";
|
|||
openFile.Multiselect = false;//设置打开对话框中不能多选
|
|||
openFile.CheckFileExists = true; //验证路径有效性
|
|||
openFile.CheckPathExists = true; //验证文件有效性
|
|||
string strName = string.Empty; |
|||
if (openFile.ShowDialog() == true) |
|||
{ |
|||
strName = openFile.FileName; |
|||
} |
|||
|
|||
if (strName == "") |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
Text_ExePath.Text = openFile.FileName;//显示选择的Exe文件
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,150 @@ |
|||
using System; |
|||
using System.ComponentModel; |
|||
using System.Drawing; |
|||
using System.Timers; |
|||
using System.Windows; |
|||
using System.Windows.Controls; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// Label走马灯自定义控件
|
|||
/// </summary>
|
|||
[ToolboxBitmap(typeof(Label))] //设置工具箱中显示的图标
|
|||
public class ScrollingTextControl : Label |
|||
{ |
|||
/// <summary>
|
|||
/// 定时器
|
|||
/// </summary>
|
|||
Timer MarqueeTimer = new Timer(); |
|||
/// <summary>
|
|||
/// 滚动文字源
|
|||
/// </summary>
|
|||
String _TextSource = "滚动文字源"; |
|||
/// <summary>
|
|||
/// 输出文本
|
|||
/// </summary>
|
|||
String _OutText = string.Empty; |
|||
/// <summary>
|
|||
/// 过度文本存储
|
|||
/// </summary>
|
|||
string _TempString = string.Empty; |
|||
/// <summary>
|
|||
/// 文字的滚动速度
|
|||
/// </summary>
|
|||
double _RunSpeed = 500; |
|||
|
|||
DateTime _SignTime; |
|||
bool _IfFirst = true; |
|||
|
|||
/// <summary>
|
|||
/// 滚动一循环字幕停留的秒数,单位为毫秒,默认值停留3秒
|
|||
/// </summary>
|
|||
int _StopSecond = 10000; |
|||
|
|||
/// <summary>
|
|||
/// 滚动一循环字幕停留的秒数,单位为毫秒,默认值停留3秒
|
|||
/// </summary>
|
|||
public int StopSecond |
|||
{ |
|||
get { return _StopSecond; } |
|||
set |
|||
{ |
|||
_StopSecond = value; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 滚动的速度
|
|||
/// </summary>
|
|||
[Description("文字滚动的速度")] //显示在属性设计视图中的描述
|
|||
public double RunSpeed |
|||
{ |
|||
get { return _RunSpeed; } |
|||
set |
|||
{ |
|||
_RunSpeed = value; |
|||
MarqueeTimer.Interval = _RunSpeed; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 滚动文字源
|
|||
/// </summary>
|
|||
[Description("文字滚动的Text")] |
|||
public string TextSource |
|||
{ |
|||
get { return _TextSource; } |
|||
set |
|||
{ |
|||
_TextSource = value; |
|||
_TempString = _TextSource + " "; |
|||
_OutText = _TempString; |
|||
} |
|||
} |
|||
|
|||
private string SetContent |
|||
{ |
|||
get { return Content.ToString(); } |
|||
set |
|||
{ |
|||
Content = value; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 构造函数
|
|||
/// </summary>
|
|||
public ScrollingTextControl() |
|||
{ |
|||
MarqueeTimer.Interval = _RunSpeed;//文字移动的速度
|
|||
MarqueeTimer.Enabled = true; //开启定时触发事件
|
|||
MarqueeTimer.Elapsed += new ElapsedEventHandler(MarqueeTimer_Elapsed);//绑定定时事件
|
|||
this.Loaded += new RoutedEventHandler(ScrollingTextControl_Loaded);//绑定控件Loaded事件
|
|||
} |
|||
|
|||
|
|||
void ScrollingTextControl_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
_TextSource = SetContent; |
|||
_TempString = _TextSource + " "; |
|||
_OutText = _TempString; |
|||
_SignTime = DateTime.Now; |
|||
} |
|||
|
|||
|
|||
void MarqueeTimer_Elapsed(object sender, ElapsedEventArgs e) |
|||
{ |
|||
if (string.IsNullOrEmpty(_OutText)) return; |
|||
|
|||
if (_OutText.Substring(1) + _OutText[0] == _TempString) |
|||
{ |
|||
if (_IfFirst) |
|||
{ |
|||
_SignTime = DateTime.Now; |
|||
} |
|||
|
|||
if ((DateTime.Now - _SignTime).TotalMilliseconds > _StopSecond) |
|||
{ |
|||
_IfFirst = true; ; |
|||
} |
|||
else |
|||
{ |
|||
_IfFirst = false; |
|||
return; |
|||
} |
|||
} |
|||
|
|||
_OutText = _OutText.Substring(1) + _OutText[0]; |
|||
|
|||
|
|||
Dispatcher.BeginInvoke(new Action(() => |
|||
{ |
|||
SetContent = _OutText; |
|||
})); |
|||
|
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,175 @@ |
|||
<Window x:Class="Container.ChildWindows.ServiceInfo" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" |
|||
xmlns:winForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" |
|||
xmlns:gifLib="clr-namespace:GifImageLib;assembly=GifImageLib" |
|||
Title="设备信息" Height="600" Topmost="True" Width="400" Loaded="Services_Loaded" Closed="Services_Closed" WindowStyle="None" AllowsTransparency="True"> |
|||
|
|||
<Canvas x:Name="Mainp"> |
|||
<Canvas x:Name="Loading" Height="600" Width="400" Visibility="Visible"> |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/connection.jpg"/> |
|||
</Canvas.Background> |
|||
<gifLib:GifImage Source="../image/Loading.gif" Width="120" Height="120" Canvas.Left="140" Canvas.Top="125"/> |
|||
<TextBlock x:Name="Time" FontSize="12" Width="400" HorizontalAlignment="Center" TextAlignment="Center" Visibility="Visible" Text="倒计时60s" Foreground="#FF777777" Canvas.Left="0" Canvas.Top="374"/> |
|||
|
|||
</Canvas> |
|||
<Canvas x:Name="ConnectFailed" Height="600" Width="400" Visibility="Hidden"> |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/connectfailed.jpg"/> |
|||
</Canvas.Background> |
|||
<Label x:Name="ErrorInfo" Visibility="Hidden" Content="(未查询到楼栋信息)" Foreground="DarkGray" Canvas.Left="135" Canvas.Top="321"/> |
|||
<Button Canvas.Left="154" Canvas.Top="351" Width="91" Height="27" Click="Btn_ReConnection"> |
|||
<Button.Style> |
|||
<Style TargetType="{x:Type Button}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Button}"> |
|||
<Canvas Name="cvs" Background="Transparent" Canvas.Top="351" Width="91" Height="27"> |
|||
<TextBlock Name="tbSale" FontWeight="Bold" Foreground="Transparent" Width="91" Canvas.Top="7" FontFamily="HYQiHei" Height="27" FontSize="15" TextAlignment="Center" Text="重试"></TextBlock> |
|||
</Canvas> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsPressed" Value="True"> |
|||
<Setter Property="Background" Value="#b6b6b6" TargetName="cvs" /> |
|||
<Setter Property="Foreground" Value="White" TargetName="tbSale" /> |
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</Button.Style> |
|||
</Button> |
|||
</Canvas> |
|||
<Canvas x:Name="UpdateFailed" Height="600" Width="400" Visibility="Hidden"> |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/failed.jpg"/> |
|||
</Canvas.Background> |
|||
<!--<Label x:Name="UpdateErrorInfo" Visibility="Visible" Content="" Foreground="DarkGray" Canvas.Left="135" Canvas.Top="321"/>--> |
|||
<StackPanel Canvas.Left="0" Canvas.Top="240" Width="400" Height="48"> |
|||
<TextBlock x:Name="UpdateErrorInfo" Foreground="DarkGray" FontSize="15" FontFamily="HYQiHei" Text="" TextWrapping = "Wrap" TextAlignment="Center" Height="47"/> |
|||
</StackPanel> |
|||
<Button Canvas.Left="154" Canvas.Top="351" Width="91" Height="27" Click="Btn_ReUpdate"> |
|||
<Button.Style> |
|||
<Style TargetType="{x:Type Button}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Button}"> |
|||
<Canvas Name="cvs" Background="Transparent" Canvas.Top="351" Width="91" Height="27"> |
|||
<TextBlock Name="tbSale" FontWeight="Bold" Foreground="Transparent" Width="91" Canvas.Top="7" FontFamily="HYQiHei" Height="27" FontSize="15" TextAlignment="Center" Text="重试"></TextBlock> |
|||
</Canvas> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsPressed" Value="True"> |
|||
<Setter Property="Background" Value="#b6b6b6" TargetName="cvs" /> |
|||
<Setter Property="Foreground" Value="White" TargetName="tbSale" /> |
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</Button.Style> |
|||
</Button> |
|||
</Canvas> |
|||
<Canvas x:Name="UpdateSuccess" Visibility="Hidden" Height="600" Width="400" > |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/success.jpg"/> |
|||
</Canvas.Background> |
|||
</Canvas> |
|||
<Canvas x:Name="deviceinfo" Visibility="Visible" Height="600" Width="400" > |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/background.jpg"/> |
|||
</Canvas.Background> |
|||
<Label x:Name="Label_Info" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#A0A0A0" Content="请输入设备信息" Canvas.Top="138" Canvas.Left="237"/> |
|||
|
|||
<Label x:Name="Label_Building" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="当前楼栋" Canvas.Top="180" Canvas.Left="65"/> |
|||
|
|||
<ComboBox x:Name="ComBox_Building" IsEditable="True" FontSize="18" Foreground="#FFA5A5A5" SelectionChanged="Combox_Building_changed" HorizontalAlignment="Left" Focusable="False" MouseLeftButtonDown="Combox_LeftButtonDown" IsReadOnly="True" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="199" Height="39" Canvas.Left="127" Canvas.Top="172" BorderThickness="0" Background="{x:Null}"/> |
|||
<Label x:Name="Label_Floor" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="当前楼层" Canvas.Top="240" Canvas.Left="64"/> |
|||
|
|||
<ComboBox x:Name="ComBox_Floor" IsEditable="True" FontSize="18" Foreground="#FFA5A5A5" Background="{x:Null}" HorizontalAlignment="Left" IsReadOnly="True" Focusable="False" MouseLeftButtonDown="Combox_LeftButtonDown" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="199" Height="39" Canvas.Top="231" Canvas.Left="127" BorderThickness="0"/> |
|||
<Label x:Name="Label_Device" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="设备标识" Canvas.Top="294" Canvas.Left="65"/> |
|||
<TextBox x:Name="Text_Device" FontSize="18" Foreground="#FFA5A5A5" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="199" Height="39" Canvas.Top="287" Canvas.Left="127" BorderThickness="0"> |
|||
<TextBox.Resources> |
|||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="1" Stretch="None" AlignmentX="Left"> |
|||
<VisualBrush.Visual> |
|||
<TextBox Width="237" Height="39" Foreground="#C0C0C0" BorderThickness="0" Background="White" FontSize="10" VerticalContentAlignment="Center" VerticalAlignment="Center" Text="可选" /> |
|||
</VisualBrush.Visual> |
|||
</VisualBrush> |
|||
</TextBox.Resources> |
|||
<TextBox.Style> |
|||
<Style TargetType="TextBox"> |
|||
<Style.Triggers> |
|||
<Trigger Property="Text" Value="{x:Null}"> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
<Trigger Property="Text" Value=""> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</TextBox.Style> |
|||
</TextBox> |
|||
<Label x:Name="Label_Type" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="设备类型" Canvas.Top="350" Canvas.Left="64"/> |
|||
|
|||
<ComboBox x:Name="ComBox_Type" IsEditable="True" FontSize="18" Foreground="#FFA5A5A5" Background="{x:Null}" HorizontalAlignment="Left" IsReadOnly="True" Focusable="False" MouseLeftButtonDown="Combox_LeftButtonDown" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="199" Height="39" Canvas.Top="341" Canvas.Left="127" BorderThickness="0"/> |
|||
<Label x:Name="Label_File" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="文件存储" Canvas.Top="410" Canvas.Left="65"/> |
|||
|
|||
<ComboBox x:Name="ComBox_File" IsEditable="True" FontSize="18" Foreground="#FFA5A5A5" SelectionChanged="Combox_File_changed" HorizontalAlignment="Left" Focusable="False" MouseLeftButtonDown="Combox_LeftButtonDown" IsReadOnly="True" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="199" Height="39" Canvas.Left="127" Canvas.Top="400" BorderThickness="0" Background="{x:Null}"/> |
|||
|
|||
<Label x:Name="Label_FilePath" Visibility="Hidden" FontWeight="Bold" FontSize="12" FontFamily="HYQiHei" Foreground="#808080" Content="文件地址" Canvas.Top="470" Canvas.Left="65"/> |
|||
<TextBox x:Name="Text_FilePath" Visibility="Hidden" FontSize="18" Foreground="#FFA5A5A5" HorizontalAlignment="Left" VerticalAlignment="Center" VerticalContentAlignment="Center" Width="199" Height="39" Canvas.Top="459" Canvas.Left="127" BorderThickness="0"> |
|||
<TextBox.Resources> |
|||
<VisualBrush x:Key="HelpBrush" TileMode="None" Opacity="1" Stretch="None" AlignmentX="Left"> |
|||
<VisualBrush.Visual> |
|||
<TextBox Width="237" Height="39" Foreground="#C0C0C0" BorderThickness="0" Background="White" FontSize="10" VerticalContentAlignment="Center" VerticalAlignment="Center" Text="可选" /> |
|||
</VisualBrush.Visual> |
|||
</VisualBrush> |
|||
</TextBox.Resources> |
|||
<TextBox.Style> |
|||
<Style TargetType="TextBox"> |
|||
<Style.Triggers> |
|||
<Trigger Property="Text" Value="{x:Null}"> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
<Trigger Property="Text" Value=""> |
|||
<Setter Property="Background" Value="{StaticResource HelpBrush}"/> |
|||
</Trigger> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</TextBox.Style> |
|||
</TextBox> |
|||
|
|||
<Button Canvas.Left="154" Canvas.Top="520" Width="91" Height="27" Click="Button_Click"> |
|||
<Button.Style> |
|||
<Style TargetType="{x:Type Button}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Button}"> |
|||
<Canvas Name="cvs" Background="Transparent" Canvas.Top="351" Width="91" Height="27"> |
|||
<Image Name="Img" Source="../image/Btn_OK.jpg" Height="27" Width="91"/> |
|||
<TextBlock Name="tbSale" FontWeight="Bold" Foreground="Transparent" Width="91" Canvas.Top="7" FontFamily="HYQiHei" Height="27" FontSize="15" TextAlignment="Center" Text="完成"></TextBlock> |
|||
</Canvas> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsPressed" Value="True"> |
|||
<Setter Property="Background" Value="#b6b6b6" TargetName="cvs" /> |
|||
<Setter Property="Foreground" Value="White" TargetName="tbSale" /> |
|||
<Setter Property="Visibility" Value="Hidden" TargetName="Img" /> |
|||
|
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</Button.Style> |
|||
</Button> |
|||
<!--<Button x:Name="Btn_Next" Content="下一步" Canvas.Left="248" Canvas.Top="250" Width="75" Click="Button_Click"/>--> |
|||
<!--<Label x:Name="Label_Building" Content="请选择楼栋信息" Canvas.Left="10" Canvas.Top="63"/>--> |
|||
<!--<Button x:Name="reclient" Visibility="Hidden" Content="重试" Canvas.Left="29" Canvas.Top="250" Width="75" Click="reclient_Click"/>--> |
|||
<!--<Button x:Name="Btn_back" Content="上一步" Visibility="Hidden" Canvas.Left="168" Canvas.Top="250" Width="75" Click="ButtonBack_Click"/>--> |
|||
<Label x:Name="lab_msg" HorizontalAlignment="Center" HorizontalContentAlignment="Center" Foreground="Red" Content="Label" Visibility="Hidden" Canvas.Top="326" Width="400" Height="27"/> |
|||
</Canvas> |
|||
</Canvas> |
|||
</Window> |
|||
@ -0,0 +1,548 @@ |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using Container.Services; |
|||
using Container.Viewmodel; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Text; |
|||
using System.Threading; |
|||
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.Shapes; |
|||
using System.Windows.Threading; |
|||
using System.IO; |
|||
using Microsoft.Win32; |
|||
using System.Diagnostics; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// ServiceInfo.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class ServiceInfo : Window |
|||
{ |
|||
BackgroundWorker backgroundWorker; |
|||
DispatcherTimer timer = new DispatcherTimer(); |
|||
App app; |
|||
int type = 1; |
|||
string ErrorLog = ""; |
|||
private Class_Log log = new Class_Log(); |
|||
string BuildingName = ""; |
|||
string BuildingId = ""; |
|||
string FloorName = ""; |
|||
string FloorId = ""; |
|||
string DeviceType = ""; |
|||
string FileType = ""; |
|||
int second = 10; |
|||
public ServiceInfo() |
|||
{ |
|||
InitializeComponent(); |
|||
this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; |
|||
} |
|||
//SelectBox mytest;
|
|||
private void Services_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
app = ((App)System.Windows.Application.Current); |
|||
|
|||
backgroundWorker = new BackgroundWorker(); |
|||
backgroundWorker.WorkerReportsProgress = true; |
|||
backgroundWorker.WorkerSupportsCancellation = true; |
|||
backgroundWorker.ProgressChanged += BackgroundWorker_ProgressChanged; |
|||
backgroundWorker.RunWorkerCompleted += BackgroundWorker_RunWorkerCompleted; |
|||
backgroundWorker.DoWork += BackgroundWorker_DoWork; |
|||
backgroundWorker.RunWorkerAsync(); |
|||
second = 60; |
|||
timer.Tick += new EventHandler(timer_Tick); |
|||
timer.Interval = TimeSpan.FromSeconds(1); |
|||
timer.Start(); |
|||
Text_Device.Text = app.devicemark = System.Net.Dns.GetHostName(); |
|||
this.Text_FilePath.Text = app.HttpUrl; |
|||
HttpMessage httpclient = new HttpMessage(); |
|||
string ErrorLog = ""; |
|||
if (httpclient.GetDeviceTypeList(ref ErrorLog)) { |
|||
if (app.DeviceTypeList.Count() > 0) |
|||
{ |
|||
//app.Floors = list.ElementAt(0);
|
|||
this.ComBox_Type.ItemsSource = (new BuildingOperate(3)).BuildingMenu; |
|||
ComBox_Type.SelectedValuePath = "code"; |
|||
ComBox_Type.DisplayMemberPath = "name"; |
|||
ComBox_Type.SelectedIndex = 0; |
|||
ComBox_Type.IsDropDownOpen = false; |
|||
} |
|||
} |
|||
|
|||
this.ComBox_File.ItemsSource = (new BuildingOperate(4)).BuildingMenu; |
|||
ComBox_File.SelectedValuePath = "code"; |
|||
ComBox_File.DisplayMemberPath = "code"; |
|||
ComBox_File.SelectedIndex = 0; |
|||
ComBox_File.IsDropDownOpen = false; |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile("异常" + ex.ToString(), "ServiceInfoError"); |
|||
} |
|||
|
|||
} |
|||
|
|||
//倒计时
|
|||
private void timer_Tick(object sender, EventArgs e) |
|||
{ |
|||
if (second > 0) |
|||
{ |
|||
second--; |
|||
if (Loading.Visibility == System.Windows.Visibility.Visible) |
|||
this.Time.Text = "倒计时" + second.ToString() + "s"; |
|||
} |
|||
else |
|||
{ |
|||
if (Loading.Visibility == System.Windows.Visibility.Visible) |
|||
{ |
|||
if (backgroundWorker.IsBusy == true) |
|||
{ |
|||
timer.Stop(); |
|||
backgroundWorker.ReportProgress(1, null); |
|||
} |
|||
|
|||
|
|||
} |
|||
else if (UpdateSuccess.Visibility == System.Windows.Visibility.Visible) |
|||
{ |
|||
timer.Stop(); |
|||
this.DialogResult = true; |
|||
} |
|||
} |
|||
} |
|||
private void Button_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
lab_msg.Visibility = System.Windows.Visibility.Hidden; |
|||
|
|||
//if (type == 1)
|
|||
//{
|
|||
BuildingName = ""; |
|||
BuildingId = ""; |
|||
|
|||
if (ComBox_Building.Text == "" || ComBox_Building.SelectedValue == null) |
|||
{ |
|||
lab_msg.Content = "请先选择楼栋信息"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
|
|||
BuildingName = ComBox_Building.Text.ToString(); |
|||
BuildingId = ComBox_Building.SelectedValue.ToString(); |
|||
//}
|
|||
//else if (type == 2)
|
|||
//{
|
|||
FloorName = ""; |
|||
FloorId = ""; |
|||
if (ComBox_Building.Text == "" || ComBox_Building.SelectedValue == null) |
|||
{ |
|||
lab_msg.Content = "请先选择楼层信息"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
FloorName = ComBox_Floor.Text.ToString(); |
|||
FloorId = ComBox_Floor.SelectedValue.ToString(); |
|||
log.WriteLogFile("ComBox_Type.Text="+ ComBox_Type.Text+ ";ComBox_Type.SelectedValue="+ ComBox_Type.SelectedValue, "123"); |
|||
if (ComBox_Type.Text == "" || ComBox_Type.SelectedValue == null) { |
|||
lab_msg.Content = "请选择设备类型"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
DeviceType = ComBox_Type.SelectedValue.ToString(); |
|||
if (ComBox_File.Text == "" || ComBox_File.SelectedValue == null) |
|||
{ |
|||
lab_msg.Content = "请先选择文件存储"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
FileType= ComBox_File.SelectedValue.ToString(); |
|||
//if (Text_Device.Text.Trim() == "")
|
|||
{ |
|||
//lab_msg.Content = "请填写设备标识";
|
|||
//lab_msg.Visibility = System.Windows.Visibility.Visible;
|
|||
//return;
|
|||
app.devicemark = Text_Device.Text.Trim(); |
|||
} |
|||
switch (FileType) |
|||
{ |
|||
case "本地部署": |
|||
app.FileServerPath = app.HttpUrl; |
|||
break; |
|||
case "前置离线": |
|||
app.FileServerPath = Text_FilePath.Text.Trim(); |
|||
break; |
|||
case "直联云": |
|||
app.FileServerPath = app.OBSPath; |
|||
break; |
|||
default: |
|||
break; |
|||
} |
|||
if (string.IsNullOrEmpty(app.FileServerPath)) |
|||
{ |
|||
lab_msg.Content = "文件服务地址不能为空"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
return; |
|||
} |
|||
//}
|
|||
if (backgroundWorker.IsBusy) |
|||
{ |
|||
lab_msg.Content = "线程正忙,请稍后再试"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
} |
|||
else |
|||
{ |
|||
type = 2; |
|||
this.deviceinfo.Visibility = System.Windows.Visibility.Hidden; |
|||
this.Loading.Visibility = System.Windows.Visibility.Visible; |
|||
string errorMsg = ""; |
|||
StartExE(app.configstartexe, (app.HttpUrl.Replace("http://", "")).Split('/')[0] + "|" + app.LocalIP + "|" + app.configwebsocket + "|1"); |
|||
HttpMessage httpmessage = new HttpMessage(); |
|||
httpmessage.LoadAppConfig(ref errorMsg); |
|||
httpmessage.LoadBG(); |
|||
httpmessage.LoadScreenTime(); |
|||
backgroundWorker.RunWorkerAsync(); |
|||
app.IsCanConnect = true; |
|||
|
|||
} |
|||
|
|||
} |
|||
|
|||
private void StartExE(string path, string param = "") |
|||
{ |
|||
try |
|||
{ |
|||
timer.Stop(); |
|||
if (!File.Exists(path) && !path.StartsWith("http:")) |
|||
{ |
|||
if (!File.Exists(System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/")) + path)) |
|||
{ |
|||
return; |
|||
} |
|||
else |
|||
{ |
|||
path = System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").Substring(0, System.Windows.Forms.Application.ExecutablePath.Replace("\\", "/").LastIndexOf("/")) + path; |
|||
} |
|||
} |
|||
log.WriteLogFile(path.Substring(path.Length - 4, 4).ToLower(), "startlog"); |
|||
if (path.Substring(path.Length - 4, 4).ToLower().Equals(".bat")) |
|||
{ |
|||
param = ""; |
|||
Process myprocess = new Process(); |
|||
ProcessStartInfo startInfo = new ProcessStartInfo(path, param); |
|||
path = path.Replace("\\", "/"); |
|||
startInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
startInfo.Verb = "runas"; |
|||
startInfo.CreateNoWindow = true; |
|||
myprocess.StartInfo = startInfo; |
|||
myprocess.StartInfo.UseShellExecute = false; |
|||
|
|||
myprocess.Start(); |
|||
app.AppPlayName = "chrome"; |
|||
app.CurAppPlayName = app.AppPlayName; |
|||
app.NowAppType = "bat"; |
|||
timer.Start(); |
|||
log.WriteLogFile("打开成功", "startlog"); |
|||
} |
|||
else |
|||
{ |
|||
Process myprocess = new Process(); |
|||
ProcessStartInfo startInfo = new ProcessStartInfo(path, param); |
|||
path = path.Replace("\\", "/"); |
|||
startInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
startInfo.Verb = "runas"; |
|||
startInfo.CreateNoWindow = true; |
|||
myprocess.StartInfo = startInfo; |
|||
myprocess.StartInfo.UseShellExecute = false; |
|||
myprocess.Start(); |
|||
app.AppPlayName = myprocess.ProcessName; |
|||
app.CurAppPlayName = app.AppPlayName; |
|||
app.NowAppType = "exe"; |
|||
timer.Start(); |
|||
} |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString()); |
|||
} |
|||
|
|||
} |
|||
|
|||
void BackgroundWorker_DoWork(object sender, DoWorkEventArgs e) |
|||
{ |
|||
//BackgroundWorker worker = sender as BackgroundWorker;
|
|||
HttpMessage httpclient = new HttpMessage(); |
|||
try |
|||
{ |
|||
ErrorLog = ""; |
|||
if (type == 1) |
|||
{ |
|||
if (httpclient.GetBuildinginfo(ref ErrorLog)) |
|||
{ |
|||
if (app.Buildinginfo.Count > 0) |
|||
{ |
|||
//查询成功
|
|||
backgroundWorker.ReportProgress(0, null); |
|||
} |
|||
else |
|||
{ |
|||
if (ErrorLog.Trim() == "") |
|||
ErrorLog = "未查到楼栋相关记录";//未查到
|
|||
backgroundWorker.ReportProgress(1, null); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
//ErrorLog = "连接服务器失败。";
|
|||
backgroundWorker.ReportProgress(1, null); |
|||
} |
|||
|
|||
} |
|||
else |
|||
{ |
|||
int i = 0; |
|||
string AddressIP = string.Empty; |
|||
foreach (IPAddress _IPAddress in Dns.GetHostEntry(Dns.GetHostName()).AddressList) |
|||
{ |
|||
if (_IPAddress.AddressFamily.ToString() == "InterNetwork") |
|||
{ |
|||
AddressIP = _IPAddress.ToString(); |
|||
} |
|||
} |
|||
// string[] IP = AddressIP.Split('.');
|
|||
// if (IP.Count() == 4)
|
|||
//app.deviceid = BuildingName + FloorName + IP[2] + IP[3];
|
|||
while (true) |
|||
{ |
|||
|
|||
if (httpclient.UploadDeviceInfo(BuildingId, FloorId, DeviceType, ref ErrorLog)) |
|||
{ |
|||
WebSocketManageForLive webForLive = new WebSocketManageForLive(); |
|||
webForLive.OpenWebSocket(); |
|||
backgroundWorker.ReportProgress(0, null);//上传成功
|
|||
break; |
|||
} |
|||
else |
|||
{ |
|||
i++; |
|||
|
|||
if (i > 3) |
|||
{ |
|||
//if (ErrorLog.Trim() == "")
|
|||
// ErrorLog = "上传失败";
|
|||
backgroundWorker.ReportProgress(1, null); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
ErrorLog = "操作失败"; |
|||
log.WriteLogFile("异常" + ex.ToString(),"ServiceInfoError"); |
|||
backgroundWorker.ReportProgress(1, null); |
|||
} |
|||
e.Cancel = true; |
|||
return; |
|||
} |
|||
void BackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e) |
|||
{ |
|||
int progressPercentage = e.ProgressPercentage; |
|||
string userState = (string)e.UserState; |
|||
try |
|||
{ |
|||
switch (progressPercentage) |
|||
{ |
|||
case 0: |
|||
//reclient.Visibility = System.Windows.Visibility.Hidden;
|
|||
if (type == 1) |
|||
{ |
|||
timer.Stop(); |
|||
this.ComBox_Building.ItemsSource = app.Buildinginfo; |
|||
this.ComBox_Building.ItemsSource = (new BuildingOperate(type)).BuildingMenu; |
|||
ComBox_Building.SelectedValuePath = "code"; |
|||
ComBox_Building.DisplayMemberPath = "name"; |
|||
ComBox_Building.IsDropDownOpen = true; |
|||
this.Loading.Visibility = System.Windows.Visibility.Hidden; |
|||
this.deviceinfo.Visibility = Visibility.Visible; |
|||
} |
|||
else |
|||
{ |
|||
second = 2; |
|||
this.Loading.Visibility = System.Windows.Visibility.Hidden; |
|||
this.UpdateSuccess.Visibility = System.Windows.Visibility.Visible; |
|||
timer.Start(); |
|||
} |
|||
backgroundWorker.CancelAsync(); |
|||
break; |
|||
case 1: |
|||
if (type == 1) |
|||
{ |
|||
this.ConnectFailed.Visibility = System.Windows.Visibility.Visible; |
|||
this.Loading.Visibility = System.Windows.Visibility.Hidden; |
|||
} |
|||
else |
|||
{ |
|||
UpdateErrorInfo.Text = ErrorLog; |
|||
UpdateErrorInfo.Visibility = System.Windows.Visibility.Visible; |
|||
this.UpdateFailed.Visibility = System.Windows.Visibility.Visible; |
|||
this.Loading.Visibility = System.Windows.Visibility.Hidden; |
|||
} |
|||
timer.Stop(); |
|||
lab_msg.Content = ErrorLog; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
backgroundWorker.CancelAsync(); |
|||
break; |
|||
case 2: |
|||
break; |
|||
default: break; |
|||
} |
|||
} |
|||
catch (System.Exception ex) |
|||
{ |
|||
log.WriteLogFile("异常" + ex.ToString()); |
|||
} |
|||
} |
|||
|
|||
private void ButtonBack_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
lab_msg.Visibility = System.Windows.Visibility.Hidden; |
|||
|
|||
if (backgroundWorker.IsBusy) |
|||
{ |
|||
lab_msg.Content = "线程正忙,请稍后再试"; |
|||
lab_msg.Visibility = System.Windows.Visibility.Visible; |
|||
} |
|||
else |
|||
{ |
|||
type = 1; |
|||
backgroundWorker.RunWorkerAsync(); |
|||
|
|||
} |
|||
} |
|||
|
|||
private void reclient_Click(object sender, RoutedEventArgs e) |
|||
{ |
|||
Button_Click(null,null); |
|||
} |
|||
|
|||
private void Services_Closed(object sender, EventArgs e) |
|||
{ |
|||
if (backgroundWorker.IsBusy) |
|||
backgroundWorker.CancelAsync(); |
|||
timer.Stop(); |
|||
|
|||
} |
|||
string buildingid = ""; |
|||
private void Combox_Building_changed(object sender, SelectionChangedEventArgs e) |
|||
{ |
|||
this.ComBox_Floor.Text = ""; |
|||
this.ComBox_Floor.ItemsSource = null; |
|||
if (buildingid.Trim().Equals(this.ComBox_Building.SelectedValue.ToString().Trim())) |
|||
{ |
|||
return; |
|||
} |
|||
else |
|||
{ |
|||
buildingid = this.ComBox_Building.SelectedValue.ToString(); |
|||
} |
|||
|
|||
IEnumerable<List<Floor>> list = (app.Buildinginfo.Where(i => i.code.ToString() == this.ComBox_Building.SelectedValue.ToString()).Select(i => i.floors)); |
|||
if (list.Count() > 0) |
|||
{ |
|||
app.Floors = list.ElementAt(0); |
|||
this.ComBox_Floor.ItemsSource = (new BuildingOperate(2)).BuildingMenu; |
|||
ComBox_Floor.SelectedValuePath = "code"; |
|||
ComBox_Floor.DisplayMemberPath = "name"; |
|||
ComBox_Floor.IsDropDownOpen = true; |
|||
} |
|||
else |
|||
{ |
|||
|
|||
} |
|||
} |
|||
|
|||
private void Combox_File_changed(object sender, SelectionChangedEventArgs e) |
|||
{ |
|||
|
|||
if (this.ComBox_File.SelectedValue.ToString() == "前置离线") |
|||
{ |
|||
Label_FilePath.Visibility = Visibility.Visible; |
|||
Text_FilePath.Visibility = Visibility.Visible; |
|||
} |
|||
else { |
|||
Label_FilePath.Visibility = Visibility.Hidden; |
|||
Text_FilePath.Visibility = Visibility.Hidden; |
|||
} |
|||
} |
|||
|
|||
private void Btn_ReConnection(object sender, RoutedEventArgs e) |
|||
{ |
|||
this.Close(); |
|||
//if (backgroundWorker.IsBusy)
|
|||
//{
|
|||
// ErrorInfo.Content = "线程正忙,请稍后再试";
|
|||
// ErrorInfo.Visibility = System.Windows.Visibility.Visible;
|
|||
//}
|
|||
//else
|
|||
//{
|
|||
// ErrorInfo.Visibility = System.Windows.Visibility.Hidden;
|
|||
// type = 1;
|
|||
// second = 60;
|
|||
// timer.Start();
|
|||
// this.ConnectFailed.Visibility = System.Windows.Visibility.Hidden;
|
|||
// this.Loading.Visibility = System.Windows.Visibility.Visible;
|
|||
// backgroundWorker.RunWorkerAsync();
|
|||
|
|||
//}
|
|||
} |
|||
|
|||
private void Btn_ReUpdate(object sender, RoutedEventArgs e) |
|||
{ |
|||
if (backgroundWorker.IsBusy) |
|||
{ |
|||
this.UpdateErrorInfo.Text = "线程正忙,请稍后再试"; |
|||
UpdateErrorInfo.Visibility = System.Windows.Visibility.Visible; |
|||
} |
|||
else |
|||
{ |
|||
//type = 2;
|
|||
//second = 60;
|
|||
//timer.Start();
|
|||
UpdateErrorInfo.Visibility = System.Windows.Visibility.Hidden; |
|||
this.UpdateFailed.Visibility = System.Windows.Visibility.Hidden; |
|||
this.Loading.Visibility = System.Windows.Visibility.Hidden; |
|||
deviceinfo.Visibility = System.Windows.Visibility.Visible; |
|||
//backgroundWorker.RunWorkerAsync();
|
|||
|
|||
} |
|||
} |
|||
|
|||
private void Combox_LeftButtonDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
ComboBox cm = (ComboBox)sender; |
|||
cm.IsDropDownOpen = true; |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,37 @@ |
|||
<UserControl x:Class="Container.ChildWindows.UCAppButton" |
|||
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" |
|||
mc:Ignorable="d" |
|||
Height="120" Width="260"> |
|||
<Canvas Name="AppMain"> |
|||
<Grid> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="145*"></ColumnDefinition> |
|||
<ColumnDefinition Width="115*"></ColumnDefinition> |
|||
</Grid.ColumnDefinitions> |
|||
<Border Grid.Column="1" Width="100" Height="100" Background="White"> |
|||
<Border.Clip> |
|||
<RectangleGeometry RadiusX="50" RadiusY="50" Rect="0,0,100,100"/> |
|||
</Border.Clip> |
|||
<Image x:Name="image" > |
|||
</Image> |
|||
</Border> |
|||
<TextBlock Grid.Column="0" FontSize="24" Width="120" x:Name="txtName" TextAlignment="Right" Foreground="White" FontFamily="HYQiHei" Text="导购" Margin="0 30 20 30"></TextBlock> |
|||
</Grid> |
|||
<!--<Canvas Height="78" Width="73"> |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/UCBackground.png"/> |
|||
</Canvas.Background> |
|||
<Canvas Name="mask" Width="28" Height="25" Canvas.Left="24" ZIndex="2" Visibility="Visible" Canvas.Top="20"> |
|||
<Canvas.Background> |
|||
<ImageBrush Stretch="Fill" x:Name="image"/> |
|||
</Canvas.Background> |
|||
</Canvas> |
|||
</Canvas> |
|||
<Canvas> |
|||
<TextBlock FontSize="10" Canvas.Left="8" Canvas.Top="48" Width="60" x:Name="txtName" TextAlignment="Center" Foreground="#969696" FontFamily="HYQiHei" ></TextBlock> |
|||
</Canvas>--> |
|||
</Canvas> |
|||
</UserControl> |
|||
@ -0,0 +1,254 @@ |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using Container.Services; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
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; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// UCAppButton.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class UCAppButton : UserControl |
|||
{ |
|||
|
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong); |
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern IntPtr FindWindow(string lpWindowClass, string lpWindowName); |
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle); |
|||
const int GWL_HWNDPARENT = -8; |
|||
[DllImport("user32.dll")] |
|||
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); |
|||
[DllImport("user32.dll")] |
|||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); |
|||
|
|||
[DllImport("user32.dll", EntryPoint = "ShowWindow")] |
|||
public static extern bool ShowWindow(System.IntPtr hWnd, int nCmdShow); |
|||
public static int SW_SHOW = 5; |
|||
public static int SW_NORMAL = 1; |
|||
public static int SW_MAX = 3; |
|||
public static int SW_HIDE = 0; |
|||
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); //窗体置顶
|
|||
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); //取消窗体置顶
|
|||
public static readonly IntPtr HWND_BOTTOM = new IntPtr(1); //取消窗体置顶
|
|||
|
|||
|
|||
public const uint SWP_NOMOVE = 0x0002; //不调整窗体位置
|
|||
public const uint SWP_NOSIZE = 0x0001; //不调整窗体大小
|
|||
Class_Log log = new Class_Log(); |
|||
App app = ((App)System.Windows.Application.Current); |
|||
string ProcessName = ""; |
|||
AppListModel AppInfo = new AppListModel(); |
|||
public UCAppButton(AppListModel ExeInfo) |
|||
{ |
|||
InitializeComponent(); |
|||
AppInfo = ExeInfo; |
|||
//this.DataContext = ExeInfo;
|
|||
//this.mask.DataContext = ExeInfo;
|
|||
Uri uri = new Uri(ExeInfo.Logo, UriKind.Relative); |
|||
//ImageBrush ib = new ImageBrush();
|
|||
//image.Source = new BitmapImage(uri);
|
|||
//Uri uri = new Uri(logo, UriKind.Absolute);
|
|||
this.image.Source = BitmapFrame.Create(uri); |
|||
txtName.Text = ExeInfo.Name; |
|||
this.MouseLeftButtonUp += new MouseButtonEventHandler(this_MouseLeftButtonDown); |
|||
} |
|||
|
|||
private void this_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
Window w = ((Canvas)(((Canvas)this.Parent).Parent)).Parent as Window; |
|||
w.Close(); |
|||
//打开应用
|
|||
try |
|||
{ |
|||
app.appClick = true; |
|||
if (!AppInfo.Code.Equals(app.AppPlayinfo.Code)) |
|||
{ |
|||
if (app.NowAppType != "html" && app.NowAppType != "bat" && app.NowAppType != "") |
|||
{ |
|||
killExE(); |
|||
} |
|||
////else if (app.NowAppType == "html")
|
|||
////{
|
|||
//// app.winh5.WinClose();
|
|||
//// //app.winh5 = null;
|
|||
////}
|
|||
string fileName = AppInfo.Startup; |
|||
//if (string.IsNullOrEmpty(AppInfo.Startup))
|
|||
//{
|
|||
// fileName = AppInfo.Startup;
|
|||
//}
|
|||
//else
|
|||
//{
|
|||
// fileName = AppInfo.exestartname + "/" + AppInfo.exestartname;
|
|||
//}
|
|||
if (StartExE(fileName)) |
|||
{ |
|||
app.AppPlayinfo = AppInfo; |
|||
//app.AppPlayName = ProcessName;
|
|||
//app.AppPlayNameCH = "";
|
|||
//app.Appversion = "";
|
|||
IntPtr Win = FindWindow(null, "WindowButton"); //CustomBar是我的程序中需要置顶的窗体的名字
|
|||
if (Win != null) |
|||
{ |
|||
SetWindowPos(Win, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); |
|||
} |
|||
else |
|||
{ |
|||
if (app.AppList != null && app.AppList.Count > 1) |
|||
{ |
|||
WindowButton win = new WindowButton(); |
|||
win.Show(); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
else |
|||
{ |
|||
app.AppPlayName = ""; |
|||
app.CurAppPlayName = app.AppPlayName; |
|||
app.AppPlayNameCH = ""; |
|||
app.Appversion = ""; |
|||
//打开失败
|
|||
} |
|||
|
|||
} |
|||
} |
|||
catch(Exception ex) |
|||
{ |
|||
// MessageBox.Show(ex.ToString());
|
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 打开外部exe应用程序
|
|||
/// <param name="path">应用程序地址</param>
|
|||
/// </summary>
|
|||
private bool StartExE(string path,string param = "") |
|||
{ |
|||
try |
|||
{ |
|||
if (!File.Exists(path)) |
|||
{ |
|||
//System.Windows.MessageBox.Show("应用程序打开失败:。。。" + path + " 文件不存在");
|
|||
log.WriteLogFile("应用程序打开失败:" + path + " 文件不存在","UCAppButtonlog"); |
|||
return false; |
|||
} |
|||
|
|||
if (path.Substring(path.Length - 4, 4).ToLower().Equals(".bat")) |
|||
{ |
|||
param = ""; |
|||
Process myprocess = new Process(); |
|||
ProcessStartInfo startInfo = new ProcessStartInfo(path, param); |
|||
path = path.Replace("\\", "/"); |
|||
startInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
startInfo.Verb = "runas"; |
|||
startInfo.CreateNoWindow = true; |
|||
myprocess.StartInfo = startInfo; |
|||
myprocess.StartInfo.UseShellExecute = false; |
|||
myprocess.Start(); |
|||
//MyProcessName.Add("chrome");
|
|||
app.AppPlayName = "chrome"; |
|||
app.CurAppPlayName = app.AppPlayName; |
|||
app.NowAppType = "bat"; |
|||
//startexe = true;
|
|||
//timer.Start();
|
|||
log.WriteLogFile("打开成功111", "startlog"); |
|||
} |
|||
else |
|||
{ |
|||
Process myprocess = new Process(); |
|||
path = path.Replace("\\", "/").Replace("//", "/"); |
|||
ProcessStartInfo startInfo = new ProcessStartInfo(path, param); |
|||
startInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("/"));//设置应用程序在其所在目录
|
|||
startInfo.Verb = "runas"; |
|||
startInfo.CreateNoWindow = true; |
|||
myprocess.StartInfo = startInfo; |
|||
myprocess.StartInfo.UseShellExecute = false; |
|||
log.WriteLogFile(startInfo.WorkingDirectory); |
|||
log.WriteLogFile(startInfo.FileName); |
|||
myprocess.Start(); |
|||
//MyProcessName.Add(myprocess.ProcessName);
|
|||
app.NowAppType = "exe"; |
|||
app.AppPlayName = myprocess.ProcessName; |
|||
app.CurAppPlayName = app.AppPlayName; |
|||
//startexe = true;
|
|||
} |
|||
//Process myprocess = new Process();
|
|||
//ProcessStartInfo startInfo = new ProcessStartInfo(path, param);
|
|||
//path = path.Replace("\\", "/");
|
|||
//startInfo.WorkingDirectory = path.Substring(0, path.LastIndexOf("/"));//设置应用程序在其所在目录工作
|
|||
//myprocess.StartInfo = startInfo;
|
|||
//myprocess.StartInfo.UseShellExecute = false;
|
|||
//myprocess.Start();
|
|||
//ProcessName = myprocess.ProcessName;
|
|||
return true; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "UCAppButtonlog"); |
|||
return false; |
|||
|
|||
} |
|||
|
|||
} |
|||
/// <summary>
|
|||
/// 关闭已打开外部应用程序
|
|||
/// </summary>
|
|||
private bool killExE() |
|||
{ |
|||
try |
|||
{ |
|||
if (app.NowAppType == "exe") |
|||
{ |
|||
Process[] pro = Process.GetProcesses(); |
|||
for (int i = 0; i < pro.Length; i++) |
|||
{ |
|||
if (pro[i].ProcessName.ToLower() == app.AppPlayName.ToLower()) |
|||
{ |
|||
pro[i].Kill();//结束进程
|
|||
|
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
else if (app.NowAppType == "html") |
|||
{ |
|||
//this.Dispatcher.Invoke(new Action(() =>
|
|||
//{
|
|||
// try
|
|||
// {
|
|||
// if (app.winh5 != null)
|
|||
// app.winh5.Close();
|
|||
// }
|
|||
// catch { }
|
|||
//}));
|
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "UCAppButtonlog"); |
|||
|
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
<Window x:Class="Container.ChildWindows.WinShow" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" |
|||
xmlns:winForms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" |
|||
xmlns:gifLib="clr-namespace:GifImageLib;assembly=GifImageLib" |
|||
Title="WinShow" Height="1920" Width="1080" ResizeMode="NoResize" WindowStyle="None"> |
|||
<Canvas> |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="../image/启动页竖.jpg"/> |
|||
</Canvas.Background> |
|||
<gifLib:GifImage Source="../image/Loading.gif" Width="120" Height="120" Canvas.Left="481" Canvas.Top="611"/> |
|||
</Canvas> |
|||
</Window> |
|||
@ -0,0 +1,32 @@ |
|||
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.Shapes; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// WinShow.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class WinShow : Window |
|||
{ |
|||
App app = ((App)System.Windows.Application.Current); |
|||
public WinShow() |
|||
{ |
|||
InitializeComponent(); |
|||
this.Width = app.ScreenWidth; |
|||
this.Height = app.ScreenHeight; |
|||
this.Left = 0; |
|||
this.Top = 0; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,33 @@ |
|||
<Window x:Class="Container.ChildWindows.WindowAppChoose" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:gifLib="clr-namespace:GifImageLib;assembly=GifImageLib" |
|||
Title="WindowAppChoose" Width="1920" Height="1080" Topmost="True" WindowStyle="None" Left="0" Top="0" AllowsTransparency="True" Background="Transparent" Loaded="Win_Load" > |
|||
<Canvas Width="1920" Height="1080" > |
|||
<Canvas.Background> |
|||
<SolidColorBrush Opacity="0.8" Color="Black"></SolidColorBrush> |
|||
</Canvas.Background> |
|||
<Canvas x:Name="MainCanvas" Background="Transparent" Height="1030" Width="260" Canvas.Right="50" Canvas.Bottom="50"> |
|||
<!--<Border x:Name="Bborder" Width="240" Height="1080"> |
|||
</Border>--> |
|||
|
|||
<!--<gifLib:GifImage x:Name="Ggif" MouseLeftButtonUp="ButtonBack_Click" Source="../image/BG.gif" Canvas.Top="-14" Canvas.Left="-14" Height="110" Width="110" />--> |
|||
|
|||
<!--<Image Height="78" Source="../Image/BtnBack.png" MouseLeftButtonUp="ButtonBack_Clic000000000000000000000000k"/>--> |
|||
<StackPanel Name="AppButton" HorizontalAlignment="Left" VerticalAlignment="Bottom" Width="260" Height="900"/> |
|||
<!--<Canvas x:Name="AppButton" Background="Transparent" VerticalAlignment="Bottom"> |
|||
</Canvas>--> |
|||
<Image x:Name="Img" Source="../image/BGButtonNew.png" Height="130" Width="130" Canvas.Right="0" Canvas.Bottom="0" MouseLeftButtonUp="ButtonBack_Click"> |
|||
<Image.RenderTransform> |
|||
<TransformGroup> |
|||
<TranslateTransform/> |
|||
<ScaleTransform/> |
|||
<RotateTransform Angle="45" CenterX="65" CenterY="65"/> |
|||
</TransformGroup> |
|||
</Image.RenderTransform> |
|||
</Image> |
|||
|
|||
</Canvas> |
|||
</Canvas> |
|||
|
|||
</Window> |
|||
@ -0,0 +1,134 @@ |
|||
using Container.Common; |
|||
using Container.Model; |
|||
using Container.Services; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
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.Shapes; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// WindowAppChoose.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class WindowAppChoose : Window |
|||
{ |
|||
//List<AppListModel> AppList = new List<AppListModel>();
|
|||
private int columnCount = 18; |
|||
private double widthSpace = 0;//横向间隔
|
|||
private double heightSpace = 0;//纵向间隔
|
|||
//private int rowCount = 0;
|
|||
private double cvsGoodsMinHeight = 0.00; |
|||
App app = ((App)System.Windows.Application.Current); |
|||
Class_Log log = new Class_Log(); |
|||
public WindowAppChoose(double top, double left, double appwidth = 78) |
|||
{ |
|||
InitializeComponent(); |
|||
//Class_Config config = new Class_Config();
|
|||
//config.ReadAppInfo(ref AppList);
|
|||
|
|||
//if (left > SystemParameters.PrimaryScreenWidth / 2)
|
|||
//{
|
|||
// AppButton.SetValue(LeftProperty, 0.00);
|
|||
// //Ggif.SetValue(LeftProperty, this.Width - 96);
|
|||
|
|||
//}
|
|||
SetAppButton(); |
|||
//this.Width = 90 + this.AppButton.Width;
|
|||
//Bborder.Width = this.Width;
|
|||
//if (left > SystemParameters.PrimaryScreenWidth / 2)
|
|||
//{
|
|||
// //AppButton.SetValue(LeftProperty, 0);
|
|||
// Ggif.SetValue(LeftProperty, this.Width - 96);
|
|||
|
|||
//}
|
|||
//this.Top = top;//SystemParameters.PrimaryScreenHeight - this.Height - 50;
|
|||
//if (left < 0)
|
|||
//{
|
|||
// left = 0;
|
|||
//}
|
|||
//if (left - this.Width < 0)
|
|||
//{
|
|||
// this.Left = 0;
|
|||
//}
|
|||
////else if (left - this.Width > SystemParameters.PrimaryScreenWidth - this.Width)
|
|||
//// this.Left = SystemParameters.PrimaryScreenWidth - this.Width
|
|||
//else if (left <= SystemParameters.PrimaryScreenWidth / 2)
|
|||
//{
|
|||
// this.Left = left - appwidth;// - this.Width
|
|||
//}
|
|||
//else
|
|||
//{
|
|||
// this.Left = left - this.Width;// - this.Width
|
|||
|
|||
//}
|
|||
//SystemParameters.PrimaryScreenWidth - this.Width;
|
|||
//this.Top = SystemParameters.PrimaryScreenHeight - this.Height - 50;
|
|||
//this.Left = SystemParameters.PrimaryScreenWidth - this.Width;
|
|||
|
|||
} |
|||
|
|||
private void Win_Load(object sender, RoutedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
|
|||
public void SetAppButton() |
|||
{ |
|||
//double goodWidth = 0;
|
|||
this.AppButton.Height = app.AppList.Count * 120; |
|||
this.AppButton.Margin = new Thickness(0, 900 - this.AppButton.Height, 0, 0); |
|||
try |
|||
{ |
|||
for (int i = 0; i < app.AppList.Count; i++) |
|||
{ |
|||
//int rowIndex = i / columnCount;
|
|||
//int columnIndex = i % columnCount;
|
|||
UCAppButton AppInfo = new UCAppButton(app.AppList[i]); |
|||
//AppInfo.SetValue(Canvas.LeftProperty, 0);
|
|||
//AppInfo.SetValue(Canvas.TopProperty, 300);
|
|||
|
|||
this.AppButton.Children.Add(AppInfo); |
|||
|
|||
//if (goodWidth == 0)
|
|||
// goodWidth = AppInfo.Width;
|
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile("1111"+e.Message,"errrrrr"); |
|||
} |
|||
//this.AppButton.MinHeight = cvsGoodsMinHeight;
|
|||
//this.AppButton.Width = app.AppList.Count * (goodWidth + widthSpace) + widthSpace;
|
|||
} |
|||
|
|||
private void ButtonBack_Click(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
this.Close(); |
|||
|
|||
} |
|||
|
|||
private void mousedown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
if (e.LeftButton == MouseButtonState.Pressed) |
|||
{ |
|||
|
|||
this.DragMove(); |
|||
|
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
<Window x:Class="Container.ChildWindows.WindowButton" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:gifLib="clr-namespace:GifImageLib;assembly=GifImageLib" |
|||
Title="WindowButton" ShowInTaskbar="False" SnapsToDevicePixels="True" Height="130" Width="130" Background="Transparent" MouseEnter="Win_MouseEnter" MouseLeftButtonUp="Btn_MouseUp" MouseLeave="Win_MouseLeave" MouseLeftButtonDown="UIElement_OnMouseLeftButtonDown" AllowsTransparency="True" ResizeMode="NoResize" Closed="Windows_Closed" Topmost="True" WindowStyle="None" > |
|||
<Canvas x:Name="Mainp" > |
|||
<!--<Image x:Name="Img" Source="../image/BGButton.png" Canvas.Top="-17" Canvas.Left="-17" Height="110" Width="110"/>--> |
|||
<Image x:Name="Img" Source="../image/BGButtonNew.png" Height="130" Width="130"/> |
|||
<!--Click="Btn_Click " MouseLeftButtonDown="Btn_MouseDown" AllowsTransparency="True" MouseLeftButtonUp="Btn_MouseUp" Click="Btn_Click" ClickMode="Release" vMouseEnter="Win_MouseEnter" MouseLeave="Win_MouseLeave" --> |
|||
<!--<Button x:Name="nocardload" Canvas.Top="2" |
|||
Height="74" Width="74" Canvas.Left="2" BorderBrush="Transparent" MouseLeftButtonDown="Btn_MouseDown" MouseLeftButtonUp="Btn_MouseUp" > |
|||
<Button.Style> |
|||
<Style TargetType="{x:Type Button}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Button}"> |
|||
<gifLib:GifImage x:Name="ButtonGif" Source="../image/AppButton.gif" Canvas.Top="2" Canvas.Left="2" Height="74" Width="74" /> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</Button.Style> |
|||
</Button>--> |
|||
<!--<gifLib:GifImage x:Name="GgifImage" Source="../image/BG.gif" Canvas.Top="-14" Canvas.Left="-14" Height="110" Width="110" />--> |
|||
</Canvas> |
|||
</Window> |
|||
@ -0,0 +1,275 @@ |
|||
using Container.Common; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading; |
|||
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.Interop; |
|||
using System.Windows.Media; |
|||
using System.Windows.Media.Imaging; |
|||
using System.Windows.Shapes; |
|||
using System.Windows.Threading; |
|||
|
|||
namespace Container.ChildWindows |
|||
{ |
|||
/// <summary>
|
|||
/// WindowButton.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class WindowButton : Window |
|||
{ |
|||
Class_Log log = new Class_Log();//日志对象
|
|||
App app = ((App)System.Windows.Application.Current); |
|||
Point _TicstartPoint;//鼠标按下位置
|
|||
Point _TicendPoint;//鼠标抬起位置
|
|||
//Point mousePostion;
|
|||
//初始化
|
|||
public WindowButton() |
|||
{ |
|||
InitializeComponent(); |
|||
this.Top = app.ScreenHeight - this.Height - 50; |
|||
this.Left = app.ScreenWidth - this.Width-65; |
|||
mLastInputInfo = new LASTINPUTINFO(); |
|||
mLastInputInfo.cbSize = Marshal.SizeOf(mLastInputInfo); |
|||
|
|||
mIdleTimer = new System.Windows.Threading.DispatcherTimer(); |
|||
mIdleTimer.Tick += new EventHandler(IdleTime);//起个Timer一直获取当前时间
|
|||
mIdleTimer.Interval = new TimeSpan(0, 0, 0, 1, 0); |
|||
; |
|||
//mIdleTimer.Start();
|
|||
} |
|||
//窗体关闭事件
|
|||
private void Windows_Closed(object sender, EventArgs e) |
|||
{ |
|||
|
|||
try |
|||
{ |
|||
|
|||
Process[] process = Process.GetProcesses(); |
|||
foreach (Process prc in process) |
|||
{ |
|||
if (prc.ProcessName.Equals(System.Diagnostics.Process.GetCurrentProcess().ProcessName)) |
|||
{ |
|||
if (app.AppList != null && app.AppList.Count > 1) |
|||
{ |
|||
WindowButton win = new WindowButton(); |
|||
win.Show(); |
|||
|
|||
} |
|||
} |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile("窗体关闭异常:" + ex.ToString(), "MainWindowError"); |
|||
} |
|||
} |
|||
//鼠标按下事件
|
|||
private void UIElement_OnMouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
_TicstartPoint = new Point(this.Left, this.Top); |
|||
|
|||
if (e.LeftButton == MouseButtonState.Pressed) |
|||
{ |
|||
|
|||
this.DragMove(); |
|||
//SendMessage(new WindowInteropHelper(this).Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
|
|||
|
|||
} |
|||
|
|||
|
|||
} |
|||
//鼠标抬起事件
|
|||
private void Btn_MouseUp(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
_TicendPoint = new Point(this.Left, this.Top); |
|||
|
|||
//X轴滑动的距离
|
|||
double offsetY = _TicstartPoint.Y - _TicendPoint.Y; |
|||
double offsetX = _TicstartPoint.X - _TicendPoint.X; |
|||
if (offsetY < 2 && offsetY > -2 && offsetX > -5 && offsetX < 5) |
|||
{ |
|||
this.Img.Visibility = System.Windows.Visibility.Hidden; |
|||
//this.GgifImage.Visibility = System.Windows.Visibility.Hidden;
|
|||
this.Img.Visibility = System.Windows.Visibility.Hidden; |
|||
//this.GgifImage.Visibility = System.Windows.Visibility.Hidden;
|
|||
WindowAppChoose win = new WindowAppChoose(this.Top, this.Left + this.Width, this.Width); |
|||
win.ShowDialog(); |
|||
//Thread.Sleep(1000);
|
|||
//this.GgifImage.Visibility = System.Windows.Visibility.Visible;
|
|||
this.Img.Visibility = System.Windows.Visibility.Visible; |
|||
//this.Left = SystemParameters.PrimaryScreenWidth - this.Width / 2 + 5;
|
|||
|
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString()); |
|||
} |
|||
} |
|||
//[DllImport("user32.dll")]
|
|||
//public static extern bool ReleaseCapture();
|
|||
//[DllImport("user32.dll")]
|
|||
//public static extern bool SetCapture();
|
|||
[DllImport("user32.dll")] |
|||
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); |
|||
public const int WM_SYSCOMMAND = 0x0112; |
|||
public const int SC_MOVE = 0xF010; |
|||
public const int HTCAPTION = 0x0002; |
|||
|
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong); |
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern IntPtr FindWindow(string lpWindowClass, string lpWindowName); |
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle); |
|||
const int GWL_HWNDPARENT = -8; |
|||
[DllImport("user32.dll")] |
|||
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); |
|||
[DllImport("user32.dll")] |
|||
public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags); |
|||
|
|||
[DllImport("user32.dll", EntryPoint = "ShowWindow")] |
|||
public static extern bool ShowWindow(System.IntPtr hWnd, int nCmdShow); |
|||
public static int SW_SHOW = 5; |
|||
public static int SW_NORMAL = 1; |
|||
public static int SW_MAX = 3; |
|||
public static int SW_HIDE = 0; |
|||
public static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); //窗体置顶
|
|||
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2); //取消窗体置顶
|
|||
public const uint SWP_NOMOVE = 0x0002; //不调整窗体位置
|
|||
public const uint SWP_NOSIZE = 0x0001; //不调整窗体大小
|
|||
private void Form1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e) |
|||
{//拖动窗体
|
|||
SendMessage(new WindowInteropHelper(this).Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0); |
|||
} |
|||
|
|||
#region 检测鼠标动作
|
|||
//定义结构体
|
|||
[StructLayout(LayoutKind.Sequential)] |
|||
struct LASTINPUTINFO |
|||
{ |
|||
// 设置结构体块容量
|
|||
[MarshalAs(UnmanagedType.U4)] |
|||
public int cbSize; |
|||
// 捕获的时间
|
|||
[MarshalAs(UnmanagedType.U4)] |
|||
public uint dwTime; |
|||
} |
|||
|
|||
// 定义定时器,结构体对象等
|
|||
|
|||
private DispatcherTimer mIdleTimer; |
|||
private LASTINPUTINFO mLastInputInfo; |
|||
|
|||
[DllImport("user32.dll")] |
|||
private static extern bool GetLastInputInfo(ref LASTINPUTINFO plii); |
|||
|
|||
/*初始化 |
|||
mLastInputInfo = new LASTINPUTINFO(); |
|||
mLastInputInfo.cbSize = Marshal.SizeOf(mLastInputInfo); |
|||
|
|||
mIdleTimer = new System.Windows.Threading.DispatcherTimer(); |
|||
mIdleTimer.Tick += new EventHandler(IdleTime);//起个Timer一直获取当前时间
|
|||
mIdleTimer.Interval = new TimeSpan(0, 0, 0, 1, 0); |
|||
mIdleTimer.Start(); |
|||
*/ |
|||
|
|||
//实现
|
|||
private void IdleTime(object sender, EventArgs e) |
|||
{ |
|||
|
|||
if (!GetLastInputInfo(ref mLastInputInfo)) |
|||
{ |
|||
//MessageBox.Show("GetLastInputInfo Failed!");
|
|||
//this.Top = SystemParameters.PrimaryScreenHeight - this.Height - 50;
|
|||
//this.Left = SystemParameters.PrimaryScreenWidth - this.Width - 10;
|
|||
} |
|||
else |
|||
{ |
|||
if ((Environment.TickCount - (long)mLastInputInfo.dwTime) / 1000 > 10) |
|||
{ |
|||
//MessageBox.Show("no operation for 5 minutes.");
|
|||
//this.Top = SystemParameters.PrimaryScreenHeight - this.Height - 50;
|
|||
this.Left = app.ScreenWidth - this.Width / 2 + 5; |
|||
} |
|||
} |
|||
|
|||
} |
|||
#endregion
|
|||
|
|||
private void Win_MouseEnter(object sender, MouseEventArgs e) |
|||
{ |
|||
|
|||
//if (this.Left > SystemParameters.PrimaryScreenWidth - this.Width)
|
|||
//{
|
|||
// this.Left = SystemParameters.PrimaryScreenWidth - this.Width;
|
|||
//}
|
|||
} |
|||
|
|||
private void Win_MouseLeave(object sender, MouseEventArgs e) |
|||
{ |
|||
//if (this.Left >= SystemParameters.PrimaryScreenWidth - this.Width-2)
|
|||
//{
|
|||
|
|||
// this.Left = SystemParameters.PrimaryScreenWidth - this.Width / 2 + 5;
|
|||
//}
|
|||
} |
|||
|
|||
|
|||
|
|||
private void Btn_MouseDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
_TicstartPoint = e.GetPosition(App.Current.MainWindow); |
|||
} |
|||
|
|||
private void GgifImage_MouseDown(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
//_TicstartPoint = PointToScreen(e.GetPosition(this));
|
|||
_TicstartPoint = new Point(this.Left,this.Top); |
|||
|
|||
} |
|||
|
|||
private void GgifImage_MouseUp(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
_TicendPoint = new Point(this.Left, this.Top); |
|||
|
|||
//X轴滑动的距离
|
|||
double offsetY = _TicstartPoint.Y - _TicendPoint.Y; |
|||
double offsetX = _TicstartPoint.X - _TicendPoint.X; |
|||
if (offsetY < 2 && offsetY > -2 && offsetX > -5 && offsetX < 5) |
|||
{ |
|||
this.Img.Visibility = System.Windows.Visibility.Hidden; |
|||
//this.GgifImage.Visibility = System.Windows.Visibility.Hidden;
|
|||
this.Img.Visibility = System.Windows.Visibility.Hidden; |
|||
//this.GgifImage.Visibility = System.Windows.Visibility.Hidden;
|
|||
WindowAppChoose win = new WindowAppChoose(this.Top, this.Left + this.Width, this.Width); |
|||
win.ShowDialog(); |
|||
//Thread.Sleep(1000);
|
|||
//this.GgifImage.Visibility = System.Windows.Visibility.Visible;
|
|||
this.Img.Visibility = System.Windows.Visibility.Visible; |
|||
//this.Left = SystemParameters.PrimaryScreenWidth - this.Width / 2 + 5;
|
|||
|
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
using Fleck; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Configuration; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class ChatWebSocketMiddleware |
|||
{ |
|||
//public static ConcurrentDictionary<string, System.Net.WebSockets.WebSocket> _sockets = new ConcurrentDictionary<string, System.Net.WebSockets.WebSocket>();
|
|||
//public static List<IWebSocketConnection> allSockets = new List<IWebSocketConnection>();
|
|||
//static bool flag = true;
|
|||
//private static Class_Log log = new Class_Log(); //日志记录文件
|
|||
//private static App app = ((App)System.Windows.Application.Current);
|
|||
//Thread receiveThread;
|
|||
//public void openSocket()
|
|||
//{
|
|||
// try
|
|||
// {
|
|||
|
|||
|
|||
// FleckLog.Level = LogLevel.Debug;
|
|||
// var ws = ConfigurationManager.AppSettings["websocketUrl"];
|
|||
// var server = new WebSocketServer(ws);
|
|||
// //RecognizerCLR.setBeamDir(serialPortname, microAngle);
|
|||
// server.Start(socket =>
|
|||
// {
|
|||
// socket.OnOpen = () => //当建立Socket链接时执行此方法
|
|||
// {
|
|||
// //var data = socket.ConnectionInfo; //通过data可以获得这个链接传递过来的Cookie信息,用来区分各个链接和用户之间的关系(如果需要后台主动推送信息到某个客户的时候,可以使用Cookie)
|
|||
// //Console.WriteLine("Open!");
|
|||
// allSockets.Add(socket);
|
|||
// ChatWebSocketMiddleware.allSockets.ToList().ForEach(s => s.Send(JsonConvert.SerializeObject(app.AppList)));
|
|||
// };
|
|||
|
|||
// socket.OnClose = () =>// 当关闭Socket链接十执行此方法
|
|||
// {
|
|||
|
|||
// //Console.WriteLine("Close!");
|
|||
// allSockets.Remove(socket);
|
|||
// };
|
|||
|
|||
// socket.OnMessage = message =>// 接收客户端发送过来的信息
|
|||
// {
|
|||
|
|||
// };
|
|||
// });
|
|||
// }
|
|||
// catch (Exception e)
|
|||
// {
|
|||
|
|||
// log.WriteLogFile("异常了"+e.ToString(), "recorderror");
|
|||
// }
|
|||
|
|||
//}
|
|||
|
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,424 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.IO; |
|||
using Microsoft.Win32; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
class Class_Log |
|||
{ |
|||
/**/ |
|||
/// <summary>
|
|||
/// 写入日志文件
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
public void WriteLogFile(string input,string strfileName="Errlog") |
|||
{ |
|||
try |
|||
{ |
|||
/**/ |
|||
///指定日志文件的目录
|
|||
strfileName = strfileName + DateTime.Now.ToString("yyyy-MM-dd"); |
|||
string fpath = Directory.GetCurrentDirectory() + "\\log\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\"; |
|||
if (!Directory.Exists(fpath)) |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(fpath); |
|||
directoryInfo.Create(); |
|||
} |
|||
|
|||
string fname = Directory.GetCurrentDirectory() + "\\log\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\" + strfileName + ".txt"; |
|||
|
|||
/**/ |
|||
///定义文件信息对象
|
|||
///
|
|||
FileInfo finfo = new FileInfo(fname); |
|||
if (!finfo.Exists) |
|||
{ |
|||
FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write); |
|||
//fs = File.Create(fname);
|
|||
fs.Close(); |
|||
finfo = new FileInfo(fname); |
|||
} |
|||
/**/ |
|||
///判断文件是否存在以及是否大于2K
|
|||
if (finfo.Length > 1024 * 1024 * 10) |
|||
{ |
|||
/**/ |
|||
///文件超过10MB则重命名
|
|||
File.Move(Directory.GetCurrentDirectory() + "\\LogFile.txt", Directory.GetCurrentDirectory() + DateTime.Now.TimeOfDay + "\\LogFile.txt"); |
|||
/**/ |
|||
///删除该文件
|
|||
//finfo.Delete();
|
|||
} |
|||
//finfo.AppendText();
|
|||
/**/ |
|||
///创建只写文件流
|
|||
|
|||
using (FileStream fs = finfo.OpenWrite()) |
|||
{ |
|||
/**/ |
|||
///根据上面创建的文件流创建写数据流
|
|||
StreamWriter w = new StreamWriter(fs); |
|||
|
|||
/**/ |
|||
///设置写数据流的起始位置为文件流的末尾
|
|||
w.BaseStream.Seek(0, SeekOrigin.End); |
|||
/**/ |
|||
///写入“Log Entry : ”
|
|||
w.Write("\n\rLog Entry : "); |
|||
/**/ |
|||
///写入当前系统时间并换行
|
|||
w.Write("{0} {1} \n\r", DateTime.Now.ToLongTimeString(), |
|||
DateTime.Now.ToLongDateString()); |
|||
/**/ |
|||
///写入日志内容并换行
|
|||
w.Write(input + "\n\r"); |
|||
/**/ |
|||
///写入------------------------------------“并换行
|
|||
w.Write("------------------------------------\n\r"); |
|||
/**/ |
|||
///清空缓冲区内容,并把缓冲区内容写入基础流
|
|||
w.Flush(); |
|||
/**/ |
|||
///关闭写数据流
|
|||
w.Close(); |
|||
} |
|||
} |
|||
catch{} |
|||
|
|||
} |
|||
|
|||
/**/ |
|||
/// <summary>
|
|||
/// 写入日志文件
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
public string Writestart() |
|||
{ |
|||
try |
|||
{ |
|||
/**/ |
|||
///指定日志文件的目录
|
|||
string fpath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); |
|||
if (!Directory.Exists(fpath)) |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(fpath); |
|||
directoryInfo.Create(); |
|||
} |
|||
|
|||
string fname = fpath + "\\start.bat"; |
|||
|
|||
/**/ |
|||
///定义文件信息对象
|
|||
///
|
|||
FileInfo finfo = new FileInfo(fname); |
|||
if (!finfo.Exists) |
|||
{ |
|||
FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write); |
|||
//fs = File.Create(fname);
|
|||
fs.Close(); |
|||
finfo = new FileInfo(fname); |
|||
} |
|||
using (FileStream fs = new FileStream(fname, FileMode.Create)) |
|||
{ |
|||
/**/ |
|||
///根据上面创建的文件流创建写数据流
|
|||
StreamWriter w = new StreamWriter(fs,Encoding.Default); |
|||
|
|||
/**/ |
|||
///设置写数据流的起始位置为文件流的末尾
|
|||
w.BaseStream.Seek(0, SeekOrigin.End); |
|||
/**/ |
|||
///写入“start.bat : ”
|
|||
w.Write("\n\r%1 mshta vbscript:CreateObject(\"WScript.Shell\").Run(\"%~s0 ::\",0,FALSE)(window.close)&&exit"); |
|||
|
|||
w.WriteLine(Environment.NewLine); |
|||
|
|||
w.Write("\n\r Timeout 60"); |
|||
/**/ |
|||
w.WriteLine(Environment.NewLine); |
|||
w.Write("\n\r" + Path.GetPathRoot(System.Windows.Forms.Application.ExecutablePath).Replace("\\", "/").TrimEnd('/')); |
|||
/**/ |
|||
w.WriteLine(Environment.NewLine); |
|||
w.Write("cd " + Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)); |
|||
/**/ |
|||
w.WriteLine(Environment.NewLine); |
|||
w.Write("start " + Path.GetFileName(System.Windows.Forms.Application.ExecutablePath)); |
|||
/**/ |
|||
/**/ |
|||
w.Flush(); |
|||
/**/ |
|||
///关闭写数据流
|
|||
w.Close(); |
|||
} |
|||
return fname; |
|||
} |
|||
catch { } |
|||
return ""; |
|||
|
|||
} |
|||
/// <summary>
|
|||
/// 删除 month 个月之前的 strFileName日志
|
|||
/// </summary>
|
|||
/// <param name="strFileName"></param>
|
|||
/// <param name="month"></param>
|
|||
public static void DeleteLogFile(string strFileName = "ErrLog", int month = 1) |
|||
{ |
|||
try |
|||
{ |
|||
string logPath = Directory.GetCurrentDirectory() + "\\log\\" + strFileName; |
|||
if (!Directory.Exists(logPath))//若文件夹不存在则返回
|
|||
return; |
|||
else |
|||
logPath += "\\"; |
|||
DirectoryInfo theFolder = new DirectoryInfo(@logPath); |
|||
FileInfo[] fileInfo = theFolder.GetFiles(); |
|||
foreach (FileInfo NextFile in fileInfo) //遍历文件
|
|||
{ |
|||
DateTime dt1 = Convert.ToDateTime(NextFile.Name.Substring(strFileName.Length, NextFile.Name.Length - strFileName.Length - 4) + " 00:00:00"); |
|||
DateTime dt2 = DateTime.Now.AddMonths(-month); |
|||
if (dt1 < dt2) |
|||
{ |
|||
NextFile.Delete(); |
|||
} |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
public void DeleteFiles(string fileName = "") |
|||
{ |
|||
try |
|||
{ |
|||
if (string.IsNullOrEmpty(fileName)) |
|||
fileName = Directory.GetCurrentDirectory() + "\\log"; |
|||
if (!Directory.Exists(fileName))//若文件夹不存在则返回
|
|||
return; |
|||
DirectoryInfo dir = new DirectoryInfo(fileName);//new DirectoryInfo(Directory.GetCurrentDirectory() + "\\log");
|
|||
//不是目录
|
|||
|
|||
if (dir == null) |
|||
return; |
|||
//DateTime DT = dir.CreationTime;
|
|||
|
|||
FileSystemInfo[] files = dir.GetFileSystemInfos(); |
|||
for (int i = 0; i < files.Length; i++) |
|||
{ |
|||
FileInfo file = files[i] as FileInfo; |
|||
//是文件
|
|||
if (file != null) |
|||
{ |
|||
DateTime DT = file.CreationTime; |
|||
if (DateTime.Now.Month - DT.Month >= 1) |
|||
{ |
|||
file.Delete(); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
DirectoryInfo dir1 = files[i] as DirectoryInfo; |
|||
if (dir1 != null) |
|||
{ |
|||
DateTime DT = dir1.CreationTime; |
|||
if (DateTime.Now.Month - DT.Month >= 1) |
|||
{ |
|||
//dir1.Delete();
|
|||
System.IO.Directory.Delete(fileName + "\\" + dir1.Name, true); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
/**/ |
|||
/// <summary>
|
|||
/// 写入日志文件
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
public string WriteAppStart(string name,string url) |
|||
{ |
|||
try |
|||
{ |
|||
/**/ |
|||
///指定日志文件的目录
|
|||
string fpath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath); |
|||
if (!Directory.Exists(fpath)) |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(fpath); |
|||
directoryInfo.Create(); |
|||
} |
|||
fpath = fpath + "\\exefile"; |
|||
if (!Directory.Exists(fpath)) |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(fpath); |
|||
directoryInfo.Create(); |
|||
} |
|||
|
|||
string fname = fpath + "\\"+name+".bat"; |
|||
|
|||
/**/ |
|||
///定义文件信息对象
|
|||
///
|
|||
FileInfo finfo = new FileInfo(fname); |
|||
if (!finfo.Exists) |
|||
{ |
|||
FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write); |
|||
//fs = File.Create(fname);
|
|||
fs.Close(); |
|||
finfo = new FileInfo(fname); |
|||
} |
|||
using (FileStream fs = new FileStream(fname, FileMode.Create)) |
|||
{ |
|||
/**/ |
|||
///根据上面创建的文件流创建写数据流
|
|||
StreamWriter w = new StreamWriter(fs, Encoding.Default); |
|||
|
|||
/**/ |
|||
///设置写数据流的起始位置为文件流的末尾
|
|||
w.BaseStream.Seek(0, SeekOrigin.End); |
|||
/**/ |
|||
///写入“start.bat : ”
|
|||
w.Write("\n\r%1 mshta vbscript:CreateObject(\"WScript.Shell\").Run(\"%~s0 ::\",0,FALSE)(window.close)&&exit"); |
|||
w.WriteLine(Environment.NewLine); |
|||
w.Write("\n\r setx GOOGLE_API_KEY \"no\""); |
|||
w.WriteLine(Environment.NewLine); |
|||
w.Write("\n\r setx GOOGLE_DEFAULT_CLIENT_ID \"no\""); |
|||
w.WriteLine(Environment.NewLine); |
|||
w.Write("\n\r setx GOOGLE_DEFAULT_CLIENT_SECRET \"no\""); |
|||
/**/ |
|||
w.WriteLine(Environment.NewLine); |
|||
string ChromiumPath = GetChromiumPath(); |
|||
if (string.IsNullOrEmpty(ChromiumPath)) { |
|||
return ""; |
|||
} |
|||
w.Write("\n\r \""+ChromiumPath+ "\" -incognito --disable-background-networking --kiosk --disable-pinch \"" + url+"\""); |
|||
/**/ |
|||
/**/ |
|||
w.Flush(); |
|||
/**/ |
|||
///关闭写数据流
|
|||
w.Close(); |
|||
} |
|||
return fname; |
|||
} |
|||
catch { } |
|||
return ""; |
|||
|
|||
} |
|||
|
|||
private string GetChromiumPath() |
|||
{ |
|||
string path = string.Empty; |
|||
try |
|||
{ |
|||
//string softName = textBox1.Text.ToString();
|
|||
string strKeyName = "InstallerSuccessLaunchCmdLine"; |
|||
string softPath = @"SOFTWARE\Chromium"; |
|||
RegistryKey regKey = Registry.CurrentUser; |
|||
RegistryKey regSubKey = regKey.OpenSubKey(softPath, false); |
|||
|
|||
object objResult = regSubKey.GetValue(strKeyName); |
|||
RegistryValueKind regValueKind = regSubKey.GetValueKind(strKeyName); |
|||
if (regValueKind == Microsoft.Win32.RegistryValueKind.String) |
|||
{ |
|||
path = objResult.ToString(); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
string s = e.Message; |
|||
//this.label3.Text = "朋友,获取程序路径失败!";
|
|||
} |
|||
return path; |
|||
} |
|||
|
|||
/**/ |
|||
/// <summary>
|
|||
/// 写入日志文件
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
public void WriteRecordToFile(string programCode, string time) |
|||
{ |
|||
try |
|||
{ |
|||
string fpath = Directory.GetCurrentDirectory() + "\\record\\"; |
|||
if (!Directory.Exists(fpath)) |
|||
{ |
|||
DirectoryInfo directoryInfo = new DirectoryInfo(fpath); |
|||
directoryInfo.Create(); |
|||
} |
|||
|
|||
string fname = Directory.GetCurrentDirectory() + "\\record\\Record.txt"; |
|||
|
|||
/**/ |
|||
///定义文件信息对象
|
|||
///
|
|||
FileInfo finfo = new FileInfo(fname); |
|||
if (!finfo.Exists) |
|||
{ |
|||
FileStream fs = new FileStream(fname, FileMode.Create, FileAccess.Write); |
|||
//fs = File.Create(fname);
|
|||
fs.Close(); |
|||
finfo = new FileInfo(fname); |
|||
} |
|||
//finfo.AppendText();
|
|||
/**/ |
|||
///创建只写文件流
|
|||
|
|||
using (FileStream fs = finfo.OpenWrite()) |
|||
{ |
|||
/**/ |
|||
///根据上面创建的文件流创建写数据流
|
|||
StreamWriter w = new StreamWriter(fs); |
|||
|
|||
/**/ |
|||
///设置写数据流的起始位置为文件流的末尾
|
|||
w.BaseStream.Seek(0, SeekOrigin.End); |
|||
/**/ |
|||
///写入“Log Entry : ”
|
|||
///
|
|||
if (finfo.Length > 10) |
|||
{ |
|||
w.Write(","); |
|||
} |
|||
string wir = "{\"ProgramCode\": \"" + programCode + "\",\"Time\": " + time + ",\"PlayTime\":\"" + DateTime.Now.ToString("G") + "\" }"; |
|||
w.Write(wir); |
|||
/**/ |
|||
///写入当前系统时间并换行
|
|||
// w.Write("{0} {1} \n\r", DateTime.Now.ToLongTimeString(),DateTime.Now.ToLongDateString());
|
|||
/**/ |
|||
///写入日志内容并换行
|
|||
// w.Write(input + "\n\r");
|
|||
/**/ |
|||
///写入------------------------------------“并换行
|
|||
// w.Write("------------------------------------\n\r");
|
|||
/**/ |
|||
///清空缓冲区内容,并把缓冲区内容写入基础流
|
|||
w.Flush(); |
|||
/**/ |
|||
///关闭写数据流
|
|||
w.Close(); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
WriteLogFile(e.Message, "11111111"); |
|||
} |
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,86 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
/// <summary>
|
|||
/// 公共类库
|
|||
/// </summary>
|
|||
public class CommonLib |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 日期转换为时间戳(时间戳单位秒)
|
|||
/// </summary>
|
|||
/// <param name="time"></param>
|
|||
/// <returns></returns>
|
|||
public static long ConvertToTimeStamp(DateTime time) |
|||
{ |
|||
DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); |
|||
return (long)(time.AddHours(-8) - Jan1st1970).TotalSeconds; |
|||
} |
|||
/// <summary>
|
|||
/// 获取当前时间戳
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public static long CurrentTime() |
|||
{ |
|||
DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); |
|||
return (long)(DateTime.Now.AddHours(-8) - Jan1st1970).TotalSeconds; |
|||
} |
|||
/// <summary>
|
|||
/// 时间戳转换为日期(时间戳/单位秒)
|
|||
/// </summary>
|
|||
/// <param name="timeStamp"></param>
|
|||
/// <returns></returns>
|
|||
public static DateTime ConvertToDateTime(long timeStamp) |
|||
{ |
|||
var start = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); |
|||
return start.AddMilliseconds(timeStamp).AddHours(8); |
|||
} |
|||
/// <summary>
|
|||
/// 生成随机数字
|
|||
/// </summary>
|
|||
/// <param name="Length">生成长度</param>
|
|||
/// <param name="Sleep">是否要在生成前将当前线程阻止以避免重复</param>
|
|||
public static string Number(int Length, bool Sleep) |
|||
{ |
|||
if (Sleep) System.Threading.Thread.Sleep(3); |
|||
string result = ""; |
|||
System.Random random = new Random(); |
|||
for (int i = 0; i < Length; i++) |
|||
{ |
|||
result += random.Next(10).ToString(); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 解密(反转再base64解码),常规配置,例如密码
|
|||
/// </summary>
|
|||
/// <param name="str"></param>
|
|||
/// <returns></returns>
|
|||
public static string StringDecode(string str) |
|||
{ |
|||
string result = string.Empty; |
|||
try |
|||
{ |
|||
if (!string.IsNullOrEmpty(str)) |
|||
{ |
|||
char[] arr = str.ToCharArray(); |
|||
Array.Reverse(arr); |
|||
result = Encoding.UTF8.GetString(Convert.FromBase64String(new string(arr))); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
|
|||
} |
|||
return result; |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,539 @@ |
|||
using Microsoft.Win32; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.Linq; |
|||
using System.Management; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
class DeviceInfo |
|||
{ |
|||
/// <summary>
|
|||
/// 获取硬盘容量
|
|||
/// </summary>
|
|||
public string GetDiskSize() |
|||
{ |
|||
string result = string.Empty; |
|||
StringBuilder sb = new StringBuilder(); |
|||
try |
|||
{ |
|||
string hdId = string.Empty; |
|||
ManagementClass hardDisk = new ManagementClass(WindowsAPIType.win32_DiskDrive.ToString()); |
|||
ManagementObjectCollection hardDiskC = hardDisk.GetInstances(); |
|||
foreach (ManagementObject m in hardDiskC) |
|||
{ |
|||
long capacity = Convert.ToInt64(m[WindowsAPIKeys.Size.ToString()].ToString()); |
|||
sb.Append(CommonUtlity.ToGB(capacity, 1000.0) + "+"); |
|||
} |
|||
result = sb.ToString().TrimEnd('+'); |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return result; |
|||
} |
|||
|
|||
} |
|||
public class CommonUtlity |
|||
{ |
|||
/// <summary>
|
|||
/// 将字节转换为GB
|
|||
/// </summary>
|
|||
/// <param name="size">字节值</param>
|
|||
/// <param name="mod">除数,硬盘除以1000,内存除以1024</param>
|
|||
/// <returns></returns>
|
|||
public static string ToGB(double size, double mod) |
|||
{ |
|||
String[] units = new String[] { "B", "KB", "MB", "GB", "TB", "PB" }; |
|||
int i = 0; |
|||
while (size >= mod) |
|||
{ |
|||
size /= mod; |
|||
i++; |
|||
} |
|||
return Math.Round(size) + units[i]; |
|||
} |
|||
} |
|||
/// <summary>
|
|||
/// windows api 名称
|
|||
/// </summary>
|
|||
public enum WindowsAPIType |
|||
{ |
|||
/// <summary>
|
|||
/// 内存
|
|||
/// </summary>
|
|||
Win32_PhysicalMemory, |
|||
/// <summary>
|
|||
/// cpu
|
|||
/// </summary>
|
|||
Win32_Processor, |
|||
/// <summary>
|
|||
/// 硬盘
|
|||
/// </summary>
|
|||
win32_DiskDrive, |
|||
/// <summary>
|
|||
/// 电脑型号
|
|||
/// </summary>
|
|||
Win32_ComputerSystemProduct, |
|||
/// <summary>
|
|||
/// 分辨率
|
|||
/// </summary>
|
|||
Win32_DesktopMonitor, |
|||
/// <summary>
|
|||
/// 显卡
|
|||
/// </summary>
|
|||
Win32_VideoController, |
|||
/// <summary>
|
|||
/// 操作系统
|
|||
/// </summary>
|
|||
Win32_OperatingSystem |
|||
|
|||
} |
|||
|
|||
public enum WindowsAPIKeys |
|||
{ |
|||
/// <summary>
|
|||
/// 名称
|
|||
/// </summary>
|
|||
Name, |
|||
/// <summary>
|
|||
/// 显卡芯片
|
|||
/// </summary>
|
|||
VideoProcessor, |
|||
/// <summary>
|
|||
/// 显存大小
|
|||
/// </summary>
|
|||
AdapterRAM, |
|||
/// <summary>
|
|||
/// 分辨率宽
|
|||
/// </summary>
|
|||
ScreenWidth, |
|||
/// <summary>
|
|||
/// 分辨率高
|
|||
/// </summary>
|
|||
ScreenHeight, |
|||
/// <summary>
|
|||
/// 电脑型号
|
|||
/// </summary>
|
|||
Version, |
|||
/// <summary>
|
|||
/// 硬盘容量
|
|||
/// </summary>
|
|||
Size, |
|||
/// <summary>
|
|||
/// 内存容量
|
|||
/// </summary>
|
|||
Capacity, |
|||
/// <summary>
|
|||
/// cpu核心数
|
|||
/// </summary>
|
|||
NumberOfCores |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 电脑信息类 单例
|
|||
/// </summary>
|
|||
public class Computer |
|||
{ |
|||
private static Computer _instance; |
|||
private static readonly object _lock = new object(); |
|||
//private Computer()
|
|||
//{ }
|
|||
//public static Computer CreateComputer()
|
|||
//{
|
|||
// if (_instance == null)
|
|||
// {
|
|||
// lock (_lock)
|
|||
// {
|
|||
// if (_instance == null)
|
|||
// {
|
|||
// _instance = new Computer();
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
// return _instance;
|
|||
//}
|
|||
/// <summary>
|
|||
/// 查找cpu的名称,主频, 核心数
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public Tuple<string, string> GetCPU() |
|||
{ |
|||
Tuple<string, string> result = null; |
|||
try |
|||
{ |
|||
string str = string.Empty; |
|||
ManagementClass mcCPU = new ManagementClass(WindowsAPIType.Win32_Processor.ToString()); |
|||
ManagementObjectCollection mocCPU = mcCPU.GetInstances(); |
|||
foreach (ManagementObject m in mocCPU) |
|||
{ |
|||
string name = m[WindowsAPIKeys.Name.ToString()].ToString(); |
|||
string[] parts = name.Split('@'); |
|||
result = new Tuple<string, string>(parts[0].Split('-')[0] + "处理器", parts[1]); |
|||
break; |
|||
} |
|||
|
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return result; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 获取cpu核心数
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
public string GetCPU_Count() |
|||
{ |
|||
string str = "查询失败"; |
|||
try |
|||
{ |
|||
int coreCount = 0; |
|||
foreach (var item in new System.Management.ManagementObjectSearcher("Select * from " + |
|||
WindowsAPIType.Win32_Processor.ToString()).Get()) |
|||
{ |
|||
coreCount += int.Parse(item[WindowsAPIKeys.NumberOfCores.ToString()].ToString()); |
|||
} |
|||
if (coreCount == 2) |
|||
{ |
|||
return "双核"; |
|||
} |
|||
str = coreCount.ToString() + "核"; |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return str; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取系统内存大小
|
|||
/// </summary>
|
|||
/// <returns>内存大小(单位M)</returns>
|
|||
public string GetPhisicalMemory() |
|||
{ |
|||
ManagementObjectSearcher searcher = new ManagementObjectSearcher(); //用于查询一些如系统信息的管理对象
|
|||
searcher.Query = new SelectQuery(WindowsAPIType.Win32_PhysicalMemory.ToString(), "", |
|||
new string[] { WindowsAPIKeys.Capacity.ToString() });//设置查询条件
|
|||
ManagementObjectCollection collection = searcher.Get(); //获取内存容量
|
|||
ManagementObjectCollection.ManagementObjectEnumerator em = collection.GetEnumerator(); |
|||
|
|||
long capacity = 0; |
|||
while (em.MoveNext()) |
|||
{ |
|||
ManagementBaseObject baseObj = em.Current; |
|||
if (baseObj.Properties[WindowsAPIKeys.Capacity.ToString()].Value != null) |
|||
{ |
|||
try |
|||
{ |
|||
capacity += long.Parse(baseObj.Properties[WindowsAPIKeys.Capacity.ToString()].Value.ToString()); |
|||
} |
|||
catch |
|||
{ |
|||
return "查询失败"; |
|||
} |
|||
} |
|||
} |
|||
return CommonUtlity.ToGB((double)capacity, 1024.0); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取硬盘容量
|
|||
/// </summary>
|
|||
public string GetDiskSize() |
|||
{ |
|||
string result = string.Empty; |
|||
StringBuilder sb = new StringBuilder(); |
|||
try |
|||
{ |
|||
string hdId = string.Empty; |
|||
ManagementClass hardDisk = new ManagementClass(WindowsAPIType.win32_DiskDrive.ToString()); |
|||
ManagementObjectCollection hardDiskC = hardDisk.GetInstances(); |
|||
foreach (ManagementObject m in hardDiskC) |
|||
{ |
|||
long capacity = Convert.ToInt64(m[WindowsAPIKeys.Size.ToString()].ToString()); |
|||
sb.Append(CommonUtlity.ToGB(capacity, 1000.0) + "+"); |
|||
} |
|||
result = sb.ToString().TrimEnd('+'); |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return result; |
|||
} |
|||
/// <summary>
|
|||
/// 电脑型号
|
|||
/// </summary>
|
|||
public string GetVersion() |
|||
{ |
|||
string str = "查询失败"; |
|||
try |
|||
{ |
|||
string hdId = string.Empty; |
|||
ManagementClass hardDisk = new ManagementClass(WindowsAPIType.Win32_ComputerSystemProduct.ToString()); |
|||
ManagementObjectCollection hardDiskC = hardDisk.GetInstances(); |
|||
foreach (ManagementObject m in hardDiskC) |
|||
{ |
|||
str = m[WindowsAPIKeys.Version.ToString()].ToString(); break; |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return str; |
|||
} |
|||
/// <summary>
|
|||
/// 获取分辨率
|
|||
/// </summary>
|
|||
public string GetFenbianlv() |
|||
{ |
|||
string result = "1920*1080"; |
|||
try |
|||
{ |
|||
string hdId = string.Empty; |
|||
ManagementClass hardDisk = new ManagementClass(WindowsAPIType.Win32_DesktopMonitor.ToString()); |
|||
ManagementObjectCollection hardDiskC = hardDisk.GetInstances(); |
|||
foreach (ManagementObject m in hardDiskC) |
|||
{ |
|||
result = m[WindowsAPIKeys.ScreenWidth.ToString()].ToString() + "*" + |
|||
m[WindowsAPIKeys.ScreenHeight.ToString()].ToString(); |
|||
break; |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return result; |
|||
} |
|||
/// <summary>
|
|||
/// 显卡 芯片,显存大小
|
|||
/// </summary>
|
|||
public Tuple<string, string> GetVideoController() |
|||
{ |
|||
Tuple<string, string> result = null; |
|||
try |
|||
{ |
|||
|
|||
ManagementClass hardDisk = new ManagementClass(WindowsAPIType.Win32_VideoController.ToString()); |
|||
ManagementObjectCollection hardDiskC = hardDisk.GetInstances(); |
|||
foreach (ManagementObject m in hardDiskC) |
|||
{ |
|||
result = new Tuple<string, string>(m[WindowsAPIKeys.VideoProcessor.ToString()].ToString() |
|||
.Replace("Family", ""), CommonUtlity.ToGB(Convert.ToInt64(m[WindowsAPIKeys.AdapterRAM.ToString()].ToString()), 1024.0)); |
|||
break; |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 操作系统版本
|
|||
/// </summary>
|
|||
public string GetOS_Version() |
|||
{ |
|||
string str = "Windows 10"; |
|||
try |
|||
{ |
|||
string hdId = string.Empty; |
|||
ManagementClass hardDisk = new ManagementClass(WindowsAPIType.Win32_OperatingSystem.ToString()); |
|||
ManagementObjectCollection hardDiskC = hardDisk.GetInstances(); |
|||
foreach (ManagementObject m in hardDiskC) |
|||
{ |
|||
str = m[WindowsAPIKeys.Name.ToString()].ToString().Split('|')[0].Replace("Microsoft", ""); |
|||
break; |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
|
|||
} |
|||
return str; |
|||
} |
|||
|
|||
|
|||
[DllImport("Kernel32.dll")] |
|||
public static extern void GlobalMemoryStatus(ref MEMORY_INFO meminfo); |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public struct MEMORY_INFO |
|||
{ |
|||
public uint dwLength; |
|||
public uint dwMemoryLoad; |
|||
public uint dwTotalPhys; |
|||
public uint dwAvailPhys; |
|||
public uint dwTotalPageFile; |
|||
public uint dwAvailPageFile; |
|||
public uint dwTotalVirtual; |
|||
public uint dwAvailVirtual; |
|||
} |
|||
|
|||
|
|||
MEMORY_INFO MemInfo = new MEMORY_INFO(); |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 获取当前CPU温度、内存使用率
|
|||
/// </summary>
|
|||
public string GetNow_WindowsState() |
|||
{ |
|||
string str = ""; |
|||
Double CPUtprt = 0; |
|||
ManagementObjectSearcher mos = new ManagementObjectSearcher(@"root\WMI", @"Select * From MSAcpi_ThermalZoneTemperature"); |
|||
foreach (ManagementObject mo in mos.Get()) |
|||
{ |
|||
CPUtprt = Convert.ToDouble(Convert.ToDouble(mo.GetPropertyValue("CurrentTemperature").ToString()) - 2732) / 10; |
|||
|
|||
} |
|||
str = "CPU温度:" + CPUtprt.ToString() + "℃ 内存使用率:" + MemInfo.dwMemoryLoad.ToString() + "%"; |
|||
return str; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 获取当前Windows版本、序列号
|
|||
/// </summary>
|
|||
public string WindowsInfo() |
|||
{ |
|||
RegistryKey rk; |
|||
rk = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion"); |
|||
string s = ""; |
|||
if (rk.GetValue("ProductName") != null) |
|||
{ |
|||
s = "当前操作系统版本:" + rk.GetValue("ProductName").ToString(); |
|||
} |
|||
else |
|||
return ""; |
|||
|
|||
if (rk.GetValue("CSDVersion") != null) |
|||
{ |
|||
s = s + "\r\n" + rk.GetValue("CSDVersion").ToString(); |
|||
} |
|||
if (rk.GetValue("ProductId") != null) |
|||
{ |
|||
s = s + "\r\n当前操作系统安装序列号:\r\n" + rk.GetValue("ProductId").ToString(); |
|||
} |
|||
if (rk.GetValue("CurrentBuildNumber") != null) |
|||
{ |
|||
s = s + "\r\n当前系统版本号:" + rk.GetValue("CurrentBuildNumber").ToString(); |
|||
} |
|||
|
|||
rk.Close(); |
|||
return s; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取操作系统位数(x32/64)
|
|||
/// </summary>
|
|||
/// <returns>int</returns>
|
|||
public static int GetOSBit() |
|||
{ |
|||
try |
|||
{ |
|||
string addressWidth = String.Empty; |
|||
ConnectionOptions mConnOption = new ConnectionOptions(); |
|||
ManagementScope mMs = new ManagementScope(@"\\localhost", mConnOption); |
|||
ObjectQuery mQuery = new ObjectQuery("select AddressWidth from Win32_Processor"); |
|||
ManagementObjectSearcher mSearcher = new ManagementObjectSearcher(mMs, mQuery); |
|||
ManagementObjectCollection mObjectCollection = mSearcher.Get(); |
|||
foreach (ManagementObject mObject in mObjectCollection) |
|||
{ |
|||
addressWidth = mObject["AddressWidth"].ToString(); |
|||
} |
|||
return Int32.Parse(addressWidth); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Console.WriteLine(ex.ToString()); |
|||
return 32; |
|||
} |
|||
} |
|||
|
|||
|
|||
string GetWindowsLanguage() |
|||
{ |
|||
string lg = ""; |
|||
|
|||
int lcid = System.Globalization.CultureInfo.CurrentCulture.LCID; |
|||
string LanguageName = System.Globalization.CultureInfo.CurrentCulture.NativeName; |
|||
string LangName = System.Globalization.RegionInfo.CurrentRegion.NativeName; |
|||
System.Console.WriteLine("Lcid:" + lcid.ToString()); |
|||
lg = "Lcid:" + lcid.ToString(); |
|||
System.Console.WriteLine("区域语言:" + LanguageName); |
|||
lg += "区域语言:" + LanguageName; |
|||
System.Console.WriteLine("区域语言2:" + LangName); |
|||
lg += "区域语言2:" + LangName; |
|||
return lg; |
|||
//try
|
|||
//{
|
|||
// Process MyProcess = new Process();
|
|||
// //设定程序名
|
|||
// MyProcess.StartInfo.FileName = "cmd.exe";
|
|||
|
|||
// //关闭Shell的使用
|
|||
// MyProcess.StartInfo.UseShellExecute = false;
|
|||
// //重定向标准输入
|
|||
// MyProcess.StartInfo.RedirectStandardInput = true;
|
|||
// //重定向标准输出
|
|||
// MyProcess.StartInfo.RedirectStandardOutput = true;
|
|||
// //重定向错误输出
|
|||
// MyProcess.StartInfo.RedirectStandardError = true;
|
|||
// //设置不显示窗口
|
|||
// MyProcess.StartInfo.CreateNoWindow = true;
|
|||
// MyProcess.StartInfo.Arguments = "/c C:\\Windows\\System32\\cmd.exe";
|
|||
|
|||
|
|||
|
|||
// string cmdtext = string.Empty;
|
|||
// cmdtext = "slmgr.vbs /xpr" ; //关机
|
|||
|
|||
// Console.WriteLine(cmdtext);
|
|||
// //执行VER命令
|
|||
// MyProcess.Start();
|
|||
// MyProcess.StandardInput.WriteLine(cmdtext);
|
|||
// //MessageBox.Show(MyProcess.StandardOutput.ReadToEnd());
|
|||
// //MessageBox.Show(MyProcess.StandardError.ReadToEnd());
|
|||
// string output = "";
|
|||
// char[] outl = new char[2048];
|
|||
// string error = "";
|
|||
// using (System.IO.StreamReader myOutput = MyProcess.StandardOutput)
|
|||
// {
|
|||
// myOutput.Read(outl, 0, 2048);
|
|||
// output = new string(outl);
|
|||
// log.WriteLogFile(output, "cmdexelog");
|
|||
|
|||
// }
|
|||
// using (System.IO.StreamReader myError = MyProcess.StandardError)
|
|||
// {
|
|||
|
|||
// myError.Read(outl, 0, 1024);
|
|||
// error = new string(outl);
|
|||
// log.WriteLogFile(error, "cmdexelog");
|
|||
// }
|
|||
// }
|
|||
// }
|
|||
//}
|
|||
//catch (Exception ex)
|
|||
//{
|
|||
// log.WriteLogFile(ex.ToString());
|
|||
//}
|
|||
|
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
/// <summary>
|
|||
/// 文件类型判断
|
|||
/// </summary>
|
|||
internal sealed class FileTypeJudgment |
|||
{ |
|||
//实现类型判断的接口
|
|||
public IJudgeFileType TypeTarget { get; set; } |
|||
|
|||
//返回判断结果
|
|||
public bool Judge(string ext) |
|||
{ |
|||
return this.TypeTarget.JudgeFileType(ext); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
/// <summary>
|
|||
/// 接口用于判断文件类型
|
|||
/// </summary>
|
|||
interface IJudgeFileType |
|||
{ |
|||
bool JudgeFileType(string ext); |
|||
} |
|||
} |
|||
@ -0,0 +1,795 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
static class IatNativeMethods |
|||
{ |
|||
[DllImport("msc_x64.dll", CharSet = CharSet.Ansi)] |
|||
public extern static int MSPLogin(string usr, string pwd, string @params); |
|||
|
|||
[DllImport("msc_x64.dll", CharSet = CharSet.Ansi)] |
|||
public extern static IntPtr QISRSessionBegin(string grammarList, string @params, ref int errorCode); |
|||
|
|||
[DllImport("msc_x64.dll", CharSet = CharSet.Ansi)] |
|||
public extern static int QISRAudioWrite(IntPtr sessionID, byte[] waveData, uint waveLen, int audioStatus, |
|||
ref int epStatus, ref int recogStatus); |
|||
[DllImport("msc_x64.dll", CharSet = CharSet.Ansi)] |
|||
public extern static int QISRAudioWrite(IntPtr sessionID, IntPtr waveData, uint waveLen, int audioStatus, |
|||
ref int epStatus, ref int recogStatus); |
|||
[DllImport("msc_x64.dll", CharSet = CharSet.Ansi)] |
|||
public extern static IntPtr QISRGetResult(IntPtr sessionID, ref int rsltStatus, int waitTime, ref int errorCode); |
|||
|
|||
[DllImport("msc_x64.dll", CharSet = CharSet.Ansi)] |
|||
public extern static int QISRSessionEnd(IntPtr sessionID, string hints); |
|||
|
|||
[DllImport("msc_x64.dll")] |
|||
public extern static int MSPLogout(); |
|||
|
|||
public static string user = ""; |
|||
public static string pwd = ""; |
|||
public static string loginparam = "appid = 5c2055f8"; |
|||
public static IntPtr session_id = IntPtr.Zero; |
|||
public static int FRAME_LEN = 640; |
|||
/// <summary>
|
|||
/// 初始化语音账号
|
|||
/// </summary>
|
|||
public static void initVoice() |
|||
{ |
|||
int ret = IatNativeMethods.MSPLogin(user, pwd, loginparam); |
|||
if ((int)Errors.MSP_SUCCESS != ret) |
|||
{ |
|||
Console.WriteLine("MSPLogin failed, error code is:" + ret); |
|||
} |
|||
} |
|||
/// <summary>
|
|||
/// 实时录制识别
|
|||
/// </summary>
|
|||
/// <param name="audio_path"></param>
|
|||
/// <param name="session_begin_params"></param>
|
|||
/// <returns></returns>
|
|||
public static string audio_iat(byte[] audio_content, int aud_stat, int ep_stat, int rec_stat, int errcode) |
|||
{ |
|||
if (audio_content == null || audio_content.Length == 0) |
|||
return ""; |
|||
StringBuilder result = new StringBuilder();//存储最终识别的结果
|
|||
//var aud_stat = AudioStatus.MSP_AUDIO_SAMPLE_CONTINUE;//音频状态
|
|||
//var ep_stat = EpStatus.MSP_EP_LOOKING_FOR_SPEECH;//端点状态
|
|||
//var rec_stat = RecogStatus.MSP_REC_STATUS_SUCCESS;//识别状态
|
|||
//int errcode = (int)Errors.MSP_SUCCESS;
|
|||
//byte[] audio_content; //用来存储音频文件的二进制数据
|
|||
int totalLength = 0;//用来记录总的识别后的结果的长度,判断是否超过缓存最大值
|
|||
//try
|
|||
//{
|
|||
// audio_content = System.IO.File.ReadAllBytes(audio_path);
|
|||
// //SoundPlayer player = new SoundPlayer(audio_path);
|
|||
// //player.Play();
|
|||
//}
|
|||
//catch (Exception e)
|
|||
//{
|
|||
// //Console.WriteLine(e);
|
|||
// System.Diagnostics.Debug.WriteLine(e.Message);
|
|||
// audio_content = null;
|
|||
//}
|
|||
try |
|||
{ |
|||
if (audio_content == null) |
|||
throw new Exception("没有读取到任何内容"); |
|||
|
|||
|
|||
int res = IatNativeMethods.QISRAudioWrite(session_id, audio_content, (uint)audio_content.Length, AudioStatus.MSP_AUDIO_SAMPLE_FIRST, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
return ("写入识别的音频失败!" + res); |
|||
res = IatNativeMethods.QISRAudioWrite(session_id, null, 0, AudioStatus.MSP_AUDIO_SAMPLE_LAST, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
return ("写入音频失败!" + res); |
|||
while (RecogStatus.MSP_REC_STATUS_COMPLETE != rec_stat) |
|||
{ |
|||
IntPtr now_result = IatNativeMethods.QISRGetResult(session_id, ref rec_stat, 0, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
return ("获取结果失败:" + errcode); |
|||
if (now_result != null) |
|||
{ |
|||
int length = now_result.ToString().Length; |
|||
totalLength += length; |
|||
if (totalLength > 4096) |
|||
return ("缓存空间不够" + totalLength); |
|||
result.Append(Marshal.PtrToStringAnsi(now_result)); |
|||
} |
|||
Thread.Sleep(150);//防止频繁占用cpu
|
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
System.Diagnostics.Debug.WriteLine(ex.Message); |
|||
} |
|||
finally |
|||
{ |
|||
Console.WriteLine("语音听写结束"); |
|||
Console.WriteLine("听写结果: "); |
|||
Console.WriteLine(result); |
|||
int ret = IatNativeMethods.QISRSessionEnd(session_id, "normal end"); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
result.Append("QISRSessionEnd failed, error code is: %d" + ret); |
|||
} |
|||
} |
|||
return result.ToString(); |
|||
} |
|||
/// <summary>
|
|||
/// 本地文件识别
|
|||
/// </summary>
|
|||
/// <param name="audio_path"></param>
|
|||
/// <param name="session_begin_params"></param>
|
|||
/// <returns></returns>
|
|||
public static string localaudio_iat(string audio_path, string session_begin_params = "sub=iat,domain=iat,language=zh_cn,accent=mandarin,sample_rate=16000,result_type=plain,result_encoding=gb2312") |
|||
{ |
|||
if (audio_path == null || audio_path == "") |
|||
return ""; |
|||
IntPtr session_id = IntPtr.Zero; |
|||
StringBuilder result = new StringBuilder();//存储最终识别的结果
|
|||
var aud_stat = AudioStatus.MSP_AUDIO_SAMPLE_CONTINUE;//音频状态
|
|||
var ep_stat = EpStatus.MSP_EP_LOOKING_FOR_SPEECH;//端点状态
|
|||
var rec_stat = RecogStatus.MSP_REC_STATUS_SUCCESS;//识别状态
|
|||
int errcode = (int)Errors.MSP_SUCCESS; |
|||
byte[] audio_content; //用来存储音频文件的二进制数据
|
|||
int totalLength = 0;//用来记录总的识别后的结果的长度,判断是否超过缓存最大值
|
|||
try |
|||
{ |
|||
audio_content = System.IO.File.ReadAllBytes(audio_path); |
|||
//SoundPlayer player = new SoundPlayer(audio_path);
|
|||
//player.Play();
|
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
//Console.WriteLine(e);
|
|||
System.Diagnostics.Debug.WriteLine(e.Message); |
|||
audio_content = null; |
|||
} |
|||
try |
|||
{ |
|||
if (audio_content == null) |
|||
throw new Exception("没有读取到任何内容"); |
|||
//Console.WriteLine("开始进行语音听写.......");
|
|||
session_id = IatNativeMethods.QISRSessionBegin(null, session_begin_params, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
return ("开始一次语音识别失败!"); |
|||
int res = IatNativeMethods.QISRAudioWrite(session_id, audio_content, (uint)audio_content.Length, AudioStatus.MSP_AUDIO_SAMPLE_FIRST, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
return ("写入识别的音频失败!" + res); |
|||
res = IatNativeMethods.QISRAudioWrite(session_id, null, 0, AudioStatus.MSP_AUDIO_SAMPLE_LAST, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
return ("写入音频失败!" + res); |
|||
while (RecogStatus.MSP_REC_STATUS_COMPLETE != rec_stat) |
|||
{ |
|||
IntPtr now_result = IatNativeMethods.QISRGetResult(session_id, ref rec_stat, 0, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
return ("获取结果失败:" + errcode); |
|||
if (now_result != null) |
|||
{ |
|||
int length = now_result.ToString().Length; |
|||
totalLength += length; |
|||
if (totalLength > 4096) |
|||
return ("缓存空间不够" + totalLength); |
|||
result.Append(Marshal.PtrToStringAnsi(now_result)); |
|||
} |
|||
Thread.Sleep(150);//防止频繁占用cpu
|
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
System.Diagnostics.Debug.WriteLine(ex.Message); |
|||
} |
|||
finally |
|||
{ |
|||
Console.WriteLine("语音听写结束"); |
|||
Console.WriteLine("听写结果: "); |
|||
Console.WriteLine(result); |
|||
int ret = IatNativeMethods.QISRSessionEnd(session_id, "normal end"); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
result.Append("QISRSessionEnd failed, error code is: %d" + ret); |
|||
} |
|||
} |
|||
return result.ToString(); |
|||
} |
|||
|
|||
} |
|||
|
|||
public class AudioStatus |
|||
{ |
|||
|
|||
public static int MSP_AUDIO_SAMPLE_INIT = 0; |
|||
public static int MSP_AUDIO_SAMPLE_FIRST = 1; |
|||
public static int MSP_AUDIO_SAMPLE_CONTINUE = 2; |
|||
public static int MSP_AUDIO_SAMPLE_LAST = 4; |
|||
} |
|||
|
|||
public class EpStatus |
|||
{ |
|||
public static int MSP_EP_LOOKING_FOR_SPEECH = 0; |
|||
public static int MSP_EP_IN_SPEECH = 1; |
|||
public static int MSP_EP_AFTER_SPEECH = 3; |
|||
public static int MSP_EP_TIMEOUT = 4; |
|||
public static int MSP_EP_ERROR = 5; |
|||
public static int MSP_EP_MAX_SPEECH = 6; |
|||
public static int MSP_EP_IDLE = 7; |
|||
} |
|||
public class RecogStatus |
|||
{ |
|||
public static int MSP_REC_STATUS_SUCCESS = 0; |
|||
public static int MSP_REC_STATUS_NO_MATCH = 1; |
|||
public static int MSP_REC_STATUS_INCOMPLETE = 2; |
|||
public static int MSP_REC_STATUS_NON_SPEECH_DETECTED = 3; |
|||
public static int MSP_REC_STATUS_SPEECH_DETECTED = 4; |
|||
public static int MSP_REC_STATUS_COMPLETE = 5; |
|||
public static int MSP_REC_STATUS_MAX_CPU_TIME = 6; |
|||
public static int MSP_REC_STATUS_MAX_SPEECH = 7; |
|||
public static int MSP_REC_STATUS_STOPPED = 8; |
|||
public static int MSP_REC_STATUS_REJECTED = 9; |
|||
public static int MSP_REC_STATUS_NO_SPEECH_FOUND = 10; |
|||
public static int MSP_REC_STATUS_FAILURE = MSP_REC_STATUS_NO_MATCH; |
|||
} |
|||
|
|||
public enum Errors |
|||
{ |
|||
MSP_SUCCESS = 0, |
|||
MSP_ERROR_FAIL = -1, |
|||
MSP_ERROR_EXCEPTION = -2, |
|||
|
|||
/* General errors 10100(0x2774) */ |
|||
MSP_ERROR_GENERAL = 10100, /* 0x2774 */ |
|||
MSP_ERROR_OUT_OF_MEMORY = 10101, /* 0x2775 */ |
|||
MSP_ERROR_FILE_NOT_FOUND = 10102, /* 0x2776 */ |
|||
MSP_ERROR_NOT_SUPPORT = 10103, /* 0x2777 */ |
|||
MSP_ERROR_NOT_IMPLEMENT = 10104, /* 0x2778 */ |
|||
MSP_ERROR_ACCESS = 10105, /* 0x2779 */ |
|||
MSP_ERROR_INVALID_PARA = 10106, /* 0x277A */ /* 缺少参数 */ |
|||
MSP_ERROR_INVALID_PARA_VALUE = 10107, /* 0x277B */ /* 无效参数值 */ |
|||
MSP_ERROR_INVALID_HANDLE = 10108, /* 0x277C */ |
|||
MSP_ERROR_INVALID_DATA = 10109, /* 0x277D */ |
|||
MSP_ERROR_NO_LICENSE = 10110, /* 0x277E */ /* 引擎授权不足 */ |
|||
MSP_ERROR_NOT_INIT = 10111, /* 0x277F */ /* 引擎未初始化,可能是引擎崩溃 */ |
|||
MSP_ERROR_NULL_HANDLE = 10112, /* 0x2780 */ |
|||
MSP_ERROR_OVERFLOW = 10113, /* 0x2781 */ /* 单用户下模型数超上限(10个), */ |
|||
/* 只出现在测试时对一个用户进行并发注册 */ |
|||
MSP_ERROR_TIME_OUT = 10114, /* 0x2782 */ /* 超时 */ |
|||
MSP_ERROR_OPEN_FILE = 10115, /* 0x2783 */ |
|||
MSP_ERROR_NOT_FOUND = 10116, /* 0x2784 */ /* 数据库中模型不存在 */ |
|||
MSP_ERROR_NO_ENOUGH_BUFFER = 10117, /* 0x2785 */ |
|||
MSP_ERROR_NO_DATA = 10118, /* 0x2786 */ /* 从客户端读音频或从引擎段获取结果时无数据 */ |
|||
MSP_ERROR_NO_MORE_DATA = 10119, /* 0x2787 */ |
|||
MSP_ERROR_NO_RESPONSE_DATA = 10120, /* 0x2788 */ |
|||
MSP_ERROR_ALREADY_EXIST = 10121, /* 0x2789 */ /* 数据库中模型已存在 */ |
|||
MSP_ERROR_LOAD_MODULE = 10122, /* 0x278A */ |
|||
MSP_ERROR_BUSY = 10123, /* 0x278B */ |
|||
MSP_ERROR_INVALID_CONFIG = 10124, /* 0x278C */ |
|||
MSP_ERROR_VERSION_CHECK = 10125, /* 0x278D */ |
|||
MSP_ERROR_CANCELED = 10126, /* 0x278E */ |
|||
MSP_ERROR_INVALID_MEDIA_TYPE = 10127, /* 0x278F */ |
|||
MSP_ERROR_CONFIG_INITIALIZE = 10128, /* 0x2790 */ |
|||
MSP_ERROR_CREATE_HANDLE = 10129, /* 0x2791 */ |
|||
MSP_ERROR_CODING_LIB_NOT_LOAD = 10130, /* 0x2792 */ |
|||
MSP_ERROR_USER_CANCELLED = 10131, /* 0x2793 */ |
|||
MSP_ERROR_INVALID_OPERATION = 10132, /* 0x2794 */ |
|||
MSP_ERROR_MESSAGE_NOT_COMPLETE = 10133, /* 0x2795 */ /* flash */ |
|||
MSP_ERROR_NO_EID = 10134, /* 0x2795 */ |
|||
MSP_ERROE_OVER_REQ = 10135, /* 0x2797 */ /* client Redundancy request */ |
|||
MSP_ERROR_USER_ACTIVE_ABORT = 10136, /* 0x2798 */ /* user abort */ |
|||
MSP_ERROR_BUSY_GRMBUILDING = 10137, /* 0x2799 */ |
|||
MSP_ERROR_BUSY_LEXUPDATING = 10138, /* 0x279A */ |
|||
MSP_ERROR_SESSION_RESET = 10139, /* 0x279B */ /* msc主动终止会话,准备重传 */ |
|||
MSP_ERROR_BOS_TIMEOUT = 10140, /* 0x279C */ /* VAD前端点超时 */ |
|||
MSP_ERROR_STREAM_FILTER = 10141, /* 0X279D */ /* AIUI当前Stream被过滤 */ |
|||
MSP_ERROR_STREAM_CLEAR = 10142, /* 0X279E */ /* AIUI当前Stream被清理 */ |
|||
|
|||
/* Error codes of network 10200(0x27D8)*/ |
|||
MSP_ERROR_NET_GENERAL = 10200, /* 0x27D8 */ |
|||
MSP_ERROR_NET_OPENSOCK = 10201, /* 0x27D9 */ /* Open socket */ |
|||
MSP_ERROR_NET_CONNECTSOCK = 10202, /* 0x27DA */ /* Connect socket */ |
|||
MSP_ERROR_NET_ACCEPTSOCK = 10203, /* 0x27DB */ /* Accept socket */ |
|||
MSP_ERROR_NET_SENDSOCK = 10204, /* 0x27DC */ /* Send socket data */ |
|||
MSP_ERROR_NET_RECVSOCK = 10205, /* 0x27DD */ /* Recv socket data */ |
|||
MSP_ERROR_NET_INVALIDSOCK = 10206, /* 0x27DE */ /* Invalid socket handle */ |
|||
MSP_ERROR_NET_BADADDRESS = 10207, /* 0x27EF */ /* Bad network address */ |
|||
MSP_ERROR_NET_BINDSEQUENCE = 10208, /* 0x27E0 */ /* Bind after listen/connect */ |
|||
MSP_ERROR_NET_NOTOPENSOCK = 10209, /* 0x27E1 */ /* Socket is not opened */ |
|||
MSP_ERROR_NET_NOTBIND = 10210, /* 0x27E2 */ /* Socket is not bind to an address */ |
|||
MSP_ERROR_NET_NOTLISTEN = 10211, /* 0x27E3 */ /* Socket is not listening */ |
|||
MSP_ERROR_NET_CONNECTCLOSE = 10212, /* 0x27E4 */ /* The other side of connection is closed */ |
|||
MSP_ERROR_NET_NOTDGRAMSOCK = 10213, /* 0x27E5 */ /* The socket is not datagram type */ |
|||
MSP_ERROR_NET_DNS = 10214, /* 0x27E6 */ /* domain name is invalid or dns server does not function well */ |
|||
MSP_ERROR_NET_INIT = 10215, /* 0x27E7 */ /* ssl ctx create failed */ |
|||
|
|||
/*nfl error*/ |
|||
MSP_ERROR_NFL_INNER_ERROR = 10216, /* NFL inner error */ |
|||
MSP_ERROR_MSS_TIME_OUT = 10217, /* MSS TIMEOUT */ |
|||
MSP_ERROT_CLIENT_TIME_OUT = 10218, /* CLIENT TIMEOUT */ |
|||
MSP_ERROR_CLIENT_CLOSE = 10219, /* CLIENT CLOSED CONNECTION */ |
|||
|
|||
MSP_ERROR_CLIENT_AREA_CHANGE = 10220, |
|||
MSP_ERROR_NET_SSL_HANDSHAKE = 10221, |
|||
MSP_ERROR_NET_INVALID_ROOT_CERT = 10222, |
|||
MSP_ERROR_NET_INVALID_CLIENT_CERT = 10223, |
|||
MSP_ERROR_NET_INVALID_SERVER_CERT = 10224, |
|||
MSP_ERROR_NET_INVALID_KEY = 10225, |
|||
MSP_ERROR_NET_CERT_VERIFY_FAILED = 10226, |
|||
MSP_ERROR_NET_WOULDBLOCK = 10227, |
|||
MSP_ERROR_NET_NOTBLOCK = 10228, |
|||
|
|||
/* Error codes of mssp message 10300(0x283C) */ |
|||
MSP_ERROR_MSG_GENERAL = 10300, /* 0x283C */ |
|||
MSP_ERROR_MSG_PARSE_ERROR = 10301, /* 0x283D */ |
|||
MSP_ERROR_MSG_BUILD_ERROR = 10302, /* 0x283E */ |
|||
MSP_ERROR_MSG_PARAM_ERROR = 10303, /* 0x283F */ |
|||
MSP_ERROR_MSG_CONTENT_EMPTY = 10304, /* 0x2840 */ |
|||
MSP_ERROR_MSG_INVALID_CONTENT_TYPE = 10305, /* 0x2841 */ |
|||
MSP_ERROR_MSG_INVALID_CONTENT_LENGTH = 10306, /* 0x2842 */ |
|||
MSP_ERROR_MSG_INVALID_CONTENT_ENCODE = 10307, /* 0x2843 */ |
|||
MSP_ERROR_MSG_INVALID_KEY = 10308, /* 0x2844 */ |
|||
MSP_ERROR_MSG_KEY_EMPTY = 10309, /* 0x2845 */ |
|||
MSP_ERROR_MSG_SESSION_ID_EMPTY = 10310, /* 0x2846 */ /* 会话ID为空 */ |
|||
MSP_ERROR_MSG_LOGIN_ID_EMPTY = 10311, /* 0x2847 */ /* 音频序列ID为空 */ |
|||
MSP_ERROR_MSG_SYNC_ID_EMPTY = 10312, /* 0x2848 */ |
|||
MSP_ERROR_MSG_APP_ID_EMPTY = 10313, /* 0x2849 */ |
|||
MSP_ERROR_MSG_EXTERN_ID_EMPTY = 10314, /* 0x284A */ |
|||
MSP_ERROR_MSG_INVALID_CMD = 10315, /* 0x284B */ |
|||
MSP_ERROR_MSG_INVALID_SUBJECT = 10316, /* 0x284C */ |
|||
MSP_ERROR_MSG_INVALID_VERSION = 10317, /* 0x284D */ |
|||
MSP_ERROR_MSG_NO_CMD = 10318, /* 0x284E */ |
|||
MSP_ERROR_MSG_NO_SUBJECT = 10319, /* 0x284F */ |
|||
MSP_ERROR_MSG_NO_VERSION = 10320, /* 0x2850 */ |
|||
MSP_ERROR_MSG_MSSP_EMPTY = 10321, /* 0x2851 */ |
|||
MSP_ERROR_MSG_NEW_RESPONSE = 10322, /* 0x2852 */ |
|||
MSP_ERROR_MSG_NEW_CONTENT = 10323, /* 0x2853 */ |
|||
MSP_ERROR_MSG_INVALID_SESSION_ID = 10324, /* 0x2854 */ /* 无效的会话ID(sid) */ |
|||
MSP_ERROR_MSG_INVALID_CONTENT = 10325, /* 0x2855 */ |
|||
|
|||
/* Error codes of DataBase 10400(0x28A0)*/ |
|||
MSP_ERROR_DB_GENERAL = 10400, /* 0x28A0 */ /* 数据库异常 */ |
|||
MSP_ERROR_DB_EXCEPTION = 10401, /* 0x28A1 */ |
|||
MSP_ERROR_DB_NO_RESULT = 10402, /* 0x28A2 */ /* redis中没有找到会话ID(sid) */ |
|||
MSP_ERROR_DB_INVALID_USER = 10403, /* 0x28A3 */ |
|||
MSP_ERROR_DB_INVALID_PWD = 10404, /* 0x28A4 */ |
|||
MSP_ERROR_DB_CONNECT = 10405, /* 0x28A5 */ |
|||
MSP_ERROR_DB_INVALID_SQL = 10406, /* 0x28A6 */ |
|||
MSP_ERROR_DB_INVALID_APPID = 10407, /* 0x28A7 */ |
|||
MSP_ERROR_DB_NO_UID = 10408, |
|||
|
|||
/* Error codes of Resource 10500(0x2904)*/ |
|||
MSP_ERROR_RES_GENERAL = 10500, /* 0x2904 */ |
|||
MSP_ERROR_RES_LOAD = 10501, /* 0x2905 */ /* Load resource */ |
|||
MSP_ERROR_RES_FREE = 10502, /* 0x2906 */ /* Free resource */ |
|||
MSP_ERROR_RES_MISSING = 10503, /* 0x2907 */ /* Resource File Missing */ |
|||
MSP_ERROR_RES_INVALID_NAME = 10504, /* 0x2908 */ /* Invalid resource file name */ |
|||
MSP_ERROR_RES_INVALID_ID = 10505, /* 0x2909 */ /* Invalid resource ID */ |
|||
MSP_ERROR_RES_INVALID_IMG = 10506, /* 0x290A */ /* Invalid resource image pointer */ |
|||
MSP_ERROR_RES_WRITE = 10507, /* 0x290B */ /* Write read-only resource */ |
|||
MSP_ERROR_RES_LEAK = 10508, /* 0x290C */ /* Resource leak out */ |
|||
MSP_ERROR_RES_HEAD = 10509, /* 0x290D */ /* Resource head currupt */ |
|||
MSP_ERROR_RES_DATA = 10510, /* 0x290E */ /* Resource data currupt */ |
|||
MSP_ERROR_RES_SKIP = 10511, /* 0x290F */ /* Resource file skipped */ |
|||
|
|||
/* Error codes of TTS 10600(0x2968)*/ |
|||
MSP_ERROR_TTS_GENERAL = 10600, /* 0x2968 */ |
|||
MSP_ERROR_TTS_TEXTEND = 10601, /* 0x2969 */ /* Meet text end */ |
|||
MSP_ERROR_TTS_TEXT_EMPTY = 10602, /* 0x296A */ /* no synth text */ |
|||
MSP_ERROR_TTS_LTTS_ERROR = 10603, /* 0x296B */ |
|||
|
|||
/* Error codes of Recognizer 10700(0x29CC) */ |
|||
MSP_ERROR_REC_GENERAL = 10700, /* 0x29CC */ /* 引擎异常 */ |
|||
MSP_ERROR_REC_INACTIVE = 10701, /* 0x29CD */ |
|||
MSP_ERROR_REC_GRAMMAR_ERROR = 10702, /* 0x29CE */ |
|||
MSP_ERROR_REC_NO_ACTIVE_GRAMMARS = 10703, /* 0x29CF */ |
|||
MSP_ERROR_REC_DUPLICATE_GRAMMAR = 10704, /* 0x29D0 */ |
|||
MSP_ERROR_REC_INVALID_MEDIA_TYPE = 10705, /* 0x29D1 */ |
|||
MSP_ERROR_REC_INVALID_LANGUAGE = 10706, /* 0x29D2 */ |
|||
MSP_ERROR_REC_URI_NOT_FOUND = 10707, /* 0x29D3 */ |
|||
MSP_ERROR_REC_URI_TIMEOUT = 10708, /* 0x29D4 */ |
|||
MSP_ERROR_REC_URI_FETCH_ERROR = 10709, /* 0x29D5 */ |
|||
MSP_ERROR_REC_PROC_MOD = 10710, /* 0x29D6 */ |
|||
|
|||
|
|||
/* Error codes of Speech Detector 10800(0x2A30) */ |
|||
MSP_ERROR_EP_GENERAL = 10800, /* 0x2A30 */ |
|||
MSP_ERROR_EP_NO_SESSION_NAME = 10801, /* 0x2A31 */ |
|||
MSP_ERROR_EP_INACTIVE = 10802, /* 0x2A32 */ |
|||
MSP_ERROR_EP_INITIALIZED = 10803, /* 0x2A33 */ |
|||
|
|||
/* Error codes of TUV */ |
|||
MSP_ERROR_TUV_GENERAL = 10900, /* 0x2A94 */ |
|||
MSP_ERROR_TUV_GETHIDPARAM = 10901, /* 0x2A95 */ /* Get Busin Param huanid*/ |
|||
MSP_ERROR_TUV_TOKEN = 10902, /* 0x2A96 */ /* Get Token */ |
|||
MSP_ERROR_TUV_CFGFILE = 10903, /* 0x2A97 */ /* Open cfg file */ |
|||
MSP_ERROR_TUV_RECV_CONTENT = 10904, /* 0x2A98 */ /* received content is error */ |
|||
MSP_ERROR_TUV_VERFAIL = 10905, /* 0x2A99 */ /* Verify failure */ |
|||
|
|||
/* Error codes of IMTV */ |
|||
MSP_ERROR_LOGIN_SUCCESS = 11000, /* 0x2AF8 */ /* 成功 */ |
|||
MSP_ERROR_LOGIN_NO_LICENSE = 11001, /* 0x2AF9 */ /* 试用次数结束,用户需要付费 */ |
|||
MSP_ERROR_LOGIN_SESSIONID_INVALID = 11002, /* 0x2AFA */ /* SessionId失效,需要重新登录通行证 */ |
|||
MSP_ERROR_LOGIN_SESSIONID_ERROR = 11003, /* 0x2AFB */ /* SessionId为空,或者非法 */ |
|||
MSP_ERROR_LOGIN_UNLOGIN = 11004, /* 0x2AFC */ /* 未登录通行证 */ |
|||
MSP_ERROR_LOGIN_INVALID_USER = 11005, /* 0x2AFD */ /* 用户ID无效 */ |
|||
MSP_ERROR_LOGIN_INVALID_PWD = 11006, /* 0x2AFE */ /* 用户密码无效 */ |
|||
MSP_ERROR_LOGIN_SYSTEM_ERROR = 11099, /* 0x2B5B */ /* 系统错误 */ |
|||
|
|||
/* Error codes of HCR */ |
|||
MSP_ERROR_HCR_GENERAL = 11100, |
|||
MSP_ERROR_HCR_RESOURCE_NOT_EXIST = 11101, |
|||
MSP_ERROR_HCR_CREATE = 11102, |
|||
MSP_ERROR_HCR_DESTROY = 11103, |
|||
MSP_ERROR_HCR_START = 11104, |
|||
MSP_ERROR_HCR_APPEND_STROKES = 11105, |
|||
MSP_ERROR_HCR_INIT = 11106, |
|||
MSP_ERROR_HCR_POINT_DECODE = 11107, |
|||
MSP_ERROR_HCR_DISPATCH = 11108, |
|||
MSP_ERROR_HCR_GETRESULT = 11109, |
|||
MSP_ERROR_HCR_RESOURCE = 11110, |
|||
|
|||
/* Error Codes using in local engine */ |
|||
MSP_ERROR_AUTH_NO_LICENSE = 11200, /* 0x2BC0 */ /* 无授权 */ |
|||
MSP_ERROR_AUTH_NO_ENOUGH_LICENSE = 11201, /* 0x2BC1 */ /* 授权不足 */ |
|||
MSP_ERROR_AUTH_INVALID_LICENSE = 11202, /* 0x2BC2 */ /* 无效的授权 */ |
|||
MSP_ERROR_AUTH_LICENSE_EXPIRED = 11203, /* 0x2BC3 */ /* 授权过期 */ |
|||
MSP_ERROR_AUTH_NEED_MORE_DATA = 11204, /* 0x2BC4 */ /* 无设备信息 */ |
|||
MSP_ERROR_AUTH_LICENSE_TO_BE_EXPIRED = 11205, /* 0x2BC5 */ /* 授权即将过期,警告性错误码 */ |
|||
MSP_ERROR_AUTH_INVALID_MACHINE_ID = 11206, /* 0x2BC6 */ /* 无效的机器码 */ |
|||
MSP_ERROR_AUTH_LOCAL_ASR_FORBIDDEN = 11207, /* 0x2BC7 */ /* 禁止使用本地识别引擎 */ |
|||
MSP_ERROR_AUTH_LOCAL_TTS_FORBIDDEN = 11208, /* 0x2BC8 */ /* 禁止使用本地合成引擎 */ |
|||
MSP_ERROR_AUTH_LOCAL_IVW_FORBIDDEN = 11209, /* 0x2BC9 */ /* 禁止使用本地唤醒引擎 */ |
|||
MSP_ERROR_AUTH_APPID_NOT_MATCH = 11210, /* 0x2BCA */ /* 资源appid和应用appid不匹配 */ |
|||
MSP_ERROR_AUTH_UID_NOT_MATCH = 11211, /* 0x2BCB */ /* 资源uid和登录用户uid不匹配 */ |
|||
MSP_ERROR_AUTH_TRIAL_EXPIRED = 11212, /* 0x2BCC */ /* 试用资源过期 */ |
|||
MSP_ERROR_AUTH_LOCAL_IFD_FORBIDDEN = 11213, /* 0x2BC9 */ /* 禁止使用本地人脸引擎 */ |
|||
|
|||
MSP_ERROR_AIUI_NO_ENOUGH_LICENSE = 11216, /* 0x2BD0 */ /* AIUI授权不足 */ |
|||
/*Error Codes of Authorization*/ |
|||
MSP_ERROR_AUTH_DVC_NO_LICENSE = 11300, |
|||
MSP_ERROR_AUTH_DVC_NO_ENOUGH_LICENSE = 11301, |
|||
MSP_ERROR_AUTH_DVC_INVALID_LICENSE = 11302, |
|||
MSP_ERROR_AUTH_DVC_LICENSE_EXPIRED = 11303, |
|||
MSP_ERROR_AUTH_DVC_NEED_MORE_DATA = 11304, |
|||
MSP_ERROR_AUTH_DVC_LICENSE_TO_BE_EXPIRED = 11305, |
|||
MSP_ERROR_AUTH_DVC_EXCEED_LICENSE = 11306, |
|||
|
|||
/* Error codes of Ise */ |
|||
|
|||
MSP_ERROR_ASE_EXCEP_SILENCE = 11401, |
|||
MSP_ERROR_ASE_EXCEP_SNRATIO = 11402, |
|||
MSP_ERROR_ASE_EXCEP_PAPERDATA = 11403, |
|||
MSP_ERROR_ASE_EXCEP_PAPERCONTENTS = 11404, |
|||
MSP_ERROR_ASE_EXCEP_NOTMONO = 11405, |
|||
MSP_ERROR_ASE_EXCEP_OTHERS = 11406, |
|||
MSP_ERROR_ASE_EXCEP_PAPERFMT = 11407, |
|||
MSP_ERROR_ASE_EXCEP_ULISTWORD = 11408, |
|||
|
|||
/* Error codes of Iot */ |
|||
MSP_ERROR_IOT_BASE = 11500, |
|||
MSP_ERROR_IOT_PARAM_ERROR = 11501, // param error
|
|||
MSP_ERROR_IOT_INVALID_SERVICE = 11502, // invalid service for iot ProTranServer
|
|||
MSP_ERROR_IOT_INVALID_PRODUCTID = 11503, // invalid productid for ProTranServer
|
|||
MSP_EEROR_IOT_INVALID_ATTR = 11504, // invalid attr value for one product in ProTranServer
|
|||
MSP_ERROR_IOT_INVALID_PLATFORM = 11505, // invalid platform for ProTranServer
|
|||
MSP_ERROR_IOT_DID_NOT_FOUND = 11506, // not found device id in semantic
|
|||
|
|||
/* Error codes of IVP */ |
|||
MSP_ERROR_IVP_GENERAL = 11600, // 内核异常
|
|||
MSP_ERROR_IVP_EXTRA_RGN_SOPPORT = 11601, // 注册时向引擎所写音频条数超过上限(9次)
|
|||
MSP_ERROR_IVP_TRUNCATED = 11602, // 音频截幅(因信号波形的幅度太大,而超出系统的线性范围),如记录尖叫声的音频
|
|||
MSP_ERROR_IVP_MUCH_NOISE = 11603, // 音频信噪比过低
|
|||
MSP_ERROR_IVP_TOO_LOW = 11604, // 音频能量过低
|
|||
MSP_ERROR_IVP_ZERO_AUDIO = 11605, // 无音频
|
|||
MSP_ERROR_IVP_UTTER_TOO_SHORT = 11606, // 音频太短
|
|||
MSP_ERROR_IVP_TEXT_NOT_MATCH = 11607, // 1.音频和文本不匹配,常见原因1.抢读(在按下录音键之前读)
|
|||
// 2.录音机的启动电流被录入表现在音频上是在音频首有冲击电流 3.确实不匹配"
|
|||
MSP_ERROR_IVP_NO_ENOUGH_AUDIO = 11608, // 音频不够,注册自由说,而写入的音频又不够长时会报,告诉调用者继续传音频
|
|||
MSP_ERROR_IVP_MODEL_NOT_FOUND_IN_HBASE = 11610, // 模型在hbase中没找到
|
|||
|
|||
/* Error codes of Face */ |
|||
|
|||
MSP_ERROR_IFR_NOT_FACE_IMAGE = 11700, // 【无人脸,对应的引擎错误码是20200 】
|
|||
MSP_ERROR_FACE_IMAGE_FULL_LEFT = 11701, // 【人脸向左,对应的引擎错误码是20201】
|
|||
MSP_ERROR_FACE_IMAGE_FULL_RIGHT = 11702, // 【人脸向右,对应的引擎错误码是20202】
|
|||
MSP_ERROR_IMAGE_CLOCKWISE_WHIRL = 11703, // 【顺时针旋转,对应的引擎错误码是20203】
|
|||
MSP_ERROR_IMAGE_COUNTET_CLOCKWISE_WHIRL = 11704, // 【逆时针旋转,对应的引擎错误码是20204】
|
|||
MSP_ERROR_VALID_IMAGE_SIZE = 11705, // 【图片大小异常 ,对应的引擎错误码是20205】
|
|||
MSP_ERROR_ILLUMINATION = 11706, // 【光照异常,对应的引擎错误码是20206】
|
|||
MSP_ERROR_FACE_OCCULTATION = 11707, // 【人脸被遮挡,对应的引擎错误码是20207】
|
|||
MSP_ERROR_FACE_INVALID_MODEL = 11708, // 【非法模型数据,对应的引擎错误码是20208】
|
|||
MSP_ERROR_FUSION_INVALID_INPUT_TYPE = 11709, // 【输入数据类型非法,对应的引擎错误码是20300】
|
|||
MSP_ERROR_FUSION_NO_ENOUGH_DATA = 11710, // 【输入的数据不完整,对应的引擎错误码是20301】
|
|||
MSP_ERROR_FUSION_ENOUGH_DATA = 11711, // 【输入的数据过多,对应的引擎错误码是20302】
|
|||
|
|||
/*Error Codes of AIUI*/ |
|||
MSP_ERROR_AIUI_CID_EXPIRED = 11800, |
|||
|
|||
/*Error Codes of Encoder*/ |
|||
MSP_ERROR_ICT_ENCODER = 11900, |
|||
|
|||
/* Error codes of http 12000(0x2EE0) */ |
|||
MSP_ERROR_HTTP_BASE = 12000, /* 0x2EE0 */ |
|||
MSP_ERROR_HTTP_400 = 12400, |
|||
MSP_ERROR_HTTP_401 = 12401, |
|||
MSP_ERROR_HTTP_402 = 12402, |
|||
MSP_ERROR_HTTP_403 = 12403, |
|||
MSP_ERROR_HTTP_404 = 12404, |
|||
MSP_ERROR_HTTP_405 = 12405, |
|||
MSP_ERROR_HTTP_406 = 12406, |
|||
MSP_ERROR_HTTP_407 = 12407, |
|||
MSP_ERROR_HTTP_408 = 12408, |
|||
MSP_ERROR_HTTP_409 = 12409, |
|||
MSP_ERROR_HTTP_410 = 12410, |
|||
MSP_ERROR_HTTP_411 = 12411, |
|||
MSP_ERROR_HTTP_412 = 12412, |
|||
MSP_ERROR_HTTP_413 = 12413, |
|||
MSP_ERROR_HTTP_414 = 12414, |
|||
MSP_ERROR_HTTP_415 = 12415, |
|||
MSP_ERROR_HTTP_416 = 12416, |
|||
MSP_ERROR_HTTP_417 = 12417, |
|||
MSP_ERROR_HTTP_500 = 12500, |
|||
MSP_ERROR_HTTP_501 = 12501, |
|||
MSP_ERROR_HTTP_502 = 12502, |
|||
MSP_ERROR_HTTP_503 = 12503, |
|||
MSP_ERROR_HTTP_504 = 12504, |
|||
MSP_ERROR_HTTP_505 = 12505, |
|||
/*Error codes of ISV */ |
|||
MSP_ERROR_ISV_NO_USER = 13000, /* 32C8 */ /* the user doesn't exist */ |
|||
|
|||
/* Error codes of Lua scripts */ |
|||
MSP_ERROR_LUA_BASE = 14000, /* 0x36B0 */ |
|||
MSP_ERROR_LUA_YIELD = 14001, /* 0x36B1 */ |
|||
MSP_ERROR_LUA_ERRRUN = 14002, /* 0x36B2 */ |
|||
MSP_ERROR_LUA_ERRSYNTAX = 14003, /* 0x36B3 */ |
|||
MSP_ERROR_LUA_ERRMEM = 14004, /* 0x36B4 */ |
|||
MSP_ERROR_LUA_ERRERR = 14005, /* 0x36B5 */ |
|||
MSP_ERROR_LUA_INVALID_PARAM = 14006, /* 0x36B6 */ |
|||
|
|||
/* Error codes of MMP */ |
|||
MSP_ERROR_MMP_BASE = 15000, /* 0x3A98 */ |
|||
MSP_ERROR_MMP_MYSQL_INITFAIL = 15001, /* 0x3A99 */ |
|||
MSP_ERROR_MMP_REDIS_INITFAIL = 15002, /* 0x3A9A */ |
|||
MSP_ERROR_MMP_NETDSS_INITFAIL = 15003, /* 0x3A9B */ |
|||
MSP_ERROR_MMP_TAIR_INITFAIL = 15004, /* 0x3A9C */ |
|||
MSP_ERROR_MMP_MAIL_SESSION_FAIL = 15006, /* 0x3A9E */ /* 邮件登陆服务器时,会话错误。*/ |
|||
MSP_ERROR_MMP_MAIL_LOGON_FAIL = 15007, /* 0x3A9F */ /* 邮件登陆服务器时,拒绝登陆。*/ |
|||
MSP_ERROR_MMP_MAIL_USER_ILLEGAL = 15008, /* 0x3AA0 */ /* 邮件登陆服务器时,用户名非法。*/ |
|||
MSP_ERROR_MMP_MAIL_PWD_ERR = 15009, /* 0x3AA1 */ /* 邮件登陆服务器时,密码错误。*/ |
|||
MSP_ERROR_MMP_MAIL_SOCKET_ERR = 15010, /* 0x3AA2 */ /* 邮件发送过程中套接字错误*/ |
|||
MSP_ERROR_MMP_MAIL_INIT_FAIL = 15011, /* 0x3AA3 */ /* 邮件初始化错误*/ |
|||
MSP_ERROR_MMP_STORE_MNR_NO_INIT = 15012, /* 0x3AA4 */ /* store_manager未初始化,或初始化失败*/ |
|||
MSP_ERROR_MMP_STORE_MNR_POOL_FULL = 15013, /* 0x3AA5 */ /* store_manager的连接池满了*/ |
|||
MSP_ERROR_MMP_STRATGY_PARAM_ILLEGAL = 15014, /* 0x3AA6 */ /* 报警策略表达式非法*/ |
|||
MSP_ERROR_MMP_STRATGY_PARAM_TOOLOOG = 15015, /* 0x3AA7 */ /* 报警策略表达式太长*/ |
|||
MSP_ERROR_MMP_PARAM_NULL = 15016, /* 0x3AA8 */ /* 函数参数为空*/ |
|||
MSP_ERROR_MMP_ERR_MORE_TOTAL = 15017, /* 0x3AA9 */ /* pms插入数据库中错误汇总表的数据,错误次数 > 总次数。*/ |
|||
MSP_ERROR_MMP_PROC_THRESHOLD = 15018, /* 0x3AAA */ /* 进程监控阀值设置错误*/ |
|||
MSP_ERROR_MMP_SERVER_THRESHOLD = 15019, /* 0x3AAB */ /* 服务器监控阀值设置错误*/ |
|||
MSP_ERROR_MMP_PYTHON_NO_EXIST = 15020, /* 0x3AAC */ /* python脚本文件不存在 */ |
|||
MSP_ERROR_MMP_PYTHON_IMPORT_FAILED = 15021, /* 0x3AAD */ /* python脚本导入出错 */ |
|||
MSP_ERROR_MMP_PYTHON_BAD_FUNC = 15022, /* 0x3AAE */ /* python脚本函数格式错误 */ |
|||
MSP_ERROR_MMP_DB_DATA_ILLEGAL = 15023, /* 0x3AAF */ /* 插入数据库中的数据格式有误 */ |
|||
MSP_ERROR_MMP_REDIS_NOT_CONN = 15024, /* 0x3AB0 */ /* redis没有连接到服务端 */ |
|||
MSP_ERROR_MMP_PMA_NOT_FOUND_STRATEGY = 15025, /* 0x3AB1 */ /* 没有找到报警策略 */ |
|||
MSP_ERROR_MMP_TAIR_CONNECT = 15026, /* 0x3AB2 */ /* 连接tair集群失败 */ |
|||
MSP_ERROR_MMP_PMC_SERVINFO_INVALID = 15027, /* Ox3AB3 */ /* 此pmc的服务器信息已经无效 */ |
|||
MSP_ERROR_MMP_ALARM_GROUP_NULL = 15028, /* Ox3AB4 */ /* 服务器报警的短信报警组与邮件报警组均为空 */ |
|||
MSP_ERROR_MMP_ALARM_CONTXT_NULL = 15029, /* Ox3AB5 */ /* 服务器报警的报警内容为空 */ |
|||
|
|||
/* Error codes of MSC(lmod loader) */ |
|||
MSP_ERROR_LMOD_BASE = 16000, /* 0x3E80 */ |
|||
MSP_ERROR_LMOD_NOT_FOUND = 16001, /* 0x3E81 */ /* 没找到lmod文件 */ |
|||
MSP_ERROR_LMOD_UNEXPECTED_BIN = 16002, /* 0x3E82 */ /* 无效的lmod */ |
|||
MSP_ERROR_LMOD_LOADCODE = 16003, /* 0x3E83 */ /* 加载lmod指令失败 */ |
|||
MSP_ERROR_LMOD_PRECALL = 16004, /* 0x3E84 */ /* 初始化lmod失败 */ |
|||
MSP_ERROR_LMOD_RUNTIME_EXCEPTION = 16005, /* 0x3E85 */ /* lmod运行时异常 */ |
|||
MSP_ERROR_LMOD_ALREADY_LOADED = 16006, /* 0x3E86 */ /* lmod重复加载 */ |
|||
|
|||
// Error code of Third Business
|
|||
MSP_ERROR_BIZ_BASE = 17000, /* 0x4268 */ /* 三方业务错误码 */ |
|||
|
|||
//Error of Nginx errlog file increase exception
|
|||
MSP_ERROR_NGX_LOG_MORE_TOTEL_SIZE = 18000, /*nginx错误日志大小异常*/ |
|||
|
|||
//Error of Flash client when network checking
|
|||
MSP_ERROR_FLASH_NETWORK_CONNECT_FIALED = 19000, /*flash服务端网络连接失败*/ |
|||
MSP_ERROR_FLASH_NETWORK_CHECK_FIALED = 19001, /*flash服务端响应了异常消息*/ |
|||
MSP_ERROR_FLASH_NETWORK_CHECK_TIMEOUT = 19002, /*flash服务端网络超时*/ |
|||
MSP_ERROR_FLASH_NETWORK_CLOSED_EXCEPTION = 19003, /*flash服务端网络异常关闭*/ |
|||
|
|||
/*Error Code Of Speech plus*/ |
|||
|
|||
SPEECH_ERROR_NO_NETWORK = 20001, /* 无有效的网络连接*/ |
|||
SPEECH_ERROR_NETWORK_TIMEOUT = 20002, /* 网络连接超时*/ |
|||
SPEECH_ERROR_NET_EXPECTION = 20003, /* 网络异常*/ |
|||
SPEECH_ERROR_INVALID_RESULT = 20004, /* 无有效的结果*/ |
|||
SPEECH_ERROR_NO_MATCH = 20005, /* 无匹配结果 */ |
|||
SPEECH_ERROR_AUDIO_RECORD = 20006, /* 录音失败 */ |
|||
SPEECH_ERROR_NO_SPPECH = 20007, /* 未检测到语音*/ |
|||
|
|||
SPEECH_ERROR_SPEECH_TIMEOUT = 20008, /* 音频输入超时*/ |
|||
SPEECH_ERROR_EMPTY_UTTERANCE = 20009, /* 无效的文本输入 */ |
|||
SPEECH_ERROR_FILE_ACCESS = 20010, /* 文件读写失败 */ |
|||
SPEECH_ERROR_PLAY_MEDIA = 20011, /* 音频播放失败 */ |
|||
|
|||
SPEECH_ERROR_INVALID_PARAM = 20012, /* 无效的参数*/ |
|||
SPEECH_ERROR_TEXT_OVERFLOW = 20013, /* 文本溢出 */ |
|||
SPEECH_ERROR_INVALID_DATA = 20014, /* 无效数据 */ |
|||
SPEECH_ERROR_LOGIN = 20015, /* 用户未登陆*/ |
|||
SPEECH_ERROR_PERMISSION_DENIED = 20016, /* 无效授权 */ |
|||
SPEECH_ERROR_INTERRUPT = 20017, /* 被异常打断 */ |
|||
|
|||
SPEECH_ERROR_VERSION_LOWER = 20018, /* 版本过低 */ |
|||
SPEECH_CLIENT_ERROR_ISUSING = 20019, /* 录音机被占用(iOS平台) */ |
|||
SPEECH_ERROR_SYSTEM_PREINSTALL = 20020, /* 系统预置版本 */ |
|||
SPEECH_ERROR_UNSATISFIED_LINK = 20021, /* 未实现的Native函数引用 */ |
|||
SPEECH_ERROR_UNKNOWN = 20999, /* 未知错误 */ |
|||
|
|||
|
|||
SPEECH_ERROR_COMPONENT_NOT_INSTALLED = 21001, /* 没有安装语音组件 */ |
|||
SPEECH_ERROR_ENGINE_NOT_SUPPORTED = 21002, /* 引擎不支持 */ |
|||
SPEECH_ERROR_ENGINE_INIT_FAIL = 21003, /* 初始化失败 */ |
|||
SPEECH_ERROR_ENGINE_CALL_FAIL = 21004, /* 调用失败 */ |
|||
SPEECH_ERROR_ENGINE_BUSY = 21005, /* 引擎繁忙 */ |
|||
|
|||
SPEECH_ERROR_LOCAL_NO_INIT = 22001, /* 本地引擎未初始化 */ |
|||
SPEECH_ERROR_LOCAL_RESOURCE = 22002, /* 本地引擎无资源 */ |
|||
SPEECH_ERROR_LOCAL_ENGINE = 22003, /* 本地引擎内部错误 */ |
|||
SPEECH_ERROR_IVW_INTERRUPT = 22004, /* 本地唤醒引擎被异常打断 */ |
|||
|
|||
|
|||
/*Error Code Of Local iflytek Engines*/ |
|||
|
|||
/*Error Code Of AiTalk*/ |
|||
|
|||
/*Error Code Of AiTalk Operation*/ |
|||
SPEECH_SUCCESS = 0, // ivErr_OK = 0 /*成功状态*/
|
|||
|
|||
SPEECH_ERROR_ASR_CLIENT = 23000, /*客户端应用程序错误*///?????????
|
|||
SPEECH_ERROR_ASR_INVALID_PARA = 23001, /*无效的参数*/ |
|||
SPEECH_ERROR_ASR_INVALID_PARA_VALUE = 23002, /*无效的参数值*/ |
|||
SPEECH_ERROR_ASR_OUT_OF_MEMORY = 23003, /*内存耗尽*/ |
|||
SPEECH_ERROR_ASR_CREATE_HANDLE_FAILED = 23004, /*创建句柄失败*/ |
|||
SPEECH_ERROR_ASR_ENGINE_INIT_FAILED = 23005, /*引擎初始化失败*/ |
|||
SPEECH_ERROR_ASR_ENGINE_STARTED = 23006, /*引擎已经启动*/ |
|||
SPEECH_ERROR_ASR_ENGINE_UNINIT = 23007, /*引擎未初始化*/ |
|||
SPEECH_ERROR_ASR_SPEECH_TIMEOUT = 23008, /*识别超时(VAD没开启或没有检测到后端点)*/ |
|||
SPEECH_ERROR_ASR_NO_RECOGNIZED_RESULT = 23009, /*无识别结果*/ |
|||
SPEECH_ERROR_ASR_INVALID_HANDLE = 23010, /*无效的句柄*/ |
|||
SPEECH_ERROR_ASR_FILE_ACCESS = 23011, /*打开文件失败*/ |
|||
|
|||
/*Error Code Of AiTalk Engine*/ |
|||
SPEECH_ERROR_AITALK_FALSE = 23100, // ivErr_FALSE = 1
|
|||
|
|||
/* For license check */ |
|||
SPEECH_ERROR_AITALK_PERMISSION_DENIED = 23101, // ivErr_InvSN = 2
|
|||
|
|||
/* General */ |
|||
SPEECH_ERROR_AITALK_INVALID_PARA = 23102, // ivErr_InvArg = 3
|
|||
SPEECH_ERROR_AITALK_BUFFER_OVERFLOW = 23103, // ivErr_BufferFull = 4 /*音频数据缓冲区已满*/
|
|||
SPEECH_ERROR_AITALK_FAILED = 23104, // ivErr_Failed = 5
|
|||
SPEECH_ERROR_AITALK_NOT_SUPPORTED = 23105, // ivErr_NotSupport = 6 /*引擎不支持*/
|
|||
SPEECH_ERROR_AITALK_OUT_OF_MEMORY = 23106, // ivErr_OutOfMemory = 7
|
|||
SPEECH_ERROR_AITALK_INVALID_RESOURCE = 23107, // ivErr_InvResource = 8 /*资源无效*/
|
|||
SPEECH_ERROR_AITALK_NOT_FOUND = 23108, // ivErr_NotFound = 9 /*打开文件失败*/
|
|||
SPEECH_ERROR_AITALK_INVALID_GRAMMAR = 23109, // ivErr_InvGrmr = 10 /*识别语法错误*/
|
|||
|
|||
/* For object status */ |
|||
SPEECH_ERROR_AITALK_INVALID_CALL = 23110, // ivErr_InvCall = 11 /*无效调用*/
|
|||
|
|||
/* For ASR Input */ |
|||
SPEECH_ERROR_AITALK_SYNTAX_ERROR = 23111, // ivErr_InvCall = 12
|
|||
|
|||
/* For Message Call Back */ |
|||
SPEECH_ERROR_AITALK_RESET = 23112, // ivErr_Reset = 13
|
|||
SPEECH_ERROR_AITALK_ENDED = 23113, // ivErr_Ended = 14
|
|||
SPEECH_ERROR_AITALK_IDLE = 23114, // ivErr_Idle = 15
|
|||
SPEECH_ERROR_AITALK_CANNOT_SAVE_FILE = 23115, // ivErr_CanNotSaveFile = 16
|
|||
|
|||
/* For Lexicon name */ |
|||
SPEECH_ERROR_AITALK_INVALID_GRAMMAR_NAME = 23116, // ivErr_InvName = 17 /*文法或词典名称非法*/
|
|||
|
|||
SPEECH_ERROR_AITALK_BUFFER_EMPTY = 23117, // ivErr_BufferEmpty = 18
|
|||
|
|||
SPEECH_ERROR_AITALK_GET_RESULT = 23118, // ivErr_GetResult = 19
|
|||
|
|||
SPEECH_ERROR_AITALK_REACT_OUT_TIME = 23119, // ivErr_ReactOutTime = 20 /*反应超时*/
|
|||
SPEECH_ERROR_AITALK_SPEECH_OUT_TIME = 23120, // ivErr_SpeechOutTime = 21 /*语音超时*/
|
|||
|
|||
SPEECH_ERROR_AITALK_AUDIO_CUT = 23121, // ivErr_CUT = 22 /*录音质量过高*/
|
|||
SPEECH_ERROR_AITALK_AUDIO_LOWER = 23122, // ivErr_LOWER = 23 /*录音质量过低*/
|
|||
|
|||
SPEECH_ERROR_AITALK_INSUFFICIENT_PERMISSIONS = 23123, // ivErr_Limitted = 24 /*授权不够*/
|
|||
SPEECH_ERROR_AITALK_RESULT_ERROR = 23124, // ivErr_ResultError = 25 /*解码器Wfst输出后,依然有cmd输出*/
|
|||
SPEECH_ERROR_AITALK_SHORT_PAUSE = 23125, // ivErr_ShortPause = 26
|
|||
SPEECH_ERROR_AITALK_BUSY = 23126, // ivErr_Busy = 27
|
|||
SPEECH_ERROR_AITALK_GRM_NOT_UPDATE = 23127, // ivErr_GrmNotUpdate = 28 /*语法未更新*/
|
|||
SPEECH_ERROR_AITALK_STARTED = 23128, // ivErr_Started = 29
|
|||
SPEECH_ERROR_AITALK_STOPPED = 23129, // ivErr_Stopped = 30
|
|||
SPEECH_ERROR_AITALK_ALREADY_STARTED = 23130, // ivErr_AlreadyStarted = 31
|
|||
SPEECH_ERROR_AITALK_ALREADY_STOPPED = 23131, // ivErr_AlreadyStopped = 32
|
|||
SPEECH_ERROR_AITALK_TOO_MANY_COMMAND = 23132, // ivErr_TooManyCmd = 33
|
|||
SPEECH_ERROR_AITALK_WAIT = 23133, // ivErr_Wait = 34 /*程序可能在做一些操作,主线程需要等待*/
|
|||
SPEECH_ERROR_AITALK_MAE_RIGHT = 23134, // ivErr_MAERight = 35
|
|||
SPEECH_ERROR_AITALK_MAE_WRONG = 23135, // ivErr_MAEWrong = 36
|
|||
|
|||
SPEECH_ERROR_AITALK_GRM_ERR = 23300, // 语法错误
|
|||
|
|||
|
|||
|
|||
/*Error Code Of AiSound*/ |
|||
|
|||
/*Error Code Of AiSound Operation*/ |
|||
SPEECH_ERROR_TTS_INVALID_PARA = 24000, /* 错误参数 */ |
|||
SPEECH_ERROR_TTS_INVALID_PARA_VALUE = 24001, /* 无效的参数值*/ |
|||
SPEECH_ERROR_TTS_OUT_OF_MEMORY = 24002, /* 内存不足*/ |
|||
SPEECH_ERROR_TTS_INVALID_HANDLE = 24003, /* 无效的句柄*/ |
|||
SPEECH_ERROR_TTS_CREATE_HANDLE_FAILED = 24004, /* 创建句柄失败*/ |
|||
SPEECH_ERROR_TTS_INVALID_RESOURCE = 24005, /* 无效资源 */ |
|||
SPEECH_ERROR_TTS_INVALID_VOICE_NAME = 24006, /* 无效发言人*/ |
|||
SPEECH_ERROR_TTS_ENGINE_UNINIT = 24007, /* 引擎未初始化 */ |
|||
SPEECH_ERROR_TTS_ENGINE_INIT_FAILED = 24008, /* 引擎初始化失败 */ |
|||
SPEECH_ERROR_TTS_ENGINE_BUSY = 24009, /* 引擎忙 */ |
|||
|
|||
|
|||
/*Error Code Of AiSound Engine*/ |
|||
SPEECH_ERROR_AISOUND_BASE = 24100, |
|||
SPEECH_ERROR_AISOUND_UNIMPEMENTED = 24100, /* unimplemented function */ |
|||
SPEECH_ERROR_AISOUND_UNSUPPORTED = 24101, /* unsupported on this platform */ |
|||
SPEECH_ERROR_AISOUND_INVALID_HANDLE = 24102, /* invalid handle */ |
|||
SPEECH_ERROR_AISOUND_INVALID_PARA = 24103, /* invalid parameter(s) */ |
|||
SPEECH_ERROR_AISOUND_INSUFFICIENT_HEAP = 24104, /* insufficient heap size */ |
|||
SPEECH_ERROR_AISOUND_STATE_REFUSE = 24105, /* refuse to do in current state */ |
|||
SPEECH_ERROR_AISOUND_INVALID_PARA_ID = 24106, /* invalid parameter ID */ |
|||
SPEECH_ERROR_AISOUND_INVALID_PARA_VALUE = 24107, /* invalid parameter value */ |
|||
SPEECH_ERROR_AISOUND_RESOURCE = 24108, /* Resource is error */ |
|||
SPEECH_ERROR_AISOUND_RESOURCE_READ = 24109, /* read resource error */ |
|||
SPEECH_ERROR_AISOUND_LBENDIAN = 24110, /* the Endian of SDK is error */ |
|||
SPEECH_ERROR_AISOUND_HEADFILE = 24111, /* the HeadFile is different of the SDK */ |
|||
SPEECH_ERROR_AISOUND_BUFFER_OVERFLOW = 24112, /* get data size exceed the data buffer */ |
|||
SPEECH_ERROR_AISOUND_INVALID_ISAMPA = 24113, /* !Invalid iSampa format or input iSampa text contain invalid alphabet*/ |
|||
SPEECH_ERROR_AISOUND_INVALID_CSSML = 24114, /* !Invalid cssml format */ |
|||
|
|||
|
|||
/*Error Code Of ivw*/ |
|||
|
|||
/*Error Code Of ivw Operation*/ |
|||
SPEECH_ERROR_IVW_ENGINE_UNINI = 25000, /* 引擎未初始化 */ |
|||
SPEECH_ERROR_IVW_RESVER_NOMATCH = 25001, /* 资源版本不匹配 */ |
|||
SPEECH_ERROR_IVW_BUFFERED_AUDIOD_LITTLE = 25002, /* 唤醒加识别缓存音频过少 */ |
|||
SPEECH_ERROR_IVW_INVALID_RESTYPE = 25003, /* 不合法的资源类型 */ |
|||
SPEECH_ERROR_IVW_INVALID_RESHEADVER = 25004, /* 不合法的资源头部版本号 */ |
|||
|
|||
/*Error Code Of ivw Engine*/ |
|||
SPEECH_ERROR_IVW_INVALID_CALL = 25101, // IvwErr_InvCal = 1
|
|||
SPEECH_ERROR_IVW_INVALID_ARG = 25102, // IvwErr_InvArg = 2
|
|||
SPEECH_ERROR_IVW_TELL_SIZE = 25103, // IvwErr_TellSize = 3
|
|||
SPEECH_ERROR_IVW_OUT_OF_MEMORY = 25104, // IvwErr_OutOfMemory = 4
|
|||
SPEECH_ERROR_IVW_OUT_BUFFER_FULL = 25105, // IvwErr_BufferFull = 5
|
|||
SPEECH_ERROR_IVW_OUT_BUFFER_EMPTY = 25106, // IvwErr_BufferEmpty = 6
|
|||
SPEECH_ERROR_IVW_INVALID_RESOURCE = 25107, // IvwErr_InvRes = 7
|
|||
SPEECH_ERROR_IVW_REPETITIOPN_ENTER = 25108, // IvwErr_ReEnter = 8
|
|||
SPEECH_ERROR_IVW_NOT_SUPPORT = 25109, // IvwErr_NotSupport = 9
|
|||
SPEECH_ERROR_IVW_NOT_FOUND = 25110, // IvwErr_NotFound = 10
|
|||
SPEECH_ERROR_IVW_INVALID_SN = 25111, // IvwErr_InvSN = 11
|
|||
SPEECH_ERROR_IVW_LIMITTED = 25112, // IvwErr_Limitted = 12
|
|||
SPEECH_ERROR_IVW_TIME_OUT = 25113, // IvwErr_TimeOut = 13
|
|||
|
|||
SPEECH_ERROR_IVW_ENROLL1_SUCESS = 25114, // IvwErr_Enroll1_Success = 14
|
|||
SPEECH_ERROR_IVW_ENROLL1_FAILED = 25115, // IvwErr_Enroll1_Failed = 15
|
|||
SPEECH_ERROR_IVW_ENROLL2_SUCESS = 25116, // IvwErr_Enroll2_Success = 16
|
|||
SPEECH_ERROR_IVW_ENROLL2_FAILED = 25117, // IvwErr_Enroll2_Failed = 17
|
|||
SPEECH_ERROR_IVW_ENROLL3_SUCESS = 25118, // IvwErr_Enroll3_Success = 18
|
|||
SPEECH_ERROR_IVW_ENROLL3_FAILED = 25119, // IvwErr_Enroll3_Failed = 19
|
|||
SPEECH_ERROR_IVW_SPEECH_TOO_SHORT = 25120, // IvwErr_SpeechTooShort = 20
|
|||
SPEECH_ERROR_IVW_SPEECH_STOP = 25121, // IvwErr_SpeechStop = 21
|
|||
|
|||
/* 非实时转写错误码:26000~26999 */ |
|||
SPEECH_ERROR_LFASR_BASE = 26000, /* 非实时转写错误码基码 */ |
|||
}; |
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Drawing; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Windows.Forms; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class MouseHook |
|||
{ |
|||
private Point point; |
|||
private Point Point |
|||
{ |
|||
get { return point; } |
|||
set |
|||
{ |
|||
if (point != value) |
|||
{ |
|||
point = value; |
|||
if (MouseMoveEvent != null) |
|||
{ |
|||
var e = new MouseEventArgs(MouseButtons.None, 0, point.X, point.Y, 0); |
|||
MouseMoveEvent(this, e); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
private int hHook; |
|||
private const int WM_LBUTTONDOWN = 0x201; |
|||
private const int WM_RBUTTONDOWN = 0x204; |
|||
public const int WH_MOUSE_LL = 14; |
|||
public Win32Api.HookProc hProc; |
|||
public MouseHook() |
|||
{ |
|||
this.Point = new Point(); |
|||
} |
|||
public int SetHook() |
|||
{ |
|||
hProc = new Win32Api.HookProc(MouseHookProc); |
|||
hHook = Win32Api.SetWindowsHookEx(WH_MOUSE_LL, hProc, IntPtr.Zero, 0); |
|||
return hHook; |
|||
} |
|||
public void UnHook() |
|||
{ |
|||
Win32Api.UnhookWindowsHookEx(hHook); |
|||
} |
|||
private int MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam) |
|||
{ |
|||
Win32Api.MouseHookStruct MyMouseHookStruct = (Win32Api.MouseHookStruct)Marshal.PtrToStructure(lParam, typeof(Win32Api.MouseHookStruct)); |
|||
if (nCode < 0) |
|||
{ |
|||
return Win32Api.CallNextHookEx(hHook, nCode, wParam, lParam); |
|||
} |
|||
else |
|||
{ |
|||
if (MouseClickEvent != null) |
|||
{ |
|||
MouseButtons button = MouseButtons.None; |
|||
int clickCount = 0; |
|||
switch ((Int32)wParam) |
|||
{ |
|||
case WM_LBUTTONDOWN: |
|||
button = MouseButtons.Left; |
|||
clickCount = 1; |
|||
break; |
|||
case WM_RBUTTONDOWN: |
|||
button = MouseButtons.Right; |
|||
clickCount = 1; |
|||
break; |
|||
} |
|||
|
|||
var e = new MouseEventArgs(button, clickCount, point.X, point.Y, 0); |
|||
MouseClickEvent(this, e); |
|||
} |
|||
this.Point = new Point(MyMouseHookStruct.pt.x, MyMouseHookStruct.pt.y); |
|||
return Win32Api.CallNextHookEx(hHook, nCode, wParam, lParam); |
|||
} |
|||
} |
|||
|
|||
public delegate void MouseMoveHandler(object sender, MouseEventArgs e); |
|||
public event MouseMoveHandler MouseMoveEvent; |
|||
|
|||
public delegate void MouseClickHandler(object sender, MouseEventArgs e); |
|||
public event MouseClickHandler MouseClickEvent; |
|||
} |
|||
} |
|||
@ -0,0 +1,220 @@ |
|||
using Container.Services; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Net; |
|||
using System.Web; |
|||
using System.Windows; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class MyHttpClient |
|||
{ |
|||
private static App app = ((App)Application.Current); |
|||
private static Class_Log Mylog = new Class_Log(); |
|||
private static void init_Request(ref HttpWebRequest request) |
|||
{ |
|||
request.Accept = "text/json,*/*;q=0.5"; |
|||
request.Headers.Add("Accept-Charset", "utf-8;q=0.7,*;q=0.7"); |
|||
request.Headers.Add("Accept-Encoding", "gzip, deflate, x-gzip, identity; q=0.9"); |
|||
request.AutomaticDecompression = DecompressionMethods.GZip; |
|||
request.Timeout = 60000; |
|||
} |
|||
public static string Get(string url) |
|||
{ |
|||
try |
|||
{ |
|||
var request = (HttpWebRequest)WebRequest.Create(url); |
|||
{ |
|||
string retval; |
|||
init_Request(ref request); |
|||
using (var response = request.GetResponse()) |
|||
{ |
|||
using (var reader = new System.IO.StreamReader(response.GetResponseStream() ?? throw new InvalidOperationException(), System.Text.Encoding.UTF8)) |
|||
{ |
|||
retval = reader.ReadToEnd(); |
|||
} |
|||
} |
|||
return retval; |
|||
} |
|||
} |
|||
catch |
|||
{ |
|||
// ignored
|
|||
} |
|||
|
|||
return null; |
|||
} |
|||
|
|||
//判断链接可用
|
|||
public static bool IsCanConnect(string url, int timeout = 1000) |
|||
{ |
|||
HttpWebRequest req = null; |
|||
HttpWebResponse res = null; |
|||
bool CanCn = true; |
|||
try |
|||
{ |
|||
req = (HttpWebRequest)WebRequest.Create(url); |
|||
req.Method = "HEAD"; |
|||
req.Timeout = timeout; |
|||
res = (HttpWebResponse)req.GetResponse(); |
|||
CanCn = res.StatusCode.ToString() == "OK"; |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
CanCn = false; //无法连接
|
|||
} |
|||
finally |
|||
{ |
|||
if (res != null) |
|||
{ |
|||
res.Close(); |
|||
} |
|||
} |
|||
return CanCn; |
|||
} |
|||
public static string Post(string url, string data, string contentType = "application/x-www-form-urlencoded; charset=utf-8", Dictionary<string, string> headers = null) |
|||
{ |
|||
try |
|||
{ |
|||
var request = (HttpWebRequest)WebRequest.Create(url); |
|||
{ |
|||
string retval; |
|||
init_Request(ref request); |
|||
request.Method = "POST"; |
|||
//request.Timeout = 5000;
|
|||
request.ContentType = contentType; |
|||
if (headers != null && headers.Count > 0) |
|||
{ |
|||
foreach (var h in headers) |
|||
{ |
|||
request.Headers.Add(h.Key, h.Value); |
|||
} |
|||
} |
|||
var bytes = System.Text.Encoding.UTF8.GetBytes(data); |
|||
request.ContentLength = bytes.Length; |
|||
using (var stream = request.GetRequestStream()) |
|||
{ |
|||
stream.Write(bytes, 0, bytes.Length); |
|||
} |
|||
using (var response = request.GetResponse()) |
|||
{ |
|||
using (var reader = new System.IO.StreamReader(response.GetResponseStream() ?? throw new InvalidOperationException())) |
|||
{ |
|||
retval = reader.ReadToEnd(); |
|||
|
|||
} |
|||
if (!app.isCheckServerTime) |
|||
{ |
|||
Class_Log log = new Class_Log(); |
|||
string[] dates = response.Headers.GetValues("Date"); |
|||
if (dates.Length > 0) |
|||
{ |
|||
app.isCheckServerTime = true; |
|||
string serverTime = GMT2Local(dates[0]).ToString(); |
|||
log.WriteLogFile(serverTime, "date"); |
|||
WebSocketManageForLive.SetLocalTimeByStr(serverTime); |
|||
} |
|||
} |
|||
} |
|||
|
|||
return retval; |
|||
} |
|||
} |
|||
catch (WebException ex) |
|||
{ |
|||
var lo = ex.Response.Headers["Location"]; |
|||
if (!string.IsNullOrEmpty(lo)) |
|||
return lo; |
|||
return "request error:" + ex.Message; |
|||
} |
|||
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// GMT时间转成本地时间
|
|||
/// </summary>
|
|||
/// <param name="gmt">字符串形式的GMT时间</param>
|
|||
/// <returns></returns>
|
|||
public static DateTime GMT2Local(string gmt) |
|||
{ |
|||
DateTime dt = DateTime.MinValue; |
|||
try |
|||
{ |
|||
string pattern = ""; |
|||
if (gmt.IndexOf("+0") != -1) |
|||
{ |
|||
gmt = gmt.Replace("GMT", ""); |
|||
pattern = "ddd, dd MMM yyyy HH':'mm':'ss zzz"; |
|||
} |
|||
if (gmt.ToUpper().IndexOf("GMT") != -1) |
|||
{ |
|||
pattern = "ddd, dd MMM yyyy HH':'mm':'ss 'GMT'"; |
|||
} |
|||
if (pattern != "") |
|||
{ |
|||
dt = DateTime.ParseExact(gmt, pattern, System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.AdjustToUniversal); |
|||
dt = dt.ToLocalTime(); |
|||
} |
|||
else |
|||
{ |
|||
dt = Convert.ToDateTime(gmt); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Class_Log log = new Class_Log(); |
|||
log.WriteLogFile(ex.ToString(), "Temp113"); |
|||
} |
|||
return dt; |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 请求云端方法,带加解密
|
|||
/// </summary>
|
|||
/// <param name="method"></param>
|
|||
/// <param name="data"></param>
|
|||
/// <returns></returns>
|
|||
public static string CryptPost(string method, object data, string httpurl = "") |
|||
{ |
|||
string _result = string.Empty; |
|||
if (!app.IsCanConnect) |
|||
{ |
|||
return _result; |
|||
} |
|||
try |
|||
{ |
|||
var timeStamp = CommonLib.CurrentTime(); |
|||
if (string.IsNullOrEmpty(httpurl)) |
|||
{ |
|||
httpurl = app.HttpUrl; |
|||
} |
|||
var token = SecurityHelper.AesEncrypt(method + timeStamp); |
|||
string postUrl = string.Concat(httpurl, method, "?token=", HttpUtility.UrlEncode(token), "&time=", timeStamp); |
|||
string contentType = "application/json; charset=utf-8"; |
|||
string body = SecurityHelper.AesEncrypt(JsonConvert.SerializeObject(data)); |
|||
_result = Post(postUrl, body, contentType); |
|||
_result = SecurityHelper.AesDecrypt(_result); |
|||
//var Jo = JObject.Parse(res);
|
|||
//string code = Jo.Value<string>("code");
|
|||
//if (code == ResultCode.Success)
|
|||
//{
|
|||
// _result.Code = code;
|
|||
// _result.Msg = Jo.Value<string>("msg");
|
|||
// _result.Data = Jo.Value<JObject>("data").ToObject<T>();
|
|||
//}
|
|||
//else
|
|||
//{
|
|||
// _result.Code = code;
|
|||
// _result.Msg = Jo.Value<string>("msg");
|
|||
//}
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Mylog.WriteLogFile("请求错误" + ex.ToString(), "MyHttpClientError"); |
|||
} |
|||
return _result; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,326 @@ |
|||
using NAudio.Wave; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class Recorder |
|||
{ |
|||
Class_Log _log = new Class_Log(); |
|||
private int deviceNumber = 0; // 选择的录音设备下标。多个设备时可设置为用户选择
|
|||
private WaveIn waveIn; // waveIn操作类
|
|||
private WaveFormat recordingFormat; // 录音格式
|
|||
private WaveFileWriter writer; // 录音文件操作类
|
|||
public event EventHandler StoppedEvent = delegate { }; // 录音结束事件
|
|||
public event EventHandler DataAvailableEvent = delegate { }; // 录音过程中接收到数据事件
|
|||
//private RichTextBox textbox; // waveIn操作类
|
|||
private byte[] wavdata; |
|||
private int aud_stat = AudioStatus.MSP_AUDIO_SAMPLE_FIRST;//音频状态
|
|||
|
|||
StringBuilder result = new StringBuilder();//存储最终识别的结果
|
|||
int totalLength = 0;//用来记录总的识别后的结果的长度,判断是否超过缓存最大值
|
|||
private int ep_stat = EpStatus.MSP_EP_LOOKING_FOR_SPEECH;//端点状态
|
|||
private int rec_stat = RecogStatus.MSP_REC_STATUS_SUCCESS;//识别状态
|
|||
int errcode = (int)Errors.MSP_SUCCESS; |
|||
public double RecordedTime // 获取到录音的时长
|
|||
{ |
|||
get |
|||
{ |
|||
if (writer == null) |
|||
return 0; |
|||
return (double)writer.Length / writer.WaveFormat.AverageBytesPerSecond; |
|||
} |
|||
} |
|||
//public Recorder(RichTextBox box)
|
|||
//{
|
|||
// textbox = box;
|
|||
|
|||
//}
|
|||
/// <summary>
|
|||
/// 开始录音
|
|||
/// </summary>
|
|||
/// <param name="filename">保存的文件名</param>
|
|||
internal bool StartRecorder(string filename = "r.wav") |
|||
{ |
|||
// 设置录音格式WaveFormat(16000, 16, 1);
|
|||
//recordingFormat = new WaveFormat(16000, 8, WaveIn.GetCapabilities(deviceNumber).Channels);
|
|||
recordingFormat = new WaveFormat(16000, 16, 1); |
|||
// 设置麦克风操作对象
|
|||
waveIn = new WaveIn(); |
|||
waveIn.DeviceNumber = deviceNumber; // 设置使用的录音设备
|
|||
waveIn.DataAvailable += OnDataAviailable; // 接收到音频数据时,写入文件
|
|||
waveIn.RecordingStopped += OnRecordingStopped; // 录音结束时执行
|
|||
waveIn.WaveFormat = recordingFormat; |
|||
// 设置文件操作类
|
|||
writer = new WaveFileWriter(filename, recordingFormat); |
|||
// 开始录音
|
|||
waveIn.StartRecording(); |
|||
int errcode = (int)Errors.MSP_SUCCESS; |
|||
string session_begin_params = "sub=iat,domain=iat,language=zh_cn,accent=mandarin,sample_rate=16000,result_type=plain,result_encoding=gb2312"; |
|||
IatNativeMethods.session_id = IatNativeMethods.QISRSessionBegin(null, session_begin_params, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
_log.WriteLogFile("开始一次语音识别失败!"); |
|||
//Thread t = new Thread(run_iat);
|
|||
//t.Start();
|
|||
return true; |
|||
} |
|||
|
|||
private void run_iat(byte[] _wavdata) |
|||
{ |
|||
wavdata = _wavdata; |
|||
if (wavdata == null || wavdata.Length == 0) |
|||
{ |
|||
try |
|||
{ |
|||
wavdata = System.IO.File.ReadAllBytes("wav/test.wav"); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
//System.Diagnostics.Debug.WriteLine(e.Message);
|
|||
//wavdata = null;
|
|||
} |
|||
} |
|||
//wavdata = System.IO.File.ReadAllBytes("wav/r.wav");
|
|||
|
|||
int res = IatNativeMethods.QISRAudioWrite(IatNativeMethods.session_id, wavdata, (uint)wavdata.Length, aud_stat, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
_log.WriteLogFile("写入识别的音频失败!" + res); |
|||
//this.textbox.Dispatcher.Invoke(new Action(delegate
|
|||
//{
|
|||
// textbox.AppendText("写入识别的音频失败!" + res + "\r\n");
|
|||
//}));
|
|||
return; |
|||
} |
|||
if (RecogStatus.MSP_REC_STATUS_SUCCESS != rec_stat) |
|||
{ |
|||
IntPtr now_result = IatNativeMethods.QISRGetResult(IatNativeMethods.session_id, ref rec_stat, 0, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
_log.WriteLogFile("获取结果失败:" + errcode); |
|||
//this.textbox.Dispatcher.Invoke(new Action(delegate
|
|||
//{
|
|||
// textbox.AppendText("获取结果失败:" + errcode + "\r\n");
|
|||
//}));
|
|||
return; |
|||
} |
|||
if (now_result != null) |
|||
{ |
|||
int length = now_result.ToString().Length; |
|||
totalLength += length; |
|||
if (totalLength > 4096) |
|||
{ |
|||
_log.WriteLogFile("缓存空间不够" + totalLength); |
|||
//this.textbox.Dispatcher.Invoke(new Action(delegate
|
|||
//{
|
|||
// textbox.AppendText("缓存空间不够:" + totalLength + "\r\n");
|
|||
//}));
|
|||
} |
|||
//result.Append(Marshal.PtrToStringAnsi(now_result));
|
|||
} |
|||
} |
|||
//if (result.Length > 0)
|
|||
//{
|
|||
// //_log.WriteLogFile("中间识别语音:" + result.ToString());
|
|||
// this.textbox.Dispatcher.Invoke(new Action(
|
|||
// delegate
|
|||
// {
|
|||
// textbox.AppendText("中间识别语音:" + result.ToString() + "\r\n");
|
|||
// }
|
|||
// )
|
|||
// );
|
|||
//}
|
|||
if (EpStatus.MSP_EP_AFTER_SPEECH == ep_stat) |
|||
{ |
|||
//run_iatlast();
|
|||
StopRecorder(); |
|||
|
|||
return; |
|||
} |
|||
//Thread.Sleep(150);//防止频繁占用cpu
|
|||
} |
|||
|
|||
private void run_iatlast() |
|||
{ |
|||
|
|||
var res = IatNativeMethods.QISRAudioWrite(IatNativeMethods.session_id, null, 0, AudioStatus.MSP_AUDIO_SAMPLE_LAST, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
_log.WriteLogFile("写入音频失败!" + res); |
|||
while (RecogStatus.MSP_REC_STATUS_COMPLETE != rec_stat) |
|||
{ |
|||
IntPtr now_result = IatNativeMethods.QISRGetResult(IatNativeMethods.session_id, ref rec_stat, 0, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
_log.WriteLogFile("获取结果失败:" + errcode); |
|||
return; |
|||
} |
|||
if (now_result != null) |
|||
{ |
|||
int length = now_result.ToString().Length; |
|||
totalLength += length; |
|||
if (totalLength > 4096) |
|||
_log.WriteLogFile("缓存空间不够" + totalLength); |
|||
result.Append(Marshal.PtrToStringAnsi(now_result)); |
|||
} |
|||
Thread.Sleep(150);//防止频繁占用cpu
|
|||
} |
|||
int ret = IatNativeMethods.QISRSessionEnd(IatNativeMethods.session_id, "normal end"); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
_log.WriteLogFile("QISRSessionEnd failed, error code is: %d" + ret); |
|||
} |
|||
if (result.Length > 0) |
|||
{ |
|||
_log.WriteLogFile("识别语音:" + result.ToString()); |
|||
//this.textbox.Dispatcher.Invoke(new Action(
|
|||
// delegate
|
|||
// {
|
|||
// textbox.AppendText("识别语音:" + result.ToString() + "\r\n");
|
|||
// textbox.ScrollToEnd();
|
|||
// }
|
|||
// )
|
|||
//);
|
|||
} |
|||
} |
|||
/// <summary>
|
|||
/// 结束录音
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
internal bool StopRecorder() |
|||
{ |
|||
waveIn.StopRecording(); |
|||
return true; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 录音结束回调函数
|
|||
/// </summary>
|
|||
/// <param name="sender"></param>
|
|||
/// <param name="e"></param>
|
|||
private void OnRecordingStopped(object sender, StoppedEventArgs e) |
|||
{ |
|||
// this.textbox.Dispatcher.Invoke(new Action(
|
|||
// delegate
|
|||
// {
|
|||
// textbox.AppendText("结束录音\r\n");
|
|||
// }
|
|||
// )
|
|||
//);
|
|||
writer.Dispose(); |
|||
run_iatlast(); |
|||
// 通知结束事件
|
|||
StoppedEvent(this, EventArgs.Empty); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 录音回调函数,写入数据
|
|||
/// </summary>
|
|||
/// <param name="sender"></param>
|
|||
/// <param name="e"></param>
|
|||
private void OnDataAviailable(object sender, WaveInEventArgs e) |
|||
{ |
|||
|
|||
byte[] buffer = e.Buffer; |
|||
int bytesRecorded = e.BytesRecorded; |
|||
//wavdata = e.Buffer;
|
|||
long maxFileLength = this.recordingFormat.AverageBytesPerSecond * 60; |
|||
var toWrite = (int)Math.Min(maxFileLength - writer.Length, bytesRecorded); |
|||
//textbox.AppendText("e.BytesRecorded" + e.BytesRecorded);
|
|||
//textbox.ScrollToEnd();
|
|||
if (toWrite > 0) |
|||
{ |
|||
//textbox.AppendText(totalLength + "run_iat" + e.BytesRecorded + "\r\n");
|
|||
//textbox.ScrollToEnd();
|
|||
writer.Write(buffer, 0, bytesRecorded); |
|||
run_iat(buffer); |
|||
aud_stat = AudioStatus.MSP_AUDIO_SAMPLE_CONTINUE; |
|||
} |
|||
//string audio_path = "wav/test.wav";
|
|||
//string session_begin = "sub=iat,domain=iat,language=zh_cn,accent=mandarin,sample_rate=16000,result_type=plain,result_encoding=gb2312";
|
|||
//string ret = IatNativeMethods.localaudio_iat(audio_path);
|
|||
//this.textbox.Dispatcher.Invoke(new Action(
|
|||
// delegate
|
|||
// {
|
|||
// textbox.AppendText("ret" + ret);
|
|||
// }
|
|||
// )
|
|||
// );
|
|||
//WriteToFile(buffer, bytesRecorded); // 音频数据写入文件
|
|||
DataAvailableEvent(this, EventArgs.Empty); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 写入文件
|
|||
/// </summary>
|
|||
/// <param name="buffer"></param>
|
|||
/// <param name="bytesRecorded"></param>
|
|||
private void WriteToFile(byte[] buffer, int bytesRecorded) |
|||
{ |
|||
long maxFileLength = this.recordingFormat.AverageBytesPerSecond * 60; |
|||
|
|||
var toWrite = (int)Math.Min(maxFileLength - writer.Length, bytesRecorded); |
|||
if (toWrite > 0) |
|||
{ |
|||
writer.Write(buffer, 0, bytesRecorded); |
|||
} |
|||
else |
|||
{ |
|||
StopRecorder(); |
|||
} |
|||
} |
|||
|
|||
private void wis_DataAvailable(object sender, WaveInEventArgs e) |
|||
{ |
|||
System.Console.WriteLine(System.DateTime.Now + ":" + System.DateTime.Now.Millisecond); |
|||
|
|||
int ret = 0; |
|||
IntPtr bp = Marshal.AllocHGlobal(e.BytesRecorded); |
|||
int status = AudioStatus.MSP_AUDIO_SAMPLE_CONTINUE; |
|||
int ep_status = EpStatus.MSP_EP_LOOKING_FOR_SPEECH; |
|||
int rec_status = RecogStatus.MSP_REC_STATUS_SUCCESS; |
|||
int rslt_status = RecogStatus.MSP_REC_STATUS_SUCCESS; |
|||
int errcode = (int)Errors.MSP_SUCCESS; |
|||
int totalLength = 0;//用来记录总的识别后的结果的长度,判断是否超过缓存最大值
|
|||
StringBuilder result = new StringBuilder();//存储最终识别的结果
|
|||
|
|||
///ep_status 端点检测(End-point detected)器所处的状态
|
|||
///rec_status 识别器所处的状态
|
|||
///rslt_status 识别器所处的状态
|
|||
Marshal.Copy(e.Buffer, 0, bp, e.BytesRecorded); |
|||
///开始向服务器发送音频数据
|
|||
ret = IatNativeMethods.QISRAudioWrite(IatNativeMethods.session_id, bp, (uint)e.BytesRecorded, status, ref ep_status, ref rec_status); |
|||
if (ret != 0) throw new Exception("QISRAudioWrite err,errCode=" + ((Errors)ret).ToString("G")); |
|||
|
|||
///服务器返回部分结果
|
|||
if (rec_status == RecogStatus.MSP_REC_STATUS_SUCCESS) |
|||
{ |
|||
IntPtr now_result = IatNativeMethods.QISRGetResult(IatNativeMethods.session_id, ref rec_status, 0, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
_log.WriteLogFile("获取结果失败:" + errcode); |
|||
return; |
|||
} |
|||
if (now_result != null) |
|||
{ |
|||
int length = now_result.ToString().Length; |
|||
totalLength += length; |
|||
if (totalLength > 4096) |
|||
{ |
|||
_log.WriteLogFile("缓存空间不够" + totalLength); |
|||
return; |
|||
} |
|||
result.Append(Marshal.PtrToStringAnsi(now_result)); |
|||
} |
|||
Thread.Sleep(150);//防止频繁占用cpu
|
|||
} |
|||
System.Threading.Thread.Sleep(500); |
|||
Marshal.FreeHGlobal(bp); |
|||
//System.Console.WriteLine(System.DateTime.Now + ":" + System.DateTime.Now.Millisecond);
|
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,95 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Security.Cryptography; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
/// <summary>
|
|||
/// 加密解密类
|
|||
/// </summary>
|
|||
public class SecurityHelper |
|||
{ |
|||
#region AES加密解密
|
|||
private static App app = ((App)System.Windows.Application.Current); |
|||
/// <summary>
|
|||
/// 128位处理key
|
|||
/// </summary>
|
|||
/// <param name="keyArray">原字节</param>
|
|||
/// <param name="key">处理key</param>
|
|||
/// <returns></returns>
|
|||
private static byte[] GetAesKey(byte[] keyArray, string key) |
|||
{ |
|||
byte[] newArray = new byte[16]; |
|||
if (keyArray.Length < 16) |
|||
{ |
|||
for (int i = 0; i < newArray.Length; i++) |
|||
{ |
|||
if (i >= keyArray.Length) |
|||
{ |
|||
newArray[i] = 0; |
|||
} |
|||
else |
|||
{ |
|||
newArray[i] = keyArray[i]; |
|||
} |
|||
} |
|||
} |
|||
else |
|||
newArray = keyArray; |
|||
|
|||
return newArray; |
|||
} |
|||
/// <summary>
|
|||
/// 使用AES加密字符串,按128位处理key
|
|||
/// </summary>
|
|||
/// <param name="content">加密内容</param>
|
|||
/// <param name="key">秘钥,需要128位、256位.....</param>
|
|||
/// <returns>Base64字符串结果</returns>
|
|||
public static string AesEncrypt(string content, bool autoHandle = true) |
|||
{ |
|||
byte[] keyArray = Encoding.UTF8.GetBytes(app.SecurityKey); |
|||
if (autoHandle) |
|||
{ |
|||
keyArray = GetAesKey(keyArray, app.SecurityKey); |
|||
} |
|||
byte[] toEncryptArray = Encoding.UTF8.GetBytes(content); |
|||
|
|||
SymmetricAlgorithm des = Aes.Create(); |
|||
des.Key = keyArray; |
|||
des.Mode = CipherMode.ECB; |
|||
des.Padding = PaddingMode.PKCS7; |
|||
ICryptoTransform cTransform = des.CreateEncryptor(); |
|||
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); |
|||
return Convert.ToBase64String(resultArray); |
|||
} |
|||
/// <summary>
|
|||
/// 使用AES解密字符串,按128位处理key
|
|||
/// </summary>
|
|||
/// <param name="content">内容</param>
|
|||
/// <param name="key">秘钥,需要128位、256位.....</param>
|
|||
/// <returns>UTF8解密结果</returns>
|
|||
public static string AesDecrypt(string content, bool autoHandle = true) |
|||
{ |
|||
byte[] keyArray = Encoding.UTF8.GetBytes(app.SecurityKey); |
|||
if (autoHandle) |
|||
{ |
|||
keyArray = GetAesKey(keyArray, app.SecurityKey); |
|||
} |
|||
byte[] toEncryptArray = Convert.FromBase64String(content); |
|||
|
|||
SymmetricAlgorithm des = Aes.Create(); |
|||
des.Key = keyArray; |
|||
des.Mode = CipherMode.ECB; |
|||
des.Padding = PaddingMode.PKCS7; |
|||
|
|||
ICryptoTransform cTransform = des.CreateDecryptor(); |
|||
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); |
|||
|
|||
return Encoding.UTF8.GetString(resultArray); |
|||
} |
|||
#endregion
|
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
/// <summary>
|
|||
/// 判断文件类型是不是图片
|
|||
/// </summary>
|
|||
internal sealed class TypeImg : IJudgeFileType |
|||
{ |
|||
public static readonly List<string> ImgTypes = new List<string> { |
|||
//"bmp", "png", "gif", "jpg", "jpeg", "tfs", "psd", "tif"
|
|||
"bmp", "png", "jpg", "jpeg" |
|||
}; |
|||
public bool JudgeFileType(string ext) |
|||
{ |
|||
if (ImgTypes.Contains(ext.ToLower())) |
|||
{ |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
/// <summary>
|
|||
/// 判断文件类型是不是视频
|
|||
/// </summary>
|
|||
internal sealed class TypeVideo : IJudgeFileType |
|||
{ |
|||
public static readonly List<string> VideoTypes = new List<string> { |
|||
"mp4", |
|||
"wmv", "asf", "asx",//微软视频 :wmv、asf、asx
|
|||
"rm", "rmvb",//Real Player :rm、 rmvb
|
|||
"mpg","mpeg","mpe",//MPEG视频 :mpg、mpeg、mpe
|
|||
"3gp",//手机视频 :3gp
|
|||
"mov",//Apple视频 :mov
|
|||
"mp4", "m4v",//Sony视频 :mp4、m4v
|
|||
"avi", "dat", "mkv", "flv", "vob" , "wvx", "mpa", //其他常见视频:avi、dat、mkv、flv、vob、wvx、mpa
|
|||
"m4k","webm","ogv","f4v","swf" |
|||
}; |
|||
public bool JudgeFileType(string ext) |
|||
{ |
|||
if (VideoTypes.Contains(ext.ToLower())) |
|||
{ |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,335 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Security; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
class VlcPlayer |
|||
{ |
|||
private IntPtr libvlc_instance_; |
|||
private IntPtr libvlc_media_player_; |
|||
|
|||
private double duration_; |
|||
public VlcPlayer(string pluginPath, bool isTransform) |
|||
{ |
|||
/* |
|||
* --avcodec-hurry-up, --no-avcodec-hurry-up |
|||
紧急 (默认启用) |
|||
解码器在时间不充足的情况下可能部分解码器或跳过帧。在 CPU 不是很强大时这非常有用,但是可能会破坏图像。 (默认启用) |
|||
* --sout-avcodec-rc-buffer-size=<整数 [-2147483648 .. 2147483647]> |
|||
速率控制缓存大小 |
|||
速率控制缓存大小 (以千字节为单位)。一个较大的缓存将会有较佳的帧率控制,但是可能会导致流的延迟。 |
|||
* --avcodec-fast, --no-avcodec-fast |
|||
允许非正常速度优化 (默认关闭) |
|||
允许不符合标准的速度优化。更快但可能会出错。 (默认关闭) |
|||
--avcodec-skiploopfilter={0 (无), 1 (非参考), 2 (双向), 3 (非关键), 4 (全部)} |
|||
用于 H.264 解码的跳过循环滤镜 |
|||
跳过循环滤镜 (又作去块) 通常对图像质量会造成不良的效果。但是它能为高分辨率的流提供一个很大的提速。 |
|||
* --avcodec-codec=<字串> 编解码器名称 |
|||
libavcodec 内部编解码器名称 |
|||
--avcodec-hw=<字串> 硬件解码 |
|||
这将允许硬件解码(当硬件解码可用时)。 |
|||
* --drop-late-frames, --no-drop-late-frames |
|||
丢弃延迟的帧 (默认启用) |
|||
这将丢弃延迟的帧 (在它们实际应该显示的时间后到达视频输出)。 (默认启用) |
|||
--skip-frames, --no-skip-frames |
|||
跳帧 (默认启用) |
|||
在 MPEG2 串流上启用帧丢弃。帧丢弃在您的计算机性能不够强大时发生 (默认启用) |
|||
*/ |
|||
string plugin_arg = "--plugin-path=" + pluginPath; |
|||
string[] arguments = { plugin_arg, "--network-caching=<300", ":sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100" }; |
|||
//string[] arguments = { plugin_arg, "--network-caching=<300", ":sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100" };
|
|||
string[] argumentTransform = { "-I", "dummy", "--ignore-config", "--video-title", plugin_arg, "--avcodec-skiploopfilter=4", "--avcodec-fast", "--network-caching<=1800", "pe=270", ":sout=#transcode{vcodec=h264,acodec=mpga,ab=128,channels=2,samplerate=44100" }; |
|||
//sring[] arguments = { "-I", "--avcodec-hw=any", plugin_arg,"--avcodec-codec=q//", "--avcodec-skiploopfilter=4", "--avcodec-fast", "--network-caching=<1800" };
|
|||
|
|||
//if (isTransform)
|
|||
// libvlc_instance_ = LibVlcAPI.libvlc_new(argumentTransform);
|
|||
//else
|
|||
libvlc_instance_ = LibVlcAPI.libvlc_new(arguments); |
|||
|
|||
libvlc_media_player_ = LibVlcAPI.libvlc_media_player_new(libvlc_instance_); |
|||
} |
|||
|
|||
public void SetRenderWindow(int wndHandle) |
|||
{ |
|||
if (libvlc_instance_ != IntPtr.Zero && wndHandle != 0) |
|||
{ |
|||
LibVlcAPI.libvlc_media_player_set_hwnd(libvlc_media_player_, wndHandle); |
|||
} |
|||
} |
|||
|
|||
public void PlayFile(string filePath) |
|||
{ |
|||
IntPtr libvlc_media = LibVlcAPI.libvlc_media_new_path(libvlc_instance_, filePath); |
|||
if (libvlc_media != IntPtr.Zero) |
|||
{ |
|||
LibVlcAPI.libvlc_media_parse(libvlc_media); |
|||
|
|||
duration_ = LibVlcAPI.libvlc_media_get_duration(libvlc_media) / 1000.0; |
|||
|
|||
LibVlcAPI.libvlc_media_player_set_media(libvlc_media_player_, libvlc_media); |
|||
LibVlcAPI.libvlc_media_release(libvlc_media); |
|||
|
|||
LibVlcAPI.libvlc_media_player_play(libvlc_media_player_); |
|||
} |
|||
} |
|||
|
|||
public void PlayStream(string url) |
|||
{ |
|||
IntPtr libvlc_media = LibVlcAPI.libvlc_media_new_location(libvlc_instance_, url); |
|||
if (libvlc_media != IntPtr.Zero) |
|||
{ |
|||
LibVlcAPI.libvlc_media_player_set_media(libvlc_media_player_, libvlc_media); |
|||
LibVlcAPI.libvlc_media_release(libvlc_media); |
|||
|
|||
LibVlcAPI.libvlc_media_player_play(libvlc_media_player_); |
|||
|
|||
LibVlcAPI.libvlc_media_parse(libvlc_media); |
|||
|
|||
Thread.Sleep(300); |
|||
|
|||
duration_ = LibVlcAPI.libvlc_media_get_duration(libvlc_media) / 1000.0; |
|||
} |
|||
} |
|||
|
|||
public void Pause() |
|||
{ |
|||
if (libvlc_media_player_ != IntPtr.Zero) |
|||
{ |
|||
LibVlcAPI.libvlc_media_player_pause(libvlc_media_player_); |
|||
} |
|||
} |
|||
|
|||
public void Stop() |
|||
{ |
|||
if (libvlc_media_player_ != IntPtr.Zero) |
|||
{ |
|||
LibVlcAPI.libvlc_media_player_stop(libvlc_media_player_); |
|||
} |
|||
} |
|||
|
|||
public double GetPlayTime() |
|||
{ |
|||
return LibVlcAPI.libvlc_media_player_get_time(libvlc_media_player_) / 1000.0; |
|||
} |
|||
|
|||
public void SetPlayTime(double seekTime) |
|||
{ |
|||
LibVlcAPI.libvlc_media_player_set_time(libvlc_media_player_, (Int64)(seekTime * 1000)); |
|||
} |
|||
|
|||
public int GetVolume() |
|||
{ |
|||
return LibVlcAPI.libvlc_audio_get_volume(libvlc_media_player_); |
|||
} |
|||
|
|||
public void SetVolume(int volume) |
|||
{ |
|||
LibVlcAPI.libvlc_audio_set_volume(libvlc_media_player_, volume); |
|||
} |
|||
|
|||
public void SetFullScreen(bool istrue) |
|||
{ |
|||
LibVlcAPI.libvlc_set_fullscreen(libvlc_media_player_, istrue ? 1 : 0); |
|||
} |
|||
|
|||
public double Duration() |
|||
{ |
|||
return duration_; |
|||
} |
|||
|
|||
public string Version() |
|||
{ |
|||
return LibVlcAPI.libvlc_get_version(); |
|||
} |
|||
} |
|||
|
|||
internal static class LibVlcAPI |
|||
{ |
|||
internal struct PointerToArrayOfPointerHelper |
|||
{ |
|||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 11)] |
|||
public IntPtr[] pointers; |
|||
} |
|||
|
|||
public static IntPtr libvlc_new(string[] arguments) |
|||
{ |
|||
PointerToArrayOfPointerHelper argv = new PointerToArrayOfPointerHelper(); |
|||
argv.pointers = new IntPtr[11]; |
|||
|
|||
for (int i = 0; i < arguments.Length; i++) |
|||
{ |
|||
argv.pointers[i] = Marshal.StringToHGlobalAnsi(arguments[i]); |
|||
} |
|||
|
|||
IntPtr argvPtr = IntPtr.Zero; |
|||
try |
|||
{ |
|||
int size = Marshal.SizeOf(typeof(PointerToArrayOfPointerHelper)); |
|||
argvPtr = Marshal.AllocHGlobal(size); |
|||
Marshal.StructureToPtr(argv, argvPtr, false); |
|||
|
|||
return libvlc_new(arguments.Length, argvPtr); |
|||
} |
|||
finally |
|||
{ |
|||
for (int i = 0; i < arguments.Length + 1; i++) |
|||
{ |
|||
if (argv.pointers[i] != IntPtr.Zero) |
|||
{ |
|||
Marshal.FreeHGlobal(argv.pointers[i]); |
|||
} |
|||
} |
|||
if (argvPtr != IntPtr.Zero) |
|||
{ |
|||
Marshal.FreeHGlobal(argvPtr); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static IntPtr libvlc_media_new_path(IntPtr libvlc_instance, string path) |
|||
{ |
|||
IntPtr pMrl = IntPtr.Zero; |
|||
try |
|||
{ |
|||
byte[] bytes = Encoding.UTF8.GetBytes(path); |
|||
pMrl = Marshal.AllocHGlobal(bytes.Length + 1); |
|||
Marshal.Copy(bytes, 0, pMrl, bytes.Length); |
|||
Marshal.WriteByte(pMrl, bytes.Length, 0); |
|||
return libvlc_media_new_path(libvlc_instance, pMrl); |
|||
} |
|||
finally |
|||
{ |
|||
if (pMrl != IntPtr.Zero) |
|||
{ |
|||
Marshal.FreeHGlobal(pMrl); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public static IntPtr libvlc_media_new_location(IntPtr libvlc_instance, string path) |
|||
{ |
|||
IntPtr pMrl = IntPtr.Zero; |
|||
try |
|||
{ |
|||
byte[] bytes = Encoding.UTF8.GetBytes(path); |
|||
pMrl = Marshal.AllocHGlobal(bytes.Length + 1); |
|||
Marshal.Copy(bytes, 0, pMrl, bytes.Length); |
|||
Marshal.WriteByte(pMrl, bytes.Length, 0); |
|||
return libvlc_media_new_location(libvlc_instance, pMrl); |
|||
} |
|||
finally |
|||
{ |
|||
if (pMrl != IntPtr.Zero) |
|||
{ |
|||
Marshal.FreeHGlobal(pMrl); |
|||
} |
|||
} |
|||
} |
|||
|
|||
// ----------------------------------------------------------------------------------------
|
|||
// 以下是libvlc.dll导出函数
|
|||
|
|||
// 创建一个libvlc实例,它是引用计数的
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
private static extern IntPtr libvlc_new(int argc, IntPtr argv); |
|||
|
|||
// 释放libvlc实例
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_release(IntPtr libvlc_instance); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern String libvlc_get_version(); |
|||
|
|||
// 从视频来源(例如Url)构建一个libvlc_meida
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
private static extern IntPtr libvlc_media_new_location(IntPtr libvlc_instance, IntPtr path); |
|||
|
|||
// 从本地文件路径构建一个libvlc_media
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
private static extern IntPtr libvlc_media_new_path(IntPtr libvlc_instance, IntPtr path); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_release(IntPtr libvlc_media_inst); |
|||
|
|||
// 创建libvlc_media_player(播放核心)
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern IntPtr libvlc_media_player_new(IntPtr libvlc_instance); |
|||
|
|||
// 将视频(libvlc_media)绑定到播放器上
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_player_set_media(IntPtr libvlc_media_player, IntPtr libvlc_media); |
|||
|
|||
// 设置图像输出的窗口
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_player_set_hwnd(IntPtr libvlc_mediaplayer, Int32 drawable); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_player_play(IntPtr libvlc_mediaplayer); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_player_pause(IntPtr libvlc_mediaplayer); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_player_stop(IntPtr libvlc_mediaplayer); |
|||
|
|||
// 解析视频资源的媒体信息(如时长等)
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_parse(IntPtr libvlc_media); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern bool libvlc_media_is_parsed(IntPtr libvlc_media); |
|||
|
|||
// 返回视频的时长(必须先调用libvlc_media_parse之后,该函数才会生效)
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern Int64 libvlc_media_get_duration(IntPtr libvlc_media); |
|||
|
|||
// 当前播放的时间
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern Int64 libvlc_media_player_get_time(IntPtr libvlc_mediaplayer); |
|||
|
|||
// 设置播放位置(拖动)
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_player_set_time(IntPtr libvlc_mediaplayer, Int64 time); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_media_player_release(IntPtr libvlc_mediaplayer); |
|||
|
|||
// 获取和设置音量
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern int libvlc_audio_get_volume(IntPtr libvlc_media_player); |
|||
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_audio_set_volume(IntPtr libvlc_media_player, int volume); |
|||
|
|||
// 设置全屏
|
|||
[DllImport("libvlc", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)] |
|||
[SuppressUnmanagedCodeSecurity] |
|||
public static extern void libvlc_set_fullscreen(IntPtr libvlc_media_player, int isFullScreen); |
|||
} |
|||
} |
|||
@ -0,0 +1,137 @@ |
|||
using System; |
|||
using System.Configuration; |
|||
using System.Threading; |
|||
using WebSocket4Net; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class WebSocketForFaceManage |
|||
{ |
|||
private WebSocket websocket = null; |
|||
App app = ((App)System.Windows.Application.Current); |
|||
public delegate void WebSocketReceiveDelegate(string type, string message); |
|||
public static event WebSocketReceiveDelegate WebSocketReceiveEvent; |
|||
private Class_Log log = new Class_Log(); |
|||
bool reconnect = false; |
|||
#region WebSocketClient
|
|||
|
|||
public void OpenWebSocket() |
|||
{ |
|||
try |
|||
{ |
|||
var ws = ConfigurationManager.AppSettings["websocketForFace"]; |
|||
log.WriteLogFile(ws, "rich"); |
|||
websocket = new WebSocket(ws); |
|||
websocket.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(websocket_Error); |
|||
websocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(websocket_MessageReceived); |
|||
websocket.Open(); |
|||
//websocket.Opened += new EventHandler(websocket_Opened);
|
|||
websocket.Closed += new EventHandler(websocket_Closed); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString()); |
|||
} |
|||
} |
|||
|
|||
void websocket_Closed(object sender, EventArgs e) |
|||
{ |
|||
if (!reconnect) |
|||
{ |
|||
reconnect = true; |
|||
ReConnect(); |
|||
} |
|||
} |
|||
|
|||
public void CloseWebSocket() |
|||
{ |
|||
if (websocket != null) |
|||
{ |
|||
reconnect = true; |
|||
websocket.Close(); |
|||
} |
|||
|
|||
} |
|||
|
|||
void websocket_MessageReceived(object sender, MessageReceivedEventArgs e) |
|||
{ |
|||
log.WriteLogFile("进来了", "rich"); |
|||
try |
|||
{ |
|||
WebSocketReceiveEvent("richad", ""); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "WebSocketLog"); |
|||
|
|||
} |
|||
} |
|||
|
|||
void websocket_Error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e) |
|||
{ |
|||
|
|||
log.WriteLogFile(e.Exception.Message + e.Exception.StackTrace, "WebSocketErrorLog"); |
|||
//try
|
|||
//{
|
|||
// if (websocket != null)
|
|||
// websocket.Close();
|
|||
//}
|
|||
//catch
|
|||
//{
|
|||
//}
|
|||
//ReConnect();
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// websocket重连
|
|||
/// </summary>
|
|||
private void ReConnect() |
|||
{ |
|||
try |
|||
{ |
|||
Action ac = new Action(() => |
|||
{ |
|||
while (true) |
|||
{ |
|||
try |
|||
{ |
|||
if (websocket.State == WebSocketState.Closed) |
|||
{ |
|||
Thread.Sleep(30000); |
|||
|
|||
if (websocket.State == WebSocketState.Closed) |
|||
websocket.Open(); |
|||
} |
|||
|
|||
if (websocket.State == WebSocketState.Open) |
|||
{ |
|||
//reconnect = false;
|
|||
break; |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "WebSocketErrorLog"); |
|||
} |
|||
finally |
|||
{ |
|||
Thread.Sleep(3000); |
|||
} |
|||
|
|||
|
|||
} |
|||
}); |
|||
ac.BeginInvoke((o) => |
|||
{ |
|||
reconnect = false; |
|||
}, null); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "WebSocketErrorLog"); |
|||
} |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
} |
|||
@ -0,0 +1,182 @@ |
|||
using System; |
|||
using System.Configuration; |
|||
using System.Threading; |
|||
using WebSocket4Net; |
|||
|
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class WebSocketForProgram |
|||
{ |
|||
private WebSocket websocket = null; |
|||
App app = ((App)System.Windows.Application.Current); |
|||
public delegate void WebSocketReceiveDelegate(string type, string message); |
|||
public static event WebSocketReceiveDelegate WebSocketReceiveEvent; |
|||
private Class_Log log = new Class_Log(); |
|||
bool reconnect = false; |
|||
#region WebSocketClient
|
|||
|
|||
public void OpenWebSocket() |
|||
{ |
|||
try |
|||
{ |
|||
//var ws = ConfigurationManager.AppSettings["websocketProgram"];
|
|||
var ws = "ws://" + app.websocketProgramIP + ":" + ConfigurationManager.AppSettings["websocketProgramPort"]; |
|||
log.WriteLogFile("ws--" + ws, "GetSyncDev"); |
|||
if (websocket != null) { |
|||
if (websocket.State == WebSocketState.Open) |
|||
{ |
|||
websocket.Close(); |
|||
} |
|||
websocket.Dispose(); |
|||
websocket = null; |
|||
} |
|||
websocket = new WebSocket(ws); |
|||
websocket.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(websocket_Error); |
|||
websocket.MessageReceived += new EventHandler<MessageReceivedEventArgs>(websocket_MessageReceived); |
|||
websocket.Opened += new EventHandler(websocket_Opened); |
|||
websocket.Closed += new EventHandler(websocket_Closed); |
|||
websocket.Open(); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString()); |
|||
} |
|||
} |
|||
|
|||
public void ReloadWebSocket() |
|||
{ |
|||
try |
|||
{ |
|||
if (websocket != null) |
|||
{ |
|||
reconnect = false; |
|||
websocket.Close(); |
|||
websocket.Dispose(); |
|||
websocket = null; |
|||
} |
|||
log.WriteLogFile("打开--", "GetSyncDev"); |
|||
OpenWebSocket(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile(e.ToString(), "WebSocketForProgramError"); |
|||
} |
|||
} |
|||
void websocket_Closed(object sender, EventArgs e) |
|||
{ |
|||
app.isProgramSync = false; |
|||
//if (!reconnect)
|
|||
//{
|
|||
// reconnect = true;
|
|||
// ReConnect();
|
|||
//}
|
|||
} |
|||
void websocket_Opened(object sender, EventArgs e) { |
|||
reconnect = false; |
|||
log.WriteLogFile("打开","客户端"); |
|||
app.isProgramSync = true; |
|||
} |
|||
|
|||
public void CloseWebSocket() |
|||
{ |
|||
|
|||
if (websocket != null) |
|||
{ |
|||
reconnect = true; |
|||
websocket.Close(); |
|||
} |
|||
|
|||
} |
|||
|
|||
void websocket_MessageReceived(object sender, MessageReceivedEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
WebSocketReceiveEvent("play", e.Message); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "WebSocketLog"); |
|||
|
|||
} |
|||
} |
|||
|
|||
void websocket_Error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e) |
|||
{ |
|||
log.WriteLogFile("失败"+e.ToString(), "客户端"); |
|||
app.isProgramSync = false; |
|||
//try
|
|||
//{
|
|||
// if (websocket != null)
|
|||
// websocket.Close();
|
|||
//}
|
|||
//catch
|
|||
//{
|
|||
//}
|
|||
//reconnect = true;
|
|||
//ReConnect();
|
|||
} |
|||
|
|||
/// <summary>
|
|||
/// websocket重连
|
|||
/// </summary>
|
|||
private void ReConnect() |
|||
{ |
|||
try |
|||
{ |
|||
Action ac = new Action(() => |
|||
{ |
|||
while (reconnect) |
|||
{ |
|||
log.WriteLogFile("重试"+ (websocket==null), "WebSocketForProgramErrorLog"); |
|||
try |
|||
{ |
|||
if (websocket != null) |
|||
{ |
|||
log.WriteLogFile("重试State" + websocket.State, "WebSocketForProgramErrorLog"); |
|||
if (websocket.State == WebSocketState.Closed) |
|||
{ |
|||
reconnect = false; |
|||
websocket.Open(); |
|||
} |
|||
|
|||
if (websocket.State == WebSocketState.Open) |
|||
{ |
|||
reconnect = false; |
|||
break; |
|||
} |
|||
} |
|||
else { |
|||
log.WriteLogFile("重试OpenWebSocket", "WebSocketForProgramErrorLog"); |
|||
//Thread.Sleep(10000);
|
|||
OpenWebSocket(); |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "WebSocketForProgramErrorLog"); |
|||
} |
|||
finally |
|||
{ |
|||
Thread.Sleep(10000); |
|||
} |
|||
|
|||
|
|||
} |
|||
}); |
|||
ac.BeginInvoke((o) => |
|||
{ |
|||
//reconnect = false;
|
|||
}, null); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile(ex.ToString(), "WebSocketForProgramErrorLog"); |
|||
} |
|||
} |
|||
|
|||
#endregion
|
|||
} |
|||
} |
|||
@ -0,0 +1,94 @@ |
|||
using Fleck; |
|||
using Newtonsoft.Json; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Configuration; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class WebsocketForProgramServer |
|||
{ |
|||
//public static ConcurrentDictionary<string, System.Net.WebSockets.WebSocket> _sockets = new ConcurrentDictionary<string, System.Net.WebSockets.WebSocket>();
|
|||
public static List<IWebSocketConnection> allSockets = new List<IWebSocketConnection>(); |
|||
|
|||
private static Class_Log log = new Class_Log(); //日志记录文件
|
|||
private static App app = ((App)System.Windows.Application.Current); |
|||
WebSocketServer server = null; |
|||
public void openSocket() |
|||
{ |
|||
|
|||
try |
|||
{ |
|||
allSockets.Clear(); |
|||
FleckLog.Level = LogLevel.Debug; |
|||
var ws = "ws://"+app.websocketProgramIP + ":"+ ConfigurationManager.AppSettings["websocketProgramPort"]; |
|||
server = new WebSocketServer(ws); |
|||
//RecognizerCLR.setBeamDir(serialPortname, microAngle);
|
|||
server.Start(socket => |
|||
{ |
|||
socket.OnOpen = () => //当建立Socket链接时执行此方法
|
|||
{ |
|||
//var data = socket.ConnectionInfo; //通过data可以获得这个链接传递过来的Cookie信息,用来区分各个链接和用户之间的关系(如果需要后台主动推送信息到某个客户的时候,可以使用Cookie)
|
|||
//Console.WriteLine("Open!");
|
|||
log.WriteLogFile(JsonConvert.SerializeObject(socket.ConnectionInfo.ClientIpAddress), "socket"); |
|||
IWebSocketConnection clearSocket = null; |
|||
foreach (var item in allSockets) |
|||
{ |
|||
if (item.ConnectionInfo.ClientIpAddress == socket.ConnectionInfo.ClientIpAddress) { |
|||
clearSocket = item; |
|||
break; |
|||
} |
|||
} |
|||
if (clearSocket != null) { |
|||
allSockets.Remove(clearSocket); |
|||
} |
|||
allSockets.Add(socket); |
|||
//log.WriteLogFile(JsonConvert.SerializeObject(allSockets), "socket");
|
|||
log.WriteLogFile(allSockets.Count.ToString(), "GetSyncDevServer"); |
|||
}; |
|||
|
|||
socket.OnClose = () =>// 当关闭Socket链接十执行此方法
|
|||
{ |
|||
|
|||
//Console.WriteLine("Close!");
|
|||
allSockets.Remove(socket); |
|||
}; |
|||
|
|||
socket.OnMessage = message =>// 接收客户端发送过来的信息
|
|||
{ |
|||
|
|||
}; |
|||
}); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile(e.ToString(), "recorderror"); |
|||
} |
|||
|
|||
} |
|||
|
|||
public void CloasSocket() { |
|||
try |
|||
{ |
|||
|
|||
if (server != null) |
|||
{ |
|||
server.Dispose(); |
|||
server = null; |
|||
} |
|||
allSockets.RemoveRange(0, allSockets.Count); |
|||
allSockets.Clear(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
log.WriteLogFile(e.Message, "ProgramServerError"); |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,630 @@ |
|||
using Container.Viewmodel; |
|||
using Fleck; |
|||
using NAudio.Wave; |
|||
using Newtonsoft.Json.Linq; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Configuration; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Net; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class WebsocketForVoice |
|||
{ |
|||
//public static ConcurrentDictionary<string, System.Net.WebSockets.WebSocket> _sockets = new ConcurrentDictionary<string, System.Net.WebSockets.WebSocket>();
|
|||
public static List<IWebSocketConnection> allSockets = new List<IWebSocketConnection>(); |
|||
static bool flag = true; |
|||
private static Class_Log log = new Class_Log(); //日志记录文件
|
|||
private static App app = ((App)System.Windows.Application.Current); |
|||
|
|||
|
|||
private int deviceNumber = 0; // 选择的录音设备下标。多个设备时可设置为用户选择
|
|||
private WaveIn waveIn; // waveIn操作类
|
|||
private WaveFormat recordingFormat; // 录音格式
|
|||
private WaveFileWriter writer; // 录音文件操作类
|
|||
public event EventHandler StoppedEvent = delegate { }; // 录音结束事件
|
|||
public event EventHandler DataAvailableEvent = delegate { }; // 录音过程中接收到数据事件
|
|||
private byte[] wavdata; |
|||
private int aud_stat = AudioStatus.MSP_AUDIO_SAMPLE_FIRST;//音频状态
|
|||
|
|||
StringBuilder result = new StringBuilder();//存储最终识别的结果
|
|||
int totalLength = 0;//用来记录总的识别后的结果的长度,判断是否超过缓存最大值
|
|||
private int ep_stat = EpStatus.MSP_EP_LOOKING_FOR_SPEECH;//端点状态
|
|||
private int rec_stat = RecogStatus.MSP_REC_STATUS_SUCCESS;//识别状态
|
|||
int errcode = (int)Errors.MSP_SUCCESS; |
|||
bool isClose = false; |
|||
|
|||
|
|||
public void openSocket() |
|||
{ |
|||
try |
|||
{ |
|||
IatNativeMethods.initVoice(); |
|||
// 设置录音格式WaveFormat(16000, 16, 1);
|
|||
//recordingFormat = new WaveFormat(16000, 8, WaveIn.GetCapabilities(deviceNumber).Channels);
|
|||
recordingFormat = new WaveFormat(16000, 16, 1); |
|||
// 设置麦克风操作对象
|
|||
waveIn = new WaveIn(); |
|||
waveIn.DeviceNumber = deviceNumber; // 设置使用的录音设备
|
|||
waveIn.DataAvailable += OnDataAviailable; // 接收到音频数据时,写入文件
|
|||
waveIn.RecordingStopped += OnRecordingStopped; // 录音结束时执行
|
|||
waveIn.WaveFormat = recordingFormat; |
|||
|
|||
FleckLog.Level = LogLevel.Debug; |
|||
var ws = ConfigurationManager.AppSettings["websocketUrlForVoice"]; |
|||
var server = new WebSocketServer(ws); |
|||
server.Start(socket => |
|||
{ |
|||
socket.OnOpen = () => //当建立Socket链接时执行此方法
|
|||
{ |
|||
allSockets.Add(socket); |
|||
}; |
|||
|
|||
socket.OnClose = () =>// 当关闭Socket链接十执行此方法
|
|||
{ |
|||
allSockets.Remove(socket); |
|||
}; |
|||
|
|||
socket.OnMessage = message =>// 接收客户端发送过来的信息
|
|||
{ |
|||
if (message == "record" && flag) |
|||
{ |
|||
startRecord(); |
|||
isClose = false; |
|||
} |
|||
else if (message == "close" && !flag) |
|||
{ |
|||
isClose = true; |
|||
StopRecorder(); |
|||
flag = true; |
|||
} |
|||
}; |
|||
}); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile(e.ToString(), "recorderror"); |
|||
} |
|||
|
|||
} |
|||
|
|||
|
|||
private void startRecord() |
|||
{ |
|||
flag = false; |
|||
log.WriteLogFile("录音进入时间" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"), "录音"); |
|||
try |
|||
{ |
|||
|
|||
StartRecorder(); |
|||
|
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile("---------22222222222-------" + "record" + e.Message, "recorderror"); |
|||
} |
|||
|
|||
} |
|||
|
|||
private static string PostUrl(string url, string postData) |
|||
{ |
|||
string result = string.Empty; |
|||
try |
|||
{ |
|||
HttpWebRequest wbRequest = (HttpWebRequest)WebRequest.Create(url); |
|||
wbRequest.Method = "POST"; |
|||
wbRequest.ContentType = "application/x-www-form-urlencoded"; |
|||
wbRequest.ContentLength = Encoding.UTF8.GetByteCount(postData); |
|||
|
|||
using (Stream requestStream = wbRequest.GetRequestStream()) |
|||
{ |
|||
using (StreamWriter swrite = new StreamWriter(requestStream)) |
|||
{ |
|||
swrite.Write(postData); |
|||
} |
|||
} |
|||
HttpWebResponse wbResponse = (HttpWebResponse)wbRequest.GetResponse(); |
|||
using (Stream responseStream = wbResponse.GetResponseStream()) |
|||
{ |
|||
using (StreamReader sread = new StreamReader(responseStream)) |
|||
{ |
|||
result = sread.ReadToEnd(); |
|||
} |
|||
} |
|||
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
log.WriteLogFile("PostUrl异常" + url + "---------------" + postData, "recorderror"); |
|||
log.WriteLogFile("PostUrl异常" + ex.ToString(), "recorderror"); |
|||
} |
|||
return result; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 开始录音
|
|||
/// </summary>
|
|||
/// <param name="filename">保存的文件名</param>
|
|||
internal bool StartRecorder(string filename = "r.wav") |
|||
{ |
|||
try |
|||
{ |
|||
totalLength = 0; |
|||
// 设置文件操作类
|
|||
writer = new WaveFileWriter(filename, recordingFormat); |
|||
result.Clear(); |
|||
// 开始录音
|
|||
waveIn.StartRecording(); |
|||
int errcode = (int)Errors.MSP_SUCCESS; |
|||
string session_begin_params = "sub=iat,domain=iat,language=zh_cn,accent=mandarin,sample_rate=16000,result_type=plain,result_encoding=gb2312"; |
|||
IatNativeMethods.session_id = IatNativeMethods.QISRSessionBegin(null, session_begin_params, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
flag = true; |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
StopRecorder(); |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile(e.ToString(), "record"); |
|||
} |
|||
return true; |
|||
} |
|||
|
|||
private void run_iat(byte[] _wavdata) |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
|
|||
wavdata = _wavdata; |
|||
if (wavdata == null || wavdata.Length == 0) |
|||
{ |
|||
try |
|||
{ |
|||
wavdata = System.IO.File.ReadAllBytes("wav/test.wav"); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
//System.Diagnostics.Debug.WriteLine(e.Message);
|
|||
//wavdata = null;
|
|||
} |
|||
} |
|||
//wavdata = System.IO.File.ReadAllBytes("wav/r.wav");
|
|||
|
|||
int res = IatNativeMethods.QISRAudioWrite(IatNativeMethods.session_id, wavdata, (uint)wavdata.Length, aud_stat, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
flag = true; |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
log.WriteLogFile("写入识别的音频失败!" + res); |
|||
|
|||
StopRecorder(); |
|||
return; |
|||
} |
|||
if (RecogStatus.MSP_REC_STATUS_SUCCESS != rec_stat) |
|||
{ |
|||
IntPtr now_result = IatNativeMethods.QISRGetResult(IatNativeMethods.session_id, ref rec_stat, 0, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
flag = true; |
|||
log.WriteLogFile("获取结果失败:" + errcode); |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
|
|||
StopRecorder(); |
|||
return; |
|||
} |
|||
if (now_result != null) |
|||
{ |
|||
int length = now_result.ToString().Length; |
|||
totalLength += length; |
|||
if (totalLength > 4096) |
|||
{ |
|||
flag = true; |
|||
log.WriteLogFile("缓存空间不够" + totalLength); |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
StopRecorder(); |
|||
return; |
|||
} |
|||
result.Append(Marshal.PtrToStringAnsi(now_result)); |
|||
} |
|||
} |
|||
if (EpStatus.MSP_EP_AFTER_SPEECH == ep_stat) |
|||
{ |
|||
//run_iatlast();
|
|||
StopRecorder(); |
|||
|
|||
return; |
|||
} |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
|
|||
log.WriteLogFile(ex.ToString(), "recorderror"); |
|||
} |
|||
//Thread.Sleep(150);//防止频繁占用cpu
|
|||
} |
|||
|
|||
private void run_iatlast() |
|||
{ |
|||
|
|||
var res = IatNativeMethods.QISRAudioWrite(IatNativeMethods.session_id, null, 0, AudioStatus.MSP_AUDIO_SAMPLE_LAST, ref ep_stat, ref rec_stat); |
|||
if (res != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
flag = true; |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
log.WriteLogFile("写入音频失败!" + res); |
|||
StopRecorder(); |
|||
return; |
|||
} |
|||
|
|||
while (RecogStatus.MSP_REC_STATUS_COMPLETE != rec_stat) |
|||
{ |
|||
IntPtr now_result = IatNativeMethods.QISRGetResult(IatNativeMethods.session_id, ref rec_stat, 0, ref errcode); |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
flag = true; |
|||
log.WriteLogFile("获取结果失败:" + errcode); |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
StopRecorder(); |
|||
return; |
|||
} |
|||
if (now_result != null) |
|||
{ |
|||
int length = now_result.ToString().Length; |
|||
totalLength += length; |
|||
if (totalLength > 4096) |
|||
{ |
|||
flag = true; |
|||
log.WriteLogFile("缓存空间不够" + totalLength); |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
|
|||
StopRecorder(); |
|||
} |
|||
|
|||
result.Append(Marshal.PtrToStringAnsi(now_result)); |
|||
} |
|||
Thread.Sleep(150);//防止频繁占用cpu
|
|||
} |
|||
QISRSessionEnd(); |
|||
//int ret = IatNativeMethods.QISRSessionEnd(IatNativeMethods.session_id, "normal end");
|
|||
//if (errcode != (int)Errors.MSP_SUCCESS)
|
|||
//{
|
|||
// flag = true;
|
|||
// log.WriteLogFile("QISRSessionEnd failed, error code is: %d" + ret);
|
|||
// string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}";
|
|||
// WebsocketForVoice.allSockets.ToList().ForEach(s => s.Send(result));
|
|||
//}
|
|||
//if (result.Length > 0)
|
|||
//{
|
|||
// string resultReturn = "{\"code\": \"100\",\"msg\": \""+ result.ToString() + "\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"录音结束\"}}";
|
|||
// //最终方法
|
|||
|
|||
// WebsocketForVoice.allSockets.ToList().ForEach(s => s.Send(resultReturn));
|
|||
// var url = app.kioskUrl + "/Video/VoiceSearch";
|
|||
// StringBuilder sb = new StringBuilder();
|
|||
// sb.Append("Query=" + WebUtility.UrlEncode(result.ToString()) + "&IP=" + app.LocalIP);
|
|||
// resultReturn = PostUrl(url, sb.ToString());
|
|||
// WebsocketForVoice.allSockets.ToList().ForEach(s => s.Send(resultReturn));
|
|||
// flag = true;
|
|||
//}
|
|||
} |
|||
|
|||
private void SendMsg(string result) |
|||
{ |
|||
if (!isClose) |
|||
{ |
|||
WebsocketForVoice.allSockets.ToList().ForEach(s => s.Send(result)); |
|||
} |
|||
|
|||
} |
|||
private void QISRSessionEnd() |
|||
{ |
|||
int ret = IatNativeMethods.QISRSessionEnd(IatNativeMethods.session_id, "normal end"); |
|||
if (!isClose) |
|||
{ |
|||
if (errcode != (int)Errors.MSP_SUCCESS) |
|||
{ |
|||
flag = true; |
|||
|
|||
log.WriteLogFile("QISRSessionEnd failed, error code is: %d" + ret); |
|||
string result = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"未识别到语音输入\"}}"; |
|||
SendMsg(result); |
|||
|
|||
} |
|||
else |
|||
{ |
|||
if (result.Length > 0) |
|||
{ |
|||
string resultReturn = "{\"code\": \"201\",\"msg\": \"" + result.ToString() + "\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"录音结束\"}}"; |
|||
//最终方法
|
|||
WebsocketForVoice.allSockets.ToList().ForEach(s => s.Send(resultReturn)); |
|||
var url = app.kioskUrl + "/Api/Video/VoiceSearch"; |
|||
StringBuilder sb = new StringBuilder(); |
|||
sb.Append("Query=" + WebUtility.UrlEncode(result.ToString()) + "&IP=" + app.LocalIP); |
|||
resultReturn = PostUrl(url, sb.ToString()); |
|||
if (!isClose) |
|||
{ |
|||
SendMsg(resultReturn); |
|||
} |
|||
if (ConfigurationManager.AppSettings["isvoiceup"] == "1") |
|||
{ |
|||
Action action = new Action(() => |
|||
{ |
|||
var Jo = JObject.Parse(resultReturn); |
|||
string code = Jo.Value<string>("code"); |
|||
if (code == "500") |
|||
{ |
|||
var voiceData = Jo.Value<JObject>("data"); |
|||
var voiceCode = voiceData.Value<string>("voiceCode"); |
|||
var mallCode = voiceData.Value<string>("mallCode"); |
|||
if (!string.IsNullOrEmpty(voiceCode)) |
|||
{ |
|||
var voiceFile = Directory.GetCurrentDirectory() + "\\r.wav"; |
|||
var formDatas = new List<FormItemModel>(); |
|||
//添加文件
|
|||
formDatas.Add(new FormItemModel() |
|||
{ |
|||
Key = "wav", |
|||
Value = "", |
|||
FileName = DateTime.Now.Ticks.ToString("x") + ".wav", |
|||
FileContent = File.OpenRead(voiceFile), |
|||
voiceCode = voiceCode, |
|||
mallCode = mallCode |
|||
}); |
|||
//添加文件
|
|||
formDatas.Add(new FormItemModel() |
|||
{ |
|||
Key = "voiceCode", |
|||
Value = voiceCode, |
|||
|
|||
}); |
|||
//添加文件
|
|||
formDatas.Add(new FormItemModel() |
|||
{ |
|||
Key = "mallCode", |
|||
Value = mallCode, |
|||
|
|||
}); |
|||
var result = PostForm(app.kioskUrl + "/SaasApi/Statistics/UpLoadVoiceFiles", formDatas); |
|||
} |
|||
|
|||
} |
|||
|
|||
}); |
|||
action.BeginInvoke(null, null); |
|||
} |
|||
flag = true; |
|||
} |
|||
else |
|||
{ |
|||
flag = true; |
|||
string resultReturn = "{\"code\": \"401\",\"msg\": \"未识别到语音输入\",\"data\": { \"ModelType\" : \"\", \"ActionType\" : \"\", \"query\":\"???\" , \"ttsMsg\":\"录音结束\"}}"; |
|||
SendMsg(resultReturn); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 结束录音
|
|||
/// </summary>
|
|||
/// <returns></returns>
|
|||
internal bool StopRecorder() |
|||
{ |
|||
waveIn.StopRecording(); |
|||
return true; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 录音结束回调函数
|
|||
/// </summary>
|
|||
/// <param name="sender"></param>
|
|||
/// <param name="e"></param>
|
|||
private void OnRecordingStopped(object sender, StoppedEventArgs e) |
|||
{ |
|||
writer.Dispose(); |
|||
run_iatlast(); |
|||
// 通知结束事件
|
|||
StoppedEvent(this, EventArgs.Empty); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 录音回调函数,写入数据
|
|||
/// </summary>
|
|||
/// <param name="sender"></param>
|
|||
/// <param name="e"></param>
|
|||
private void OnDataAviailable(object sender, WaveInEventArgs e) |
|||
{ |
|||
try |
|||
{ |
|||
byte[] buffer = e.Buffer; |
|||
int bytesRecorded = e.BytesRecorded; |
|||
long maxFileLength = this.recordingFormat.AverageBytesPerSecond * 60; |
|||
var toWrite = (int)Math.Min(maxFileLength - writer.Length, bytesRecorded); |
|||
if (toWrite > 0) |
|||
{ |
|||
writer.Write(buffer, 0, bytesRecorded); |
|||
run_iat(buffer); |
|||
aud_stat = AudioStatus.MSP_AUDIO_SAMPLE_CONTINUE; |
|||
} |
|||
DataAvailableEvent(this, EventArgs.Empty); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
|
|||
log.WriteLogFile(ex.ToString(), "recorderror"); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
/// <summary>
|
|||
/// 使用Post方法获取字符串结果
|
|||
/// </summary>
|
|||
/// <param name="url"></param>
|
|||
/// <param name="formItems">Post表单内容</param>
|
|||
/// <param name="cookieContainer"></param>
|
|||
/// <param name="timeOut">默认20秒</param>
|
|||
/// <param name="encoding">响应内容的编码类型(默认utf-8)</param>
|
|||
/// <returns></returns>
|
|||
public static string PostForm(string url, List<FormItemModel> formItems, CookieContainer cookieContainer = null, string refererUrl = null, Encoding encoding = null, int timeOut = 10000) |
|||
{ |
|||
try |
|||
{ |
|||
|
|||
|
|||
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); |
|||
#region 初始化请求对象
|
|||
request.Method = "POST"; |
|||
request.Timeout = timeOut; |
|||
request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; |
|||
request.KeepAlive = true; |
|||
request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"; |
|||
if (!string.IsNullOrEmpty(refererUrl)) |
|||
request.Referer = refererUrl; |
|||
if (cookieContainer != null) |
|||
request.CookieContainer = cookieContainer; |
|||
#endregion
|
|||
|
|||
string boundary = "----" + DateTime.Now.Ticks.ToString("x");//分隔符
|
|||
request.ContentType = string.Format("multipart/form-data; boundary={0}", boundary); |
|||
//请求流
|
|||
var postStream = new MemoryStream(); |
|||
#region 处理Form表单请求内容
|
|||
//是否用Form上传文件
|
|||
var formUploadFile = formItems != null && formItems.Count > 0; |
|||
if (formUploadFile) |
|||
{ |
|||
//文件数据模板
|
|||
string fileFormdataTemplate = |
|||
"\r\n--" + boundary + |
|||
"\r\nContent-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"" + |
|||
"\r\nContent-Type: application/octet-stream" + |
|||
"\r\n\r\n"; |
|||
//文本数据模板
|
|||
string dataFormdataTemplate = |
|||
"\r\n--" + boundary + |
|||
"\r\nContent-Disposition: form-data; name=\"{0}\"" + |
|||
"\r\n\r\n{1}"; |
|||
foreach (var item in formItems) |
|||
{ |
|||
string formdata = null; |
|||
if (item.IsFile) |
|||
{ |
|||
//上传文件
|
|||
formdata = string.Format( |
|||
fileFormdataTemplate, |
|||
item.Key, //表单键
|
|||
item.FileName); |
|||
} |
|||
else |
|||
{ |
|||
//上传文本
|
|||
formdata = string.Format( |
|||
dataFormdataTemplate, |
|||
item.Key, |
|||
item.Value); |
|||
} |
|||
|
|||
//统一处理
|
|||
byte[] formdataBytes = null; |
|||
//第一行不需要换行
|
|||
if (postStream.Length == 0) |
|||
formdataBytes = Encoding.UTF8.GetBytes(formdata.Substring(2, formdata.Length - 2)); |
|||
else |
|||
formdataBytes = Encoding.UTF8.GetBytes(formdata); |
|||
postStream.Write(formdataBytes, 0, formdataBytes.Length); |
|||
|
|||
//写入文件内容
|
|||
if (item.FileContent != null && item.FileContent.Length > 0) |
|||
{ |
|||
using (var stream = item.FileContent) |
|||
{ |
|||
byte[] buffer = new byte[1024]; |
|||
int bytesRead = 0; |
|||
while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0) |
|||
{ |
|||
postStream.Write(buffer, 0, bytesRead); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
//结尾
|
|||
var footer = Encoding.UTF8.GetBytes("\r\n--" + boundary + "--\r\n"); |
|||
postStream.Write(footer, 0, footer.Length); |
|||
|
|||
} |
|||
else |
|||
{ |
|||
request.ContentType = "application/x-www-form-urlencoded"; |
|||
} |
|||
#endregion
|
|||
|
|||
request.ContentLength = postStream.Length; |
|||
|
|||
#region 输入二进制流
|
|||
if (postStream != null) |
|||
{ |
|||
postStream.Position = 0; |
|||
//直接写入流
|
|||
Stream requestStream = request.GetRequestStream(); |
|||
|
|||
byte[] buffer = new byte[1024]; |
|||
int bytesRead = 0; |
|||
while ((bytesRead = postStream.Read(buffer, 0, buffer.Length)) != 0) |
|||
{ |
|||
requestStream.Write(buffer, 0, bytesRead); |
|||
} |
|||
|
|||
////debug
|
|||
//postStream.Seek(0, SeekOrigin.Begin);
|
|||
//StreamReader sr = new StreamReader(postStream);
|
|||
//var postStr = sr.ReadToEnd();
|
|||
postStream.Close();//关闭文件访问
|
|||
} |
|||
#endregion
|
|||
|
|||
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); |
|||
if (cookieContainer != null) |
|||
{ |
|||
response.Cookies = cookieContainer.GetCookies(response.ResponseUri); |
|||
} |
|||
|
|||
using (Stream responseStream = response.GetResponseStream()) |
|||
{ |
|||
using (StreamReader myStreamReader = new StreamReader(responseStream, encoding ?? Encoding.UTF8)) |
|||
{ |
|||
string retString = myStreamReader.ReadToEnd(); |
|||
return retString; |
|||
} |
|||
} |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
|
|||
log.WriteLogFile(e.ToString(), "voiceerror"); |
|||
return ""; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -0,0 +1,37 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Common |
|||
{ |
|||
public class Win32Api |
|||
{ |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public class POINT |
|||
{ |
|||
public int x; |
|||
public int y; |
|||
} |
|||
[StructLayout(LayoutKind.Sequential)] |
|||
public class MouseHookStruct |
|||
{ |
|||
public POINT pt; |
|||
public int hwnd; |
|||
public int wHitTestCode; |
|||
public int dwExtraInfo; |
|||
} |
|||
public delegate int HookProc(int nCode, IntPtr wParam, IntPtr lParam); |
|||
//安装钩子
|
|||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern int SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId); |
|||
//卸载钩子
|
|||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern bool UnhookWindowsHookEx(int idHook); |
|||
//调用下一个钩子
|
|||
[DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)] |
|||
public static extern int CallNextHookEx(int idHook, int nCode, IntPtr wParam, IntPtr lParam); |
|||
} |
|||
} |
|||
File diff suppressed because it is too large
@ -0,0 +1,14 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|||
<PropertyGroup> |
|||
<ProjectView>ShowAllFiles</ProjectView> |
|||
<PublishUrlHistory>publish\</PublishUrlHistory> |
|||
<InstallUrlHistory /> |
|||
<SupportUrlHistory /> |
|||
<UpdateUrlHistory /> |
|||
<BootstrapperUrlHistory /> |
|||
<ErrorReportUrlHistory /> |
|||
<FallbackCulture>zh-CN</FallbackCulture> |
|||
<VerifyUploadedFiles>false</VerifyUploadedFiles> |
|||
</PropertyGroup> |
|||
</Project> |
|||
@ -0,0 +1,166 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel; |
|||
using System.Windows; |
|||
using System.Windows.Input; |
|||
using System.Windows.Markup; |
|||
using System.Windows.Media; |
|||
using System.Windows.Threading; |
|||
using Drawing = System.Drawing; |
|||
using Forms = System.Windows.Forms; |
|||
|
|||
namespace Container.Control |
|||
{ |
|||
/// <summary>
|
|||
/// Represents a thin wrapper for <see cref="Forms.NotifyIcon"/>
|
|||
/// </summary>
|
|||
[ContentProperty("Text")] |
|||
[DefaultEvent("MouseDoubleClick")] |
|||
public class NotificationAreaIcon : FrameworkElement |
|||
{ |
|||
Forms.NotifyIcon notifyIcon; |
|||
|
|||
public static readonly RoutedEvent MouseClickEvent = EventManager.RegisterRoutedEvent( |
|||
"MouseClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(NotificationAreaIcon)); |
|||
|
|||
public static readonly RoutedEvent MouseDoubleClickEvent = EventManager.RegisterRoutedEvent( |
|||
"MouseDoubleClick", RoutingStrategy.Bubble, typeof(MouseButtonEventHandler), typeof(NotificationAreaIcon)); |
|||
|
|||
public static readonly DependencyProperty IconProperty = |
|||
DependencyProperty.Register("Icon", typeof(ImageSource), typeof(NotificationAreaIcon)); |
|||
|
|||
public static readonly DependencyProperty TextProperty = |
|||
DependencyProperty.Register("Text", typeof(string), typeof(NotificationAreaIcon)); |
|||
|
|||
public static readonly DependencyProperty FormsContextMenuProperty = |
|||
DependencyProperty.Register("MenuItems", typeof(List<Forms.MenuItem>), typeof(NotificationAreaIcon), new PropertyMetadata(new List<Forms.MenuItem>())); |
|||
|
|||
protected override void OnInitialized(EventArgs e) |
|||
{ |
|||
base.OnInitialized(e); |
|||
|
|||
// Create and initialize the window forms notify icon based
|
|||
notifyIcon = new Forms.NotifyIcon(); |
|||
notifyIcon.Text = Text; |
|||
if (!DesignerProperties.GetIsInDesignMode(this)) |
|||
{ |
|||
notifyIcon.Icon = FromImageSource(Icon); |
|||
} |
|||
notifyIcon.Visible = FromVisibility(Visibility); |
|||
|
|||
if (this.MenuItems != null && this.MenuItems.Count > 0) |
|||
{ |
|||
notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(this.MenuItems.ToArray()); |
|||
} |
|||
|
|||
notifyIcon.MouseDown += OnMouseDown; |
|||
notifyIcon.MouseUp += OnMouseUp; |
|||
notifyIcon.MouseClick += OnMouseClick; |
|||
notifyIcon.MouseDoubleClick += OnMouseDoubleClick; |
|||
|
|||
Dispatcher.ShutdownStarted += OnDispatcherShutdownStarted; |
|||
} |
|||
|
|||
private void OnDispatcherShutdownStarted(object sender, EventArgs e) |
|||
{ |
|||
notifyIcon.Dispose(); |
|||
} |
|||
|
|||
private void OnMouseDown(object sender, Forms.MouseEventArgs e) |
|||
{ |
|||
OnRaiseEvent(MouseDownEvent, new MouseButtonEventArgs( |
|||
InputManager.Current.PrimaryMouseDevice, 0, ToMouseButton(e.Button))); |
|||
} |
|||
|
|||
private void OnMouseUp(object sender, Forms.MouseEventArgs e) |
|||
{ |
|||
OnRaiseEvent(MouseUpEvent, new MouseButtonEventArgs( |
|||
InputManager.Current.PrimaryMouseDevice, 0, ToMouseButton(e.Button))); |
|||
} |
|||
|
|||
private void OnMouseDoubleClick(object sender, Forms.MouseEventArgs e) |
|||
{ |
|||
OnRaiseEvent(MouseDoubleClickEvent, new MouseButtonEventArgs( |
|||
InputManager.Current.PrimaryMouseDevice, 0, ToMouseButton(e.Button))); |
|||
} |
|||
|
|||
private void OnMouseClick(object sender, Forms.MouseEventArgs e) |
|||
{ |
|||
OnRaiseEvent(MouseClickEvent, new MouseButtonEventArgs( |
|||
InputManager.Current.PrimaryMouseDevice, 0, ToMouseButton(e.Button))); |
|||
} |
|||
|
|||
private void OnRaiseEvent(RoutedEvent handler, MouseButtonEventArgs e) |
|||
{ |
|||
e.RoutedEvent = handler; |
|||
RaiseEvent(e); |
|||
} |
|||
|
|||
public List<Forms.MenuItem> MenuItems |
|||
{ |
|||
get { return (List<Forms.MenuItem>)GetValue(FormsContextMenuProperty); } |
|||
set { SetValue(FormsContextMenuProperty, value); } |
|||
} |
|||
|
|||
public ImageSource Icon |
|||
{ |
|||
get { return (ImageSource)GetValue(IconProperty); } |
|||
set { SetValue(IconProperty, value); } |
|||
} |
|||
|
|||
public string Text |
|||
{ |
|||
get { return (string)GetValue(TextProperty); } |
|||
set { SetValue(TextProperty, value); } |
|||
} |
|||
|
|||
public event MouseButtonEventHandler MouseClick |
|||
{ |
|||
add { AddHandler(MouseClickEvent, value); } |
|||
remove { RemoveHandler(MouseClickEvent, value); } |
|||
} |
|||
|
|||
public event MouseButtonEventHandler MouseDoubleClick |
|||
{ |
|||
add { AddHandler(MouseDoubleClickEvent, value); } |
|||
remove { RemoveHandler(MouseDoubleClickEvent, value); } |
|||
} |
|||
|
|||
#region Conversion members
|
|||
|
|||
private static Drawing.Icon FromImageSource(ImageSource icon) |
|||
{ |
|||
if (icon == null) |
|||
{ |
|||
return null; |
|||
} |
|||
Uri iconUri = new Uri(icon.ToString()); |
|||
return new Drawing.Icon(Application.GetResourceStream(iconUri).Stream); |
|||
} |
|||
|
|||
private static bool FromVisibility(Visibility visibility) |
|||
{ |
|||
return visibility == Visibility.Visible; |
|||
} |
|||
|
|||
private MouseButton ToMouseButton(Forms.MouseButtons button) |
|||
{ |
|||
switch (button) |
|||
{ |
|||
case Forms.MouseButtons.Left: |
|||
return MouseButton.Left; |
|||
case Forms.MouseButtons.Right: |
|||
return MouseButton.Right; |
|||
case Forms.MouseButtons.Middle: |
|||
return MouseButton.Middle; |
|||
case Forms.MouseButtons.XButton1: |
|||
return MouseButton.XButton1; |
|||
case Forms.MouseButtons.XButton2: |
|||
return MouseButton.XButton2; |
|||
} |
|||
throw new InvalidOperationException(); |
|||
} |
|||
|
|||
#endregion Conversion members
|
|||
} |
|||
} |
|||
@ -0,0 +1,190 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
using System.Diagnostics; |
|||
using System.Runtime.InteropServices; |
|||
using System.Windows.Forms; |
|||
|
|||
namespace Container.Control |
|||
{ |
|||
/// <summary>
|
|||
/// 以嵌入到窗体的方式打开外部exe--kongfl888 2013
|
|||
/// </summary>
|
|||
class OpenExeClass |
|||
{ |
|||
static Process process = null; |
|||
static IntPtr appWin; |
|||
private static string exeName = ""; |
|||
|
|||
|
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); |
|||
|
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent); |
|||
|
|||
[DllImport("user32.dll", SetLastError = true)] |
|||
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint); |
|||
|
|||
//[DllImport("user32.dll", EntryPoint = "GetWindowThreadProcessId", SetLastError = true,
|
|||
// CharSet = CharSet.Unicode, ExactSpelling = true,
|
|||
// CallingConvention = CallingConvention.StdCall)]
|
|||
//private static extern long GetWindowThreadProcessId(long hWnd, long lpdwProcessId);
|
|||
|
|||
//[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true)]
|
|||
//private static extern long GetWindowLong(IntPtr hwnd, int nIndex);
|
|||
|
|||
//[DllImport("user32.dll", EntryPoint = "SetWindowLongA", SetLastError = true)]
|
|||
//private static extern long SetWindowLong(IntPtr hwnd, int nIndex, long dwNewLong);
|
|||
|
|||
|
|||
//[DllImport("user32.dll", SetLastError = true)]
|
|||
//private static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long wFlags);
|
|||
|
|||
|
|||
//[DllImport("user32.dll", EntryPoint = "PostMessageA", SetLastError = true)]
|
|||
//private static extern bool PostMessage(IntPtr hwnd, uint Msg, long wParam, long lParam);
|
|||
|
|||
//[DllImport("user32.dll", EntryPoint = "ShowWindow", SetLastError = true)]
|
|||
//private static extern bool ShowWindow(IntPtr hWnd, uint nCmdShow);
|
|||
|
|||
//[DllImport("user32.dll")]
|
|||
//[return: MarshalAs(UnmanagedType.Bool)]
|
|||
//static extern bool GetWindowRect(IntPtr hWnd, ref RECT lpRect);
|
|||
|
|||
//[StructLayout(LayoutKind.Sequential)]
|
|||
//public struct RECT
|
|||
//{
|
|||
// public int Left; //最左坐标
|
|||
// public int Top; //最上坐标
|
|||
// public int Right; //最右坐标
|
|||
// public int Bottom; //最下坐标
|
|||
//}
|
|||
|
|||
//private const int SWP_NOOWNERZORDER = 0x200;
|
|||
//private const int SWP_NOREDRAW = 0x8;
|
|||
//private const int SWP_NOZORDER = 0x4;
|
|||
//private const int SWP_SHOWWINDOW = 0x0040;
|
|||
//private const int WS_EX_MDICHILD = 0x40;
|
|||
//private const int SWP_FRAMECHANGED = 0x20;
|
|||
//private const int SWP_NOACTIVATE = 0x10;
|
|||
//private const int SWP_ASYNCWINDOWPOS = 0x4000;
|
|||
//private const int SWP_NOMOVE = 0x2;
|
|||
//private const int SWP_NOSIZE = 0x1;
|
|||
//private const int GWL_STYLE = (-16);
|
|||
//private const int WS_VISIBLE = 0x10000000;
|
|||
//private const int WM_CLOSE = 0x10;
|
|||
//private const int WS_CHILD = 0x40000000;
|
|||
//private const int SW_HIDE = 0;
|
|||
|
|||
|
|||
public string ExeName |
|||
{ |
|||
get |
|||
{ |
|||
return exeName; |
|||
} |
|||
set |
|||
{ |
|||
exeName = value; |
|||
} |
|||
} |
|||
|
|||
public static void OpenExe(GroupBox fm, string filefullname) |
|||
{ |
|||
exeName = filefullname; |
|||
if (exeName == null || exeName == string.Empty) return; |
|||
|
|||
try |
|||
{ |
|||
// Start the process
|
|||
process = System.Diagnostics.Process.Start(exeName); |
|||
|
|||
// Wait for process to be created and enter idle condition
|
|||
process.WaitForInputIdle(); |
|||
|
|||
// Get the main handle
|
|||
//appWin = process.MainWindowHandle;
|
|||
|
|||
appWin = FindWindow(null, "War3 fixer"); |
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
MessageBox.Show(fm, ex.Message, "Error"); |
|||
} |
|||
|
|||
// Put it into this form
|
|||
SetParent(appWin, fm.Handle); |
|||
|
|||
// Remove border and whatnot
|
|||
// SetWindowLong(appWin, GWL_STYLE, WS_VISIBLE);
|
|||
|
|||
// Move the window to overlay it on this window
|
|||
MoveWindow(appWin, 0, 0, fm.Width+2, fm.Height, true); |
|||
//RECT rc = new RECT();
|
|||
//GetWindowRect(appWin, ref rc);
|
|||
//int width = rc.Right - rc.Left; //窗口的宽度
|
|||
//int height = rc.Bottom - rc.Top; //窗口的高度
|
|||
//int x = rc.Left;
|
|||
//int y = rc.Top;
|
|||
//MoveWindow(appWin, 0, 0, width, height, true);
|
|||
|
|||
fm.Text = ""; |
|||
|
|||
} |
|||
|
|||
|
|||
public static bool CloseExe() |
|||
{ |
|||
bool sc = false; |
|||
try |
|||
{ |
|||
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses(); |
|||
foreach (System.Diagnostics.Process process2 in processList) |
|||
{ |
|||
if (process2.Id == process.Id) |
|||
{ |
|||
process.Kill(); //结束进程
|
|||
sc=process.WaitForExit(100000); |
|||
|
|||
} |
|||
} |
|||
} |
|||
catch { sc = true; } |
|||
return sc; |
|||
} |
|||
|
|||
public static Process IsProcessRun() |
|||
{ |
|||
Process processRun = new Process(); |
|||
try |
|||
{ |
|||
System.Diagnostics.Process[] processList = System.Diagnostics.Process.GetProcesses(); |
|||
foreach (System.Diagnostics.Process process2 in processList) |
|||
{ |
|||
if (process2.Id == process.Id) |
|||
{ |
|||
processRun = process; |
|||
|
|||
} |
|||
} |
|||
} |
|||
catch { } |
|||
|
|||
return processRun; |
|||
} |
|||
|
|||
//主窗体退出时写FormClosed事件函数,调用CloseExe()函数 在控件改变大小的时候,重新MoveWindow()即可,如:
|
|||
//private void splitContainer1_Panel2_Resize(object sender, EventArgs e)
|
|||
//{
|
|||
// if (this.appWin != IntPtr.Zero)
|
|||
// {
|
|||
// MoveWindow(appWin, 0, 0, this.splitContainer1.Panel2.Width, this.splitContainer1.Panel2.Height, true);
|
|||
// }
|
|||
// base.OnResize(e);
|
|||
//}
|
|||
} |
|||
} |
|||
@ -0,0 +1,158 @@ |
|||
using Microsoft.Win32; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Diagnostics; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using ICSharpCode.SharpZipLib.Checksums; |
|||
using ICSharpCode.SharpZipLib.Zip; |
|||
using ICSharpCode.SharpZipLib.GZip; |
|||
using System.Windows; |
|||
using System.IO.Compression; |
|||
using Container.Common; |
|||
|
|||
namespace Container.Control |
|||
{ |
|||
class ZipFloClass |
|||
{ |
|||
|
|||
/// 利用 WinRAR 进行压缩
|
|||
/// </summary>
|
|||
/// <param name="path">将要被压缩的文件夹(绝对路径)</param>
|
|||
/// <param name="rarPath">压缩后的 .rar 的存放目录(绝对路径)</param>
|
|||
/// <param name="rarName">压缩文件的名称(包括后缀)</param>
|
|||
/// <returns>true 或 false。压缩成功返回 true,反之,false。</returns>
|
|||
public bool RAR(string path, string rarPath, string rarName) |
|||
{ |
|||
bool flag = false; |
|||
string rarexe; //WinRAR.exe 的完整路径
|
|||
RegistryKey regkey; //注册表键
|
|||
Object regvalue; //键值
|
|||
string cmd; //WinRAR 命令参数
|
|||
ProcessStartInfo startinfo; |
|||
Process process; |
|||
|
|||
try |
|||
{ |
|||
regkey = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\shell\open\command"); |
|||
regvalue = regkey.GetValue(""); // 键值为 "d:\Program Files\WinRAR\WinRAR.exe" "%1"
|
|||
rarexe = regvalue.ToString(); |
|||
regkey.Close(); |
|||
rarexe = rarexe.Substring(1, rarexe.Length - 7); // d:\Program Files\WinRAR\WinRAR.exe
|
|||
Directory.CreateDirectory(path); |
|||
//压缩命令,相当于在要压缩的文件夹(path)上点右键 ->WinRAR->添加到压缩文件->输入压缩文件名(rarName)
|
|||
cmd = string.Format("a {0} {1} -r", rarName, path); |
|||
startinfo = new ProcessStartInfo(); |
|||
startinfo.FileName = rarexe; |
|||
startinfo.Arguments = cmd; //设置命令参数
|
|||
startinfo.WindowStyle = ProcessWindowStyle.Hidden; //隐藏 WinRAR 窗口
|
|||
startinfo.WorkingDirectory = rarPath; |
|||
process = new Process(); |
|||
process.StartInfo = startinfo; |
|||
process.Start(); |
|||
process.WaitForExit(); //无限期等待进程 winrar.exe 退出
|
|||
if (process.HasExited) |
|||
{ |
|||
flag = true; |
|||
} |
|||
process.Close(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
throw e; |
|||
} |
|||
return flag; |
|||
} |
|||
/// <summary>
|
|||
/// 利用 WinRAR 进行解压缩
|
|||
/// </summary>
|
|||
/// <param name="path">文件解压路径(绝对)</param>
|
|||
/// <param name="rarPath">将要解压缩的 .rar 文件的存放目录(绝对路径)</param>
|
|||
/// <param name="rarName">将要解压缩的 .rar 文件名(包括后缀)</param>
|
|||
/// <returns>true 或 false。解压缩成功返回 true,反之,false。</returns>
|
|||
public bool UnRAR(string path, string rarPath, string rarName) |
|||
{ |
|||
bool flag = false; |
|||
string rarexe; |
|||
RegistryKey regkey; |
|||
Object regvalue; |
|||
string cmd; |
|||
ProcessStartInfo startinfo; |
|||
Process process; |
|||
try |
|||
{ |
|||
regkey = Registry.ClassesRoot.OpenSubKey(@"Applications\WinRAR.exe\shell\open\command"); |
|||
regvalue = regkey.GetValue(""); |
|||
rarexe = regvalue.ToString(); |
|||
regkey.Close(); |
|||
rarexe = rarexe.Substring(1, rarexe.Length - 7); |
|||
Directory.CreateDirectory(path); |
|||
//解压缩命令,相当于在要压缩文件(rarName)上点右键 ->WinRAR->解压到当前文件夹
|
|||
cmd = string.Format("x {0} {1} -y", rarName, path); |
|||
startinfo = new ProcessStartInfo(); |
|||
startinfo.FileName = rarexe; |
|||
startinfo.Arguments = cmd; |
|||
startinfo.WindowStyle = ProcessWindowStyle.Hidden; |
|||
startinfo.WorkingDirectory = rarPath; |
|||
process = new Process(); |
|||
process.StartInfo = startinfo; |
|||
process.Start(); |
|||
process.WaitForExit(); |
|||
if (process.HasExited) |
|||
{ |
|||
flag = true; |
|||
} |
|||
process.Close(); |
|||
} |
|||
catch (Exception e) |
|||
{ |
|||
Class_Log log = new Class_Log(); |
|||
log.WriteLogFile(e.ToString(), "UnZipError"); |
|||
} |
|||
return flag; |
|||
} |
|||
public static void UnZip(string SrcFile, string DstFile) |
|||
{ |
|||
try |
|||
{ |
|||
System.IO.Compression.ZipFile.ExtractToDirectory(SrcFile, DstFile); |
|||
// 列出压缩压缩文件
|
|||
//using (FileStream zipFileToOpen = new FileStream(SrcFile, FileMode.Open))
|
|||
//using (ZipArchive archive = new ZipArchive(zipFileToOpen, ZipArchiveMode.Read))
|
|||
//{
|
|||
|
|||
// foreach (var zipArchiveEntry in archive.Entries)
|
|||
// MessageBox.Show(
|
|||
// "FullName of the Zip Archive Entry: {0}", zipArchiveEntry.
|
|||
// );
|
|||
//}
|
|||
} |
|||
catch (Exception ex) |
|||
{ |
|||
Class_Log log = new Class_Log(); |
|||
log.WriteLogFile(ex.ToString(), "UnZipError"); |
|||
} |
|||
// 读取其中一个文件的内容
|
|||
//using (FileStream zipFileToOpen = new FileStream(zipFilePath, FileMode.Open))
|
|||
//using (ZipArchive archive = new ZipArchive(zipFileToOpen, ZipArchiveMode.Read))
|
|||
//{
|
|||
// // 解压某个文件
|
|||
// ZipArchiveEntry entry = archive.GetEntry("ZipArchiveSample.exe");
|
|||
// Console.WriteLine(entry.Name);
|
|||
// using (System.IO.Stream stream = entry.Open())
|
|||
// {
|
|||
// System.IO.Stream output = new FileStream("http://www.cnblogs.com/ZipArchiveSample.exe", FileMode.Create);
|
|||
// int b = -1;
|
|||
// while ((b = stream.ReadByte()) != -1)
|
|||
// {
|
|||
// output.WriteByte((byte)b);
|
|||
// }
|
|||
// output.Close();
|
|||
// }
|
|||
|
|||
//}
|
|||
} |
|||
} |
|||
} |
|||
|
After Width: | Height: | Size: 10 KiB |
@ -0,0 +1,69 @@ |
|||
<Window x:Class="Container.MainWindow" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:My="clr-namespace:Container.Control" |
|||
xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" |
|||
Title="Container" Height="500" Width="400" ResizeMode="NoResize" WindowStyle="None" Loaded ="MainWindow_Loaded" Closed ="MainWindow_Closed" WindowState="Minimized"> |
|||
<Canvas x:Name="mainp"> |
|||
<Canvas.Background> |
|||
<ImageBrush ImageSource="image/background.jpg"/> |
|||
</Canvas.Background> |
|||
<Canvas x:Name="sucessopen" Visibility="Visible"> |
|||
|
|||
<!--<Image Width="15" Source="qm.ico" Height="15" Canvas.Left="45" Canvas.Top="40"/>--> |
|||
<!--<StackPanel Canvas.Left="8" Canvas.Top="40" Width="237" Visibility="Hidden" > |
|||
<TextBlock Foreground="White" HorizontalAlignment="Center" TextAlignment="Center" Text="千目产品终端控制程序"/> |
|||
</StackPanel>--> |
|||
<StackPanel Canvas.Left="0" Canvas.Top="251" Width="400"> |
|||
<TextBlock x:Name="Terminalid" Foreground="#FF555555" Visibility="Hidden" FontSize="14" FontFamily="HYQiHei" Text="" TextAlignment="Center"/> |
|||
</StackPanel> |
|||
<StackPanel Canvas.Left="0" Canvas.Top="221" Width="400"> |
|||
<TextBlock x:Name="Terminalmark" Foreground="#FF555555" FontSize="14" FontFamily="HYQiHei" Text="" TextAlignment="Center"/> |
|||
</StackPanel> |
|||
<Button x:Name="btn_OK" Canvas.Left="154" Canvas.Top="351" Width="91" Height="27" Click="Btn_OK" Visibility="Visible"> |
|||
<Button.Style> |
|||
<Style TargetType="{x:Type Button}"> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate TargetType="{x:Type Button}"> |
|||
<Canvas Name="cvs" Background="Transparent" Canvas.Top="351" Width="91" Height="27"> |
|||
<Image Name="Img" Source="image/Btn_OK.jpg" Height="27" Width="91"/> |
|||
<TextBlock Name="tbSale" FontWeight="Bold" Foreground="Transparent" Width="91" Canvas.Top="7" FontFamily="HYQiHei" Height="27" FontSize="15" TextAlignment="Center" Text="完成"></TextBlock> |
|||
</Canvas> |
|||
<ControlTemplate.Triggers> |
|||
<Trigger Property="IsPressed" Value="True"> |
|||
<Setter Property="Background" Value="#b6b6b6" TargetName="cvs" /> |
|||
<Setter Property="Foreground" Value="White" TargetName="tbSale" /> |
|||
<Setter Property="Visibility" Value="Hidden" TargetName="Img" /> |
|||
|
|||
</Trigger> |
|||
</ControlTemplate.Triggers> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
</Button.Style> |
|||
</Button> |
|||
<StackPanel Canvas.Left="0" Canvas.Top="181" Width="400"> |
|||
<TextBlock x:Name="txtVersion" Foreground="#FF555555" FontFamily="HYQiHei" Text="版本号:1.2.2" FontSize="14" TextAlignment="Center" Margin="0,0,0,0"/> |
|||
</StackPanel> |
|||
</Canvas> |
|||
<!--<Canvas x:Name="failopen" Visibility="Hidden"> |
|||
<Label Content="应用程序路径" Canvas.Left="3" Canvas.Top="15"/> |
|||
<TextBox x:Name="Textpath" Height="23" Canvas.Left="10" TextWrapping="Wrap" Text="" Canvas.Top="42" GotFocus="Text_Focus" Width="223"/> |
|||
<Button Content="打开" Canvas.Left="158" Canvas.Top="70" Width="75" Click="Btn_Click"/> |
|||
</Canvas>--> |
|||
<My:NotificationAreaIcon |
|||
Text="千目产品" |
|||
Icon="/Icon/qm.ico" |
|||
MouseDoubleClick="OnNotificationAreaIconDoubleClick" Grid.Row="2"> |
|||
<My:NotificationAreaIcon.MenuItems> |
|||
<!--Click="OnMenuItemOpenClick"--> |
|||
<!--<forms:MenuItem x:Name="Openexe" Visible="False" Text="打开应用" Click="OnReLoginClick" DefaultItem="True" />--> |
|||
<forms:MenuItem Text="退出" Click="OnMenuItemExitClick" /> |
|||
<!--<forms:MenuItem x:Name="Clear" Text="清空节目信息" Click="OnMenuItemClearClick" Visible="False" DefaultItem="True" />--> |
|||
</My:NotificationAreaIcon.MenuItems> |
|||
</My:NotificationAreaIcon> |
|||
|
|||
</Canvas> |
|||
</Window> |
|||
File diff suppressed because it is too large
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Model |
|||
{ |
|||
public class BuildingModel |
|||
{ |
|||
public int ID { set; get; } //楼栋ID
|
|||
public string BNAME { set; get; } //名称
|
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.IO; |
|||
using System.Linq; |
|||
using System.Runtime.Serialization.Formatters.Binary; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Model |
|||
{ |
|||
public class ExeModel |
|||
{ |
|||
//应用名称
|
|||
public string exename { get; set; } |
|||
//启动项名称
|
|||
public string exestartname { get; set; } |
|||
//应用文件夹路径名称
|
|||
public string exepath { get; set; } |
|||
//图标路径
|
|||
public string icopath { get; set; } |
|||
//应用ID
|
|||
public string AppID { get; set; } |
|||
|
|||
public string Version { get; set; } |
|||
|
|||
public bool Default { get; set; } |
|||
} |
|||
|
|||
|
|||
} |
|||
@ -0,0 +1,14 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Model |
|||
{ |
|||
class FloorModel |
|||
{ |
|||
public int ID { set; get; } //楼层ID
|
|||
public string FNAME { set; get; } //名称
|
|||
} |
|||
} |
|||
@ -0,0 +1,104 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Model |
|||
{ |
|||
public class InsertADModel |
|||
{ |
|||
|
|||
public string FilePath { set; get; } //文件地址
|
|||
public int Duration { set; get; } //时长
|
|||
} |
|||
|
|||
public class Live |
|||
{ |
|||
public string LiveUrl { get; set; } |
|||
|
|||
public string HFilePath { get; set; } |
|||
|
|||
public List<string> VFilePath { get; set; } |
|||
|
|||
public string MallCode { get; set; } |
|||
|
|||
public string MallName { get; set; } |
|||
|
|||
public string OldLiveCode { get; set; } |
|||
public string LiveCode { get; set; } |
|||
|
|||
public string SenderID { get; set; } |
|||
public int Likes { get; set; } |
|||
|
|||
public int WatchNum { get; set; } |
|||
|
|||
public CouponInfo CouponInfo { get; set; } |
|||
|
|||
public string FloorName { get; set; } |
|||
|
|||
public string HouseNum { get; set; } |
|||
|
|||
public string LogoPath { get; set; } |
|||
|
|||
public string QRCode { get; set; } |
|||
|
|||
public string ShopName { get; set; } |
|||
} |
|||
|
|||
|
|||
public class CouponInfo { |
|||
|
|||
public int ID { get; set; } |
|||
public string Code { get; set; } |
|||
public string ShopCode { get; set; } |
|||
public string Title { get; set; } |
|||
public string Intro { get; set; } |
|||
public int PublishState { get; set; } |
|||
public int TotalNum { get; set; } |
|||
public int Received { get; set; } |
|||
|
|||
public string QrCode { get; set; } |
|||
} |
|||
|
|||
public class CurrentLive |
|||
{ |
|||
public string floorName { get; set; } |
|||
|
|||
public string hFilePath { get; set; } |
|||
|
|||
public string houseNum { get; set; } |
|||
|
|||
public int likes { get; set; } |
|||
|
|||
public string liveurl { get; set; } |
|||
public string logoPath { get; set; } |
|||
|
|||
public string mallName { get; set; } |
|||
public string qrCode { get; set; } |
|||
public string shopName { get; set; } |
|||
public List<string> vFilePath { get; set; } |
|||
public int watchNum { get; set; } |
|||
|
|||
public CouponInfo CouponInfo { get; set; } |
|||
} |
|||
|
|||
public class PlayProg { |
|||
|
|||
public string OrderNo { get; set; } |
|||
|
|||
public string Code { get; set; } |
|||
|
|||
public string FilePath { get; set; } |
|||
|
|||
public int OrderType { get; set; } |
|||
} |
|||
|
|||
public class ShutDownProg |
|||
{ |
|||
|
|||
public string OrderNo { get; set; } |
|||
|
|||
public string Code { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,105 @@ |
|||
using Newtonsoft.Json.Linq; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Model |
|||
{ |
|||
public class ScheduleModel { |
|||
public string date { get; set; } |
|||
public List<ProgModel> schedule { get; set; } |
|||
} |
|||
|
|||
public class ProgModel |
|||
{ |
|||
public string beginTime { get; set; } |
|||
|
|||
public string endTime { get; set; } |
|||
public List<Programme> programs { get; set; } |
|||
} |
|||
|
|||
public class Programme { |
|||
public string code { get; set; } |
|||
public string name { get; set; } |
|||
public string resolution { get; set; } |
|||
public string duration { get; set; } |
|||
public string backgroundColor { get; set; } |
|||
public string backgroundMaterial { get; set; } |
|||
public backgroundMaterialInfo backgroundMaterialInfo { get; set; } |
|||
public List<Component> components { get; set; } |
|||
|
|||
} |
|||
|
|||
public class backgroundMaterialInfo { |
|||
public string filePath { get; set; } |
|||
public string fileHash { get; set; } |
|||
} |
|||
|
|||
public class Component |
|||
{ |
|||
public string code { get; set; } |
|||
public string programmeCode { get; set; } |
|||
|
|||
public string addTime { get; set; } |
|||
|
|||
public int height { get; set; } |
|||
|
|||
public int width { get; set; } |
|||
|
|||
public int offsetX { get; set; } |
|||
|
|||
public int offsetY { get; set; } |
|||
|
|||
public int zIndex { get; set; } |
|||
|
|||
public string typeCode { get; set; } |
|||
|
|||
public JObject config { get; set; } |
|||
|
|||
public List<Material> materials { get; set; } |
|||
} |
|||
|
|||
public class Material{ |
|||
public int order { get; set; } |
|||
public string materialCode { get; set; } |
|||
public string fileUrl { get; set; } |
|||
public string fileHash { get; set; } |
|||
public string name { get; set; } |
|||
|
|||
public int duration { get; set; } |
|||
|
|||
public MediaInfo mediaInfo { get; set; } |
|||
} |
|||
|
|||
public class PlayMaterial { |
|||
public JObject config { get; set; } |
|||
public int order { get; set; } |
|||
public string materialCode { get; set; } |
|||
public string fileUrl { get; set; } |
|||
public string fileHash { get; set; } |
|||
public string name { get; set; } |
|||
|
|||
public int duration { get; set; } |
|||
public string typeCode { get; set; } |
|||
|
|||
public MediaInfo mediaInfo { get; set; } |
|||
} |
|||
|
|||
public class MediaInfo { |
|||
public string name { get; set; } |
|||
public string password { get; set; } |
|||
public int port { get; set; } |
|||
public string protocol { get; set; } |
|||
public string url { get; set; } |
|||
|
|||
public string userName { get; set; } |
|||
|
|||
public string ipAddress { get; set; } |
|||
|
|||
public string channel { get; set; } |
|||
|
|||
public string bitRateType { get; set; } |
|||
} |
|||
} |
|||
@ -0,0 +1,126 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
using System.Xml.Serialization; |
|||
|
|||
namespace Container.Model |
|||
{ |
|||
[XmlRoot("root")] |
|||
public class ScreenSavers |
|||
{ |
|||
[XmlElement("code")] |
|||
public string Code; |
|||
|
|||
[XmlArray("items"), XmlArrayItem("item")] |
|||
public List<ResInfo> ResList = new List<ResInfo>(); |
|||
|
|||
public ScreenSavers Clone() |
|||
{ |
|||
ScreenSavers model = new ScreenSavers(); |
|||
model.Code = this.Code; |
|||
foreach (var item in this.ResList) |
|||
{ |
|||
ResInfo info = new ResInfo(); |
|||
info.id = item.id; |
|||
info.img = item.img; |
|||
info.time = item.time; |
|||
info.effect = item.effect; |
|||
info.text = item.text; |
|||
info.color = item.color; |
|||
info.code = item.code; |
|||
info.screenmatch = item.screenmatch; |
|||
//info.angle = item.angle;
|
|||
info.expirydate = item.expirydate; |
|||
info.launchtime = item.launchtime; |
|||
info.floorName = item.floorName; |
|||
info.logoPath = item.logoPath; |
|||
info.shopName = item.shopName; |
|||
info.protype = item.protype; |
|||
info.xaxis = item.xaxis; |
|||
info.yaxis = item.yaxis; |
|||
info.houseNum = item.houseNum; |
|||
info.devNum = item.devNum; |
|||
info.floorOrder = item.floorOrder; |
|||
info.shopFormatIcon = item.shopFormatIcon; |
|||
info.shopFormatName = item.shopFormatName; |
|||
info.applets = item.applets; |
|||
model.ResList.Add(info); |
|||
} |
|||
|
|||
return model; |
|||
} |
|||
} |
|||
|
|||
public class ResInfo |
|||
{ |
|||
[XmlAttribute("id")] |
|||
public string id; |
|||
|
|||
[XmlAttribute("img")] |
|||
public string img; |
|||
|
|||
[XmlAttribute("time")] |
|||
public string time; |
|||
|
|||
[XmlAttribute("effect")] |
|||
public string effect; |
|||
|
|||
[XmlAttribute("text")] |
|||
public string text; |
|||
|
|||
[XmlAttribute("color")] |
|||
public string color; |
|||
|
|||
[XmlAttribute("code")] |
|||
public string code; |
|||
|
|||
[XmlAttribute("screenmatch")] |
|||
public string screenmatch; |
|||
|
|||
[XmlAttribute("launchtime")] |
|||
public string launchtime; |
|||
|
|||
[XmlAttribute("expirydate")] |
|||
public string expirydate; |
|||
|
|||
//[XmlAttribute("angle")]
|
|||
//public string angle;
|
|||
|
|||
[XmlAttribute("floorName")] |
|||
public string floorName; |
|||
|
|||
[XmlAttribute("shopName")] |
|||
public string shopName; |
|||
|
|||
[XmlAttribute("logoPath")] |
|||
public string logoPath; |
|||
|
|||
[XmlAttribute("protype")] |
|||
public string protype; |
|||
|
|||
[XmlAttribute("houseNum")] |
|||
public string houseNum; |
|||
|
|||
[XmlAttribute("xaxis")] |
|||
public string xaxis; |
|||
|
|||
[XmlAttribute("yaxis")] |
|||
public string yaxis; |
|||
|
|||
[XmlAttribute("devNum")] |
|||
public string devNum; |
|||
|
|||
[XmlAttribute("floorOrder")] |
|||
public string floorOrder; |
|||
|
|||
[XmlAttribute("shopFormatIcon")] |
|||
public string shopFormatIcon; |
|||
[XmlAttribute("shopFormatName")] |
|||
public string shopFormatName; |
|||
|
|||
[XmlAttribute("applets")] |
|||
public string applets; |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.Model |
|||
{ |
|||
public class SubTitle |
|||
{ |
|||
|
|||
/// <summary>
|
|||
/// 字幕内容
|
|||
/// </summary>
|
|||
public string text { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 开始时间
|
|||
/// </summary>
|
|||
public string beginTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 结束时间
|
|||
/// </summary>
|
|||
public string endTime { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 位置
|
|||
/// </summary>
|
|||
public string location { get; set; } |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 编码
|
|||
/// </summary>
|
|||
public string code { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字体大小
|
|||
/// </summary>
|
|||
public int fontSize { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 滚动方向 left:从左到右 right:从右到左
|
|||
/// </summary>
|
|||
public string direction { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 字体颜色
|
|||
/// </summary>
|
|||
public string fontColor { get; set; } |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
using System.Reflection; |
|||
using System.Resources; |
|||
using System.Runtime.CompilerServices; |
|||
using System.Runtime.InteropServices; |
|||
using System.Windows; |
|||
|
|||
// 有关程序集的常规信息通过以下
|
|||
// 特性集控制。更改这些特性值可修改
|
|||
// 与程序集关联的信息。
|
|||
[assembly: AssemblyTitle("Container")] |
|||
[assembly: AssemblyDescription("")] |
|||
[assembly: AssemblyConfiguration("")] |
|||
[assembly: AssemblyCompany("南京千目信息科技有限公司")] |
|||
[assembly: AssemblyProduct("产品容器")] |
|||
[assembly: AssemblyCopyright("Wxd@1000mu.2017.7.20")] |
|||
[assembly: AssemblyTrademark("1000mu")] |
|||
[assembly: AssemblyCulture("")] |
|||
|
|||
// 将 ComVisible 设置为 false 使此程序集中的类型
|
|||
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
|
|||
// 则将该类型上的 ComVisible 特性设置为 true。
|
|||
[assembly: ComVisible(false)] |
|||
|
|||
//若要开始生成可本地化的应用程序,请在
|
|||
//<PropertyGroup> 中的 .csproj 文件中
|
|||
//设置 <UICulture>CultureYouAreCodingWith</UICulture>。 例如,如果您在源文件中
|
|||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
|
|||
//对以下 NeutralResourceLanguage 特性的注释。 更新
|
|||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
|||
|
|||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
|||
|
|||
|
|||
[assembly: ThemeInfo( |
|||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
|||
//(在页面或应用程序资源词典中
|
|||
// 未找到某个资源的情况下使用)
|
|||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
|||
//(在页面、应用程序或任何主题特定资源词典中
|
|||
// 未找到某个资源的情况下使用)
|
|||
)] |
|||
|
|||
|
|||
// 程序集的版本信息由下面四个值组成:
|
|||
//
|
|||
// 主版本
|
|||
// 次版本
|
|||
// 生成号
|
|||
// 修订号
|
|||
//
|
|||
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
|
|||
// 方法是按如下所示使用“*”:
|
|||
// [assembly: AssemblyVersion("1.0.*")]
|
|||
[assembly: AssemblyVersion("1.0.0.0")] |
|||
[assembly: AssemblyFileVersion("1.0.0.0")] |
|||
@ -0,0 +1,63 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// 此代码由工具生成。
|
|||
// 运行时版本:4.0.30319.42000
|
|||
//
|
|||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
|||
// 重新生成代码,这些更改将会丢失。
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace Container.Properties { |
|||
using System; |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
|||
/// </summary>
|
|||
// 此类是由 StronglyTypedResourceBuilder
|
|||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
|||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
|||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] |
|||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] |
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
internal class Resources { |
|||
|
|||
private static global::System.Resources.ResourceManager resourceMan; |
|||
|
|||
private static global::System.Globalization.CultureInfo resourceCulture; |
|||
|
|||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] |
|||
internal Resources() { |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Resources.ResourceManager ResourceManager { |
|||
get { |
|||
if (object.ReferenceEquals(resourceMan, null)) { |
|||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Container.Properties.Resources", typeof(Resources).Assembly); |
|||
resourceMan = temp; |
|||
} |
|||
return resourceMan; |
|||
} |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 重写当前线程的 CurrentUICulture 属性,对
|
|||
/// 使用此强类型资源类的所有资源查找执行重写。
|
|||
/// </summary>
|
|||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] |
|||
internal static global::System.Globalization.CultureInfo Culture { |
|||
get { |
|||
return resourceCulture; |
|||
} |
|||
set { |
|||
resourceCulture = value; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,117 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<root> |
|||
<!-- |
|||
Microsoft ResX Schema |
|||
|
|||
Version 2.0 |
|||
|
|||
The primary goals of this format is to allow a simple XML format |
|||
that is mostly human readable. The generation and parsing of the |
|||
various data types are done through the TypeConverter classes |
|||
associated with the data types. |
|||
|
|||
Example: |
|||
|
|||
... ado.net/XML headers & schema ... |
|||
<resheader name="resmimetype">text/microsoft-resx</resheader> |
|||
<resheader name="version">2.0</resheader> |
|||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> |
|||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> |
|||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> |
|||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> |
|||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> |
|||
<value>[base64 mime encoded serialized .NET Framework object]</value> |
|||
</data> |
|||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> |
|||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> |
|||
<comment>This is a comment</comment> |
|||
</data> |
|||
|
|||
There are any number of "resheader" rows that contain simple |
|||
name/value pairs. |
|||
|
|||
Each data row contains a name, and value. The row also contains a |
|||
type or mimetype. Type corresponds to a .NET class that support |
|||
text/value conversion through the TypeConverter architecture. |
|||
Classes that don't support this are serialized and stored with the |
|||
mimetype set. |
|||
|
|||
The mimetype is used for serialized objects, and tells the |
|||
ResXResourceReader how to depersist the object. This is currently not |
|||
extensible. For a given mimetype the value must be set accordingly: |
|||
|
|||
Note - application/x-microsoft.net.object.binary.base64 is the format |
|||
that the ResXResourceWriter will generate, however the reader can |
|||
read any of the formats listed below. |
|||
|
|||
mimetype: application/x-microsoft.net.object.binary.base64 |
|||
value : The object must be serialized with |
|||
: System.Serialization.Formatters.Binary.BinaryFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.soap.base64 |
|||
value : The object must be serialized with |
|||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter |
|||
: and then encoded with base64 encoding. |
|||
|
|||
mimetype: application/x-microsoft.net.object.bytearray.base64 |
|||
value : The object must be serialized into a byte array |
|||
: using a System.ComponentModel.TypeConverter |
|||
: and then encoded with base64 encoding. |
|||
--> |
|||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> |
|||
<xsd:element name="root" msdata:IsDataSet="true"> |
|||
<xsd:complexType> |
|||
<xsd:choice maxOccurs="unbounded"> |
|||
<xsd:element name="metadata"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
<xsd:attribute name="type" type="xsd:string" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="assembly"> |
|||
<xsd:complexType> |
|||
<xsd:attribute name="alias" type="xsd:string" /> |
|||
<xsd:attribute name="name" type="xsd:string" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="data"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" /> |
|||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> |
|||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
<xsd:element name="resheader"> |
|||
<xsd:complexType> |
|||
<xsd:sequence> |
|||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> |
|||
</xsd:sequence> |
|||
<xsd:attribute name="name" type="xsd:string" use="required" /> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:choice> |
|||
</xsd:complexType> |
|||
</xsd:element> |
|||
</xsd:schema> |
|||
<resheader name="resmimetype"> |
|||
<value>text/microsoft-resx</value> |
|||
</resheader> |
|||
<resheader name="version"> |
|||
<value>2.0</value> |
|||
</resheader> |
|||
<resheader name="reader"> |
|||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
<resheader name="writer"> |
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> |
|||
</resheader> |
|||
</root> |
|||
@ -0,0 +1,26 @@ |
|||
//------------------------------------------------------------------------------
|
|||
// <auto-generated>
|
|||
// 此代码由工具生成。
|
|||
// 运行时版本:4.0.30319.42000
|
|||
//
|
|||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
|||
// 重新生成代码,这些更改将会丢失。
|
|||
// </auto-generated>
|
|||
//------------------------------------------------------------------------------
|
|||
|
|||
namespace Container.Properties { |
|||
|
|||
|
|||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] |
|||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.2.0.0")] |
|||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { |
|||
|
|||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); |
|||
|
|||
public static Settings Default { |
|||
get { |
|||
return defaultInstance; |
|||
} |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
<?xml version='1.0' encoding='utf-8'?> |
|||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)"> |
|||
<Profiles> |
|||
<Profile Name="(Default)" /> |
|||
</Profiles> |
|||
<Settings /> |
|||
</SettingsFile> |
|||
@ -0,0 +1,54 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> |
|||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" /> |
|||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> |
|||
<security> |
|||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3"> |
|||
<!-- UAC 清单选项 |
|||
如果要更改 Windows 用户帐户控制级别,请用以下节点之一替换 |
|||
requestedExecutionLevel 节点。 |
|||
|
|||
<requestedExecutionLevel level="asInvoker" uiAccess="false" /> |
|||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> |
|||
<requestedExecutionLevel level="highestAvailable" uiAccess="false" /> |
|||
|
|||
指定 requestedExecutionLevel 节点将会禁用文件和注册表虚拟化。 |
|||
如果要利用文件和注册表虚拟化实现向后 |
|||
兼容性,则删除 requestedExecutionLevel 节点。 |
|||
--> |
|||
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> |
|||
</requestedPrivileges> |
|||
<applicationRequestMinimum> |
|||
<defaultAssemblyRequest permissionSetReference="Custom" /> |
|||
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" /> |
|||
</applicationRequestMinimum> |
|||
</security> |
|||
</trustInfo> |
|||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> |
|||
<application> |
|||
<!-- 此应用程序设计使用的所有 Windows 版本的列表。 |
|||
Windows 将会自动选择最兼容的环境。--> |
|||
<!-- 如果应用程序设计为使用 Windows Vista,请取消注释以下 supportedOS 节点--> |
|||
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>--> |
|||
<!-- 如果应用程序设计使用 Windows 7,请取消注释以下 supportedOS 节点--> |
|||
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>--> |
|||
<!-- 如果应用程序设计为使用 Windows 8,请取消注释以下 supportedOS 节点--> |
|||
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>--> |
|||
<!-- 如果应用程序设计为使用 Windows 8.1,请取消对以下 supportedOS 节点的注释--> |
|||
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>--> |
|||
</application> |
|||
</compatibility> |
|||
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) --> |
|||
<!-- <dependency> |
|||
<dependentAssembly> |
|||
<assemblyIdentity |
|||
type="win32" |
|||
name="Microsoft.Windows.Common-Controls" |
|||
version="6.0.0.0" |
|||
processorArchitecture="*" |
|||
publicKeyToken="6595b64144ccf1df" |
|||
language="*" |
|||
/> |
|||
</dependentAssembly> |
|||
</dependency>--> |
|||
</asmv1:assembly> |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.SaversViewModel |
|||
{ |
|||
public class NavViewModel |
|||
{ |
|||
public string FloorName { get; set; } |
|||
public int Angle { get; set; } |
|||
public int Distance { get; set; } |
|||
public string ShopName { get; set; } |
|||
public string LogoPath { get; set; } |
|||
|
|||
} |
|||
} |
|||
@ -0,0 +1,76 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.SaversViewModel |
|||
{ |
|||
class ProgressViewModel : ViewModelBase |
|||
{ |
|||
private int currentProgress = 0; |
|||
private int maxValue = 0; |
|||
private double val = 0.00; |
|||
private string message = string.Empty; |
|||
private string title = string.Empty; |
|||
|
|||
|
|||
public double Val |
|||
{ |
|||
get { return val; } |
|||
set |
|||
{ |
|||
val = value; |
|||
OnPropertyChanged("Val"); |
|||
} |
|||
} |
|||
|
|||
public string Title |
|||
{ |
|||
get { return title; } |
|||
set |
|||
{ |
|||
title = value; |
|||
OnPropertyChanged("Title"); |
|||
} |
|||
} |
|||
|
|||
public int CurrentProgress |
|||
{ |
|||
get { return currentProgress; } |
|||
set |
|||
{ |
|||
currentProgress = value; |
|||
OnPropertyChanged("CurrentProgress"); |
|||
} |
|||
} |
|||
|
|||
public int MaxValue |
|||
{ |
|||
get { return maxValue; } |
|||
set |
|||
{ |
|||
maxValue = value; |
|||
OnPropertyChanged("MaxValue"); |
|||
} |
|||
} |
|||
|
|||
public string Message |
|||
{ |
|||
get { return message; } |
|||
set |
|||
{ |
|||
message = value; |
|||
OnPropertyChanged("Message"); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public enum MarqueeType |
|||
{ |
|||
Up, |
|||
Down, |
|||
Left, |
|||
Right |
|||
} |
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
namespace Container.SaversViewModel |
|||
{ |
|||
public class Screensaver |
|||
{ |
|||
|
|||
|
|||
/// <summary>
|
|||
/// 屏保提示图标设置
|
|||
/// </summary>
|
|||
public int ScreenType { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 屏保提示图标设置
|
|||
/// </summary>
|
|||
public string ScreenFile { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 效果 0、固定位置 1、自由运动
|
|||
/// </summary>
|
|||
public int ScreenEffect { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 播放类型 固定位置( 0、右下角 1、居中) 自由运动(0、左右移动 1、随机移动)
|
|||
/// </summary>
|
|||
public int EffectType { get; set; } |
|||
|
|||
public int ScreenTime { get; set; } |
|||
|
|||
} |
|||
|
|||
public class Input_PlayRecordDetail |
|||
{ |
|||
/// <summary>
|
|||
/// 节目编码
|
|||
/// </summary>
|
|||
public string ProgramCode { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 时长
|
|||
/// </summary>
|
|||
public int Time { get; set; } |
|||
|
|||
/// <summary>
|
|||
/// 播放日期
|
|||
/// </summary>
|
|||
public DateTime PlayTime { get; set; } |
|||
} |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue