diff --git a/README.md b/README.md index ab8c3235538db1315f2a59c15ce73efb9fe8395e..64dd6a7dff168242f4093bbc9d5ef45f14f2817f 100644 --- a/README.md +++ b/README.md @@ -1,84 +1,91 @@  # 系统介绍 - - SiMay远程控制管理系统一套Windows远程控制系统,底层基于IOCP的异步通信模型,能对海量客户端实时监控,目前功能已实现了采用可视区域逐行扫描的远程桌面控制,只发送桌面变化区域,有效节省传输流量;经典的文件管理方式,支持快速上传下载文件和文件夹;语音监听实时传输远程语音,发送语音;视频监视采用Dx组件捕获视频画面,兼容市场主流摄像头;键盘监控全局Hook键盘,支持离线记录;经典的注册表管理;cmd终端;系统进程管理,桌面视图墙等功能,并且实现了中间会话服务器(测试阶段),支持Web端监控,项目完全采用C#.NET开发,代码仅供参考,项目不定时更新,欢迎关注点星星,fork。欢迎入群技术交流:905958449 :laughing: :blush: + - SiMay远程控制管理系统是一个Windows远程控制系统,底层基于IOCP的异步通信模型,能对海量客户端实时监控,目前功能已实现:逐行扫描远程桌面,仅传输桌面变化区域,可有效节省传输流量;经典的文件管理方式,实现了快速上传下载文件和文件夹;实时传输远程语音与发送语音,及实时捕获远程摄像头;Windows风格界面的经典注册表管理模块;命令行终端;系统进程管理,实时进程查看,用户桌面视图墙轮播等功能,被控服务端支持绿色启动及以系统服务方式安装,解决了WindowsSession桌面切换限制,实现了捕获UAC,WinLogon桌面;系统实现了中间会话服务器,可支持不同平台多主控端同时监控同一被控端,项目完全采用C#.NET开发,代码仅供参考,项目不定时更新,欢迎关注点星星,fork。欢迎入群技术交流:905958449 :laughing: :blush: # 申明 - 作为创作者,我对由此软件引起的任何行为和/或损害不承担任何责任。 您对自己的行为承担全部责任,并承认此软件仅用于教育和研究目的。 不得用于您不拥有或有权使用的任何系统。 使用此软件,您自动同意上述内容,感谢支持。 # 背景 - - 项目仅是个人在平时开发中的技术试验性项目,用于积累在工作中所遇到的有趣技术,或者试验新技术,比如系统架构,语法等。经过几次重构,系统相对比较成熟了,决定开源反馈开源社区,希望更多人能和我一起进步,欢迎吐槽改进。 + - 本项目仅为个人项目,是个人技术的一个总结,经过几次重构,系统相对比较成熟了,决定开源反馈开源社区,希望更多人能和我一起进步,欢迎吐槽改进。 ![主控界面](https://images.gitee.com/uploads/images/2019/0717/225727_cc5c40c8_1654743.jpeg "主控制界面") -![创建服务端](https://images.gitee.com/uploads/images/2019/0717/225801_d0ccad61_1654743.jpeg "创建服务端") +![创建服务端](https://images.gitee.com/uploads/images/2020/0216/154537_c7d2473c_1654743.png "创建服务") ![远程桌面](https://images.gitee.com/uploads/images/2019/0717/225853_2d8f4f8d_1654743.jpeg "远程桌面") ![文件管理](https://images.gitee.com/uploads/images/2019/0717/225829_9fed04ca_1654743.jpeg "文件管理") ![语音传输](https://images.gitee.com/uploads/images/2019/0717/225918_159b8bec_1654743.jpeg "语音传输") ![注册表管理](https://images.gitee.com/uploads/images/2019/0906/221633_6f9559ff_1654743.jpeg "注册表管理") - +![中间服务器](https://images.gitee.com/uploads/images/2020/0216/154108_e5e50552_1654743.png "多对一实时控制") + # 系统项目结构 -### SiMay.Common.Core【公共核心功能】## - - SiMay.Basic--框架级通用库 - - SiMay.Core--系统统一公共库【如统一的通讯指令丶共用组件丶通信数据实体丶字符串编解码等..】 - - SiMay.Serialize--轻量级二进制序列化库【作用:系统通信数据实体化】 +### SiMay.Core【公共核心功能】 + - SiMay.Basic --基础通用库 + - SiMay.Core --系统核心统一公共库【统一通讯指令丶共用组件丶通信数据实体等..】 + - SiMay.Serialize --轻量级高性能二进制序列化库【作用:系统通信数据实体化】 -### SiMay.RemoteMonitor【主控端】## - - SiMay.RemoteControlsCore 主控端核心库 - - SiMay.RemoteMonitor--Windows主控端(基于核心库) - - SiMay.HttpRemoteMonitor【计划,未完成】 --Http主控端展示层(基于核心库,支持.NET Core),基于WebSocket与前端通信 - - WebRemoteMonitorSystem--Web监控前端 +### SiMay.RemoteMonitor【主控制端】 + - SiMay.RemoteControlsCore --主控端核心库 + - SiMay.RemoteMonitor --Windows主控端(基于核心库) + - SiMay.RemoteMonitorForWeb【计划,未完成】 --Web主控端后端(基于核心库,支持.NET Core),基于WebSocket与前端通信 + - SiMay.RemoteMonitorForWebSite【计划,未完成】 --Web监控前端 -### SiMay.RemoteService【远程服务端】## - - SiMay.RemoteService --内存加载Loader - - SiMay.RemoteClient.NewCore--被控端核心库/被控端主程序 - - SiMay.Daemon--服务端守护进程【未启用】 +### SiMay.RemoteService【远程被控服务端】 + - SiMay.RemoteService.Loader --内存加载Loader,实现远程内存载入被控端核心库 + - SiMay.ServiceCore --被控端核心库/被控端主程序 -### SiMay.SessionProvider【会话提供库】## - - SiMay.Net.SessionProvider--会话提供库【作用:提供服务器监听模式或者中间会话代理协议】 - - SiMay.Net.SessionProvider.Core--代理协议统一公用库【作用:统一中间库和服务器的通信指令及序列化等】 - - SiMay.Net.SessionProviderService--中间会话代理服务器【作用:提供保持服务端会话保持丶数据转发功能,基于此实现多平台端监控】 +### SiMay.SessionProvider【会话提供层】 + - SiMay.Net.SessionProvider --会话提供库【作用:提供服务器监听模式或者中间会话代理协议】 + - SiMay.Net.SessionProvider.Core --代理协议统一公用库【作用:统一中间库和服务器的通信指令及序列化等】 + - SiMay.Net.SessionProviderService --中间会话代理服务器【作用:提供保持服务端会话保持丶数据转发功能,基于此实现多平台端监控】 -### SiMay.Sockets【Socket通信库】## - - SiMay.Socket.V4 1.0--轻量级通信引擎【计划.NET Core】 - - SiMaySocketTestApp--通信引擎测试程序 +### SiMay.Sockets【通信层】 + - SiMay.Socket.Standard --轻量级通信引擎 + - SiMaySocketTestApp --通信引擎测试程序 -### SiMay.Web.MonitorService【Web监控服务端】## - - SiMay.Net.HttpRemoteMonitorService--WebSocket监控服务端【计划弃用】 +### SiMay.Web.MonitorService【Web监控服务端,已弃用】 + - SiMay.Net.HttpRemoteMonitorService --WebSocket监控服务端 ### 编译 -1.Bin目录为生成目录,重新生成后,主控程序将编译到此目录,Bin->dat目录为服务端目录,被控服务端编译后在此。(没有目录新建一下) + - 1.Bin为编译目录,重新生成后,主控程序将编译到此目录,Bin->dat目录为被控服务端目录,被控服务端编译后在此。(没有目录新建一下) ### 运行 -1.局域网 -主控端:打开主控程序SiMayRemoteMonitor.exe,确认系统设置服务器地址为0.0.0.0(监听本机所有网卡),端口默认5200,确认会话模式为:本地服务器,然后保存配置重启程序, + - 1.局域网 + +主控端:打开位与Bin目录下的主控端程序SiMayRemoteMonitor.exe,确认系统设置服务器地址为0.0.0.0(监听本机所有网卡),端口默认5200,使用会话模式为=本地服务器,然后保存配置重启程序, 重启后日志输出监听成功,即主控端设置正确。 -被控服务端:打开主控端-->创建客户-->地址输入本机ip地址(或127.0.0.1)-->端口设置为服务端监听端口(默认5200)-->点击连接测试检查配置是否正确-->创建服务端文件,服务端文件即为配置完成的被控端程序(如提示找不到文件,请检查编译步骤是否正确),双击运行即可连接至主控端,如连接不成功,请检查上述步骤是否配置正确。 +被控服务端创建:打开主控端-->创建客户-->地址输入本机物理地址(或127.0.0.1),端口设置为服务端监听端口(默认5200)-->点击连接测试检查配置是否正确-->创建服务端文件,服务端文件即为配置完成的被控端程序(如提示找不到文件,请检查被控服务程序是否存在[编译步骤是否正确]),双击运行被控服务程序即可在主控端看见服务在线信息,如主控端无在线信息,请检查上述步骤是否配置正确。 + + - 2.广域网 -2.广域网 -条件:需要主控端处于公网环境(或者设置路由内网映射),并且开放主控端监听端口。 +条件:需要主控端处于公网环境(或者设置路由内网映射、使用内网映射工具[如花生壳,内网通]),并且开放主控端监听端口(注意检查端口是否开放、防火墙通行规则)。 创建客户端-->被控服务端连接至主控端的公网地址,端口即可 -3.中间服务器部署 -条件:需要中间服务器处于公网环境(或者设置路由内网映射),并且开放中间服务器监听端口(默认522端口)。 + - 3.中间服务器部署 + +条件:需要中间服务器处于公网环境(建议部署在公网服务器,或者设置路由内网映射),并且开放中间服务器监听端口(默认522端口、注意检查端口是否开放、防火墙通行规则)。 + +主控端设置: 系统设置-->会话服务器地址 输入 中间服务器的公网地址,端口。-->设置会话模式为:中间会话模式-->确认AccessKey与中间服务器Accesskey一致。(中间会话服务器系统设置位于标题栏系统菜单右键)-->创建客户端并选择会话模式为中间会话模式,ip,端输入中间服务器的公网地址即可 -设置 主控端设置 会话服务器地址 为 中间服务器的地址,端口。-->设置会话模式为:中间会话模式-->(中间会话服务器系统设置位于系统菜单右键)确认连接密码与中间服务器密码一致。-->创建客户端,将ip,端口指向中间服务器即可 + - 4.web端监控【完善中,不可用】 -4.web端监控【完善中,不可用】 配置IIS,部署SiMay.WebRemoteMonitor网站,编译启动SiMay.Net.HttpRemoteMonitorService,配置地址指向中间服务器ip,端口即可(无系统设置,需手动配置配置文件),如连接成功,中间服务器出现主控制连接在线日志即可 -使用浏览器,访问SiMay.WebRemoteMonitor网站,输入SiMay.Net.HttpRemoteMonitorService配置的账号密码即可,当有中间服务器有被控端会话时,将自动连接至http服务,此时网页可看到被控服务端计算机屏幕视图,长按视图打开更多功能。 +使用浏览器,访问SiMay.WebRemoteMonitor网站,输入SiMay.Net.HttpRemoteMonitorService配置的账号密码即可,当有中间服务器有被控端会话时,将自动连接至http服务,连接成功后网页可看到被控服务端计算机桌面视图,长按视图可打开更多功能。 ### 技术架构 + - 基于组件式的系统架构 + - 基于实体的实体消息协议 - 基于IOCP的异步Socket高性能通信模型 - - 采用热区域逐行扫描算法的远程桌面 - - 语音通讯采用Windows WaInXX等Api实现 - - 视频监控采用Dx组件捕获图像 - - 键盘记录采用HOOK技术捕获全局键盘消息 - - Web端监控采用了WebSocket等技术实现 + - 基于可视区域逐行扫描算法的远程桌面 + - 基于Windows WaInXX系列实现的语音通讯 + - 基于Dx组件捕获摄像头 + - 基于HOOK技术的键盘记录 + - 基于WebSocket技术实现Web端监控 + - 中间会话服务转发,支持多个主控端同时实时监控 ### 开发环境 - - Visual Studio 2015 以上 + - 建议 Visual Studio 2019 企业版 ### 参与贡献 - Fork 本仓库 @@ -87,32 +94,36 @@ - 新建 Pull Request ### 未来构想 - - 实现多平台控制端同步监控 - - 完善更多web监控功能 + - 移动Web监控端 + - 跨平台的系统管理监控 ### SiMay远程监控管理系统更新说明 ### 6.0更新 -1. 跨.NET Core支持,完善中间会话服务器、Web端实时监控管理 --未完成 -2. 二进制序列器性能优化,提升系统性能 -- 未完成 +1. 跨.NET Core支持,重构中间会话服务器 --2020.2.15 +2. 二进制序列化器采用反射缓存,提高系统性能 -- 2020.1.25 +3. 屏幕视图轮播 --2020.1.15 +4. Web端主控端 --未实现 +5. SOCK5代理,并兼容中间服务转发 -- 未实现 +6. 远程桌面,语音监听,摄像头监控支持录制功能 --2.26 ### 5.0更新 -1. 优化了通讯库,支持FULL丶PACK数据处理方式,更友好的配置接口 +1. 优化了通讯库,支持FULL丶PACK数据处理方式,实现了更友好的配置接口 2. 新增中间会话转发服务,增加了SessionProvider层,控制端支持监听模式丶中间会话模式,在此基础上实现了Web监控服务,支持Web方式监控 -3. 增强了远程桌面,支持全屏监控的远程鼠标控制 -4. 重构代码结构,实现了组件化代码框架,即使不熟悉框架也能轻松扩展功能 --2019.5.19 -5. 远程桌面采用了热区域扫描算法,仅扫描可视区域变化部分,优化了远程桌面模块,速度更加快了 --2019.4.2 -6. 增强系统管理模块,实时进程监控 8.28 -7. 语音监听,视频监控支持录制功能 --待实现 -8. 被控服务实现了服务方式安装,实现了Session隔离穿透捕获桌面(锁屏,UAC), --11.9 -9. 文件管理功能增强,重构文件夹传输 2019.7.13 -10. 系统传输数据实体化 -- 2019-6-4 -11. 二进制序列化器采用反射缓存,提高系统性能 --待实现 -12. 远程桌面增加质量调整,低速率网络下控制更加流畅 -- 7.27 +3. 增强了远程桌面模块,支持全屏监控的远程鼠标控制及多屏幕切换 +4. 重构代码结构,实现了组件化系统框架,屏蔽了系统底层实现细节,增强了可扩展性 --2019.5.19 +5. 远程桌面增加了可视区域扫描算法,仅扫描可视区域变化部分,优化了远程桌面模块,速度更加快了 --2019.4.2 +6. 增强系统管理模块,实现了进程实时监控 --8.28 +7. 语音监听,视频监控支持录制功能 --6.0已实现 +8. 被控服务实现了以服务方式安装,使用服务方式可实现Session隔离穿透捕获桌面(锁屏,UAC), --11.9 +9. 文件管理功文件夹传输重构优化 2019.7.13 +10. 系统传输数据消息实体化 -- 2019-6-4 +11. 二进制序列化器采用反射缓存,提高系统性能 --已实现 +12. 远程桌面增加画面质量调整,优化低速率网络下的控制体验,使画面更加流畅 -- 7.27 13. 支持远程更新服务端 -- 7.27 14. 增加列表排序功能 -- 7.27 -15. 注册表组件更新,支持二进制丶多种类型数据编辑 9.6 -16. 重构主控端,实现主控端逻辑与展示层(winform)彻底分离,实现核心逻辑复用为跨平台监控打好基础 - 11.2 +15. 注册表组件更新,支持二进制丶多种类型数据编辑 -- 9.6 +16. 重构主控端,主控端逻辑核心库与展示层彻底分离(如:基于核心库横向扩展Web主控端,实现多平台逻辑复用) - 11.2 ### 4.0更新 1. 重写了通讯层,解决网络环境极差时频繁断开连接的情况,实现了对象池,以更好的并发能力应对大规模的客户端数据交互 diff --git a/SiMay.Basic/ArrayHelper.cs b/SiMay.Basic/ArrayHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..50ebf5783f3679c30830eb2e822a395960a86144 --- /dev/null +++ b/SiMay.Basic/ArrayHelper.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Basic +{ + public static class ArrayHelper + { + public static T[] Copy(this T[] source, int offset, int lenght) + { + var nArray = new T[lenght]; + Array.Copy(source, offset, nArray, 0, lenght); + return nArray; + } + } +} diff --git a/SiMay.Basic/CollectionExtension.cs b/SiMay.Basic/CollectionExtension.cs index 73e34ef7d827ddf457a6f36b7bd7f997057410f6..ebd4653942ed246ce1312a2bc9de49b314371982 100644 --- a/SiMay.Basic/CollectionExtension.cs +++ b/SiMay.Basic/CollectionExtension.cs @@ -1,4 +1,5 @@ using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; @@ -11,5 +12,43 @@ namespace SiMay.Basic { return source == null || source.Count == 0; } + + public static T FristOrDefault(this ICollection source, Func func) + { + foreach (var item in source) + { + if (func(item)) + return item; + } + return default; + } + + public static T FristOrDefault(this ICollection source) + { + foreach (var item in source) + { + return (T)item; + } + return default; + } + + public static T FristOrDefault(this ICollection source, Func func) + { + foreach (var item in source) + { + if (func((T)item)) + return (T)item; + } + return default; + } + + public static IEnumerable Select(this ICollection source, Func func) + { + var results = new List(); + foreach (var item in source) + results.Add(func((T)item)); + + return results; + } } } diff --git a/SiMay.Basic/CompressHelper.cs b/SiMay.Basic/GZipHelper.cs similarity index 87% rename from SiMay.Basic/CompressHelper.cs rename to SiMay.Basic/GZipHelper.cs index 2e28233d7e34e5599c511dc777ede9718974646d..04afb29d21cafaa1ac7e695c16844fb44ac3ee12 100644 --- a/SiMay.Basic/CompressHelper.cs +++ b/SiMay.Basic/GZipHelper.cs @@ -7,7 +7,7 @@ using System.Text; namespace SiMay.Basic { - public class CompressHelper + public class GZipHelper { public static byte[] Compress(byte[] data, int offset, int lenght) @@ -27,13 +27,14 @@ namespace SiMay.Basic catch { } return buffer; } - public static byte[] Decompress(byte[] data) + => Decompress(data, 0, data.Length); + public static byte[] Decompress(byte[] data, int offset, int length) { byte[] buffer = null; try { - MemoryStream ms = new MemoryStream(data); + MemoryStream ms = new MemoryStream(data, offset, length); GZipStream zip = new GZipStream(ms, CompressionMode.Decompress, true); MemoryStream msreader = new MemoryStream(); buffer = new byte[0x1000]; diff --git a/SiMay.Basic/IPHelper.cs b/SiMay.Basic/HostHelper.cs similarity index 94% rename from SiMay.Basic/IPHelper.cs rename to SiMay.Basic/HostHelper.cs index 46fd274d20512cd1e824e06992b164c7acc26036..c30f821ebda99a00f77d1731e96640406757e366 100644 --- a/SiMay.Basic/IPHelper.cs +++ b/SiMay.Basic/HostHelper.cs @@ -6,7 +6,7 @@ using System.Text; namespace SiMay.Basic { - public class IPHelper + public class HostHelper { public static string GetHostByName(string host) { diff --git a/SiMay.Basic/ImageHelper.cs b/SiMay.Basic/ImageHelper.cs deleted file mode 100644 index 44ad7be204e8719889cb6a7c5b8af043edec2404..0000000000000000000000000000000000000000 --- a/SiMay.Basic/ImageHelper.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Drawing.Drawing2D; -using System.Drawing.Imaging; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; - -namespace SiMay.Core.ScreenSpy -{ - /// - /// 通用屏幕图像处理类 - /// - public class ImageHelper - { - public static Bitmap SizeImage(Image srcImage, Size size) - { - try - { - Bitmap bitmap = new Bitmap(srcImage, size.Width, size.Height); - //Graphics g = Graphics.FromImage(bitmap); - - //g.InterpolationMode = InterpolationMode.HighQualityBicubic; - //g.DrawImage(srcImage, new Rectangle(0, 0, width, height), new Rectangle(0, 0, srcImage.Width, srcImage.Height), GraphicsUnit.Pixel); - //g.Dispose(); - return bitmap; - } - catch - { - return null; - } - } - } -} diff --git a/SiMay.Basic/ObjectHelper.cs b/SiMay.Basic/ObjectHelper.cs index 2649902f4b674b8aafbb0430d094ca827fc1bd16..ed979ee923700fdc9e0697741d53e269a0b0d938 100644 --- a/SiMay.Basic/ObjectHelper.cs +++ b/SiMay.Basic/ObjectHelper.cs @@ -11,5 +11,10 @@ namespace SiMay.Basic { return (T)obj; } + + public static bool IsNull(this object obj) + { + return obj == null; + } } } diff --git a/SiMay.Basic/Properties/AssemblyInfo.cs b/SiMay.Basic/Properties/AssemblyInfo.cs deleted file mode 100644 index b8e5859cc610884434797839dec348e9c43ac024..0000000000000000000000000000000000000000 --- a/SiMay.Basic/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("SiMay.Basic")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SiMay.Basic")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("b30cd716-698a-4da2-bd1a-c152b16993c0")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -//通过使用 "*",如下所示: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.cs b/SiMay.Basic/RectangleHelper.cs similarity index 33% rename from SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.cs rename to SiMay.Basic/RectangleHelper.cs index 3b39d787cdf213b79944dd3c42155c3b88955d5f..2f9f81ae5de7ce8a5b082d117613a990b7c3e807 100644 --- a/SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.cs +++ b/SiMay.Basic/RectangleHelper.cs @@ -1,20 +1,17 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.Data; using System.Drawing; using System.Linq; using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; -namespace SiMay.RemoteMonitor.MainApplication +namespace SiMay.Basic { - public partial class DesktopViewWallSettingForm : Form + public class RectangleHelper { - public DesktopViewWallSettingForm() + public static bool WhetherContainsInRectangle(Rectangle containerRect, Rectangle childRect) { - InitializeComponent(); + var result = childRect.Y + childRect.Height >= containerRect.Y && childRect.Y <= containerRect.Bottom; + return result; } } } diff --git a/SiMay.Basic/SecurityHelper.cs b/SiMay.Basic/SecurityHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..838114b25de45d1208c638c8c93fcd39879d5ecb --- /dev/null +++ b/SiMay.Basic/SecurityHelper.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Security.Cryptography; +using System.Text; + +namespace SiMay.Basic +{ + public class SecurityHelper + { + public static string MD5(string text) + { + using (System.Security.Cryptography.MD5 mi = System.Security.Cryptography.MD5.Create()) + { + byte[] buffer = Encoding.Default.GetBytes(text); + byte[] newBuffer = mi.ComputeHash(buffer); + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < newBuffer.Length; i++) + { + sb.Append(newBuffer[i].ToString("x2")); + } + return sb.ToString(); + } + } + } +} diff --git a/SiMay.Basic/SiMay.Basic.csproj b/SiMay.Basic/SiMay.Basic.csproj index dd39ee25691650c71c770dbcbfe8aba2cdf2d941..c7ed923eaabfd0694c46385fa9e887decca6fb2a 100644 --- a/SiMay.Basic/SiMay.Basic.csproj +++ b/SiMay.Basic/SiMay.Basic.csproj @@ -1,65 +1,15 @@ - - - + + - Debug - AnyCPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0} - Library - Properties - SiMay.Basic - SiMay.Basic - v4.0 - 512 - true + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 8.0 + + + ..\Bin\ - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - 8.0 + + + ..\Bin\ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + diff --git a/SiMay.Core/AppJobConstant.cs b/SiMay.Core/AppJobConstant.cs new file mode 100644 index 0000000000000000000000000000000000000000..bcf570a7a7ecc075b3ff7ddb9536c2332bec06b8 --- /dev/null +++ b/SiMay.Core/AppJobConstant.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SiMay.Core +{ + public class AppJobConstant + { + public const string REMOTE_DESKTOP = "RemoteDesktopJob"; + + public const string REMOTE_FILE = "FileManagerJob"; + + public const string REMOTE_AUDIO = "RemoteAudioJob"; + + public const string REMOTE_REGEDIT = "RemoteRegistryEditorJob"; + + public const string REMOTE_SHELL = "RemoteShellJob"; + + public const string REMOTE_STARTUP = "StartupManagerJob"; + + public const string REMOTE_SYSMANAGER = "SystemManagerJob"; + + public const string REMOTE_TCP = "TcpConnectionManagerJob"; + + public const string REMOTE_VIDEO = "RemoteViedoJob"; + + public const string REMOTE_UPDATE = "RemoteUpdateJob"; + } +} diff --git a/SiMay.Core/Entitys/ServiceOptions.cs b/SiMay.Core/Entitys/ServiceOptions.cs index 2ac6004664382d579c52f3c7e1b65ae45c5888dd..425c2773ef6d6a046f5a8cc9e697f0ec6485e46e 100644 --- a/SiMay.Core/Entitys/ServiceOptions.cs +++ b/SiMay.Core/Entitys/ServiceOptions.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Entitys { - public class ServiceOptions + public class ServiceOptions : EntitySerializerBase { public string Id { get; set; } public string Host { get; set; } diff --git a/SiMay.Core/Enums/ConnectionWorkType.cs b/SiMay.Core/Enums/ConnectionWorkType.cs index c0d84ca5de70a0269d8a46ff2ea31ec0f553f4b8..91380852b66aa2cc03420fd6f3d7514eebf139ab 100644 --- a/SiMay.Core/Enums/ConnectionWorkType.cs +++ b/SiMay.Core/Enums/ConnectionWorkType.cs @@ -3,12 +3,23 @@ using System.Collections.Generic; using System.Linq; using System.Text; -namespace SiMay.Core.Enums +namespace SiMay.Core { public enum ConnectionWorkType : Byte { - MAINCON,//主连接 - WORKCON,//工作连接 - NONE,//未确认的连接 + /// + /// 主服务连接 + /// + MAINCON, + + /// + /// 应用服务工作连接 + /// + WORKCON, + + /// + /// 未识别的连接 + /// + NONE, } } diff --git a/SiMay.Core/Enums/DifferStatus.cs b/SiMay.Core/Enums/DifferStatus.cs index 623d9c5215b002341008e4c6d6a8c233880c46fc..43cb1a2b016ffecf933a4abd2bbff6dffc572da5 100644 --- a/SiMay.Core/Enums/DifferStatus.cs +++ b/SiMay.Core/Enums/DifferStatus.cs @@ -7,8 +7,19 @@ namespace SiMay.Core.Enums { public enum DifferStatus { - FULLDIFFERENCES, - NEXTSCREEN, - COMPLETE + /// + /// 全屏扫描完成 + /// + FULL_DIFFERENCES, + + /// + /// 差异下一帧扫描完成 + /// + NEXT_SCREEN, + + /// + /// 完成扫描 + /// + COMPLETED } } diff --git a/SiMay.Core/Enums/FileType.cs b/SiMay.Core/Enums/FileType.cs index 384da5d810b62157db413959953fde283c3fda1a..25d3d7dfbe8597d4b08c673d0b43469bbb33a293 100644 --- a/SiMay.Core/Enums/FileType.cs +++ b/SiMay.Core/Enums/FileType.cs @@ -7,8 +7,19 @@ namespace SiMay.Core.Enums { public enum FileType : Byte { + /// + /// 磁盘 + /// Disk, + + /// + /// 文件 + /// File, + + /// + /// 文件夹 + /// Directory } } diff --git a/SiMay.Core/Enums/MessageIcon.cs b/SiMay.Core/Enums/MessageIcon.cs index 799f411a2a2fdba124aa1618f79a9abbb91c019a..743f446e342907213bf3a8586bacfed142cb292c 100644 --- a/SiMay.Core/Enums/MessageIcon.cs +++ b/SiMay.Core/Enums/MessageIcon.cs @@ -7,9 +7,24 @@ namespace SiMay.Core.Enums { public enum MessageIcon : Byte { + /// + /// 错误信息 + /// Error, + + /// + /// 问号 + /// Question, + + /// + /// 信息 + /// InforMation, + + /// + /// 叹号 + /// Exclaim } } diff --git a/SiMay.Core/Enums/MouseKeyEnum.cs b/SiMay.Core/Enums/MouseKeyEnum.cs index 98ac04a5d1332712f12f21ec98d95be07a5cb2ad..2f907e6d29275c8dd9712431a4a2709b03a6a7f0 100644 --- a/SiMay.Core/Enums/MouseKeyEnum.cs +++ b/SiMay.Core/Enums/MouseKeyEnum.cs @@ -7,15 +7,47 @@ namespace SiMay.Core.Enums { public enum MOUSEKEY_ENUM : byte { + /// + /// 鼠标移动 + /// Move, + + /// + /// 左键按下 + /// LeftDown, + + /// + /// 左键抬起 + /// LeftUp, + MiddleDown, MiddleUp, + + /// + /// 右键按下 + /// RightDown, + + /// + /// 右键抬起 + /// RightUp, + + /// + /// 滚轮 + /// Wheel, + + /// + /// 按键按下 + /// KeyDown, + + /// + /// 按键抬起 + /// KeyUp } } diff --git a/SiMay.Core/Enums/RemoteUpdateType.cs b/SiMay.Core/Enums/RemoteUpdateType.cs index 23f67ae53d97bc38edfc01f2d8d65eb442ee45ec..a49c2dc4437d36d6b307e6f1c65dff1aca9dea7d 100644 --- a/SiMay.Core/Enums/RemoteUpdateType.cs +++ b/SiMay.Core/Enums/RemoteUpdateType.cs @@ -7,7 +7,14 @@ namespace SiMay.Core.Enums { public enum RemoteUpdateType { + /// + /// URL下载更新 + /// Url, + + /// + /// 文件上传更新 + /// File } } diff --git a/SiMay.Core/Enums/SystemSessionType.cs b/SiMay.Core/Enums/SystemSessionType.cs index 1fe0f8f6ea0d7c9f56d94ac48e7bda7d750597a9..3602c8b0f17ad3866181611a7f385aaba5cc2a78 100644 --- a/SiMay.Core/Enums/SystemSessionType.cs +++ b/SiMay.Core/Enums/SystemSessionType.cs @@ -7,14 +7,53 @@ namespace SiMay.Core.Enums { public enum SystemSessionType : byte { + /// + /// 关机 + /// Shutdown = 0, + + /// + /// 重启 + /// Reboot = 1, + + /// + /// 注册表启动 + /// RegStart = 2, + + /// + /// 取消注册表启动 + /// RegCancelStart = 3, + + /// + /// 隐藏自身文件及日志 + /// AttributeHide = 4, + + /// + /// 显示自身文件 + /// AttributeShow = 5, + + /// + /// 退出程序 + /// Unstall = 6, + + /// + /// 以服务安装 + /// InstallService = 7, - UnInstallService = 8 + + /// + /// 卸载服务 + /// + UnInstallService = 8, + /// + /// 重启服务 + /// + ReStartService=9 } } diff --git a/SiMay.Core/Extensions/RegistryKeyExtensions.cs b/SiMay.Core/Extensions/RegistryKeyExtensions.cs index 21c24cbdfa64c4bc4adb8466c155ae068740493e..0b9cc4fa6c9c3c686d6e6615d835fd603b7a4a49 100644 --- a/SiMay.Core/Extensions/RegistryKeyExtensions.cs +++ b/SiMay.Core/Extensions/RegistryKeyExtensions.cs @@ -246,16 +246,16 @@ namespace SiMay.Core.Extensions { case RegistryValueKind.String: case RegistryValueKind.ExpandString: - data = ByteConverter.ToString((byte[]) data); + data = ByteConverterHelper.ToString((byte[]) data); break; case RegistryValueKind.DWord: - data = ByteConverter.ToUInt32((byte[]) data); + data = ByteConverterHelper.ToUInt32((byte[]) data); break; case RegistryValueKind.QWord: - data = ByteConverter.ToUInt64((byte[]) data); + data = ByteConverterHelper.ToUInt64((byte[]) data); break; case RegistryValueKind.MultiString: - data = ByteConverter.ToStringArray((byte[]) data); + data = ByteConverterHelper.ToStringArray((byte[]) data); break; } } diff --git a/SiMay.Core/ByteConverter.cs b/SiMay.Core/Helper/ByteConverterHelper.cs similarity index 98% rename from SiMay.Core/ByteConverter.cs rename to SiMay.Core/Helper/ByteConverterHelper.cs index 800fc3884225e259fcf5f409678d24161e38e144..2ee16af436ac11a6b5a1ffd751589706750f4ecc 100644 --- a/SiMay.Core/ByteConverter.cs +++ b/SiMay.Core/Helper/ByteConverterHelper.cs @@ -5,7 +5,7 @@ using System.Text; namespace SiMay.Core { - public class ByteConverter + public class ByteConverterHelper { private static byte NULL_BYTE = byte.MinValue; diff --git a/SiMay.Core/Common/FileHelper.cs b/SiMay.Core/Helper/FileHelper.cs similarity index 100% rename from SiMay.Core/Common/FileHelper.cs rename to SiMay.Core/Helper/FileHelper.cs diff --git a/SiMay.Core/FileIconUtil.cs b/SiMay.Core/Helper/FileIconUtil.cs similarity index 97% rename from SiMay.Core/FileIconUtil.cs rename to SiMay.Core/Helper/FileIconUtil.cs index 7f35f0cf94210b8f1663c1bfa85c9994f5cc31c4..e8ae2da5b065062ae89db2cb7376f4580eec7f88 100644 --- a/SiMay.Core/FileIconUtil.cs +++ b/SiMay.Core/Helper/FileIconUtil.cs @@ -36,6 +36,9 @@ namespace SiMay.Core [DllImport("User32.dll", EntryPoint = "DestroyIcon")] public static extern int DestroyIcon(IntPtr hIcon); + [DllImport("ole32.dll")] + public static extern int CoInitialize(IntPtr pvReserved); + //定义文件属性标识 public enum FileAttributeFlags : int { @@ -97,6 +100,7 @@ namespace SiMay.Core { FileInfomation shfi = new FileInfomation(); IntPtr hI; + CoInitialize(IntPtr.Zero); if (isLargeIcon) { hI = SHGetFileInfo(fileExt, 0, ref shfi, (uint)Marshal.SizeOf(shfi), (uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_USEFILEATTRIBUTES | (uint)FileInfoFlags.SHGFI_LARGEICON); @@ -118,6 +122,7 @@ namespace SiMay.Core { FileInfomation _FileInfomation = new FileInfomation(); IntPtr _IconIntPtr; + CoInitialize(IntPtr.Zero); if (isLargeIcon) { _IconIntPtr = SHGetFileInfo(@"", 0, ref _FileInfomation, (uint)Marshal.SizeOf(_FileInfomation), ((uint)FileInfoFlags.SHGFI_ICON | (uint)FileInfoFlags.SHGFI_LARGEICON)); diff --git a/SiMay.Core/Helper/FileTransmissionHelper.cs b/SiMay.Core/Helper/FileTransmissionHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..f59cd5f142e7c2a9eba110958f74d71b59735cc5 --- /dev/null +++ b/SiMay.Core/Helper/FileTransmissionHelper.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SiMay.Basic; + +namespace SiMay.Core.Helper +{ + public class FileTransmissionHelper + { + private const int DefaultBufferSize = 1024 * 100; + + public int BufferSize + { + get + { + return _bufferSize; + } + set + { + if (_bufferSize == value) + return; + _buffer = new byte[value]; + _bufferSize = value; + } + } + + private byte[] _buffer = new byte[DefaultBufferSize]; + private FileStream _fileStream; + private int _bufferSize = DefaultBufferSize; + public FileTransmissionHelper(string fileName, FileMode fileMode) => _fileStream = new FileStream(fileName, fileMode); + + public byte[] Read() + { + int lenght = _fileStream.Read(_buffer, 0, _buffer.Length); + if (lenght < _bufferSize) + return _buffer.Copy(0, lenght); + else + return _buffer; + } + + public void Write(byte[] data) => _fileStream.Write(data, 0, data.Length); + + public void Close() + { + _fileStream.Flush(); + _fileStream.Close(); + } + } +} diff --git a/SiMay.Core/Common/GeoLocationHelper.cs b/SiMay.Core/Helper/GeoLocationHelper.cs similarity index 100% rename from SiMay.Core/Common/GeoLocationHelper.cs rename to SiMay.Core/Helper/GeoLocationHelper.cs diff --git a/SiMay.Core/Common/PlatformHelper.cs b/SiMay.Core/Helper/PlatformHelper.cs similarity index 100% rename from SiMay.Core/Common/PlatformHelper.cs rename to SiMay.Core/Helper/PlatformHelper.cs diff --git a/SiMay.Core/Common/RegValueHelper.cs b/SiMay.Core/Helper/RegValueHelper.cs similarity index 81% rename from SiMay.Core/Common/RegValueHelper.cs rename to SiMay.Core/Helper/RegValueHelper.cs index d34dfad34bd3e230eefb4f08f7face44a0043ef6..51e20918e7868a5fbff807acdb340627ea108a84 100644 --- a/SiMay.Core/Common/RegValueHelper.cs +++ b/SiMay.Core/Helper/RegValueHelper.cs @@ -26,16 +26,16 @@ namespace SiMay.Core.Common case RegistryValueKind.Binary: return value.Data.Length > 0 ? BitConverter.ToString(value.Data).Replace("-", " ").ToLower() : "(zero-length binary value)"; case RegistryValueKind.MultiString: - return string.Join(" ", ByteConverter.ToStringArray(value.Data)); + return string.Join(" ", ByteConverterHelper.ToStringArray(value.Data)); case RegistryValueKind.DWord: - var dword = ByteConverter.ToUInt32(value.Data); + var dword = ByteConverterHelper.ToUInt32(value.Data); return $"0x{dword:x8} ({dword})"; // show hexadecimal and decimal case RegistryValueKind.QWord: - var qword = ByteConverter.ToUInt64(value.Data); + var qword = ByteConverterHelper.ToUInt64(value.Data); return $"0x{qword:x8} ({qword})"; // show hexadecimal and decimal case RegistryValueKind.String: case RegistryValueKind.ExpandString: - return ByteConverter.ToString(value.Data); + return ByteConverterHelper.ToString(value.Data); default: return string.Empty; } diff --git a/SiMay.Core/Common/RegistryKeyHelper.cs b/SiMay.Core/Helper/RegistryKeyHelper.cs similarity index 93% rename from SiMay.Core/Common/RegistryKeyHelper.cs rename to SiMay.Core/Helper/RegistryKeyHelper.cs index ce5fe531eaa92fd84cec5628d637c0cba5eb944f..4d7432b86d7b9836dd8d18b5f3a1f3288dde43cf 100644 --- a/SiMay.Core/Common/RegistryKeyHelper.cs +++ b/SiMay.Core/Helper/RegistryKeyHelper.cs @@ -131,17 +131,17 @@ namespace SiMay.Core.Common newRegValue.Data = (byte[]) value; break; case RegistryValueKind.MultiString: - newRegValue.Data = ByteConverter.GetBytes((string[]) value); + newRegValue.Data = ByteConverterHelper.GetBytes((string[]) value); break; case RegistryValueKind.DWord: - newRegValue.Data = ByteConverter.GetBytes((uint) (int) value); + newRegValue.Data = ByteConverterHelper.GetBytes((uint) (int) value); break; case RegistryValueKind.QWord: - newRegValue.Data = ByteConverter.GetBytes((ulong) (long) value); + newRegValue.Data = ByteConverterHelper.GetBytes((ulong) (long) value); break; case RegistryValueKind.String: case RegistryValueKind.ExpandString: - newRegValue.Data = ByteConverter.GetBytes((string) value); + newRegValue.Data = ByteConverterHelper.GetBytes((string) value); break; } } diff --git a/SiMay.Core/MessageHead.cs b/SiMay.Core/MessageHead.cs index 6e80b6fd8f97d49968ee72e5095e1d19f1be075c..29945016252b4d9e07d5dc8d4b9bf6df337af483 100644 --- a/SiMay.Core/MessageHead.cs +++ b/SiMay.Core/MessageHead.cs @@ -5,8 +5,8 @@ namespace SiMay.Core { /// - /// S_XX :表示控制端接收的命令头 - /// C_XX :表示服务端接收的命令头 + /// S_ :表示控制端接收的命令头 + /// C_ :表示服务端接收的命令头 /// public enum MessageHead { @@ -17,192 +17,186 @@ namespace SiMay.Core //主窗体------------------------------------------------------------ S_MAIN_REMARK = 1000, //备注 - S_MAIN_ACTIVATE_CTRLSERVICE, //创建功能服务 + S_MAIN_ACTIVATE_APPLICATIONSERVICE, //创建功能服务 S_MAIN_SESSION, //会话管理 S_MAIN_HTTPDOWNLOAD, //下载 - S_MAIN_OPEN_WEBURL, //打开URL + S_MAIN_OPEN_WEBURL, //打开URL S_MAIN_MESSAGEBOX, //MessageBox - S_MAIN_DESKTOPVIEW, //屏幕查看 - S_MAIN_SCREENWALL_GETIMG, //获取屏幕 - S_MAIN_USERDESKTOP_CLOSE, //关闭屏幕墙 - S_MAIN_SCREEN_RECORD_OPEN, //设置屏幕记录 - S_MAIN_SCREEN_RECORD_CLOSE, //关闭屏幕记录 - S_MAIN_SCREEN_RECORD_GETIMG, //获取下一帧屏幕记录数据 + S_MAIN_CREATE_DESKTOPVIEW, //屏幕查看 + S_MAIN_DESKTOPVIEW_GETFRAME, //获取屏幕 + S_MAIN_DESKTOPVIEW_CLOSE, //关闭屏幕墙 + S_MAIN_DESKTOPRECORD_OPEN, //设置屏幕记录 + S_MAIN_DESKTOPRECORD_CLOSE, //关闭屏幕记录 + S_MAIN_DESKTOPRECORD_GETFRAME, //获取下一帧屏幕记录数据 S_MAIN_GROUP, //分组 S_MAIN_UPDATE, //远程更新 S_MAIN_PLUGIN_FILES, //插件文件 S_MAIN_RELOADER, //重新载入服务端程序(重启进程) - S_MAIN_INSTANLL_SERVICE, //服务安装 - S_MAIN_UNINSTANLL_SERVICE, //卸载服务 + S_MAIN_INSTANLL_SERVICE, //服务安装 + S_MAIN_UNINSTANLL_SERVICE, //卸载服务 //接收指令 C_MAIN_LOGIN = 2000, //上线信息 - C_MAIN_ACTIVE_APP, //打开窗口 - C_MAIN_USERDESKTOP_CREATE, //创建屏幕查看控件 - C_MAIN_SCREENWALL_IMG, //屏幕墙数据 - C_MAIN_SCREEN_RECORD_IMG, //屏幕记录数据 - C_MAIN_SCREEN_RECORD_OPEN, //打开桌面录制任务 - //C_MAIN_GET_PLUGIN_FILES, //下载插件 - //C_MAIN_TEMP_LOGIN, //临时上线信息(插件未加载状态) + C_MAIN_ACTIVE_APP, //打开窗口 + C_MAIN_DESKTOPVIEW_CREATE, //创建屏幕查看控件 + C_MAIN_DESKTOPVIEW_FRAME, //屏幕墙数据 + C_MAIN_DESKTOPRECORD_FRAME, //屏幕记录数据 + C_MAIN_DESKTOPRECORD_OPEN, //打开桌面录制任务 + C_MAIN_GET_PLUGIN_FILES, //下载插件 + C_MAIN_TEMP_LOGIN, //临时上线信息(插件未加载状态) //远程桌面------------------------------------------------------------------------ - S_SCREEN_NEXT_SCREENBITMP = 1000, //请求获取图像数据 + S_SCREEN_NEXT_SCREENBITMP = 1000, //请求获取图像数据 S_SCREEN_MOUSEKEYEVENT, //鼠键操作 S_SCREEN_MOUSEBLOCK, //鼠标锁定 S_SCREEN_BLACKSCREEN, //黑屏 - S_SCREEN_SET_CLIPBOARD_TEXT, //设置剪贴板内容 + S_SCREEN_SET_CLIPBOARD_TEXT, //设置剪贴板内容 S_SCREEN_RESET, //改变屏幕位色 S_SCREEN_CHANGESCANMODE, //改变扫描方式 S_SCREEN_SETQTY, //设置图像质量 - S_SCREEN_GET_CLIPOARD_TEXT, //获取剪切板Text - S_SCREEN_GET_INIT_BITINFO, //获取初始化屏幕信息 - S_SCREEN_CTRL_ALT_DEL, //模拟Ctrl+Alt+Del - S_SCREEN_CHANGE_MONITOR, //切换监视器 - S_SCREEN_DELETE_WALLPAPER, //移除壁纸 + S_SCREEN_GET_CLIPOARD_TEXT, //获取剪切板Text + S_SCREEN_GET_INIT_BITINFO, //获取初始化屏幕信息 + S_SCREEN_CTRL_ALT_DEL, //模拟Ctrl+Alt+Del + S_SCREEN_CHANGE_MONITOR, //切换监视器 + S_SCREEN_DELETE_WALLPAPER, //移除壁纸 C_SCREEN_BITINFO = 2000, //桌面大小信息 C_SCREEN_SCANCOMPLETE, //屏幕扫描完成 C_SCREEN_BITMP, //图像数据 C_SCREEN_DIFFBITMAP, //差异完整屏幕数据 - C_SCREEN_CLIPOARD_TEXT, //剪切板Text + C_SCREEN_CLIPOARD_TEXT, //剪切板Text //文件管理---------------------------------------------------------------- - S_FILE_GET_DRIVES = 1000, //发送驱动器列表 - S_FILE_GET_FILES, //打开目录 - S_FILE_EXECUTE, //打开文件 - S_FILE_DELETE, //删除 - S_FILE_CREATE_DIR, //创建文件夹 - S_FILE_RENAME, //文件重命名 - S_FILE_RENAME_FINISH, //重命名完成 - S_FILE_FILE_COPY, //复制文件 - S_FILE_FILE_PASTER, //粘贴文件 - S_FILE_DOWNLOAD, //下载文件 - S_FILE_OPEN_TEXT, //打开Text - S_FILE_UPLOAD, //上传文件 - S_FILE_NEXT_DATA, //下块数据 - //S_FILE_TRANSFER_FINISH, //上传完成 - S_FILE_FRIST_DATA, //首个数据包 - S_FILE_DATA, //文件数据 - S_FILE_STOP, //停止任务 - S_FILE_GETDIR_FILES, //获取文件夹中的文件 - //S_FILE_DIRECTORY_UPLOADINFO, //上传的文件夹信息 - //S_FILE_DIRECTORY_DOWNLOAD, //下载文件夹 - //S_FILE_CHANGEPOSITION, //改变断点 - S_FILE_TREE_DIR, //为树形控件获取指定目录所有文件夹 - S_FILE_REDIRION, //跳转路径 - - C_FILE_FILE_LIST = 2000, //文件列表 - C_FILE_CREATEF_DIR_FNISH, //文件夹创建完成 - //C_FILE_NEXTTASK, //下1个任务 - //C_FILE_FILE_INFO, //文件信息 - //C_FILE_FILE_UPLOAD, //上传文件 - C_FILE_OPEN_STATUS, //文件打开状态 - C_FILE_FRIST_DATA, //首个数据包 - C_FILE_NEXT_DATA, //下块数据 - C_FILE_DATA, //文件数据 - //C_FILE_TRANSFER_FINISH, //下载完成 - C_FILE_DELETE_FINISH, //删除完成 - C_FILE_PASTER_FINISH, //粘贴完成 - C_FILE_RENAME_FINISH, //重命名完成 - //C_FILE_DIRECTORY_UPLOAD, //上传文件夹 - //C_FILE_DIRECTORY_DOWNLOADINFO, //下载的文件夹信息 - //C_FILE_CHANGEPOSITION, //改变断点 - C_FILE_ERROR_INFO, //错误信息 - C_FILE_TEXT, //Text数据 - C_FILE_DIR_FILES, //文件夹内的文件 - C_FILE_COPY_FINISH, //复制文件完成 - C_FILE_TREE_DIRS, //树形控件文件夹信息 + S_FILE_GET_DRIVES = 1000, //发送驱动器列表 + S_FILE_GET_FILES, //打开目录 + S_FILE_EXECUTE, //打开文件 + S_FILE_DELETE, //删除 + S_FILE_CREATE_DIR, //创建文件夹 + S_FILE_RENAME, //文件重命名 + S_FILE_RENAME_FINISH, //重命名完成 + S_FILE_FILE_COPY, //复制文件 + S_FILE_FILE_PASTER, //粘贴文件 + S_FILE_DOWNLOAD, //下载文件 + S_FILE_OPEN_TEXT, //打开Text + S_FILE_UPLOAD, //上传文件 + S_FILE_NEXT_DATA, //下块数据 + S_FILE_FRIST_DATA, //首个数据包 + S_FILE_DATA, //文件数据 + S_FILE_STOP, //停止任务 + S_FILE_GETDIR_FILES, //获取文件夹中的文件 + S_FILE_TREE_DIR, //为树形控件获取指定目录所有文件夹 + S_FILE_REDIRION, //跳转路径 + + C_FILE_FILE_LIST = 2000, //文件列表 + C_FILE_CREATEF_DIR_FNISH, //文件夹创建完成 + C_FILE_OPEN_STATUS, //文件打开状态 + C_FILE_FRIST_DATA, //首个数据包 + C_FILE_NEXT_DATA, //下块数据 + C_FILE_DATA, //文件数据 + C_FILE_DELETE_FINISH, //删除完成 + C_FILE_PASTER_FINISH, //粘贴完成 + C_FILE_RENAME_FINISH, //重命名完成 + C_FILE_ERROR_INFO, //错误信息 + C_FILE_TEXT, //Text数据 + C_FILE_DIR_FILES, //文件夹内的文件 + C_FILE_COPY_FINISH, //复制文件完成 + C_FILE_TREE_DIRS, //树形控件文件夹信息 //SHELL------------------------------------------------------------------- - S_SHELL_INPUT = 1000, //执行CMD命令 + S_SHELL_INPUT = 1000, //执行CMD命令 - C_SHELL_RESULT = 2000, //SHELL结果 + C_SHELL_RESULT = 2000, //SHELL结果 //系统管理---------------------------------------------------------------- - S_SYSTEM_GET_PROCESS_LIST = 1000, //进程列表 - S_SYSTEM_GET_SYSTEMINFO, //系统信息 - S_SYSTEM_KILL, //结束进程 - S_SYSTEM_MAXIMIZE, //最大化窗口 - S_SYSTEM_MINIMIZE, //最小化窗体 - S_SYSTEM_GET_OCCUPY, //获取系统占用率信息 - S_SYSTEM_ENUMSESSIONS, //获取所有会话信息 - S_SYSTEM_CREATE_USER_PROCESS, //创建用户进程 + S_SYSTEM_GET_PROCESS_LIST = 1000, //进程列表 + S_SYSTEM_GET_SYSTEMINFO, //系统信息 + S_SYSTEM_KILL, //结束进程 + S_SYSTEM_MAXIMIZE, //最大化窗口 + S_SYSTEM_MINIMIZE, //最小化窗体 + S_SYSTEM_GET_OCCUPY, //获取系统占用率信息 + S_SYSTEM_ENUMSESSIONS, //获取所有会话信息 + S_SYSTEM_CREATE_USER_PROCESS, //创建用户进程 //接收指令 - C_SYSTEM_PROCESS_LIST = 2000, //进程列表 - C_SYSTEM_SYSTEMINFO, //系统信息 - C_SYSTEM_OCCUPY_INFO, //系统占用率信息 - C_SYSTEM_SESSIONS, //会话信息 + C_SYSTEM_PROCESS_LIST = 2000, //进程列表 + C_SYSTEM_SYSTEMINFO, //系统信息 + C_SYSTEM_OCCUPY_INFO, //系统占用率信息 + C_SYSTEM_SESSIONS, //会话信息 //键盘记录--------------------------------------------------------------- - S_KEYBOARD_ONOPEN = 1000, //窗口打开 - S_KEYBOARD_OFFLINE, //开始离线记录 - S_KEYBOARD_GET_OFFLINEFILE, //获取离线文件并停止离线记录 + S_KEYBOARD_ONOPEN = 1000, //窗口打开 + S_KEYBOARD_OFFLINE, //开始离线记录 + S_KEYBOARD_GET_OFFLINEFILE, //获取离线文件并停止离线记录 - C_KEYBOARD_DATA = 2000, //键盘记录数据 - C_KEYBOARD_OFFLINEFILE, //离线文件 + C_KEYBOARD_DATA = 2000, //键盘记录数据 + C_KEYBOARD_OFFLINEFILE, //离线文件 //语音监听--------------------------------------------------------------- - S_AUDIO_START, //开始语音 - S_AUDIO_DATA = 1000, //语音数据 - S_AUDIO_DEIVCE_ONOFF, //开关 + S_AUDIO_START, //开始语音 + S_AUDIO_DATA = 1000, //语音数据 + S_AUDIO_DEIVCE_ONOFF, //开关 - C_AUDIO_DATA = 2000, //语音数据 - C_AUDIO_DEVICE_OPENSTATE, //打开失败的设备 + C_AUDIO_DATA = 2000, //语音数据 + C_AUDIO_DEVICE_OPENSTATE, //打开失败的设备 //视频监控---------------------------------------------------------------- - S_VIEDO_GET_DATA = 1000, //获取图像 - S_VIEDO_RESET, //改变画质 + S_VIEDO_GET_DATA = 1000, //获取图像 + S_VIEDO_RESET, //改变画质 - C_VIEDO_DATA = 2000, //图像 - C_VIEDO_DEVICE_NOTEXIST, //未检测到视频设备 + C_VIEDO_DATA = 2000, //图像 + C_VIEDO_DEVICE_NOTEXIST, //未检测到视频设备 //注册表管理---------------------------------------------------------------- - S_REG_OPENDIRECTLY = 1000, //打开根目录 - S_REG_OPENSUBKEY, //打开子项 - S_REG_GETVALUES, //获取键值数据 - S_REG_CREATEVALUE, //创建键值 - S_REG_CREATESUBKEY, //创建项 - S_REG_DELETEVALUE, //删除键值 - S_REG_DELETESUBKEY, //删除子项 - S_REG_CHANGEVALUE, //修改键值数据 - - C_REG_ROOT_DIRSUBKEYNAMES = 2000, //根目录数据 - C_REG_SUBKEYNAMES, //子项数据 - C_REG_VALUENAMES, //键值数据 - C_REG_DELETESUBKEY_FINSH, //删除子项完成 - C_REG_CREATESUBKEY_FINSH, //创建子项完成 - C_REG_DELETEVALUE_FINSH, //删除键值完成 - - S_NREG_LOAD_REGKEYS = 1000, //加载键 - S_NREG_CREATE_KEY, //创建KEY - S_NREG_CREATE_VALUE, //创建值 - S_NREG_RENAME_KEY, //重命名键 - S_NREG_RENAME_VALUE, //重命名值 - S_NREG_DELETE_KEY, //删除键 - S_NREG_DELETE_VALUE, //删除值 - S_NREG_CHANGE_VALUE, //更改值 + S_REG_OPENDIRECTLY = 1000, //打开根目录 + S_REG_OPENSUBKEY, //打开子项 + S_REG_GETVALUES, //获取键值数据 + S_REG_CREATEVALUE, //创建键值 + S_REG_CREATESUBKEY, //创建项 + S_REG_DELETEVALUE, //删除键值 + S_REG_DELETESUBKEY, //删除子项 + S_REG_CHANGEVALUE, //修改键值数据 + + C_REG_ROOT_DIRSUBKEYNAMES = 2000, //根目录数据 + C_REG_SUBKEYNAMES, //子项数据 + C_REG_VALUENAMES, //键值数据 + C_REG_DELETESUBKEY_FINSH, //删除子项完成 + C_REG_CREATESUBKEY_FINSH, //创建子项完成 + C_REG_DELETEVALUE_FINSH, //删除键值完成 + + S_NREG_LOAD_REGKEYS = 1000, //加载键 + S_NREG_CREATE_KEY, //创建KEY + S_NREG_CREATE_VALUE, //创建值 + S_NREG_RENAME_KEY, //重命名键 + S_NREG_RENAME_VALUE, //重命名值 + S_NREG_DELETE_KEY, //删除键 + S_NREG_DELETE_VALUE, //删除值 + S_NREG_CHANGE_VALUE, //更改值 - C_NREG_LOAD_REGKEYS = 2000, //加载 - C_NREG_CREATE_KEY_RESPONSE, //创建KEY响应 - C_NREG_CREATE_VALUE_RESPONSE,//创建Value响应 - C_NREG_RENAME_KEY_RESPONSE, //重命名响应 - C_NREG_RENAME_VALUE_RESPONSE,//重命名值 - C_NREG_DELETE_KEY_RESPONSE, //删除键响应 - C_NREG_DELETE_VALUE_RESPONSE,//删除值响应 - C_NREG_CHANGE_VALUE_RESPONSE,//更改值响应 - - S_TCP_GET_LIST = 1000, //获取TCP连接列表 + C_NREG_LOAD_REGKEYS = 2000, //加载 + C_NREG_CREATE_KEY_RESPONSE, //创建KEY响应 + C_NREG_CREATE_VALUE_RESPONSE, //创建Value响应 + C_NREG_RENAME_KEY_RESPONSE, //重命名响应 + C_NREG_RENAME_VALUE_RESPONSE, //重命名值 + C_NREG_DELETE_KEY_RESPONSE, //删除键响应 + C_NREG_DELETE_VALUE_RESPONSE, //删除值响应 + C_NREG_CHANGE_VALUE_RESPONSE, //更改值响应 + + S_TCP_GET_LIST = 1000, //获取TCP连接列表 S_TCP_CLOSE_CHANNEL, - C_TCP_LIST = 2000, //关闭TCP连接 - C_TCP_CLOSE_ERROR_LIST, //关闭错误项 + C_TCP_LIST = 2000, //关闭TCP连接 + C_TCP_CLOSE_ERROR_LIST, //关闭错误项 - S_STARTUP_GET_LIST = 1000, //获取所有启动项 - S_STARTUP_ADD_ITEM, //添加启动项 - S_STARTUP_REMOVE_ITEM, //移除启动项目 + S_STARTUP_GET_LIST = 1000, //获取所有启动项 + S_STARTUP_ADD_ITEM, //添加启动项 + S_STARTUP_REMOVE_ITEM, //移除启动项目 - C_STARTUP_LIST = 2000, //启动项列表 - C_STARTUP_OPER_RESPONSE //操作结果 + C_STARTUP_LIST = 2000, //启动项列表 + C_STARTUP_OPER_RESPONSE, //操作结果 + + C_REMOTE_UPDATE_READY = 2000, //远程就绪 + C_REMOTE_UPDATE_NEXT_DATA, //获取下一个文件数据 + + S_REMOTE_UPDATE_DATA, //文件数据 } } \ No newline at end of file diff --git a/SiMay.Core/MessageHelper.cs b/SiMay.Core/MessageHelper.cs index 6bda8e2fa7c53082c3d75adf886029b73736d9bf..a665c82afce43fea6747004a1f09ec42bfd2643d 100644 --- a/SiMay.Core/MessageHelper.cs +++ b/SiMay.Core/MessageHelper.cs @@ -1,13 +1,13 @@ -using SiMay.Basic; +using System; +using System.IO; using SiMay.Core.Extensions; -using System; -using System.Collections; -using System.Collections.Generic; -using static SiMay.Serialize.PacketSerializeHelper; +using static SiMay.Serialize.Standard.PacketSerializeHelper; namespace SiMay.Core { - + /// + /// 消息处理帮助(格式:Int16的消息头 + payload) + /// public static class MessageHelper { /// @@ -86,9 +86,9 @@ namespace SiMay.Core /// public static byte[] GetMessagePayload(this byte[] data) { - byte[] bytes = new byte[data.Length - sizeof(short)]; - Array.Copy(data, sizeof(short), bytes, 0, bytes.Length); - return bytes; + byte[] payload = new byte[data.Length - sizeof(short)]; + Array.Copy(data, sizeof(short), payload, 0, payload.Length); + return payload; } /// @@ -100,8 +100,16 @@ namespace SiMay.Core public static T GetMessageEntity(this byte[] data) where T : new() { - var entity = DeserializePacket(GetMessagePayload(data)); - return entity; + try + { + var entity = DeserializePacket(GetMessagePayload(data)); + return entity; + } + catch + { + File.WriteAllBytes(Path.Combine(Environment.CurrentDirectory, $"{typeof(T).FullName}_{DateTime.Now.ToFileTime()}"), data); + } + return default; } } } \ No newline at end of file diff --git a/SiMay.Core/Packets/AckPack.cs b/SiMay.Core/Packets/AckPack.cs index a04fd046b302b0206b0d686d2ea13c739ca041a2..86cee86e5c18a9f7c1c6efa29c8d42dbbc3fa127 100644 --- a/SiMay.Core/Packets/AckPack.cs +++ b/SiMay.Core/Packets/AckPack.cs @@ -1,4 +1,4 @@ -using SiMay.Core.Enums; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,9 +6,34 @@ using System.Text; namespace SiMay.Core.Packets { - public class AckPack : BasePacket + public class AckPack : EntitySerializerBase { + public byte Type { get; set; } + public long AccessId { get; set; } public long AccessKey { get; set; } - public ConnectionWorkType Type { get; set; } + public string IPV4 { get; set; } + public string MachineName { get; set; } + public string Remark { get; set; } + public string GroupName { get; set; } + public int ProcessorCount { get; set; } + public string ProcessorInfo { get; set; } + public long MemorySize { get; set; } + public string StartRunTime { get; set; } + public string ServiceVison { get; set; } + public string UserName { get; set; } + public string OSVersion { get; set; } + public bool OpenScreenWall { get; set; } + public bool ExistCameraDevice { get; set; } + public bool ExitsRecordDevice { get; set; } + public bool ExitsPlayerDevice { get; set; } + public string IdentifyId { get; set; } + public bool OpenScreenRecord { get; set; } + public int RecordHeight { get; set; } + public int RecordWidth { get; set; } + public int RecordSpanTime { get; set; } + + public bool HasLoadServiceCOM { get; set; } + + public string MacAddress { get; set; } } } diff --git a/SiMay.Core/Packets/OpenDialogPack.cs b/SiMay.Core/Packets/ActivedApplicationPack.cs similarity index 52% rename from SiMay.Core/Packets/OpenDialogPack.cs rename to SiMay.Core/Packets/ActivedApplicationPack.cs index f87e154fe83b313212b60e4a677185d84bd49602..d751d63d10c62126111406bebc79101afde91eaa 100644 --- a/SiMay.Core/Packets/OpenDialogPack.cs +++ b/SiMay.Core/Packets/ActivedApplicationPack.cs @@ -1,11 +1,16 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class ActiveAppPack : BasePacket + public class ActivateServicePack : EntitySerializerBase + { + public string ApplicationKey { get; set; } + } + public class ActivateApplicationPack : EntitySerializerBase { public string IdentifyId { get; set; } public string ServiceKey { get; set; } diff --git a/SiMay.Core/Packets/Audio/AudioDeviceStatesPack.cs b/SiMay.Core/Packets/Audio/AudioDeviceStatesPack.cs index 0273f2e883d363d56fa867ee1ae6ddc22f649630..5c4a84b2edc04a9414ef4d217ada1088f858911c 100644 --- a/SiMay.Core/Packets/Audio/AudioDeviceStatesPack.cs +++ b/SiMay.Core/Packets/Audio/AudioDeviceStatesPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class AudioDeviceStatesPack : BasePacket + public class AudioDeviceStatesPack : EntitySerializerBase { public bool PlayerEnable { get; set; } public bool RecordEnable { get; set; } diff --git a/SiMay.Core/Packets/Audio/AudioOptionsPack.cs b/SiMay.Core/Packets/Audio/AudioOptionsPack.cs index e956fb8bdf7e0e193ed73a4e13e2947155cc6d31..0746e16c00578e86e83e75be47bba8d4f6a9c604 100644 --- a/SiMay.Core/Packets/Audio/AudioOptionsPack.cs +++ b/SiMay.Core/Packets/Audio/AudioOptionsPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class AudioOptionsPack : BasePacket + public class AudioOptionsPack : EntitySerializerBase { public int SamplesPerSecond { get; set; } public int BitsPerSample { get; set; } diff --git a/SiMay.Core/Packets/DesktopRecordGetFramePack.cs b/SiMay.Core/Packets/DesktopRecordGetFramePack.cs index 644a6c191e5c1fc5993663af73d94ed695f13dd3..c47bf7f5adebe4447722cf19133e6e0e6df1df59 100644 --- a/SiMay.Core/Packets/DesktopRecordGetFramePack.cs +++ b/SiMay.Core/Packets/DesktopRecordGetFramePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class DesktopRecordGetFramePack : BasePacket + public class DesktopRecordGetFramePack : EntitySerializerBase { public int Height { get; set; } public int Width { get; set; } diff --git a/SiMay.Core/Packets/DesktopViewDescribePack.cs b/SiMay.Core/Packets/DesktopViewDescribePack.cs index 623c9e7f900fb94373d7dbf55a49963eb6105c54..aaf588be60490629ca3bfc88ef7785d1ed0d8bf2 100644 --- a/SiMay.Core/Packets/DesktopViewDescribePack.cs +++ b/SiMay.Core/Packets/DesktopViewDescribePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class DesktopViewDescribePack : BasePacket + public class DesktopViewDescribePack : EntitySerializerBase { public string MachineName { get; set; } public string RemarkInformation { get; set; } diff --git a/SiMay.Core/Packets/DesktopViewGetFramePack.cs b/SiMay.Core/Packets/DesktopViewGetFramePack.cs index f42c4b8369010eabd3b1c6dfd3b56c80e865ee2b..e2ba178c017bbef76a6c033353c2a805318aa152 100644 --- a/SiMay.Core/Packets/DesktopViewGetFramePack.cs +++ b/SiMay.Core/Packets/DesktopViewGetFramePack.cs @@ -1,14 +1,22 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class DesktopViewGetFramePack : BasePacket + public class DesktopViewGetFramePack : EntitySerializerBase { public int Height { get; set; } public int Width { get; set; } public int TimeSpan { get; set; } + public bool InVisbleArea { get; set; } + } + + public class DesktopViewFramePack : EntitySerializerBase + { + public bool InVisbleArea { get; set; } + public byte[] ViewData { get; set; } } } diff --git a/SiMay.Core/Packets/FileManager/FileCopyPack.cs b/SiMay.Core/Packets/FileManager/FileCopyPack.cs index f0dd85c1f741cd26c0d17dfb71967ab4d2001b78..28985f95cdcae7ff54380893bf79c0a7c92e8512 100644 --- a/SiMay.Core/Packets/FileManager/FileCopyPack.cs +++ b/SiMay.Core/Packets/FileManager/FileCopyPack.cs @@ -1,4 +1,5 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +9,7 @@ namespace SiMay.Core.Packets.FileManager /// /// 复制文件 /// - public class FileCopyPack : BasePacket + public class FileCopyPack : EntitySerializerBase { public string[] FileNames { get; set; } public string TargetDirectoryPath { get; set; } @@ -16,7 +17,7 @@ namespace SiMay.Core.Packets.FileManager /// /// 复制结束 /// - public class FileCopyFinishPack : BasePacket + public class FileCopyFinishPack : EntitySerializerBase { /// /// 复制异常的文件 diff --git a/SiMay.Core/Packets/FileManager/FileCreateDirectoryPack.cs b/SiMay.Core/Packets/FileManager/FileCreateDirectoryPack.cs index b578ff66c4a31e07aeaf4ae9a85fc885f972b154..cb72e4fb5d4ded1883ab3c9a8608295906588ddf 100644 --- a/SiMay.Core/Packets/FileManager/FileCreateDirectoryPack.cs +++ b/SiMay.Core/Packets/FileManager/FileCreateDirectoryPack.cs @@ -1,17 +1,18 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.FileManager { - public class FileCreateDirectoryPack : BasePacket + public class FileCreateDirectoryPack : EntitySerializerBase { public string DirectoryName { get; set; } public bool NoCallBack { get; set; } } - public class FileCreateDirectoryFinishPack : BasePacket + public class FileCreateDirectoryFinishPack : EntitySerializerBase { public bool IsSuccess { get; set; } } diff --git a/SiMay.Core/Packets/FileManager/FileDeletePack.cs b/SiMay.Core/Packets/FileManager/FileDeletePack.cs index ec1ee0f2231c854918303a6c3d114c5abc9b4cd6..379f6e877eeea9aa196d63b01957220aef09bec8 100644 --- a/SiMay.Core/Packets/FileManager/FileDeletePack.cs +++ b/SiMay.Core/Packets/FileManager/FileDeletePack.cs @@ -1,4 +1,5 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,11 +9,11 @@ namespace SiMay.Core.Packets.FileManager /// /// 删除文件 /// - public class FileDeletePack : BasePacket + public class FileDeletePack : EntitySerializerBase { public string[] FileNames { get; set; } } - public class FileDeleteFinishPack : BasePacket + public class FileDeleteFinishPack : EntitySerializerBase { /// /// 删除成功的文件 diff --git a/SiMay.Core/Packets/FileManager/FileDirectoryGetFilesPack.cs b/SiMay.Core/Packets/FileManager/FileDirectoryGetFilesPack.cs index 8ef8b214bba7ce71acfe3ee17048872c497bd530..2d3360a1a53675617eb14ca4ea6cb165f47bce15 100644 --- a/SiMay.Core/Packets/FileManager/FileDirectoryGetFilesPack.cs +++ b/SiMay.Core/Packets/FileManager/FileDirectoryGetFilesPack.cs @@ -1,4 +1,5 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,12 +9,12 @@ namespace SiMay.Core.Packets.FileManager /// /// 获取文件夹文件 /// - public class FileDirectoryGetFilesPack : BasePacket + public class FileDirectoryGetFilesPack : EntitySerializerBase { public string DirectoryPath { get; set; } } - public class FileDirectoryFilesPack : BasePacket + public class FileDirectoryFilesPack : EntitySerializerBase { /// /// 文件信息 @@ -21,7 +22,7 @@ namespace SiMay.Core.Packets.FileManager public DirectoryFileItem[] Files { get; set; } } - public class DirectoryFileItem + public class DirectoryFileItem : EntitySerializerBase { public DirectoryFileType Type { get; set; } public string FileName { get; set; } diff --git a/SiMay.Core/Packets/FileManager/FileDownloadPack.cs b/SiMay.Core/Packets/FileManager/FileDownloadPack.cs index c0cea163a97f17d73782d41eb4bf0aef7023d371..e6e3a67f0db7f19f442fbcc30de3092eea007fb4 100644 --- a/SiMay.Core/Packets/FileManager/FileDownloadPack.cs +++ b/SiMay.Core/Packets/FileManager/FileDownloadPack.cs @@ -1,4 +1,5 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -8,7 +9,7 @@ namespace SiMay.Core.Packets.FileManager /// /// 文件下载 /// - public class FileDownloadPack : BasePacket + public class FileDownloadPack : EntitySerializerBase { public string FileName { get; set; } /// @@ -20,7 +21,7 @@ namespace SiMay.Core.Packets.FileManager /// /// 首数据包(减少交互快速传输文件) /// - public class FileFristDownloadDataPack : BasePacket + public class FileFristDownloadDataPack : EntitySerializerBase { //public string fileName { get; set; } /// @@ -37,7 +38,7 @@ namespace SiMay.Core.Packets.FileManager public byte[] Data { get; set; } } - public class FileDownloadDataPack : BasePacket + public class FileDownloadDataPack : EntitySerializerBase { public byte[] Data { get; set; } } diff --git a/SiMay.Core/Packets/FileManager/FileExceptionPack.cs b/SiMay.Core/Packets/FileManager/FileExceptionPack.cs index 3b8c9da9121677495ccebd8754690eab31c9ff83..8d4b572d02d553c89d7e839f5b15551990bbf837 100644 --- a/SiMay.Core/Packets/FileManager/FileExceptionPack.cs +++ b/SiMay.Core/Packets/FileManager/FileExceptionPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.FileManager { - public class FileExceptionPack : BasePacket + public class FileExceptionPack : EntitySerializerBase { public DateTime OccurredTime { get; set; } public string TipMessage { get; set; } diff --git a/SiMay.Core/Packets/FileManager/FileExcutePack.cs b/SiMay.Core/Packets/FileManager/FileExcutePack.cs index c1198fae5888ca627b6aabc59f42d3d73349064d..4d09b34d023a202af99f9bee669494b1998fcbee 100644 --- a/SiMay.Core/Packets/FileManager/FileExcutePack.cs +++ b/SiMay.Core/Packets/FileManager/FileExcutePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.FileManager { - public class FileExcutePack : BasePacket + public class FileExcutePack : EntitySerializerBase { public string FilePath { get; set; } } diff --git a/SiMay.Core/Packets/FileManager/FileGetTreeDirectoryPack.cs b/SiMay.Core/Packets/FileManager/FileGetTreeDirectoryPack.cs index 2f5b2acfaddb0b47699092b897febfaca3288539..1793b931e689948abef50d81584e786f3de02e78 100644 --- a/SiMay.Core/Packets/FileManager/FileGetTreeDirectoryPack.cs +++ b/SiMay.Core/Packets/FileManager/FileGetTreeDirectoryPack.cs @@ -1,16 +1,17 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.FileManager { - public class FileGetTreeDirectoryPack + public class FileGetTreeDirectoryPack : EntitySerializerBase { public string TargetRoot { get; set; } } - public class FileTreeDirFilePack + public class FileTreeDirFilePack : EntitySerializerBase { public FileItem[] FileList { get; set; } public string Message { get; set; } diff --git a/SiMay.Core/Packets/FileManager/FileListItemsPack.cs b/SiMay.Core/Packets/FileManager/FileListItemsPack.cs index 078dbabb0cef24dd650913a525f18c27f88852f9..a14e1b94b91f2ef61e2b4bebedf8ee3fa3f30ea4 100644 --- a/SiMay.Core/Packets/FileManager/FileListItemsPack.cs +++ b/SiMay.Core/Packets/FileManager/FileListItemsPack.cs @@ -1,4 +1,5 @@ using SiMay.Core.Enums; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,19 +7,19 @@ using System.Text; namespace SiMay.Core.Packets { - public class FileListPack : BasePacket + public class FileListPack : EntitySerializerBase { public string FilePath { get; set; } } - public class FileListItemsPack : BasePacket + public class FileListItemsPack : EntitySerializerBase { public FileItem[] FileList { get; set; } public string Path { get; set; } public string Message { get; set; } public bool IsSccessed { get; set; } } - public class FileItem + public class FileItem : EntitySerializerBase { public string FileName { get; set; } diff --git a/SiMay.Core/Packets/FileManager/FileReNamePack.cs b/SiMay.Core/Packets/FileManager/FileReNamePack.cs index bfdc66755aae285945e38ea5d5951bc138d932c4..3c9fffef1e847e4a6a9f4e6b3ab6a0eac69b910a 100644 --- a/SiMay.Core/Packets/FileManager/FileReNamePack.cs +++ b/SiMay.Core/Packets/FileManager/FileReNamePack.cs @@ -1,17 +1,18 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.FileManager { - public class FileReNamePack : BasePacket + public class FileReNamePack : EntitySerializerBase { public string SourceFileName { get; set; } public string TargetName { get; set; } } - public class FileReNameFinishPack : BasePacket + public class FileReNameFinishPack : EntitySerializerBase { public bool IsSuccess { get; set; } public string SourceFileName { get; set; } diff --git a/SiMay.Core/Packets/FileManager/FileRedirectionPath.cs b/SiMay.Core/Packets/FileManager/FileRedirectionPath.cs index 488243ecd67ccf68f7477e627407dd933f0de236..9ebf1e06962b83ff4840f4d7a712d933ef8c0d40 100644 --- a/SiMay.Core/Packets/FileManager/FileRedirectionPath.cs +++ b/SiMay.Core/Packets/FileManager/FileRedirectionPath.cs @@ -1,4 +1,5 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -6,7 +7,7 @@ using static System.Environment; namespace SiMay.Core.Packets.FileManager { - public class FileRedirectionPath : BasePacket + public class FileRedirectionPath : EntitySerializerBase { public SpecialFolder SpecialFolder { get; set; } } diff --git a/SiMay.Core/Packets/FileManager/FileTextPack.cs b/SiMay.Core/Packets/FileManager/FileTextPack.cs index 8b448840df1d4da082991521587aca187ab27b99..6a4f6dff96db3afd73ba797bd7c2962cacd2f3b6 100644 --- a/SiMay.Core/Packets/FileManager/FileTextPack.cs +++ b/SiMay.Core/Packets/FileManager/FileTextPack.cs @@ -1,15 +1,16 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.FileManager { - public class FileOpenTextPack : BasePacket + public class FileOpenTextPack : EntitySerializerBase { public string FileName { get; set; } } - public class FileTextPack : BasePacket + public class FileTextPack : EntitySerializerBase { /// /// 是否可以访问 diff --git a/SiMay.Core/Packets/FileManager/FileUploadPack.cs b/SiMay.Core/Packets/FileManager/FileUploadPack.cs index 0e5e242a7e20fb38c3bdc84597f9e1478c206d42..cbc3025b5764c7a716befffb55bf85ab9f08dd51 100644 --- a/SiMay.Core/Packets/FileManager/FileUploadPack.cs +++ b/SiMay.Core/Packets/FileManager/FileUploadPack.cs @@ -1,16 +1,17 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.FileManager { - public class FileUploadPack : BasePacket + public class FileUploadPack : EntitySerializerBase { public string FileName { get; set; } } - public class FileUploadFileStatus : BasePacket + public class FileUploadFileStatus : EntitySerializerBase { /// /// 文件打开状态 0:文件不存在,1文件存在,2文件访问失败 @@ -19,7 +20,7 @@ namespace SiMay.Core.Packets.FileManager public long Position { get; set; } } - public class FileFristUploadDataPack : BasePacket + public class FileFristUploadDataPack : EntitySerializerBase { public int FileMode { get; set; } public long Position { get; set; } @@ -27,7 +28,7 @@ namespace SiMay.Core.Packets.FileManager public byte[] Data { get; set; } } - public class FileUploadDataPack : BasePacket + public class FileUploadDataPack : EntitySerializerBase { public long FileSize { get; set; } public byte[] Data { get; set; } diff --git a/SiMay.Core/Packets/LoginPack.cs b/SiMay.Core/Packets/LoginPack.cs index 5fde69b0e2f056b217a3b995d583250a0ca890af..05fc6e3cee4c52b44566fe07d5c30eba3a69cce2 100644 --- a/SiMay.Core/Packets/LoginPack.cs +++ b/SiMay.Core/Packets/LoginPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class LoginPack : BasePacket + public class LoginPack : EntitySerializerBase { public string IPV4 { get; set; } public string MachineName { get; set; } @@ -29,5 +30,7 @@ namespace SiMay.Core.Packets public int RecordSpanTime { get; set; } public bool HasLoadServiceCOM { get; set; } + + public string MacAddress { get; set; } } } diff --git a/SiMay.Core/Packets/MessagePack.cs b/SiMay.Core/Packets/MessagePack.cs index 59ef087a10b55dd8fc2fad361e9be09de28e9d56..efb60b1b7dfe567ab32dcc59d52b712668a8741b 100644 --- a/SiMay.Core/Packets/MessagePack.cs +++ b/SiMay.Core/Packets/MessagePack.cs @@ -1,4 +1,5 @@ using SiMay.Core.Enums; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +7,7 @@ using System.Text; namespace SiMay.Core.Packets { - public class MessagePack : BasePacket + public class MessagePack : EntitySerializerBase { public byte MessageIcon { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegDeleteSubKeyPack.cs b/SiMay.Core/Packets/Reg/RegDeleteSubKeyPack.cs index 5fdc9fdbb5125f891382e1dc7d141d37b6c3530e..091aba6faeafeb4c2ad86fb89bcb81cc62e7de00 100644 --- a/SiMay.Core/Packets/Reg/RegDeleteSubKeyPack.cs +++ b/SiMay.Core/Packets/Reg/RegDeleteSubKeyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegDeleteSubKeyPack : BasePacket + public class RegDeleteSubKeyPack : EntitySerializerBase { public string Root { get; set; } public string NodePath { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegDeleteValuePack.cs b/SiMay.Core/Packets/Reg/RegDeleteValuePack.cs index f9c1a465170bc82dddea6389fcbc0f11ad447075..efae9ea753dcdf6c3888e6ffff3e344244a45c2f 100644 --- a/SiMay.Core/Packets/Reg/RegDeleteValuePack.cs +++ b/SiMay.Core/Packets/Reg/RegDeleteValuePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegDeleteValuePack : BasePacket + public class RegDeleteValuePack : EntitySerializerBase { public string Root { get; set; } public string NodePath { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegNewSubkeyPack.cs b/SiMay.Core/Packets/Reg/RegNewSubkeyPack.cs index 1671fdeff1014f9d76823de86fad52df6470d801..330e5e04f59b8f85fffae4e671e4b7dd30a33e12 100644 --- a/SiMay.Core/Packets/Reg/RegNewSubkeyPack.cs +++ b/SiMay.Core/Packets/Reg/RegNewSubkeyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegNewSubkeyPack : BasePacket + public class RegNewSubkeyPack : EntitySerializerBase { public string Root { get; set; } public string NodePath { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegNewValuePack.cs b/SiMay.Core/Packets/Reg/RegNewValuePack.cs index 5176a75f2f2c4905a8b0749538616b4cc010ad9c..a52ed04bc0f0b2a5a393d193747cd0cfd95cd1a0 100644 --- a/SiMay.Core/Packets/Reg/RegNewValuePack.cs +++ b/SiMay.Core/Packets/Reg/RegNewValuePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegNewValuePack : BasePacket + public class RegNewValuePack : EntitySerializerBase { public string Root { get; set; } public string NodePath { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegOpenSubKeyPack.cs b/SiMay.Core/Packets/Reg/RegOpenSubKeyPack.cs index 5aff9d18f8df9d10e2631d96b8eac64d1536c8d7..335cf8c9b7ce62f0920d3f75d227a22ca1a2fc7c 100644 --- a/SiMay.Core/Packets/Reg/RegOpenSubKeyPack.cs +++ b/SiMay.Core/Packets/Reg/RegOpenSubKeyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegOpenSubKeyPack : BasePacket + public class RegOpenSubKeyPack : EntitySerializerBase { public string Root { get; set; } public string NodePath { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegOperFinshPack.cs b/SiMay.Core/Packets/Reg/RegOperFinshPack.cs index 507247f53853567244fe5419885384550b18e5ff..e71c4908283274da0a8ce1f19fdf58ebc7562232 100644 --- a/SiMay.Core/Packets/Reg/RegOperFinshPack.cs +++ b/SiMay.Core/Packets/Reg/RegOperFinshPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegOperFinshPack : BasePacket + public class RegOperFinshPack : EntitySerializerBase { public bool Result { get; set; } public string Value { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegRootDirectorysPack.cs b/SiMay.Core/Packets/Reg/RegRootDirectorysPack.cs index 6ae85aa2e1be6afe429529f923639f611b9ffb20..ab22f3e682993d7ce610d6787edc6d88117a0fbe 100644 --- a/SiMay.Core/Packets/Reg/RegRootDirectorysPack.cs +++ b/SiMay.Core/Packets/Reg/RegRootDirectorysPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegRootDirectorysPack : BasePacket + public class RegRootDirectorysPack : EntitySerializerBase { public string[] RootDirectorys { get; set; } } diff --git a/SiMay.Core/Packets/Reg/RegSubKeyValuePack.cs b/SiMay.Core/Packets/Reg/RegSubKeyValuePack.cs index e088c52946fa1c10b56c199ec5ff004bd1c865b6..3a19e8eecd33e47ae158a40af73c21fa400895d9 100644 --- a/SiMay.Core/Packets/Reg/RegSubKeyValuePack.cs +++ b/SiMay.Core/Packets/Reg/RegSubKeyValuePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegSubKeyValuePack : BasePacket + public class RegSubKeyValuePack : EntitySerializerBase { public string[] SubKeyNames { get; set; } public RegValueItem[] Values { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegValueItem.cs b/SiMay.Core/Packets/Reg/RegValueItem.cs index a8a5c6b0551c14aa3b5f49e580baf108016a452a..0b23fe8b121cc8ad19dbf8b4cb9aecb43a39d6aa 100644 --- a/SiMay.Core/Packets/Reg/RegValueItem.cs +++ b/SiMay.Core/Packets/Reg/RegValueItem.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegValueItem + public class RegValueItem : EntitySerializerBase { public string ValueName { get; set; } public string Value { get; set; } diff --git a/SiMay.Core/Packets/Reg/RegValuesPack.cs b/SiMay.Core/Packets/Reg/RegValuesPack.cs index 81f2c98a82e158b498d449edb054dc25df852e05..8a8f35df223e0f6f30fd995b908695a8d57d2ee4 100644 --- a/SiMay.Core/Packets/Reg/RegValuesPack.cs +++ b/SiMay.Core/Packets/Reg/RegValuesPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Reg { - public class RegValuesPack : BasePacket + public class RegValuesPack : EntitySerializerBase { public RegValueItem[] Values { get; set; } } diff --git a/SiMay.Core/Packets/RegEdit/DoChangeRegistryValuePack.cs b/SiMay.Core/Packets/RegEdit/DoChangeRegistryValuePack.cs index 4e6a719823b4091a0fcbfd9de8b959c0c588ad09..e8bf5999e467ca160783a3b779a434ad3cd6c57c 100644 --- a/SiMay.Core/Packets/RegEdit/DoChangeRegistryValuePack.cs +++ b/SiMay.Core/Packets/RegEdit/DoChangeRegistryValuePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoChangeRegistryValuePack + public class DoChangeRegistryValuePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/DoCreateRegistryKeyPack.cs b/SiMay.Core/Packets/RegEdit/DoCreateRegistryKeyPack.cs index f4cecf5088697222c1f0219165434a546e217b6f..a072f2b446f333030c7268dffc68886e7e8516d2 100644 --- a/SiMay.Core/Packets/RegEdit/DoCreateRegistryKeyPack.cs +++ b/SiMay.Core/Packets/RegEdit/DoCreateRegistryKeyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoCreateRegistryKeyPack + public class DoCreateRegistryKeyPack : EntitySerializerBase { public string ParentPath { get; set; } } diff --git a/SiMay.Core/Packets/RegEdit/DoCreateRegistryValuePack.cs b/SiMay.Core/Packets/RegEdit/DoCreateRegistryValuePack.cs index d6b0b6f8e0bce1d41034af5432da561591979ee0..028d8c9f5328f94965757b7ee09b5f3fb006d7f0 100644 --- a/SiMay.Core/Packets/RegEdit/DoCreateRegistryValuePack.cs +++ b/SiMay.Core/Packets/RegEdit/DoCreateRegistryValuePack.cs @@ -1,4 +1,5 @@ using Microsoft.Win32; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +7,7 @@ using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoCreateRegistryValuePack + public class DoCreateRegistryValuePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/DoDeleteRegistryKeyPack.cs b/SiMay.Core/Packets/RegEdit/DoDeleteRegistryKeyPack.cs index 12736712dd74001b4103c272a9b5c5cf1d465d88..4ac2e16a5269244c6f52a50154ee69a9a97c07cc 100644 --- a/SiMay.Core/Packets/RegEdit/DoDeleteRegistryKeyPack.cs +++ b/SiMay.Core/Packets/RegEdit/DoDeleteRegistryKeyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoDeleteRegistryKeyPack + public class DoDeleteRegistryKeyPack : EntitySerializerBase { public string ParentPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/DoDeleteRegistryValuePack.cs b/SiMay.Core/Packets/RegEdit/DoDeleteRegistryValuePack.cs index 6148ba29c34c8220b68295080a214e5e808aeced..940f654138355c3fa50a24a363111c1c9e527b63 100644 --- a/SiMay.Core/Packets/RegEdit/DoDeleteRegistryValuePack.cs +++ b/SiMay.Core/Packets/RegEdit/DoDeleteRegistryValuePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoDeleteRegistryValuePack + public class DoDeleteRegistryValuePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/DoLoadRegistryKeyPack.cs b/SiMay.Core/Packets/RegEdit/DoLoadRegistryKeyPack.cs index c979970ccac8e9980c36602401a8ee3b6b6bb8a5..264501f38b8a7090b2d16b643da41445861a8cce 100644 --- a/SiMay.Core/Packets/RegEdit/DoLoadRegistryKeyPack.cs +++ b/SiMay.Core/Packets/RegEdit/DoLoadRegistryKeyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoLoadRegistryKeyPack + public class DoLoadRegistryKeyPack : EntitySerializerBase { public string RootKeyName { get; set; } } diff --git a/SiMay.Core/Packets/RegEdit/DoRenameRegistryKeyPack.cs b/SiMay.Core/Packets/RegEdit/DoRenameRegistryKeyPack.cs index b31a566536ad5a3de03680e9cc2b34be98c675d5..aca263ef0f66e851bd7602cf2a2ad1b607b0c9d1 100644 --- a/SiMay.Core/Packets/RegEdit/DoRenameRegistryKeyPack.cs +++ b/SiMay.Core/Packets/RegEdit/DoRenameRegistryKeyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoRenameRegistryKeyPack + public class DoRenameRegistryKeyPack : EntitySerializerBase { public string ParentPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/DoRenameRegistryValuePack.cs b/SiMay.Core/Packets/RegEdit/DoRenameRegistryValuePack.cs index 49d22f20be543658502bebdee38c4b5eb4c28ef2..b4153cf05d1c9ea45caa69839b6dd486eec955f8 100644 --- a/SiMay.Core/Packets/RegEdit/DoRenameRegistryValuePack.cs +++ b/SiMay.Core/Packets/RegEdit/DoRenameRegistryValuePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class DoRenameRegistryValuePack + public class DoRenameRegistryValuePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetChangeRegistryValueResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetChangeRegistryValueResponsePack.cs index ec3dbd915c75af732b20b45381f3860064eafa76..a9a59ac4ac3f5eac0daa46e73a20f20a8836b717 100644 --- a/SiMay.Core/Packets/RegEdit/GetChangeRegistryValueResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetChangeRegistryValueResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetChangeRegistryValueResponsePack + public class GetChangeRegistryValueResponsePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetCreateRegistryKeyResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetCreateRegistryKeyResponsePack.cs index dbd5e504a74cfa89558fd99fc04873de78c24026..ebdd6a25c60da5baf4abbceecdf3ecb48bbcf914 100644 --- a/SiMay.Core/Packets/RegEdit/GetCreateRegistryKeyResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetCreateRegistryKeyResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetCreateRegistryKeyResponsePack + public class GetCreateRegistryKeyResponsePack : EntitySerializerBase { public string ParentPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetCreateRegistryValueResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetCreateRegistryValueResponsePack.cs index b5d4a3ab783119fac8db12d4733d369059060b18..3a7545652e944beb09cb7bc78987fbe4c64bc742 100644 --- a/SiMay.Core/Packets/RegEdit/GetCreateRegistryValueResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetCreateRegistryValueResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetCreateRegistryValueResponsePack + public class GetCreateRegistryValueResponsePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetDeleteRegistryKeyResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetDeleteRegistryKeyResponsePack.cs index e943e5c758db19578fdc0007d1897f47ec5fa08b..b01da19029bb9c908b250d36276275f5f572e595 100644 --- a/SiMay.Core/Packets/RegEdit/GetDeleteRegistryKeyResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetDeleteRegistryKeyResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetDeleteRegistryKeyResponsePack + public class GetDeleteRegistryKeyResponsePack : EntitySerializerBase { public string ParentPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetDeleteRegistryValueResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetDeleteRegistryValueResponsePack.cs index 8b79578a47c33df29d254cde3eae9cb9c93b2e79..a5a913521cc475f64c40aeb77c0bac35b275a3ca 100644 --- a/SiMay.Core/Packets/RegEdit/GetDeleteRegistryValueResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetDeleteRegistryValueResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetDeleteRegistryValueResponsePack + public class GetDeleteRegistryValueResponsePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetRegistryKeysResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetRegistryKeysResponsePack.cs index eb4a067c3f970850e31f9689778f69fd28da53ad..ab3d81681e2e16327ea85b98e186583501f70073 100644 --- a/SiMay.Core/Packets/RegEdit/GetRegistryKeysResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetRegistryKeysResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetRegistryKeysResponsePack + public class GetRegistryKeysResponsePack : EntitySerializerBase { public RegSeekerMatch[] Matches { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetRenameRegistryKeyResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetRenameRegistryKeyResponsePack.cs index 2fe7ee527c5fc2858d7785971c132196edafc9b7..77b0c84f04da050199c619d91523b38346f9ecf8 100644 --- a/SiMay.Core/Packets/RegEdit/GetRenameRegistryKeyResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetRenameRegistryKeyResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetRenameRegistryKeyResponsePack + public class GetRenameRegistryKeyResponsePack : EntitySerializerBase { public string ParentPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/GetRenameRegistryValueResponsePack.cs b/SiMay.Core/Packets/RegEdit/GetRenameRegistryValueResponsePack.cs index 80e28096f937704d4ab90a9343185393bbd5d56f..6dc1bd679919c1cd34107d94cd9421988b7a0e6b 100644 --- a/SiMay.Core/Packets/RegEdit/GetRenameRegistryValueResponsePack.cs +++ b/SiMay.Core/Packets/RegEdit/GetRenameRegistryValueResponsePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class GetRenameRegistryValueResponsePack + public class GetRenameRegistryValueResponsePack : EntitySerializerBase { public string KeyPath { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/RegSeekerMatch.cs b/SiMay.Core/Packets/RegEdit/RegSeekerMatch.cs index ae001f384fc5f587f83ef9a901ffbdd7fbdd48b5..28ba8bf09145d571659b911f0b1c3e0d2d460262 100644 --- a/SiMay.Core/Packets/RegEdit/RegSeekerMatch.cs +++ b/SiMay.Core/Packets/RegEdit/RegSeekerMatch.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class RegSeekerMatch + public class RegSeekerMatch : EntitySerializerBase { public string Key { get; set; } diff --git a/SiMay.Core/Packets/RegEdit/RegValueData.cs b/SiMay.Core/Packets/RegEdit/RegValueData.cs index 0a7377332efdfee32af7001945de1d70a996ef22..c209c03be528dacbf36f3708d8921e3ebdb92408 100644 --- a/SiMay.Core/Packets/RegEdit/RegValueData.cs +++ b/SiMay.Core/Packets/RegEdit/RegValueData.cs @@ -1,4 +1,5 @@ using Microsoft.Win32; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +7,7 @@ using System.Text; namespace SiMay.Core.Packets.RegEdit { - public class RegValueData + public class RegValueData : EntitySerializerBase { public string Name { get; set; } diff --git a/SiMay.Net.SessionProviderService/TcpChannelContextServiceType.cs b/SiMay.Core/Packets/RemoteUpdate/DataPacket.cs similarity index 41% rename from SiMay.Net.SessionProviderService/TcpChannelContextServiceType.cs rename to SiMay.Core/Packets/RemoteUpdate/DataPacket.cs index c482837b4c46c3d0020ab0ca136b45d42e6b4fd1..f4da2f081c6bcc5fcd5e1deb1f64bd3ed5f26ce8 100644 --- a/SiMay.Net.SessionProviderService/TcpChannelContextServiceType.cs +++ b/SiMay.Core/Packets/RemoteUpdate/DataPacket.cs @@ -4,14 +4,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace SiMay.Net.SessionProviderService +namespace SiMay.Core.Packets.RemoteUpdate { - public enum TcpChannelContextServiceType + public class DataPacket { - MainChannel, - WorkChannel, - ManagerChannel, - ManagerWorkChannel, - None + public int TotalSize { get; set; } + + public byte[] Data { get; set; } } } diff --git a/SiMay.Core/Packets/RemoteUpdatePack.cs b/SiMay.Core/Packets/RemoteUpdatePack.cs index b6215a7654b8b0356c383ad9f2703018f218d919..ced261dab7fe81270fb65e7abdc319cce8169af5 100644 --- a/SiMay.Core/Packets/RemoteUpdatePack.cs +++ b/SiMay.Core/Packets/RemoteUpdatePack.cs @@ -1,4 +1,5 @@ using SiMay.Core.Enums; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +7,7 @@ using System.Text; namespace SiMay.Core.Packets { - public class RemoteUpdatePack + public class RemoteUpdatePack : EntitySerializerBase { /// /// Url更新还是文件更新 @@ -16,5 +17,7 @@ namespace SiMay.Core.Packets public string DownloadUrl { get; set; } public byte[] FileDate { get; set; } + public int FilePackLength { get; set; } + public int CurrentPack { get; set; } } } diff --git a/SiMay.Core/Packets/Screen/MonitorChangePack.cs b/SiMay.Core/Packets/Screen/MonitorChangePack.cs index b0f5339cb3ba527fb0d40add7ef63d94a9d88a3c..79f448ba214edb2e699fbce237f1762b39ee0a41 100644 --- a/SiMay.Core/Packets/Screen/MonitorChangePack.cs +++ b/SiMay.Core/Packets/Screen/MonitorChangePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Screen { - public class MonitorChangePack + public class MonitorChangePack : EntitySerializerBase { public int MonitorIndex { get; set; } } diff --git a/SiMay.Core/Packets/Screen/ScreenBitInfoPack.cs b/SiMay.Core/Packets/Screen/ScreenBitInfoPack.cs index aad526e21a936526ae425ba385d9f85a4099cf34..f684491d2749081f3c497584bfdd74a3bb31d9d2 100644 --- a/SiMay.Core/Packets/Screen/ScreenBitInfoPack.cs +++ b/SiMay.Core/Packets/Screen/ScreenBitInfoPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class ScreenInitBitPack : BasePacket + public class ScreenInitBitPack : EntitySerializerBase { public int Height { get; set; } public int Width { get; set; } @@ -14,7 +15,7 @@ namespace SiMay.Core.Packets public MonitorItem[] Monitors { get; set; } } - public class MonitorItem + public class MonitorItem : EntitySerializerBase { public string DeviceName { get; set; } public bool Primary { get; set; } diff --git a/SiMay.Core/Packets/Screen/ScreenClipoardValuePack.cs b/SiMay.Core/Packets/Screen/ScreenClipoardValuePack.cs index 91435798956db282253abf3e5ea318c2fb9d61da..8956bbd56e7227b7ae7bac383e7dfada8a0cb17d 100644 --- a/SiMay.Core/Packets/Screen/ScreenClipoardValuePack.cs +++ b/SiMay.Core/Packets/Screen/ScreenClipoardValuePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Screen { - public class ScreenClipoardValuePack : BasePacket + public class ScreenClipoardValuePack : EntitySerializerBase { public string Value { get; set; } } diff --git a/SiMay.Core/Packets/Screen/ScreenFragmentPack.cs b/SiMay.Core/Packets/Screen/ScreenFragmentPack.cs index 3bf76137b52bf423c81e391116ea136577ef0b25..be581e8e76c990663fda9aee9b2bbfa65565100e 100644 --- a/SiMay.Core/Packets/Screen/ScreenFragmentPack.cs +++ b/SiMay.Core/Packets/Screen/ScreenFragmentPack.cs @@ -1,4 +1,5 @@ using SiMay.Core.ScreenSpy.Entitys; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +7,7 @@ using System.Text; namespace SiMay.Core.Packets { - public class ScreenFragmentPack : BasePacket + public class ScreenFragmentPack : EntitySerializerBase { public Fragment[] Fragments { get; set; } } diff --git a/SiMay.Core/Packets/Screen/ScreenHotRectanglePack.cs b/SiMay.Core/Packets/Screen/ScreenHotRectanglePack.cs index d0174997d1eb1ea0bc7a18cac349bcc33d6c3f2c..a224059814acfde539aa205449d4f03ea6a09c66 100644 --- a/SiMay.Core/Packets/Screen/ScreenHotRectanglePack.cs +++ b/SiMay.Core/Packets/Screen/ScreenHotRectanglePack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class ScreenHotRectanglePack : BasePacket + public class ScreenHotRectanglePack : EntitySerializerBase { public int X { get; set; } public int Y { get; set; } diff --git a/SiMay.Core/Packets/Screen/ScreenMKeyPack.cs b/SiMay.Core/Packets/Screen/ScreenKeyPack.cs similarity index 78% rename from SiMay.Core/Packets/Screen/ScreenMKeyPack.cs rename to SiMay.Core/Packets/Screen/ScreenKeyPack.cs index e188a12ae38f39093ca321cbbaed92ae563680c8..e96af7686f4781490f57397890d8b9b85fe6bc3e 100644 --- a/SiMay.Core/Packets/Screen/ScreenMKeyPack.cs +++ b/SiMay.Core/Packets/Screen/ScreenKeyPack.cs @@ -1,4 +1,5 @@ using SiMay.Core.Enums; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +7,7 @@ using System.Text; namespace SiMay.Core.Packets { - public class ScreenMKeyPack : BasePacket + public class ScreenKeyPack : EntitySerializerBase { public MOUSEKEY_ENUM Key { get; set; } public int Point1 { get; set; } diff --git a/SiMay.Core/Packets/Screen/ScreenSetClipoardPack.cs b/SiMay.Core/Packets/Screen/ScreenSetClipoardPack.cs index 818116b7dc6159f444b36d794ee51a219c7f31a2..bcf5252c56585593d129b787966679a84b2057a1 100644 --- a/SiMay.Core/Packets/Screen/ScreenSetClipoardPack.cs +++ b/SiMay.Core/Packets/Screen/ScreenSetClipoardPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Screen { - public class ScreenSetClipoardPack : BasePacket + public class ScreenSetClipoardPack : EntitySerializerBase { public string Text { get; set; } } diff --git a/SiMay.Core/Packets/Screen/ScreenSetQtyPack.cs b/SiMay.Core/Packets/Screen/ScreenSetQtyPack.cs index 0752b49f6367d362fe0571b5a3d16b5a2181b3da..42a5f640b578d70129f0a7a84660a809caa7dc2d 100644 --- a/SiMay.Core/Packets/Screen/ScreenSetQtyPack.cs +++ b/SiMay.Core/Packets/Screen/ScreenSetQtyPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.Screen { - public class ScreenSetQtyPack + public class ScreenSetQtyPack : EntitySerializerBase { public long Quality { get; set; } } diff --git a/SiMay.Core/Packets/ServicePluginPack.cs b/SiMay.Core/Packets/ServicePluginPack.cs index 6b4a0eb3e16ede0c7f9ff5b8b293f0c4a56c2282..d7cae562b1f2c1044b5264983bc32f94db73e382 100644 --- a/SiMay.Core/Packets/ServicePluginPack.cs +++ b/SiMay.Core/Packets/ServicePluginPack.cs @@ -1,16 +1,17 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class ServicePluginPack + public class ServicePluginPack : EntitySerializerBase { public PluginItem[] Files { get; set; } } - public class PluginItem + public class PluginItem : EntitySerializerBase { public string FileName { get; set; } public byte[] PayLoad { get; set; } diff --git a/SiMay.Core/Packets/Startup/StartupItemPack.cs b/SiMay.Core/Packets/Startup/StartupItemPack.cs index 49b9f7a7de7d47d795ae29487fd310c4bd8d83aa..846cd8214d403c5761d6c304616ce198a83b6db2 100644 --- a/SiMay.Core/Packets/Startup/StartupItemPack.cs +++ b/SiMay.Core/Packets/Startup/StartupItemPack.cs @@ -1,4 +1,5 @@ using SiMay.Core.Enums; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,11 +7,11 @@ using System.Text; namespace SiMay.Core.Packets.Startup { - public class StartupItemsPack : BasePacket + public class StartupItemsPack : EntitySerializerBase { public StartupItemPack[] StartupItems { get; set; } } - public class StartupItemPack : BasePacket + public class StartupItemPack : EntitySerializerBase { public string Name { get; set; } diff --git a/SiMay.Core/Packets/Startup/StartupOperResponsePack.cs b/SiMay.Core/Packets/Startup/StartupOperResponsePack.cs index 4b29b351461f17b254f32eb7d8ab42bbdb1f984d..147ff972bf1a33a3973e59b4eb6846c296929607 100644 --- a/SiMay.Core/Packets/Startup/StartupOperResponsePack.cs +++ b/SiMay.Core/Packets/Startup/StartupOperResponsePack.cs @@ -1,4 +1,5 @@ using SiMay.Core.Packets.Startup.Enums; +using SiMay.ReflectCache; using System; using System.Collections.Generic; using System.Linq; @@ -6,7 +7,7 @@ using System.Text; namespace SiMay.Core.Packets.Startup { - public class StartupOperResponsePack : BasePacket + public class StartupOperResponsePack : EntitySerializerBase { public OperFlag OperFlag { get; set; } public string Msg { get; set; } diff --git a/SiMay.Core/Packets/SysManager/ProcessInfo.cs b/SiMay.Core/Packets/SysManager/ProcessInfo.cs index 06705a35cb04d41b0c92c0befb652aa14c30de7c..5d93b756fc051aa06b72e4b7cf2c7c4451a91a42 100644 --- a/SiMay.Core/Packets/SysManager/ProcessInfo.cs +++ b/SiMay.Core/Packets/SysManager/ProcessInfo.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class ProcessItem + public class ProcessItem : EntitySerializerBase { public int ProcessId { get; set; } diff --git a/SiMay.Core/Packets/SysManager/SessionManagerPack.cs b/SiMay.Core/Packets/SysManager/SessionManagerPack.cs index 0d5ebc0f859dca5c3b7b2e991a30f02514a33a25..52ffc2693fbb03ade3662a6ad136f3546baff411 100644 --- a/SiMay.Core/Packets/SysManager/SessionManagerPack.cs +++ b/SiMay.Core/Packets/SysManager/SessionManagerPack.cs @@ -1,21 +1,22 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.SysManager { - public class CreateProcessAsUserPack + public class CreateProcessAsUserPack : EntitySerializerBase { public int SessionId { get; set; } } - public class SessionsPack : BasePacket + public class SessionsPack : EntitySerializerBase { public SessionItem[] Sessions { get; set; } } - public class SessionItem + public class SessionItem : EntitySerializerBase { public string UserName { get; set; } public int SessionId { get; set; } diff --git a/SiMay.Core/Packets/SysManager/SysKillPack.cs b/SiMay.Core/Packets/SysManager/SysKillPack.cs index 3de9227c08acd66d5698f65b26e37ce2cb61754d..4bee48f18e76adef86b279083e8fe7bdb453e4b7 100644 --- a/SiMay.Core/Packets/SysManager/SysKillPack.cs +++ b/SiMay.Core/Packets/SysManager/SysKillPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.SysManager { - public class SysKillPack : BasePacket + public class SysKillPack : EntitySerializerBase { public int[] ProcessIds { get; set; } } diff --git a/SiMay.Core/Packets/SysManager/SysWindowMaxPack.cs b/SiMay.Core/Packets/SysManager/SysWindowMaxPack.cs index 8ce45236375801539af153af8ec19af92dd46941..c115f397929baa2a9110074c304f08c692de74b3 100644 --- a/SiMay.Core/Packets/SysManager/SysWindowMaxPack.cs +++ b/SiMay.Core/Packets/SysManager/SysWindowMaxPack.cs @@ -1,11 +1,12 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.SysManager { - public class SysWindowMaxPack : BasePacket + public class SysWindowMaxPack : EntitySerializerBase { public int State { get; set; } public int[] Handlers { get; set; } diff --git a/SiMay.Core/Packets/SysManager/SystemInfoPack.cs b/SiMay.Core/Packets/SysManager/SystemInfoPack.cs index d8fa42e740f21bf9fff88296121a9c889c574ad4..40285535c9057de14e281276d971e5fa05c18333 100644 --- a/SiMay.Core/Packets/SysManager/SystemInfoPack.cs +++ b/SiMay.Core/Packets/SysManager/SystemInfoPack.cs @@ -1,26 +1,27 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets { - public class ProcessListPack : BasePacket + public class ProcessListPack : EntitySerializerBase { public ProcessItem[] ProcessList { get; set; } } - public class SystemInfoPack : BasePacket + public class SystemInfoPack : EntitySerializerBase { public SystemInfoItem[] SystemInfos { get; set; } } - public class SystemOccupyPack : BasePacket + public class SystemOccupyPack : EntitySerializerBase { public string CpuUsage { get; set; } public string MemoryUsage { get; set; } } - public class SystemInfoItem + public class SystemInfoItem : EntitySerializerBase { public string ItemName { get; set; } public string Value { get; set; } diff --git a/SiMay.Core/Packets/TcpConnection/TcpConnectionItem.cs b/SiMay.Core/Packets/TcpConnection/TcpConnectionItem.cs index 5bf534824ce4d3819d8b89ced80f1a4e20391989..f67ce3be19bbbdee202953f230a60e1c04ed28f4 100644 --- a/SiMay.Core/Packets/TcpConnection/TcpConnectionItem.cs +++ b/SiMay.Core/Packets/TcpConnection/TcpConnectionItem.cs @@ -3,10 +3,11 @@ using System.Collections.Generic; using System.Linq; using System.Text; using SiMay.Core.Enums; +using SiMay.ReflectCache; namespace SiMay.Core.Packets.TcpConnection { - public class TcpConnectionItem + public class TcpConnectionItem : EntitySerializerBase { public string ProcessName { get; set; } public string LocalAddress { get; set; } diff --git a/SiMay.Core/Packets/TcpConnection/TcpConnectionPack.cs b/SiMay.Core/Packets/TcpConnection/TcpConnectionPack.cs index 4d38354fd092b572e6c9219ca071fa672e5f8c3b..90ff7dfb6e37649974ced9391b4eacc6db1c6036 100644 --- a/SiMay.Core/Packets/TcpConnection/TcpConnectionPack.cs +++ b/SiMay.Core/Packets/TcpConnection/TcpConnectionPack.cs @@ -1,20 +1,21 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.Core.Packets.TcpConnection { - public class TcpConnectionPack : BasePacket + public class TcpConnectionPack : EntitySerializerBase { public TcpConnectionItem[] TcpConnections { get; set; } } - public class KillTcpConnectionPack : BasePacket + public class KillTcpConnectionPack : EntitySerializerBase { public KillTcpConnectionItem[] Kills { get; set; } } - public class KillTcpConnectionItem + public class KillTcpConnectionItem : EntitySerializerBase { public string LocalAddress { get; set; } diff --git a/SiMay.Core/ScreenSpy/ScreenSpy.cs b/SiMay.Core/ScreenSpy/ScreenSpy.cs index 136b045838d047c084b56be0283a90fbd631bdba..afef702a53703477457c5c34c6016c3fbf36907a 100644 --- a/SiMay.Core/ScreenSpy/ScreenSpy.cs +++ b/SiMay.Core/ScreenSpy/ScreenSpy.cs @@ -81,9 +81,11 @@ namespace SiMay.Core.ScreenSpy public void FindDifferences(bool hotRegionScan, Rectangle rect) { + var previousFrame = _capturer.PreviousFrame; + _capturer.Capture(); + var currenFrame = _capturer.CurrentFrame; - var previousFrame = _capturer.PreviousFrame; if (!hotRegionScan) _capturer.Size = new Size(rect.Width, rect.Height); @@ -152,7 +154,7 @@ namespace SiMay.Core.ScreenSpy FragmentData = _jpgCompression.Compress(m_new) } }; - this.OnDifferencesNotice?.Invoke(fragments, DifferStatus.NEXTSCREEN); + this.OnDifferencesNotice?.Invoke(fragments, DifferStatus.NEXT_SCREEN); } else m_old.Dispose(); @@ -166,14 +168,16 @@ namespace SiMay.Core.ScreenSpy _clientHotRegion = rect; - this.OnDifferencesNotice?.Invoke(null, DifferStatus.COMPLETE); + this.OnDifferencesNotice?.Invoke(null, DifferStatus.COMPLETED); } public void FullFindDifferences(bool hotRegionScan, Rectangle rect) { + var previousFrame = _capturer.PreviousFrame; + _capturer.Capture(); + var currenFrame = _capturer.CurrentFrame; - var previousFrame = _capturer.PreviousFrame; if (!hotRegionScan) _capturer.Size = new Size(rect.Width, rect.Height); @@ -256,7 +260,7 @@ namespace SiMay.Core.ScreenSpy if (this.OnDifferencesNotice != null) { - this.OnDifferencesNotice(fragments.ToArray(), DifferStatus.FULLDIFFERENCES); + this.OnDifferencesNotice(fragments.ToArray(), DifferStatus.FULL_DIFFERENCES); fragments.Clear(); } } diff --git a/SiMay.Core/SiMay.Core.csproj b/SiMay.Core/SiMay.Core.csproj index ee68c0c638444fb36cfd965149aa474e9c3926d1..42a241c142c1ebff4e26992b32353c2bf22ee3a3 100644 --- a/SiMay.Core/SiMay.Core.csproj +++ b/SiMay.Core/SiMay.Core.csproj @@ -9,7 +9,7 @@ Properties SiMay.Core SiMay.Core - v4.0 + v4.6.1 512 @@ -23,6 +23,7 @@ 4 true 8.0 + false pdbonly @@ -33,6 +34,7 @@ 4 true 8.0 + false @@ -48,12 +50,14 @@ - - - - - - + + + + + + + + @@ -68,7 +72,7 @@ - + @@ -97,7 +101,7 @@ - + @@ -127,12 +131,13 @@ + - + @@ -147,7 +152,6 @@ - @@ -161,16 +165,16 @@ - {B30CD716-698A-4DA2-BD1A-C152B16993C0} + {8f2f35cb-d5ee-4d92-b42f-bcffbf9c9d4f} SiMay.Basic - - {4888d6bb-46d9-4519-8758-e13e397aa226} - SiMay.Serialize + + {0B2B697D-DD20-4869-836C-08C848E1813F} + SiMay.Net.SessionProvider.Core - - {d181fcce-ecc7-4710-89cc-d97f94a6181b} - SiMay.Sockets.V4 + + {9525a4aa-6731-4ab2-8cd0-addf7940fe32} + SiMay.Serialize.Standard diff --git a/SiMay.Daemon/Program.cs b/SiMay.Daemon/Program.cs deleted file mode 100644 index 4a296f6eac98e2a6f0436a71bc8c3adeadf8c290..0000000000000000000000000000000000000000 --- a/SiMay.Daemon/Program.cs +++ /dev/null @@ -1,45 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Threading; -using System.Windows.Forms; - -namespace SiMay.Daemon -{ - static class Program - { - static void Main(string[] args) - { - int processId = int.Parse(args[0]); - string processName = Process.GetProcessById(processId).ProcessName + ".exe"; - while (true) - { - - try - { - if (Process.GetProcessById(processId).Id != processId) - break; - } - catch - { - if (File.Exists(processName)) - { - try - { - Process.Start(processName); - } - catch { } - break; - } - else - { - break; - } - } - Thread.Sleep(30000); - } - } - } -} diff --git a/SiMay.Daemon/SiMay.Daemon.csproj b/SiMay.Daemon/SiMay.Daemon.csproj deleted file mode 100644 index b5562a48e420bf5d34110463636008512f8d1c4d..0000000000000000000000000000000000000000 --- a/SiMay.Daemon/SiMay.Daemon.csproj +++ /dev/null @@ -1,54 +0,0 @@ - - - - - Debug - AnyCPU - {77867DE2-193E-4533-B365-31CEF16A876B} - WinExe - SiMay.Daemon - SiMay.Daemon - v4.0 - 512 - - - - AnyCPU - true - full - false - ..\Bin\dat\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SiMay.Net.HttpRemoteMonitorService/HttpRemoteMonitorService.cs b/SiMay.Net.HttpRemoteMonitorService/HttpRemoteMonitorService.cs index 5554f91370b95db294b0b79df6f457f70671342a..f20614b5f44222907d7a525a1e6fc63c22509490 100644 --- a/SiMay.Net.HttpRemoteMonitorService/HttpRemoteMonitorService.cs +++ b/SiMay.Net.HttpRemoteMonitorService/HttpRemoteMonitorService.cs @@ -40,7 +40,7 @@ namespace SiMay.Net.HttpRemoteMonitorService string _login_id = AppConfiguration.LoginId; string _login_password = AppConfiguration.LoginPassWord; - Dictionary _sessionDictionary = new Dictionary(); + Dictionary _sessionDictionary = new Dictionary(); Queue _logQueue = new Queue(10); @@ -150,7 +150,7 @@ namespace SiMay.Net.HttpRemoteMonitorService this.SendMessage(JsonConvert.SerializeObject(model)); } - private void OnNotifyProc(SessionCompletedNotify notify, SessionHandler session) + private void OnNotifyProc(SessionCompletedNotify notify, SessionProviderContext session) { switch (notify) { @@ -170,7 +170,7 @@ namespace SiMay.Net.HttpRemoteMonitorService } } - private void OnMessage(SessionHandler session) + private void OnMessage(SessionProviderContext session) { object[] ars = session.AppTokens; ConnectionWorkType sessionWorkType = (ConnectionWorkType)ars[0]; @@ -188,7 +188,7 @@ namespace SiMay.Net.HttpRemoteMonitorService case MessageHead.C_MAIN_LOGIN://上线包 this.ProcessLogin(session); break; - case MessageHead.C_MAIN_SCREENWALL_IMG://屏幕视图数据 + case MessageHead.C_MAIN_DESKTOPVIEW_FRAME://屏幕视图数据 this.ProcessDesktopViewData(session, session.CompletedBuffer.GetMessagePayload()); break; } @@ -202,7 +202,7 @@ namespace SiMay.Net.HttpRemoteMonitorService session.AppTokens[0] = ConnectionWorkType.MAINCON; - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_GLOBAL_OK); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_GLOBAL_OK); session.SendAsync(data); break; @@ -213,7 +213,7 @@ namespace SiMay.Net.HttpRemoteMonitorService } } - private void ProcessDesktopViewData(SessionHandler session, byte[] bytes) + private void ProcessDesktopViewData(SessionProviderContext session, byte[] bytes) { if (this._manager_login_c == 0) return; @@ -230,7 +230,7 @@ namespace SiMay.Net.HttpRemoteMonitorService this.PutLogQueue("DEBUG ImageProcess id:" + id + " " + bytes.Length / 1024 + "k"); } - private void SessionClosed(SessionHandler session) + private void SessionClosed(SessionProviderContext session) { string id = (string)session.AppTokens[1]; this._sessionDictionary.Remove(id); @@ -252,7 +252,7 @@ namespace SiMay.Net.HttpRemoteMonitorService } } - private void InitSessionAppToken(SessionHandler session) + private void InitSessionAppToken(SessionProviderContext session) { string id = "A" + Guid.NewGuid().ToString().Replace("-", ""); //分配NONE,等待工作指令分配新的工作类型 @@ -267,7 +267,7 @@ namespace SiMay.Net.HttpRemoteMonitorService this.PutLogQueue("DEBUG Session Connect id:" + id); } - private void ProcessLogin(SessionHandler session) + private void ProcessLogin(SessionProviderContext session) { LoginPack login = PacketSerializeHelper.DeserializePacket(session.CompletedBuffer.GetMessagePayload()); @@ -404,10 +404,10 @@ namespace SiMay.Net.HttpRemoteMonitorService string id = request.Id; if (this._sessionDictionary.ContainsKey(id)) { - SessionHandler session = this._sessionDictionary[id]; + SessionProviderContext session = this._sessionDictionary[id]; if (!(bool)session.AppTokens[2]) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_DESKTOPVIEW); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_CREATE_DESKTOPVIEW); session.SendAsync(data); session.AppTokens[2] = true; @@ -420,12 +420,12 @@ namespace SiMay.Net.HttpRemoteMonitorService string id = request.Id; if (this._sessionDictionary.ContainsKey(id)) { - SessionHandler session = this._sessionDictionary[id]; + SessionProviderContext session = this._sessionDictionary[id]; if ((bool)session.AppTokens[2]) { session.AppTokens[2] = false; - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_USERDESKTOP_CLOSE); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_DESKTOPVIEW_CLOSE); session.SendAsync(data); } } @@ -436,7 +436,7 @@ namespace SiMay.Net.HttpRemoteMonitorService if (this._sessionDictionary.ContainsKey(id)) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SESSION, new byte[] { 6 }); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SESSION, new byte[] { 6 }); this._sessionDictionary[id].SendAsync(data); } @@ -448,7 +448,7 @@ namespace SiMay.Net.HttpRemoteMonitorService if (this._sessionDictionary.ContainsKey(id)) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_HTTPDOWNLOAD, url); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_HTTPDOWNLOAD, url); this._sessionDictionary[id].SendAsync(data); } } @@ -459,7 +459,7 @@ namespace SiMay.Net.HttpRemoteMonitorService if (this._sessionDictionary.ContainsKey(id)) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_OPEN_WEBURL, url); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_OPEN_WEBURL, url); this._sessionDictionary[id].SendAsync(data); } } @@ -470,7 +470,7 @@ namespace SiMay.Net.HttpRemoteMonitorService if (this._sessionDictionary.ContainsKey(id)) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SESSION, new byte[] { byte.Parse(val) }); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SESSION, new byte[] { byte.Parse(val) }); this._sessionDictionary[id].SendAsync(data); } } @@ -485,7 +485,7 @@ namespace SiMay.Net.HttpRemoteMonitorService msg.MessageTitle = "系统通知"; msg.MessageBody = body; - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_MESSAGEBOX, PacketSerializeHelper.SerializePacket(msg)); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_MESSAGEBOX, PacketSerializeHelper.SerializePacket(msg)); this._sessionDictionary[id].SendAsync(data); } } @@ -496,7 +496,7 @@ namespace SiMay.Net.HttpRemoteMonitorService string des = request.val; if (this._sessionDictionary.ContainsKey(id)) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_REMARK, des); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_REMARK, des); this._sessionDictionary[id].SendAsync(data); } } @@ -508,12 +508,12 @@ namespace SiMay.Net.HttpRemoteMonitorService { if (this._sessionDictionary.ContainsKey(id)) { - SessionHandler session = this._sessionDictionary[id]; + SessionProviderContext session = this._sessionDictionary[id]; if (!(bool)session.AppTokens[2]) return; - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SCREENWALL_GETIMG, _desktopView_width + "|" + _desktopView_height + "|" + _desktopView_spantime); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_DESKTOPVIEW_GETFRAME, _desktopView_width + "|" + _desktopView_height + "|" + _desktopView_spantime); session.SendAsync(data); this.PutLogQueue("DEBUG pull Image height:" + _desktopView_height + " width:" + _desktopView_width); @@ -527,7 +527,7 @@ namespace SiMay.Net.HttpRemoteMonitorService { foreach (var item in this._sessionDictionary) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_GLOBAL_OK); + byte[] data = Core.MessageHelper.CopyMessageHeadTo(MessageHead.S_GLOBAL_OK); item.Value.SendAsync(data); } } diff --git a/SiMay.Net.SessionProvider.Core/Entitys/AckPacket.cs b/SiMay.Net.SessionProvider.Core/Entitys/AckPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..3f6c5ba2a611c24b67c823e4e8d665f378787022 --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Entitys/AckPacket.cs @@ -0,0 +1,39 @@ +using SiMay.ReflectCache; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SiMay.Net.SessionProvider.Core +{ + public class AckPacket : EntitySerializerBase + { + public byte Type { get; set; } + public long AccessId { get; set; } + public long AccessKey { get; set; } + public string IPV4 { get; set; } + public string MachineName { get; set; } + public string Remark { get; set; } + public string GroupName { get; set; } + public int ProcessorCount { get; set; } + public string ProcessorInfo { get; set; } + public long MemorySize { get; set; } + public string StartRunTime { get; set; } + public string ServiceVison { get; set; } + public string UserName { get; set; } + public string OSVersion { get; set; } + public bool OpenScreenWall { get; set; } + public bool ExistCameraDevice { get; set; } + public bool ExitsRecordDevice { get; set; } + public bool ExitsPlayerDevice { get; set; } + public string IdentifyId { get; set; } + public bool OpenScreenRecord { get; set; } + public int RecordHeight { get; set; } + public int RecordWidth { get; set; } + public int RecordSpanTime { get; set; } + + public bool HasLoadServiceCOM { get; set; } + + public string MacAddress { get; set; } + } +} diff --git a/SiMay.Net.SessionProvider.Core/Entitys/LogOutPacket.cs b/SiMay.Net.SessionProvider.Core/Entitys/LogOutPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..bed94c52d63c806b8c494f604f8e72c0da15758c --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Entitys/LogOutPacket.cs @@ -0,0 +1,15 @@ +using SiMay.ReflectCache; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProvider.Core +{ + public class LogOutPacket : EntitySerializerBase + { + /// + /// 登出原因 + /// + public string Message { get; set; } + } +} diff --git a/SiMay.Net.SessionProvider.Core/Entitys/MessageDataPacket.cs b/SiMay.Net.SessionProvider.Core/Entitys/MessageDataPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..0b9c236666a187324bdac05677d5b71ba138aa61 --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Entitys/MessageDataPacket.cs @@ -0,0 +1,16 @@ +using SiMay.ReflectCache; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProvider.Core +{ + public class MessageDataPacket : EntitySerializerBase + { + public long AccessId { get; set; } + + public long DispatcherId { get; set; } + + public byte[] Data { get; set; } + } +} diff --git a/SiMay.Sockets/Tcp/TcpConfiguration/TcpSocketSaeaClientConfiguration.cs b/SiMay.Net.SessionProvider.Core/Entitys/SessionClosedPacket.cs similarity index 32% rename from SiMay.Sockets/Tcp/TcpConfiguration/TcpSocketSaeaClientConfiguration.cs rename to SiMay.Net.SessionProvider.Core/Entitys/SessionClosedPacket.cs index 4fca66d72d7a7de2964f8b77dc731030d73e0b9d..92cb921555e03b264faf6220a642158689c22e92 100644 --- a/SiMay.Sockets/Tcp/TcpConfiguration/TcpSocketSaeaClientConfiguration.cs +++ b/SiMay.Net.SessionProvider.Core/Entitys/SessionClosedPacket.cs @@ -1,13 +1,12 @@ -using SiMay.Sockets.Tcp; +using SiMay.ReflectCache; using System; using System.Collections.Generic; -using System.Linq; using System.Text; -namespace SiMay.Sockets.Tcp.TcpConfiguration +namespace SiMay.Net.SessionProvider.Core { - public class TcpSocketSaeaClientConfiguration : TcpSocketConfigurationBase + public class SessionClosedPacket : EntitySerializerBase { - + public long Id { get; set; } } } diff --git a/SiMay.Net.SessionProvider.Core/Entitys/SessionPacket.cs b/SiMay.Net.SessionProvider.Core/Entitys/SessionPacket.cs new file mode 100644 index 0000000000000000000000000000000000000000..581a9709b6ca2fe33befe922fd7d82784860197b --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Entitys/SessionPacket.cs @@ -0,0 +1,19 @@ +using SiMay.ReflectCache; +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProvider.Core +{ + public class SessionPacket : EntitySerializerBase + { + public SessionItemPacket[] SessionItems { get; set; } + } + + public class SessionItemPacket : EntitySerializerBase + { + public long Id { get; set; } + + public byte[] ACKPacketData { get; set; } + } +} diff --git a/SiMay.Net.SessionProvider.Core/Enums/ConnectionWorkType.cs b/SiMay.Net.SessionProvider.Core/Enums/ConnectionWorkType.cs new file mode 100644 index 0000000000000000000000000000000000000000..87d127bc773b9fda760087cf34e8dcaf371ae702 --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Enums/ConnectionWorkType.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Text; + +namespace SiMay.Net.SessionProvider.Core +{ + public enum ConnectionWorkType + { + /// + /// 主被控服务连接 + /// + [Description("主服务连接")] + MainServiceConnection, + + /// + /// 服务工作连接 + /// + [Description("应用服务连接")] + ApplicationServiceConnection, + + /// + /// 主控端连接 + /// + [Description("主控端连接")] + MainApplicationConnection, + + /// + /// 应用工作连接 + /// + [Description("应用连接")] + ApplicationConnection, + + /// + /// 未识别 + /// + [Description("未知连接")] + None + } +} diff --git a/SiMay.Net.SessionProvider.Core/Enums/MessageHead.cs b/SiMay.Net.SessionProvider.Core/Enums/MessageHead.cs new file mode 100644 index 0000000000000000000000000000000000000000..9d28f306020e97d5b2e4943532c055f0f735c3ec --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Enums/MessageHead.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SiMay.Net.SessionProvider.Core +{ + /// + /// APP_XX : 主控端消息 + /// MID_XX : 中间服务消息 + /// + public enum MessageHead + { + /// + /// //获取所有Session + /// + APP_PULL_SESSION, + + /// + /// 关联Session信息 + /// + MID_SESSION, + + /// + /// Session离线 + /// + MID_SESSION_CLOSED, + + /// + /// 发起一个工作连接 + /// + MID_APPWORK, + + /// + /// 向主服务连接发送消息 + /// + APP_MESSAGE_DATA, + + /// + /// 转发的主服务连接数据 + /// + MID_MESSAGE_DATA, + + /// + /// AccessKey错误 + /// + MID_ACCESS_KEY_WRONG, + + /// + /// 登出 + /// + MID_LOGOUT, + } +} diff --git a/SiMay.Net.SessionProvider.Core/Extension/MessagePacketExtension.cs b/SiMay.Net.SessionProvider.Core/Extension/MessagePacketExtension.cs new file mode 100644 index 0000000000000000000000000000000000000000..e2457b3ac54ea208883013c70e1b5e6644aeb266 --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Extension/MessagePacketExtension.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProvider.Core +{ + public static class MessagePacketExtension + { + public static byte[] BuilderHeadPacket(this byte[] data) + { + int defineHeadSize = sizeof(int); + var builderHeadBytes = new byte[data.Length + defineHeadSize]; + BitConverter.GetBytes(data.Length).CopyTo(builderHeadBytes, 0); + data.CopyTo(builderHeadBytes, defineHeadSize); + + return builderHeadBytes; + } + } +} diff --git a/SiMay.Net.SessionProvider.Core/Extension/UnicodeExtensions.cs b/SiMay.Net.SessionProvider.Core/Extension/UnicodeExtensions.cs new file mode 100644 index 0000000000000000000000000000000000000000..3c5babd3689bd7351e2b63038e315e7d7eec5f58 --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Extension/UnicodeExtensions.cs @@ -0,0 +1,19 @@ +using System.Text; + +namespace SiMay.Net.SessionProvider.Core +{ + + public static class UnicodeExtensions + { + + public static string ToUnicodeString(this byte[] data) + { + return Encoding.Unicode.GetString(data); + } + + public static byte[] UnicodeStringToBytes(this string str) + { + return Encoding.Unicode.GetBytes(str); + } + } +} \ No newline at end of file diff --git a/SiMay.Net.SessionProvider.Core/Helper/LogHelper.cs b/SiMay.Net.SessionProvider.Core/Helper/LogHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..76b6a551d595b801b5cd20f68db1a7c1ccdbe7c2 --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Helper/LogHelper.cs @@ -0,0 +1,100 @@ +using SiMay.Basic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Text; +using System.Threading; + +namespace SiMay.Net.SessionProvider.Core +{ + + public class LogHelper : IDisposable + { + public static string fileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SiMaylog.log"); + + static bool _isDisposed = false; + static object _lock = new object(); + static Queue _logQueue = new Queue(); + static ManualResetEvent _event = new ManualResetEvent(false); + static LogHelper() + { + ThreadHelper.CreateThread(() => + { + while (!_isDisposed) + { + _event.WaitOne(); + lock (_lock) + { + var logs = _logQueue.ToArray(); + _logQueue.Clear(); + if (!logs.IsNullOrEmpty()) + Write(logs, fileName); + } + _event.Reset(); + Thread.Sleep(100);//缓存一下 + } + }, true); + } + + public static void WriteErrorByCurrentMethod(Exception ex) + { + StackFrame frame = new StackFrame(1, false); + StringBuilder sb = new StringBuilder(); + sb.AppendLine("DateTime:" + DateTime.Now.ToString()); + sb.AppendLine("Method:" + frame.GetMethod().Name); + sb.AppendLine("Exception Message:" + ex.Message); + sb.AppendLine("StackTrace:" + ex.StackTrace); + _logQueue.Enqueue(sb.ToString()); + _event.Set(); + } + + public static void WriteErrorByCurrentMethod(string log) + { + StackFrame frame = new StackFrame(1, false); + StringBuilder sb = new StringBuilder(); + sb.AppendLine("DateTime:" + DateTime.Now.ToString()); + sb.AppendLine("Method:" + frame.GetMethod().Name); + sb.AppendLine("Log:" + log); + _logQueue.Enqueue(sb.ToString()); + _event.Set(); + } + + public static void WriteLog(string log, string path) + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("DateTime:" + DateTime.Now.ToString()); + sb.AppendLine("Log:" + log); + Write(new string[] { sb.ToString() }, path); + } + + public static void DebugWriteLog(string log) + { +#if DEBUG + log = "DateTime:" + DateTime.Now.ToString() + " - " + log; + Console.WriteLine(log); + _logQueue.Enqueue(log); + _event.Set(); +#endif + } + + public static void Write(string[] logs, string path) + { + try + { + StreamWriter fs = new StreamWriter(path, true); + foreach (var log in logs) + fs.WriteLine(log); + fs.Close(); + } + catch { } + + } + + public void Dispose() + { + _isDisposed = true; + _event.Set(); + } + } +} \ No newline at end of file diff --git a/SiMay.Net.SessionProvider.Core/Helper/MessageHelper.cs b/SiMay.Net.SessionProvider.Core/Helper/MessageHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..785a11de6dc7915259f8ebf9f3cbaf9c323c7877 --- /dev/null +++ b/SiMay.Net.SessionProvider.Core/Helper/MessageHelper.cs @@ -0,0 +1,105 @@ +using System; +using static SiMay.Serialize.Standard.PacketSerializeHelper; + +namespace SiMay.Net.SessionProvider.Core +{ + /// + /// 消息处理帮助(格式:Int16的消息头 + payload) + /// + public static class MessageHelper + { + /// + /// 序列化数据实体,并封装消息头 + /// + /// + /// + /// + public static byte[] CopyMessageHeadTo(T cmd, object entity) + where T : struct + { + return CopyMessageHeadTo(cmd, SerializePacket(entity)); + } + + /// + /// + /// + /// + /// + /// + /// + public static byte[] CopyMessageHeadTo(T cmd, byte[] data, int offset, int size) + where T : struct + { + byte[] buff = new byte[size + sizeof(short)]; + BitConverter.GetBytes(Convert.ToInt16(cmd)).CopyTo(buff, 0); + Array.Copy(data, 0, buff, sizeof(Int16) + offset, size); + + return buff; + } + + /// + /// 构建消息至数据头部 + /// + /// + /// + /// + public static byte[] CopyMessageHeadTo(T cmd, byte[] data = null) + where T : struct + { + if (data == null) + data = new byte[] { }; + + return CopyMessageHeadTo(cmd, data, 0, data.Length); + } + + /// + /// 构建消息头至数据头部 + /// + /// 消息头 + /// 字符串 + /// + public static byte[] CopyMessageHeadTo(T cmd, string str) + where T : struct + { + byte[] data = str.UnicodeStringToBytes(); + + return CopyMessageHeadTo(cmd, data, 0, data.Length); + } + + /// + /// 获取消息头 + /// + /// + /// + public static T GetMessageHead(this byte[] data) + where T : struct + { + return (T)Enum.ToObject(typeof(T), BitConverter.ToInt16(data, 0)); + } + + /// + /// 获取消息载体 + /// + /// + /// + public static byte[] GetMessagePayload(this byte[] data) + { + byte[] payload = new byte[data.Length - sizeof(short)]; + Array.Copy(data, sizeof(short), payload, 0, payload.Length); + return payload; + } + + /// + /// 反序列化数据实体 + /// + /// + /// + /// + public static T GetMessageEntity(this byte[] data) + where T : new() + { + var entity = DeserializePacket(GetMessagePayload(data)); + return entity; + } + } +} \ No newline at end of file diff --git a/SiMay.Net.SessionProvider.Core/LogHelper.cs b/SiMay.Net.SessionProvider.Core/LogHelper.cs deleted file mode 100644 index ae5322334c1918bb198136f22897e6fd5cfdc8e4..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider.Core/LogHelper.cs +++ /dev/null @@ -1,25 +0,0 @@ -using System; -using System.IO; - -namespace SiMay.Net.SessionProvider.Core -{ - - public class LogHelper - { - - public static void WriteLog(string log, string LogAddress = "") - { - if (LogAddress == "") - LogAddress = Environment.CurrentDirectory + @"\SiMaylog.log"; - - try - { - StreamWriter fs = new StreamWriter(LogAddress, true); - fs.WriteLine(DateTime.Now.ToString() + " " + log); - fs.Close(); - } - catch { } - - } - } -} \ No newline at end of file diff --git a/SiMay.Net.SessionProvider.Core/MsgCommand.cs b/SiMay.Net.SessionProvider.Core/MsgCommand.cs deleted file mode 100644 index dcd3b9f4037e675c876af339759c2fde6cca0eb6..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider.Core/MsgCommand.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.Net.SessionProvider.Core -{ - public enum MsgCommand - { - Msg_Pull_Session,//获取所有主连接 - Msg_Set_Session,//创建Session - Msg_Set_Session_Id,//主连接关联Session - Msg_Close_Session,//Session离线 - Msg_Connect_Work,//发起一个工作连接 - Msg_LogOut,//退出登陆 - Msg_MessageData,//数据 - Msg_AccessKeyWrong//AccessKey错误 - } -} diff --git a/SiMay.Net.SessionProvider.Core/Properties/AssemblyInfo.cs b/SiMay.Net.SessionProvider.Core/Properties/AssemblyInfo.cs deleted file mode 100644 index d5f16f2a865e9318bf4ec53b58d25e3c5a394964..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider.Core/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("SiMay.Net.SessionProvider.Core")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SiMay.Net.SessionProvider.Core")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("8bfdb408-d26d-4689-b426-be45ad195880")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -//通过使用 "*",如下所示: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SiMay.Net.SessionProvider.Core/SiMay.Net.SessionProvider.Core.csproj b/SiMay.Net.SessionProvider.Core/SiMay.Net.SessionProvider.Core.csproj index d3e901f14f4fe0fd7c8ebb0e3614bf6d69235e21..7dea9a38f8eb806061e22872bb28a51a5e7bf105 100644 --- a/SiMay.Net.SessionProvider.Core/SiMay.Net.SessionProvider.Core.csproj +++ b/SiMay.Net.SessionProvider.Core/SiMay.Net.SessionProvider.Core.csproj @@ -1,52 +1,18 @@ - - - + + - Debug - AnyCPU - {8BFDB408-D26D-4689-B426-BE45AD195880} - Library - Properties - SiMay.Net.SessionProvider.Core - SiMay.Net.SessionProvider.Core - v4.0 - 512 - - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 8.0 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - 8.0 + netstandard2.0 + false + false + - - - - - - - - + + - - - - + + - - \ No newline at end of file + + diff --git a/SiMay.Net.SessionProvider/Delegate/NetNotifyEventHandler.cs b/SiMay.Net.SessionProvider/Delegate/NetNotifyEventHandler.cs deleted file mode 100644 index ea9ec869cbdd543bd8edcb70e218ec9ecddee35e..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/Delegate/NetNotifyEventHandler.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SiMay.Net.SessionProvider.Delegate -{ - public delegate void OnSessionNotify(TEvent e, Session session); -} diff --git a/SiMay.Net.SessionProvider/Delegate/ProxyNotifyEventHandler.cs b/SiMay.Net.SessionProvider/Delegate/ProxyNotifyEventHandler.cs deleted file mode 100644 index 1b45ffa9e257aa65c65e6d48edf19dc5d674f72b..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/Delegate/ProxyNotifyEventHandler.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SiMay.Net.SessionProvider.Delegate -{ - public delegate void OnProxyNotify(TEvent arg); -} diff --git a/SiMay.Net.SessionProvider/Notify/ProxyNotify.cs b/SiMay.Net.SessionProvider/Enum/ProxyProviderNotify.cs similarity index 35% rename from SiMay.Net.SessionProvider/Notify/ProxyNotify.cs rename to SiMay.Net.SessionProvider/Enum/ProxyProviderNotify.cs index 5822ee6f8ea1827e4859808e9d877d0e6c043bd3..006d5d282ff0b85e1bc5e804725c99e0c8a731cd 100644 --- a/SiMay.Net.SessionProvider/Notify/ProxyNotify.cs +++ b/SiMay.Net.SessionProvider/Enum/ProxyProviderNotify.cs @@ -1,13 +1,17 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; -namespace SiMay.Net.SessionProvider.Notify +namespace SiMay.Net.SessionProvider { - public enum ProxyNotify + public enum ProxyProviderNotify { - AccessKeyWrong, + [Description("AccessId、Key验证不通过")] + AccessIdOrKeyWrong, + + [Description("登出")] LogOut } } diff --git a/SiMay.Net.SessionProvider/SessionProviderType.cs b/SiMay.Net.SessionProvider/Enum/SessionProviderType.cs similarity index 100% rename from SiMay.Net.SessionProvider/SessionProviderType.cs rename to SiMay.Net.SessionProvider/Enum/SessionProviderType.cs diff --git a/SiMay.Net.SessionProvider/Notify/SessionCompletedNotify.cs b/SiMay.Net.SessionProvider/EventArgs/LogOutEventArgs.cs similarity index 30% rename from SiMay.Net.SessionProvider/Notify/SessionCompletedNotify.cs rename to SiMay.Net.SessionProvider/EventArgs/LogOutEventArgs.cs index 1b33a7dceb33fb6bf9ca061833537642369fc541..5a1fdd0be2f4177527c30dbb405f44319550e7b9 100644 --- a/SiMay.Net.SessionProvider/Notify/SessionCompletedNotify.cs +++ b/SiMay.Net.SessionProvider/EventArgs/LogOutEventArgs.cs @@ -1,16 +1,12 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; -namespace SiMay.Net.SessionProvider.Notify +namespace SiMay.Net.SessionProvider { - public enum SessionCompletedNotify + public class LogOutEventArgs : EventArgs { - OnConnected, - OnSend, - OnRecv, - OnReceived, - OnClosed + public string Message { get; private set; } + public LogOutEventArgs(string message) => Message = message; } } diff --git a/SiMay.Net.SessionProvider/Properties/AssemblyInfo.cs b/SiMay.Net.SessionProvider/Properties/AssemblyInfo.cs deleted file mode 100644 index 2cd07b6626b08f1d4d5223b6d63c162e3600e328..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// 有关程序集的一般信息由以下 -// 控制。更改这些特性值可修改 -// 与程序集关联的信息。 -[assembly: AssemblyTitle("SiMay.Net.SessionProvider")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SiMay.Net.SessionProvider")] -[assembly: AssemblyCopyright("Copyright © 2019")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// 将 ComVisible 设置为 false 会使此程序集中的类型 -//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 -//请将此类型的 ComVisible 特性设置为 true。 -[assembly: ComVisible(false)] - -// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("bf5b6f41-d688-447f-bf81-ea821216f188")] - -// 程序集的版本信息由下列四个值组成: -// -// 主版本 -// 次版本 -// 生成号 -// 修订号 -// -// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号 -//通过使用 "*",如下所示: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/SiMay.Net.SessionProvider/SessionProvider.cs b/SiMay.Net.SessionProvider/Providers/SessionProvider.cs similarity index 31% rename from SiMay.Net.SessionProvider/SessionProvider.cs rename to SiMay.Net.SessionProvider/Providers/SessionProvider.cs index 1fe6a054b1a073199b257e1684a1fed9525b45b3..7f54be0ad3428202eec4e13c590eb9522299e50d 100644 --- a/SiMay.Net.SessionProvider/SessionProvider.cs +++ b/SiMay.Net.SessionProvider/Providers/SessionProvider.cs @@ -1,6 +1,4 @@ -using SiMay.Net.SessionProvider.Delegate; -using SiMay.Net.SessionProvider.Notify; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Sockets.Tcp; using System; using System.Collections.Generic; using System.Linq; @@ -10,17 +8,41 @@ namespace SiMay.Net.SessionProvider { public abstract class SessionProvider { - protected OnSessionNotify _onSessionNotifyProc; + public event Action SessionNotifyEventHandler; - internal SessionProvider(OnSessionNotify onSessionNotifyProc) + protected void SessionNotify(SessionProviderContext providerContext, TcpSessionNotify type) { - _onSessionNotifyProc = onSessionNotifyProc; + SessionNotifyEventHandler?.Invoke(providerContext, type); } + /// + /// 启动 + /// public abstract void StartSerivce(); - public abstract void BroadcastAsync(byte[] data); + + /// + /// 广播发送 + /// + /// + public virtual void BroadcastAsync(byte[] data) + => BroadcastAsync(data, 0, data.Length); + + /// + /// 广播发送 + /// + /// + /// + /// public abstract void BroadcastAsync(byte[] data, int offset, int lenght); + + /// + /// 关闭所有 + /// public abstract void DisconnectAll(); + + /// + /// 关闭 + /// public abstract void CloseService(); } } \ No newline at end of file diff --git a/SiMay.Net.SessionProvider/Providers/TcpProxySessionProvider.cs b/SiMay.Net.SessionProvider/Providers/TcpProxySessionProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..de67e6ba74cd148929ef177bd0d258d85cedbe79 --- /dev/null +++ b/SiMay.Net.SessionProvider/Providers/TcpProxySessionProvider.cs @@ -0,0 +1,275 @@ +using System; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using SiMay.Basic; +using SiMay.Core.Packets; +using SiMay.Sockets.Tcp; +using SiMay.Sockets.Tcp.Client; +using SiMay.Sockets.Tcp.Session; +using SiMay.Net.SessionProvider.Core; +using SiMay.Sockets.Tcp.TcpConfiguration; + +namespace SiMay.Net.SessionProvider.Providers +{ + public class TcpProxySessionProvider : SessionProvider + { + public static LoginPack loginPack { get; set; } + public event Action ProxyProviderNotify; + + private TcpProxyMainConnectionContext TcpProxyMainConnectionContext { get; set; } + + private const Int16 CHANNEL_LOGOUT = 0; + private const Int16 CHANNEL_LOGIN = 1; + + private int _currentState = 0; + private bool _wetherLogOut; + private IDictionary _proxySessions = new Dictionary(); + private TcpSocketSaeaClientAgent _clientAgent; + + /// + /// session代理提供器构造函数 + /// + /// 代理配置设置 + /// session事件通知 + /// 代理事件通知 + internal TcpProxySessionProvider(SessionProviderOptions options) + { + ApplicationConfiguartion.SetOptions(options); + + var clientConfig = new TcpSocketSaeaClientConfiguration(); + clientConfig.ReuseAddress = true; + clientConfig.KeepAlive = true; + clientConfig.KeepAliveInterval = 5000; + clientConfig.KeepAliveSpanTime = 1000; + + //不启用压缩 + clientConfig.CompressTransferFromPacket = false; + //停用应用心跳检测线程 + clientConfig.AppKeepAlive = false; + + _clientAgent = TcpSocketsFactory.CreateClientAgent(TcpSocketSaeaSessionType.Packet, clientConfig, (notify, session) => + { + switch (notify) + { + case TcpSessionNotify.OnConnected: + this.ConnectedHandler(session); + break; + case TcpSessionNotify.OnSend: + this.OnSend(session); + break; + case TcpSessionNotify.OnDataReceived: + this.OnMessageHandler(session); + break; + case TcpSessionNotify.OnClosed: + this.OnClosed(session); + break; + default: + break; + } + }); + } + private void SendACK(TcpSocketSaeaSession session, ConnectionWorkType type) + { + var ackBody = MessageHelper.CopyMessageHeadTo(SiMay.Core.MessageHead.C_GLOBAL_CONNECT, + new AckPack() + { + Type = (byte)type, + AccessId = ApplicationConfiguartion.Options.AccessId, + AccessKey = type == ConnectionWorkType.MainApplicationConnection ? ApplicationConfiguartion.Options.MainAppAccessKey : ApplicationConfiguartion.Options.AccessKey, + IPV4 =loginPack.IPV4, + MachineName = loginPack.MachineName, + ProcessorCount = loginPack.ProcessorCount, + ProcessorInfo = loginPack.ProcessorInfo, + MemorySize = loginPack.MemorySize, + UserName = loginPack.UserName, + OSVersion = loginPack.OSVersion, + MacAddress = loginPack.MacAddress + + }); + + var dataBuilder = new List(); + dataBuilder.AddRange(BitConverter.GetBytes(ApplicationConfiguartion.Options.AccessId)); + dataBuilder.AddRange(GZipHelper.Compress(ackBody, 0, ackBody.Length)); + session.SendAsync(dataBuilder.ToArray());//构造发送 + dataBuilder.Clear(); + } + + private void ConnectedHandler(TcpSocketSaeaSession session) + { + if (Interlocked.Exchange(ref _currentState, CHANNEL_LOGIN) == CHANNEL_LOGOUT) + { + this.TcpProxyMainConnectionContext = new TcpProxyMainConnectionContext(session); + this.TcpProxyMainConnectionContext.SessionNotifyEventHandler += ProxyMainConnectionSessionNotify; + this.TcpProxyMainConnectionContext.LogOutEventHandler += LogOutEventHandler; + this.TcpProxyMainConnectionContext.LaunchApplicationConnectEventHandler += LaunchApplicationConnectEventHandler; + this.TcpProxyMainConnectionContext.AccessIdOrKeyWrongEventHandler += AccessIdOrKeyWrongEventHandler; + session.AppTokens = new object[] { + this.TcpProxyMainConnectionContext, + ConnectionWorkType.MainApplicationConnection + }; + this.SendACK(session, ConnectionWorkType.MainApplicationConnection); + this.TcpProxyMainConnectionContext.PullSession(); + } + else + { + var tcpSessionContext = new TcpSocketSessionContext(session); + this._proxySessions.Add(tcpSessionContext.GetHashCode(), tcpSessionContext); + + session.AppTokens = new object[] { + tcpSessionContext, + ConnectionWorkType.ApplicationConnection + }; + this.SendACK(session, ConnectionWorkType.ApplicationConnection); + this.SessionNotify(tcpSessionContext, TcpSessionNotify.OnConnected); + } + } + + private void AccessIdOrKeyWrongEventHandler(TcpProxyMainConnectionContext mainConnectionContext) + => this.ProxyProviderNotify?.Invoke(Net.SessionProvider.ProxyProviderNotify.AccessIdOrKeyWrong, EventArgs.Empty); + + private void LaunchApplicationConnectEventHandler(TcpProxyMainConnectionContext mainConnectionContext) + => this._clientAgent.ConnectToServer(ApplicationConfiguartion.Options.ServiceIPEndPoint); + + private void LogOutEventHandler(TcpProxyMainConnectionContext mainConnectionContext, string message) + { + _wetherLogOut = true; + this.ProxyProviderNotify?.Invoke(Net.SessionProvider.ProxyProviderNotify.LogOut, new LogOutEventArgs(message)); + } + + private void ProxyMainConnectionSessionNotify(TcpProxyApplicationConnectionContext proxyContext, TcpSessionNotify type) + { + this.SessionNotify(proxyContext, type); + + //switch (type) + //{ + // case TcpSessionNotify.OnConnected: + // this.SessionNotify(proxyContext, TcpSessionNotify.OnConnected); + // break; + // case TcpSessionNotify.OnSend: + // this.SessionNotify(proxyContext, TcpSessionNotify.OnSend); + // break; + // case TcpSessionNotify.OnDataReceiveing: + // this.SessionNotify(proxyContext, TcpSessionNotify.OnDataReceiveing); + // break; + // case TcpSessionNotify.OnDataReceived: + // this.SessionNotify(proxyContext, TcpSessionNotify.OnDataReceived); + // break; + // case TcpSessionNotify.OnClosed: + // this.SessionNotify(proxyContext, TcpSessionNotify.OnClosed); + // break; + //} + } + + private void OnSend(TcpSocketSaeaSession session) + { + if (session.AppTokens.IsNull()) + return; + + var type = session.AppTokens[SysContanct.INDEX_WORKTYPE].ConvertTo(); + if (type == ConnectionWorkType.ApplicationConnection) + { + var tcpSessionContext = session.AppTokens[SysContanct.INDEX_WORKER].ConvertTo(); + this.SessionNotify(tcpSessionContext, TcpSessionNotify.OnSend); + } + } + + private void OnMessageHandler(TcpSocketSaeaSession session) + { + var type = session.AppTokens[SysContanct.INDEX_WORKTYPE].ConvertTo(); + if (type == ConnectionWorkType.MainApplicationConnection) + { + var sessionContext = session.AppTokens[SysContanct.INDEX_WORKER].ConvertTo(); + sessionContext.OnMessage(session.CompletedBuffer); + } + else if (type == ConnectionWorkType.ApplicationConnection) + { + var sessionContext = session.AppTokens[SysContanct.INDEX_WORKER].ConvertTo(); + this.SessionNotify(sessionContext, TcpSessionNotify.OnDataReceived); + } + } + + private void OnClosed(TcpSocketSaeaSession session) + { + if (session.AppTokens.IsNull() && this._currentState == CHANNEL_LOGOUT) + { + session.AppTokens = new object[] { + null, + ConnectionWorkType.MainApplicationConnection + }; + } + else if (session.AppTokens.IsNull() && this._currentState == CHANNEL_LOGIN) + return; + + var type = session.AppTokens[SysContanct.INDEX_WORKTYPE].ConvertTo(); + if (type == ConnectionWorkType.MainApplicationConnection) + { + if (!TcpProxyMainConnectionContext.IsNull()) + { + this.TcpProxyMainConnectionContext.CloseCurrentSession(); + this.TcpProxyMainConnectionContext.LaunchApplicationConnectEventHandler -= LaunchApplicationConnectEventHandler; + this.TcpProxyMainConnectionContext.AccessIdOrKeyWrongEventHandler -= AccessIdOrKeyWrongEventHandler; + this.TcpProxyMainConnectionContext.SessionNotifyEventHandler -= ProxyMainConnectionSessionNotify; + this.TcpProxyMainConnectionContext.LogOutEventHandler -= LogOutEventHandler; + } + this.TcpProxyMainConnectionContext = null; _currentState = CHANNEL_LOGOUT; + + lock (this) + { + foreach (var proxySession in _proxySessions.Select(c => c.Value)) + this.SessionNotify(proxySession, TcpSessionNotify.OnClosed); + this._proxySessions.Clear(); + } + + if (!_wetherLogOut) + { + var timer = new System.Timers.Timer(); + timer.Interval = 5000; + timer.Elapsed += (s, e) => + { + this._clientAgent.ConnectToServer(ApplicationConfiguartion.Options.ServiceIPEndPoint); + + timer.Stop(); + timer.Dispose(); + }; + timer.Start(); + } + } + else if (type == ConnectionWorkType.ApplicationConnection) + { + lock (this) + { + var sessionContext = session.AppTokens[SysContanct.INDEX_WORKER].ConvertTo(); + this.SessionNotify(sessionContext, TcpSessionNotify.OnClosed); + this._proxySessions.Remove(sessionContext.GetHashCode()); + } + } + } + + public override void StartSerivce() + { + this._clientAgent.ConnectToServer(ApplicationConfiguartion.Options.ServiceIPEndPoint); + } + + public override void BroadcastAsync(byte[] data, int offset, int lenght) + { + foreach (var session in this._proxySessions.Select(c => c.Value)) + session.SendAsync(data, offset, lenght); + } + + public override void CloseService() + { + this._wetherLogOut = true; + + } + + public override void DisconnectAll() + { + foreach (var session in this._proxySessions.Select(c => c.Value)) + session.SessionClose(); + } + } +} diff --git a/SiMay.Net.SessionProvider/Providers/TcpProxySessionProviderHandle.cs b/SiMay.Net.SessionProvider/Providers/TcpProxySessionProviderHandle.cs deleted file mode 100644 index 71b1d5712efbc5b5fa56615910850dfaa870cfea..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/Providers/TcpProxySessionProviderHandle.cs +++ /dev/null @@ -1,445 +0,0 @@ -using SiMay.Net.SessionProvider.Delegate; -using SiMay.Net.SessionProvider.SessionBased; -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Client; -using SiMay.Sockets.Tcp.Server; -using System.Net; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Threading; -using SiMay.Net.SessionProvider.Core; -using System.Runtime.InteropServices; -using System.Windows.Forms; -using SiMay.Net.SessionProvider.Notify; -using SiMay.Basic; -using SiMay.Sockets.Tcp.Session; -using SiMay.Sockets.Tcp.TcpConfiguration; - -namespace SiMay.Net.SessionProvider.Providers -{ - /// - /// 代理协议写的有些冗余。。有空抽出时间重构 - /// - public class TcpProxySessionProviderHandle : SessionProvider - { - const Int16 AckPacket = 1000; - - List _sessionList = new List(); - - TcpSocketSaeaClientAgent _clientAgent; - SessionProviderOptions _options; - - List _manager_buffer = new List(); - TcpSocketSaeaSession _manager_session; - int _manager_login = 0; - bool _LogOut = false; - - OnProxyNotify _onProxyNotify; - internal TcpProxySessionProviderHandle( - SessionProviderOptions options, - OnSessionNotify onSessionNotifyProc, - OnProxyNotify onProxyNotify) - : base(onSessionNotifyProc) - { - _options = options; - _onProxyNotify = onProxyNotify; - - var clientConfig = new TcpSocketSaeaClientConfiguration(); - clientConfig.ReuseAddress = true; - clientConfig.KeepAlive = true; - clientConfig.KeepAliveInterval = 5000; - clientConfig.KeepAliveSpanTime = 1000; - - _clientAgent = TcpSocketsFactory.CreateClientAgent(TcpSocketSaeaSessionType.Full, clientConfig, (notify, session) => - { - - switch (notify) - { - case TcpSocketCompletionNotify.OnConnected: - this.ConnectionProcess(session); - break; - case TcpSocketCompletionNotify.OnSend: - this.OnSend(session); - break; - case TcpSocketCompletionNotify.OnDataReceiveing: - this.PacketProcess(session); - break; - case TcpSocketCompletionNotify.OnClosed: - this.OnClosed(session); - break; - default: - break; - } - }); - } - - private void ConnectionProcess(TcpSocketSaeaSession session) - { - if (Interlocked.Exchange(ref _manager_login, 1) == 0) - { - this.SendAck(session, SessionWorkType.ManagerSession); - - _manager_session = session; - session.AppTokens = new object[] - { - SessionWorkType.ManagerSession, - null - }; - - //获取所有主连接 - SendMessageHelper.SendMessage(session, MsgCommand.Msg_Pull_Session); - } - else - { - this.SendAck(session, SessionWorkType.ManagerWorkSession); - var sessionBased = new TcpProxySessionBased(session); - session.AppTokens = new object[] - { - SessionWorkType.ManagerWorkSession, - sessionBased - }; - - this._onSessionNotifyProc(SessionCompletedNotify.OnConnected, sessionBased as SessionHandler); - } - } - private void OnSend(TcpSocketSaeaSession session) - { - if ((SessionWorkType)session.AppTokens[0] == SessionWorkType.ManagerWorkSession) - { - var sessionBased = session.AppTokens[1] as TcpProxySessionBased; - sessionBased._sendTransferredBytes = session.SendTransferredBytes; - this._onSessionNotifyProc(SessionCompletedNotify.OnSend, sessionBased as SessionHandler); - } - } - - private void PacketProcess(TcpSocketSaeaSession session) - { - byte[] data = new byte[session.ReceiveBytesTransferred]; - Array.Copy(session.CompletedBuffer, 0, data, 0, data.Length); - - if ((SessionWorkType)session.AppTokens[0] == SessionWorkType.ManagerSession) - { - _manager_buffer.AddRange(data); - do - { - if (_manager_buffer.Count < 4) - return; - - byte[] lenBytes = _manager_buffer.GetRange(0, 4).ToArray(); - int packageLen = BitConverter.ToInt32(lenBytes, 0); - - //缓冲区越界判断 - if (packageLen > (1024 * 1024 * 2) || packageLen < 1) - { - this.ConsoleWriteLine("DEBUG BUFFER OutOfRange !! PacketProcess MAIN", ConsoleColor.Red); - this._manager_buffer.Clear(); - session.Close(true); - return; - } - - if (packageLen > _manager_buffer.Count - 4) - return; - - byte[] completedBytes = _manager_buffer.GetRange(4, packageLen).ToArray(); - - this.OnMessage(completedBytes); - - _manager_buffer.RemoveRange(0, packageLen + 4); - - } while (_manager_buffer.Count > 4); - } - else - { - var sessionBased = session.AppTokens[1] as TcpProxySessionBased; - - sessionBased._receiveTransferredBytes = data.Length; - - this._onSessionNotifyProc(SessionCompletedNotify.OnRecv, sessionBased as SessionHandler); - - sessionBased.Buffer.AddRange(data); - do - { - if (sessionBased.Buffer.Count < 4) - return; - - byte[] lenBytes = sessionBased.Buffer.GetRange(0, 4).ToArray(); - int packageLen = BitConverter.ToInt32(lenBytes, 0); - - //缓冲区越界判断 - if (packageLen > (1024 * 1024 * 2) || packageLen < 1) - { - this.ConsoleWriteLine("DEBUG BUFFER OutOfRange !! PacketProcess WORK", ConsoleColor.Red); - session.Close(true); - return; - } - - if (packageLen > sessionBased.Buffer.Count - 4) - return; - - byte[] completeBytes = sessionBased.Buffer.GetRange(4, packageLen).ToArray(); - - sessionBased._completedBuffer = CompressHelper.Decompress(completeBytes); - - this._onSessionNotifyProc(SessionCompletedNotify.OnReceived, sessionBased as SessionHandler); - - sessionBased.Buffer.RemoveRange(0, packageLen + 4); - - } while (sessionBased.Buffer.Count > 4); - } - } - - private void OnClosed(TcpSocketSaeaSession session) - { - if (session.AppTokens == null && this._manager_login == 0) - { - session.AppTokens = new object[] - { - SessionWorkType.ManagerSession, - null - }; - } - else if (this._manager_login == 1 && session.AppTokens == null) - { - return; - } - - if ((SessionWorkType)session.AppTokens[0] == SessionWorkType.ManagerSession) - { - Interlocked.Exchange(ref this._manager_login, 0); - - //_manager_buffer.Clear(); - _manager_session = null; - - foreach (var _session in this._sessionList) - { - this._onSessionNotifyProc(SessionCompletedNotify.OnClosed, _session as SessionHandler); - _session.Dispose(); - } - this._sessionList.Clear(); - - if (!this._LogOut) - { - this.ConsoleWriteLine("DEBUG ACCEPT CONNECT", ConsoleColor.Green); - var timer = new System.Timers.Timer(); - timer.Interval = 5000; - timer.Elapsed += (s, e) => - { - this.ConsoleWriteLine("DEBUG RE CONNECT", ConsoleColor.Green); - this._clientAgent.ConnectToServer(this._options.ServiceIPEndPoint); - - timer.Stop(); - timer.Dispose(); - }; - timer.Start(); - } - - - } - else - { - var sessionBased = session.AppTokens[1] as TcpProxySessionBased; - this._onSessionNotifyProc(SessionCompletedNotify.OnClosed, sessionBased as SessionHandler); - sessionBased.Dispose(); - } - } - private void OnMessage(byte[] data) - { - MsgCommand cmd = (MsgCommand)data[0]; - switch (cmd) - { - case MsgCommand.Msg_Set_Session: - this.CreateSession(data); - break; - case MsgCommand.Msg_Connect_Work: - this._clientAgent.ConnectToServer(this._options.ServiceIPEndPoint); - break; - case MsgCommand.Msg_LogOut: - this.LogOut(); - break; - case MsgCommand.Msg_MessageData: - this.ProcessPackage(data); - break; - case MsgCommand.Msg_Close_Session: - this.ProcessSessionClose(data); - break; - case MsgCommand.Msg_AccessKeyWrong: - this.ProcessAccessKeyWrong(); - break; - } - - - } - private void ProcessAccessKeyWrong() - { - this._LogOut = true; - if (this._manager_login == 1) - this._manager_session.Close(true); - - this._onProxyNotify?.Invoke(ProxyNotify.AccessKeyWrong); - } - private void ProcessPackage(byte[] data) - { - long id = BitConverter.ToInt64(data, 1); - GCHandle gc = GCHandle.FromIntPtr(new IntPtr(id)); - TcpProxySessionBased session = gc.Target as TcpProxySessionBased; - - if (session == null) - { - this.ConsoleWriteLine("DEBUG ProcessPackage SESSION NULL", ConsoleColor.Red); - return; - } - - byte[] bytes = new byte[data.Length - (sizeof(Int64) + 1)]; - Array.Copy(data, sizeof(Int64) + 1, bytes, 0, bytes.Length); - - session._receiveTransferredBytes = bytes.Length; - this._onSessionNotifyProc(SessionCompletedNotify.OnRecv, session as SessionHandler); - session.Buffer.AddRange(bytes); - do - { - if (session.Buffer.Count < 4) - return; - - byte[] lenBytes = session.Buffer.GetRange(0, 4).ToArray(); - int packageLen = BitConverter.ToInt32(lenBytes, 0); - - //缓冲区越界判断 - if (packageLen > (1024 * 1024 * 2) || packageLen < 1) - { - this.ConsoleWriteLine("DEBUG BUFFER OutOfRange !! ProcessPackage DATA", ConsoleColor.Red); - this._manager_session.Close(true); - return; - } - - if (packageLen > session.Buffer.Count - 4) - return; - - byte[] completeBytes = session.Buffer.GetRange(4, packageLen).ToArray(); - - session._completedBuffer = CompressHelper.Decompress(completeBytes); - - this._onSessionNotifyProc(SessionCompletedNotify.OnReceived, session as SessionHandler); - - session.Buffer.RemoveRange(0, packageLen + 4); - - } while (session.Buffer.Count > 4); - } - - - private void LogOut() - { - this._LogOut = true; - if (this._manager_login == 1) - this._manager_session.Close(true); - - this._onProxyNotify?.Invoke(ProxyNotify.LogOut); - } - - private void ProcessSessionClose(byte[] data) - { - long id = BitConverter.ToInt64(data, 1); - GCHandle gc = GCHandle.FromIntPtr(new IntPtr(id)); - - TcpProxySessionBased session = gc.Target as TcpProxySessionBased; - this._onSessionNotifyProc(SessionCompletedNotify.OnClosed, session as SessionHandler); - this._sessionList.Remove(session);//移除List引用 - session.Buffer.Clear(); - session.Dispose(); - //////////////////////////////check - } - private void CreateSession(byte[] data) - { - byte[] body = new byte[data.Length - 1]; - Array.Copy(data, 1, body, 0, body.Length); - - //byte[] sessionIds = new byte[body.Length * 2]; - List buffer = new List(); - - byte[] sessionId = new byte[sizeof(Int64) * 2]; - - List sessionList = new List(); - for (int i = 0; i < body.Length / sizeof(Int64); i++) - { - Array.Copy(body, i * sizeof(Int64), sessionId, 0, sizeof(Int64)); - TcpProxySessionBased sessionBased = new TcpProxySessionBased(_manager_session); - sessionBased.RemoteId = BitConverter.ToInt64(sessionId, 0); - - Console.WriteLine("CreateSession:" + sessionBased.RemoteId + " Id:" + sessionBased.Id); - - sessionList.Add(sessionBased); - - BitConverter.GetBytes(sessionBased.Id).CopyTo(sessionId, sizeof(Int64)); - buffer.AddRange(sessionId); - //Array.Copy(sessionId, 0, sessionIds, i * (sizeof(Int64) + sizeof(Int64)), sizeof(Int64) + sizeof(Int64)); - } - - SendMessageHelper.SendMessage(_manager_session, MsgCommand.Msg_Set_Session_Id, buffer.ToArray()); - - this._sessionList.AddRange(sessionList.ToArray()); - - foreach (var session in sessionList) - { - this._onSessionNotifyProc?.Invoke(SessionCompletedNotify.OnConnected, session as SessionHandler); - } - - sessionList.Clear(); - } - - private void SendAck(TcpSocketSaeaSession session, SessionWorkType type) - { - // //命令头 //accesskey //workType - byte[] bytes = new byte[sizeof(Int16) + sizeof(Int64) + sizeof(Byte)]; - BitConverter.GetBytes(AckPacket).CopyTo(bytes, 0); - BitConverter.GetBytes(_options.AccessKey).CopyTo(bytes, 2); - bytes[10] = (Byte)type; - - byte[] body = CompressHelper.Compress(bytes, 0, bytes.Length); - - byte[] data = new byte[sizeof(Int32) + body.Length]; - BitConverter.GetBytes(body.Length).CopyTo(data, 0); - body.CopyTo(data, 4); - - session.SendAsync(data); - } - - private void ConsoleWriteLine(string log, ConsoleColor color) - { - Console.ForegroundColor = color; - Console.WriteLine(log); - Console.ResetColor(); - } - - public override void StartSerivce() - { - this._LogOut = false; - this._clientAgent.ConnectToServer(this._options.ServiceIPEndPoint); - } - public override void BroadcastAsync(byte[] data) - { - foreach (var session in this._sessionList) - session.SendAsync(data); - } - - public override void BroadcastAsync(byte[] data, int offset, int lenght) - { - foreach (var session in this._sessionList) - session.SendAsync(data, offset, lenght); - } - - public override void CloseService() - { - this._LogOut = true; - if (this._manager_login == 1) - _manager_session.Close(true); - } - - public override void DisconnectAll() - { - foreach (var session in this._sessionList) - session.SessionClose(); - } - } -} diff --git a/SiMay.Net.SessionProvider/Providers/TcpSocketSessionProvider.cs b/SiMay.Net.SessionProvider/Providers/TcpSocketSessionProvider.cs new file mode 100644 index 0000000000000000000000000000000000000000..208b0ab7e36558b60463232d93cca67902c09cd0 --- /dev/null +++ b/SiMay.Net.SessionProvider/Providers/TcpSocketSessionProvider.cs @@ -0,0 +1,59 @@ +using System; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SiMay.Basic; +using SiMay.Sockets.Tcp; +using SiMay.Sockets.Tcp.Server; +using SiMay.Sockets.Tcp.TcpConfiguration; + +namespace SiMay.Net.SessionProvider.Providers +{ + public class TcpSocketSessionProvider : SessionProvider + { + TcpSocketSaeaServer _server; + internal TcpSocketSessionProvider(SessionProviderOptions options) + { + ApplicationConfiguartion.SetOptions(options); + var serverConfig = new TcpSocketSaeaServerConfiguration(); + + serverConfig.AppKeepAlive = true; + serverConfig.CompressTransferFromPacket = false; + serverConfig.PendingConnectionBacklog = ApplicationConfiguartion.Options.PendingConnectionBacklog; + + _server = TcpSocketsFactory.CreateServerAgent(TcpSocketSaeaSessionType.Packet, serverConfig, (notify, session) => + { + switch (notify) + { + case TcpSessionNotify.OnConnected: + + SessionProviderContext sessionBased = new TcpSocketSessionContext(session); + this.SessionNotify(sessionBased, TcpSessionNotify.OnConnected); + break; + case TcpSessionNotify.OnSend: + this.SessionNotify(session.AppTokens.First().ConvertTo(), TcpSessionNotify.OnSend); + break; + case TcpSessionNotify.OnDataReceiveing: + this.SessionNotify(session.AppTokens.First().ConvertTo(), TcpSessionNotify.OnDataReceiveing); + break; + case TcpSessionNotify.OnDataReceived: + this.SessionNotify(session.AppTokens.First().ConvertTo(), TcpSessionNotify.OnDataReceived); + break; + case TcpSessionNotify.OnClosed: + this.SessionNotify(session.AppTokens.First().ConvertTo(), TcpSessionNotify.OnClosed); + break; + default: + break; + } + + }); + } + public override void StartSerivce() => _server.Listen(ApplicationConfiguartion.Options.ServiceIPEndPoint); + + public override void BroadcastAsync(byte[] data, int offset, int lenght) => _server.BroadcastAsync(data, offset, lenght); + + public override void CloseService() => _server.Dispose(); + + public override void DisconnectAll() => _server.DisconnectAll(true); + } +} diff --git a/SiMay.Net.SessionProvider/Providers/TcpSocketSessionProviderHandle.cs b/SiMay.Net.SessionProvider/Providers/TcpSocketSessionProviderHandle.cs deleted file mode 100644 index 608284d7bc70ff6e8dcd2597b401d8eb9840486f..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/Providers/TcpSocketSessionProviderHandle.cs +++ /dev/null @@ -1,80 +0,0 @@ -using SiMay.Net.SessionProvider.Delegate; -using SiMay.Net.SessionProvider.Notify; -using SiMay.Net.SessionProvider.SessionBased; -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Server; -using SiMay.Sockets.Tcp.TcpConfiguration; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.Net.SessionProvider.Providers -{ - public class TcpSocketSessionProviderHandle : SessionProvider - { - TcpSocketSaeaServer _server; - SessionProviderOptions _options; - internal TcpSocketSessionProviderHandle( - SessionProviderOptions options, - OnSessionNotify onSessionNotifyProc) - : base(onSessionNotifyProc) - { - - _options = options; - - var serverConfig = new TcpSocketSaeaServerConfiguration(); - - serverConfig.AppKeepAlive = true; - serverConfig.PendingConnectionBacklog = options.PendingConnectionBacklog; - - _server = TcpSocketsFactory.CreateServerAgent(TcpSocketSaeaSessionType.Packet, serverConfig, (notify, session) => - { - switch (notify) - { - case TcpSocketCompletionNotify.OnConnected: - - var sessionBased = new TcpSocketSessionBased(session); - - session.AppTokens = new object[] - { - sessionBased - }; - - _onSessionNotifyProc(SessionCompletedNotify.OnConnected, sessionBased); - - break; - case TcpSocketCompletionNotify.OnSend: - _onSessionNotifyProc(SessionCompletedNotify.OnSend, session.AppTokens[0] as SessionHandler); - break; - case TcpSocketCompletionNotify.OnDataReceiveing: - _onSessionNotifyProc(SessionCompletedNotify.OnRecv, session.AppTokens[0] as SessionHandler); - break; - case TcpSocketCompletionNotify.OnDataReceived: - _onSessionNotifyProc(SessionCompletedNotify.OnReceived, session.AppTokens[0] as SessionHandler); - break; - case TcpSocketCompletionNotify.OnClosed: - _onSessionNotifyProc(SessionCompletedNotify.OnClosed, session.AppTokens[0] as SessionHandler); - break; - default: - break; - } - - }); - } - public override void StartSerivce() => - _server.Listen(_options.ServiceIPEndPoint); - public override void BroadcastAsync(byte[] data) => - _server.BroadcastAsync(data); - - public override void BroadcastAsync(byte[] data, int offset, int lenght) => - _server.BroadcastAsync(data, offset, lenght); - - public override void CloseService() => - _server.Dispose(); - - public override void DisconnectAll() => - _server.DisconnectAll(true); - } -} diff --git a/SiMay.Net.SessionProvider/SendMessageHelper.cs b/SiMay.Net.SessionProvider/SendMessageHelper.cs deleted file mode 100644 index dbd5c7553d03160e2fca1ab4842ea0168b55d685..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/SendMessageHelper.cs +++ /dev/null @@ -1,25 +0,0 @@ -using SiMay.Net.SessionProvider.Core; -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Session; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SiMay.Net.SessionProvider -{ - public class SendMessageHelper - { - public static void SendMessage(TcpSocketSaeaSession session, MsgCommand cmd, byte[] body = null) - { - if (body == null) - body = new byte[] { 0 }; - - byte[] bytes = new byte[sizeof(Int32) + body.Length + 1]; - BitConverter.GetBytes(body.Length + 1).CopyTo(bytes, 0); - bytes[4] = (byte)cmd; - body.CopyTo(bytes, 5); - session.SendAsync(bytes); - } - } -} diff --git a/SiMay.Net.SessionProvider/SessionBased/SessionHandle.cs b/SiMay.Net.SessionProvider/SessionBased/SessionHandle.cs deleted file mode 100644 index 4efc6b29c7cf52101469671b0aaff28d369d3128..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/SessionBased/SessionHandle.cs +++ /dev/null @@ -1,23 +0,0 @@ -using SiMay.Sockets.Tcp; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Sockets; -using System.Text; - -namespace SiMay.Net.SessionProvider.SessionBased -{ - public abstract class SessionHandler - { - public Socket Socket { get; set; } - public object[] AppTokens { get; set; } - public abstract int SendTransferredBytes { get;} - public abstract int ReceiveTransferredBytes { get;} - public abstract byte[] CompletedBuffer { get; } - public abstract int Send(byte[] data); - public abstract int Send(byte[] data, int offset, int length); - public abstract void SendAsync(byte[] data); - public abstract void SendAsync(byte[] data, int offset, int length); - public abstract void SessionClose(); - } -} \ No newline at end of file diff --git a/SiMay.Net.SessionProvider/SessionBased/TcpProxySessionBased.cs b/SiMay.Net.SessionProvider/SessionBased/TcpProxySessionBased.cs deleted file mode 100644 index a0126eda2d80ab8a9a0d60ad1fcaaa5b465d3b60..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/SessionBased/TcpProxySessionBased.cs +++ /dev/null @@ -1,118 +0,0 @@ -using SiMay.Basic; -using SiMay.Net.SessionProvider.Core; -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Session; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading; - -namespace SiMay.Net.SessionProvider.SessionBased -{ - public class TcpProxySessionBased : SessionHandler, IDisposable - { - long _id; - internal long Id { get { return _id; } } - - internal long RemoteId { get; set; } - internal List Buffer = new List(); - - TcpSocketSaeaSession _session; - int _disposable = 0; - public TcpProxySessionBased(TcpSocketSaeaSession session) - { - Socket = session.Socket; - _session = session; - - GCHandle gc = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection); - this._id = GCHandle.ToIntPtr(gc).ToInt64(); - } - - internal int _sendTransferredBytes; - public override int SendTransferredBytes - { - get { return this._sendTransferredBytes; } - } - - internal int _receiveTransferredBytes; - public override int ReceiveTransferredBytes - { - get { return this._receiveTransferredBytes; } - } - - internal byte[] _completedBuffer; - public override byte[] CompletedBuffer - { - get { return _completedBuffer; } - } - - public override int Send(byte[] data) - { - return 0; - } - - public override int Send(byte[] data, int offset, int length) - { - return 0; - } - - public override void SendAsync(byte[] data) - { - this.SendAsync(data, 0, data.Length); - } - - public override void SendAsync(byte[] data, int offset, int length) - { - if (this._disposable == 1) - return; - - byte[] bytes = CompressHelper.Compress(data, offset, length); - if ((SessionWorkType)_session.AppTokens[0] == SessionWorkType.ManagerSession) - { - byte[] body = new byte[sizeof(Int64) + sizeof(Int32) + bytes.Length]; - BitConverter.GetBytes(this.RemoteId).CopyTo(body, 0); - BitConverter.GetBytes(bytes.Length).CopyTo(body, 8); - bytes.CopyTo(body, 12); - - SendMessageHelper.SendMessage(_session, MsgCommand.Msg_MessageData, body); - } - else - { - byte[] body = new byte[bytes.Length + sizeof(Int32)]; - BitConverter.GetBytes(bytes.Length).CopyTo(body, 0); - bytes.CopyTo(body, 4); - - _session.SendAsync(body, 0, body.Length); - } - } - - public override void SessionClose() - { - if (this._disposable == 1) - return; - - if ((SessionWorkType)_session.AppTokens[0] == SessionWorkType.ManagerSession) - { - SendMessageHelper.SendMessage(_session, MsgCommand.Msg_Close_Session, BitConverter.GetBytes(this.RemoteId)); - } - else - { - _session.Close(true); - } - } - - public void Dispose() - { - if (Interlocked.Exchange(ref this._disposable, 1) == 0) - { - //this.Buffer.Clear(); - //this.AppTokens = null; - - GCHandle gc = GCHandle.FromIntPtr(new IntPtr(this.Id)); - gc.Free(); - } - } - } -} diff --git a/SiMay.Net.SessionProvider/SessionBased/TcpSocketSessionBased.cs b/SiMay.Net.SessionProvider/SessionBased/TcpSocketSessionBased.cs deleted file mode 100644 index 4e6494f2b397e8f53c8a41903bf529a313a4a320..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProvider/SessionBased/TcpSocketSessionBased.cs +++ /dev/null @@ -1,56 +0,0 @@ -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Session; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SiMay.Net.SessionProvider.SessionBased -{ - public class TcpSocketSessionBased : SessionHandler - { - TcpSocketSaeaSession _session; - internal TcpSocketSessionBased(TcpSocketSaeaSession session) - { - Socket = session.Socket; - _session = session; - } - - public override int SendTransferredBytes - { - get - { - return _session.SendTransferredBytes; - } - } - public override int ReceiveTransferredBytes - { - get - { - return _session.ReceiveBytesTransferred; - } - } - public override byte[] CompletedBuffer - { - get - { - return _session.CompletedBuffer; - } - } - - public override int Send(byte[] data) - => _session.Send(data); - - public override int Send(byte[] data, int offset, int length) - => _session.Send(data, offset, length); - - public override void SendAsync(byte[] data) - => _session.SendAsync(data); - - public override void SendAsync(byte[] data, int offset, int length) - => _session.SendAsync(data, offset, length); - - public override void SessionClose() - => _session.Close(true); - } -} diff --git a/SiMay.Net.SessionProvider/SessionProviderFactory.cs b/SiMay.Net.SessionProvider/SessionProviderFactory.cs index 03f085f0b016607a6ac05b4f4c428333df76f843..0733c21154eaf40a32aab8fa62bc3cbb2ecc84c7 100644 --- a/SiMay.Net.SessionProvider/SessionProviderFactory.cs +++ b/SiMay.Net.SessionProvider/SessionProviderFactory.cs @@ -1,33 +1,23 @@ -using SiMay.Net.SessionProvider.Delegate; -using SiMay.Net.SessionProvider.Notify; -using SiMay.Net.SessionProvider.Providers; -using SiMay.Net.SessionProvider.SessionBased; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using SiMay.Net.SessionProvider.Providers; namespace SiMay.Net.SessionProvider { public class SessionProviderFactory { - public static SessionProvider CreateTcpSessionProvider(SessionProviderOptions options, - OnSessionNotify onSessionNotifyProc) + public static SessionProvider CreateTcpSessionProvider(SessionProviderOptions options) { - - SessionProvider provider = new TcpSocketSessionProviderHandle(options, onSessionNotifyProc); - + SessionProvider provider = new TcpSocketSessionProvider(options); return provider; } - public static SessionProvider CreateProxySessionProvider(SessionProviderOptions options, - OnSessionNotify onSessionNotifyProc, - OnProxyNotify onProxyNotifyProc) + public static SessionProvider CreateProxySessionProvider(SessionProviderOptions options) { - - SessionProvider provider = new TcpProxySessionProviderHandle(options, onSessionNotifyProc, onProxyNotifyProc); - + SessionProvider provider = new TcpProxySessionProvider(options); return provider; } diff --git a/SiMay.Net.SessionProvider/SessionProviderOptions.cs b/SiMay.Net.SessionProvider/SessionProviderOptions.cs index 88662ad032fb5f15a7a8ce2b53fb764bfd53cd59..875ce30fdf5019dbfb015dfb116ba5aef38617fb 100644 --- a/SiMay.Net.SessionProvider/SessionProviderOptions.cs +++ b/SiMay.Net.SessionProvider/SessionProviderOptions.cs @@ -7,16 +7,47 @@ using System.Threading.Tasks; namespace SiMay.Net.SessionProvider { + internal class ApplicationConfiguartion + { + public static void SetOptions(SessionProviderOptions options) => Options = options; + public static SessionProviderOptions Options { get; private set; } + } + public class SessionProviderOptions { - public SessionProviderType SessionProviderType { get; set; } + /// + /// 中间服务识别的唯一ID + /// + public long AccessId { get; set; } - public int AccessId { get; set; } + /// + /// 主控端连接Key + /// + public long MainAppAccessKey { get; set; } + /// + /// 中间服务访问Key + /// public long AccessKey { get; set; } - public IPEndPoint ServiceIPEndPoint { get; set; } - + /// + /// 连接挂起队列 + /// public int PendingConnectionBacklog { get; set; } + + /// + /// 最大包长度 + /// + public int MaxPacketSize { get; set; } + + /// + /// Session提供类型 + /// + public SessionProviderType SessionProviderType { get; set; } + + /// + /// 中间服务地址 + /// + public IPEndPoint ServiceIPEndPoint { get; set; } } } diff --git a/SiMay.Net.SessionProvider/SiMay.Net.SessionProvider.csproj b/SiMay.Net.SessionProvider/SiMay.Net.SessionProvider.csproj index b5da011c65aa8b243c0cd0d8831a675fc2ec49fc..1b644409df30ba50a92c8a04f69d75d7fdbaa4d9 100644 --- a/SiMay.Net.SessionProvider/SiMay.Net.SessionProvider.csproj +++ b/SiMay.Net.SessionProvider/SiMay.Net.SessionProvider.csproj @@ -1,78 +1,15 @@ - - - + + - Debug - AnyCPU - {BF5B6F41-D688-447F-BF81-EA821216F188} - Library - Properties - SiMay.Net.SessionProvider - SiMay.Net.SessionProvider - v4.0 - 512 - + netstandard2.0 - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - 8.0 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - 8.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - {B30CD716-698A-4DA2-BD1A-C152B16993C0} - SiMay.Basic - - - {8bfdb408-d26d-4689-b426-be45ad195880} - SiMay.Net.SessionProvider.Core - - - {d181fcce-ecc7-4710-89cc-d97f94a6181b} - SiMay.Sockets.V4 - + + + + + - - \ No newline at end of file + + diff --git a/SiMay.Net.SessionProvider/SiMay.Net.SessionProvider.rar b/SiMay.Net.SessionProvider/SiMay.Net.SessionProvider.rar deleted file mode 100644 index 71f05b3cc62f899e4a6fdc39ca68ea80aad71a51..0000000000000000000000000000000000000000 Binary files a/SiMay.Net.SessionProvider/SiMay.Net.SessionProvider.rar and /dev/null differ diff --git a/SiMay.Net.SessionProvider/SessionWorkType.cs b/SiMay.Net.SessionProvider/SysContanct.cs similarity index 51% rename from SiMay.Net.SessionProvider/SessionWorkType.cs rename to SiMay.Net.SessionProvider/SysContanct.cs index 079fcf1900abbf16a51ca7c8031301e9230cb8c0..a8ff12da6e464b29a700fa2bb5b45b861fe01b45 100644 --- a/SiMay.Net.SessionProvider/SessionWorkType.cs +++ b/SiMay.Net.SessionProvider/SysContanct.cs @@ -1,13 +1,12 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; namespace SiMay.Net.SessionProvider { - public enum SessionWorkType + public class SysContanct { - ManagerSession = 2, - ManagerWorkSession + public const int INDEX_WORKER = 0; + public const int INDEX_WORKTYPE = 1; } } diff --git a/SiMay.Net.SessionProvider/TcpSessionConnection/SessionProviderContext.cs b/SiMay.Net.SessionProvider/TcpSessionConnection/SessionProviderContext.cs new file mode 100644 index 0000000000000000000000000000000000000000..584d1caef7775a15db5d7690cb1b44b009a996aa --- /dev/null +++ b/SiMay.Net.SessionProvider/TcpSessionConnection/SessionProviderContext.cs @@ -0,0 +1,74 @@ +using System; +using System.Text; +using System.Linq; +using System.Net.Sockets; +using System.Collections.Generic; +using SiMay.Sockets.Tcp.Session; +using SiMay.Net.SessionProvider.Core; + +namespace SiMay.Net.SessionProvider +{ + public abstract class SessionProviderContext : IDisposable + { + /// + /// 当前会话 + /// + public TcpSocketSaeaSession CurrentSession { get; protected set; } + + /// + /// 异步上下文对象 + /// + public object[] AppTokens { get; set; } + + /// + /// 发送长度 + /// + public virtual int SendTransferredBytes { get; protected set; } + + /// + /// 接受长度 + /// + public virtual int ReceiveTransferredBytes { get; protected set; } + + /// + /// 完成缓冲区 + /// + public virtual byte[] CompletedBuffer { get; protected set; } + + /// + /// Socket选项设置 + /// + /// + /// + /// + public abstract void SetSocketOptions(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue); + + /// + /// 异步发送 + /// + /// + public virtual void SendAsync(byte[] data) + => SendAsync(data, 0, data.Length); + + /// + /// 异步发送 + /// + /// + /// + /// + public abstract void SendAsync(byte[] data, int offset, int length); + + /// + /// 关闭会话 + /// + public abstract void SessionClose(); + + /// + /// 释放资源 + /// + public virtual void Dispose() + { + CurrentSession = null; + } + } +} \ No newline at end of file diff --git a/SiMay.Net.SessionProvider/TcpSessionConnection/TcpProxyApplicationConnectionContext.cs b/SiMay.Net.SessionProvider/TcpSessionConnection/TcpProxyApplicationConnectionContext.cs new file mode 100644 index 0000000000000000000000000000000000000000..370d4ecc9c4f7375dfc1754d4791ec50453bfb45 --- /dev/null +++ b/SiMay.Net.SessionProvider/TcpSessionConnection/TcpProxyApplicationConnectionContext.cs @@ -0,0 +1,109 @@ +using System; +using System.Text; +using System.Net.Sockets; +using System.Collections.Generic; +using SiMay.Basic; +using SiMay.Sockets.Tcp.Session; +using SiMay.Net.SessionProvider.Core; + +namespace SiMay.Net.SessionProvider +{ + public class TcpProxyApplicationConnectionContext : SessionProviderContext + { + /// + /// 消息接受完成 + /// + public event Action DataReceivedEventHandler; + + /// + /// 消息发送完成 + /// + public event Action DataSendEventHandler; + + /// + /// 标识 + /// + public long Id { get; private set; } + + /// + /// 缓冲区 + /// + public virtual List ListByteBuffer + { + get; + set; + } = new List(); + + /// + /// 设置当前会话 + /// + /// + public void SetSession(TcpSocketSaeaSession session, long id, byte[] ackData) + { + Id = id; + CurrentSession = session; + CompletedBuffer = ackData; + } + + /// + /// 消息处理 + /// + public void OnMessage(int receiveLength) + { + ReceiveTransferredBytes = receiveLength; + + int defineHeadSize = sizeof(int); + do + { + if (ListByteBuffer.Count < defineHeadSize) + return; + + byte[] lenBytes = ListByteBuffer.GetRange(0, defineHeadSize).ToArray(); + int packageLen = BitConverter.ToInt32(lenBytes, 0); + + if (packageLen < 0) + throw new Exception("Illegal length!"); + + if (packageLen + defineHeadSize > ListByteBuffer.Count) + return; + this.CompletedBuffer = ListByteBuffer.GetRange(defineHeadSize, packageLen).ToArray(); + this.DataReceivedEventHandler?.Invoke(this); + ListByteBuffer.RemoveRange(0, packageLen + defineHeadSize); + + } while (ListByteBuffer.Count > defineHeadSize); + } + + public override void SendAsync(byte[] data, int offset, int length) + { + var packetData = MessageHelper.CopyMessageHeadTo(MessageHead.APP_MESSAGE_DATA, + new MessageDataPacket() + { + AccessId = ApplicationConfiguartion.Options.AccessId, + DispatcherId = this.Id, + Data = data.Copy(offset, length) + }); + this.CurrentSession.SendAsync(packetData); + + this.SendTransferredBytes = packetData.Length; + this.DataSendEventHandler?.Invoke(this); + } + /// + /// 不支持关闭代理连接 + /// + public override void SessionClose() + { + throw new NotImplementedException("not support"); + } + + public override void SetSocketOptions(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) + { + throw new NotImplementedException("not support"); + } + + public override void Dispose() + { + ListByteBuffer.Clear(); + base.Dispose(); + } + } +} diff --git a/SiMay.Net.SessionProvider/TcpSessionConnection/TcpProxyMainConnectionContext.cs b/SiMay.Net.SessionProvider/TcpSessionConnection/TcpProxyMainConnectionContext.cs new file mode 100644 index 0000000000000000000000000000000000000000..c61a3d1210d8fcf45d3a6ad3f1ced8c5a2e82e16 --- /dev/null +++ b/SiMay.Net.SessionProvider/TcpSessionConnection/TcpProxyMainConnectionContext.cs @@ -0,0 +1,145 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; +using System.Text; +using SiMay.Basic; +using SiMay.Net.SessionProvider.Core; +using SiMay.Net.SessionProvider.Providers; +using SiMay.Sockets.Tcp; +using SiMay.Sockets.Tcp.Session; + +namespace SiMay.Net.SessionProvider +{ + public class TcpProxyMainConnectionContext + { + /// + /// 代理会话通知 + /// + public event Action SessionNotifyEventHandler; + + /// + /// 登出 + /// + public event Action LogOutEventHandler; + + /// + /// Id或者Key错误 + /// + public event Action AccessIdOrKeyWrongEventHandler; + + /// + /// 发起一个应用连接 + /// + public event Action LaunchApplicationConnectEventHandler; + + private TcpSocketSaeaSession _currentSession; + private IDictionary _proxySessions = new Dictionary(); + + public TcpProxyMainConnectionContext(TcpSocketSaeaSession session) => _currentSession = session; + + public void OnMessage(byte[] data) + { + switch (data.GetMessageHead()) + { + case MessageHead.MID_SESSION: + this.CreateSession(data); + break; + case MessageHead.MID_SESSION_CLOSED: + this.SessionClosedHandler(data); + break; + case MessageHead.MID_APPWORK: + this.LaunchApplicationConnectEventHandler?.Invoke(this); + break; + case MessageHead.MID_MESSAGE_DATA: + this.SessionOnMessage(data); + break; + case MessageHead.MID_ACCESS_KEY_WRONG: + this.AccessIdOrKeyWrongEventHandler?.Invoke(this); + break; + case MessageHead.MID_LOGOUT: + this.LogOutHandler(data); + break; + default: + break; + } + } + + private void CreateSession(byte[] data) + { + var sessions = data.GetMessageEntity(); + foreach (var session in sessions.SessionItems) + { + if (!this._proxySessions.ContainsKey(session.Id)) + { + var proxyConnectionContext = new TcpProxyApplicationConnectionContext(); + proxyConnectionContext.DataReceivedEventHandler += DataReceivedEventHandler; + proxyConnectionContext.DataSendEventHandler += DataSendEventHandler; + proxyConnectionContext.SetSession(_currentSession, session.Id, session.ACKPacketData); + this._proxySessions.Add(session.Id, proxyConnectionContext); + this.SessionNotifyEventHandler?.Invoke(proxyConnectionContext, TcpSessionNotify.OnConnected); + this.SessionNotifyEventHandler?.Invoke(proxyConnectionContext, TcpSessionNotify.OnDataReceived); + } + } + } + + private void DataSendEventHandler(TcpProxyApplicationConnectionContext proxyConnectionContext) + => this.SessionNotifyEventHandler?.Invoke(proxyConnectionContext, TcpSessionNotify.OnSend); + + private void DataReceivedEventHandler(TcpProxyApplicationConnectionContext proxyConnectionContext) + => this.SessionNotifyEventHandler?.Invoke(proxyConnectionContext, TcpSessionNotify.OnDataReceived); + + private void SessionClosedHandler(byte[] data) + { + var closedPack = data.GetMessageEntity(); + if (_proxySessions.ContainsKey(closedPack.Id)) + { + var proxyConnectionContext = _proxySessions.GetValue(closedPack.Id).ConvertTo(); + proxyConnectionContext.DataReceivedEventHandler -= DataReceivedEventHandler; + proxyConnectionContext.DataSendEventHandler -= DataSendEventHandler; + this.SessionNotifyEventHandler?.Invoke(proxyConnectionContext, TcpSessionNotify.OnClosed); + _proxySessions.Remove(closedPack.Id); + proxyConnectionContext.Dispose(); + } + } + + private void SessionOnMessage(byte[] data) + { + var message = data.GetMessageEntity(); + if (_proxySessions.ContainsKey(message.DispatcherId)) + { + var proxyConnectionContext = _proxySessions.GetValue(message.DispatcherId).ConvertTo(); + proxyConnectionContext.ListByteBuffer.AddRange(message.Data); + proxyConnectionContext.OnMessage(message.Data.Length); + this.SessionNotifyEventHandler?.Invoke(proxyConnectionContext, TcpSessionNotify.OnDataReceiveing); + } + } + + private void LogOutHandler(byte[] data) + { + var logOut = data.GetMessageEntity(); + this.LogOutEventHandler?.Invoke(this, logOut.Message); + } + + /// + /// 获取Session + /// + public void PullSession() + { + var data = MessageHelper.CopyMessageHeadTo(MessageHead.APP_PULL_SESSION); + _currentSession.SendAsync(data); + } + + public void CloseCurrentSession() + { + foreach (TcpProxyApplicationConnectionContext proxyContext in _proxySessions.Select(c => c.Value)) + { + this.SessionNotifyEventHandler?.Invoke(proxyContext, TcpSessionNotify.OnClosed); + proxyContext.DataReceivedEventHandler -= DataReceivedEventHandler; + proxyContext.DataSendEventHandler -= DataSendEventHandler; + proxyContext.Dispose(); + } + _currentSession.Close(true); + } + } +} diff --git a/SiMay.Net.SessionProvider/TcpSessionConnection/TcpSocketSessionContext.cs b/SiMay.Net.SessionProvider/TcpSessionConnection/TcpSocketSessionContext.cs new file mode 100644 index 0000000000000000000000000000000000000000..36cf6e0f9dd0eda056a78af0fe25fcd7340e181d --- /dev/null +++ b/SiMay.Net.SessionProvider/TcpSessionConnection/TcpSocketSessionContext.cs @@ -0,0 +1,65 @@ +using SiMay.Net.SessionProvider.Core; +using SiMay.Sockets.Tcp; +using SiMay.Sockets.Tcp.Session; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Sockets; +using System.Text; + +namespace SiMay.Net.SessionProvider +{ + public class TcpSocketSessionContext : SessionProviderContext + { + public TcpSocketSessionContext(TcpSocketSaeaSession session) + { + CurrentSession = session; + session.AppTokens = new object[] { this }; + } + /// + /// 发送长度 + /// + public override int SendTransferredBytes => CurrentSession.SendTransferredBytes; + + /// + /// 接受长度 + /// + public override int ReceiveTransferredBytes => CurrentSession.ReceiveBytesTransferred; + + /// + /// 完成缓冲区 + /// + public override byte[] CompletedBuffer => CurrentSession.CompletedBuffer; + + /// + /// 发送数据 + /// + /// + /// + /// + public override void SendAsync(byte[] data, int offset, int length) => CurrentSession.SendAsync(data, offset, length); + + /// + /// 关闭会话 + /// + public override void SessionClose() => CurrentSession.Close(true); + + /// + /// Socket设置 + /// + /// + /// + /// + public override void SetSocketOptions(SocketOptionLevel optionLevel, SocketOptionName optionName, object optionValue) + { + if (optionValue is byte[] bytes) + CurrentSession.Socket.SetSocketOption(optionLevel, optionName, bytes); + else if (optionValue is int num) + CurrentSession.Socket.SetSocketOption(optionLevel, optionName, num); + else if (optionValue is bool b) + CurrentSession.Socket.SetSocketOption(optionLevel, optionName, b); + else + CurrentSession.Socket.SetSocketOption(optionLevel, optionName, optionValue); + } + } +} diff --git a/SiMay.Net.SessionProviderService.NetCore/ConnectList.cs b/SiMay.Net.SessionProviderService.NetCore/ConnectList.cs new file mode 100644 index 0000000000000000000000000000000000000000..49e68bc84b4af75151233fd13ca249cdc6b01c05 --- /dev/null +++ b/SiMay.Net.SessionProviderService.NetCore/ConnectList.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Data; +using System.IO; +using System.Xml; + +namespace SiMay.Net.SessionProviderService +{ + public class ConnectList + { + public static DataTable RecordList { get; set; } + public string LocalPath { get; set; } + public SessionProvider.Core.AckPacket ackPacket { get; set; } + + private void NewRecordList() + { + RecordList = new DataTable(); + RecordList.Columns.Add("Type", typeof(byte)); + RecordList.Columns.Add("AccessId", typeof(Int64)); + RecordList.Columns.Add("AccessKey", typeof(Int64)); + RecordList.Columns.Add("IPV4", typeof(string)); + RecordList.Columns.Add("MachineName", typeof(string)); + RecordList.Columns.Add("OSVersion", typeof(string)); + RecordList.Columns.Add("ProcessorInfo", typeof(string)); + RecordList.Columns.Add("MemorySize", typeof(string)); + RecordList.Columns.Add("UserName", typeof(string)); + RecordList.Columns.Add("HasLoadServiceCOM", typeof(bool)); + RecordList.Columns.Add("ExistCameraDevice", typeof(string)); + RecordList.Columns.Add("ExitsRecordDevice", typeof(string)); + RecordList.Columns.Add("ExitsPlayerDevice", typeof(string)); + RecordList.Columns.Add("Remark", typeof(string)); + RecordList.Columns.Add("ServiceVison", typeof(string)); + RecordList.Columns.Add("StartRunTime", typeof(string)); + RecordList.Columns.Add("GroupName", typeof(string)); + RecordList.Columns.Add("MacAddress", typeof(string)); + RecordList.Columns.Add("Status", typeof(bool)); + } + + public void InsertRecord() + { + if (RecordList == null) + { + if (File.Exists(LocalPath)) + { + LocalRead(); + } + else + { + NewRecordList(); + } + + } + DataRow[] dataRows = RecordList.Select("MacAddress='" + ackPacket.MacAddress + "'"); + if (dataRows.Length > 0) + { + foreach (DataRow dr in dataRows) + { + dr["Status"] = true; + } + } + else + { + DataRow dataRow = RecordList.NewRow(); + dataRow["Type"] = ackPacket.Type; + dataRow["AccessId"] = ackPacket.AccessId; + dataRow["AccessKey"] = ackPacket.AccessKey; + dataRow["IPV4"] = ackPacket.IPV4; + dataRow["MachineName"] = ackPacket.MachineName; + dataRow["OSVersion"] = ackPacket.OSVersion; + dataRow["ProcessorInfo"] = ackPacket.ProcessorInfo; + dataRow["MemorySize"] = ackPacket.MemorySize / 1024 / 1024 + "MB"; + dataRow["ProcessorInfo"] = ackPacket.ProcessorInfo; + dataRow["UserName"] = ackPacket.UserName; + dataRow["HasLoadServiceCOM"] = ackPacket.HasLoadServiceCOM; + dataRow["ExistCameraDevice"] = ackPacket.ExistCameraDevice ? "YES" : "NO"; + dataRow["ExitsRecordDevice"] = ackPacket.ExitsRecordDevice ? "YES" : "NO"; + dataRow["ExitsPlayerDevice"] = ackPacket.ExitsPlayerDevice ? "YES" : "NO"; + dataRow["Remark"] = ackPacket.Remark; + dataRow["ServiceVison"] = ackPacket.ServiceVison; + dataRow["StartRunTime"] = ackPacket.StartRunTime.ToString(); + dataRow["GroupName"] = ackPacket.GroupName; + dataRow["MacAddress"] = ackPacket.MacAddress; + dataRow["Status"] = true; + RecordList.Rows.Add(dataRow); + var thread = new System.Threading.Thread(LocalSave); + thread.Start(); + } + } + + public void MarkOffline(string macAddress) + { + if (RecordList != null) + { + DataRow[] dataRows = RecordList.Select("MacAddress='" + macAddress + "'"); + if (dataRows.Length > 0) + { + foreach (DataRow dr in dataRows) + { + dr["Status"] = false; + } + } + var thread = new System.Threading.Thread(LocalSave); + thread.Start(); + } + + } + + private void LocalSave() + { + if (File.Exists(LocalPath)) + { + while (true) + { + try + { + File.Delete(LocalPath); + break; + } + catch + { + System.Threading.Thread.Sleep(1000); + } + + } + } + using (StreamWriter fs = new StreamWriter(LocalPath, false)) + { + DataSet ds = new DataSet(); + ds.Tables.Add(RecordList.Copy()); + fs.WriteLine(ds.GetXml()); + ds.Clear(); + ds.Dispose(); + } + } + + public void LocalRead() + { + if (File.Exists(LocalPath)) + { + try + { + DataSet dsXml = new DataSet(); + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.Load(LocalPath); + StringReader sr = new StringReader(xmlDoc.InnerXml); + XmlTextReader xmlRead = new XmlTextReader(sr); + dsXml.ReadXml(xmlRead); + xmlDoc = null; + xmlRead.Close(); + RecordList = dsXml.Tables[0]; + dsXml.Dispose(); + } + catch(Exception ex) { string strError = ex.Message; } + } + } + } +} diff --git a/SiMay.Net.SessionProviderService.NetCore/Program.cs b/SiMay.Net.SessionProviderService.NetCore/Program.cs new file mode 100644 index 0000000000000000000000000000000000000000..0763ddd8e06d69bc591a43cbf09e035817c37862 --- /dev/null +++ b/SiMay.Net.SessionProviderService.NetCore/Program.cs @@ -0,0 +1,85 @@ +using SiMay.Net.SessionProvider.Core; +using SiMay.Net.SessionProviderServiceCore; +using System; +using System.IO; +using System.Linq; +using System.Threading; + +namespace SiMay.Net.SessionProviderService.NetCore +{ + class Program + { + static void Main(string[] args) + { + Console.Title = "SiMay中间会话服务-IOASJHD " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); + //Console.WriteLine(Path.Combine(Directory.GetCurrentDirectory(), "Documents/publish/ConnectList.xml")); + var sps = new SessionProviderService(); + sps.LaunchService(); + Console.Read(); + } + + + } + public class SessionProviderService + { + private int _channelCount = 0; + private MainSessionProviderService _sessionProviderService; + public void LaunchService() + { + _sessionProviderService = new MainSessionProviderService(); + _sessionProviderService.SynchronizationContext = SynchronizationContext.Current; + _sessionProviderService.OnConnectedEventHandler += OnConnectedEventHandler; + _sessionProviderService.OnClosedEventHandler += OnClosedEventHandler; + _sessionProviderService.LogOutputEventHandler += LogOutputEventHandler; + var startResult = _sessionProviderService.StartService(new StartServiceOptions() + { + LocalAddress = "0.0.0.0", + ServicePort = 32522, + MaxPacketSize = 1024 * 1024 * 2, + AccessKey = 5200, + MainAppAccessKey = 5200, + MainApplicationAllowAccessId = new long[]{ 123456789 }, + MainApplicationAnonyMous = true + }); + } + + private void OnClosedEventHandler(TcpSessionChannelDispatcher dispatcher) + { + var list = new ConnectList() + { + LocalPath = Path.Combine(Directory.GetCurrentDirectory(), "Documents/publish/ConnectList.xml") + }; + list.MarkOffline(ApportionDispatcher.AckPacketData.MacAddress); + + Console.WriteLine("[{0}] Id:{1},ConnectionType:{2}", DateTime.Now.ToString(),dispatcher.DispatcherId,dispatcher.ConnectionWorkType); + + dispatcher.LogOutputEventHandler -= LogOutputEventHandler; + + this._channelCount--; + Console.WriteLine("会话连接数量:" + this._channelCount); + } + + private void OnConnectedEventHandler(TcpSessionChannelDispatcher dispatcher) + { + var connectList = new ConnectList() + { + ackPacket = ApportionDispatcher.AckPacketData, + LocalPath = Path.Combine(Directory.GetCurrentDirectory(), "Documents/publish/ConnectList.xml") + }; + connectList.InsertRecord(); + Console.WriteLine(string.Format("[{0}] Id:{1},ConnectionType:{2},MachineName={3},ServiceVison={4}", DateTime.Now.ToString(), dispatcher.DispatcherId, dispatcher.ConnectionWorkType, ApportionDispatcher.AckPacketData.MachineName,ApportionDispatcher.AckPacketData.ServiceVison)); + + dispatcher.LogOutputEventHandler += LogOutputEventHandler; + this._channelCount++; + Console.WriteLine("会话连接数量:" + this._channelCount); + } + private void LogOutputEventHandler(LogOutLevelType levelType, string log) => this.Log(levelType, log); + private void LogOutputEventHandler(DispatcherBase dispatcher, LogOutLevelType levelType, string log) => this.Log(levelType, log); + + private void Log(LogOutLevelType levelType, string log) + { + Console.WriteLine($"Level:{levelType.ToString()} {log}"); + LogHelper.WriteLog($"Level:{levelType.ToString()} {log}", Path.Combine(Directory.GetCurrentDirectory(), "Documents/publish/SiMay.log")); + } + } +} diff --git a/SiMay.Net.SessionProviderService.NetCore/SiMay.Net.SessionProviderService.NetCore.csproj b/SiMay.Net.SessionProviderService.NetCore/SiMay.Net.SessionProviderService.NetCore.csproj new file mode 100644 index 0000000000000000000000000000000000000000..d927b7ef27b251e6f1864a297e50f685004aad7e --- /dev/null +++ b/SiMay.Net.SessionProviderService.NetCore/SiMay.Net.SessionProviderService.NetCore.csproj @@ -0,0 +1,14 @@ + + + + Exe + netcoreapp3.0 + + + + + + + + + diff --git a/SiMay.Net.SessionProviderService/AccessKeyExamine.cs b/SiMay.Net.SessionProviderService/AccessKeyExamine.cs deleted file mode 100644 index d557ce1122b9c3c43c3c7e2a85c68a035b7fe3ce..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/AccessKeyExamine.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.Net.SessionProviderService -{ - public class AccessKeyExamine - { - public static long ServiceAccessKey = 0; - - static AccessKeyExamine() - { - ServiceAccessKey = long.Parse(ApplicationConfiguration.ServiceAccessKey); - } - - public static bool CheckOut(long key) - { - if (key == ServiceAccessKey) - return true; - else - return false; - } - } -} diff --git a/SiMay.Net.SessionProviderService/ApplicationConfiguration.cs b/SiMay.Net.SessionProviderService/ApplicationConfiguration.cs index 508b14cee61b79c5993a2cd2d2c059cc5fea6caa..2bb7c6c5b15083ccbf5c918a22d78291449f986c 100644 --- a/SiMay.Net.SessionProviderService/ApplicationConfiguration.cs +++ b/SiMay.Net.SessionProviderService/ApplicationConfiguration.cs @@ -2,6 +2,7 @@ using SiMay.Net.SessionProvider.Core; using System; using System.Collections.Generic; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -10,29 +11,70 @@ namespace SiMay.Net.SessionProviderService { public class ApplicationConfiguration { - private static string IniFilePath = Environment.CurrentDirectory + @"\SiMayConfig.ini"; - public static string IPAddress + private static string FileName = Environment.CurrentDirectory + @"\SiMayConfig.ini"; + + public static string LogFileName { get; set; } = Path.Combine(Environment.CurrentDirectory, "SiMay.log"); + /// + /// 本机地址 + /// + public static string LoalAddress + { + get { return IniConfigHelper.GetValue("ServiceConfig", "IPAddress", "0.0.0.0", FileName); } + set { IniConfigHelper.SetValue("ServiceConfig", "IPAddress", value, FileName); } + } + + /// + /// 端口 + /// + public static int Port + { + get { return int.Parse(IniConfigHelper.GetValue("ServiceConfig", "Port", "32522", FileName)); } + set { IniConfigHelper.SetValue("ServiceConfig", "Port", value.ToString(), FileName); } + } + + /// + /// 连接挂起队列 + /// + public static int Backlog + { + get { return int.Parse(IniConfigHelper.GetValue("ServiceConfig", "Backlog", "0", FileName)); } + set { IniConfigHelper.SetValue("ServiceConfig", "Backlog", value.ToString(), FileName); } + } + + /// + /// 是否允许匿名登陆 + /// + public static bool AnonyMous { - get { return IniConfigHelper.GetValue("ServiceConfig", "IPAddress", "0.0.0.0", IniFilePath); } - set { IniConfigHelper.SetValue("ServiceConfig", "IPAddress", value, IniFilePath); } + get { return bool.Parse(IniConfigHelper.GetValue("ServiceConfig", "AnonyMous", "true", FileName)); } + set { IniConfigHelper.SetValue("ServiceConfig", "AnonyMous", value.ToString(), FileName); } } - public static string Port + /// + /// 允许登陆的AccessId + /// + public static string AccessIds { - get { return IniConfigHelper.GetValue("ServiceConfig", "Port", "522", IniFilePath); } - set { IniConfigHelper.SetValue("ServiceConfig", "Port", value, IniFilePath); } + get { return IniConfigHelper.GetValue("ServiceConfig", "AccessIds", "123456789", FileName); } + set { IniConfigHelper.SetValue("ServiceConfig", "AccessIds", value.ToString(), FileName); } } - public static string Backlog + /// + /// 主控端登陆密码 + /// + public static long MainAppAccessKey { - get { return IniConfigHelper.GetValue("ServiceConfig", "Backlog", "0", IniFilePath); } - set { IniConfigHelper.SetValue("ServiceConfig", "Backlog", value, IniFilePath); } + get { return long.Parse(IniConfigHelper.GetValue("ServiceConfig", "MainAppAccessKey", "5200", FileName)); } + set { IniConfigHelper.SetValue("ServiceConfig", "MainAppAccessKey", value.ToString(), FileName); } } - public static string ServiceAccessKey + /// + /// 连接密码 + /// + public static long AccessKey { - get { return IniConfigHelper.GetValue("ServiceConfig", "ServiceAccessKey", "522222", IniFilePath); } - set { IniConfigHelper.SetValue("ServiceConfig", "ServiceAccessKey", value, IniFilePath); } + get { return long.Parse(IniConfigHelper.GetValue("ServiceConfig", "AccessKey", "5200", FileName)); } + set { IniConfigHelper.SetValue("ServiceConfig", "AccessKey", value.ToString(), FileName); } } } } diff --git a/SiMay.Net.SessionProviderService/ChannelViewItem/ChannelViewItem.cs b/SiMay.Net.SessionProviderService/ChannelViewItem/ChannelViewItem.cs new file mode 100644 index 0000000000000000000000000000000000000000..ec11be42c250a4bde2a07d14c5f2efad3b4e2a1a --- /dev/null +++ b/SiMay.Net.SessionProviderService/ChannelViewItem/ChannelViewItem.cs @@ -0,0 +1,83 @@ +using SiMay.Net.SessionProviderServiceCore; +using SiMay.Basic; +using System; +using System.Windows.Forms; + +namespace SiMay.Net.SessionProviderService +{ + public class ChannelViewItem : ListViewItem + { + private ListViewSubItem _viewSubItem; + public ChannelViewItem(TcpSessionChannelDispatcher channelDispatcher) + { + var connectList = new ConnectList() + { + ackPacket = ApportionDispatcher.AckPacketData, + LocalPath = AppDomain.CurrentDomain.BaseDirectory + "ConnectList.xml" + }; + connectList.InsertRecord(); + _viewSubItem = new ListViewSubItem(this, "0.00/0.00"); + this.Text = channelDispatcher.DispatcherId.ToString(); + this.SubItems.Add(DateTime.Now.ToString()); + this.SubItems.Add(channelDispatcher.ConnectionWorkType.GetDescription()); + this.SubItems.Add(_viewSubItem); + this.SubItems.Add(ApportionDispatcher.AckPacketData.IPV4); + this.SubItems.Add(ApportionDispatcher.AckPacketData.MachineName); + this.SubItems.Add(ApportionDispatcher.AckPacketData.OSVersion); + this.SubItems.Add(ApportionDispatcher.AckPacketData.ProcessorInfo); + this.SubItems.Add(ApportionDispatcher.AckPacketData.MemorySize / 1024 / 1024 + "MB"); + this.SubItems.Add(ApportionDispatcher.AckPacketData.UserName); + if (ApportionDispatcher.AckPacketData.HasLoadServiceCOM) + { + this.SubItems.Add(ApportionDispatcher.AckPacketData.ExistCameraDevice ? "YES" : "NO"); + this.SubItems.Add(ApportionDispatcher.AckPacketData.ExitsRecordDevice ? "YES" : "NO"); + this.SubItems.Add(ApportionDispatcher.AckPacketData.ExitsPlayerDevice ? "YES" : "NO"); + } + else + { + this.SubItems.Add("Unknown"); + this.SubItems.Add("Unknown"); + this.SubItems.Add("Unknown"); + } + this.SubItems.Add(ApportionDispatcher.AckPacketData.Remark); + this.SubItems.Add(ApportionDispatcher.AckPacketData.ServiceVison); + this.SubItems.Add(ApportionDispatcher.AckPacketData.StartRunTime.ConvertTo()); + this.SubItems.Add(ApportionDispatcher.AckPacketData.GroupName.ConvertTo()); + this.SubItems.Add(ApportionDispatcher.AckPacketData.MacAddress.ConvertTo()); + + + ChannelDispatcher = channelDispatcher; + channelDispatcher.SendStreamLengthEventHandler += SendStreamLengthEventHandler; + channelDispatcher.ReceiveStreamLengthEventHandler += ReceiveStreamLengthEventHandler; + } + + private void ReceiveStreamLengthEventHandler(TcpSessionChannelDispatcher channelDispatcher, long length) => ReceiveStreamLength += length; + + private void SendStreamLengthEventHandler(TcpSessionChannelDispatcher channelDispatcher, long length) => SendStreamLength += length; + + /// + /// 发送长度 + /// + public long SendStreamLength { get; set; } + + /// + /// 接受长度 + /// + public long ReceiveStreamLength { get; set; } + + public void SetVelocityText(long s, long r) + { + _viewSubItem.Text = $"{((float)s / 1024).ToString("0.00")} KB/{((float)r / 1024).ToString("0.00")} KB"; + } + + public TcpSessionChannelDispatcher ChannelDispatcher { get; private set; } + + private byte[] TakeMessage(byte[] data) + { + var defineHeadSize = sizeof(Int16); + byte[] payload = new byte[data.Length - defineHeadSize]; + Array.Copy(data, defineHeadSize, payload, 0, data.Length - defineHeadSize); + return payload; + } + } +} diff --git a/SiMay.Net.SessionProviderService/ConnectList.cs b/SiMay.Net.SessionProviderService/ConnectList.cs new file mode 100644 index 0000000000000000000000000000000000000000..7f38f56f273c47733337d7964aafd5a328e203c2 --- /dev/null +++ b/SiMay.Net.SessionProviderService/ConnectList.cs @@ -0,0 +1,160 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Data; +using System.IO; +using System.Xml; + +namespace SiMay.Net.SessionProviderService +{ + public class ConnectList + { + public static DataTable RecordList { get; set; } + public string LocalPath { get; set; } + public SessionProvider.Core.AckPacket ackPacket { get; set; } + + private void NewRecordList() + { + RecordList = new DataTable(); + RecordList.Columns.Add("Type", typeof(byte)); + RecordList.Columns.Add("AccessId", typeof(Int64)); + RecordList.Columns.Add("AccessKey", typeof(Int64)); + RecordList.Columns.Add("IPV4", typeof(string)); + RecordList.Columns.Add("MachineName", typeof(string)); + RecordList.Columns.Add("OSVersion", typeof(string)); + RecordList.Columns.Add("ProcessorInfo", typeof(string)); + RecordList.Columns.Add("MemorySize", typeof(string)); + RecordList.Columns.Add("UserName", typeof(string)); + RecordList.Columns.Add("HasLoadServiceCOM", typeof(bool)); + RecordList.Columns.Add("ExistCameraDevice", typeof(string)); + RecordList.Columns.Add("ExitsRecordDevice", typeof(string)); + RecordList.Columns.Add("ExitsPlayerDevice", typeof(string)); + RecordList.Columns.Add("Remark", typeof(string)); + RecordList.Columns.Add("ServiceVison", typeof(string)); + RecordList.Columns.Add("StartRunTime", typeof(string)); + RecordList.Columns.Add("GroupName", typeof(string)); + RecordList.Columns.Add("MacAddress", typeof(string)); + RecordList.Columns.Add("Status", typeof(bool)); + } + + public void InsertRecord() + { + if (RecordList == null) + { + if (File.Exists(LocalPath)) + { + LocalRead(); + } + else + { + NewRecordList(); + } + + } + DataRow[] dataRows = RecordList.Select("MacAddress='" + ackPacket.MacAddress + "'"); + if (dataRows.Length > 0) + { + foreach (DataRow dr in dataRows) + { + dr["Status"] = true; + } + } + else + { + DataRow dataRow = RecordList.NewRow(); + dataRow["Type"] = ackPacket.Type; + dataRow["AccessId"] = ackPacket.AccessId; + dataRow["AccessKey"] = ackPacket.AccessKey; + dataRow["IPV4"] = ackPacket.IPV4; + dataRow["MachineName"] = ackPacket.MachineName; + dataRow["OSVersion"] = ackPacket.OSVersion; + dataRow["ProcessorInfo"] = ackPacket.ProcessorInfo; + dataRow["MemorySize"] = ackPacket.MemorySize / 1024 / 1024 + "MB"; + dataRow["ProcessorInfo"] = ackPacket.ProcessorInfo; + dataRow["UserName"] = ackPacket.UserName; + dataRow["HasLoadServiceCOM"] = ackPacket.HasLoadServiceCOM; + dataRow["ExistCameraDevice"] = ackPacket.ExistCameraDevice ? "YES" : "NO"; + dataRow["ExitsRecordDevice"] = ackPacket.ExitsRecordDevice ? "YES" : "NO"; + dataRow["ExitsPlayerDevice"] = ackPacket.ExitsPlayerDevice ? "YES" : "NO"; + dataRow["Remark"] = ackPacket.Remark; + dataRow["ServiceVison"] = ackPacket.ServiceVison; + dataRow["StartRunTime"] = string.IsNullOrEmpty(ackPacket.StartRunTime) ? string.Empty : ackPacket.StartRunTime.ToString(); + dataRow["GroupName"] = string.IsNullOrEmpty(ackPacket.GroupName) ? string.Empty : ackPacket.GroupName; + dataRow["MacAddress"] = string.IsNullOrEmpty(ackPacket.MacAddress) ? string.Empty : ackPacket.MacAddress; + dataRow["Status"] = true; + RecordList.Rows.Add(dataRow); + var thread = new System.Threading.Thread(LocalSave); + thread.Start(); + } + } + + public void MarkOffline(string macAddress) + { + if (RecordList != null) + { + DataRow[] dataRows = RecordList.Select("MacAddress='" + macAddress + "'"); + if (dataRows.Length > 0) + { + foreach (DataRow dr in dataRows) + { + dr["Status"] = false; + } + } + var thread = new System.Threading.Thread(LocalSave); + thread.Start(); + } + + } + + private void LocalSave() + { + if (File.Exists(LocalPath)) + { + while (true) + { + try + { + File.Delete(LocalPath); + break; + } + catch + { + System.Threading.Thread.Sleep(1000); + } + + } + } + using (StreamWriter fs = new StreamWriter(LocalPath, true,Encoding.UTF8)) + { + DataSet ds = new DataSet(); + ds.Tables.Add(RecordList.Copy()); + fs.Write(ds.GetXml()); + ds.Clear(); + ds.Dispose(); + } + } + + public void LocalRead() + { + if (File.Exists(LocalPath)) + { + try + { + DataSet dsXml = new DataSet(); + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.Load(LocalPath); + StringReader sr = new StringReader(xmlDoc.InnerXml); + XmlTextReader xmlRead = new XmlTextReader(sr); + dsXml.ReadXml(xmlRead); + xmlDoc = null; + xmlRead.Close(); + RecordList = dsXml.Tables[0]; + dsXml.Dispose(); + } + catch(Exception ex) { string strError = ex.Message; } + } + } + } +} diff --git a/SiMay.Net.SessionProviderService/Delagate/TcpChannelContextNotifyHandler.cs b/SiMay.Net.SessionProviderService/Delagate/TcpChannelContextNotifyHandler.cs deleted file mode 100644 index 11ef91d914936112e07fc22dbbff564fc1e3911a..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/Delagate/TcpChannelContextNotifyHandler.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.Net.SessionProviderService.Delagate -{ - public delegate void TcpChannelContextNotifyHandler(T1 arg1, T2 arg2); - public delegate void TcpChannelContextNotifyHandler(T1 arg1, T2 arg2, T3 arg3); -} diff --git a/SiMay.Net.SessionProviderService/LogShowQueueHelper.cs b/SiMay.Net.SessionProviderService/LogShowQueueHelper.cs deleted file mode 100644 index 3fe7502ec8cb24f8a90ded6785cd8af800e8107a..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/LogShowQueueHelper.cs +++ /dev/null @@ -1,28 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.Net.SessionProviderService -{ - public class Log - { - public int Success { get; set; } - - public string log { get; set; } - } - public class LogShowQueueHelper - { - public static Queue LogQueue = new Queue(); - - public static void WriteLog(string log, string status = "ok") - { - LogQueue.Enqueue(new Log() - { - Success = status == "ok" ? 0 : 1, - log = log - }); - } - } -} diff --git a/SiMay.Net.SessionProviderService/MessageHelper.cs b/SiMay.Net.SessionProviderService/MessageHelper.cs deleted file mode 100644 index 2a49d8633acaaeecfa565b998daddc2bb680860f..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/MessageHelper.cs +++ /dev/null @@ -1,26 +0,0 @@ -using SiMay.Net.SessionProvider.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.Net.SessionProviderService -{ - public class MessageHelper - { - public static byte[] CommandCopyTo(MsgCommand cmd, byte[] data) - { - byte[] bytes = new byte[data.Length + 1]; - bytes[0] = (byte)cmd; - data.CopyTo(bytes, 1); - - return bytes; - } - - public static byte[] CommandCopyTo(MsgCommand cmd) - { - return new byte[] { (byte)cmd }; - } - } -} diff --git a/SiMay.Net.SessionProviderService/OnChannelListViewItem/ChannelListViewItem.cs b/SiMay.Net.SessionProviderService/OnChannelListViewItem/ChannelListViewItem.cs deleted file mode 100644 index ff820775372ac8106214232eeacf0fc3cbf60201..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/OnChannelListViewItem/ChannelListViewItem.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Forms; - -namespace SiMay.Net.SessionProviderService.OnChannelListViewItem -{ - public class ChannelListViewItem : ListViewItem - { - public ChannelListViewItem(TcpChannelContext context) - { - TcpChannelContext = context; - } - public TcpChannelContext TcpChannelContext { get; set; } - } -} diff --git a/SiMay.Net.SessionProviderService/Packet/PackDeserializeSetup.cs b/SiMay.Net.SessionProviderService/Packet/PackDeserializeSetup.cs deleted file mode 100644 index 187008a976a0ad6c219918e184fbb20e51cb3acd..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/Packet/PackDeserializeSetup.cs +++ /dev/null @@ -1,182 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; - -namespace SiMay.Package -{ - public class PackDeserializeSetup - { - private int _index = 0; - private List _arr = new List(); - public Encoding Encoding { get; set; } = Encoding.Unicode; - internal PackDeserializeSetup(byte[] data, object @object) - { - this._arr.AddRange(data); - this.ActionDeserialize(@object); - this._arr.Clear(); - } - private void ActionDeserialize(object @object) - { - var properties = @object.GetType().GetProperties(); - foreach (PropertyInfo property in properties) - { - var type = property.PropertyType; - var value = property.GetValue(@object, null); - if (type.Equals(typeof(Boolean))) - property.SetValue(@object, this.ReadBoolean()); - else if (type.Equals(typeof(Boolean[]))) - property.SetValue(@object, this.ReadArrayBoolean()); - else if (type.Equals(typeof(Byte))) - property.SetValue(@object, this.ReadByte()); - else if (type.Equals(typeof(Byte[]))) - property.SetValue(@object, this.ReadBytes()); - else if (type.Equals(typeof(Int16))) - property.SetValue(@object, this.ReadInt16()); - else if (type.Equals(typeof(Int16[]))) - property.SetValue(@object, this.ReadArrayInt16()); - else if (type.Equals(typeof(Int32))) - property.SetValue(@object, this.ReadInt32()); - else if (type.Equals(typeof(Int32[]))) - property.SetValue(@object, this.ReadArrayInt32()); - else if (type.Equals(typeof(Int64))) - property.SetValue(@object, this.ReadInt64()); - else if (type.Equals(typeof(Int64[]))) - property.SetValue(@object, this.ReadArrayInt64()); - else if (type.Equals(typeof(String))) - property.SetValue(@object, this.ReadString()); - else if (type.Equals(typeof(String[]))) - property.SetValue(@object, this.ReadArrayString()); - else if (type.IsArray) - property.SetValue(@object, this.ReadArray(property.PropertyType)); - else - this.ActionDeserialize(value); - } - } - private bool[] ReadArrayBoolean() - { - int len = this.ReadInt32(); - bool[] Arraybool = new bool[len]; - if (len > 0) - { - var bytes = this.Read(len); - for (int i = 0; i < len; i++) - Arraybool[i] = bytes[i] == 1 ? true : false; - } - return Arraybool; - } - private short[] ReadArrayInt16() - { - int len = this.ReadInt32(); - short[] ArrayInt16 = new short[len]; - if (len > 0) - { - for (int i = 0; i < len; i++) - ArrayInt16[i] = this.ReadInt16(); - } - return ArrayInt16; - } - private int[] ReadArrayInt32() - { - int len = this.ReadInt32(); - int[] ArrayInt32 = new int[len]; - if (len > 0) - { - for (int i = 0; i < len; i++) - ArrayInt32[i] = this.ReadInt32(); - } - return ArrayInt32; - } - private long[] ReadArrayInt64() - { - int len = this.ReadInt32(); - long[] ArrayInt64 = new long[len]; - if (len > 0) - { - for (int i = 0; i < len; i++) - ArrayInt64[i] = this.ReadInt64(); - } - return ArrayInt64; - } - private string[] ReadArrayString() - { - int len = this.ReadInt32(); - string[] ArrayString = new string[len]; - if (len > 0) - { - for (int i = 0; i < len; i++) - ArrayString[i] = this.ReadString(); - } - return ArrayString; - } - - private Array ReadArray(Type type) - { - int len = this.ReadInt32(); - object array = null; - array = type.InvokeMember("Set", BindingFlags.CreateInstance, null, array, new object[] { len }); - for (int i = 0; i < len; i++) - { - var @object = Activator.CreateInstance(type.GetElementType()); - this.ActionDeserialize(@object); - type.GetMethod("SetValue", new Type[2] { typeof(object), typeof(int) }).Invoke(array, new object[] { @object, i }); - } - return (Array)array; - } - private byte ReadByte() - { - return this.Read(1)[0]; - } - private bool ReadBoolean() - { - byte[] buffer = this.Read(1); - return BitConverter.ToBoolean(buffer, 0); - } - private short ReadInt16() - { - byte[] buffer = this.Read(sizeof(Int16)); - return BitConverter.ToInt16(buffer, 0); - } - private int ReadInt32() - { - byte[] buffer = this.Read(sizeof(Int32)); - return BitConverter.ToInt32(buffer, 0); - } - private long ReadInt64() - { - byte[] buffer = this.Read(sizeof(Int64)); - return BitConverter.ToInt64(buffer, 0); - } - private string ReadString() - { - int len = this.ReadInt32(); - string str = string.Empty; - if (len > 0) - { - byte[] strBytes = this.Read(len); - str = Encoding.GetString(strBytes); - } - return str; - } - private byte[] ReadBytes() - { - int len = this.ReadInt32(); - if (len > 0) - return this.Read(len); - else - return new byte[0]; - } - private byte[] Read(int lenght) - { - if ((_index + lenght) > this._arr.Count) - throw new ArgumentOutOfRangeException(); - - byte[] bytes = this._arr.GetRange(_index, lenght).ToArray(); - _index += lenght; - return bytes; - } - } -} - diff --git a/SiMay.Net.SessionProviderService/Packet/PackSerializeSetup.cs b/SiMay.Net.SessionProviderService/Packet/PackSerializeSetup.cs deleted file mode 100644 index 53d18c51bb8a45aab966761d47f68df678e909e1..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/Packet/PackSerializeSetup.cs +++ /dev/null @@ -1,164 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; - -namespace SiMay.Package -{ - public class PackSerializeSetup - { - public Encoding Encoding { get; set; } = Encoding.Unicode; - - List _arr = new List(); - internal PackSerializeSetup(object @object) - { - this.ActionSerialize(@object); - } - private void ActionSerialize(object @object) - { - var properties = @object.GetType().GetProperties(); - foreach (System.Reflection.PropertyInfo property in properties) - { - var type = property.PropertyType; - var value = property.GetValue(@object, null); - if (type.Equals(typeof(Boolean))) - this.WriteByte((Boolean)value ? (Byte)1 : (Byte)0); - else if (type.Equals(typeof(Boolean[]))) - this.WriteArrayBool((Boolean[])value); - else if (type.Equals(typeof(Byte))) - this.WriteByte((Byte)value); - else if (type.Equals(typeof(Byte[]))) - this.WriteArrayByte((Byte[])value); - else if (type.Equals(typeof(Int16))) - this.WriteInt16((Int16)value); - else if (type.Equals(typeof(Int16[]))) - this.WriteArrayInt16((Int16[])value); - else if (type.Equals(typeof(Int32))) - this.WriteInt32((Int32)value); - else if (type.Equals(typeof(Int32[]))) - this.WriteArrayInt32((Int32[])value); - else if (type.Equals(typeof(Int64))) - this.WriteInt64((Int64)value); - else if (type.Equals(typeof(Int64[]))) - this.WriteArrayInt64((Int64[])value); - else if (type.Equals(typeof(String))) - this.WriteString((String)value); - else if (type.Equals(typeof(String[]))) - WriteArrayString((String[])value); - else if (type.IsArray) - this.WriteArray((Array)value); - else - this.ActionSerialize(value); - } - } - - - public byte[] ToArray() - { - byte[] buffer = this._arr.ToArray(); - this._arr.Clear(); - - return buffer; - } - - private void WriteArrayBool(bool[] val) - { - this.WriteInt32(val.Length); - foreach (bool b in val) - this.WriteByte((byte)(b ? 1 : 0)); - } - - private void WriteArrayByte(byte[] val) - { - this.WriteInt32(val.Length); - this.Write(val); - } - - private void WriteArrayInt16(Int16[] val) - { - this.WriteInt32(val.Length); - foreach (Int16 b in val) - this.WriteInt16(b); - } - - private void WriteArrayInt32(Int32[] val) - { - this.WriteInt32(val.Length); - foreach (Int32 b in val) - this.WriteInt32(b); - } - - private void WriteArrayInt64(Int64[] val) - { - this.WriteInt32(val.Length); - foreach (Int32 b in val) - this.WriteInt64(b); - } - - private void WriteArrayString(String[] val) - { - String[] strArray = val as String[]; - this.WriteInt32(strArray.Length); - foreach (var str in strArray) - this.WriteString(str); - } - private void WriteArray(Array val) - { - this.WriteInt32(val.Length); - foreach (var item in val) - this.ActionSerialize(item); - } - private void WriteInt16(short s) - { - byte[] bytes = BitConverter.GetBytes(s); - this.Write(bytes); - } - - private void WriteInt32(int i) - { - byte[] bytes = BitConverter.GetBytes(i); - this.Write(bytes); - } - - private void WriteInt64(long l) - { - byte[] bytes = BitConverter.GetBytes(l); - this.Write(bytes); - } - - private void WriteSingle(Single f) - { - byte[] bytes = BitConverter.GetBytes(f); - this.Write(bytes); - } - - private void WriteDouble(double d) - { - byte[] bytes = BitConverter.GetBytes(d); - this.Write(bytes); - } - - - private void WriteString(string str) - { - if (str.Length == 0) - { - this.WriteInt32(0); - return; - } - byte[] bytes = Encoding.GetBytes(str); - this.WriteInt32(bytes.Length); - this.Write(bytes); - } - - private void Write(byte[] bytes) - { - this._arr.AddRange(bytes); - } - private void WriteByte(byte b) - { - this._arr.Add(b); - } - } -} diff --git a/SiMay.Net.SessionProviderService/Packet/PacketBuilderHelper.cs b/SiMay.Net.SessionProviderService/Packet/PacketBuilderHelper.cs deleted file mode 100644 index d748865d827b75fc8856991618f909191ffbe61b..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/Packet/PacketBuilderHelper.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SiMay.Package -{ - public class PacketBuilderHelper - { - public static T BuilderPacket(byte[] data) where T : new() - { - T pack = new T(); - var builder = new PackDeserializeSetup(data, pack); - return pack; - } - - public static byte[] BuilderPacketBytes(T pack) where T : new() - { - var builder = new PackSerializeSetup(pack); - - return builder.ToArray(); - } - } -} diff --git a/SiMay.Net.SessionProviderService/Program.cs b/SiMay.Net.SessionProviderService/Program.cs index c7725133e1caba61b020020cf3b1456441a8ca01..4fddf0037bb7bb74173613754a90cdd6b9cc21fc 100644 --- a/SiMay.Net.SessionProviderService/Program.cs +++ b/SiMay.Net.SessionProviderService/Program.cs @@ -30,7 +30,7 @@ namespace SiMay.Net.SessionProviderService Exception e = (Exception)ex.ExceptionObject; LogHelper.WriteLog("子线程异常:" + Environment.NewLine + "异常信息:" + e.Message + Environment.NewLine + - "异常堆栈:" + e.StackTrace + Environment.NewLine); + "异常堆栈:" + e.StackTrace + Environment.NewLine, ApplicationConfiguration.LogFileName); } private static void Application_ThreadException(object sender, ThreadExceptionEventArgs ex) @@ -39,7 +39,7 @@ namespace SiMay.Net.SessionProviderService LogHelper.WriteLog("UI异常:" + Environment.NewLine + "异常信息:" + e.Message + Environment.NewLine + - "异常堆栈:" + e.StackTrace + Environment.NewLine); + "异常堆栈:" + e.StackTrace + Environment.NewLine, ApplicationConfiguration.LogFileName); } } } diff --git a/SiMay.Net.SessionProviderService/Properties/AssemblyInfo.cs b/SiMay.Net.SessionProviderService/Properties/AssemblyInfo.cs index f50c73f93ef6d7868125d1a93bc5840f7ac0ac0e..8bb908f5ec7346e0958f909f04de07e376ec3904 100644 Binary files a/SiMay.Net.SessionProviderService/Properties/AssemblyInfo.cs and b/SiMay.Net.SessionProviderService/Properties/AssemblyInfo.cs differ diff --git a/SiMay.Net.SessionProviderService/Properties/Settings.Designer.cs b/SiMay.Net.SessionProviderService/Properties/Settings.Designer.cs index 48d13cf84a334289153391c9f2b6907a88b734fd..cfdd0f5ac0a03ee862132a6af9a1dfb2370d23ff 100644 --- a/SiMay.Net.SessionProviderService/Properties/Settings.Designer.cs +++ b/SiMay.Net.SessionProviderService/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace SiMay.Net.SessionProviderService.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/SiMay.Net.SessionProviderService/SessionProviderService.Designer.cs b/SiMay.Net.SessionProviderService/SessionProviderService.Designer.cs index c08a3f235d58125263fdc6ab8f7e0c5904d382ec..745ecde863746c59352db3d3f1eadc932cf3e71c 100644 --- a/SiMay.Net.SessionProviderService/SessionProviderService.Designer.cs +++ b/SiMay.Net.SessionProviderService/SessionProviderService.Designer.cs @@ -29,10 +29,6 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.channelListView = new System.Windows.Forms.ListView(); - this.create_time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.channel_type = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.channel_rate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.channelListContext = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); @@ -40,10 +36,10 @@ this.lableStatrTime = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel3 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); - this.labelUpload = new System.Windows.Forms.ToolStripStatusLabel(); + this.lbUpload = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel4 = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel6 = new System.Windows.Forms.ToolStripStatusLabel(); - this.labelReceive = new System.Windows.Forms.ToolStripStatusLabel(); + this.lbReceive = new System.Windows.Forms.ToolStripStatusLabel(); this.toolStripStatusLabel8 = new System.Windows.Forms.ToolStripStatusLabel(); this.label1 = new System.Windows.Forms.Label(); this.lableIPAddress = new System.Windows.Forms.Label(); @@ -51,55 +47,48 @@ this.labelPort = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.lableConnectionCount = new System.Windows.Forms.Label(); - this.splitContainer1 = new System.Windows.Forms.SplitContainer(); - this.logList = new System.Windows.Forms.ListView(); - this.log_create_time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.log = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.logContext = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem(); this.清空日志ToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.timerFlowCalac = new System.Windows.Forms.Timer(this.components); + this.tabControl1 = new System.Windows.Forms.TabControl(); + this.tabPage1 = new System.Windows.Forms.TabPage(); + this.channelListView = new System.Windows.Forms.ListView(); + this.channel_id = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.create_time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.channel_type = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.channel_rate = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader3 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader6 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader7 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader8 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader9 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader10 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader11 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader12 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader13 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader14 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.tabPage2 = new System.Windows.Forms.TabPage(); + this.dgvOffline = new System.Windows.Forms.DataGridView(); + this.tabPage3 = new System.Windows.Forms.TabPage(); + this.logList = new System.Windows.Forms.ListView(); + this.log_create_time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader15 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.channelListContext.SuspendLayout(); this.statusStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); - this.splitContainer1.Panel1.SuspendLayout(); - this.splitContainer1.Panel2.SuspendLayout(); - this.splitContainer1.SuspendLayout(); this.logContext.SuspendLayout(); + this.tabControl1.SuspendLayout(); + this.tabPage1.SuspendLayout(); + this.tabPage2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dgvOffline)).BeginInit(); + this.tabPage3.SuspendLayout(); this.SuspendLayout(); // - // channelListView - // - this.channelListView.CheckBoxes = true; - this.channelListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.create_time, - this.channel_type, - this.channel_rate}); - this.channelListView.ContextMenuStrip = this.channelListContext; - this.channelListView.Dock = System.Windows.Forms.DockStyle.Fill; - this.channelListView.FullRowSelect = true; - this.channelListView.Location = new System.Drawing.Point(0, 0); - this.channelListView.Name = "channelListView"; - this.channelListView.Size = new System.Drawing.Size(722, 189); - this.channelListView.TabIndex = 0; - this.channelListView.UseCompatibleStateImageBehavior = false; - this.channelListView.View = System.Windows.Forms.View.Details; - // - // create_time - // - this.create_time.Text = "连接时间"; - this.create_time.Width = 150; - // - // channel_type - // - this.channel_type.Text = "连接类型"; - this.channel_type.Width = 100; - // - // channel_rate - // - this.channel_rate.Text = "实时速率(s/kb)"; - this.channel_rate.Width = 100; - // // channelListContext // this.channelListContext.ImageScalingSize = new System.Drawing.Size(20, 20); @@ -119,19 +108,21 @@ // // statusStrip1 // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1, this.lableStatrTime, this.toolStripStatusLabel3, this.toolStripStatusLabel2, - this.labelUpload, + this.lbUpload, this.toolStripStatusLabel4, this.toolStripStatusLabel6, - this.labelReceive, + this.lbReceive, this.toolStripStatusLabel8}); - this.statusStrip1.Location = new System.Drawing.Point(0, 470); + this.statusStrip1.Location = new System.Drawing.Point(0, 548); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Size = new System.Drawing.Size(722, 22); + this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 16, 0); + this.statusStrip1.Size = new System.Drawing.Size(826, 22); this.statusStrip1.TabIndex = 1; this.statusStrip1.Text = "statusStrip1"; // @@ -150,20 +141,20 @@ // toolStripStatusLabel3 // this.toolStripStatusLabel3.Name = "toolStripStatusLabel3"; - this.toolStripStatusLabel3.Size = new System.Drawing.Size(311, 17); + this.toolStripStatusLabel3.Size = new System.Drawing.Size(413, 17); this.toolStripStatusLabel3.Spring = true; // // toolStripStatusLabel2 // this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; this.toolStripStatusLabel2.Size = new System.Drawing.Size(35, 17); - this.toolStripStatusLabel2.Text = "上传:"; + this.toolStripStatusLabel2.Text = "上行:"; // - // labelUpload + // lbUpload // - this.labelUpload.Name = "labelUpload"; - this.labelUpload.Size = new System.Drawing.Size(32, 17); - this.labelUpload.Text = "0.00"; + this.lbUpload.Name = "lbUpload"; + this.lbUpload.Size = new System.Drawing.Size(32, 17); + this.lbUpload.Text = "0.00"; // // toolStripStatusLabel4 // @@ -175,13 +166,13 @@ // this.toolStripStatusLabel6.Name = "toolStripStatusLabel6"; this.toolStripStatusLabel6.Size = new System.Drawing.Size(35, 17); - this.toolStripStatusLabel6.Text = "下传:"; + this.toolStripStatusLabel6.Text = "下行:"; // - // labelReceive + // lbReceive // - this.labelReceive.Name = "labelReceive"; - this.labelReceive.Size = new System.Drawing.Size(32, 17); - this.labelReceive.Text = "0.00"; + this.lbReceive.Name = "lbReceive"; + this.lbReceive.Size = new System.Drawing.Size(32, 17); + this.lbReceive.Text = "0.00"; // // toolStripStatusLabel8 // @@ -192,103 +183,57 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(12, 7); + this.label1.Location = new System.Drawing.Point(14, 10); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(23, 12); + this.label1.Size = new System.Drawing.Size(22, 17); this.label1.TabIndex = 2; this.label1.Text = "IP:"; // // lableIPAddress // this.lableIPAddress.AutoSize = true; - this.lableIPAddress.Location = new System.Drawing.Point(41, 7); + this.lableIPAddress.Location = new System.Drawing.Point(48, 10); this.lableIPAddress.Name = "lableIPAddress"; - this.lableIPAddress.Size = new System.Drawing.Size(47, 12); + this.lableIPAddress.Size = new System.Drawing.Size(45, 17); this.lableIPAddress.TabIndex = 3; this.lableIPAddress.Text = "0.0.0.0"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(148, 7); + this.label3.Location = new System.Drawing.Point(173, 10); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(35, 12); + this.label3.Size = new System.Drawing.Size(35, 17); this.label3.TabIndex = 4; this.label3.Text = "Port:"; // // labelPort // this.labelPort.AutoSize = true; - this.labelPort.Location = new System.Drawing.Point(189, 7); + this.labelPort.Location = new System.Drawing.Point(220, 10); this.labelPort.Name = "labelPort"; - this.labelPort.Size = new System.Drawing.Size(29, 12); + this.labelPort.Size = new System.Drawing.Size(36, 17); this.labelPort.TabIndex = 5; this.labelPort.Text = "5200"; // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(553, 7); + this.label5.Location = new System.Drawing.Point(645, 10); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(83, 12); + this.label5.Size = new System.Drawing.Size(83, 17); this.label5.TabIndex = 6; this.label5.Text = "会话连接数量:"; // // lableConnectionCount // this.lableConnectionCount.AutoSize = true; - this.lableConnectionCount.Location = new System.Drawing.Point(642, 7); + this.lableConnectionCount.Location = new System.Drawing.Point(749, 10); this.lableConnectionCount.Name = "lableConnectionCount"; - this.lableConnectionCount.Size = new System.Drawing.Size(11, 12); + this.lableConnectionCount.Size = new System.Drawing.Size(15, 17); this.lableConnectionCount.TabIndex = 7; this.lableConnectionCount.Text = "0"; // - // splitContainer1 - // - this.splitContainer1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer1.Location = new System.Drawing.Point(0, 24); - this.splitContainer1.Name = "splitContainer1"; - this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; - // - // splitContainer1.Panel1 - // - this.splitContainer1.Panel1.Controls.Add(this.channelListView); - // - // splitContainer1.Panel2 - // - this.splitContainer1.Panel2.Controls.Add(this.logList); - this.splitContainer1.Size = new System.Drawing.Size(722, 443); - this.splitContainer1.SplitterDistance = 189; - this.splitContainer1.SplitterWidth = 1; - this.splitContainer1.TabIndex = 8; - // - // logList - // - this.logList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.log_create_time, - this.log}); - this.logList.ContextMenuStrip = this.logContext; - this.logList.Dock = System.Windows.Forms.DockStyle.Fill; - this.logList.FullRowSelect = true; - this.logList.Location = new System.Drawing.Point(0, 0); - this.logList.Name = "logList"; - this.logList.Size = new System.Drawing.Size(722, 253); - this.logList.TabIndex = 1; - this.logList.UseCompatibleStateImageBehavior = false; - this.logList.View = System.Windows.Forms.View.Details; - // - // log_create_time - // - this.log_create_time.Text = "发生时间"; - this.log_create_time.Width = 150; - // - // log - // - this.log.Text = "事件信息"; - this.log.Width = 500; - // // logContext // this.logContext.ImageScalingSize = new System.Drawing.Size(20, 20); @@ -321,12 +266,223 @@ this.清空日志ToolStripMenuItem1.Text = "清空日志"; this.清空日志ToolStripMenuItem1.Click += new System.EventHandler(this.清空日志ToolStripMenuItem1_Click); // + // timerFlowCalac + // + this.timerFlowCalac.Enabled = true; + this.timerFlowCalac.Interval = 1000; + this.timerFlowCalac.Tick += new System.EventHandler(this.timerFlowCalac_Tick); + // + // tabControl1 + // + this.tabControl1.Controls.Add(this.tabPage1); + this.tabControl1.Controls.Add(this.tabPage2); + this.tabControl1.Controls.Add(this.tabPage3); + this.tabControl1.Location = new System.Drawing.Point(0, 31); + this.tabControl1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tabControl1.Name = "tabControl1"; + this.tabControl1.SelectedIndex = 0; + this.tabControl1.Size = new System.Drawing.Size(826, 518); + this.tabControl1.TabIndex = 9; + // + // tabPage1 + // + this.tabPage1.Controls.Add(this.channelListView); + this.tabPage1.Location = new System.Drawing.Point(4, 26); + this.tabPage1.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tabPage1.Name = "tabPage1"; + this.tabPage1.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tabPage1.Size = new System.Drawing.Size(818, 488); + this.tabPage1.TabIndex = 0; + this.tabPage1.Text = "在线列表"; + this.tabPage1.UseVisualStyleBackColor = true; + // + // channelListView + // + this.channelListView.CheckBoxes = true; + this.channelListView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.channel_id, + this.create_time, + this.channel_type, + this.channel_rate, + this.columnHeader1, + this.columnHeader2, + this.columnHeader3, + this.columnHeader4, + this.columnHeader5, + this.columnHeader6, + this.columnHeader7, + this.columnHeader8, + this.columnHeader9, + this.columnHeader10, + this.columnHeader11, + this.columnHeader12, + this.columnHeader13, + this.columnHeader14}); + this.channelListView.ContextMenuStrip = this.channelListContext; + this.channelListView.Dock = System.Windows.Forms.DockStyle.Fill; + this.channelListView.FullRowSelect = true; + this.channelListView.HideSelection = false; + this.channelListView.Location = new System.Drawing.Point(3, 4); + this.channelListView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.channelListView.Name = "channelListView"; + this.channelListView.Size = new System.Drawing.Size(812, 480); + this.channelListView.TabIndex = 1; + this.channelListView.UseCompatibleStateImageBehavior = false; + this.channelListView.View = System.Windows.Forms.View.Details; + // + // channel_id + // + this.channel_id.Text = "Id"; + this.channel_id.Width = 150; + // + // create_time + // + this.create_time.Text = "连接时间"; + this.create_time.Width = 150; + // + // channel_type + // + this.channel_type.Text = "连接类型"; + this.channel_type.Width = 150; + // + // channel_rate + // + this.channel_rate.Text = "实时速率(上行/下行)"; + this.channel_rate.Width = 175; + // + // columnHeader1 + // + this.columnHeader1.Text = "IP地址"; + // + // columnHeader2 + // + this.columnHeader2.Text = "计算机名"; + // + // columnHeader3 + // + this.columnHeader3.Text = "处理器信息"; + // + // columnHeader4 + // + this.columnHeader4.Text = "核心数量"; + // + // columnHeader5 + // + this.columnHeader5.Text = "运行内存"; + // + // columnHeader6 + // + this.columnHeader6.Text = "系统账户"; + // + // columnHeader7 + // + this.columnHeader7.Text = "摄像设备"; + // + // columnHeader8 + // + this.columnHeader8.Text = "录音设备"; + // + // columnHeader9 + // + this.columnHeader9.Text = "播放设备"; + // + // columnHeader10 + // + this.columnHeader10.Text = "备注信息"; + // + // columnHeader11 + // + this.columnHeader11.Text = "服务版本"; + // + // columnHeader12 + // + this.columnHeader12.Text = "启动时间"; + // + // columnHeader13 + // + this.columnHeader13.Text = "分组名称"; + // + // columnHeader14 + // + this.columnHeader14.Text = "物理地址"; + // + // tabPage2 + // + this.tabPage2.Controls.Add(this.dgvOffline); + this.tabPage2.Location = new System.Drawing.Point(4, 26); + this.tabPage2.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tabPage2.Name = "tabPage2"; + this.tabPage2.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tabPage2.Size = new System.Drawing.Size(818, 488); + this.tabPage2.TabIndex = 1; + this.tabPage2.Text = "离线列表"; + this.tabPage2.UseVisualStyleBackColor = true; + // + // dgvOffline + // + this.dgvOffline.AllowUserToAddRows = false; + this.dgvOffline.AllowUserToDeleteRows = false; + this.dgvOffline.AllowUserToOrderColumns = true; + this.dgvOffline.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells; + this.dgvOffline.BackgroundColor = System.Drawing.SystemColors.Control; + this.dgvOffline.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dgvOffline.Dock = System.Windows.Forms.DockStyle.Fill; + this.dgvOffline.GridColor = System.Drawing.SystemColors.Control; + this.dgvOffline.Location = new System.Drawing.Point(3, 4); + this.dgvOffline.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.dgvOffline.Name = "dgvOffline"; + this.dgvOffline.ReadOnly = true; + this.dgvOffline.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; + this.dgvOffline.RowTemplate.Height = 23; + this.dgvOffline.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; + this.dgvOffline.Size = new System.Drawing.Size(812, 480); + this.dgvOffline.TabIndex = 0; + // + // tabPage3 + // + this.tabPage3.Controls.Add(this.logList); + this.tabPage3.Location = new System.Drawing.Point(4, 26); + this.tabPage3.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tabPage3.Name = "tabPage3"; + this.tabPage3.Padding = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.tabPage3.Size = new System.Drawing.Size(818, 488); + this.tabPage3.TabIndex = 2; + this.tabPage3.Text = "日志"; + this.tabPage3.UseVisualStyleBackColor = true; + // + // logList + // + this.logList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.log_create_time, + this.columnHeader15}); + this.logList.ContextMenuStrip = this.logContext; + this.logList.Dock = System.Windows.Forms.DockStyle.Fill; + this.logList.FullRowSelect = true; + this.logList.HideSelection = false; + this.logList.Location = new System.Drawing.Point(3, 4); + this.logList.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.logList.Name = "logList"; + this.logList.Size = new System.Drawing.Size(812, 480); + this.logList.TabIndex = 2; + this.logList.UseCompatibleStateImageBehavior = false; + this.logList.View = System.Windows.Forms.View.Details; + // + // log_create_time + // + this.log_create_time.Text = "发生时间"; + this.log_create_time.Width = 114; + // + // columnHeader15 + // + this.columnHeader15.Text = "事件信息"; + this.columnHeader15.Width = 693; + // // SessionProviderService // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 17F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(722, 492); - this.Controls.Add(this.splitContainer1); + this.ClientSize = new System.Drawing.Size(826, 570); + this.Controls.Add(this.tabControl1); this.Controls.Add(this.lableConnectionCount); this.Controls.Add(this.label5); this.Controls.Add(this.labelPort); @@ -334,6 +490,8 @@ this.Controls.Add(this.lableIPAddress); this.Controls.Add(this.label1); this.Controls.Add(this.statusStrip1); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "SessionProviderService"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "SiMay中间会话服务"; @@ -342,21 +500,18 @@ this.channelListContext.ResumeLayout(false); this.statusStrip1.ResumeLayout(false); this.statusStrip1.PerformLayout(); - this.splitContainer1.Panel1.ResumeLayout(false); - this.splitContainer1.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); - this.splitContainer1.ResumeLayout(false); this.logContext.ResumeLayout(false); + this.tabControl1.ResumeLayout(false); + this.tabPage1.ResumeLayout(false); + this.tabPage2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dgvOffline)).EndInit(); + this.tabPage3.ResumeLayout(false); this.ResumeLayout(false); this.PerformLayout(); } #endregion - - private System.Windows.Forms.ListView channelListView; - private System.Windows.Forms.ColumnHeader create_time; - private System.Windows.Forms.ColumnHeader channel_type; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.Label label1; private System.Windows.Forms.Label lableIPAddress; @@ -366,24 +521,47 @@ private System.Windows.Forms.ToolStripStatusLabel lableStatrTime; private System.Windows.Forms.Label lableConnectionCount; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; - private System.Windows.Forms.ColumnHeader channel_rate; - private System.Windows.Forms.SplitContainer splitContainer1; - private System.Windows.Forms.ListView logList; - private System.Windows.Forms.ColumnHeader log_create_time; - private System.Windows.Forms.ColumnHeader log; private System.Windows.Forms.ContextMenuStrip logContext; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem1; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; private System.Windows.Forms.ToolStripMenuItem 清空日志ToolStripMenuItem1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel3; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel2; - private System.Windows.Forms.ToolStripStatusLabel labelUpload; + private System.Windows.Forms.ToolStripStatusLabel lbUpload; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel4; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel6; - private System.Windows.Forms.ToolStripStatusLabel labelReceive; + private System.Windows.Forms.ToolStripStatusLabel lbReceive; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel8; private System.Windows.Forms.ContextMenuStrip channelListContext; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem3; + private System.Windows.Forms.Timer timerFlowCalac; + private System.Windows.Forms.TabControl tabControl1; + private System.Windows.Forms.TabPage tabPage1; + private System.Windows.Forms.ListView channelListView; + private System.Windows.Forms.ColumnHeader channel_id; + private System.Windows.Forms.ColumnHeader create_time; + private System.Windows.Forms.ColumnHeader channel_type; + private System.Windows.Forms.ColumnHeader channel_rate; + private System.Windows.Forms.ColumnHeader columnHeader1; + private System.Windows.Forms.ColumnHeader columnHeader2; + private System.Windows.Forms.ColumnHeader columnHeader3; + private System.Windows.Forms.ColumnHeader columnHeader4; + private System.Windows.Forms.ColumnHeader columnHeader5; + private System.Windows.Forms.ColumnHeader columnHeader6; + private System.Windows.Forms.ColumnHeader columnHeader7; + private System.Windows.Forms.ColumnHeader columnHeader8; + private System.Windows.Forms.ColumnHeader columnHeader9; + private System.Windows.Forms.ColumnHeader columnHeader10; + private System.Windows.Forms.ColumnHeader columnHeader11; + private System.Windows.Forms.ColumnHeader columnHeader12; + private System.Windows.Forms.ColumnHeader columnHeader13; + private System.Windows.Forms.ColumnHeader columnHeader14; + private System.Windows.Forms.TabPage tabPage2; + private System.Windows.Forms.DataGridView dgvOffline; + private System.Windows.Forms.TabPage tabPage3; + private System.Windows.Forms.ListView logList; + private System.Windows.Forms.ColumnHeader log_create_time; + private System.Windows.Forms.ColumnHeader columnHeader15; } } diff --git a/SiMay.Net.SessionProviderService/SessionProviderService.cs b/SiMay.Net.SessionProviderService/SessionProviderService.cs index 21fa80a8a7df558540843ba8217c8fecc1868c18..ce8536a7d629e9293dbbe78f45fb3cca55cc9bb6 100644 --- a/SiMay.Net.SessionProviderService/SessionProviderService.cs +++ b/SiMay.Net.SessionProviderService/SessionProviderService.cs @@ -1,25 +1,18 @@ -using SiMay.Net.SessionProvider.Core; -using SiMay.Net.SessionProviderService.OnChannelListViewItem; -using SiMay.Net.SessionProviderService.Properties; -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Server; -using SiMay.Sockets.Tcp.Session; -using SiMay.Sockets.Tcp.TcpConfiguration; -using System; -using System.Collections.Generic; +using System; using System.ComponentModel; -using System.Data; using System.Diagnostics; using System.Drawing; using System.IO; using System.Linq; using System.Net; -using System.Runtime.InteropServices; -using System.Text; using System.Threading; -using System.Threading.Tasks; using System.Windows.Forms; -using static SiMay.Net.SessionProvider.Core.Win32Api; +using SiMay.Basic; +using SiMay.Net.SessionProvider.Core; +using SiMay.Net.SessionProviderService.Properties; +using SiMay.Net.SessionProviderServiceCore; +using static System.Windows.Forms.ListViewItem; +using static SiMay.Net.SessionProviderService.Win32; namespace SiMay.Net.SessionProviderService { @@ -27,179 +20,45 @@ namespace SiMay.Net.SessionProviderService { private const Int32 IDM_OPTIONS = 1000; private const Int32 IDM_RUNLOG = 1001; + public SessionProviderService() { InitializeComponent(); + this.Resize += new EventHandler(SessionProviderService_Resize); + this.tabControl1.SelectedIndexChanged += new EventHandler(tabControl1_SelectedIndexChanged); } - float _uploadTransferBytes; - float _receiveTransferBytes; - - ImageList _log_imgList; - - List _channelContexts = new List(); - TcpSocketSaeaServer _server; - - TcpChannelContext _manager_channel; - int _managerchannel_login = 0; - - int _connectionCount = 0; - private void SessionProviderService_Load(object sender, EventArgs e) + private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { - - this.Text = "SiMay中间会话服务-IOASJHD BEAT " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - - IntPtr sysMenuHandle = GetSystemMenu(this.Handle, false); - - InsertMenu(sysMenuHandle, 7, MF_SEPARATOR, 0, null); - InsertMenu(sysMenuHandle, 8, MF_BYPOSITION, IDM_OPTIONS, "系统设置"); - InsertMenu(sysMenuHandle, 9, MF_BYPOSITION, IDM_RUNLOG, "运行日志"); - - _log_imgList = new ImageList(); - _log_imgList.Images.Add("ok", Resources.ok); - _log_imgList.Images.Add("err", Resources.erro); - - logList.SmallImageList = _log_imgList; - - string address = ApplicationConfiguration.IPAddress; - string port = ApplicationConfiguration.Port; - - this.lableIPAddress.Text = address; - this.labelPort.Text = port; - this.lableStatrTime.Text = DateTime.Now.ToString(); - var ipe = new IPEndPoint(IPAddress.Parse(address), int.Parse(port)); - - - var serverConfig = new TcpSocketSaeaServerConfiguration(); - serverConfig.ReuseAddress = false; - serverConfig.KeepAlive = true; - serverConfig.KeepAliveInterval = 5000; - serverConfig.KeepAliveSpanTime = 1000; - serverConfig.PendingConnectionBacklog = int.Parse(ApplicationConfiguration.Backlog); - - _server = TcpSocketsFactory.CreateServerAgent(TcpSocketSaeaSessionType.Full, serverConfig, (notify, session) => + if (tabControl1.SelectedIndex == 1) { - switch (notify) + System.Data.DataTable dataTable = new System.Data.DataTable(); + if (ConnectList.RecordList == null) { - case TcpSocketCompletionNotify.OnConnected: - _connectionCount++; - - this.Invoke(new Action(() => - { - this.lableConnectionCount.Text = _connectionCount.ToString(); - })); - - //创建通道上下文,等待确认通道类型 - TcpChannelContext context = new TcpChannelContext(session); - context.OnChannelTypeNotify += Context_TcpAwaitnotifyProc; - - _channelContexts.Add(context); - break; - case TcpSocketCompletionNotify.OnSend: - this._uploadTransferBytes += session.SendTransferredBytes; - break; - case TcpSocketCompletionNotify.OnDataReceiveing: - this._receiveTransferBytes += session.ReceiveBytesTransferred; - - ((TcpChannelContext)session.AppTokens[0]).OnMessage(session); - break; - case TcpSocketCompletionNotify.OnClosed: - _connectionCount--; - - this.Invoke(new Action(() => - { - this.lableConnectionCount.Text = _connectionCount.ToString(); - })); - - this.SessionClosed(session); - break; - default: - break; + var connectList = new ConnectList() + { + LocalPath = AppDomain.CurrentDomain.BaseDirectory + "ConnectList.xml" + }; + connectList.LocalRead(); } - - }); - try - { - _server.Listen(ipe); - LogShowQueueHelper.WriteLog("SiMay中间会话服务端口" + port + "启动成功!"); - } - catch - { - LogShowQueueHelper.WriteLog("SiMay中间会话服务端口" + port + "启动失败!", "err"); - } - - System.Timers.Timer timer = new System.Timers.Timer(); - timer.Interval = 100; - timer.Elapsed += Timer_Elapsed; - timer.Start(); - - System.Timers.Timer flow_timer = new System.Timers.Timer(); - flow_timer.Interval = 1000; - flow_timer.Elapsed += Flow_timer_Elapsed; - flow_timer.Start(); - } - - private void Flow_timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) - { - this.Invoke(new Action(() => - { - this.labelUpload.Text = (this._uploadTransferBytes / 1024).ToString("0.00"); - this.labelReceive.Text = (this._receiveTransferBytes / 1024).ToString("0.00"); - - this._receiveTransferBytes = 0; - this._uploadTransferBytes = 0; - })); - } - - private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) - { - while (LogShowQueueHelper.LogQueue.Count != 0) - { - if (LogShowQueueHelper.LogQueue.Count > 0) + if (ConnectList.RecordList != null) { - Log log = LogShowQueueHelper.LogQueue.Dequeue(); - - - - this.Invoke(new Action(() => - { - WriteRuninglog(log.log, log.Success == 0 ? "ok" : "err"); - })); + dataTable = ConnectList.RecordList.Copy(); + System.Data.DataView dataView = new System.Data.DataView(dataTable); + dataView.RowFilter = "Status='False'"; + dgvOffline.DataSource = dataView.ToTable(); } + } } - /// - /// 输出日志 - /// - /// - /// - private void WriteRuninglog(string log, string key = "ok") - { - ListViewItem lv = new ListViewItem(); - lv.ImageKey = key; - lv.Text = DateTime.Now.ToString(); - lv.SubItems.Add(log); - - LogHelper.WriteLog(log, "OnRun.log"); - if (logList.Items.Count >= 1) - logList.Items.Insert(1, lv); - else - logList.Items.Insert(0, lv); - } - /// - /// 清除日志 - /// - private void Clearlogs() + private void SessionProviderService_Resize(object sender, EventArgs e) { - int i = 0; - foreach (ListViewItem item in logList.Items) - { - i++; - if (i > 1) - item.Remove(); - } + tabControl1.Width = this.Width - 15; + tabControl1.Height = this.Height - statusStrip1.Height - 70; + logList.Columns[1].Width = tabControl1.Width - logList.Columns[0].Width - 10; } + protected override void WndProc(ref Message m) { if (m.Msg == WM_SYSCOMMAND) @@ -208,342 +67,157 @@ namespace SiMay.Net.SessionProviderService switch (m.WParam.ToInt64()) { case IDM_OPTIONS: - AppOptionsDialog dlg = new AppOptionsDialog(); + SystemOptionsDialog dlg = new SystemOptionsDialog(); dlg.ShowDialog(); break; - case IDM_RUNLOG: - if (File.Exists("OnRun.log")) - { - Process.Start("OnRun.log"); - } - break; } } base.WndProc(ref m); } - private void SessionClosed(TcpSocketSaeaSession session) + + private float _uploadTransferBytes; + private float _receiveTransferBytes; + private ImageList _log_imgList; + private int _channelCount = 0; + + private MainSessionProviderService _sessionProviderService; + private void SessionProviderService_Load(object sender, EventArgs e) { - var context = ((TcpChannelContext)session.AppTokens[0]); - context.OnClosed(); - context.OnChannelTypeNotify -= Context_TcpAwaitnotifyProc; - context.OnManagerChannelMessage -= Context_OnManagerChannelMessage; - context.OnMainChannelMessage -= Context_OnMainChannelMessage; + this.Text = "SiMay中间会话服务-IOASJHD " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - _channelContexts.Remove(context); + IntPtr sysMenuHandle = GetSystemMenu(this.Handle, false); - LogShowQueueHelper.WriteLog("有连接断开,工作类型:" + context.ChannelType, "err"); + InsertMenu(sysMenuHandle, 7, MF_SEPARATOR, 0, null); + InsertMenu(sysMenuHandle, 8, MF_BYPOSITION, IDM_OPTIONS, "系统设置"); - if (context.ChannelType == TcpChannelContextServiceType.ManagerChannel) - { - if (this._managerchannel_login > 0) - Interlocked.Decrement(ref _managerchannel_login); - else - _manager_channel = null; + this._log_imgList = new ImageList(); + this._log_imgList.Images.Add("ok", Resources.ok); + this._log_imgList.Images.Add("err", Resources.erro); + this.logList.SmallImageList = _log_imgList; - } - else if (context.ChannelType == TcpChannelContextServiceType.MainChannel) - { - byte[] data = BitConverter.GetBytes(context.RemoteId); + string localAddress = ApplicationConfiguration.LoalAddress; + int port = ApplicationConfiguration.Port; - if (this._managerchannel_login > 0) - SendMessage(_manager_channel, MessageHelper.CommandCopyTo(MsgCommand.Msg_Close_Session, data)); - } + this.lableIPAddress.Text = localAddress; + this.labelPort.Text = port.ToString(); + this.lableStatrTime.Text = DateTime.Now.ToString(); - if (context.ChannelType != TcpChannelContextServiceType.None) - { - this.RemoveChannelListViewItem(context); - } - } + //dgvOffline.DataSource = ConnectList.RecordList; - private void RemoveChannelListViewItem(TcpChannelContext context) - { - this.BeginInvoke(new Action(() => - { - for (int i = 0; i < this.channelListView.Items.Count; i++) - { - ChannelListViewItem lv = this.channelListView.Items[i] as ChannelListViewItem; - if (lv.TcpChannelContext.Id == context.Id) - { - this.channelListView.Items.RemoveAt(i); - break; - } - } - })); + this.LaunchService(); } - private void AddChannelListViewItem(TcpChannelContext context) + private void LaunchService() { - this.BeginInvoke(new Action(() => + _sessionProviderService = new MainSessionProviderService(); + _sessionProviderService.SynchronizationContext = SynchronizationContext.Current; + _sessionProviderService.OnConnectedEventHandler += OnConnectedEventHandler; + _sessionProviderService.OnClosedEventHandler += OnClosedEventHandler; + _sessionProviderService.LogOutputEventHandler += LogOutputEventHandler; + var startResult = _sessionProviderService.StartService(new StartServiceOptions() { - ChannelListViewItem item = new ChannelListViewItem(context); - item.Text = DateTime.Now.ToString(); - item.SubItems.Add(context.ChannelType.ToString()); - item.SubItems.Add("0.00/0.00"); - this.channelListView.Items.Add(item); - })); + LocalAddress = ApplicationConfiguration.LoalAddress, + ServicePort = ApplicationConfiguration.Port, + MaxPacketSize = 1024 * 1024 * 2, + AccessKey = ApplicationConfiguration.AccessKey, + MainAppAccessKey = ApplicationConfiguration.MainAppAccessKey, + MainApplicationAllowAccessId = !ApplicationConfiguration.AccessIds.IsNullOrEmpty() ? ApplicationConfiguration.AccessIds.Split(',').Select(c => long.Parse(c)).ToArray() : new long[0], + MainApplicationAnonyMous = ApplicationConfiguration.AnonyMous + }); } - private void Context_TcpAwaitnotifyProc(TcpChannelContext context, TcpChannelContextServiceType type) - { - this.AddChannelListViewItem(context); - - LogShowQueueHelper.WriteLog("连接被确认,工作类型:" + type.ToString()); + private void LogOutputEventHandler(LogOutLevelType levelType, string log) => this.Log(levelType, log); - switch (type) + private void OnClosedEventHandler(TcpSessionChannelDispatcher dispatcher) + { + ChannelViewItem viewItem = this.channelListView.Items.FristOrDefault(c => c.ChannelDispatcher.Equals(dispatcher)); + this.channelListView.Items.Remove(viewItem); + ConnectList list = new ConnectList() { - case TcpChannelContextServiceType.MainChannel: - this.MainChannelProcess(context); - break; - case TcpChannelContextServiceType.WorkChannel: + LocalPath = AppDomain.CurrentDomain.BaseDirectory + "ConnectList.xml" + }; + list.MarkOffline(viewItem.SubItems[17].Text); - //通知发起工作连接 - if (this._managerchannel_login > 0) - SendMessage(_manager_channel, MessageHelper.CommandCopyTo(MsgCommand.Msg_Connect_Work)); - else - { - context.Session.Close(true); - } - - break; - case TcpChannelContextServiceType.ManagerChannel: - this.ManagerChannelProcess(context); - break; - case TcpChannelContextServiceType.ManagerWorkChannel: + dispatcher.LogOutputEventHandler -= LogOutputEventHandler; - this.JoinWorkChannelContext(context); - break; - default: - LogShowQueueHelper.WriteLog("未确认的连接:" + type.ToString()); - break; - } + this._channelCount--; + this.lableConnectionCount.Text = _channelCount.ToString(); } - private void MainChannelProcess(TcpChannelContext context) + private void OnConnectedEventHandler(TcpSessionChannelDispatcher dispatcher) { - if (this._managerchannel_login > 0) - { - //发送新上线会话的ID - byte[] data = BitConverter.GetBytes(context.Id); - SendMessage(_manager_channel, MessageHelper.CommandCopyTo(MsgCommand.Msg_Set_Session, data)); - } + var viewItem = new ChannelViewItem(dispatcher); + this.channelListView.Items.Add(viewItem); + AutoResizeColumnWidth(channelListView); - context.OnMainChannelMessage += Context_OnMainChannelMessage; + dispatcher.LogOutputEventHandler += LogOutputEventHandler; + this._channelCount++; + this.lableConnectionCount.Text = _channelCount.ToString(); } - private void ManagerChannelProcess(TcpChannelContext context) - { - //登出管理连接 - if (_managerchannel_login > 0) - { - //close所有mainContext - //while (this._channelContexts.Count < 1) - //{ - // for (int i = 0; i < this._channelContexts.Count; i++) - // { - - // } - // Thread.Sleep(10); - //} - + private void LogOutputEventHandler(DispatcherBase dispatcher, LogOutLevelType levelType, string log) => this.Log(levelType, log); - byte[] body = MessageHelper.CommandCopyTo(MsgCommand.Msg_LogOut); - SendMessage(_manager_channel, body); - LogShowQueueHelper.WriteLog("ManagerChannel LogOut"); - } - - Interlocked.Increment(ref _managerchannel_login); - - if (_manager_channel != null) - { - _manager_channel.OnManagerChannelMessage -= Context_OnManagerChannelMessage; - _manager_channel.OnChannelTypeNotify -= Context_TcpAwaitnotifyProc; - } - - _manager_channel = context; - context.OnManagerChannelMessage += Context_OnManagerChannelMessage; - } - - private void Context_OnManagerChannelMessage(TcpChannelContext context, byte[] data) + private void Log(LogOutLevelType levelType, string log) { + if (this.logList.Items.Count > 500) + CleanViewLog(); - MsgCommand msg = (MsgCommand)data[0]; - switch (msg) + var viewItem = new ListViewItem(); + viewItem.Text = DateTime.Now.ToString(); + viewItem.SubItems.Add(log); + switch (levelType) { - case MsgCommand.Msg_Pull_Session: - this.ProcessPullMainChannel(context); - break; - case MsgCommand.Msg_Set_Session_Id: - this.SetSessionId(context, data); + case LogOutLevelType.Debug: + viewItem.ImageKey = "ok"; break; - case MsgCommand.Msg_Close_Session: - this.CloseSession(data); + case LogOutLevelType.Warning: + viewItem.ImageKey = "err"; break; - case MsgCommand.Msg_MessageData: - this.ProcessSendMessage(data); - break; - default: + case LogOutLevelType.Error: + viewItem.ImageKey = "err"; break; } + this.logList.Items.Insert(0, viewItem); + LogHelper.WriteLog($"Level:{levelType.ToString()} {log}", ApplicationConfiguration.LogFileName); } - - private void Context_OnMainChannelMessage(TcpChannelContext context, byte[] data) + private void timerFlowCalac_Tick(object sender, EventArgs e) { - if (this._managerchannel_login == 0) return; - - byte[] bytes = new byte[sizeof(Int64) + data.Length]; - BitConverter.GetBytes(context.RemoteId).CopyTo(bytes, 0); - data.CopyTo(bytes, sizeof(Int64)); - - //MainChannel的数据封装代理协议发送出去 - if (this._managerchannel_login > 0) - SendMessage(_manager_channel, MessageHelper.CommandCopyTo(MsgCommand.Msg_MessageData, bytes)); - } - - private void ProcessSendMessage(byte[] data) - { - //byte[] body = new byte[data.Length - 1]; - //Array.Copy(data, 1, body, 0, body.Length); - - long id = BitConverter.ToInt64(data, 1); - - Console.WriteLine("ProcessSendMessage:" + id); - GCHandle gc = GCHandle.FromIntPtr(new IntPtr(id)); - Console.WriteLine("ProcessSendMessage OK"); - TcpChannelContext context = gc.Target as TcpChannelContext; - - if (context == null) - return; - - //将消息转发给MainChannel - context.SendMessage(data, sizeof(Int64) + 1, data.Length - sizeof(Int64) - 1); - } - - private void CloseSession(byte[] data) - { - long id = BitConverter.ToInt64(data, 1); - Console.WriteLine("CloseSession:" + id); - GCHandle gc = GCHandle.FromIntPtr(new IntPtr(id)); - Console.WriteLine("CloseSession OK"); - TcpChannelContext target_context = gc.Target as TcpChannelContext; - - if (target_context == null) - return; - - target_context.Session.Close(true); - - } - - private void SetSessionId(TcpChannelContext context, byte[] data) - { - byte[] body = new byte[data.Length - 1]; - Array.Copy(data, 1, body, 0, body.Length); - - try + foreach (ChannelViewItem item in channelListView.Items) { - byte[] sessionItems = new byte[sizeof(Int64) * 2]; - for (int i = 0; i < body.Length / (sizeof(Int64) * 2); i++) - { - Array.Copy(body, i * sessionItems.Length, sessionItems, 0, sessionItems.Length); - long id = BitConverter.ToInt64(sessionItems, 0); - - LogShowQueueHelper.WriteLog("DEBUG SetSessionId:" + id); - - GCHandle gc = GCHandle.FromIntPtr(new IntPtr(id)); - - LogShowQueueHelper.WriteLog("DEBUG SetSessionId OK"); - - TcpChannelContext target_context = gc.Target as TcpChannelContext; - id = BitConverter.ToInt64(sessionItems, sizeof(Int64)); - - LogShowQueueHelper.WriteLog("DEBUG SetSessionId RmoteId:" + id); + item.SetVelocityText(item.SendStreamLength, item.ReceiveStreamLength); + this._uploadTransferBytes += item.SendStreamLength; + this._receiveTransferBytes += item.ReceiveStreamLength; - //关联控制端SessionId - target_context.RemoteId = id; - - byte[] ack = target_context.AckPack; - - byte[] ackPack = new byte[ack.Length + sizeof(Int64)]; - BitConverter.GetBytes(id).CopyTo(ackPack, 0); - ack.CopyTo(ackPack, sizeof(Int64)); - - //发送应用层连接确认报(连接密码等信息) - if (this._managerchannel_login > 0) - SendMessage(_manager_channel, MessageHelper.CommandCopyTo(MsgCommand.Msg_MessageData, ackPack)); - } - - if (this._managerchannel_login > 0) - LogShowQueueHelper.WriteLog("Set SessionId SessionCount:" + body.Length / (sizeof(Int64) * 2)); - } - catch (Exception e) - { - LogShowQueueHelper.WriteLog("Set SessionId Exception:" + e.Message, "err"); - } - - - } - private void ProcessPullMainChannel(TcpChannelContext context) - { - //查找所有MainChannel - List contexts = _channelContexts.Where(x => x.ChannelType == TcpChannelContextServiceType.MainChannel).ToList(); - byte[] data = new byte[contexts.Count * sizeof(Int64)]; - for (int i = 0; i < contexts.Count; i++) - { - BitConverter.GetBytes(contexts[i].Id).CopyTo(data, i * sizeof(Int64)); - Console.WriteLine("ProcessPullMainChannel:" + contexts[i].Id); + item.SendStreamLength = 0; + item.ReceiveStreamLength = 0; } - if (_managerchannel_login > 0) - { - SendMessage(_manager_channel, MessageHelper.CommandCopyTo(MsgCommand.Msg_Set_Session, data)); - LogShowQueueHelper.WriteLog("Get Session SessionCount:" + contexts.Count); - } + this.lbUpload.Text = (_uploadTransferBytes / 1024).ToString("0.00"); + this.lbReceive.Text = (_receiveTransferBytes / 1024).ToString("0.00"); + this._uploadTransferBytes = 0; + this._receiveTransferBytes = 0; } - private void JoinWorkChannelContext(TcpChannelContext context) + private void CleanViewLog() { - //查找没有关联过的WorkChannel - TcpChannelContext workContext = _channelContexts.Find(x => x.ChannelType == TcpChannelContextServiceType.WorkChannel && !x.IsJoin); - if (workContext != null) - { - workContext.WorkChannelJoinContext(context.Session, context.GetBuffer); - - //关联完成,释放资源 - context.OnChannelTypeNotify -= Context_TcpAwaitnotifyProc; - context.DisposeContext(); - - this._channelContexts.Remove(context); - this.RemoveChannelListViewItem(context); - } - else + int i = 0; + foreach (ListViewItem item in logList.Items) { - //没找到就断开连接,回调会释放所有资源 - context.Session.Close(true); + i++; + if (i > 1) + item.Remove(); } } - private void SendMessage(TcpChannelContext context, byte[] data) - { - byte[] body = new byte[sizeof(Int32) + data.Length]; - BitConverter.GetBytes(data.Length).CopyTo(body, 0); - data.CopyTo(body, 4); - - if (context == null) - return; - - context.SendMessage(body, 0, body.Length); - } - private void toolStripMenuItem1_Click(object sender, EventArgs e) { - if (logList.SelectedItems.Count != 0) - { - Clipboard.SetText(logList.Items[logList.SelectedItems[0].Index].SubItems[1].Text); - } + if (this.logList.SelectedItems.Count != 0) + Clipboard.SetText(string.Join(",", logList.Items[logList.SelectedItems.FristOrDefault().Index].SubItems.Select(c => c.Text))); } private void toolStripMenuItem2_Click(object sender, EventArgs e) { - if (logList.SelectedItems.Count != 0) + if (this.logList.SelectedItems.Count != 0) { int Index = logList.SelectedItems[0].Index; if (Index >= 1) @@ -553,14 +227,13 @@ namespace SiMay.Net.SessionProviderService private void 清空日志ToolStripMenuItem1_Click(object sender, EventArgs e) { - this.Clearlogs(); + this.CleanViewLog(); } private void toolStripMenuItem3_Click(object sender, EventArgs e) { - var channelsListItems = channelListView.SelectedItems; - foreach (ChannelListViewItem item in channelsListItems) - item.TcpChannelContext.Session.Close(true); + foreach (ChannelViewItem item in channelListView.SelectedItems) + item.ChannelDispatcher.CloseSession(); } private void channelListContext_Opening(object sender, CancelEventArgs e) @@ -574,9 +247,39 @@ namespace SiMay.Net.SessionProviderService private void SessionProviderService_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBox.Show("服务正在运行中,确定要关闭吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK) - { e.Cancel = true; + } + + /// + /// 自动调整ListView列宽 + /// + /// + public void AutoResizeColumnWidth(ListView listView) + { + int intColumnCount = listView.Columns.Count; + Graphics graphics = listView.CreateGraphics(); + Font font = listView.Font; + ListView.ListViewItemCollection items = listView.Items; + + listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); + + for (int intCount = 0; intCount < intColumnCount; intCount++) + { + int intMaxWidth = listView.Columns[intCount].Width; + + foreach (ListViewItem item in items) + { + string strContent = item.SubItems[intCount].Text; + int intWidth = (int)graphics.MeasureString(strContent, font).Width; + if (intWidth > intMaxWidth) + { + intMaxWidth = intWidth; + } + } + listView.Columns[intCount].Width = intMaxWidth; } } + + } } diff --git a/SiMay.Net.SessionProviderService/SessionProviderService.resx b/SiMay.Net.SessionProviderService/SessionProviderService.resx index 3f0ca3e6e531f638eb232e2f6f4daf2cdc1cc4dc..1bfc232296f7f06eec16ee464b6c1bcdc1005539 100644 --- a/SiMay.Net.SessionProviderService/SessionProviderService.resx +++ b/SiMay.Net.SessionProviderService/SessionProviderService.resx @@ -126,4 +126,7 @@ 124, 17 + + 530, 24 + \ No newline at end of file diff --git a/SiMay.Net.SessionProviderService/SiMay.Net.SessionProviderService.csproj b/SiMay.Net.SessionProviderService/SiMay.Net.SessionProviderService.csproj index ff8b2c4fab5ff98ff65ac010a87584c89e9f68ff..64f31d3fd6ecb3d8fe1d49289526c4b7b6ed8c0d 100644 --- a/SiMay.Net.SessionProviderService/SiMay.Net.SessionProviderService.csproj +++ b/SiMay.Net.SessionProviderService/SiMay.Net.SessionProviderService.csproj @@ -50,23 +50,15 @@ - - + + Form - - AppOptionsDialog.cs + + SystemOptionsDialog.cs - - - - - - - - - + Form @@ -75,10 +67,9 @@ - - - - AppOptionsDialog.cs + + + SystemOptionsDialog.cs SessionProviderService.cs @@ -108,16 +99,20 @@ - {B30CD716-698A-4DA2-BD1A-C152B16993C0} + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F} SiMay.Basic - {8BFDB408-D26D-4689-B426-BE45AD195880} + {0b2b697d-dd20-4869-836c-08c848e1813f} SiMay.Net.SessionProvider.Core - - {d181fcce-ecc7-4710-89cc-d97f94a6181b} - SiMay.Sockets.V4 + + {3c91f949-5187-4cdf-9a5b-aa3c20f7544b} + SiMay.Net.SessionProviderServiceCore + + + {9525a4aa-6731-4ab2-8cd0-addf7940fe32} + SiMay.Serialize.Standard diff --git a/SiMay.Net.SessionProviderService/AppOptionsDialog.Designer.cs b/SiMay.Net.SessionProviderService/SystemOptionsDialog.Designer.cs similarity index 50% rename from SiMay.Net.SessionProviderService/AppOptionsDialog.Designer.cs rename to SiMay.Net.SessionProviderService/SystemOptionsDialog.Designer.cs index 566c215c04cbbccb803bccb23ae975e23b81771a..e163188ce24e82ed2bc6e0b97c40c9c125d8eb3a 100644 --- a/SiMay.Net.SessionProviderService/AppOptionsDialog.Designer.cs +++ b/SiMay.Net.SessionProviderService/SystemOptionsDialog.Designer.cs @@ -1,6 +1,6 @@ namespace SiMay.Net.SessionProviderService { - partial class AppOptionsDialog + partial class SystemOptionsDialog { /// /// Required designer variable. @@ -41,45 +41,56 @@ this.label6 = new System.Windows.Forms.Label(); this.checkBox1 = new System.Windows.Forms.CheckBox(); this.label7 = new System.Windows.Forms.Label(); + this.txtAccessId = new System.Windows.Forms.TextBox(); + this.label8 = new System.Windows.Forms.Label(); + this.txtMainAppAccessKey = new System.Windows.Forms.TextBox(); + this.label9 = new System.Windows.Forms.Label(); + this.label10 = new System.Windows.Forms.Label(); + this.ckAnonyMous = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(119, 54); + this.label1.Location = new System.Drawing.Point(198, 68); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(59, 12); + this.label1.Size = new System.Drawing.Size(75, 15); this.label1.TabIndex = 0; this.label1.Text = "监听地址:"; // // txtIPAddress // - this.txtIPAddress.Location = new System.Drawing.Point(184, 51); + this.txtIPAddress.Location = new System.Drawing.Point(284, 64); + this.txtIPAddress.Margin = new System.Windows.Forms.Padding(4); this.txtIPAddress.Name = "txtIPAddress"; - this.txtIPAddress.Size = new System.Drawing.Size(138, 21); + this.txtIPAddress.Size = new System.Drawing.Size(183, 25); this.txtIPAddress.TabIndex = 1; // // txtPort // - this.txtPort.Location = new System.Drawing.Point(184, 79); + this.txtPort.Location = new System.Drawing.Point(284, 99); + this.txtPort.Margin = new System.Windows.Forms.Padding(4); this.txtPort.Name = "txtPort"; - this.txtPort.Size = new System.Drawing.Size(138, 21); + this.txtPort.Size = new System.Drawing.Size(183, 25); this.txtPort.TabIndex = 3; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(143, 82); + this.label2.Location = new System.Drawing.Point(230, 102); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(35, 12); + this.label2.Size = new System.Drawing.Size(45, 15); this.label2.TabIndex = 2; this.label2.Text = "端口:"; // // saveBtn // - this.saveBtn.Location = new System.Drawing.Point(232, 216); + this.saveBtn.Location = new System.Drawing.Point(425, 371); + this.saveBtn.Margin = new System.Windows.Forms.Padding(4); this.saveBtn.Name = "saveBtn"; - this.saveBtn.Size = new System.Drawing.Size(90, 36); + this.saveBtn.Size = new System.Drawing.Size(204, 45); this.saveBtn.TabIndex = 4; this.saveBtn.Text = "保存设置"; this.saveBtn.UseVisualStyleBackColor = true; @@ -87,17 +98,19 @@ // // txtBacklog // - this.txtBacklog.Location = new System.Drawing.Point(184, 106); + this.txtBacklog.Location = new System.Drawing.Point(284, 132); + this.txtBacklog.Margin = new System.Windows.Forms.Padding(4); this.txtBacklog.Name = "txtBacklog"; - this.txtBacklog.Size = new System.Drawing.Size(138, 21); + this.txtBacklog.Size = new System.Drawing.Size(183, 25); this.txtBacklog.TabIndex = 6; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(95, 109); + this.label3.Location = new System.Drawing.Point(166, 136); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(83, 12); + this.label3.Size = new System.Drawing.Size(105, 15); this.label3.TabIndex = 5; this.label3.Text = "连接挂起队列:"; // @@ -105,9 +118,10 @@ // this.label4.AutoSize = true; this.label4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label4.Location = new System.Drawing.Point(95, 29); + this.label4.Location = new System.Drawing.Point(166, 36); + this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(57, 12); + this.label4.Size = new System.Drawing.Size(71, 15); this.label4.TabIndex = 7; this.label4.Text = "基本设置"; // @@ -115,52 +129,124 @@ // this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label5.Location = new System.Drawing.Point(95, 163); + this.label5.Location = new System.Drawing.Point(166, 204); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(57, 12); + this.label5.Size = new System.Drawing.Size(71, 15); this.label5.TabIndex = 8; this.label5.Text = "访问安全"; // // txtAccessKey // - this.txtAccessKey.Location = new System.Drawing.Point(184, 187); + this.txtAccessKey.Location = new System.Drawing.Point(284, 234); + this.txtAccessKey.Margin = new System.Windows.Forms.Padding(4); this.txtAccessKey.Name = "txtAccessKey"; - this.txtAccessKey.Size = new System.Drawing.Size(138, 21); + this.txtAccessKey.Size = new System.Drawing.Size(183, 25); this.txtAccessKey.TabIndex = 10; // // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(113, 190); + this.label6.Location = new System.Drawing.Point(190, 238); + this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(65, 12); + this.label6.Size = new System.Drawing.Size(87, 15); this.label6.TabIndex = 9; this.label6.Text = "AccessKey:"; // // checkBox1 // this.checkBox1.AutoSize = true; - this.checkBox1.Location = new System.Drawing.Point(184, 135); + this.checkBox1.Enabled = false; + this.checkBox1.Location = new System.Drawing.Point(284, 169); + this.checkBox1.Margin = new System.Windows.Forms.Padding(4); this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(60, 16); + this.checkBox1.Size = new System.Drawing.Size(74, 19); this.checkBox1.TabIndex = 11; this.checkBox1.Text = "不启动"; this.checkBox1.UseVisualStyleBackColor = true; + this.checkBox1.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); // // label7 // this.label7.AutoSize = true; - this.label7.Location = new System.Drawing.Point(119, 135); + this.label7.Enabled = false; + this.label7.Location = new System.Drawing.Point(198, 169); + this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(59, 12); + this.label7.Size = new System.Drawing.Size(75, 15); this.label7.TabIndex = 12; this.label7.Text = "开机启动:"; // - // AppOptionsDialog + // txtAccessId // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.txtAccessId.Location = new System.Drawing.Point(284, 267); + this.txtAccessId.Margin = new System.Windows.Forms.Padding(4); + this.txtAccessId.Name = "txtAccessId"; + this.txtAccessId.Size = new System.Drawing.Size(183, 25); + this.txtAccessId.TabIndex = 14; + // + // label8 + // + this.label8.AutoSize = true; + this.label8.Location = new System.Drawing.Point(198, 270); + this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label8.Name = "label8"; + this.label8.Size = new System.Drawing.Size(79, 15); + this.label8.TabIndex = 13; + this.label8.Text = "AccessId:"; + // + // txtMainAppAccessKey + // + this.txtMainAppAccessKey.Location = new System.Drawing.Point(284, 300); + this.txtMainAppAccessKey.Margin = new System.Windows.Forms.Padding(4); + this.txtMainAppAccessKey.Name = "txtMainAppAccessKey"; + this.txtMainAppAccessKey.Size = new System.Drawing.Size(183, 25); + this.txtMainAppAccessKey.TabIndex = 16; + // + // label9 + // + this.label9.AutoSize = true; + this.label9.Location = new System.Drawing.Point(134, 303); + this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label9.Name = "label9"; + this.label9.Size = new System.Drawing.Size(143, 15); + this.label9.TabIndex = 15; + this.label9.Text = "MainAppAccessKey:"; + // + // label10 + // + this.label10.AutoSize = true; + this.label10.Location = new System.Drawing.Point(202, 341); + this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label10.Name = "label10"; + this.label10.Size = new System.Drawing.Size(75, 15); + this.label10.TabIndex = 18; + this.label10.Text = "匿名登陆:"; + // + // ckAnonyMous + // + this.ckAnonyMous.AutoSize = true; + this.ckAnonyMous.Location = new System.Drawing.Point(284, 340); + this.ckAnonyMous.Margin = new System.Windows.Forms.Padding(4); + this.ckAnonyMous.Name = "ckAnonyMous"; + this.ckAnonyMous.Size = new System.Drawing.Size(74, 19); + this.ckAnonyMous.TabIndex = 17; + this.ckAnonyMous.Text = "不允许"; + this.ckAnonyMous.UseVisualStyleBackColor = true; + this.ckAnonyMous.CheckedChanged += new System.EventHandler(this.ckAnonyMous_CheckedChanged); + // + // SystemOptionsDialog + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(425, 265); + this.ClientSize = new System.Drawing.Size(664, 440); + this.Controls.Add(this.label10); + this.Controls.Add(this.ckAnonyMous); + this.Controls.Add(this.txtMainAppAccessKey); + this.Controls.Add(this.label9); + this.Controls.Add(this.txtAccessId); + this.Controls.Add(this.label8); this.Controls.Add(this.label7); this.Controls.Add(this.checkBox1); this.Controls.Add(this.txtAccessKey); @@ -175,8 +261,9 @@ this.Controls.Add(this.txtIPAddress); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(4); this.MaximizeBox = false; - this.Name = "AppOptionsDialog"; + this.Name = "SystemOptionsDialog"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "系统设置"; this.Load += new System.EventHandler(this.AppOptions_Load); @@ -200,5 +287,11 @@ private System.Windows.Forms.Label label6; private System.Windows.Forms.CheckBox checkBox1; private System.Windows.Forms.Label label7; + private System.Windows.Forms.TextBox txtAccessId; + private System.Windows.Forms.Label label8; + private System.Windows.Forms.TextBox txtMainAppAccessKey; + private System.Windows.Forms.Label label9; + private System.Windows.Forms.Label label10; + private System.Windows.Forms.CheckBox ckAnonyMous; } } \ No newline at end of file diff --git a/SiMay.Net.SessionProviderService/AppOptionsDialog.cs b/SiMay.Net.SessionProviderService/SystemOptionsDialog.cs similarity index 39% rename from SiMay.Net.SessionProviderService/AppOptionsDialog.cs rename to SiMay.Net.SessionProviderService/SystemOptionsDialog.cs index cce68e9ade5580cc327c7263a09500ee0a18f629..b3dcb87e6f0d3731de32a5b5bef91664d924bd4f 100644 --- a/SiMay.Net.SessionProviderService/AppOptionsDialog.cs +++ b/SiMay.Net.SessionProviderService/SystemOptionsDialog.cs @@ -10,9 +10,9 @@ using System.Windows.Forms; namespace SiMay.Net.SessionProviderService { - public partial class AppOptionsDialog : Form + public partial class SystemOptionsDialog : Form { - public AppOptionsDialog() + public SystemOptionsDialog() { InitializeComponent(); } @@ -24,12 +24,13 @@ namespace SiMay.Net.SessionProviderService MessageBox.Show("请完整输入服务器配置信息", "提示", 0, MessageBoxIcon.Exclamation); return; } - ApplicationConfiguration.IPAddress = txtIPAddress.Text; - ApplicationConfiguration.Port = txtPort.Text; - ApplicationConfiguration.Backlog = txtBacklog.Text; - ApplicationConfiguration.ServiceAccessKey = txtAccessKey.Text; - - AccessKeyExamine.ServiceAccessKey = long.Parse(txtAccessKey.Text); + ApplicationConfiguration.LoalAddress = txtIPAddress.Text; + ApplicationConfiguration.Port = int.Parse(txtPort.Text); + ApplicationConfiguration.Backlog = int.Parse(txtBacklog.Text); + ApplicationConfiguration.AccessKey = long.Parse(txtAccessKey.Text); + ApplicationConfiguration.AnonyMous = this.ckAnonyMous.Checked; + ApplicationConfiguration.AccessIds = txtAccessId.Text; + ApplicationConfiguration.MainAppAccessKey = long.Parse(txtMainAppAccessKey.Text); DialogResult result = MessageBox.Show("设置已保存,是否重启程序以生效已保存的应用设置?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); @@ -41,10 +42,26 @@ namespace SiMay.Net.SessionProviderService private void AppOptions_Load(object sender, EventArgs e) { - txtIPAddress.Text = ApplicationConfiguration.IPAddress; - txtPort.Text = ApplicationConfiguration.Port; - txtBacklog.Text = ApplicationConfiguration.Backlog; - txtAccessKey.Text = ApplicationConfiguration.ServiceAccessKey; + txtIPAddress.Text = ApplicationConfiguration.LoalAddress; + txtPort.Text = ApplicationConfiguration.Port.ToString(); + txtBacklog.Text = ApplicationConfiguration.Backlog.ToString(); + txtAccessKey.Text = ApplicationConfiguration.AccessKey.ToString(); + txtAccessId.Text = ApplicationConfiguration.AccessIds; + txtMainAppAccessKey.Text = ApplicationConfiguration.MainAppAccessKey.ToString(); + ckAnonyMous.Checked = ApplicationConfiguration.AnonyMous; + + ckAnonyMous.Text = ckAnonyMous.Checked ? "允许" : "不允许"; + checkBox1.Text = checkBox1.Checked ? "开机启动" : "不启动"; + } + + private void ckAnonyMous_CheckedChanged(object sender, EventArgs e) + { + ckAnonyMous.Text = ckAnonyMous.Checked ? "允许" : "不允许"; + } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + checkBox1.Text = checkBox1.Checked ? "开机启动" : "不启动"; } } } diff --git a/SiMay.Net.SessionProviderService/AppOptionsDialog.resx b/SiMay.Net.SessionProviderService/SystemOptionsDialog.resx similarity index 100% rename from SiMay.Net.SessionProviderService/AppOptionsDialog.resx rename to SiMay.Net.SessionProviderService/SystemOptionsDialog.resx diff --git a/SiMay.Net.SessionProviderService/TcpChannelContext.cs b/SiMay.Net.SessionProviderService/TcpChannelContext.cs deleted file mode 100644 index 0599cd129bc6ce2a0db8cfff16d9db75f6dea161..0000000000000000000000000000000000000000 --- a/SiMay.Net.SessionProviderService/TcpChannelContext.cs +++ /dev/null @@ -1,258 +0,0 @@ -using SiMay.Basic; -using SiMay.Net.SessionProvider.Core; -using SiMay.Net.SessionProviderService.Delagate; -using SiMay.Net.SessionProviderService.Notify; -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Session; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Runtime.InteropServices; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.Net.SessionProviderService -{ - public class TcpChannelContext - { - //缓冲区同步 - readonly object _lock = new object(); - const short AckPacket = 1000; - - bool _isJoin = false; - List _buffer = new List(); - TcpSocketSaeaSession _desession; - TcpSocketSaeaSession _session; - TcpChannelContextServiceType _channelType = TcpChannelContextServiceType.None; - - public TcpSocketSaeaSession Session - { - get { return _session; } - } - public byte[] GetBuffer - { - get { return this._buffer.ToArray(); } - } - public TcpChannelContextServiceType ChannelType - { - get { return _channelType; } - } - - public bool IsJoin - { - get { return this._isJoin; } - } - - long _id; - public long Id - { - get { return _id; } - } - - long _rid; - public long RemoteId - { - get { return _rid; } - set { _rid = value; } - } - - byte[] _ack_buffer; - public byte[] AckPack - { - get { return _ack_buffer; } - } - - public event TcpChannelContextNotifyHandler OnChannelTypeNotify; - - public event TcpChannelContextNotifyHandler OnManagerChannelMessage; - - public event TcpChannelContextNotifyHandler OnMainChannelMessage; - - public TcpChannelContext(TcpSocketSaeaSession session) - { - _session = session; - - //与连接绑定,当消息接收后,会通过OnMessage接收 - session.AppTokens = new object[] - { - this, - TcpChannelContextServiceType.None - }; - - //获取通道对象内存地址作为id - GCHandle gc = GCHandle.Alloc(this, GCHandleType.WeakTrackResurrection); - this._id = GCHandle.ToIntPtr(gc).ToInt64(); - } - - public void SendMessage(byte[] data, int offset, int lenght) - { - if (this._session == null) - return; - - _session.SendAsync(data, offset, lenght); - } - - public void WorkChannelJoinContext(TcpSocketSaeaSession session, byte[] buffer) - { - _desession = session; - - session.AppTokens[0] = this; - - //转发给工作连接 - if (buffer.Length > 0) - this._session.SendAsync(buffer); - - if (this._buffer.Count > 0) - { - this._desession.SendAsync(this._buffer.ToArray()); - this._buffer.Clear(); - } - - this._isJoin = true; - } - - public void OnMessage(TcpSocketSaeaSession session) - { - byte[] data = new byte[session.ReceiveBytesTransferred]; - Array.Copy(session.CompletedBuffer, 0, data, 0, data.Length); - - var type = (TcpChannelContextServiceType)session.AppTokens[1]; - if (type == TcpChannelContextServiceType.None) - { - //当通道类型未确认时,进入该区域处理消息 - - _buffer.AddRange(data); - if (_buffer.Count < 4) - return; - - byte[] lenBytes = _buffer.GetRange(0, 4).ToArray(); - int packageLen = BitConverter.ToInt32(lenBytes, 0); - - if (packageLen < 0 || packageLen > 1024 * 1024 * 2) - { - session.Close(true); - return; - } - - if (packageLen > _buffer.Count - 4) - return; - - //保留ack,与控制端连接时要用到 - this._ack_buffer = _buffer.GetRange(0, packageLen + 4).ToArray(); - - byte[] Ack = CompressHelper.Decompress(_buffer.GetRange(4, packageLen).ToArray()); - - short headMsg = BitConverter.ToInt16(Ack, 0); - - if (headMsg == AckPacket) - { - // 命令头 消息体 连接类型 - this._channelType = (TcpChannelContextServiceType)Ack[sizeof(Int16) + sizeof(Int64) + sizeof(Byte) - 1]; - - if (this._channelType == TcpChannelContextServiceType.ManagerChannel) - { - long accessKey = BitConverter.ToInt64(Ack, 2); - - if (!AccessKeyExamine.CheckOut(accessKey))//连接密码确认 - { - LogShowQueueHelper.WriteLog("ManagerChannel AccessKey Wrong " + accessKey.ToString(), "err"); - - byte[] body = MessageHelper.CommandCopyTo(MsgCommand.Msg_AccessKeyWrong); - - byte[] pack = new byte[body.Length + sizeof(Int32)]; - BitConverter.GetBytes(body.Length).CopyTo(pack, 0); - body.CopyTo(pack, 4); - - session.SendAsync(pack); - //session.Close(true); - return; - } - } - - this._session.AppTokens[1] = this._channelType; - - if (this._channelType == TcpChannelContextServiceType.ManagerWorkChannel - || this._channelType == TcpChannelContextServiceType.ManagerChannel) - { - _buffer.RemoveRange(0, packageLen + 4); - } - - this.OnChannelTypeNotify?.Invoke(this, this._channelType); - - if (this._channelType == TcpChannelContextServiceType.ManagerChannel) - this.ManagerPackageProcess();//如果缓冲区还有数据 - } - else - { - session.Close(true); - } - } - else if (type == TcpChannelContextServiceType.WorkChannel && this._isJoin) - { - if (this._desession == null) - return; - - this._desession.SendAsync(data); - } - else if (type == TcpChannelContextServiceType.ManagerWorkChannel && this._channelType != type)//当前连接类型为ManagerWorkChannel且当前通道类型为ManagerWorkChannel时表示通道此时未与工作类型关联,暂时将数据存放在缓存区,待关联时再将数据转发 - { - if (this._session == null) - return; - - this._session.SendAsync(data); - } - else if (type == TcpChannelContextServiceType.ManagerChannel) - { - this._buffer.AddRange(data); - this.ManagerPackageProcess(); - } - else if (type == TcpChannelContextServiceType.MainChannel) - { - this.OnMainChannelMessage?.Invoke(this, data);//直接转发 - } - else - { - _buffer.AddRange(data); - } - - } - - private void ManagerPackageProcess() - { - do - { - if (_buffer.Count < 4) - return; - - byte[] lenBytes = _buffer.GetRange(0, 4).ToArray(); - int packageLen = BitConverter.ToInt32(lenBytes, 0); - - if (packageLen > _buffer.Count - 4) - return; - - byte[] completedBytes = _buffer.GetRange(4, packageLen).ToArray(); - - this.OnManagerChannelMessage?.Invoke(this, completedBytes); - - _buffer.RemoveRange(0, packageLen + 4); - - } while (_buffer.Count > 4); - } - public void OnClosed() - { - this._session?.Close(true); - this._desession?.Close(true); - this.DisposeContext(); - } - - public void DisposeContext() - { - //this._buffer.Clear(); - this._desession = null; - this._session = null; - - GCHandle gc = GCHandle.FromIntPtr(new IntPtr(this.Id)); - gc.Free(); - } - } -} diff --git a/SiMay.Net.SessionProvider.Core/Win32Api.cs b/SiMay.Net.SessionProviderService/Win32.cs similarity index 90% rename from SiMay.Net.SessionProvider.Core/Win32Api.cs rename to SiMay.Net.SessionProviderService/Win32.cs index 37600b95bd63f435f44f7efd910e077d69540105..3cb11164ee7649f7dc4d110d213389e574608cd6 100644 --- a/SiMay.Net.SessionProvider.Core/Win32Api.cs +++ b/SiMay.Net.SessionProviderService/Win32.cs @@ -4,16 +4,28 @@ using System.Drawing; using System.Linq; using System.Runtime.InteropServices; using System.Text; +using System.Threading.Tasks; -namespace SiMay.Net.SessionProvider.Core +namespace SiMay.Net.SessionProviderService { - public class Win32Api + public class Win32 { + public const int WM_SYSCOMMAND = 0x112; + + public const Int32 MF_SEPARATOR = 0x800; + public const Int32 MF_BYPOSITION = 0x400; + public const Int32 MF_STRING = 0x0; + public const Int32 MF_REMOVE = 0x1000; + + public const uint MF_ENABLED = 0; + public const uint MF_DISABLED = (uint)0x00000002L; + public const uint MF_UNCHECKED = 0; + public const uint MF_CHECKED = (uint)0x00000008L; + [DllImport("user32.dll")] public static extern IntPtr GetSystemMenu(IntPtr hWnd, bool bRevert);//获取窗体系统菜单 - [DllImport("user32.dll")] - + [DllImport("user32.dll")] public static extern bool InsertMenu(IntPtr hMenu, Int32 wPosition, Int32 wFlags, Int32 wIDNewItem, string lpNewItem);//插入菜单 [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)] @@ -22,11 +34,9 @@ namespace SiMay.Net.SessionProvider.Core [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)] private static extern bool SetMenuItemBitmaps(IntPtr hMenu, Int32 nPosition, Int32 nFlags, Bitmap pBmpUnchecked, Bitmap pBmpchecked);//设置菜单图片 - [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)] public static extern bool InsertMenuItem(IntPtr hMenu, Int32 uItem, Int32 lpMenuItemInfo, bool fByPos);//插入菜单 - [DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)] public static extern bool AppendMenu(IntPtr hMenu, Int32 nFlags, Int32 IDNewItem, string lpNewItem);//追加菜单 @@ -37,16 +47,7 @@ namespace SiMay.Net.SessionProvider.Core public static extern bool EnableMenuItem(IntPtr hmenu, uint uIDEnableItem, uint wEnable);//设置菜单可用 - public const Int32 MF_SEPARATOR = 0x800; - public const Int32 MF_BYPOSITION = 0x400; - public const Int32 MF_STRING = 0x0; - public const Int32 MF_REMOVE = 0x1000; - - public const int WM_SYSCOMMAND = 0x112; - - public const uint MF_ENABLED = 0; - public const uint MF_DISABLED = (uint)0x00000002L; - public const uint MF_UNCHECKED = 0; - public const uint MF_CHECKED = (uint)0x00000008L; + [DllImport("User32")] + public static extern bool FlashWindow(IntPtr hWnd, bool bInvert);//任务栏图标闪烁 } } diff --git a/SiMay.Net.SessionProviderServiceCore/ApplicationConfiguartion.cs b/SiMay.Net.SessionProviderServiceCore/ApplicationConfiguartion.cs new file mode 100644 index 0000000000000000000000000000000000000000..5780d5ed33bb6cea020c26a522ca641e9ac6a148 --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/ApplicationConfiguartion.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProviderServiceCore +{ + internal class ApplicationConfiguartion + { + public static void SetOptions(StartServiceOptions options) => Options = options; + public static StartServiceOptions Options { get; private set; } + } + + public class StartServiceOptions + { + /// + /// 监听地址 + /// + public string LocalAddress { get; set; } + + /// + /// 监听端口 + /// + public int ServicePort { get; set; } + + /// + /// 最大数据包长度 + /// + public long MaxPacketSize { get; set; } + + /// + /// 允许主控端匿名登陆 + /// + public bool MainApplicationAnonyMous { get; set; } + + /// + /// 允许登陆的主控端Id + /// + public long[] MainApplicationAllowAccessId { get; set; } + + /// + /// 主控端登陆Key + /// + public long MainAppAccessKey { get; set; } + + /// + /// 连接AccessKey + /// + public long AccessKey { get; set; } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/Dispatcher/ApportionDispatcher.cs b/SiMay.Net.SessionProviderServiceCore/Dispatcher/ApportionDispatcher.cs new file mode 100644 index 0000000000000000000000000000000000000000..af5c0bb59397e52055e0102738864dfa1a6c6a65 --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/Dispatcher/ApportionDispatcher.cs @@ -0,0 +1,136 @@ +using SiMay.Basic; +using SiMay.Net.SessionProvider.Core; +using SiMay.Serialize.Standard; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SiMay.Net.SessionProviderServiceCore +{ + + /// + /// 连接分配器 + /// + public class ApportionDispatcher : DispatcherBase + { + public static AckPacket AckPacketData { get; set; } + private const Int16 ACK_HEAD = 1000; + + public event Action ApportionTypeHandlerEvent; + + private byte[] _ackRetainData; + private long _accessId; + public override void OnMessage() + { + var defineHeadSize = sizeof(int); + if (ListByteBuffer.Count < defineHeadSize) + return; + + byte[] lenBytes = ListByteBuffer.GetRange(0, defineHeadSize).ToArray(); + int packageLen = BitConverter.ToInt32(lenBytes, 0); + + if (packageLen < 0 || packageLen > ApplicationConfiguartion.Options.MaxPacketSize || packageLen < 25) //数据不合法 或 小于大概ack固定长度 + { + this.Log(LogOutLevelType.Error, $"Type:{ConnectionWorkType.ToString()} 长度不合法!"); + this.CloseSession(); + return; + } + + if (packageLen + defineHeadSize > ListByteBuffer.Count) + return; + + this._ackRetainData = ListByteBuffer.GetRange(defineHeadSize, packageLen).ToArray(); + ListByteBuffer.RemoveRange(0, packageLen + defineHeadSize); + + var longSize = sizeof(long); + var packageBody = GZipHelper.Decompress(_ackRetainData, longSize, _ackRetainData.Length - longSize); + var messageHead = TakeMessageHead(packageBody); + if (messageHead == ACK_HEAD) + { + AckPacketData = PacketSerializeHelper.DeserializePacket(TakeMessage(packageBody)); + + this._accessId = AckPacketData.AccessId; + + if (ValidityAccessIdWithKey((ConnectionWorkType)AckPacketData.Type, AckPacketData.AccessId, AckPacketData.AccessKey)) + this.ApportionTypeHandlerEvent?.Invoke(this, (ConnectionWorkType)AckPacketData.Type); + else + { + if ((ConnectionWorkType)AckPacketData.Type == ConnectionWorkType.MainApplicationConnection) + { + var midData = MessageHelper.CopyMessageHeadTo(MessageHead.MID_ACCESS_KEY_WRONG); + this.CurrentSession.SendAsync(midData.BuilderHeadPacket()); + } + this.Log(LogOutLevelType.Debug, $"Type:{((ConnectionWorkType)AckPacketData.Type).ToString()} AccessId:{AckPacketData.AccessId} 或AccessKey:{AckPacketData.AccessKey} 验证失败,登陆不成功!"); + this.CloseSession(); + } + } + else + { + this.CloseSession(); + this.Log(LogOutLevelType.Warning, $"未知消息,连接被关闭!"); + } + + } + + /// + /// 验证是否允许连接 + /// + /// + /// + /// + /// + private bool ValidityAccessIdWithKey(ConnectionWorkType type, long id, long key) + { + if (type == ConnectionWorkType.MainApplicationConnection && ApplicationConfiguartion.Options.MainApplicationAnonyMous) + return key.Equals(ApplicationConfiguartion.Options.MainAppAccessKey);//主控端允许匿名Id登陆 + else if (type == ConnectionWorkType.MainApplicationConnection && !ApplicationConfiguartion.Options.MainApplicationAnonyMous) + return ApplicationConfiguartion.Options.MainApplicationAllowAccessId.Contains(id) && ApplicationConfiguartion.Options.MainAppAccessKey.Equals(key); + else + { + return key.Equals(ApplicationConfiguartion.Options.AccessKey);//其他的暂仅验证AccessKey + } + } + + /// + /// 获取被控服务AccessId + /// + /// + public long GetAccessId() + { + if (_ackRetainData.IsNull()) + throw new ArgumentNullException(); + + return _accessId; + } + + /// + /// 获取Ack数据 + /// + /// + public byte[] GetACKPacketData() + { + if (_ackRetainData.IsNull()) + throw new ArgumentNullException(); + + return _ackRetainData; + } + + private Int16 TakeMessageHead(byte[] data) + { + return BitConverter.ToInt16(data, 0); + } + private byte[] TakeMessage(byte[] data) + { + var defineHeadSize = sizeof(Int16); + byte[] payload = new byte[data.Length - defineHeadSize]; + Array.Copy(data, defineHeadSize, payload, 0, data.Length - defineHeadSize); + return payload; + } + + public override void OnClosed() + { + ListByteBuffer.Clear(); + } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionApplicationWorkerConnection.cs b/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionApplicationWorkerConnection.cs new file mode 100644 index 0000000000000000000000000000000000000000..c2cc0749976622ea98e51072911c7d4553a411ce --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionApplicationWorkerConnection.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using SiMay.Net.SessionProvider.Core; +using SiMay.Sockets.Tcp; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public class TcpSessionApplicationWorkerConnection : TcpSessionChannelDispatcher + { + /// + /// 是否已与工作连接关联 + /// + public bool IsJoin { get; private set; } + + private TcpSessionApplicationWorkerConnection _targetConnection; + + public void Join(TcpSessionApplicationWorkerConnection targetConnection) + { + if (IsJoin) + return; + IsJoin = true; + _targetConnection = targetConnection; + targetConnection.Join(this); + } + + public override void OnMessageBefore(byte[] data) => this._targetConnection.SendTo(data); + + public override void OnMessage() + { + base.OnMessage(); + if (ListByteBuffer.Count > 0) + { + this._targetConnection.SendTo(ListByteBuffer.ToArray()); + ListByteBuffer.Clear(); + } + } + public override void OnClosed() + { + if (_targetConnection.CurrentSession.State == TcpSocketConnectionState.Closed) + return; + _targetConnection.CloseSession(); + ListByteBuffer.Clear(); + } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionMainApplicationConnection.cs b/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionMainApplicationConnection.cs new file mode 100644 index 0000000000000000000000000000000000000000..b716e7f6593c860be794b23073b7e5fc0c82b8ae --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionMainApplicationConnection.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SiMay.Basic; +using SiMay.Net.SessionProvider.Core; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public class TcpSessionMainApplicationConnection : TcpSessionChannelDispatcher + { + private long _createdTime = DateTime.Now.ToFileTime(); + + public long CreatedTime => _createdTime; + + public override ConnectionWorkType ConnectionWorkType => ConnectionWorkType.MainApplicationConnection; + + private readonly IDictionary _dispatchers; + public TcpSessionMainApplicationConnection(IDictionary dispatchers) => _dispatchers = dispatchers; + + public override void OnMessage() + { + base.OnMessage(); + + int defineHeadSize = sizeof(int); + do + { + if (ListByteBuffer.Count < defineHeadSize) + return; + + byte[] lenBytes = ListByteBuffer.GetRange(0, defineHeadSize).ToArray(); + int packageLen = BitConverter.ToInt32(lenBytes, 0); + + if (packageLen < 0 || packageLen > ApplicationConfiguartion.Options.MaxPacketSize) + { + this.CloseSession(); + this.Log(LogOutLevelType.Error, $"Type:{ConnectionWorkType.ToString()} 长度不合法!"); + return; + } + + if (packageLen + defineHeadSize > ListByteBuffer.Count) + return; + + byte[] mainAppMessageData = ListByteBuffer.GetRange(defineHeadSize, packageLen).ToArray(); + + this.MessageCompletedHandler(mainAppMessageData); + ListByteBuffer.RemoveRange(0, packageLen + defineHeadSize); + + } while (ListByteBuffer.Count > defineHeadSize); + } + + private void MessageCompletedHandler(byte[] data) + { + + switch (data.GetMessageHead()) + { + case MessageHead.APP_PULL_SESSION: + this.GetAllSessionItem(); + break; + case MessageHead.APP_MESSAGE_DATA: + var message = data.GetMessageEntity(); + this.TranspondMessage(message.DispatcherId, message.Data); + break; + default: + break; + } + } + + /// + /// 获取所有主服务连接 + /// + private void GetAllSessionItem() + { + var mainServiceConnections = _dispatchers + .Select(c => c.Value) + .Where(c => c.ConnectionWorkType == ConnectionWorkType.MainServiceConnection) + .Cast() + .ToList(); + + var data = MessageHelper.CopyMessageHeadTo(MessageHead.MID_SESSION, + new SessionPacket() + { + SessionItems = mainServiceConnections.Select(c => new SessionItemPacket() + { + Id = c.DispatcherId, + ACKPacketData = c.ACKPacketData + }).ToArray() + }); + SendTo(data); + } + + /// + /// 构造带长度消息头的数据 + /// + /// + public override void SendTo(byte[] data) + { + base.SendTo(data.BuilderHeadPacket()); + } + + private void TranspondMessage(long dispatcherId, byte[] data) + { + TcpSessionChannelDispatcher dispatcher; + if (_dispatchers.TryGetValue(dispatcherId, out dispatcher)) + { + dispatcher.SendTo(data.BuilderHeadPacket());//直接转发 + } + else this.Log(LogOutLevelType.Debug, $"ID:{dispatcherId} 未找到主服务连接!"); + } + + public override void OnClosed() + { + ListByteBuffer.Clear(); + } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionMainConnection.cs b/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionMainConnection.cs new file mode 100644 index 0000000000000000000000000000000000000000..d3dfc3750df9bb954f662aed41e898a5a1b1baa9 --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/Dispatcher/TcpSessionMainConnection.cs @@ -0,0 +1,91 @@ +using SiMay.Net.SessionProvider.Core; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public class TcpSessionMainConnection : TcpSessionChannelDispatcher + { + public override ConnectionWorkType ConnectionWorkType => ConnectionWorkType.MainServiceConnection; + + private readonly object _sendLock = new object(); + private readonly IDictionary _dispatchers; + public TcpSessionMainConnection(IDictionary dispatchers) => _dispatchers = dispatchers; + + public byte[] ACKPacketData { get; set; } + + long? _accessId; + long? _lastChannelCreatedTime; + int? _packageLength; + int _transpondOffset; + public override void OnMessage() + { + base.OnMessage(); + + int defineHeadSize = sizeof(int); + int defineAccessIdSize = sizeof(long); + do + { + if (!_accessId.HasValue && !_packageLength.HasValue) + { + if (ListByteBuffer.Count < defineHeadSize + defineAccessIdSize) + break; + + byte[] headBytes = ListByteBuffer.GetRange(0, defineHeadSize + defineAccessIdSize).ToArray(); + this._packageLength = BitConverter.ToInt32(headBytes, 0); + this._accessId = BitConverter.ToInt64(headBytes, defineHeadSize); + this._transpondOffset = 0; + } + + var calculateOffsetLength = (_packageLength.Value + defineHeadSize) - _transpondOffset; + if (ListByteBuffer.Count <= calculateOffsetLength) + calculateOffsetLength = ListByteBuffer.Count; + this._transpondOffset += calculateOffsetLength; + if (calculateOffsetLength == 0) + { + this._accessId = null; this._packageLength = null; this._lastChannelCreatedTime = null; continue; + } + var waitTranspondData = ListByteBuffer.GetRange(0, calculateOffsetLength).ToArray(); + TcpSessionChannelDispatcher dispatcher; + if (_dispatchers.TryGetValue(_accessId.Value, out dispatcher) && dispatcher is TcpSessionMainApplicationConnection mainApplicationConnection) + { + if (!_lastChannelCreatedTime.HasValue) + this._lastChannelCreatedTime = mainApplicationConnection.CreatedTime; + + //数据包未完整发送完成期间,如果主控端被登出,则剩余的数据不再发送 + if (mainApplicationConnection.CreatedTime == _lastChannelCreatedTime.Value) + { + mainApplicationConnection.SendTo(MessageHelper.CopyMessageHeadTo(MessageHead.MID_MESSAGE_DATA, + new MessageDataPacket() + { + AccessId = dispatcher.DispatcherId, + DispatcherId = this.DispatcherId, + Data = waitTranspondData + })); + } + else + { + this.Log(LogOutLevelType.Debug, "原主控端已离线,数据被抛弃!"); + } + } + ListByteBuffer.RemoveRange(0, calculateOffsetLength); + } while (ListByteBuffer.Count > defineHeadSize + defineAccessIdSize); + } + + public override void SendTo(byte[] data) + { + //防止其他线程发送消息 + lock (this._sendLock) + { + base.SendTo(data); + } + } + + public override void OnClosed() + { + ListByteBuffer.Clear(); + } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/DispatcherBase/DispatcherBase.cs b/SiMay.Net.SessionProviderServiceCore/DispatcherBase/DispatcherBase.cs new file mode 100644 index 0000000000000000000000000000000000000000..0f5d49cac838e67ff7da7719e8c7f442852243b3 --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/DispatcherBase/DispatcherBase.cs @@ -0,0 +1,119 @@ +using SiMay.Net.SessionProvider.Core; +using SiMay.Sockets.Tcp.Session; +using System; +using System.Collections.Generic; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public abstract class DispatcherBase : IDisposable + { + /// + /// 输出日志 + /// + /// + /// + protected void Log(LogOutLevelType logLevel, string log) + => this.LogOutputEventHandler?.Invoke(this, logLevel, log); + + /// + /// 日志输出事件 + /// + public event Action LogOutputEventHandler; + + /// + /// 当前连接会话 + /// + public TcpSocketSaeaSession CurrentSession + { + get; + protected set; + } + + private long? _dispatcherId; + /// + /// Id + /// + public virtual long DispatcherId + { + get + { + if (_dispatcherId.HasValue) + return _dispatcherId.Value; + else + { + _dispatcherId = this.GetHashCode(); + return _dispatcherId.Value; + } + } + set + { + _dispatcherId = value; + } + } + + /// + /// 连接工作类型 + /// + public virtual ConnectionWorkType ConnectionWorkType + { + get; + set; + } = ConnectionWorkType.None; + + /// + /// 缓冲区 + /// + public virtual List ListByteBuffer + { + get; + set; + } = new List(); + + /// + /// 设置连接会话 + /// + /// + public virtual void SetSession(TcpSocketSaeaSession session) + { + CurrentSession = session; + + session.AppTokens = new object[] + { + this, + ConnectionWorkType + }; + } + + /// + /// 关闭当前会话 + /// + public virtual void CloseSession() + { + CurrentSession.Close(true); + } + + /// + /// 消息处理前 + /// + /// + public virtual void OnMessageBefore(byte[] data) + => ListByteBuffer.AddRange(data); + + /// + /// 触发消息处理 + /// + public abstract void OnMessage(); + + + /// + /// 会话关闭 + /// + public abstract void OnClosed(); + + + public virtual void Dispose() + { + ListByteBuffer.Clear(); + } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/DispatcherBase/TcpSessionChannelDispatcher.cs b/SiMay.Net.SessionProviderServiceCore/DispatcherBase/TcpSessionChannelDispatcher.cs new file mode 100644 index 0000000000000000000000000000000000000000..8ce6b8d9b2e04563da7d15890741adbf90bbae34 --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/DispatcherBase/TcpSessionChannelDispatcher.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public abstract class TcpSessionChannelDispatcher : DispatcherBase + { + /// + /// 接收长度 + /// + public event Action ReceiveStreamLengthEventHandler; + + /// + /// 发送长度 + /// + public event Action SendStreamLengthEventHandler; + + public override void OnMessage() + { + this.ReceiveStreamLengthEventHandler?.Invoke(this, ListByteBuffer.Count); + } + + public virtual void SendTo(byte[] data) + { + this.CurrentSession.SendAsync(data); + this.SendStreamLengthEventHandler?.Invoke(this, data.Length); + } + } +} diff --git a/SiMay.Net.SessionProviderService/Packet/AckPacket.cs b/SiMay.Net.SessionProviderServiceCore/Enums/LogOutLevelType.cs similarity index 35% rename from SiMay.Net.SessionProviderService/Packet/AckPacket.cs rename to SiMay.Net.SessionProviderServiceCore/Enums/LogOutLevelType.cs index 21c9b1458943e9c2c0b800c6c96f534072088047..88c26d571ea69730697f01072db5ad790fb18154 100644 --- a/SiMay.Net.SessionProviderService/Packet/AckPacket.cs +++ b/SiMay.Net.SessionProviderServiceCore/Enums/LogOutLevelType.cs @@ -1,24 +1,24 @@ using System; using System.Collections.Generic; -using System.Linq; using System.Text; -using System.Threading.Tasks; -namespace SiMay.Net.SessionProviderService.Packet +namespace SiMay.Net.SessionProviderServiceCore { - public class AckPacket + public enum LogOutLevelType { /// - /// 命令头 + /// 调试信息 /// - public short MsgCommand { get; set; } + Debug, + /// - /// 用于连接后,业务层验证此键是否允许访问 + /// 警告 /// - public long AccessKey { get; set; } + Warning, + /// - /// 代理协议,判断连接类型 + /// 异常错误 /// - public byte ServiceType { get; set; } + Error } } diff --git a/SiMay.Net.SessionProviderServiceCore/Extension/CreateDispatcherExtension.cs b/SiMay.Net.SessionProviderServiceCore/Extension/CreateDispatcherExtension.cs new file mode 100644 index 0000000000000000000000000000000000000000..38a81bc62a7289025ac6120d42d7dc0603b9976e --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/Extension/CreateDispatcherExtension.cs @@ -0,0 +1,49 @@ +using SiMay.Net.SessionProvider.Core; +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public static class CreateDispatcherExtension + { + public static TcpSessionMainConnection CreateMainServiceChannelDispatcher(this ApportionDispatcher apportionDispatcher, IDictionary dispatchers) + { + var mainServiceChannelDispatcher = new TcpSessionMainConnection(dispatchers); + mainServiceChannelDispatcher.ACKPacketData = apportionDispatcher.GetACKPacketData(); + mainServiceChannelDispatcher.SetSession(apportionDispatcher.CurrentSession); + var bufferData = apportionDispatcher.ListByteBuffer.ToArray(); + if (bufferData.Length > 0)//如缓冲区有数据,则处理消息 + { + mainServiceChannelDispatcher.ListByteBuffer.AddRange(bufferData); + mainServiceChannelDispatcher.OnMessage(); + } + return mainServiceChannelDispatcher; + } + + public static TcpSessionMainApplicationConnection CreateMainApplicationChannelDispatcher(this ApportionDispatcher apportionDispatcher, IDictionary dispatchers) + { + var accessId = apportionDispatcher.GetAccessId(); + var mainappChannelDispatcher = new TcpSessionMainApplicationConnection(dispatchers); + mainappChannelDispatcher.DispatcherId = accessId; + mainappChannelDispatcher.SetSession(apportionDispatcher.CurrentSession); + + var bufferData = apportionDispatcher.ListByteBuffer.ToArray(); + if (bufferData.Length > 0)//如缓冲区有数据,则处理消息 + { + mainappChannelDispatcher.ListByteBuffer.AddRange(bufferData); + mainappChannelDispatcher.OnMessage(); + } + return mainappChannelDispatcher; + } + + public static TcpSessionApplicationWorkerConnection CreateApplicationWorkerChannelDispatcher(this ApportionDispatcher apportionDispatcher, IDictionary dispatchers, ConnectionWorkType workType) + { + var workerConnection = new TcpSessionApplicationWorkerConnection(); + workerConnection.ConnectionWorkType = workType; + workerConnection.SetSession(apportionDispatcher.CurrentSession); + return workerConnection; + } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/MainSessionProviderService.cs b/SiMay.Net.SessionProviderServiceCore/MainSessionProviderService.cs new file mode 100644 index 0000000000000000000000000000000000000000..db0d153a02798e68a84ab6dd16e6891eff101400 --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/MainSessionProviderService.cs @@ -0,0 +1,289 @@ +using SiMay.Basic; +using SiMay.Net.SessionProvider.Core; +using SiMay.Sockets.Tcp; +using SiMay.Sockets.Tcp.Server; +using SiMay.Sockets.Tcp.Session; +using SiMay.Sockets.Tcp.TcpConfiguration; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Threading; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public class MainSessionProviderService + { + /// + /// 日志输出 + /// + public event Action LogOutputEventHandler; + + /// + /// 连接事件 + /// + public event Action OnConnectedEventHandler; + + /// + /// 离线事件 + /// + public event Action OnClosedEventHandler; + + /// + /// 主线程同步上下文 + /// + public SynchronizationContext SynchronizationContext { get; set; } + + private TcpSocketSaeaServer _tcpSaeaServer; + private IList> _appServiceChannels = new List>(); + private IDictionary _dispatchers = new Dictionary(); + public bool StartService(StartServiceOptions options) + { + ApplicationConfiguartion.SetOptions(options); + + var serverConfig = new TcpSocketSaeaServerConfiguration(); + serverConfig.ReuseAddress = false; + serverConfig.KeepAlive = true; + serverConfig.KeepAliveInterval = 5000; + serverConfig.KeepAliveSpanTime = 1000; + serverConfig.PendingConnectionBacklog = 0; + + var ipe = new IPEndPoint(IPAddress.Parse(ApplicationConfiguartion.Options.LocalAddress), ApplicationConfiguartion.Options.ServicePort); + + _tcpSaeaServer = TcpSocketsFactory.CreateServerAgent(TcpSocketSaeaSessionType.Full, serverConfig, (notify, session) => + { + if (SynchronizationContext.IsNull()) + NotifyProc(null); + else + SynchronizationContext.Send(NotifyProc, null); + + void NotifyProc(object @object) + { + switch (notify) + { + case TcpSessionNotify.OnConnected: + + ApportionDispatcher apportionDispatcher = new ApportionDispatcher(); + apportionDispatcher.ApportionTypeHandlerEvent += ApportionTypeHandlerEvent; + apportionDispatcher.LogOutputEventHandler += ApportionDispatcher_LogOutputEventHandler; + apportionDispatcher.SetSession(session); + + break; + case TcpSessionNotify.OnSend: + break; + case TcpSessionNotify.OnDataReceiveing: + this.OnDataReceiveingHandler(session); + break; + case TcpSessionNotify.OnClosed: + this.OnClosedHandler(session); + break; + default: + break; + } + } + }); + + try + { + _tcpSaeaServer.Listen(ipe); + LogOutputEventHandler?.Invoke(LogOutLevelType.Debug, $"SiMay中间会话服务器监听 {ipe.Port} 端口启动成功!"); + return true; + } + catch (Exception ex) + { + LogOutputEventHandler?.Invoke(LogOutLevelType.Error, $"SiMay中间会话服务器启动发生错误,端口:{ipe.Port} 错误信息:{ex.Message}!"); + return false; + } + } + + private void ApportionDispatcher_LogOutputEventHandler(DispatcherBase dispatcher, LogOutLevelType level, string log) + { + LogOutputEventHandler?.Invoke(level, log); + } + + private void OnDataReceiveingHandler(TcpSocketSaeaSession session) + { + byte[] data = session.CompletedBuffer.Copy(0, session.ReceiveBytesTransferred); + var dispatcher = session.AppTokens[SysContanct.INDEX_WORKER].ConvertTo(); + dispatcher.OnMessageBefore(data); + dispatcher.OnMessage(); + } + + private void OnClosedHandler(TcpSocketSaeaSession session) + { + var closedDispatcher = session.AppTokens[SysContanct.INDEX_WORKER].ConvertTo(); + closedDispatcher.OnClosed(); + + if (closedDispatcher.ConnectionWorkType == ConnectionWorkType.MainServiceConnection) + { + var data = MessageHelper.CopyMessageHeadTo(MessageHead.MID_SESSION_CLOSED, + new SessionClosedPacket() + { + Id = closedDispatcher.DispatcherId + }); + + //通知所有主控端离线 + _dispatchers + .Select(c => c.Value) + .Where(c => c.ConnectionWorkType == ConnectionWorkType.MainApplicationConnection) + .ForEach(c => c.SendTo(data)); + } + + var serviceWorkerChannelItem = this._appServiceChannels.FirstOrDefault(c => c.Item2 == closedDispatcher.DispatcherId); + if (!serviceWorkerChannelItem.IsNull()) + _appServiceChannels.Remove(serviceWorkerChannelItem); + + if (_dispatchers.ContainsKey(closedDispatcher.DispatcherId)) + _dispatchers.Remove(closedDispatcher.DispatcherId); + + if (closedDispatcher is ApportionDispatcher ofclosedApportionDispatcher) + { + ofclosedApportionDispatcher.ApportionTypeHandlerEvent -= ApportionTypeHandlerEvent; + ofclosedApportionDispatcher.LogOutputEventHandler -= ApportionDispatcher_LogOutputEventHandler; + ofclosedApportionDispatcher.Dispose(); + } + + if (closedDispatcher is TcpSessionChannelDispatcher tcpSessionChannelDispatcher) + this.OnClosedEventHandler?.Invoke(tcpSessionChannelDispatcher); + + this.LogOutputEventHandler?.Invoke(LogOutLevelType.Warning, $"ID:{closedDispatcher.DispatcherId} 的连接已与服务器断开连接!"); + } + + private void ApportionTypeHandlerEvent(ApportionDispatcher apportionDispatcher, ConnectionWorkType type) + { + switch (type) + { + case ConnectionWorkType.MainServiceConnection: + this.MainServiceConnect(apportionDispatcher); + break; + case ConnectionWorkType.MainApplicationConnection: + this.MainApplicationConnect(apportionDispatcher); + break; + case ConnectionWorkType.ApplicationServiceConnection: + this.ApplicationServiceConnect(apportionDispatcher); + break; + case ConnectionWorkType.ApplicationConnection: + this.ApplicationConnect(apportionDispatcher); + break; + case ConnectionWorkType.None: + break; + default: + break; + } + this.LogOutputEventHandler?.Invoke(LogOutLevelType.Debug, $"工作类型:{type.ToString()} 的连接已分配!"); + } + + private void MainServiceConnect(ApportionDispatcher apportionDispatcher) + { + var mainServiceChannelDispatcher = apportionDispatcher.CreateMainServiceChannelDispatcher(_dispatchers); + + var data = MessageHelper.CopyMessageHeadTo(MessageHead.MID_SESSION, + new SessionPacket() + { + SessionItems = new SessionItemPacket[] + { + new SessionItemPacket(){ + Id = mainServiceChannelDispatcher.DispatcherId, + ACKPacketData = mainServiceChannelDispatcher.ACKPacketData + } + } + }); + //通知所有主控端上线 + _dispatchers + .Select(c => c.Value) + .Where(c => c.ConnectionWorkType == ConnectionWorkType.MainApplicationConnection) + .ForEach(c => c.SendTo(data)); + + this.OnConnectedEventHandler?.Invoke(mainServiceChannelDispatcher); + _dispatchers.Add(mainServiceChannelDispatcher.DispatcherId, mainServiceChannelDispatcher); + + + } + + private void MainApplicationConnect(ApportionDispatcher apportionDispatcher) + { + var accessId = apportionDispatcher.GetAccessId(); + var mainappChannelDispatcher = apportionDispatcher.CreateMainApplicationChannelDispatcher(_dispatchers); + if (_dispatchers.ContainsKey(accessId))//可能重连太快 + { + var aboutOfCloseDispatcher = _dispatchers[accessId]; + + var data = MessageHelper.CopyMessageHeadTo(MessageHead.MID_LOGOUT, + new LogOutPacket() + { + Message = "已有相同Id的主控端登陆,你已被登出" + }); + aboutOfCloseDispatcher.SendTo(data); + aboutOfCloseDispatcher.CloseSession();//调用后底层会触发Closed事件 + + this.LogOutputEventHandler?.Invoke(LogOutLevelType.Debug, $"有相同Id:{accessId}的主控端登陆!"); + } + _dispatchers.Add(accessId, mainappChannelDispatcher); + + this.OnConnectedEventHandler?.Invoke(mainappChannelDispatcher); + } + + private void ApplicationServiceConnect(ApportionDispatcher apportionDispatcher) + { + var appWorkerConnectionDispatcher = apportionDispatcher.CreateApplicationWorkerChannelDispatcher(_dispatchers, ConnectionWorkType.ApplicationServiceConnection); + + appWorkerConnectionDispatcher.ListByteBuffer.AddRange(apportionDispatcher.GetACKPacketData().BuilderHeadPacket()); + + if (apportionDispatcher.ListByteBuffer.Count > 0) + { + var bufferData = apportionDispatcher.ListByteBuffer.ToArray(); + appWorkerConnectionDispatcher.ListByteBuffer.AddRange(bufferData); + } + + this._dispatchers.Add(appWorkerConnectionDispatcher.DispatcherId, appWorkerConnectionDispatcher); + this._appServiceChannels.Add(new Tuple(apportionDispatcher.GetAccessId(), appWorkerConnectionDispatcher.DispatcherId)); + this.OnConnectedEventHandler?.Invoke(appWorkerConnectionDispatcher); + //找到相应主控端连接 + TcpSessionChannelDispatcher dispatcher; + if (_dispatchers.TryGetValue(apportionDispatcher.GetAccessId(), out dispatcher)) + { + var data = MessageHelper.CopyMessageHeadTo(MessageHead.MID_APPWORK); + dispatcher.SendTo(data); + } + else + { + appWorkerConnectionDispatcher.CloseSession(); + this.LogOutputEventHandler?.Invoke(LogOutLevelType.Debug, $"应用服务工作连接未找到相应的主控端!"); + } + } + + private void ApplicationConnect(ApportionDispatcher apportionDispatcher) + { + TcpSessionChannelDispatcher dispatcher = null; + var serviceWorkerChannelItem = this._appServiceChannels.FirstOrDefault(c => c.Item1 == apportionDispatcher.GetAccessId()); + if (!serviceWorkerChannelItem.IsNull() && _dispatchers.TryGetValue(serviceWorkerChannelItem.Item2, out dispatcher)) + { + this._appServiceChannels.Remove(serviceWorkerChannelItem); + var serviceChannelDispatcher = dispatcher.ConvertTo(); + var appChannelDispatcher = apportionDispatcher.CreateApplicationWorkerChannelDispatcher(_dispatchers, ConnectionWorkType.ApplicationConnection); + + if (apportionDispatcher.ListByteBuffer.Count > 0) + { + var bufferData = apportionDispatcher.ListByteBuffer.ToArray(); + appChannelDispatcher.ListByteBuffer.AddRange(bufferData); + } + + this._dispatchers.Add(appChannelDispatcher.DispatcherId, appChannelDispatcher); + this.OnConnectedEventHandler?.Invoke(appChannelDispatcher); + + if (!serviceChannelDispatcher.IsJoin) + { + serviceChannelDispatcher.Join(appChannelDispatcher); + serviceChannelDispatcher.OnMessage(); + appChannelDispatcher.OnMessage(); + } + else appChannelDispatcher.CloseSession(); + } + else + { + apportionDispatcher.CloseSession(); + this.LogOutputEventHandler?.Invoke(LogOutLevelType.Debug, $"主控端应用工作连接未找到可匹配的应用服务工作连接!"); + } + } + } +} diff --git a/SiMay.Net.SessionProviderServiceCore/SiMay.Net.SessionProviderServiceCore.csproj b/SiMay.Net.SessionProviderServiceCore/SiMay.Net.SessionProviderServiceCore.csproj new file mode 100644 index 0000000000000000000000000000000000000000..b2fff1cb9346ac560cd566e8ba4a59f635c597fc --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/SiMay.Net.SessionProviderServiceCore.csproj @@ -0,0 +1,16 @@ + + + + netstandard2.0 + false + false + + + + + + + + + + diff --git a/SiMay.Net.SessionProviderServiceCore/SysContanct.cs b/SiMay.Net.SessionProviderServiceCore/SysContanct.cs new file mode 100644 index 0000000000000000000000000000000000000000..54ebdb1b2237bcafba86b3f40f716b41b8f052f5 --- /dev/null +++ b/SiMay.Net.SessionProviderServiceCore/SysContanct.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace SiMay.Net.SessionProviderServiceCore +{ + public class SysContanct + { + public const int INDEX_WORKER = 0; + public const int INDEX_WORKTYPE = 1; + } +} diff --git a/SiMay.RemoteClient.NewCore/App.config b/SiMay.RemoteClient.NewCore/App.config index bdca387115c48cb9c60b35a8478c2a32e6f84291..07684763db3d77a59f8f0a8c91b1fce838f5f305 100644 --- a/SiMay.RemoteClient.NewCore/App.config +++ b/SiMay.RemoteClient.NewCore/App.config @@ -2,7 +2,7 @@ - + diff --git a/SiMay.RemoteClient.NewCore/AppConfiguartion.cs b/SiMay.RemoteClient.NewCore/AppConfiguartion.cs index 811cb8c6beffcd6d51e3724a33bc4474c7ce27e2..6c64f352d8edcfaaeb497f8da6b5814bc428e156 100644 --- a/SiMay.RemoteClient.NewCore/AppConfiguartion.cs +++ b/SiMay.RemoteClient.NewCore/AppConfiguartion.cs @@ -49,7 +49,7 @@ namespace SiMay.ServiceCore /// /// 连接的服务端是否中间服务器 /// - public static bool IsCentreServiceMode { get; set; } = false; + public static bool CenterServiceMode { get; set; } = false; public static string IdentifyId { get; set; } public static IPEndPoint ServerIPEndPoint { get; set; } @@ -86,86 +86,136 @@ namespace SiMay.ServiceCore } } - public static string IsOpenScreenView + public static bool IsOpenScreenView { get { - return SysConfigs.GetConfig("isOpenScreenView"); + try + { + return bool.Parse(SysConfigs.GetConfig("isOpenScreenView")); + } + catch + { + return false; + } } set { - SysConfigs.SetConfig("isOpenScreenView", value); + SysConfigs.SetConfig("isOpenScreenView", value.ToString()); } } - public static string IsScreenRecord + public static bool IsScreenRecord { get { - return SysConfigs.GetConfig("IsScreenRecord"); + try + { + return bool.Parse(SysConfigs.GetConfig("IsScreenRecord")); + } + catch + { + return false; + } } set { - SysConfigs.SetConfig("IsScreenRecord", value); + SysConfigs.SetConfig("IsScreenRecord", value.ToString()); } } - public static string ScreenRecordHeight + public static int ScreenRecordHeight { get { - return SysConfigs.GetConfig("ScreenRecordHeight"); + try + { + return int.Parse(SysConfigs.GetConfig("ScreenRecordHeight")); + } + catch + { + return 800; + } } set { - SysConfigs.SetConfig("ScreenRecordHeight", value); + SysConfigs.SetConfig("ScreenRecordHeight", value.ToString()); } } - public static string ScreenRecordWidth + public static int ScreenRecordWidth { get { - return SysConfigs.GetConfig("ScreenRecordWidth"); + try + { + return int.Parse(SysConfigs.GetConfig("ScreenRecordWidth")); + } + catch + { + return 1200; + } } set { - SysConfigs.SetConfig("ScreenRecordWidth", value); + SysConfigs.SetConfig("ScreenRecordWidth", value.ToString()); } } - public static string ScreenRecordSpanTime + public static int ScreenRecordSpanTime { get { - return SysConfigs.GetConfig("ScreenRecordSpanTime"); + try + { + return int.Parse(SysConfigs.GetConfig("ScreenRecordSpanTime")); + } + catch + { + return 3000; + } } set { - SysConfigs.SetConfig("ScreenRecordSpanTime", value); + SysConfigs.SetConfig("ScreenRecordSpanTime", value.ToString()); } } - public static string KeyboardOffline + public static bool KeyboardOffline { get { - return SysConfigs.GetConfig("Offlinekeyboard"); + try + { + return bool.Parse(SysConfigs.GetConfig("Offlinekeyboard")); + } + catch + { + return false; + } } set { - SysConfigs.SetConfig("Offlinekeyboard", value); + SysConfigs.SetConfig("Offlinekeyboard", value.ToString()); } } - public static string HasSystemAuthority + public static bool HasSystemAuthority { get { - return SysConfigs.GetConfig("HasSystemAuthority"); + + try + { + return bool.Parse(SysConfigs.GetConfig("HasSystemAuthority")); + } + catch + { + return false; + } } set { - SysConfigs.SetConfig("HasSystemAuthority", value); + SysConfigs.SetConfig("HasSystemAuthority", value.ToString()) ; } } } diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/AForgeViedo.cs b/SiMay.RemoteClient.NewCore/ApplicationService/AForgeViedo.cs index 7de108ddb072cfdfc6efa527c3aee173b3052b29..541190ae5394e61bee52305539418dc75846c822 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/AForgeViedo.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/AForgeViedo.cs @@ -4,7 +4,7 @@ using System; using System.Drawing; using System.Drawing.Imaging; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { public class AForgeViedo @@ -12,7 +12,7 @@ namespace SiMay.ServiceCore.ApplicationService private VideoCaptureDevice videoSource; private Bitmap _img; - public Bitmap GetBitmap() + public Bitmap GetFrame() { return _img; } @@ -43,7 +43,7 @@ namespace SiMay.ServiceCore.ApplicationService { try { - _img = (Bitmap)eventArgs.Frame.Clone(new Rectangle(0, 0,eventArgs.Frame.Width, eventArgs.Frame.Height), PixelFormat.Format16bppRgb555); + _img = eventArgs.Frame.Clone(new Rectangle(0, 0,eventArgs.Frame.Width, eventArgs.Frame.Height), PixelFormat.Format16bppRgb555); GC.Collect(); } diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/AudioService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/AudioService.cs index 197164b9ada8556e2234f0ba730428b41d244088..bb9d8e4a7fc849675861f9911da18f263590b495 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/AudioService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/AudioService.cs @@ -2,24 +2,25 @@ using SiMay.Core; using SiMay.Core.Extensions; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.Extensions; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; using WindSound; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("远程语音")] - [ServiceKey("RemoteAudioJob")] - public class AudioService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_AUDIO)] + public class AudioService : ApplicationRemoteService { private bool _isRun = true; private bool _isPlaying = false; private WinSoundRecord _Recorder = null; private WinSoundPlayer _Player = null; + public override void SessionInited(TcpSocketSaeaSession session) + { + + } public override void SessionClosed() { @@ -61,11 +62,11 @@ namespace SiMay.ServiceCore.ApplicationService } catch { } - SendAsyncToServer(MessageHead.C_AUDIO_DEVICE_OPENSTATE, + SendTo(CurrentSession, MessageHead.C_AUDIO_DEVICE_OPENSTATE, new AudioDeviceStatesPack() { - PlayerEnable = outDeviceOpen == 0 ? true : false, - RecordEnable = inDeviceOpen == 0 ? true : false + PlayerEnable = outDeviceOpen == 0, + RecordEnable = inDeviceOpen == 0 }); } @@ -74,20 +75,20 @@ namespace SiMay.ServiceCore.ApplicationService if (_isPlaying == true) return; - SendAsyncToServer(MessageHead.C_AUDIO_DATA, bytes); + SendTo(CurrentSession, MessageHead.C_AUDIO_DATA, bytes); } [PacketHandler(MessageHead.S_AUDIO_START)] public void SetOpenAudioInConfig(TcpSocketSaeaSession session) { - var config = session.CompletedBuffer.GetMessageEntity(); + var config = GetMessageEntity(session); this.OpenAudio(config.SamplesPerSecond, config.BitsPerSample, config.Channels); } [PacketHandler(MessageHead.S_AUDIO_DEIVCE_ONOFF)] public void SetAudioState(TcpSocketSaeaSession session) { - var state = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + var state = GetMessage(session).ToUnicodeString(); if (state == "0") _isPlaying = true; else if (state == "1") @@ -97,7 +98,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_AUDIO_DATA)] public void PlayerData(TcpSocketSaeaSession session) { - byte[] payload = session.CompletedBuffer.GetMessagePayload(); + byte[] payload = GetMessage(session); try { if (!_isRun || _Player == null || _isPlaying == false) return; //正在录音不播放 diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs index c1dbc585041242d8a5e911f43bd872be487bd6b5..6f0e1c7a281c3c6f7a6bf6c1d5f4cfd3c82817a2 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/FileService.cs @@ -3,14 +3,10 @@ using SiMay.Core; using SiMay.Core.Common; using SiMay.Core.Enums; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.Core.Packets.FileManager; using SiMay.ServiceCore.Attributes; using SiMay.ServiceCore.Entitys; -using SiMay.ServiceCore.Extensions; - -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; using System; using System.Collections.Generic; @@ -20,11 +16,11 @@ using System.Linq; using System.Threading; using static SiMay.ServiceCore.CommonWin32Api; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("文件管理")] - [ServiceKey("FileManagerJob")] - public class FileService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_FILE)] + public class FileService : ApplicationRemoteService { private const int FILE_BUFFER_SIZE = 1024 * 512; @@ -33,6 +29,10 @@ namespace SiMay.ServiceCore.ApplicationService private bool _isStopTask = false; private System.IO.FileStream _fileStream; private ManualResetEvent _event = new ManualResetEvent(true); + public override void SessionInited(TcpSocketSaeaSession session) + { + + } public override void SessionClosed() { this._isSessionClose = true; @@ -43,7 +43,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_UPLOAD)] public void TryFixedDownloadFile(TcpSocketSaeaSession session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); this._event.WaitOne();//等待上个文件传输完成 if (_isSessionClose) return; @@ -74,13 +74,13 @@ namespace SiMay.ServiceCore.ApplicationService this.SendErrorMessage(ex, "文件上传打开失败!"); } Console.WriteLine("send status"); - SendAsyncToServer(MessageHead.C_FILE_OPEN_STATUS, response); + SendTo(CurrentSession, MessageHead.C_FILE_OPEN_STATUS, response); } [PacketHandler(MessageHead.S_FILE_FRIST_DATA)] public void RecvFristDataHandler(TcpSocketSaeaSession session) { - var data = session.CompletedBuffer.GetMessageEntity(); + var data = GetMessageEntity(session); if (data.FileMode == 0) { _fileStream.Position = 0; @@ -97,7 +97,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_DATA)] public void RecvDataHandler(TcpSocketSaeaSession session) { - var data = session.CompletedBuffer.GetMessageEntity(); + var data = GetMessageEntity(session); this.WriteFileAsync(data.Data, data.FileSize); } @@ -112,14 +112,14 @@ namespace SiMay.ServiceCore.ApplicationService if (_fileStream.Length == originSize) this.CloseFileStream(); else - SendAsyncToServer(MessageHead.C_FILE_NEXT_DATA); + SendTo(CurrentSession, MessageHead.C_FILE_NEXT_DATA); }, null); } [PacketHandler(MessageHead.S_FILE_FILE_PASTER)] public void CopyFiles(TcpSocketSaeaSession session) { - var files = session.CompletedBuffer.GetMessageEntity(); + var files = GetMessageEntity(session); ThreadHelper.CreateThread(() => { var failFiles = new List(); @@ -140,7 +140,7 @@ namespace SiMay.ServiceCore.ApplicationService this.SendErrorMessage(ex, "文件复制失败!"); } } - SendAsyncToServer(MessageHead.C_FILE_COPY_FINISH, + SendTo(CurrentSession, MessageHead.C_FILE_COPY_FINISH, new FileCopyFinishPack() { ExceptionFileNames = failFiles.ToArray() @@ -152,7 +152,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_DELETE)] public void DeleteFiles(TcpSocketSaeaSession session) { - var files = session.CompletedBuffer.GetMessageEntity(); + var files = GetMessageEntity(session); ThreadHelper.CreateThread(() => { var response = new List(); @@ -175,7 +175,7 @@ namespace SiMay.ServiceCore.ApplicationService } } - SendAsyncToServer(MessageHead.C_FILE_DELETE_FINISH, + SendTo(CurrentSession, MessageHead.C_FILE_DELETE_FINISH, new FileDeleteFinishPack() { DeleteFileNames = response.ToArray() @@ -187,7 +187,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_CREATE_DIR)] public void CreateDirectory(TcpSocketSaeaSession session) { - var file = session.CompletedBuffer.GetMessageEntity(); + var file = GetMessageEntity(session); var result = true; try { @@ -201,7 +201,7 @@ namespace SiMay.ServiceCore.ApplicationService if (!file.NoCallBack) { - SendAsyncToServer(MessageHead.C_FILE_CREATEF_DIR_FNISH, + SendTo(CurrentSession, MessageHead.C_FILE_CREATEF_DIR_FNISH, new FileCreateDirectoryFinishPack() { IsSuccess = result @@ -212,7 +212,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_RENAME)] public void FileReName(TcpSocketSaeaSession session) { - var file = session.CompletedBuffer.GetMessageEntity(); + var file = GetMessageEntity(session); var result = true; ThreadHelper.CreateThread(() => { @@ -230,7 +230,7 @@ namespace SiMay.ServiceCore.ApplicationService result = false; this.SendErrorMessage(ex, "文件重命名失败!"); } - SendAsyncToServer(MessageHead.C_FILE_RENAME_FINISH, + SendTo(CurrentSession, MessageHead.C_FILE_RENAME_FINISH, new FileReNameFinishPack() { SourceFileName = file.SourceFileName, @@ -243,7 +243,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_OPEN_TEXT)] public void OpenText(TcpSocketSaeaSession session) { - var file = session.CompletedBuffer.GetMessageEntity(); + var file = GetMessageEntity(session); var textPack = new FileTextPack(); if (File.Exists(file.FileName) && new FileInfo(file.FileName).Length <= 1024 * 512) { @@ -262,26 +262,26 @@ namespace SiMay.ServiceCore.ApplicationService else this.SendErrorMessage(new Exception(), "文件不存在或文件长度超出范围!"); - this.SendAsyncToServer(MessageHead.C_FILE_TEXT, textPack); + this.SendTo(CurrentSession, MessageHead.C_FILE_TEXT, textPack); } [PacketHandler(MessageHead.S_FILE_GETDIR_FILES)] public void SendDirectoryFiles(TcpSocketSaeaSession session) { - var file = session.CompletedBuffer.GetMessageEntity(); + var file = GetMessageEntity(session); ThreadPool.QueueUserWorkItem(c => { _isStopTask = false;//允许任务继续 var fileItems = new EventList(100); fileItems.Notify += (list, items) => - this.SendAsyncToServer(MessageHead.C_FILE_DIR_FILES, + this.SendTo(CurrentSession, MessageHead.C_FILE_DIR_FILES, new FileDirectoryFilesPack() { Files = items }); this.DirectoryGetFiles(file.DirectoryPath, fileItems); - this.SendAsyncToServer(MessageHead.C_FILE_DIR_FILES, + this.SendTo(CurrentSession, MessageHead.C_FILE_DIR_FILES, new FileDirectoryFilesPack() { Files = fileItems.ToArray() @@ -328,7 +328,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_DOWNLOAD)] public void TryFixedUploadFile(TcpSocketSaeaSession session) { - var file = session.CompletedBuffer.GetMessageEntity(); + var file = GetMessageEntity(session); //var dir = Path.GetDirectoryName(file.FileName); //if (!Directory.Exists(dir)) // Directory.CreateDirectory(dir); @@ -361,7 +361,7 @@ namespace SiMay.ServiceCore.ApplicationService if (status != 1) { - this.SendAsyncToServer(MessageHead.C_FILE_FRIST_DATA, + this.SendTo(CurrentSession, MessageHead.C_FILE_FRIST_DATA, new FileFristDownloadDataPack() { //fileName = Path.GetFileName(file.FileName), @@ -374,7 +374,7 @@ namespace SiMay.ServiceCore.ApplicationService var fileSize = _fileStream.Length; this.ReadFileAsync(data => { - this.SendAsyncToServer(MessageHead.C_FILE_FRIST_DATA, + this.SendTo(CurrentSession, MessageHead.C_FILE_FRIST_DATA, new FileFristDownloadDataPack() { //fileName = Path.GetFileName(file.FileName), @@ -391,7 +391,7 @@ namespace SiMay.ServiceCore.ApplicationService { this.ReadFileAsync(data => { - this.SendAsyncToServer(MessageHead.C_FILE_DATA, + this.SendTo(CurrentSession, MessageHead.C_FILE_DATA, new FileDownloadDataPack() { Data = data @@ -453,7 +453,7 @@ namespace SiMay.ServiceCore.ApplicationService private void SendErrorMessage(Exception e, string info) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_FILE_ERROR_INFO, + SendTo(CurrentSession, MessageHead.C_FILE_ERROR_INFO, new FileExceptionPack() { OccurredTime = DateTime.Now, @@ -461,13 +461,12 @@ namespace SiMay.ServiceCore.ApplicationService ExceptionMessage = e.Message, StackTrace = e.StackTrace }); - SendAsyncToServer(data); } [PacketHandler(MessageHead.S_FILE_EXECUTE)] public void ExcuteFile(TcpSocketSaeaSession session) { - var file = session.CompletedBuffer.GetMessageEntity(); + var file = GetMessageEntity(session); try { if (Directory.Exists(file.FilePath)) @@ -481,14 +480,14 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_REDIRION)] public void RedirtionHandler(TcpSocketSaeaSession session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); this.GetFileListHandler(Environment.GetFolderPath(pack.SpecialFolder)); } [PacketHandler(MessageHead.S_FILE_GET_FILES)] public void SendFilelist(TcpSocketSaeaSession session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); this.GetFileListHandler(pack.FilePath); } @@ -517,7 +516,7 @@ namespace SiMay.ServiceCore.ApplicationService }) .ToArray(); - SendAsyncToServer(MessageHead.C_FILE_FILE_LIST, new FileListItemsPack() + SendTo(CurrentSession, MessageHead.C_FILE_FILE_LIST, new FileListItemsPack() { FileList = dirs.Concat(files).ToArray(), Path = path, @@ -527,7 +526,7 @@ namespace SiMay.ServiceCore.ApplicationService } catch (Exception e) { - SendAsyncToServer(MessageHead.C_FILE_FILE_LIST, new FileListItemsPack() + SendTo(CurrentSession, MessageHead.C_FILE_FILE_LIST, new FileListItemsPack() { FileList = new FileItem[0], Path = path, @@ -540,11 +539,11 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_FILE_TREE_DIR)] public void GetTreeDirsHandler(TcpSocketSaeaSession session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); if (pack.TargetRoot == "") { var drives = this.GetDrivelist(); - SendAsyncToServer(MessageHead.C_FILE_TREE_DIRS, + SendTo(CurrentSession, MessageHead.C_FILE_TREE_DIRS, new FileTreeDirFilePack() { FileList = drives.ToArray(), @@ -557,7 +556,7 @@ namespace SiMay.ServiceCore.ApplicationService try { var dirs = Directory.GetDirectories(pack.TargetRoot).Select(c => new FileItem() { FileName = Path.GetFileName(c) }).ToArray(); - SendAsyncToServer(MessageHead.C_FILE_TREE_DIRS, + SendTo(CurrentSession, MessageHead.C_FILE_TREE_DIRS, new FileTreeDirFilePack() { FileList = dirs, @@ -567,7 +566,7 @@ namespace SiMay.ServiceCore.ApplicationService } catch (Exception ex) { - SendAsyncToServer(MessageHead.C_FILE_TREE_DIRS, + SendTo(CurrentSession, MessageHead.C_FILE_TREE_DIRS, new FileTreeDirFilePack() { FileList = new FileItem[0], @@ -588,7 +587,7 @@ namespace SiMay.ServiceCore.ApplicationService { var drives = this.GetDrivelist(); - SendAsyncToServer(MessageHead.C_FILE_FILE_LIST, + SendTo(CurrentSession, MessageHead.C_FILE_FILE_LIST, new FileListItemsPack() { FileList = drives.ToArray(), @@ -599,7 +598,7 @@ namespace SiMay.ServiceCore.ApplicationService } catch (Exception e) { - SendAsyncToServer(MessageHead.C_FILE_FILE_LIST, + SendTo(CurrentSession, MessageHead.C_FILE_FILE_LIST, new FileListItemsPack() { FileList = new FileItem[0], diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/Keyboard.cs b/SiMay.RemoteClient.NewCore/ApplicationService/Keyboard.cs index c23a04bbe38098e63e570bba4537d1d9d6de12f1..bfaa2f8294e004a0d21c6a21412701d1422b885e 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/Keyboard.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/Keyboard.cs @@ -8,7 +8,7 @@ using System.Timers; using System.Windows.Forms; using static SiMay.ServiceCore.CommonWin32Api; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { public class Keyboard diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/KeyboardService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/KeyboardService.cs index 29db00bfdcfda29499a8d92d815f5dfe00d2d37d..075f92eb749122a618b29ac950e45ca910fef6a8 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/KeyboardService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/KeyboardService.cs @@ -1,20 +1,20 @@ using SiMay.Core; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; -using SiMay.Core.Packets; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.Extensions; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; -using System; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("键盘输入记录")] [ServiceKey("RemoteKeyboradJob")] - public class KeyboardService : ServiceManagerBase + public class KeyboardService : ApplicationRemoteService { private Keyboard _keyboard; + public override void SessionInited(TcpSocketSaeaSession session) + { + + } + public override void SessionClosed() { if (_keyboard != null) @@ -32,7 +32,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_KEYBOARD_GET_OFFLINEFILE)] public void SendOffLineRecord(TcpSocketSaeaSession session) { - SendAsyncToServer(MessageHead.C_KEYBOARD_OFFLINEFILE, + SendTo(CurrentSession, MessageHead.C_KEYBOARD_OFFLINEFILE, _keyboard.GetOfflineRecord()); } @@ -56,7 +56,7 @@ namespace SiMay.ServiceCore.ApplicationService break; case Keyboard.KeyboardHookEvent.Data: - SendAsyncToServer(MessageHead.C_KEYBOARD_DATA, key); + SendTo(CurrentSession, MessageHead.C_KEYBOARD_DATA, key); break; } } diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/ProcessSpy.cs b/SiMay.RemoteClient.NewCore/ApplicationService/ProcessSpy.cs deleted file mode 100644 index ea2aa9bb1c5280a1e516416ea07b68681b797505..0000000000000000000000000000000000000000 --- a/SiMay.RemoteClient.NewCore/ApplicationService/ProcessSpy.cs +++ /dev/null @@ -1,50 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading; - -namespace SiMay.ServiceCore.ApplicationService -{ - public class ProcessSpy - { - Dictionary _processs = new Dictionary(); - bool _isRun; - public void StartDiff() - { - Thread _thread = new Thread(() => - { - while (this._isRun) - { - var process = Process.GetProcesses(); - - - } - }); - _thread.IsBackground = true; - _thread.Start(); - } - - public void ExitDiff() - { - - } - } - - public enum ChangeType - { - /// - /// 新建进程信息 - /// - CreateProcess, - /// - /// 更新进程信息 - /// - UpdateProcess, - /// - /// 移除进程 - /// - RemoveProcess - } -} diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistryEditor.cs b/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistryEditor.cs index 12f1b0551e2fb8b8cf22f734764e10d0b2b803f5..34d002a7a1f98c4bf6f3d6e8aa4494cdbc88efa5 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistryEditor.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistryEditor.cs @@ -4,7 +4,7 @@ using SiMay.Core.Common; using SiMay.Core.Extensions; using SiMay.Core.Packets.RegEdit; -namespace SiMay.ServiceCore.ApplicationService.Registry +namespace SiMay.ServiceCore { public class RegistryEditor { diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistrySeeker.cs b/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistrySeeker.cs index 5e0522efdb08a6a08fd7610cd06837860badd00b..d017dbb0807c6b7d7a4acb7e790f1da1a4653603 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistrySeeker.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/Registry/RegistrySeeker.cs @@ -5,7 +5,7 @@ using SiMay.Core.Common; using SiMay.Core.Extensions; using SiMay.Core.Packets.RegEdit; -namespace SiMay.ServiceCore.ApplicationService.Registry +namespace SiMay.ServiceCore { public class RegistrySeeker { diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/RegistryEditorService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/RegistryEditorService.cs index 4d1cf48e5c07d9c835d8a6902f6d42d67a72c94c..c444e7cc20d9f7036113d98e0c99bbd61ef27270 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/RegistryEditorService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/RegistryEditorService.cs @@ -2,29 +2,34 @@ using SiMay.Core.Common; using SiMay.Core.Extensions; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; -using SiMay.Core.Packets; using SiMay.Core.Packets.RegEdit; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.ApplicationService.Registry; -using SiMay.ServiceCore.Extensions; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; using System; using System.Collections.Generic; using System.Linq; using System.Text; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("远程注册表")] - [ServiceKey("RemoteRegistryEditorJob")] - public class RegistryEditorService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_REGEDIT)] + public class RegistryEditorService : ApplicationRemoteService { + public override void SessionInited(TcpSocketSaeaSession session) + { + + } + + public override void SessionClosed() + { + + } + [PacketHandler(MessageHead.S_NREG_LOAD_REGKEYS)] public void HandleGetRegistryKey(TcpSocketSaeaSession session) { - DoLoadRegistryKeyPack packet = session.CompletedBuffer.GetMessageEntity(); + DoLoadRegistryKeyPack packet = GetMessageEntity(session); GetRegistryKeysResponsePack responsePacket = new GetRegistryKeysResponsePack(); try { @@ -40,7 +45,7 @@ namespace SiMay.ServiceCore.ApplicationService responsePacket.ErrorMsg = e.Message; } responsePacket.RootKey = packet.RootKeyName; - SendAsyncToServer(MessageHead.C_NREG_LOAD_REGKEYS, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_LOAD_REGKEYS, responsePacket); } #region Registry Key Edit @@ -48,7 +53,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_NREG_CREATE_KEY)] public void HandleCreateRegistryKey(TcpSocketSaeaSession session) { - var packet = session.CompletedBuffer.GetMessageEntity(); + var packet = GetMessageEntity(session); GetCreateRegistryKeyResponsePack responsePacket = new GetCreateRegistryKeyResponsePack(); string errorMsg; string newKeyName = ""; @@ -72,14 +77,14 @@ namespace SiMay.ServiceCore.ApplicationService }; responsePacket.ParentPath = packet.ParentPath; - SendAsyncToServer(MessageHead.C_NREG_CREATE_KEY_RESPONSE, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_CREATE_KEY_RESPONSE, responsePacket); //client.Send(responsePacket); } [PacketHandler(MessageHead.S_NREG_DELETE_KEY)] public void HandleDeleteRegistryKey(TcpSocketSaeaSession session) { - DoDeleteRegistryKeyPack packet = session.CompletedBuffer.GetMessageEntity(); + DoDeleteRegistryKeyPack packet = GetMessageEntity(session); GetDeleteRegistryKeyResponsePack responsePacket = new GetDeleteRegistryKeyResponsePack(); string errorMsg; try @@ -95,14 +100,14 @@ namespace SiMay.ServiceCore.ApplicationService responsePacket.ParentPath = packet.ParentPath; responsePacket.KeyName = packet.KeyName; - SendAsyncToServer(MessageHead.C_NREG_DELETE_KEY_RESPONSE, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_DELETE_KEY_RESPONSE, responsePacket); //client.Send(responsePacket); } [PacketHandler(MessageHead.S_NREG_RENAME_KEY)] public void HandleRenameRegistryKey(TcpSocketSaeaSession session) { - DoRenameRegistryKeyPack packet = session.CompletedBuffer.GetMessageEntity(); + DoRenameRegistryKeyPack packet = GetMessageEntity(session); GetRenameRegistryKeyResponsePack responsePacket = new GetRenameRegistryKeyResponsePack(); string errorMsg; try @@ -119,7 +124,7 @@ namespace SiMay.ServiceCore.ApplicationService responsePacket.OldKeyName = packet.OldKeyName; responsePacket.NewKeyName = packet.NewKeyName; - SendAsyncToServer(MessageHead.C_NREG_RENAME_KEY_RESPONSE, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_RENAME_KEY_RESPONSE, responsePacket); //client.Send(responsePacket); } @@ -130,7 +135,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_NREG_CREATE_VALUE)] public void HandleCreateRegistryValue(TcpSocketSaeaSession session) { - DoCreateRegistryValuePack packet = session.CompletedBuffer.GetMessageEntity(); + DoCreateRegistryValuePack packet = GetMessageEntity(session); GetCreateRegistryValueResponsePack responsePacket = new GetCreateRegistryValueResponsePack(); string errorMsg; string newKeyName = ""; @@ -147,14 +152,14 @@ namespace SiMay.ServiceCore.ApplicationService responsePacket.Value = RegistryKeyHelper.CreateRegValueData(newKeyName, packet.Kind, packet.Kind.GetDefault()); responsePacket.KeyPath = packet.KeyPath; - SendAsyncToServer(MessageHead.C_NREG_CREATE_VALUE_RESPONSE, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_CREATE_VALUE_RESPONSE, responsePacket); //client.Send(responsePacket); } [PacketHandler(MessageHead.S_NREG_DELETE_VALUE)] public void HandleDeleteRegistryValue(TcpSocketSaeaSession session) { - DoDeleteRegistryValuePack packet = session.CompletedBuffer.GetMessageEntity(); + DoDeleteRegistryValuePack packet = GetMessageEntity(session); GetDeleteRegistryValueResponsePack responsePacket = new GetDeleteRegistryValueResponsePack(); string errorMsg; try @@ -170,14 +175,14 @@ namespace SiMay.ServiceCore.ApplicationService responsePacket.ValueName = packet.ValueName; responsePacket.KeyPath = packet.KeyPath; - SendAsyncToServer(MessageHead.C_NREG_DELETE_VALUE_RESPONSE, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_DELETE_VALUE_RESPONSE, responsePacket); //client.Send(responsePacket); } [PacketHandler(MessageHead.S_NREG_RENAME_VALUE)] public void HandleRenameRegistryValue(TcpSocketSaeaSession session) { - DoRenameRegistryValuePack packet = session.CompletedBuffer.GetMessageEntity(); + DoRenameRegistryValuePack packet = GetMessageEntity(session); GetRenameRegistryValueResponsePack responsePacket = new GetRenameRegistryValueResponsePack(); string errorMsg; try @@ -194,14 +199,14 @@ namespace SiMay.ServiceCore.ApplicationService responsePacket.OldValueName = packet.OldValueName; responsePacket.NewValueName = packet.NewValueName; - SendAsyncToServer(MessageHead.C_NREG_RENAME_VALUE_RESPONSE, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_RENAME_VALUE_RESPONSE, responsePacket); //client.Send(responsePacket); } [PacketHandler(MessageHead.S_NREG_CHANGE_VALUE)] public void HandleChangeRegistryValue(TcpSocketSaeaSession session) { - DoChangeRegistryValuePack packet = session.CompletedBuffer.GetMessageEntity(); + DoChangeRegistryValuePack packet = GetMessageEntity(session); GetChangeRegistryValueResponsePack responsePacket = new GetChangeRegistryValueResponsePack(); string errorMsg; try @@ -217,7 +222,7 @@ namespace SiMay.ServiceCore.ApplicationService responsePacket.KeyPath = packet.KeyPath; responsePacket.Value = packet.Value; - SendAsyncToServer(MessageHead.C_NREG_CHANGE_VALUE_RESPONSE, responsePacket); + SendTo(CurrentSession, MessageHead.C_NREG_CHANGE_VALUE_RESPONSE, responsePacket); //client.Send(responsePacket); } diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/RemoteUpdateService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/RemoteUpdateService.cs new file mode 100644 index 0000000000000000000000000000000000000000..129d084bd168b7940f36ce9df4ccbdd508d63112 --- /dev/null +++ b/SiMay.RemoteClient.NewCore/ApplicationService/RemoteUpdateService.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SiMay.Core; +using SiMay.ServiceCore.Attributes; +using SiMay.Sockets.Tcp.Session; + +namespace SiMay.ServiceCore.ApplicationService +{ + [ServiceName("远程更新服务")] + [ServiceKey(AppJobConstant.REMOTE_UPDATE)] + public class RemoteUpdateService : ApplicationRemoteService + { + public override void SessionClosed() + { + throw new NotImplementedException(); + } + + public override void SessionInited(TcpSocketSaeaSession session) + { + + } + } +} diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/ScreenService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/ScreenService.cs index 8fc28474d0caee4ac230c625ee7904ecb7c56293..d3e27d2f3c93c1b320dddd57115e1b9c5c9c01aa 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/ScreenService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/ScreenService.cs @@ -1,43 +1,34 @@ using SiMay.Core; using SiMay.Core.Enums; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.Core.Packets.Screen; using SiMay.Core.ScreenSpy; using SiMay.Core.ScreenSpy.Entitys; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.Extensions; -using SiMay.Serialize; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; -using System; using System.Drawing; -using System.Runtime.InteropServices; using System.Threading; using System.Windows.Forms; using static SiMay.ServiceCore.CommonWin32Api; using SiMay.ServiceCore.Win32; -//using static SiMay.ServiceCore.Win32.User32; -using SiMay.Basic; -using SiMay.ServiceCore.ApplicationService.Registry; using System.Linq; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("远程桌面")] - [ServiceKey("RemoteDesktopJob")] - public class ScreenService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_DESKTOP)] + public class ScreenService : ApplicationRemoteService { private int _bscanmode = 1; //0差异 1逐行 private bool _cleanWallPaper = false; private static string wallpaper = string.Empty; - private bool _hasSystemAuthor = AppConfiguartion.HasSystemAuthority.Equals("true", StringComparison.OrdinalIgnoreCase); + private bool _hasSystemAuthor = AppConfiguartion.HasSystemAuthority; private ScreenSpy _spy; - public override void SessionInitialized(TcpSocketSaeaSession session) + public override void SessionInited(TcpSocketSaeaSession session) { - session.Socket.NoDelay = false; + CurrentSession.Socket.NoDelay = false; _spy = new ScreenSpy(new BitBltCapture(true)); _spy.OnDifferencesNotice += ScreenDifferences_OnDifferencesNotice; } @@ -65,7 +56,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SCREEN_SET_CLIPBOARD_TEXT)] public void SetClipoardHandler(TcpSocketSaeaSession session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); Thread thread = new Thread(() => { @@ -82,7 +73,7 @@ namespace SiMay.ServiceCore.ApplicationService Thread thread = new Thread(() => { var text = Clipboard.GetText(); - SendAsyncToServer(MessageHead.C_SCREEN_CLIPOARD_TEXT, + SendTo(CurrentSession, MessageHead.C_SCREEN_CLIPOARD_TEXT, new ScreenClipoardValuePack() { Value = text @@ -99,7 +90,7 @@ namespace SiMay.ServiceCore.ApplicationService private void SendDesktopInitInfo() { - SendAsyncToServer(MessageHead.C_SCREEN_BITINFO, + SendTo(CurrentSession, MessageHead.C_SCREEN_BITINFO, new ScreenInitBitPack() { Height = _spy.ScreenHeight, @@ -116,7 +107,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SCREEN_CHANGE_MONITOR)] public void MonitorChangeHandler(TcpSocketSaeaSession session) { - var currenMonitor = session.CompletedBuffer.GetMessageEntity().MonitorIndex; + var currenMonitor = GetMessageEntity(session).MonitorIndex; _spy.Capturer.SelectedScreen = currenMonitor; } @@ -124,33 +115,33 @@ namespace SiMay.ServiceCore.ApplicationService { switch (nCode) { - case DifferStatus.FULLDIFFERENCES: - SendAsyncToServer(MessageHead.C_SCREEN_DIFFBITMAP, + case DifferStatus.FULL_DIFFERENCES: + SendTo(CurrentSession, MessageHead.C_SCREEN_DIFFBITMAP, new ScreenFragmentPack() { Fragments = fragments }); break; - case DifferStatus.NEXTSCREEN: - SendAsyncToServer(MessageHead.C_SCREEN_BITMP, + case DifferStatus.NEXT_SCREEN: + SendTo(CurrentSession, MessageHead.C_SCREEN_BITMP, new ScreenFragmentPack() { Fragments = fragments }); break; - case DifferStatus.COMPLETE: - SendAsyncToServer(MessageHead.C_SCREEN_SCANCOMPLETE); + case DifferStatus.COMPLETED: + SendTo(CurrentSession, MessageHead.C_SCREEN_SCANCOMPLETE); break; } } [PacketHandler(MessageHead.S_SCREEN_NEXT_SCREENBITMP)] public void SendNextScreen(TcpSocketSaeaSession session) { - var rect = session.CompletedBuffer.GetMessageEntity(); + var rect = GetMessageEntity(session); //根据监控模式使用热区域扫描 - bool ishotRegtionScan = rect.CtrlMode == 1 ? true : false; + bool ishotRegtionScan = false;// rect.CtrlMode == 1 ? true : false; if (_hasSystemAuthor) Win32Interop.SwitchToInputDesktop(); @@ -167,7 +158,7 @@ namespace SiMay.ServiceCore.ApplicationService var registryKey = RegistryEditor.GetWritableRegistryKey(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"); registryKey.SetValue("SoftwareSASGeneration", 00000003, Microsoft.Win32.RegistryValueKind.DWord); - if (AppConfiguartion.HasSystemAuthority.Equals("true", StringComparison.OrdinalIgnoreCase)) + if (AppConfiguartion.HasSystemAuthority) UserTrunkContext.UserTrunkContextInstance?.SendSas(); else User32.SendSAS(true); @@ -176,20 +167,20 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SCREEN_CHANGESCANMODE)] public void ChangeSpyScanMode(TcpSocketSaeaSession session) { - _bscanmode = session.CompletedBuffer.GetMessagePayload()[0]; + _bscanmode = GetMessage(session)[0]; } [PacketHandler(MessageHead.S_SCREEN_SETQTY)] public void SetImageQuality(TcpSocketSaeaSession session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); _spy.SetImageQuality = pack.Quality; } [PacketHandler(MessageHead.S_SCREEN_RESET)] public void SetSpyFormat(TcpSocketSaeaSession session) { - _spy.SetFormat = session.CompletedBuffer.GetMessagePayload()[0]; + _spy.SetFormat = GetMessage(session)[0]; } [PacketHandler(MessageHead.S_SCREEN_BLACKSCREEN)] @@ -201,7 +192,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SCREEN_MOUSEBLOCK)] public void SetMouseBlock(TcpSocketSaeaSession session) { - if (session.CompletedBuffer.GetMessagePayload()[0] == 10) + if (GetMessage(session)[0] == 10) BlockInput(true); else BlockInput(false); @@ -210,7 +201,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SCREEN_MOUSEKEYEVENT)] public void MouseKeyEvent(TcpSocketSaeaSession session) { - var @event = session.CompletedBuffer.GetMessageEntity(); + var @event =GetMessageEntity(session); Screen[] allScreens = Screen.AllScreens; int offsetX = allScreens[_spy.Capturer.SelectedScreen].Bounds.X; int offsetY = allScreens[_spy.Capturer.SelectedScreen].Bounds.Y; @@ -237,7 +228,7 @@ namespace SiMay.ServiceCore.ApplicationService break; case MOUSEKEY_ENUM.MiddleDown: - User32.SetCursorPos(p1, p2); + SetCursorPos(p1, p2); mouse_event(MOUSEEVENTF_MIDDLEDOWN, 0, 0, 0, 0); break; diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/ServiceManagerBase.cs b/SiMay.RemoteClient.NewCore/ApplicationService/ServiceManagerBase.cs deleted file mode 100644 index bfbb6c151244c1a308ff9a404f9515bb0ce45954..0000000000000000000000000000000000000000 --- a/SiMay.RemoteClient.NewCore/ApplicationService/ServiceManagerBase.cs +++ /dev/null @@ -1,139 +0,0 @@ -using SiMay.Core; -using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; -using SiMay.Core.Packets; -using SiMay.Sockets.Tcp; -using SiMay.Sockets.Tcp.Session; -using System; - -namespace SiMay.ServiceCore.ApplicationService -{ - - /// - /// 应用服务基类 - /// - public class ServiceManagerBase - { - /// - /// 服务Id - /// - public string AppServiceKey { get; set; } - - /// - /// 当前会话是否已关闭 - /// - public bool Closed { get; set; } = false; - - /// - /// 数据处理绑定 - /// - public PacketModelBinder HandlerBinder { get; set; } - - - public ServiceManagerBase() - { - HandlerBinder = new PacketModelBinder(); - } - - /// - /// 当前会话 - /// - protected TcpSocketSaeaSession Session { get; set; } - - /// - /// 设置Session - /// - /// - public void SetSession(TcpSocketSaeaSession session) - => Session = session; - /// - /// 同步发送数据 - /// - /// - /// - protected int SendToServer(byte[] data) - => Session.Send(data); - - protected int SendToServer(MessageHead msg, byte[] data = null) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data); - return Session.Send(bytes); - } - - protected int SendToServer(MessageHead msg, string lpString) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, lpString); - return Session.Send(bytes); - } - - protected int SendToServer(MessageHead msg, byte[] data, int size) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data, size); - return Session.Send(bytes); - } - protected void SendAsyncToServer(byte[] data) - => Session.SendAsync(data); - - protected void SendAsyncToServer(MessageHead msg, object entity) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, entity); - Console.WriteLine("send lenght:" + bytes.Length); - Session.SendAsync(bytes); - } - protected void SendAsyncToServer(MessageHead msg, byte[] data = null) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data); - Session.SendAsync(bytes); - } - protected void SendAsyncToServer(MessageHead msg, string lpString) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, lpString); - Session.SendAsync(bytes); - } - protected void SendAsyncToServer(MessageHead msg, byte[] data, int size) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data, size); - Session.SendAsync(bytes); - } - - /// - /// 关闭当前会话 - /// - protected void CloseSession() - => Session.Close(true); - - [PacketHandler(MessageHead.S_GLOBAL_OK)] - public void InitializeCompleted(TcpSocketSaeaSession session) - { - this.SessionInitialized(session); - SendAsyncToServer(MessageHead.C_MAIN_ACTIVE_APP, - new ActiveAppPack() - { - IdentifyId = AppConfiguartion.IdentifyId, - ServiceKey = this.AppServiceKey, - OriginName = Environment.MachineName + "@" + (AppConfiguartion.RemarkInfomation ?? AppConfiguartion.DefaultRemarkInfo) - }); - } - - [PacketHandler(MessageHead.S_GLOBAL_ONCLOSE)] - public void SessionClosed(TcpSocketSaeaSession session) - { - if (this.Closed) - return; - this.Closed = true; - this.CloseSession(); - this.SessionClosed(); - this.HandlerBinder.Dispose(); - } - - public virtual void SessionInitialized(TcpSocketSaeaSession session) - { - - } - - public virtual void SessionClosed() - { - - } - } -} \ No newline at end of file diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/ShellService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/ShellService.cs index ed296911550b15234ea6947a5b65d198f145c371..68d3da6e3964042e9fb14d79532979c5ca5c6771 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/ShellService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/ShellService.cs @@ -1,24 +1,20 @@ using SiMay.Core; using SiMay.Core.Extensions; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; -using SiMay.Core.Packets; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.Extensions; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; using System; using System.Diagnostics; using System.IO; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("Shell管理")] - [ServiceKey("RemoteShellJob")] - public class ShellService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_SHELL)] + public class ShellService : ApplicationRemoteService { private Process _pipe; - public override void SessionInitialized(TcpSocketSaeaSession session) + public override void SessionInited(TcpSocketSaeaSession session) { this.Init(); } @@ -27,11 +23,6 @@ namespace SiMay.ServiceCore.ApplicationService { _pipe.Kill(); } - - [PacketHandler(MessageHead.S_GLOBAL_ONCLOSE)] - public void CloseSession(TcpSocketSaeaSession session) - => this.CloseSession(); - private void Init() { _pipe = new Process @@ -60,7 +51,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SHELL_INPUT)] public void StartCommand(TcpSocketSaeaSession session) { - byte[] payload = session.CompletedBuffer.GetMessagePayload(); + byte[] payload = GetMessage(session); string command = payload.ToUnicodeString(); _pipe.StandardInput.WriteLine(command); @@ -71,14 +62,14 @@ namespace SiMay.ServiceCore.ApplicationService { if (outLine.Data == null) return; - SendAsyncToServer(MessageHead.C_SHELL_RESULT, "\r\n" + outLine.Data + "\r\n"); + SendTo(CurrentSession, MessageHead.C_SHELL_RESULT, "\r\n" + outLine.Data + "\r\n"); } private void OutputHandler(object sendingProcess, DataReceivedEventArgs outLine) { if (outLine.Data == null) return; - SendAsyncToServer(MessageHead.C_SHELL_RESULT, "\r\n" + outLine.Data); + SendTo(CurrentSession, MessageHead.C_SHELL_RESULT, "\r\n" + outLine.Data); } } } \ No newline at end of file diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/StartupService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/StartupService.cs index d13cddb489bf08b9ca5ff9940ed144d40daa57b2..73966f07f063613e64060ac3176a9bf5bb40ce7a 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/StartupService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/StartupService.cs @@ -4,27 +4,31 @@ using SiMay.Core.Common; using SiMay.Core.Enums; using SiMay.Core.Extensions; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; -using SiMay.Core.Packets; using SiMay.Core.Packets.Startup; using SiMay.Core.Packets.Startup.Enums; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.Extensions; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; -using System.Windows.Forms; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("启动项管理")] - [ServiceKey("StartupManagerJob")] - public class StartupService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_STARTUP)] + public class StartupService : ApplicationRemoteService { + public override void SessionInited(TcpSocketSaeaSession session) + { + + } + + public override void SessionClosed() + { + + } + [PacketHandler(MessageHead.S_STARTUP_GET_LIST)] public void HandleGetStartupItems(TcpSocketSaeaSession session) { @@ -109,24 +113,31 @@ namespace SiMay.ServiceCore.ApplicationService { var files = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.Startup)).GetFiles(); - startupItems.AddRange(files.Where(file => file.Name != "desktop.ini").Select(file => new StartupItemPack - { Name = file.Name, Path = file.FullName, Type = StartupType.StartMenu })); + startupItems.AddRange(files.Where(file => file.Name != "desktop.ini") + .Select(file => new StartupItemPack + { + Name = file.Name, + Path = file.FullName, + Type = StartupType.StartMenu + })); } - SendAsyncToServer(MessageHead.C_STARTUP_LIST, new StartupItemsPack() - { - StartupItems = startupItems.ToArray() - }); + SendTo(CurrentSession, MessageHead.C_STARTUP_LIST, + new StartupItemsPack() + { + StartupItems = startupItems.ToArray() + }); } catch (Exception ex) { LogHelper.WriteErrorByCurrentMethod(ex); - SendAsyncToServer(MessageHead.C_STARTUP_OPER_RESPONSE, new StartupOperResponsePack() - { - OperFlag = OperFlag.GetStartupItems, - Successed = false, - Msg = ex.Message - }); + SendTo(CurrentSession, MessageHead.C_STARTUP_OPER_RESPONSE, + new StartupOperResponsePack() + { + OperFlag = OperFlag.GetStartupItems, + Successed = false, + Msg = ex.Message + }); } } [PacketHandler(MessageHead.S_STARTUP_ADD_ITEM)] @@ -134,7 +145,7 @@ namespace SiMay.ServiceCore.ApplicationService { try { - var command = session.CompletedBuffer.GetMessageEntity(); + var command = GetMessageEntity(session); switch (command.Type) { case StartupType.LocalMachineRun: @@ -208,12 +219,13 @@ namespace SiMay.ServiceCore.ApplicationService } catch (Exception ex) { - SendAsyncToServer(MessageHead.C_STARTUP_OPER_RESPONSE, new StartupOperResponsePack() - { - OperFlag = OperFlag.AddStartupItem, - Successed = false, - Msg = ex.Message - }); + SendTo(CurrentSession, MessageHead.C_STARTUP_OPER_RESPONSE, + new StartupOperResponsePack() + { + OperFlag = OperFlag.AddStartupItem, + Successed = false, + Msg = ex.Message + }); } } @@ -222,7 +234,7 @@ namespace SiMay.ServiceCore.ApplicationService { try { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); foreach (var command in pack.StartupItems) { switch (command.Type) @@ -289,12 +301,13 @@ namespace SiMay.ServiceCore.ApplicationService } catch (Exception ex) { - SendAsyncToServer(MessageHead.C_STARTUP_OPER_RESPONSE, new StartupOperResponsePack() - { - OperFlag = OperFlag.RemoveStartupItem, - Successed = false, - Msg = ex.Message - }); + SendTo(CurrentSession, MessageHead.C_STARTUP_OPER_RESPONSE, + new StartupOperResponsePack() + { + OperFlag = OperFlag.RemoveStartupItem, + Successed = false, + Msg = ex.Message + }); } } } diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/SystemService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/SystemService.cs index b3b322bdb6d18670fceb054d5ee095f7ffa96996..4f32ae21d3ee7c6b1a2fba5425ddbb46634a68c9 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/SystemService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/SystemService.cs @@ -3,32 +3,30 @@ using SiMay.Basic; using SiMay.Core; using SiMay.Core.Common; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.Core.Packets.SysManager; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.Extensions; using SiMay.ServiceCore.Helper; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Runtime.InteropServices; using System.Windows.Forms; using static SiMay.ServiceCore.CommonWin32Api; -using System.Management; -using SiMay.ServiceCore.Win32; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("系统管理")] - [ServiceKey("SystemManagerJob")] - public class SystemService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_SYSMANAGER)] + public class SystemService : ApplicationRemoteService { private ComputerInfo _memoryInfo = new ComputerInfo(); private PerformanceCounter _cpuInfo = new PerformanceCounter("Processor", "% Processor Time", "_Total"); + public override void SessionInited(TcpSocketSaeaSession session) + { + + } public override void SessionClosed() { @@ -38,7 +36,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SYSTEM_KILL)] public void TryKillProcess(TcpSocketSaeaSession session) { - var processIds = session.CompletedBuffer.GetMessageEntity(); + var processIds = GetMessageEntity(session); foreach (var id in processIds.ProcessIds) { try @@ -54,7 +52,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SYSTEM_MAXIMIZE)] public void SetWindowState(TcpSocketSaeaSession session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); int[] handlers = pack.Handlers; int state = pack.State; @@ -82,7 +80,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_SYSTEM_CREATE_USER_PROCESS)] public void CreateProcessAsUser(TcpSocketSaeaSession session) { - var sessionId = session.CompletedBuffer.GetMessageEntity().SessionId; + var sessionId = GetMessageEntity(session).SessionId; UserTrunkContext.UserTrunkContextInstance.CreateProcessAsUser(sessionId); } @@ -99,7 +97,7 @@ namespace SiMay.ServiceCore.ApplicationService }) .ToArray(); - SendAsyncToServer(MessageHead.C_SYSTEM_SESSIONS, + SendTo(CurrentSession, MessageHead.C_SYSTEM_SESSIONS, new SessionsPack() { Sessions = sessions @@ -129,7 +127,7 @@ namespace SiMay.ServiceCore.ApplicationService // return p; //}).ToArray(); - SendAsyncToServer(MessageHead.C_SYSTEM_PROCESS_LIST, + SendTo(CurrentSession, MessageHead.C_SYSTEM_PROCESS_LIST, new ProcessListPack() { ProcessList = processList @@ -148,7 +146,7 @@ namespace SiMay.ServiceCore.ApplicationService } [PacketHandler(MessageHead.S_SYSTEM_GET_SYSTEMINFO)] - public void HandlerGetSystemInfos(TcpSocketSaeaSession session) + public void GetSystemInfosHandler(TcpSocketSaeaSession session) { ThreadHelper.ThreadPoolStart(c => { @@ -261,7 +259,7 @@ namespace SiMay.ServiceCore.ApplicationService }); var sysInfos = new SystemInfoPack(); sysInfos.SystemInfos = infos.ToArray(); - SendAsyncToServer(MessageHead.C_SYSTEM_SYSTEMINFO, sysInfos); + SendTo(CurrentSession, MessageHead.C_SYSTEM_SYSTEMINFO, sysInfos); }); } @@ -275,7 +273,7 @@ namespace SiMay.ServiceCore.ApplicationService } catch { } - SendAsyncToServer(MessageHead.C_SYSTEM_OCCUPY_INFO, + SendTo(CurrentSession, MessageHead.C_SYSTEM_OCCUPY_INFO, new SystemOccupyPack() { CpuUsage = cpuUserate, diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/TcpConnectionService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/TcpConnectionService.cs index c5bee4ae5a32c7917b3d6cc574266370c918ee02..002236522825370fd6b694214730bdf9e5a9d338 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/TcpConnectionService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/TcpConnectionService.cs @@ -1,27 +1,31 @@ using SiMay.Core; using SiMay.Core.Enums; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; -using SiMay.Core.Packets; using SiMay.Core.Packets.TcpConnection; -using SiMay.ServiceCore; using SiMay.ServiceCore.Attributes; -using SiMay.ServiceCore.Extensions; -using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Session; using System; -using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Runtime.InteropServices; using System.Text; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("Tcp连接管理")] - [ServiceKey("TcpConnectionManagerJob")] - public class TcpConnectionService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_TCP)] + public class TcpConnectionService : ApplicationRemoteService { + public override void SessionInited(TcpSocketSaeaSession session) + { + + } + + public override void SessionClosed() + { + + } + [PacketHandler(MessageHead.S_TCP_GET_LIST)] public void GetTcpConnectionList(TcpSocketSaeaSession session) { @@ -54,16 +58,17 @@ namespace SiMay.ServiceCore.ApplicationService var ss = connections[i]; } - SendAsyncToServer(MessageHead.C_TCP_LIST, new TcpConnectionPack() - { - TcpConnections = connections - }); + SendTo(CurrentSession, MessageHead.C_TCP_LIST, + new TcpConnectionPack() + { + TcpConnections = connections + }); } [PacketHandler(MessageHead.S_TCP_CLOSE_CHANNEL)] public void CloseTcpConnectionHandler(TcpSocketSaeaSession session) { - var kills = session.CompletedBuffer.GetMessageEntity(); + var kills = GetMessageEntity(session); var table = GetTable(); diff --git a/SiMay.RemoteClient.NewCore/ApplicationService/VideoService.cs b/SiMay.RemoteClient.NewCore/ApplicationService/VideoService.cs index e2e5affffd0eacf9a4996dbb35a28c86bcba59fb..850a536daebd725d35b77844b6c9eacdc6c8eeb8 100644 --- a/SiMay.RemoteClient.NewCore/ApplicationService/VideoService.cs +++ b/SiMay.RemoteClient.NewCore/ApplicationService/VideoService.cs @@ -13,17 +13,17 @@ using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Threading; -namespace SiMay.ServiceCore.ApplicationService +namespace SiMay.ServiceCore { [ServiceName("远程监控摄像头")] - [ServiceKey("RemoteViedoJob")] - public class VideoService : ServiceManagerBase + [ServiceKey(AppJobConstant.REMOTE_VIDEO)] + public class VideoService : ApplicationRemoteService { private int qty = 30; private bool isOpen = false; private AForgeViedo av; - public override void SessionInitialized(TcpSocketSaeaSession session) + public override void SessionInited(TcpSocketSaeaSession session) { this.Init(); } @@ -43,7 +43,7 @@ namespace SiMay.ServiceCore.ApplicationService av = new AForgeViedo(); if (!av.Init()) { - SendAsyncToServer(MessageHead.C_VIEDO_DEVICE_NOTEXIST); + SendTo(CurrentSession, MessageHead.C_VIEDO_DEVICE_NOTEXIST); return; } @@ -53,7 +53,7 @@ namespace SiMay.ServiceCore.ApplicationService } catch { - SendAsyncToServer(MessageHead.C_VIEDO_DEVICE_NOTEXIST); + SendTo(CurrentSession, MessageHead.C_VIEDO_DEVICE_NOTEXIST); } } @@ -71,10 +71,9 @@ namespace SiMay.ServiceCore.ApplicationService try { int j = 0; - while (true) //尝试10次无数据则未成功打开摄像头 + while ((j++) <= 10) //尝试10次无数据则未成功打开摄像头 { - j++; - Bitmap value = av.GetBitmap(); + Bitmap value = av.GetFrame(); if (value != null) { byte[] data = KiSaveAsJPEG(value, qty); //清晰度 15 @@ -83,10 +82,8 @@ namespace SiMay.ServiceCore.ApplicationService return data; } Thread.Sleep(1000); - - if (j == 10) - return null; } + return null; } catch { @@ -97,7 +94,7 @@ namespace SiMay.ServiceCore.ApplicationService [PacketHandler(MessageHead.S_VIEDO_RESET)] public void SetBitQuality(TcpSocketSaeaSession session) { - switch (session.CompletedBuffer.GetMessagePayload()[0]) + switch (GetMessage(session)[0]) { case 3: qty = 90; @@ -131,7 +128,7 @@ namespace SiMay.ServiceCore.ApplicationService return; } - SendAsyncToServer(MessageHead.C_VIEDO_DATA, data); + SendTo(CurrentSession, MessageHead.C_VIEDO_DATA, data); } diff --git a/SiMay.RemoteClient.NewCore/Helper/ImageExtensionHelper.cs b/SiMay.RemoteClient.NewCore/Helper/ImageExtensionHelper.cs index a599acae7d0edafbdae4930be638298edff241d3..6521d8e66f829e0bcf4b46f372c2a25362df48ed 100644 --- a/SiMay.RemoteClient.NewCore/Helper/ImageExtensionHelper.cs +++ b/SiMay.RemoteClient.NewCore/Helper/ImageExtensionHelper.cs @@ -1,8 +1,5 @@ using SiMay.Core.ScreenSpy; -using SiMay.ServiceCore.ApplicationService; using SiMay.ServiceCore.Win32; -using System; -using System.Collections.Generic; using System.Drawing; using System.IO; using System.Linq; @@ -13,7 +10,7 @@ namespace SiMay.ServiceCore.Helper public class ImageExtensionHelper { static ICapturer _capturer = new BitBltCapture(false); - static bool _hasSystemAuthor = AppConfiguartion.HasSystemAuthority.Equals("true", StringComparison.OrdinalIgnoreCase); + static bool _hasSystemAuthor = AppConfiguartion.HasSystemAuthority; public static byte[] CaptureNoCursorToBytes(Size size) { if (_hasSystemAuthor) diff --git a/SiMay.Core/RegValueHelper.cs b/SiMay.RemoteClient.NewCore/Helper/RegValueHelper.cs similarity index 100% rename from SiMay.Core/RegValueHelper.cs rename to SiMay.RemoteClient.NewCore/Helper/RegValueHelper.cs diff --git a/SiMay.RemoteClient.NewCore/Helper/SystemInfoHelper.cs b/SiMay.RemoteClient.NewCore/Helper/SystemInfoHelper.cs index b7349fac69372106f805abdae4875a5f00f9b323..9282422cea13dcf7e7ddef11e0261ecd5d947e0b 100644 --- a/SiMay.RemoteClient.NewCore/Helper/SystemInfoHelper.cs +++ b/SiMay.RemoteClient.NewCore/Helper/SystemInfoHelper.cs @@ -247,6 +247,7 @@ namespace SiMay.ServiceCore.Helper public static string GetLocalIPV4() { + string ReturnValue = string.Empty; try { string HostName = Dns.GetHostName(); @@ -254,14 +255,16 @@ namespace SiMay.ServiceCore.Helper for (int i = 0; i < IpEntry.AddressList.Length; i++) { if (IpEntry.AddressList[i].AddressFamily == AddressFamily.InterNetwork) - return IpEntry.AddressList[i].ToString(); + //return IpEntry.AddressList[i].ToString(); + ReturnValue += " | " + IpEntry.AddressList[i].ToString();//多网卡显示 } - return string.Empty; + //return string.Empty; } catch { - return string.Empty; + //return string.Empty; } + return ReturnValue.Length > 0 ? ReturnValue.Substring(3) : ReturnValue; } //public static string GetLocalIPV4() @@ -326,9 +329,9 @@ namespace SiMay.ServiceCore.Helper foreach (ManagementObject mo in queryCollection) { if (mo["IPEnabled"].ToString() == "True") - mac = mo["MacAddress"].ToString(); + mac = " | " + mo["MacAddress"].ToString();//多网卡显示 } - return mac; + return mac.Length > 0 ? mac.Substring(3) : mac; } catch (Exception ex) { diff --git a/SiMay.RemoteClient.NewCore/MainService/MainService.cs b/SiMay.RemoteClient.NewCore/MainService/MainService.cs index d0bb62686f85901caccc8e69ac6f198b392ba799..0d4c66722ae4a579654af3b7f9c1a25d6c98f8a5 100644 --- a/SiMay.RemoteClient.NewCore/MainService/MainService.cs +++ b/SiMay.RemoteClient.NewCore/MainService/MainService.cs @@ -1,5 +1,4 @@ -using Microsoft.Win32; -using SiMay.Core; +using SiMay.Core; using System; using System.Diagnostics; using System.Linq; @@ -8,47 +7,50 @@ using System.Threading; using System.Windows.Forms; using SiMay.Core.Enums; using SiMay.Core.Packets; -using SiMay.Core.ScreenSpy; using SiMay.Sockets.Tcp; using SiMay.Sockets.Tcp.Client; using SiMay.Sockets.Tcp.Session; using SiMay.Sockets.Tcp.TcpConfiguration; -using SiMay.ServiceCore.ApplicationService; -using SiMay.Core.PacketModelBinding; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Basic; using System.Net; using System.IO; -using SiMay.RemoteService.Entitys; -using SiMay.RemoteService.Interface; using SiMay.Core.Extensions; using SiMay.ServiceCore.Helper; using SiMay.ServiceCore.Attributes; using System.Drawing; +using SiMay.RemoteService.Loader.Interface; +using SiMay.RemoteService.Loader.Entitys; +using System.Collections.Generic; namespace SiMay.ServiceCore.MainService { - /// - /// 主连接模块 - /// 作用:与服务端保持长连接,接收工作指令打开其他模块工作连接,意外断开时能主动重连 - /// - public class MainService : IAppMainService + public class MainService : MainApplicationService, IAppMainService { + /// + /// 正常 + /// + private const int STATE_NORMAL = 1; + + /// + /// 断开 + /// + private const int STATE_DISCONNECT = 0; + + private int _sessionKeepSign = STATE_DISCONNECT;//主连接状态 + private bool _screenViewIsAction = false; private int _screen_record_height; private int _screen_record_width; private int _screen_record_spantime; - private int _sessionKeep = 0;//主连接状态 0断开连接,1已连接 private TcpSocketSaeaClientAgent _clientAgent; - private TcpSocketSaeaSession _session; - private ManagerTaskQueue _taskQueue = new ManagerTaskQueue(); - private PacketModelBinder _handlerBinder = new PacketModelBinder(); + private ServiceTaskQueue _taskQueue = new ServiceTaskQueue(); public MainService(StartParameterEx startParameter) { while (true) //第一次解析域名,直至解析成功 { - var ip = IPHelper.GetHostByName(startParameter.Host); + var ip = HostHelper.GetHostByName(startParameter.Host); if (ip != null) { AppConfiguartion.ServerIPEndPoint = new IPEndPoint(IPAddress.Parse(ip), startParameter.Port); @@ -68,37 +70,22 @@ namespace SiMay.ServiceCore.MainService AppConfiguartion.IsHideExcutingFile = startParameter.IsHide; AppConfiguartion.RunTime = startParameter.RunTimeText; AppConfiguartion.Version = startParameter.ServiceVersion; - AppConfiguartion.IsCentreServiceMode = startParameter.SessionMode == 1 ? true : false; + AppConfiguartion.CenterServiceMode = startParameter.SessionMode == 1 ? true : false; AppConfiguartion.IdentifyId = startParameter.UniqueId; if (AppConfiguartion.IsHideExcutingFile) - ComputerSessionHelper.SetExecutingFileHide(true); + SystemSessionHelper.SetExecutingFileHide(true); if (AppConfiguartion.IsAutoRun) - ComputerSessionHelper.SetAutoRun(true); - - if (!int.TryParse(AppConfiguartion.ScreenRecordHeight, out _screen_record_height)) - _screen_record_height = 800; - - if (!int.TryParse(AppConfiguartion.ScreenRecordWidth, out _screen_record_width)) - _screen_record_width = 1200; + SystemSessionHelper.SetAutoRun(true); - if (!int.TryParse(AppConfiguartion.ScreenRecordSpanTime, out _screen_record_spantime)) - _screen_record_spantime = 3000; + _screen_record_height = AppConfiguartion.ScreenRecordHeight; + _screen_record_width = AppConfiguartion.ScreenRecordWidth; + _screen_record_spantime = AppConfiguartion.ScreenRecordSpanTime; - if (!bool.TryParse(AppConfiguartion.KeyboardOffline, out var bKeyboardOffline)) - bKeyboardOffline = false; - - if (bKeyboardOffline) - { - Keyboard keyboard = Keyboard.GetKeyboardInstance(); - keyboard.Initialization(); - keyboard.StartOfflineRecords();//开始离线记录 - } //创建通讯接口实例 var clientConfig = new TcpSocketSaeaClientConfiguration(); - - if (!AppConfiguartion.IsCentreServiceMode) + if (!AppConfiguartion.CenterServiceMode) { //服务版配置 clientConfig.AppKeepAlive = true; @@ -112,6 +99,7 @@ namespace SiMay.ServiceCore.MainService } clientConfig.KeepAliveInterval = 5000; clientConfig.KeepAliveSpanTime = 1000; + clientConfig.CompressTransferFromPacket = false; _clientAgent = TcpSocketsFactory.CreateClientAgent(TcpSocketSaeaSessionType.Packet, clientConfig, Notify); ConnectToServer(); @@ -133,8 +121,8 @@ namespace SiMay.ServiceCore.MainService ) { _clientAgent = clientAgent; - _session = session; - _sessionKeep = 1;//主连接状态 + _sessionKeepSign = 1;//主连接状态 + this.SetSession(session); session.AppTokens = new object[2] { @@ -151,7 +139,7 @@ namespace SiMay.ServiceCore.MainService AppConfiguartion.IsHideExcutingFile = startParameter.IsHide; AppConfiguartion.RunTime = startParameter.RunTimeText; AppConfiguartion.Version = startParameter.ServiceVersion; - AppConfiguartion.IsCentreServiceMode = startParameter.SessionMode == 1 ? true : false; + AppConfiguartion.CenterServiceMode = startParameter.SessionMode == 1 ? true : false; AppConfiguartion.IdentifyId = startParameter.UniqueId; AppConfiguartion.ServerIPEndPoint = serviceIPEndPoint; @@ -160,44 +148,53 @@ namespace SiMay.ServiceCore.MainService private void ConnectToServer() { - //IPEndPoint ipend; - //if (!IPAddress.TryParse(AppConfiguartion.HostAddress, out var iPAddress)) - // ipend = new IPEndPoint(iPAddress, AppConfiguartion.HostPort); - //else - //{ - ThreadHelper.ThreadPoolStart(x => + //尝试解析出最新的域名地址 + ThreadHelper.ThreadPoolStart(c => { - var ip = IPHelper.GetHostByName(AppConfiguartion.HostAddress);//尝试解析域名 + var ip = HostHelper.GetHostByName(AppConfiguartion.HostAddress); if (ip.IsNullOrEmpty()) return; AppConfiguartion.ServerIPEndPoint = new IPEndPoint(IPAddress.Parse(ip), AppConfiguartion.HostPort); }); - //} _clientAgent.ConnectToServer(AppConfiguartion.ServerIPEndPoint); } - private void SendMessageToServer(byte[] data) - { - if (_session == null) - return; - _session.SendAsync(data); - } - /// /// 发送确认包 - /// - /// 作用:连接确认,以便服务端识别这是一个有效的工作连接,type = 中间服务器识别 + /// 作用:连接确认,以便服务端识别这是一个有效的工作连接,type = 中间服务器识别 , accessId = 发起创建应用服务请求的主控端标识 /// /// - public void SendAckPack(TcpSocketSaeaSession session, ConnectionWorkType type) + private void SendACK(TcpSocketSaeaSession session, ConnectionWorkType type, long accessId) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_GLOBAL_CONNECT, + SendTo(session, MessageHead.C_GLOBAL_CONNECT, new AckPack() { + AccessId = accessId,//当前主控端标识 AccessKey = AppConfiguartion.AccessKey, - Type = type + Type = (byte)type, + IPV4 = SystemInfoHelper.GetLocalIPV4(), + MachineName = Environment.MachineName ?? string.Empty, + Remark = AppConfiguartion.RemarkInfomation ?? AppConfiguartion.DefaultRemarkInfo, + ProcessorCount = Environment.ProcessorCount, + ProcessorInfo = SystemInfoHelper.GetMyCpuInfo, + MemorySize = SystemInfoHelper.GetMyMemorySize, + StartRunTime = AppConfiguartion.RunTime, + ServiceVison = AppConfiguartion.Version, + UserName = Environment.UserName.ToString(), + OSVersion = SystemInfoHelper.GetOSFullName, + GroupName = AppConfiguartion.GroupName ?? AppConfiguartion.DefaultGroupName, + OpenScreenWall = AppConfiguartion.IsOpenScreenView, + ExistCameraDevice = SystemInfoHelper.ExistCameraDevice(), + ExitsRecordDevice = SystemInfoHelper.ExistRecordDevice(), + ExitsPlayerDevice = SystemInfoHelper.ExistPlayDevice(), + IdentifyId = AppConfiguartion.IdentifyId, + OpenScreenRecord = AppConfiguartion.IsScreenRecord, + RecordHeight = _screen_record_height, + RecordWidth = _screen_record_width, + RecordSpanTime = _screen_record_spantime, + HasLoadServiceCOM = true,//已加载 + MacAddress = SystemInfoHelper.GetMacAddress }); - session.SendAsync(data); } /// @@ -205,28 +202,28 @@ namespace SiMay.ServiceCore.MainService /// /// /// - public void Notify(TcpSocketCompletionNotify notify, TcpSocketSaeaSession session) + public void Notify(TcpSessionNotify notify, TcpSocketSaeaSession session) { try { switch (notify) { - case TcpSocketCompletionNotify.OnConnected: + case TcpSessionNotify.OnConnected: this.ConnectedHandler(session, notify); break; - case TcpSocketCompletionNotify.OnDataReceiveing: + case TcpSessionNotify.OnDataReceiveing: break; - case TcpSocketCompletionNotify.OnDataReceived: + case TcpSessionNotify.OnDataReceived: var workType = (ConnectionWorkType)session.AppTokens[0]; if (workType == ConnectionWorkType.MAINCON) - this._handlerBinder.InvokePacketHandler(session, session.CompletedBuffer.GetMessageHead(), this); + this.HandlerBinder.InvokePacketHandler(session, GetMessageHead(session), this); else if (workType == ConnectionWorkType.WORKCON) { - var appService = ((ServiceManagerBase)session.AppTokens[1]); - appService.HandlerBinder.InvokePacketHandler(session, session.CompletedBuffer.GetMessageHead(), appService); + var appService = ((ApplicationRemoteService)session.AppTokens[1]); + appService.HandlerBinder.InvokePacketHandler(session, GetMessageHead(session), appService); } break; - case TcpSocketCompletionNotify.OnClosed: + case TcpSessionNotify.OnClosed: this.CloseHandler(session, notify); break; } @@ -250,56 +247,55 @@ namespace SiMay.ServiceCore.MainService /// /// /// - private void ConnectedHandler(TcpSocketSaeaSession session, TcpSocketCompletionNotify notify) + private void ConnectedHandler(TcpSocketSaeaSession session, TcpSessionNotify notify) { - if (Interlocked.Exchange(ref _sessionKeep, 1) == 0) + //当服务主连接离线或未连接,优先与session关联 + if (Interlocked.Exchange(ref _sessionKeepSign, STATE_NORMAL) == STATE_DISCONNECT) { - this.SendAckPack(session, ConnectionWorkType.MAINCON); - - _session = session; - //主连接优先获取session session.AppTokens = new object[2] { ConnectionWorkType.MAINCON, null }; + this.SetSession(session); + //服务主连接accessId保留 + this.SendACK(session, ConnectionWorkType.MAINCON, 0); + } else { - this.SendAckPack(session, ConnectionWorkType.WORKCON); - - //消费工作实例 - ServiceManagerBase manager = _taskQueue.Dequeue(); - if (manager == null) + ApplicationRemoteService service = _taskQueue.Dequeue(); + if (service.IsNull()) { - //无工作实例。。连接分配不到工作 + //找不到服务。。 session.Close(false); return; } session.AppTokens = new object[2] { ConnectionWorkType.WORKCON, - manager + service }; - manager.SetSession(session); + service.SetSession(session); + this.SendACK(session, ConnectionWorkType.WORKCON, service.AccessId); } } - private void CloseHandler(TcpSocketSaeaSession session, TcpSocketCompletionNotify notify) + private void CloseHandler(TcpSocketSaeaSession session, TcpSessionNotify notify) { - if (_sessionKeep == 0 && session.AppTokens == null) + if (_sessionKeepSign == STATE_DISCONNECT && session.AppTokens.IsNull()) { - //主连接连接失败 + //服务主连接断开或未连接 session.AppTokens = new object[2] { ConnectionWorkType.MAINCON, null }; } - else if (_sessionKeep == 1 && session.AppTokens == null)//task连接,连接服务器失败 + else if (_sessionKeepSign == STATE_NORMAL && session.AppTokens.IsNull())//task连接,连接服务器失败 { - _taskQueue.Dequeue();//移除掉,不重试连接,因为可能会连接不上,导致频繁重试连接 - return; + _taskQueue.Dequeue(); + return;//不重试连接,因为可能会连接不上,导致频繁重试连接 } var workType = (ConnectionWorkType)session.AppTokens[0]; @@ -307,10 +303,10 @@ namespace SiMay.ServiceCore.MainService { _screenViewIsAction = false; //清除主连接会话信息 - _session = null; - Interlocked.Exchange(ref _sessionKeep, 0); + this.SetSession(null); + Interlocked.Exchange(ref _sessionKeepSign, STATE_DISCONNECT); - System.Timers.Timer timer = new System.Timers.Timer(); + var timer = new System.Timers.Timer(); timer.Interval = 5000; timer.Elapsed += (s, e) => { @@ -324,75 +320,87 @@ namespace SiMay.ServiceCore.MainService } else if (workType == ConnectionWorkType.WORKCON) { - var appService = ((ServiceManagerBase)session.AppTokens[1]); - if (appService.Closed) + var appService = ((ApplicationRemoteService)session.AppTokens[1]); + if (appService.WhetherClosed) return; - appService.Closed = true; + appService.WhetherClosed = true; appService.SessionClosed(); } } - private void PostTaskToQueue(ServiceManagerBase manager) + private void PostTaskToQueue(ApplicationRemoteService service) { - this._taskQueue.Enqueue(manager); + this._taskQueue.Enqueue(service); this.ConnectToServer(); } - [PacketHandler(MessageHead.S_MAIN_ACTIVATE_CTRLSERVICE)] - public void ActiveControlService(TcpSocketSaeaSession session) + [PacketHandler(MessageHead.S_MAIN_ACTIVATE_APPLICATIONSERVICE)] + private void ActivateApplicationService(TcpSocketSaeaSession session) { - string key = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + var activateServicePack = GetMessageEntity(session); + string key = activateServicePack.ApplicationKey; + + //获取当前消息发送源主控端标识 + long accessId = this.GetAccessId(session); var context = SysUtil.ControlTypes.FirstOrDefault(x => x.ServiceKey.Equals(key)); if (context != null) { - var serviceName = context.AppServiceType.GetCustomAttribute(true).Name; - SystemMessageNotify.ShowTip($"正在进行远程操作:{serviceName ?? context.ServiceKey}"); - var appService = Activator.CreateInstance(context.AppServiceType, null) as ServiceManagerBase; + var serviceName = context.AppServiceType.GetCustomAttribute(true); + SystemMessageNotify.ShowTip($"正在进行远程操作:{(serviceName.IsNull() ? context.ServiceKey : serviceName.Name) }"); + var appService = Activator.CreateInstance(context.AppServiceType, null) as ApplicationRemoteService; appService.AppServiceKey = context.ServiceKey; + appService.AccessId = accessId; this.PostTaskToQueue(appService); } } [PacketHandler(MessageHead.S_MAIN_REMARK)] - public void SetRemarkInfo(TcpSocketSaeaSession session) + private void SetRemarkInfo(TcpSocketSaeaSession session) { - var des = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + var des = GetMessage(session).ToUnicodeString(); AppConfiguartion.RemarkInfomation = des; } [PacketHandler(MessageHead.S_MAIN_GROUP)] - public void SetGroupName(TcpSocketSaeaSession session) + private void SetGroupName(TcpSocketSaeaSession session) { - var groupName = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + var groupName = GetMessage(session).ToUnicodeString(); AppConfiguartion.GroupName = groupName; } [PacketHandler(MessageHead.S_MAIN_SESSION)] - public void SetSystemSession(TcpSocketSaeaSession session) + private void SetSystemSession(TcpSocketSaeaSession session) { - ComputerSessionHelper.SessionManager(session.CompletedBuffer.GetMessagePayload()[0]); + SystemSessionHelper.SetSessionStatus(GetMessage(session)[0]); } [PacketHandler(MessageHead.S_MAIN_RELOADER)] - public void ReLoader(TcpSocketSaeaSession session) + private void ReLoader(TcpSocketSaeaSession session) { Application.Restart(); } [PacketHandler(MessageHead.S_MAIN_UPDATE)] - public void UpdateService(TcpSocketSaeaSession session) + private void UpdateService(TcpSocketSaeaSession session) { try { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); string tempFile = this.GetTempFilePath(".exe"); if (pack.UrlOrFileUpdate == RemoteUpdateType.File) { - using (var stream = File.Open(tempFile, FileMode.Create, FileAccess.Write)) + if (pack.CurrentPack == 1 && File.Exists(tempFile)) + { + File.Delete(tempFile); + } + using (var stream = new FileStream(tempFile, FileMode.Append,FileAccess.Write)) { - stream.Seek(0, SeekOrigin.Begin); stream.Write(pack.FileDate, 0, pack.FileDate.Length); } + pack.FileDate = null; + pack.CurrentPack += 1; + SendTo(session, MessageHead.S_MAIN_UPDATE, pack); + } else if (pack.UrlOrFileUpdate == RemoteUpdateType.Url) { @@ -403,30 +411,34 @@ namespace SiMay.ServiceCore.MainService } } - if (File.Exists(tempFile) && new FileInfo(tempFile).Length > 0) + if (pack.CurrentPack > pack.FilePackLength) { - var batchFile = CreateBatch(Application.ExecutablePath, tempFile); - if (!batchFile.IsNullOrEmpty()) + if (File.Exists(tempFile) && new FileInfo(tempFile).Length > 0) { - ProcessStartInfo startInfo = new ProcessStartInfo + var batchFile = CreateBatch(Application.ExecutablePath, tempFile); + if (!batchFile.IsNullOrEmpty()) { - WindowStyle = ProcessWindowStyle.Hidden, - UseShellExecute = true, - FileName = batchFile - }; - Process.Start(startInfo); - - Environment.Exit(0);//退出程序 + ProcessStartInfo startInfo = new ProcessStartInfo + { + WindowStyle = ProcessWindowStyle.Hidden, + UseShellExecute = true, + FileName = batchFile + }; + Process.Start(startInfo); + + Environment.Exit(0);//退出程序 + } + else + { + LogHelper.WriteErrorByCurrentMethod("远程更新失败,更新脚本创建失败!"); + } } else { - LogHelper.WriteErrorByCurrentMethod("远程更新失败,更新脚本创建失败!"); + LogHelper.WriteErrorByCurrentMethod("远程更新失败,服务端文件不存在!"); } } - else - { - LogHelper.WriteErrorByCurrentMethod("远程更新失败,服务端文件不存在!"); - } + } catch (Exception ex) { @@ -462,35 +474,36 @@ namespace SiMay.ServiceCore.MainService private string GetTempFilePath(string extension) { string tempFilePath; - do - { - tempFilePath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + extension); - } while (File.Exists(tempFilePath)); + //do + //{ + tempFilePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\", Path.GetFileNameWithoutExtension(Application.ExecutablePath) + extension); + //} while (File.Exists(tempFilePath)); return tempFilePath; } [PacketHandler(MessageHead.S_MAIN_HTTPDOWNLOAD)] - public void HttpDownloadExecute(TcpSocketSaeaSession session) + private void HttpDownloadExecute(TcpSocketSaeaSession session) { - DownloadHelper.DownloadFile(session.CompletedBuffer.GetMessagePayload()); + DownloadHelper.DownloadFile(GetMessage(session)); } [PacketHandler(MessageHead.S_MAIN_OPEN_WEBURL)] - public void OpenUrl(TcpSocketSaeaSession session) + private void OpenUrl(TcpSocketSaeaSession session) { try { - Process.Start(session.CompletedBuffer.GetMessagePayload().ToUnicodeString()); + Process.Start(GetMessage(session).ToUnicodeString()); } catch { } } - [PacketHandler(MessageHead.S_MAIN_DESKTOPVIEW)] - public void CreateDesktopView(TcpSocketSaeaSession session) + + [PacketHandler(MessageHead.S_MAIN_CREATE_DESKTOPVIEW)] + private void CreateDesktopView(TcpSocketSaeaSession session) { - var isConstraint = session.CompletedBuffer.GetMessagePayload()[0]; - AppConfiguartion.IsOpenScreenView = "true"; - if (_screenViewIsAction != true || isConstraint == 0) + var isConstraint = GetMessage(session)[0]; + AppConfiguartion.IsOpenScreenView = true; + if (!_screenViewIsAction || isConstraint == 0) this.OnRemoteCreateDesktopView(); } @@ -498,33 +511,39 @@ namespace SiMay.ServiceCore.MainService /// 发送桌面下一帧 /// /// - [PacketHandler(MessageHead.S_MAIN_SCREENWALL_GETIMG)] - public void SendNextScreenView(TcpSocketSaeaSession session) + [PacketHandler(MessageHead.S_MAIN_DESKTOPVIEW_GETFRAME)] + private void SendNextFrameDesktopView(TcpSocketSaeaSession session) { - ThreadPool.QueueUserWorkItem(c => + ThreadHelper.ThreadPoolStart(c => { - var getframe = session.CompletedBuffer.GetMessageEntity(); + var args = c.ConvertTo(); + var accessId = args[0].ConvertTo(); + var getframe = args[1].ConvertTo(); if (getframe.Width == 0 || getframe.Height == 0 || getframe.TimeSpan == 0 || getframe.TimeSpan < 50) return; - Thread.Sleep(getframe.TimeSpan); + Thread.SetData(Thread.GetNamedDataSlot("AccessId"), accessId); - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_MAIN_SCREENWALL_IMG, - ImageExtensionHelper.CaptureNoCursorToBytes(new Size(getframe.Width, getframe.Height))); + Thread.Sleep(getframe.TimeSpan); - SendMessageToServer(data); - }); + SendTo(session, MessageHead.C_MAIN_DESKTOPVIEW_FRAME, + new DesktopViewFramePack() + { + InVisbleArea = getframe.InVisbleArea, + ViewData = getframe.InVisbleArea ? ImageExtensionHelper.CaptureNoCursorToBytes(new Size(getframe.Width, getframe.Height)) : new byte[0] + }); + }, new object[] { GetAccessId(session), GetMessageEntity(session) }); } - [PacketHandler(MessageHead.S_MAIN_USERDESKTOP_CLOSE)] - public void CloseDesktopView(TcpSocketSaeaSession session) + [PacketHandler(MessageHead.S_MAIN_DESKTOPVIEW_CLOSE)] + private void CloseDesktopView(TcpSocketSaeaSession session) { _screenViewIsAction = false; - AppConfiguartion.IsOpenScreenView = "false"; + AppConfiguartion.IsOpenScreenView = false; } - [PacketHandler(MessageHead.S_MAIN_SCREEN_RECORD_OPEN)] - public void ActionScreenRecord(TcpSocketSaeaSession session) + [PacketHandler(MessageHead.S_MAIN_DESKTOPRECORD_OPEN)] + private void StartDesktopRecord(TcpSocketSaeaSession session) { - var getframe = session.CompletedBuffer.GetMessageEntity(); + var getframe = GetMessageEntity(session); _screen_record_height = getframe.Height; _screen_record_width = getframe.Width; _screen_record_spantime = getframe.TimeSpan; @@ -532,19 +551,17 @@ namespace SiMay.ServiceCore.MainService if (_screen_record_height <= 0 || _screen_record_width <= 0 || _screen_record_spantime < 500) return; - AppConfiguartion.ScreenRecordHeight = _screen_record_height.ToString(); - AppConfiguartion.ScreenRecordWidth = _screen_record_width.ToString(); - AppConfiguartion.ScreenRecordSpanTime = _screen_record_spantime.ToString(); - AppConfiguartion.IsScreenRecord = "true"; + AppConfiguartion.ScreenRecordHeight = _screen_record_height; + AppConfiguartion.ScreenRecordWidth = _screen_record_width; + AppConfiguartion.ScreenRecordSpanTime = _screen_record_spantime; + AppConfiguartion.IsScreenRecord = true; //主机名称作为目录名 - this.SendMessageToServer(MessageHelper.CopyMessageHeadTo(MessageHead.C_MAIN_SCREEN_RECORD_OPEN, Environment.MachineName)); - } - [PacketHandler(MessageHead.S_MAIN_SCREEN_RECORD_CLOSE)] - public void ScreenRecordClose(TcpSocketSaeaSession session) - { - AppConfiguartion.IsScreenRecord = "false"; + SendTo(session, MessageHead.C_MAIN_DESKTOPRECORD_OPEN, Environment.MachineName); } + [PacketHandler(MessageHead.S_MAIN_DESKTOPRECORD_CLOSE)] + private void DesktopRecordClose(TcpSocketSaeaSession session) + => AppConfiguartion.IsScreenRecord = false; /// /// 远程创建屏幕墙屏幕视图 @@ -555,14 +572,12 @@ namespace SiMay.ServiceCore.MainService //创建屏幕 string RemarkName = AppConfiguartion.RemarkInfomation ?? AppConfiguartion.DefaultRemarkInfo; - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_MAIN_USERDESKTOP_CREATE, + SendTo(CurrentSession, MessageHead.C_MAIN_DESKTOPVIEW_CREATE, new DesktopViewDescribePack() { MachineName = Environment.MachineName, RemarkInformation = RemarkName }); - - SendMessageToServer(data); } @@ -572,8 +587,8 @@ namespace SiMay.ServiceCore.MainService /// /// /// - [PacketHandler(MessageHead.S_MAIN_SCREEN_RECORD_GETIMG)] - public void SendNextScreenRecordView(TcpSocketSaeaSession session) + [PacketHandler(MessageHead.S_MAIN_DESKTOPRECORD_GETFRAME)] + private void SendNextDesktopRecordFrame(TcpSocketSaeaSession session) { ThreadPool.QueueUserWorkItem((o) => @@ -583,17 +598,14 @@ namespace SiMay.ServiceCore.MainService Thread.Sleep(_screen_record_spantime); - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_MAIN_SCREEN_RECORD_IMG, - ImageExtensionHelper.CaptureNoCursorToBytes(new Size(_screen_record_width, _screen_record_height))); - - SendMessageToServer(data); + SendTo(session, MessageHead.C_MAIN_DESKTOPRECORD_FRAME, ImageExtensionHelper.CaptureNoCursorToBytes(new Size(_screen_record_width, _screen_record_height))); }); } [PacketHandler(MessageHead.S_MAIN_MESSAGEBOX)] - public void ShowMessageBox(TcpSocketSaeaSession session) + private void ShowMessageBox(TcpSocketSaeaSession session) { - var msg = session.CompletedBuffer.GetMessageEntity(); + var msg = GetMessageEntity(session); ThreadHelper.CreateThread(() => { string title = msg.MessageTitle; @@ -623,16 +635,16 @@ namespace SiMay.ServiceCore.MainService /// 发送上线包 /// [PacketHandler(MessageHead.S_GLOBAL_OK)] - public void SendLoginPack(TcpSocketSaeaSession session) + private void SendLoginPack(TcpSocketSaeaSession session) { string remarkInfomation = AppConfiguartion.RemarkInfomation ?? AppConfiguartion.DefaultRemarkInfo; string groupName = AppConfiguartion.GroupName ?? AppConfiguartion.DefaultGroupName; - string openScreenWall = AppConfiguartion.IsOpenScreenView ?? "true";//默认为打开屏幕墙 - string openScreenRecord = AppConfiguartion.IsScreenRecord ?? "false"; //默认屏幕记录 + bool openScreenWall = AppConfiguartion.IsOpenScreenView;//默认为打开屏幕墙 + bool openScreenRecord = AppConfiguartion.IsScreenRecord; //默认屏幕记录 var loginPack = new LoginPack(); loginPack.IPV4 = SystemInfoHelper.GetLocalIPV4(); - loginPack.MachineName = Environment.MachineName ?? ""; + loginPack.MachineName = Environment.MachineName ?? string.Empty; loginPack.Remark = remarkInfomation; loginPack.ProcessorCount = Environment.ProcessorCount; loginPack.ProcessorInfo = SystemInfoHelper.GetMyCpuInfo; @@ -642,21 +654,19 @@ namespace SiMay.ServiceCore.MainService loginPack.UserName = Environment.UserName.ToString(); loginPack.OSVersion = SystemInfoHelper.GetOSFullName; loginPack.GroupName = groupName; - loginPack.OpenScreenWall = (openScreenWall == "true" ? true : false); + loginPack.OpenScreenWall = openScreenWall; loginPack.ExistCameraDevice = SystemInfoHelper.ExistCameraDevice(); loginPack.ExitsRecordDevice = SystemInfoHelper.ExistRecordDevice(); loginPack.ExitsPlayerDevice = SystemInfoHelper.ExistPlayDevice(); loginPack.IdentifyId = AppConfiguartion.IdentifyId; - loginPack.OpenScreenRecord = (openScreenRecord == "true" ? true : false); + loginPack.OpenScreenRecord = openScreenRecord; loginPack.RecordHeight = _screen_record_height; loginPack.RecordWidth = _screen_record_width; loginPack.RecordSpanTime = _screen_record_spantime; loginPack.HasLoadServiceCOM = true;//已加载 + loginPack.MacAddress = SystemInfoHelper.GetMacAddress; - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.C_MAIN_LOGIN, - loginPack); - - SendMessageToServer(data); + SendTo(session, MessageHead.C_MAIN_LOGIN, loginPack); } } } \ No newline at end of file diff --git a/SiMay.RemoteClient.NewCore/MainService/ManagerTaskQueue.cs b/SiMay.RemoteClient.NewCore/MainService/ManagerTaskQueue.cs deleted file mode 100644 index 068bb612b0def15019e528f8bce69e9935899be6..0000000000000000000000000000000000000000 --- a/SiMay.RemoteClient.NewCore/MainService/ManagerTaskQueue.cs +++ /dev/null @@ -1,34 +0,0 @@ -using SiMay.ServiceCore.ApplicationService; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace SiMay.ServiceCore.MainService -{ - /// - /// 线程安全的任务队列,防止任务重复创建 - /// - public class ManagerTaskQueue : Queue - { - private readonly object _taskopLock = new object(); - - public new void Enqueue(ServiceManagerBase manager) - { - lock (_taskopLock) - { - base.Enqueue(manager); - } - } - public new ServiceManagerBase Dequeue() - { - ServiceManagerBase manager = null; - lock (_taskopLock) - { - if (this.Count > 0) - manager = base.Dequeue(); - } - return manager; - } - } -} diff --git a/SiMay.RemoteClient.NewCore/MainService/UpdateService.cs b/SiMay.RemoteClient.NewCore/MainService/ServiceTaskQueue.cs similarity index 31% rename from SiMay.RemoteClient.NewCore/MainService/UpdateService.cs rename to SiMay.RemoteClient.NewCore/MainService/ServiceTaskQueue.cs index f40ed85cc71c7ee8a910c6bf8d2b19b5cbe2b30d..ec402f6f702a33dcd7c4ecaca147997ec071ccc7 100644 --- a/SiMay.RemoteClient.NewCore/MainService/UpdateService.cs +++ b/SiMay.RemoteClient.NewCore/MainService/ServiceTaskQueue.cs @@ -1,15 +1,14 @@ -using System; +using System.Collections.Concurrent; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace SiMay.ServiceCore.MainService { - public class UpdateService + public class ServiceTaskQueue : ConcurrentQueue { - public static void Update(string destFileName) + public ApplicationRemoteService Dequeue() { - + base.TryDequeue(out var service); + return service; } } } diff --git a/SiMay.RemoteClient.NewCore/MainService/ComputerSessionHelper.cs b/SiMay.RemoteClient.NewCore/MainService/SystemSessionHelper.cs similarity index 80% rename from SiMay.RemoteClient.NewCore/MainService/ComputerSessionHelper.cs rename to SiMay.RemoteClient.NewCore/MainService/SystemSessionHelper.cs index 897967ffe352ef7ebde18b70be4bab381f59f24a..a76e56e8b1eac50cb0e5afee3c8b5bc6cde1f197 100644 --- a/SiMay.RemoteClient.NewCore/MainService/ComputerSessionHelper.cs +++ b/SiMay.RemoteClient.NewCore/MainService/SystemSessionHelper.cs @@ -1,8 +1,6 @@ using Microsoft.Win32; using SiMay.Core; -using SiMay.ServiceCore.ApplicationService; using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; @@ -13,7 +11,7 @@ using System.Windows.Forms; namespace SiMay.ServiceCore.MainService { - public class ComputerSessionHelper + public class SystemSessionHelper { /// /// 关机 @@ -60,8 +58,12 @@ namespace SiMay.ServiceCore.MainService /// 卸载服务 /// public const int UNINSTALL_SERVICE = 8; + /// + /// 重启服务 + /// + public const int RESTART_SERVICE = 9; - public static void SessionManager(int status) + public static void SetSessionStatus(int status) { switch (status) { @@ -97,6 +99,9 @@ namespace SiMay.ServiceCore.MainService case UNINSTALL_SERVICE: UnInstallAutoStartService(); break; + case RESTART_SERVICE: + ReStartService(); + break; } } @@ -127,7 +132,7 @@ namespace SiMay.ServiceCore.MainService if (key != null) key.DeleteValue("SiMayServiceEx"); } } - catch (Exception e) + catch { } @@ -181,5 +186,36 @@ namespace SiMay.ServiceCore.MainService } catch { } } + + /// + /// 重启服务项 + /// + private static void ReStartService() + { + string batPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\ReService.bat"; + if (!File.Exists(batPath)) + { + try + { + string strReServiceBatch = + "@echo off" + "\r\n" + + "net stop SiMayService" + "\r\n" + + "net start SiMayService" + "\r\n"; + + File.WriteAllText(batPath, strReServiceBatch, new UTF8Encoding(false)); + } + catch (Exception) + { + + } + } + ProcessStartInfo startInfo = new ProcessStartInfo + { + WindowStyle = ProcessWindowStyle.Hidden, + UseShellExecute = true, + FileName = batPath + }; + Process.Start(startInfo); + } } } diff --git a/SiMay.RemoteClient.NewCore/Program.cs b/SiMay.RemoteClient.NewCore/Program.cs index 1ed977f8327e96d020664e95daca489ea5b5388a..4557814a89f31c0b05aad27e389ea957dc5de305 100644 --- a/SiMay.RemoteClient.NewCore/Program.cs +++ b/SiMay.RemoteClient.NewCore/Program.cs @@ -19,6 +19,7 @@ using System.Linq; using System.Reflection; using System.ServiceProcess; using SiMay.ServiceCore.MainService; +using SiMay.Serialize.Standard; namespace SiMay.ServiceCore { @@ -69,23 +70,23 @@ namespace SiMay.ServiceCore { var startParameter = new StartParameterEx() { - Host = "192.168.1.105", - Port = 5200, - //Port = 522, + Host = "192.168.168.3", + //Port = 520, + Port = 32522, GroupName = "默认分组", RemarkInformation = "SiMayService", IsHide = false, IsMutex = false, IsAutoStart = false, - SessionMode = 0, - //SessionMode = 1, + //SessionMode = 0, + SessionMode = 1, AccessKey = 5200, - ServiceVersion = "正式5.0", + ServiceVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(), RunTimeText = DateTime.Now.ToString(), UniqueId = "AAAAAAAAAAAAAAA11111111", ServiceName = "SiMayService", ServiceDisplayName = "SiMay远程被控服务", - InstallService = true + InstallService = false }; try { @@ -105,7 +106,7 @@ namespace SiMay.ServiceCore startParameter.IsHide = options.IsHide; startParameter.AccessKey = options.AccessKey; startParameter.SessionMode = options.SessionMode; - startParameter.UniqueId = options.Id; + startParameter.UniqueId = options.Id + $"_{Environment.MachineName}"; startParameter.IsMutex = options.IsMutex; startParameter.GroupName = options.GroupName; startParameter.InstallService = options.InstallService; @@ -124,9 +125,7 @@ namespace SiMay.ServiceCore Environment.Exit(0); } - AppConfiguartion.HasSystemAuthority = args.Any(c => c.Equals(SERVICE_USER_START, StringComparison.OrdinalIgnoreCase)) ? - "true" : - "false"; + AppConfiguartion.HasSystemAuthority = args.Any(c => c.Equals(SERVICE_USER_START, StringComparison.OrdinalIgnoreCase)); AppConfiguartion.ServiceName = startParameter.ServiceName.IsNullOrEmpty() ? "SiMayService" : startParameter.ServiceName; AppConfiguartion.ServiceDisplayName = startParameter.ServiceDisplayName.IsNullOrEmpty() ? "SiMay远程被控服务" : startParameter.ServiceDisplayName; @@ -139,7 +138,7 @@ namespace SiMay.ServiceCore //非SYSTEM用户进程启动则进入安装服务 if (startParameter.InstallService && !args.Any(c => c.Equals(SERVICE_USER_START, StringComparison.OrdinalIgnoreCase))) - ComputerSessionHelper.InstallAutoStartService(); + SystemSessionHelper.InstallAutoStartService(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; diff --git a/SiMay.RemoteClient.NewCore/Properties/AssemblyInfo.cs b/SiMay.RemoteClient.NewCore/Properties/AssemblyInfo.cs index 27f83eb796cbecce6492094297d903433ddbc0bf..a63b6346abe6617f3bb5bb40fdf7e9df66fccfc8 100644 Binary files a/SiMay.RemoteClient.NewCore/Properties/AssemblyInfo.cs and b/SiMay.RemoteClient.NewCore/Properties/AssemblyInfo.cs differ diff --git a/SiMay.RemoteClient.NewCore/Properties/Resources.Designer.cs b/SiMay.RemoteClient.NewCore/Properties/Resources.Designer.cs index 406366875c573e0b9dccba0acb92b7945472f6f3..27ad1a79699f27b0c8ebe76580edbcc714bb0848 100644 --- a/SiMay.RemoteClient.NewCore/Properties/Resources.Designer.cs +++ b/SiMay.RemoteClient.NewCore/Properties/Resources.Designer.cs @@ -19,7 +19,7 @@ namespace SiMay.ServiceCore.Properties { // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen // (以 /str 作为命令选项),或重新生成 VS 项目。 - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] internal class Resources { diff --git a/SiMay.RemoteClient.NewCore/Properties/Settings.Designer.cs b/SiMay.RemoteClient.NewCore/Properties/Settings.Designer.cs index 4b3527c8de13d5f18d13804efa346fc0a1ca8e2f..631f1e5c1b6b10d95aeb5bf4a290def6ed8e8fc5 100644 --- a/SiMay.RemoteClient.NewCore/Properties/Settings.Designer.cs +++ b/SiMay.RemoteClient.NewCore/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace SiMay.ServiceCore.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/SiMay.RemoteClient.NewCore/Properties/app.manifest b/SiMay.RemoteClient.NewCore/Properties/app.manifest index b84d3956816cd2e767e7b18152b6e88401b0309d..31caee1e7830502c679219456815c826118aa63f 100644 --- a/SiMay.RemoteClient.NewCore/Properties/app.manifest +++ b/SiMay.RemoteClient.NewCore/Properties/app.manifest @@ -18,8 +18,8 @@ + - diff --git a/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationProtocolService.cs b/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationProtocolService.cs new file mode 100644 index 0000000000000000000000000000000000000000..ad7d48f198380b6639cb444fbde5f20b2cbd7da5 --- /dev/null +++ b/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationProtocolService.cs @@ -0,0 +1,105 @@ +using SiMay.Basic; +using SiMay.Core; +using SiMay.Core.PacketModelBinding; +using SiMay.Sockets.Tcp.Session; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +namespace SiMay.ServiceCore +{ + /// + /// 应用协议处理服务,提供消息封装丶消息解析处理及消息处理函数绑定 + /// + public abstract class ApplicationProtocolService : ApplicationServiceBase + { + /// + /// 数据处理绑定 + /// + public PacketModelBinder HandlerBinder { get; set; } + + + public ApplicationProtocolService() + { + HandlerBinder = new PacketModelBinder(); + } + + protected virtual void SendTo(TcpSocketSaeaSession session, MessageHead msg, object entity) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, entity); + SendToBefore(session, bytes); + } + protected virtual void SendTo(TcpSocketSaeaSession session, MessageHead msg, byte[] data = null) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data); + SendToBefore(session, bytes); + } + protected virtual void SendTo(TcpSocketSaeaSession session, MessageHead msg, string lpString) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, lpString); + SendToBefore(session, bytes); + } + protected virtual void SendToBefore(TcpSocketSaeaSession session, byte[] data) + { + //为解决延迟发送导致的accessId不安全问题 + var accessIdObj = Thread.GetData(Thread.GetNamedDataSlot("AccessId")); + var accessId = accessIdObj.IsNull() ? GetAccessId(session) : accessIdObj.ConvertTo(); + + SendTo(session, WrapAccessId(GZipHelper.Compress(data, 0, data.Length), accessId)); + } + + protected virtual void SendTo(TcpSocketSaeaSession session, byte[] data) + { + session.SendAsync(data); + } + /// + /// 封装主控端标识 + /// + /// + /// + /// + private byte[] WrapAccessId(byte[] data, long accessId) + { + var bytes = new byte[data.Length + sizeof(long)]; + BitConverter.GetBytes(accessId).CopyTo(bytes, 0); + data.CopyTo(bytes, sizeof(long)); + return bytes; + } + + protected virtual T GetMessageEntity(TcpSocketSaeaSession session) + where T : new() + { + return TakeHeadAndMessage(session).GetMessageEntity(); + } + + protected virtual byte[] GetMessage(TcpSocketSaeaSession session) + { + return TakeHeadAndMessage(session).GetMessagePayload(); + } + + protected virtual MessageHead GetMessageHead(TcpSocketSaeaSession session) + { + return TakeHeadAndMessage(session).GetMessageHead(); + } + + private byte[] TakeHeadAndMessage(TcpSocketSaeaSession session) + { + var bytes = session.CompletedBuffer.Copy(sizeof(long), session.CompletedBuffer.Length - sizeof(long)); + return GZipHelper.Decompress(bytes); + } + + /// + /// 获取当前数据来源AccessId + /// + /// + /// + protected long GetAccessId(TcpSocketSaeaSession session) + { + if (session.CompletedBuffer.IsNull()) + return 0; + return BitConverter.ToInt64(session.CompletedBuffer, 0); + } + + } +} diff --git a/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationRemoteService.cs b/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationRemoteService.cs new file mode 100644 index 0000000000000000000000000000000000000000..3e6f4bee995f31452c1a1c18f0e653222da7cb8a --- /dev/null +++ b/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationRemoteService.cs @@ -0,0 +1,61 @@ +using SiMay.Core; +using SiMay.Core.PacketModelBinder.Attributes; +using SiMay.Core.Packets; +using SiMay.Sockets.Tcp.Session; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SiMay.ServiceCore +{ + /// + /// 远程应用服务 + /// + public abstract class ApplicationRemoteService : ApplicationProtocolService + { + /// + /// 当前连接的主控端标识 + /// + public long AccessId { get; set; } + + /// + /// 服务唯一标识 + /// + public string AppServiceKey { get; set; } + + /// + /// 当前会话是否已关闭 + /// + public bool WhetherClosed { get; set; } = false; + + [PacketHandler(MessageHead.S_GLOBAL_OK)] + public void InitializeCompleted(TcpSocketSaeaSession session) + { + SendTo(CurrentSession, MessageHead.C_MAIN_ACTIVE_APP, + new ActivateApplicationPack() + { + IdentifyId = AppConfiguartion.IdentifyId, + ServiceKey = this.AppServiceKey, + OriginName = Environment.MachineName + "@" + (AppConfiguartion.RemarkInfomation ?? AppConfiguartion.DefaultRemarkInfo) + }); + this.SessionInited(session); + } + + [PacketHandler(MessageHead.S_GLOBAL_ONCLOSE)] + public void SessionClosed(TcpSocketSaeaSession session) + { + if (this.WhetherClosed) + return; + this.WhetherClosed = true; + this.CloseSession(); + this.SessionClosed(); + this.HandlerBinder.Dispose(); + } + + public abstract void SessionInited(TcpSocketSaeaSession session); + + public abstract void SessionClosed(); + } +} diff --git a/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationServiceBase.cs b/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationServiceBase.cs new file mode 100644 index 0000000000000000000000000000000000000000..a0e37028a0b5af7ebfda8d3d749a94707c156d3d --- /dev/null +++ b/SiMay.RemoteClient.NewCore/ServiceBase/ApplicationServiceBase.cs @@ -0,0 +1,35 @@ +using SiMay.Core; +using SiMay.Core.PacketModelBinder.Attributes; +using SiMay.Core.PacketModelBinding; +using SiMay.Core.Packets; +using SiMay.Sockets.Tcp; +using SiMay.Sockets.Tcp.Session; +using System; + +namespace SiMay.ServiceCore +{ + /// + /// 基础应用服务 + /// + public abstract class ApplicationServiceBase + { + + /// + /// 当前会话 + /// + protected TcpSocketSaeaSession CurrentSession { get; set; } + + /// + /// 设置当前Session + /// + /// + public void SetSession(TcpSocketSaeaSession session) + => CurrentSession = session; + + /// + /// 关闭当前会话 + /// + public void CloseSession() + => CurrentSession.Close(true); + } +} \ No newline at end of file diff --git a/SiMay.Net.SessionProviderService/Notify/ManagerChannelNotify.cs b/SiMay.RemoteClient.NewCore/ServiceBase/MainApplicationService.cs similarity index 58% rename from SiMay.Net.SessionProviderService/Notify/ManagerChannelNotify.cs rename to SiMay.RemoteClient.NewCore/ServiceBase/MainApplicationService.cs index bd7e87dc96280dccbad6440e5d7e3d1c508e557e..d692d20726b248aed8a68a22aca96dda17cfc8fd 100644 --- a/SiMay.Net.SessionProviderService/Notify/ManagerChannelNotify.cs +++ b/SiMay.RemoteClient.NewCore/ServiceBase/MainApplicationService.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace SiMay.Net.SessionProviderService.Notify +namespace SiMay.ServiceCore { - public enum ManagerChannelNotify + public class MainApplicationService : ApplicationProtocolService { } diff --git a/SiMay.RemoteClient.NewCore/SiMay.ServiceCore.csproj b/SiMay.RemoteClient.NewCore/SiMay.ServiceCore.csproj index 6da54e23a5be1c21f276e943cd066c1019538ab7..44862e86a9a4f682b1f3318ac7c36ffd517b3b0a 100644 --- a/SiMay.RemoteClient.NewCore/SiMay.ServiceCore.csproj +++ b/SiMay.RemoteClient.NewCore/SiMay.ServiceCore.csproj @@ -8,8 +8,8 @@ WinExe Properties SiMay.ServiceCore - SiMayServiceCore - v4.0 + SiMayService + v4.6.1 512 false @@ -35,7 +35,7 @@ true full false - ..\Bin\plugins\ + ..\Bin\dat\ DEBUG;TRACE prompt 4 @@ -47,7 +47,7 @@ AnyCPU pdbonly true - ..\Bin\plugins\ + ..\Bin\dat\ DEBUG;TRACE prompt 4 @@ -57,7 +57,7 @@ true - bin\x64\Debug\ + ..\Bin\dat\ DEBUG;TRACE full x64 @@ -87,6 +87,9 @@ + + Properties\app.manifest + ..\AForge.dll\AForge.Video.dll @@ -114,6 +117,7 @@ + @@ -124,21 +128,20 @@ - - + - - - + - + + + @@ -147,7 +150,9 @@ - + + + Component @@ -207,24 +212,24 @@ - {B30CD716-698A-4DA2-BD1A-C152B16993C0} + {8f2f35cb-d5ee-4d92-b42f-bcffbf9c9d4f} SiMay.Basic {1aadc6f7-6ff9-4c68-8a26-e507f22b9060} SiMay.Core - + {7efe8058-f772-40eb-8e12-6e88e2a9e19a} - SiMay.RemoteService + SiMay.RemoteService.Loader - - {4888d6bb-46d9-4519-8758-e13e397aa226} - SiMay.Serialize + + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32} + SiMay.Serialize.Standard - - {d181fcce-ecc7-4710-89cc-d97f94a6181b} - SiMay.Sockets.V4 + + {866f8fe0-ee58-4d38-8be7-cbdd19dd1b40} + SiMay.Sockets.Standard diff --git a/SiMay.RemoteClient.NewCore/SysUtil.cs b/SiMay.RemoteClient.NewCore/SysUtil.cs index 3eab3c88920ece8bdc0de559853c6778a1f9981d..bbd4dba0d5e946ab16de46d8d0b0ee6ed1bfcc8b 100644 --- a/SiMay.RemoteClient.NewCore/SysUtil.cs +++ b/SiMay.RemoteClient.NewCore/SysUtil.cs @@ -1,5 +1,4 @@ using SiMay.Basic; -using SiMay.ServiceCore.ApplicationService; using SiMay.ServiceCore.Extensions; using SiMay.ServiceCore.MainService; using System; @@ -13,29 +12,24 @@ namespace SiMay.ServiceCore { public class SysUtil { - public class ServiceTypeContext + public class ServiceTypeItem { public string ServiceKey { get; set; } public Type AppServiceType { get; set; } } - public static List ControlTypes { get; set; } + public static List ControlTypes { get; set; } static SysUtil() { - List controlTypes = new List(); - var types = Assembly.GetExecutingAssembly().GetTypes(); - foreach (var type in types) - { - if (typeof(ServiceManagerBase).IsAssignableFrom(type) && type.IsSubclassOf(typeof(ServiceManagerBase)) && type.IsClass) + ControlTypes = AppDomain.CurrentDomain + .GetAssemblies() + .SelectMany(a => a.GetTypes()) + .Where(type => typeof(ApplicationRemoteService).IsAssignableFrom(type) && type.IsSubclassOf(typeof(ApplicationRemoteService)) && type.IsClass) + .Select(type => new ServiceTypeItem() { - var context = new ServiceTypeContext() - { - ServiceKey = type.GetServiceKey() ?? throw new Exception(type.Name + ":The serviceKey cannot be empty!"), - AppServiceType = type - }; - controlTypes.Add(context); - } - } - ControlTypes = controlTypes; + ServiceKey = type.GetServiceKey() ?? throw new Exception(type.Name + ":The serviceKey cannot be empty!"), + AppServiceType = type + }) + .ToList(); } } @@ -51,12 +45,12 @@ namespace SiMay.ServiceCore exitMenu.MouseDown += (s, e) => { if (MessageBox.Show("确认退出服务吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) - ComputerSessionHelper.SessionManager(ComputerSessionHelper.UNSTALL);//退出 + SystemSessionHelper.SetSessionStatus(SystemSessionHelper.UNSTALL);//退出 }; var aboutMenu = new ToolStripMenuItem("关于服务"); aboutMenu.MouseDown += (s, e) => { - MessageBoxHelper.ShowBoxExclamation("SiMay远程管理是一款开源的Windows系统远程协助系统,支持远程桌面控制、文件管理、远程语音、远程查看摄像头、远程注册表、远程shell、远程键盘记录等功能,您当前运行的是被控服务程序。", "关于程序"); + MessageBox.Show("SiMay远程管理是一款开源的Windows系统远程协助系统,支持远程桌面、文件管理、远程语音、远程摄像头、远程注册表、远程shell等功能,您当前运行的是被控服务程序。", "关于程序", 0, MessageBoxIcon.Exclamation); }; contextMenus.Items.Add(aboutMenu); contextMenus.Items.Add(exitMenu); diff --git a/SiMay.RemoteClient.NewCore/TrunkService/Packet/EntityPack.cs b/SiMay.RemoteClient.NewCore/TrunkService/Packet/PacketEntity.cs similarity index 66% rename from SiMay.RemoteClient.NewCore/TrunkService/Packet/EntityPack.cs rename to SiMay.RemoteClient.NewCore/TrunkService/Packet/PacketEntity.cs index 845b27c8176f06f93e10191ece2296791bee806c..19b6916c2c7824be7a74ec8b69e967444aa94293 100644 --- a/SiMay.RemoteClient.NewCore/TrunkService/Packet/EntityPack.cs +++ b/SiMay.RemoteClient.NewCore/TrunkService/Packet/PacketEntity.cs @@ -1,26 +1,27 @@ -using System; +using SiMay.ReflectCache; +using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SiMay.ServiceCore { - public class ActivePack + public class ActivePack : EntitySerializerBase { public int SessionId { get; set; } } - public class SessionStatusPack + public class SessionStatusPack : EntitySerializerBase { public SessionItem[] Sessions { get; set; } } - public class CreateUserProcessPack + public class CreateUserProcessPack : EntitySerializerBase { public int SessionId { get; set; } } - public class SessionItem + public class SessionItem : EntitySerializerBase { public string UserName { get; set; } public int SessionId { get; set; } diff --git a/SiMay.RemoteClient.NewCore/TrunkService/Service.cs b/SiMay.RemoteClient.NewCore/TrunkService/Service.cs index af23f32ac75233e0aab34f01976683b3a0798aa4..4cc06eda6b5fed007ad368116d6216352f811c15 100644 --- a/SiMay.RemoteClient.NewCore/TrunkService/Service.cs +++ b/SiMay.RemoteClient.NewCore/TrunkService/Service.cs @@ -49,17 +49,17 @@ namespace SiMay.ServiceCore { switch (notity) { - case TcpSocketCompletionNotify.OnConnected: + case TcpSessionNotify.OnConnected: LogHelper.DebugWriteLog("OnConnected"); break; - case TcpSocketCompletionNotify.OnSend: + case TcpSessionNotify.OnSend: break; - case TcpSocketCompletionNotify.OnDataReceiveing: + case TcpSessionNotify.OnDataReceiveing: break; - case TcpSocketCompletionNotify.OnDataReceived: + case TcpSessionNotify.OnDataReceived: _handlerBinder.InvokePacketHandler(session, session.CompletedBuffer.GetMessageHead(), this); break; - case TcpSocketCompletionNotify.OnClosed: + case TcpSessionNotify.OnClosed: this.SessionClosedHandler(session); break; default: diff --git a/SiMay.RemoteClient.NewCore/TrunkService/UserTrunkContext.cs b/SiMay.RemoteClient.NewCore/TrunkService/UserTrunkContext.cs index f775f3d7cd5e88cb90018aab6c64354e6e149c83..93e2ad2b72bb58f61428be4c9e13db377c84f09d 100644 --- a/SiMay.RemoteClient.NewCore/TrunkService/UserTrunkContext.cs +++ b/SiMay.RemoteClient.NewCore/TrunkService/UserTrunkContext.cs @@ -66,19 +66,19 @@ namespace SiMay.ServiceCore { switch (notity) { - case TcpSocketCompletionNotify.OnConnected: + case TcpSessionNotify.OnConnected: LogHelper.DebugWriteLog("InitConntectTrunkService:OnClosed"); _trunkTcpSession = session; SendActiveFlag(); break; - case TcpSocketCompletionNotify.OnSend: + case TcpSessionNotify.OnSend: break; - case TcpSocketCompletionNotify.OnDataReceiveing: + case TcpSessionNotify.OnDataReceiveing: break; - case TcpSocketCompletionNotify.OnDataReceived: + case TcpSessionNotify.OnDataReceived: _handlerBinder.InvokePacketHandler(session, session.CompletedBuffer.GetMessageHead(), this); break; - case TcpSocketCompletionNotify.OnClosed: + case TcpSessionNotify.OnClosed: LogHelper.DebugWriteLog("InitConntectTrunkService:OnClosed"); _trunkTcpSession = null; _autoReset.Set(); diff --git a/SiMay.RemoteClient.NewCore/app.manifest b/SiMay.RemoteClient.NewCore/app.manifest new file mode 100644 index 0000000000000000000000000000000000000000..8c579dc49a8d39254ab379e778d78f5b111851d3 --- /dev/null +++ b/SiMay.RemoteClient.NewCore/app.manifest @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SiMay.RemoteClient.NewCore/packages.config b/SiMay.RemoteClient.NewCore/packages.config index dcda121159a5c4561dfc5e2bf464257016fdc41f..8f04900df95f0f38243cc39bf9cd224cbd454b3f 100644 --- a/SiMay.RemoteClient.NewCore/packages.config +++ b/SiMay.RemoteClient.NewCore/packages.config @@ -1,5 +1,5 @@  - - + + \ No newline at end of file diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/AdapterHandlerBase.cs b/SiMay.RemoteControlsCore/AdapterHandlerBase/ApplicationAdapterHandler.cs similarity index 38% rename from SiMay.RemoteControlsCore/HandlerAdapters/AdapterHandlerBase.cs rename to SiMay.RemoteControlsCore/AdapterHandlerBase/ApplicationAdapterHandler.cs index 1c9734e892146a9d7b14f31f68390e218b802557..a5d9398b2f648cbedc72e37bc22e92571a79fc68 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/AdapterHandlerBase.cs +++ b/SiMay.RemoteControlsCore/AdapterHandlerBase/ApplicationAdapterHandler.cs @@ -1,6 +1,6 @@ using SiMay.Core; using SiMay.Core.PacketModelBinding; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; using System; using System.Collections.Generic; using System.Linq; @@ -8,17 +8,29 @@ using System.Text; namespace SiMay.RemoteControlsCore { - public abstract class AdapterHandlerBase : IDisposable + public abstract class ApplicationAdapterHandler : ApplicationProtocolAdapterHandler { + /// + /// 当前会话对象 + /// + protected SessionProviderContext CurrentSession { get; set; } + + /// + /// 设置当前会话 + /// + /// + public void SetSession(SessionProviderContext session) + => CurrentSession = session; + /// /// 用户状态上下文 /// public object StateContext { get; set; } /// - /// 重连AppKey + /// 应用唯一标识 /// - public string ResetApplicationKey { get; set; } + public string ApplicationKey { get; set; } /// /// 来源备注名 @@ -33,94 +45,32 @@ namespace SiMay.RemoteControlsCore /// /// 当前会话是否关闭 /// - public bool IsClose { get; private set; } + public bool WhetherClose { get; private set; } /// /// 展示应用对象 /// public IApplication App { get; set; } - /// - /// 当前会话对象 - /// - public SessionHandler Session { get; set; } - - internal PacketModelBinder HandlerBinder { get; set; } - - public AdapterHandlerBase() - { - HandlerBinder = new PacketModelBinder(); - } - /// /// 当会话重连后触发 /// /// - internal virtual void ContinueTask(SessionHandler session) + public virtual void ContinueTask(SessionProviderContext session) => App.ContinueTask(this); /// /// 当会话中断后触发 /// /// - internal virtual void SessionClosed(SessionHandler session) + public virtual void SessionClosed(SessionProviderContext session) => App.SessionClose(this); - /// - /// 数据接收时触发(底层接收数据,未解压),未启用 - /// - /// - [Obsolete] - internal virtual void MessageReceive(SessionHandler session) - { } - - /// - /// 使用当前会话发送实体对象 - /// - /// - public void SendAsyncMessage(MessageHead msg, object entity) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, entity); - Session.SendAsync(bytes); - } - - /// - /// 使用当前会话仅发送消息头或者数据 - /// - /// - /// - public void SendAsyncMessage(MessageHead msg, byte[] data = null) - { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data); - Session.SendAsync(bytes); - } - - /// - /// 使用当前会话发送字符串 - /// - /// - /// - public void SendAsyncMessage(MessageHead msg, string lpString) + public virtual void CloseSession() { - byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, lpString); - Session.SendAsync(bytes); - } - - - /// - /// 断开当前会话 - /// - /// - public virtual void CloseHandler() - { - this.IsClose = true; + this.WhetherClose = true; this.HandlerBinder.Dispose(); - SendAsyncMessage(MessageHead.S_GLOBAL_ONCLOSE); - } - - public void Dispose() - { - this.CloseHandler(); + SendTo(CurrentSession, MessageHead.S_GLOBAL_ONCLOSE); } } } diff --git a/SiMay.RemoteControlsCore/AdapterHandlerBase/ApplicationProtocolAdapterHandler.cs b/SiMay.RemoteControlsCore/AdapterHandlerBase/ApplicationProtocolAdapterHandler.cs new file mode 100644 index 0000000000000000000000000000000000000000..1ab849e6bb412455e37b9ffb3c9164a57eae51ac --- /dev/null +++ b/SiMay.RemoteControlsCore/AdapterHandlerBase/ApplicationProtocolAdapterHandler.cs @@ -0,0 +1,110 @@ +using SiMay.Basic; +using SiMay.Core; +using SiMay.Core.PacketModelBinding; +using SiMay.Net.SessionProvider; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SiMay.RemoteControlsCore +{ + public abstract class ApplicationProtocolAdapterHandler : IDisposable + { + /// + /// 数据处理函数绑定 + /// + public PacketModelBinder HandlerBinder { get; set; } + + public ApplicationProtocolAdapterHandler() + { + HandlerBinder = new PacketModelBinder(); + } + + /// + /// 发送实体对象 + /// + /// + protected virtual void SendTo(SessionProviderContext session, MessageHead msg, object entity) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, entity); + SendToBefore(session, bytes); + } + + /// + /// 发送消息 + /// + /// + /// + protected virtual void SendTo(SessionProviderContext session, MessageHead msg, byte[] data = null) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data); + SendToBefore(session, bytes); + } + + /// + /// 发送字符串 + /// + /// + /// + protected virtual void SendTo(SessionProviderContext session, MessageHead msg, string lpString) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, lpString); + SendToBefore(session, bytes); + } + protected virtual void SendToBefore(SessionProviderContext session, byte[] data) + { + var accessId = AppConfiguration.UseAccessId; + SendTo(session, WrapAccessId(GZipHelper.Compress(data, 0, data.Length), accessId)); + } + + protected virtual void SendTo(SessionProviderContext session, byte[] data) + { + session.SendAsync(data); + } + + /// + /// 包装主控端标识 + /// + /// + /// + /// + private byte[] WrapAccessId(byte[] data, long accessId) + { + var bytes = new byte[data.Length + sizeof(long)]; + BitConverter.GetBytes(accessId).CopyTo(bytes, 0); + data.CopyTo(bytes, sizeof(long)); + return bytes; + } + + protected virtual T GetMessageEntity(SessionProviderContext session) + where T : new() + { + return TakeHeadAndMessage(session).GetMessageEntity(); + } + + protected virtual byte[] GetMessage(SessionProviderContext session) + { + return TakeHeadAndMessage(session).GetMessagePayload(); + } + + protected virtual MessageHead GetMessageHead(SessionProviderContext session) + { + return TakeHeadAndMessage(session).GetMessageHead(); + } + + private byte[] TakeHeadAndMessage(SessionProviderContext session) + { + var length = session.CompletedBuffer.Length - sizeof(long); + var bytes = new byte[length]; + Array.Copy(session.CompletedBuffer, sizeof(long), bytes, 0, length); + return GZipHelper.Decompress(bytes); + } + + public virtual void Dispose() + { + this.HandlerBinder.Dispose(); + } + } +} diff --git a/SiMay.RemoteControlsCore/AdapterHandlerBase/MainApplicationAdapterHandler.cs b/SiMay.RemoteControlsCore/AdapterHandlerBase/MainApplicationAdapterHandler.cs new file mode 100644 index 0000000000000000000000000000000000000000..6a404cb371024cf6ec1d6ca49180570d33a21785 --- /dev/null +++ b/SiMay.RemoteControlsCore/AdapterHandlerBase/MainApplicationAdapterHandler.cs @@ -0,0 +1,94 @@ +using SiMay.Basic; +using SiMay.Core; +using SiMay.Core.Packets; +using SiMay.Net.SessionProvider; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace SiMay.RemoteControlsCore +{ + public abstract class MainApplicationBaseAdapterHandler : ApplicationProtocolAdapterHandler + { + private Dictionary _serviceCOMPlugins = new Dictionary(); + + public MainApplicationBaseAdapterHandler() + { + // string[] pluginFileNames = new string[] + // { + // "SiMayServiceCore.dll", + // "SiMay.Core.dll", + // "SiMay.Serialize.dll", + // "SiMay.Basic.dll", + // "AForge.Video.dll", + // "AForge.Video.DirectShow.dll" + // }; + + // foreach (var fileName in pluginFileNames) + // { + // var path = Path.Combine(Environment.CurrentDirectory, "plugins", fileName); + // if (File.Exists(path)) + // ServiceCOMPlugins.Add(fileName, File.ReadAllBytes(path)); + // else + // throw new FileNotFoundException("服务插件缺失:" + fileName); + // } + + } + + /// + /// 加载插件 + /// + /// + private void SendServicePlugins(SessionProviderContext session) + { + SendTo(session, MessageHead.S_MAIN_PLUGIN_FILES, + new ServicePluginPack() + { + Files = _serviceCOMPlugins.Select(c => new PluginItem() { FileName = c.Key, PayLoad = c.Value }).ToArray() + }); + } + + /// + /// 发送实体对象 + /// + /// + protected void HasComWithSendTo(SessionProviderContext session, MessageHead msg, object entity) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, entity); + SendToBefore(session, bytes); + } + + /// + /// 发送消息 + /// + /// + /// + protected void HasComWithSendTo(SessionProviderContext session, MessageHead msg, byte[] data = null) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, data); + SendToBefore(session, bytes); + } + + /// + /// 发送字符串 + /// + /// + /// + protected void HasComWithSendTo(SessionProviderContext session, MessageHead msg, string lpString) + { + byte[] bytes = MessageHelper.CopyMessageHeadTo(msg, lpString); + SendToBefore(session, bytes); + } + + //protected override void SendToBefore(SessionProviderContext session, byte[] data) + //{ + // //var syncContext = session.AppTokens[SysConstants.INDEX_WORKER] as SessionSyncContext; + // //if (!syncContext[SysConstants.HasLoadServiceCOM].ConvertTo()) + // // SendServicePlugins(session); + // base.SendToBefore(session, data); + //} + } +} diff --git a/SiMay.RemoteControlsCore/AppConfiguration.cs b/SiMay.RemoteControlsCore/AppConfiguration.cs index a0ac09f28063f91472c79348575300d1dcb22782..4625f25c0901df42cd077e3932e1c993d1d9c6f9 100644 --- a/SiMay.RemoteControlsCore/AppConfiguration.cs +++ b/SiMay.RemoteControlsCore/AppConfiguration.cs @@ -17,20 +17,25 @@ namespace SiMay.RemoteControlsCore { "ConnectPassWord", "5200" }, { "MaxConnectCount", "100000" }, { "Maximize", "false" }, - { "DesktopViewHeight", "220" }, - { "DesktopViewWidth", "280" }, { "lHosts", "127.0.0.1:5200" }, { "DbClickViewExc", "" }, { "LockPassWord", "5200" }, { "WindowsIsLock", "false" }, - { "DesktopRefreshTimeSpan", "1500" }, + { "DesktopRefreshInterval", "1500" }, { "AudioSamplesPerSecond", "8000" }, { "AudioBitsPerSample", "16" }, { "AudioChannels", "1" }, { "SessionMode", "0" }, - { "AccessKey", "522222" }, { "ServiceIPAddress", "127.0.0.1" }, - { "ServicePort", "522" } + { "ServicePort", "522" }, + { "EnabledCarousel", "true" }, + { "CarouselInterval", "5000" }, + { "ViewColumn", "4" }, + { "ViewRow", "3" }, + { "EnabledAnonyMous", "true" }, + { "AccessId" , "123456789" }, + { "MainAppAccessKey", "5200" }, + { "AccessKey", "5200" } }; string _filePath = Path.Combine(Environment.CurrentDirectory, "SiMayConfig.ini"); @@ -65,10 +70,10 @@ namespace SiMay.RemoteControlsCore set { SysConfig.SetConfig("IPAddress", value); } } - public static string Port + public static int Port { - get { return SysConfig.GetConfig("Port"); } - set { SysConfig.SetConfig("Port", value); } + get { return int.Parse(SysConfig.GetConfig("Port")); } + set { SysConfig.SetConfig("Port", value.ToString()); } } public static string ConnectPassWord @@ -77,30 +82,17 @@ namespace SiMay.RemoteControlsCore set { SysConfig.SetConfig("ConnectPassWord", value); } } - public static string MaxConnectCount + public static int MaxConnectCount { - get { return SysConfig.GetConfig("MaxConnectCount"); } - set { SysConfig.SetConfig("MaxConnectCount", value); } + get { return int.Parse(SysConfig.GetConfig("MaxConnectCount")); } + set { SysConfig.SetConfig("MaxConnectCount", value.ToString()); } } - public static string WindowMaximize + public static bool WindowMaximize { - get { return SysConfig.GetConfig("Maximize"); } - set { SysConfig.SetConfig("Maximize", value); } + get { return bool.Parse(SysConfig.GetConfig("Maximize")); } + set { SysConfig.SetConfig("Maximize", value.ToString()); } } - - public static string DesktopViewHeight - { - get { return SysConfig.GetConfig("DesktopViewHeight"); } - set { SysConfig.SetConfig("DesktopViewHeight", value); } - } - - public static string DesktopViewWidth - { - get { return SysConfig.GetConfig("DesktopViewWidth"); } - set { SysConfig.SetConfig("DesktopViewWidth", value); } - } - public static string LHostString { get { return SysConfig.GetConfig("lHosts"); } @@ -119,34 +111,34 @@ namespace SiMay.RemoteControlsCore set { SysConfig.SetConfig("LockPassWord", value); } } - public static string WindowsIsLock + public static bool WindowsIsLock { - get { return SysConfig.GetConfig("WindowsIsLock"); } - set { SysConfig.SetConfig("WindowsIsLock", value); } + get { return bool.Parse(SysConfig.GetConfig("WindowsIsLock")); } + set { SysConfig.SetConfig("WindowsIsLock", value.ToString()); } } - public static string DesktopRefreshTimeSpan + public static int DesktopRefreshInterval { - get { return SysConfig.GetConfig("DesktopRefreshTimeSpan"); } - set { SysConfig.SetConfig("DesktopRefreshTimeSpan", value); } + get { return int.Parse(SysConfig.GetConfig("DesktopRefreshInterval")); } + set { SysConfig.SetConfig("DesktopRefreshInterval", value.ToString()); } } - public static string AudioSamplesPerSecond + public static int AudioSamplesPerSecond { - get { return SysConfig.GetConfig("AudioSamplesPerSecond"); } - set { SysConfig.SetConfig("AudioSamplesPerSecond", value); } + get { return int.Parse(SysConfig.GetConfig("AudioSamplesPerSecond")); } + set { SysConfig.SetConfig("AudioSamplesPerSecond", value.ToString()); } } - public static string AudioBitsPerSample + public static int AudioBitsPerSample { - get { return SysConfig.GetConfig("AudioBitsPerSample"); } - set { SysConfig.SetConfig("AudioBitsPerSample", value); } + get { return int.Parse(SysConfig.GetConfig("AudioBitsPerSample")); } + set { SysConfig.SetConfig("AudioBitsPerSample", value.ToString()); } } - public static string AudioChannels + public static int AudioChannels { - get { return SysConfig.GetConfig("AudioChannels"); } - set { SysConfig.SetConfig("AudioChannels", value); } + get { return int.Parse(SysConfig.GetConfig("AudioChannels")); } + set { SysConfig.SetConfig("AudioChannels", value.ToString()); } } public static string SessionMode @@ -166,10 +158,57 @@ namespace SiMay.RemoteControlsCore set { SysConfig.SetConfig("ServiceIPAddress", value); } } - public static string ServicePort + public static int ServicePort + { + get { return int.Parse(SysConfig.GetConfig("ServicePort")); } + set { SysConfig.SetConfig("ServicePort", value.ToString()); } + } + + public static bool CarouselEnabled + { + get { return bool.Parse(SysConfig.GetConfig("EnabledCarousel")); } + set { SysConfig.SetConfig("EnabledCarousel", value.ToString()); } + } + + public static int CarouselInterval + { + get { return int.Parse(SysConfig.GetConfig("CarouselInterval")); } + set { SysConfig.SetConfig("CarouselInterval", value.ToString()); } + } + + public static int ViewColumn + { + get { return int.Parse(SysConfig.GetConfig("ViewColumn")); } + set { SysConfig.SetConfig("ViewColumn", value.ToString()); } + } + + public static int ViewRow + { + get { return int.Parse(SysConfig.GetConfig("ViewRow")); } + set { SysConfig.SetConfig("ViewRow", value.ToString()); } + } + + /// + /// 临时Id + /// + public static long UseAccessId { get; set; } + + public static long AccessId + { + get { return long.Parse(SysConfig.GetConfig("AccessId")); } + set { SysConfig.SetConfig("AccessId", value.ToString()); } + } + + public static long MainAppAccessKey + { + get { return long.Parse(SysConfig.GetConfig("MainAppAccessKey")); } + set { SysConfig.SetConfig("MainAppAccessKey", value.ToString()); } + } + + public static bool EnabledAnonyMous { - get { return SysConfig.GetConfig("ServicePort"); } - set { SysConfig.SetConfig("ServicePort", value); } + get { return bool.Parse(SysConfig.GetConfig("EnabledAnonyMous")); } + set { SysConfig.SetConfig("EnabledAnonyMous", value.ToString()); } } } } \ No newline at end of file diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/AudioAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/AudioAdapterHandler.cs similarity index 62% rename from SiMay.RemoteControlsCore/HandlerAdapters/AudioAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/AudioAdapterHandler.cs index 5b5bff321a5ffd6aa43fecc71580ae0789583eb5..2af9960b42bd8b820a5f391cd16b5fd5d726a221 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/AudioAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/AudioAdapterHandler.cs @@ -7,38 +7,39 @@ using SiMay.Core; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class AudioAdapterHandler : AdapterHandlerBase + public class AudioAdapterHandler : ApplicationAdapterHandler { public event Action OnOpenDeviceStatusEventHandler; public event Action OnPlayerEventHandler; [PacketHandler(MessageHead.C_AUDIO_DEVICE_OPENSTATE)] - private void RemoteDeveiceStatusHandler(SessionHandler session) + private void RemoteDeveiceStatusHandler(SessionProviderContext session) { - var statesPack = session.CompletedBuffer.GetMessageEntity(); + var statesPack = GetMessageEntity(session); this.OnOpenDeviceStatusEventHandler?.Invoke(this, statesPack.PlayerEnable, statesPack.RecordEnable); } [PacketHandler(MessageHead.C_AUDIO_DATA)] - private void PlayerData(SessionHandler session) + private void PlayerData(SessionProviderContext session) { - var payload = session.CompletedBuffer.GetMessagePayload(); + var payload = GetMessage(session); this.OnPlayerEventHandler?.Invoke(this, payload); } public void StartRemoteAudio(int samplesPerSecond, int bitsPerSample, int channels) { - SendAsyncMessage(MessageHead.S_AUDIO_START, new AudioOptionsPack() - { - SamplesPerSecond = samplesPerSecond, - BitsPerSample = bitsPerSample, - Channels = channels - }); + SendTo(CurrentSession, MessageHead.S_AUDIO_START, + new AudioOptionsPack() + { + SamplesPerSecond = samplesPerSecond, + BitsPerSample = bitsPerSample, + Channels = channels + }); } /// @@ -47,7 +48,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void SendVoiceDataToRemote(byte[] payload) { - SendAsyncMessage(MessageHead.S_AUDIO_DATA, payload); + SendTo(CurrentSession, MessageHead.S_AUDIO_DATA, payload); } @@ -57,7 +58,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void SetRemotePlayerStreamEnabled(bool enabled) { - SendAsyncMessage(MessageHead.S_AUDIO_DEIVCE_ONOFF, enabled ? "1" : "0"); + SendTo(CurrentSession, MessageHead.S_AUDIO_DEIVCE_ONOFF, enabled ? "1" : "0"); } } } diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/FileCommon/AwaitAutoResetEvent.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/FileCommon/AwaitAutoResetEvent.cs similarity index 98% rename from SiMay.RemoteControlsCore/HandlerAdapters/FileCommon/AwaitAutoResetEvent.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/FileCommon/AwaitAutoResetEvent.cs index 186d78a2f63f40faaaa7235de31fac0eb0c1a54a..c83e1121bc767dc6f11b7b6cba01223ae2c8a658 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/FileCommon/AwaitAutoResetEvent.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/FileCommon/AwaitAutoResetEvent.cs @@ -48,7 +48,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters { LogHelper.DebugWriteLog(frame.GetMethod().Name + " AwaitOneData ----wait version:" + _version); _event.Reset(); - _event.WaitOne(1000); + _event.WaitOne(); LogHelper.DebugWriteLog(frame.GetMethod().Name + " AwaitOneData ----wait finish version:" + _version); } return this._buffer; diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/KeyboardAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/KeyboardAdapterHandler.cs similarity index 61% rename from SiMay.RemoteControlsCore/HandlerAdapters/KeyboardAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/KeyboardAdapterHandler.cs index 1001c8f4e6ec042634863714898c3316c617a61d..12e6ec6ed3c6ff009c4e2f9591b18e27acabe279 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/KeyboardAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/KeyboardAdapterHandler.cs @@ -7,43 +7,43 @@ using SiMay.Core; using SiMay.Core.Extensions; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class KeyboardAdapterHandler : AdapterHandlerBase + public class KeyboardAdapterHandler : ApplicationAdapterHandler { public event Action OnKeyboardDataEventHandler; public event Action OnOffLineKeyboradEventHandler; [PacketHandler(MessageHead.C_KEYBOARD_DATA)] - private void KeyBoardDataHandler(SessionHandler session) + private void KeyBoardDataHandler(SessionProviderContext session) { - var text = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + var text = GetMessage(session).ToUnicodeString(); this.OnKeyboardDataEventHandler?.Invoke(this, text); } [PacketHandler(MessageHead.C_KEYBOARD_OFFLINEFILE)] - private void OffLinesDataHandler(SessionHandler session) + private void OffLinesDataHandler(SessionProviderContext session) { - var text = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + var text = GetMessage(session).ToUnicodeString(); this.OnOffLineKeyboradEventHandler?.Invoke(this, text); } public void StartGetKeyorad() { - SendAsyncMessage(MessageHead.S_KEYBOARD_ONOPEN); + SendTo(CurrentSession, MessageHead.S_KEYBOARD_ONOPEN); } public void StartOffLineKeyboard() { - SendAsyncMessage(MessageHead.S_KEYBOARD_OFFLINE); + SendTo(CurrentSession, MessageHead.S_KEYBOARD_OFFLINE); } public void GetOffLineKeyboardData() { - SendAsyncMessage(MessageHead.S_KEYBOARD_GET_OFFLINEFILE); + SendTo(CurrentSession, MessageHead.S_KEYBOARD_GET_OFFLINEFILE); } } } diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/RegistryEditorAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RegistryEditorAdapterHandler.cs similarity index 81% rename from SiMay.RemoteControlsCore/HandlerAdapters/RegistryEditorAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RegistryEditorAdapterHandler.cs index a3f2fc37c3c324d83be3ed86996540f44a223358..0b9f259d0998f97ddab43a4f80c166c88bfd6f51 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/RegistryEditorAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RegistryEditorAdapterHandler.cs @@ -3,11 +3,11 @@ using SiMay.Core; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets.RegEdit; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class RegistryEditorAdapterHandler : AdapterHandlerBase + public class RegistryEditorAdapterHandler : ApplicationAdapterHandler { public delegate void KeysReceivedEventHandler(RegistryEditorAdapterHandler adapterHandler, string rootKey, RegSeekerMatch[] matches); public delegate void KeyCreatedEventHandler(RegistryEditorAdapterHandler adapterHandler, string parentPath, RegSeekerMatch match); @@ -28,67 +28,67 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public event ValueChangedEventHandler OnValueChangedEventHandler; [PacketHandler(MessageHead.C_NREG_LOAD_REGKEYS)] - private void AddKeyedHandler(SessionHandler session) + private void AddKeyedHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnKeysReceivedEventHandler; handler?.Invoke(this, pack.RootKey, pack.Matches); } [PacketHandler(MessageHead.C_NREG_CREATE_KEY_RESPONSE)] - private void CreateNewKeyedHandler(SessionHandler session) + private void CreateNewKeyedHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnKeyCreatedEventHandler; handler?.Invoke(this, pack.ParentPath, pack.Match); } [PacketHandler(MessageHead.C_NREG_DELETE_KEY_RESPONSE)] - private void DeleteKeyedHandler(SessionHandler session) + private void DeleteKeyedHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnKeyDeletedEventHandler; handler?.Invoke(this, pack.ParentPath, pack.KeyName); } [PacketHandler(MessageHead.C_NREG_RENAME_KEY_RESPONSE)] - private void RenameKeyedHandler(SessionHandler session) + private void RenameKeyedHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnKeyRenamedEventHandler; handler?.Invoke(this, pack.ParentPath, pack.OldKeyName, pack.NewKeyName); } [PacketHandler(MessageHead.C_NREG_CREATE_VALUE_RESPONSE)] - private void CreateValueHandler(SessionHandler session) + private void CreateValueHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnValueCreatedEventHandler; handler?.Invoke(this, pack.KeyPath, pack.Value); } [PacketHandler(MessageHead.C_NREG_DELETE_VALUE_RESPONSE)] - private void DeleteValueHandler(SessionHandler session) + private void DeleteValueHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnValueDeletedEventHandler; handler?.Invoke(this, pack.KeyPath, pack.ValueName); } [PacketHandler(MessageHead.C_NREG_RENAME_VALUE_RESPONSE)] - private void RenameValueHandler(SessionHandler session) + private void RenameValueHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnValueRenamedEventHandler; handler?.Invoke(this, pack.KeyPath, pack.OldValueName, pack.NewValueName); } [PacketHandler(MessageHead.C_NREG_CHANGE_VALUE_RESPONSE)] - private void ChangeValueHandler(SessionHandler session) + private void ChangeValueHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); var handler = OnValueChangedEventHandler; handler?.Invoke(this, pack.KeyPath, pack.Value); } @@ -99,7 +99,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The root key name. public void LoadRegistryKey(string rootKeyName) { - SendAsyncMessage(MessageHead.S_NREG_LOAD_REGKEYS, + SendTo(CurrentSession, MessageHead.S_NREG_LOAD_REGKEYS, new DoLoadRegistryKeyPack() { RootKeyName = rootKeyName @@ -112,7 +112,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The parent path. public void CreateRegistryKey(string parentPath) { - SendAsyncMessage(MessageHead.S_NREG_CREATE_KEY, + SendTo(CurrentSession, MessageHead.S_NREG_CREATE_KEY, new DoCreateRegistryKeyPack() { ParentPath = parentPath @@ -126,7 +126,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The registry key name to delete. public void DeleteRegistryKey(string parentPath, string keyName) { - SendAsyncMessage(MessageHead.S_NREG_DELETE_KEY, + SendTo(CurrentSession, MessageHead.S_NREG_DELETE_KEY, new DoDeleteRegistryKeyPack() { ParentPath = parentPath, @@ -142,7 +142,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The new name of the registry key. public void RenameRegistryKey(string parentPath, string oldKeyName, string newKeyName) { - SendAsyncMessage(MessageHead.S_NREG_RENAME_KEY, + SendTo(CurrentSession, MessageHead.S_NREG_RENAME_KEY, new DoRenameRegistryKeyPack() { ParentPath = parentPath, @@ -158,7 +158,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The kind of registry key value. public void CreateRegistryValue(string keyPath, RegistryValueKind kind) { - SendAsyncMessage(MessageHead.S_NREG_CREATE_VALUE, + SendTo(CurrentSession, MessageHead.S_NREG_CREATE_VALUE, new DoCreateRegistryValuePack() { KeyPath = keyPath, @@ -173,7 +173,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The registry key value name to delete. public void DeleteRegistryValue(string keyPath, string valueName) { - SendAsyncMessage(MessageHead.S_NREG_DELETE_VALUE, + SendTo(CurrentSession, MessageHead.S_NREG_DELETE_VALUE, new DoDeleteRegistryValuePack() { KeyPath = keyPath, @@ -189,7 +189,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The new registry key value name. public void RenameRegistryValue(string keyPath, string oldValueName, string newValueName) { - SendAsyncMessage(MessageHead.S_NREG_RENAME_VALUE, + SendTo(CurrentSession, MessageHead.S_NREG_RENAME_VALUE, new DoRenameRegistryValuePack() { KeyPath = keyPath, @@ -205,7 +205,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// The updated registry key value. public void ChangeRegistryValue(string keyPath, RegValueData value) { - SendAsyncMessage(MessageHead.S_NREG_CHANGE_VALUE, + SendTo(CurrentSession, MessageHead.S_NREG_CHANGE_VALUE, new DoChangeRegistryValuePack() { KeyPath = keyPath, diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/RemoteFileAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteFileAdapterHandler.cs similarity index 82% rename from SiMay.RemoteControlsCore/HandlerAdapters/RemoteFileAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteFileAdapterHandler.cs index 011872dd1f8aad98588009498b18a3178cbd273d..611cdaaaf22dadc1645b2e07d0c7f88e8185a1df 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/RemoteFileAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteFileAdapterHandler.cs @@ -8,15 +8,14 @@ using System.Threading.Tasks; using SiMay.Basic; using SiMay.Core; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.Core.Packets.FileManager; -using SiMay.Net.SessionProvider.SessionBased; -using SiMay.RemoteControlsCore.Interface; +using SiMay.Net.SessionProvider; +using SiMay.Serialize.Standard; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class RemoteFileAdapterHandler : AdapterHandlerBase + public class RemoteFileAdapterHandler : ApplicationAdapterHandler { /// /// 文件列表项 @@ -84,7 +83,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void GetRemoteDriveItems() { - SendAsyncMessage(MessageHead.S_FILE_GET_DRIVES); + SendTo(CurrentSession, MessageHead.S_FILE_GET_DRIVES); } /// @@ -93,7 +92,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void GetRemoteFiles(string path) { - SendAsyncMessage(MessageHead.S_FILE_GET_FILES, + SendTo(CurrentSession, MessageHead.S_FILE_GET_FILES, new FileListPack() { FilePath = path @@ -106,10 +105,11 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void GetRemoteSystemFoldFiles(Environment.SpecialFolder specialFolder) { - SendAsyncMessage(MessageHead.S_FILE_REDIRION, new FileRedirectionPath() - { - SpecialFolder = specialFolder - }); + SendTo(CurrentSession, MessageHead.S_FILE_REDIRION, + new FileRedirectionPath() + { + SpecialFolder = specialFolder + }); } /// @@ -117,9 +117,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_FILE_LIST)] - private void FixedRemoteFileItems(SessionHandler session) + private void FixedRemoteFileItems(SessionProviderContext session) { - var fileItems = session.CompletedBuffer.GetMessageEntity(); + var fileItems = GetMessageEntity(session); this.OnFileItemsEventHandler?.Invoke(this, fileItems.FileList, fileItems.Path, fileItems.IsSccessed, fileItems.Message); } @@ -128,9 +128,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_ERROR_INFO)] - private void WriteExceptionLog(SessionHandler session) + private void WriteExceptionLog(SessionProviderContext session) { - var log = session.CompletedBuffer.GetMessageEntity(); + var log = GetMessageEntity(session); this.OnRemoteExceptionEventHandler?.Invoke(this, log.OccurredTime, log.TipMessage, log.ExceptionMessage, log.StackTrace); } @@ -141,7 +141,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void RemoteFilePaster(string root, string[] files) { - SendAsyncMessage(MessageHead.S_FILE_FILE_PASTER, + SendTo(CurrentSession, MessageHead.S_FILE_FILE_PASTER, new FileCopyPack() { TargetDirectoryPath = root, @@ -154,9 +154,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_COPY_FINISH)] - private void RefreshDirectory(SessionHandler session) + private void RefreshDirectory(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); this.OnPasterFinishEventHandler?.Invoke(this, pack.ExceptionFileNames); } @@ -166,7 +166,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void RemoteOpenText(string path) { - SendAsyncMessage(MessageHead.S_FILE_OPEN_TEXT, + SendTo(CurrentSession, MessageHead.S_FILE_OPEN_TEXT, new FileOpenTextPack() { FileName = path @@ -178,9 +178,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_TEXT)] - private void OpenRemoteText(SessionHandler session) + private void OpenRemoteText(SessionProviderContext session) { - var text = session.CompletedBuffer.GetMessageEntity(); + var text = GetMessageEntity(session); this.OnOpenTextEventHandler?.Invoke(this, text.Text, text.IsSuccess); } @@ -190,8 +190,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void RemoteDeleteFiles(string[] files) { - SendAsyncMessage( - MessageHead.S_FILE_DELETE, + SendTo(CurrentSession, MessageHead.S_FILE_DELETE, new FileDeletePack() { FileNames = files @@ -203,9 +202,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_DELETE_FINISH)] - private void DeleteFinishHandler(SessionHandler session) + private void DeleteFinishHandler(SessionProviderContext session) { - var files = session.CompletedBuffer.GetMessageEntity(); + var files = GetMessageEntity(session); this.OnFileDeteledFinishEventHandler?.Invoke(this, files.DeleteFileNames); } @@ -216,7 +215,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// false = 回调 public void RemoteCreateDirectory(string path, bool noCallback = false) { - SendAsyncMessage(MessageHead.S_FILE_CREATE_DIR, + SendTo(CurrentSession, MessageHead.S_FILE_CREATE_DIR, new FileCreateDirectoryPack() { DirectoryName = path, @@ -229,9 +228,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_CREATEF_DIR_FNISH)] - private void DirectoryCreateFinishHandler(SessionHandler session) + private void DirectoryCreateFinishHandler(SessionProviderContext session) { - var response = session.CompletedBuffer.GetMessageEntity(); + var response = GetMessageEntity(session); this.OnDirectoryCreateFinishEventHandler?.Invoke(this, response.IsSuccess); } @@ -242,7 +241,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void RemoteFileRename(string srcFileName, string targetFileName) { - SendAsyncMessage(MessageHead.S_FILE_RENAME, + SendTo(CurrentSession, MessageHead.S_FILE_RENAME, new FileReNamePack() { SourceFileName = srcFileName, @@ -255,9 +254,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_RENAME_FINISH)] - private void ReNameFinishHandler(SessionHandler session) + private void ReNameFinishHandler(SessionProviderContext session) { - var file = session.CompletedBuffer.GetMessageEntity(); + var file = GetMessageEntity(session); this.OnFileNameRenameFinishEventHandler?.Invoke(this, file.SourceFileName, file.TargetName, file.IsSuccess); } @@ -267,7 +266,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void GetRemoteRootTreeItems(string path) { - SendAsyncMessage(MessageHead.S_FILE_TREE_DIR, + SendTo(CurrentSession, MessageHead.S_FILE_TREE_DIR, new FileGetTreeDirectoryPack() { TargetRoot = path @@ -279,9 +278,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// /// [PacketHandler(MessageHead.C_FILE_TREE_DIRS)] - private void TreeFilesHandler(SessionHandler session) + private void TreeFilesHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); this.OnFileTreeItemsEventHandler?.Invoke(this, pack.FileList); } @@ -291,7 +290,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void RemoteExecuteFile(string path) { - SendAsyncMessage(MessageHead.S_FILE_EXECUTE, + SendTo(CurrentSession, MessageHead.S_FILE_EXECUTE, new FileExcutePack() { FilePath = path @@ -315,7 +314,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters var status = 0; //返回null表示已断开连接 - if (responsed == null) + if (responsed.IsNull()) { var positionNull = await this.AwaitResetDownloadFile(fileStream);//等待重新连接 if (positionNull.HasValue) @@ -347,9 +346,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters var data = await this.AwaitDownloadDataPack().ConfigureAwait(true); //LogHelper.DebugWriteLog("download data:" + (data == null ? "null" : data.Data.Length.ToString())); - if (this.IsClose) + if (this.WhetherClose) break;//传输中途关闭应用 - if (data == null) + if (data.IsNull()) { var positionNull = await this.AwaitResetDownloadFile(fileStream).ConfigureAwait(true); if (!positionNull.HasValue) @@ -373,7 +372,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters return await Task.Run(() => { _sessionOfLinesEvent.WaitOne();//等待重连 - if (this.IsClose) + if (this.WhetherClose) return null; long? position = fileStream.Length; @@ -381,16 +380,17 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters }); } [PacketHandler(MessageHead.C_FILE_FRIST_DATA)] - private void SetOpenEvent(SessionHandler session) + private void SetOpenEvent(SessionProviderContext session) { - LogHelper.DebugWriteLog("C_FILE_FRIST_DATA SetOpenEvent head:" + string.Join(",", session.CompletedBuffer.Take(2).Select(c => c.ToString()).ToArray()) /*+ " fileName:" + session.CompletedBuffer.GetMessageEntity().fileName*/); - _workerStreamEvent.SetOneData(session.CompletedBuffer); + //LogHelper.DebugWriteLog("C_FILE_FRIST_DATA SetOpenEvent head:" + string.Join(",", session.CompletedBuffer.Take(2).Select(c => c.ToString()).ToArray()) /*+ " fileName:" + session.CompletedBuffer.GetMessageEntity().fileName*/); + var data = GetMessage(session); + _workerStreamEvent.SetOneData(data); } private async Task AwaitOpenDownloadData(string remoteFileName, long position) { return await Task.Run(() => { - SendAsyncMessage(MessageHead.S_FILE_DOWNLOAD, + SendTo(CurrentSession, MessageHead.S_FILE_DOWNLOAD, new FileDownloadPack() { FileName = remoteFileName, @@ -402,8 +402,8 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters var data = _workerStreamEvent.AwaitOneData(); if (data.IsNullOrEmpty()) return null; - LogHelper.DebugWriteLog("AwaitFristDownloadData head:" + string.Join(",", data.Take(2).Select(c => c.ToString()).ToArray()) + " buffer lenght:" + data.Length); - return data.GetMessageEntity(); + //LogHelper.DebugWriteLog("AwaitFristDownloadData head:" + string.Join(",", data.Take(2).Select(c => c.ToString()).ToArray()) + " buffer lenght:" + data.Length); + return PacketSerializeHelper.DeserializePacket(data); } else return null; @@ -411,24 +411,25 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters } [PacketHandler(MessageHead.C_FILE_DATA)] - private void SetDataOneEvent(SessionHandler session) + private void SetDataOneEvent(SessionProviderContext session) { - LogHelper.DebugWriteLog("SetDataOneEvent head:" + string.Join(",", session.CompletedBuffer.Take(2).Select(c => c.ToString()).ToArray())); - _workerStreamEvent.SetOneData(session.CompletedBuffer); + //LogHelper.DebugWriteLog("SetDataOneEvent head:" + string.Join(",", session.CompletedBuffer.Take(2).Select(c => c.ToString()).ToArray())); + var data = GetMessage(session); + _workerStreamEvent.SetOneData(); } private async Task AwaitDownloadDataPack() { return await Task.Run(() => { - SendAsyncMessage(MessageHead.S_FILE_NEXT_DATA); + SendTo(CurrentSession, MessageHead.S_FILE_NEXT_DATA); if (_isWorkSessionOfLines) { var data = _workerStreamEvent.AwaitOneData(); if (data.IsNullOrEmpty()) return null; - LogHelper.DebugWriteLog("AwaitDataPack head:" + string.Join(",", data.Take(2).Select(c => c.ToString()).ToArray()) + " buffer lenght:" + data.Length); - return data.GetMessageEntity(); + //LogHelper.DebugWriteLog("AwaitDataPack head:" + string.Join(",", data.Take(2).Select(c => c.ToString()).ToArray()) + " buffer lenght:" + data.Length); + return PacketSerializeHelper.DeserializePacket(data); } else return null; @@ -437,7 +438,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters private void RemoteTaskStop() { - SendAsyncMessage(MessageHead.S_FILE_STOP);//停止任务,通知远程关闭文件 + SendTo(CurrentSession, MessageHead.S_FILE_STOP);//停止任务,通知远程关闭文件 } /// @@ -464,7 +465,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters LogHelper.DebugWriteLog("begin upload"); var responsed = await this.AwaitOpenUploadFileStatus(remoteFileName);//获取远程文件状态 - if (responsed == null)//返回null表示等待结果期间连接中断 + if (responsed.IsNull())//返回null表示等待结果期间连接中断 { var isReset = await this.AwaitResetUploadFile(); if (isReset) @@ -528,7 +529,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters var data = await Task.Run(() => this.ReadFileStream(fileStream)); - SendAsyncMessage(MessageHead.S_FILE_FRIST_DATA,//上传首数据块,带文件选项及长度 + SendTo(CurrentSession, MessageHead.S_FILE_FRIST_DATA,//上传首数据块,带文件选项及长度 new FileFristUploadDataPack() { FileMode = fileMode, @@ -569,7 +570,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters data = await Task.Run(() => this.ReadFileStream(fileStream)); //底层通信库在正式发送数据包前会进行组包丶压缩等操作,由于文件数据块大,所处理耗时较长,此处使用线程以防止ui发生卡顿 - await Task.Run(() => SendAsyncMessage(MessageHead.S_FILE_DATA, + await Task.Run(() => SendTo(CurrentSession, MessageHead.S_FILE_DATA, new FileUploadDataPack() { FileSize = fileStream.Length, @@ -591,7 +592,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters } [PacketHandler(MessageHead.C_FILE_NEXT_DATA)] - private void GetNextDataHandler(SessionHandler session) + private void GetNextDataHandler(SessionProviderContext session) => _workerStreamEvent.SetOneData(); private async Task AwaitGetNextFileData() @@ -620,16 +621,16 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters } [PacketHandler(MessageHead.C_FILE_OPEN_STATUS)] - private void SetUploadFileStatus(SessionHandler session) + private void SetUploadFileStatus(SessionProviderContext session) { - LogHelper.DebugWriteLog("SetUploadFileStatus head:" + string.Join(",", session.CompletedBuffer.Take(2).Select(c => c.ToString()).ToArray())); - _workerStreamEvent.SetOneData(session.CompletedBuffer); + //LogHelper.DebugWriteLog("SetUploadFileStatus head:" + string.Join(",", session.CompletedBuffer.Take(2).Select(c => c.ToString()).ToArray())); + _workerStreamEvent.SetOneData(GetMessage(session)); } private async Task AwaitOpenUploadFileStatus(string remoteFileName) { return await Task.Run(() => { - SendAsyncMessage(MessageHead.S_FILE_UPLOAD, + SendTo(CurrentSession, MessageHead.S_FILE_UPLOAD, new FileUploadPack() { FileName = remoteFileName @@ -640,8 +641,8 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters var data = _workerStreamEvent.AwaitOneData(); if (data.IsNullOrEmpty()) return null; - LogHelper.DebugWriteLog("AwaitUploadFileStatus head:" + string.Join(",", data.Take(2).Select(c => c.ToString()).ToArray())); - return data.GetMessageEntity(); + //LogHelper.DebugWriteLog("AwaitUploadFileStatus head:" + string.Join(",", data.Take(2).Select(c => c.ToString()).ToArray())); + return PacketSerializeHelper.DeserializePacket(data); } else return null; @@ -653,7 +654,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters return await Task.Run(() => { _sessionOfLinesEvent.WaitOne();//等待重连 - if (this.IsClose) + if (this.WhetherClose) return false; else return true; @@ -692,7 +693,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters var targetFileName = file.FileName; var localFileName = file.FileName.Substring(remotedirectory.LastIndexOf("\\") + 1); var fileStream = onCreateFileStream?.Invoke(localFileName); - if (fileStream == null) + if (fileStream.IsNull()) continue; if (_transferMode == TransferMode.Cancel || TransferTaskFlage == TransferTaskFlage.Abort) break; @@ -708,9 +709,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters this._filesQueue.Clear(); } [PacketHandler(MessageHead.C_FILE_DIR_FILES)] - private void SetFilesTriggerEvent(SessionHandler session) + private void SetFilesTriggerEvent(SessionProviderContext session) { - foreach (var file in session.CompletedBuffer.GetMessageEntity().Files) + foreach (var file in GetMessageEntity(session).Files) _filesQueue.Enqueue(file); _filesTriggerEvent.Set(); } @@ -719,7 +720,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters { return await Task.Run(() => { - SendAsyncMessage(MessageHead.S_FILE_GETDIR_FILES, + SendTo(CurrentSession, MessageHead.S_FILE_GETDIR_FILES, new FileDirectoryGetFilesPack() { DirectoryPath = remotedirectory @@ -739,27 +740,27 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters return await Task.Run(() => { _sessionOfLinesEvent.WaitOne();//等待重连 - if (this.IsClose) + if (this.WhetherClose) return false; else return true; }); } - internal override void SessionClosed(SessionHandler session) + public override void SessionClosed(SessionProviderContext session) { this._isWorkSessionOfLines = false; this._filesTriggerEvent.Set();//释放 this._sessionOfLinesEvent.Reset();//阻塞等待重连 this._workerStreamEvent.SetOneData();//如果有正在等待数据响应的,则先释放信号,进入重置方法 LogHelper.DebugWriteLog("close eventSet"); - if (this.IsClose)//如果窗口已关闭,则释放退出 + if (this.WhetherClose)//如果应用已关闭,则释放退出 this._sessionOfLinesEvent.Set(); base.SessionClosed(session); } - internal override void ContinueTask(SessionHandler session) + public override void ContinueTask(SessionProviderContext session) { this._workerStreamEvent.Reset(); this._isWorkSessionOfLines = true; diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/RemoteScreenAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteScreenAdapterHandler.cs similarity index 69% rename from SiMay.RemoteControlsCore/HandlerAdapters/RemoteScreenAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteScreenAdapterHandler.cs index 018fc7798b457f54f9533490a4c760df44ad01d8..3cffe3f4cfdd78843b01b68b46d1c55707ea922a 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/RemoteScreenAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteScreenAdapterHandler.cs @@ -12,13 +12,13 @@ using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.Core.Packets.Screen; using SiMay.Core.ScreenSpy.Entitys; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; using SiMay.RemoteControlsCore.Enum; -using static SiMay.Serialize.PacketSerializeHelper; +using static SiMay.Serialize.Standard.PacketSerializeHelper; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class RemoteScreenAdapterHandler : AdapterHandlerBase + public class RemoteScreenAdapterHandler : ApplicationAdapterHandler { /// @@ -36,12 +36,17 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public event Action OnScreenFragmentEventHandler; + //public RemoteScreenAdapterHandler() + //{ + // CurrentSession.Socket.NoDelay = false; + //} + //已接收帧数 private int _frameCount = 0; public void RemoteMouseKeyEvent(MOUSEKEY_ENUM @event, int point1, int point2) { - SendAsyncMessage(MessageHead.S_SCREEN_MOUSEKEYEVENT, - new ScreenMKeyPack() + SendTo(CurrentSession, MessageHead.S_SCREEN_MOUSEKEYEVENT, + new ScreenKeyPack() { Key = @event, Point1 = point1, @@ -50,28 +55,27 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters } [PacketHandler(MessageHead.C_SCREEN_BITINFO)] - private void SetBitmapHandler(SessionHandler session) + private void SetBitmapHandler(SessionProviderContext session) { - var bitinfo = session.CompletedBuffer.GetMessageEntity(); + var bitinfo = GetMessageEntity(session); this.OnServcieInitEventHandler?.Invoke(this, bitinfo.Height, bitinfo.Width, bitinfo.PrimaryScreenIndex, bitinfo.Monitors); } [PacketHandler(MessageHead.C_SCREEN_DIFFBITMAP)] - private void FullFragmentHandler(SessionHandler session) + private void FullFragmentHandler(SessionProviderContext session) { - var fragments = session.CompletedBuffer.GetMessageEntity(); + var fragments = GetMessageEntity(session); this.OnScreenFragmentEventHandler?.Invoke(this, fragments.Fragments, ScreenReceivedType.Noninterlaced); } [PacketHandler(MessageHead.C_SCREEN_BITMP)] - private void SigleFragmentHandler(SessionHandler session) + private void SigleFragmentHandler(SessionProviderContext session) { - int dataSize = session.CompletedBuffer.Length; - var fragments = session.CompletedBuffer.GetMessageEntity(); + var fragments = GetMessageEntity(session); this.OnScreenFragmentEventHandler?.Invoke(this, fragments.Fragments, ScreenReceivedType.Difference); } [PacketHandler(MessageHead.C_SCREEN_SCANCOMPLETE)] - private void ScanFinishHandler(SessionHandler session) + private void ScanFinishHandler(SessionProviderContext session) { this.OnScreenFragmentEventHandler?.Invoke(this, new Fragment[0], ScreenReceivedType.DifferenceEnd); } @@ -90,12 +94,12 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters _frameCount = 0; //第一帧不计入连续帧 for (int i = 0; i < 3; i++) - SendAsyncMessage(MessageHead.S_SCREEN_NEXT_SCREENBITMP, rect); + SendTo(CurrentSession, MessageHead.S_SCREEN_NEXT_SCREENBITMP, rect); } public void GetNextScreen(int height, int width, int x, int y, ScreenDisplayMode mode) { - if (this.IsClose) + if (this.WhetherClose) return; _frameCount++; @@ -112,7 +116,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters CtrlMode = mode.ConvertTo() }); for (int i = 0; i < 3; i++) - SendAsyncMessage(MessageHead.S_SCREEN_NEXT_SCREENBITMP, rect); + SendTo(CurrentSession, MessageHead.S_SCREEN_NEXT_SCREENBITMP, rect); } else if (_frameCount == 3) _frameCount = 0; @@ -120,7 +124,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public void MonitorChange(int screenIndex) { - SendAsyncMessage(MessageHead.S_SCREEN_CHANGE_MONITOR, + SendTo(CurrentSession, MessageHead.S_SCREEN_CHANGE_MONITOR, new MonitorChangePack() { MonitorIndex = screenIndex @@ -129,36 +133,36 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public void GetInitializeBitInfo() { - SendAsyncMessage(MessageHead.S_SCREEN_GET_INIT_BITINFO); + SendTo(CurrentSession, MessageHead.S_SCREEN_GET_INIT_BITINFO); } public void RemoteDeleteWallPaper() { - SendAsyncMessage(MessageHead.S_SCREEN_DELETE_WALLPAPER); + SendTo(CurrentSession, MessageHead.S_SCREEN_DELETE_WALLPAPER); } public void RemoteMouseBlock(bool islock) { byte @lock = islock ? (byte)10 : (byte)11; - SendAsyncMessage(MessageHead.S_SCREEN_MOUSEBLOCK, new byte[] { @lock }); + SendTo(CurrentSession, MessageHead.S_SCREEN_MOUSEBLOCK, new byte[] { @lock }); } public void RemoteScreenBlack() { - SendAsyncMessage(MessageHead.S_SCREEN_BLACKSCREEN); + SendTo(CurrentSession, MessageHead.S_SCREEN_BLACKSCREEN); } public void RemoteChangeScanMode(ScreenScanMode scanMode) { - SendAsyncMessage(MessageHead.S_SCREEN_CHANGESCANMODE, new byte[] { (byte)scanMode }); + SendTo(CurrentSession, MessageHead.S_SCREEN_CHANGESCANMODE, new byte[] { (byte)scanMode }); } public void RemoteResetBrandColor(BrandColorMode mode) { - SendAsyncMessage(MessageHead.S_SCREEN_RESET, new byte[] { (byte)mode }); + SendTo(CurrentSession, MessageHead.S_SCREEN_RESET, new byte[] { (byte)mode }); } public void RemoteSetScreenQuantity(long qty) { - SendAsyncMessage(MessageHead.S_SCREEN_SETQTY, + SendTo(CurrentSession, MessageHead.S_SCREEN_SETQTY, new ScreenSetQtyPack() { Quality = qty @@ -167,7 +171,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public void SetRemoteClipoardText(string text) { - SendAsyncMessage(MessageHead.S_SCREEN_SET_CLIPBOARD_TEXT, + SendTo(CurrentSession, MessageHead.S_SCREEN_SET_CLIPBOARD_TEXT, new ScreenSetClipoardPack() { Text = text @@ -175,17 +179,17 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters } public void SendCtrlAltDel() { - SendAsyncMessage(MessageHead.S_SCREEN_CTRL_ALT_DEL); + SendTo(CurrentSession, MessageHead.S_SCREEN_CTRL_ALT_DEL); } public void GetRemoteClipoardText() { - SendAsyncMessage(MessageHead.S_SCREEN_GET_CLIPOARD_TEXT); + SendTo(CurrentSession, MessageHead.S_SCREEN_GET_CLIPOARD_TEXT); } [PacketHandler(MessageHead.C_SCREEN_CLIPOARD_TEXT)] - private void GetClipoardValueHandler(SessionHandler session) + private void GetClipoardValueHandler(SessionProviderContext session) { - var response = session.CompletedBuffer.GetMessageEntity(); + var response = GetMessageEntity(session); this.OnClipoardReceivedEventHandler?.Invoke(this, response.Value); } } diff --git a/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteUpdateAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteUpdateAdapterHandler.cs new file mode 100644 index 0000000000000000000000000000000000000000..cdd09a4ba95985c8c96b97ab014d0b17683cdeb1 --- /dev/null +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/RemoteUpdateAdapterHandler.cs @@ -0,0 +1,36 @@ +using SiMay.Core; +using SiMay.Core.PacketModelBinder.Attributes; +using SiMay.Net.SessionProvider; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SiMay.RemoteControlsCore +{ + public class RemoteUpdateAdapterHandler : ApplicationAdapterHandler + { + /// + /// 远程更新就绪 + /// + public event Action OnRemoteUpdateReadyEventHandler; + + /// + /// 获取下一个数据 + /// + public event Action OnNextDataEventHandler; + + [PacketHandler(MessageHead.C_REMOTE_UPDATE_READY)] + public void ReadyHandler(SessionProviderContext session) + => OnRemoteUpdateReadyEventHandler?.Invoke(); + + + [PacketHandler(MessageHead.C_REMOTE_UPDATE_NEXT_DATA)] + public void NextDataHandler(SessionProviderContext session) + => OnNextDataEventHandler?.Invoke(); + + public void SendFileData(byte[] data) + => SendTo(CurrentSession, MessageHead.S_REMOTE_UPDATE_DATA, data); + } +} diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/ShellAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/ShellAdapterHandler.cs similarity index 68% rename from SiMay.RemoteControlsCore/HandlerAdapters/ShellAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/ShellAdapterHandler.cs index 0ce26f87655f0f1bc794ddeb7b1a9aee5eda9bbc..d98c1a74b2014c8212dc966a0d97f5427bac510d 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/ShellAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/ShellAdapterHandler.cs @@ -7,11 +7,11 @@ using SiMay.Core; using SiMay.Core.Extensions; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class ShellAdapterHandler : AdapterHandlerBase + public class ShellAdapterHandler : ApplicationAdapterHandler { /// /// 输出命令处理事件 @@ -19,15 +19,15 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public event Action OnOutputCommandEventHandler; [PacketHandler(MessageHead.C_SHELL_RESULT)] - private void OutputCommandHandler(SessionHandler session) + private void OutputCommandHandler(SessionProviderContext session) { - string text = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + string text = GetMessage(session).ToUnicodeString(); this.OnOutputCommandEventHandler?.Invoke(this, text); } public void InputCommand(string command) { - SendAsyncMessage(MessageHead.S_SHELL_INPUT, command); + SendTo(CurrentSession, MessageHead.S_SHELL_INPUT, command); } } } diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/StartupAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/StartupAdapterHandler.cs similarity index 79% rename from SiMay.RemoteControlsCore/HandlerAdapters/StartupAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/StartupAdapterHandler.cs index 9fe2b28963e1d6ff0250492380c6839dbf63ee8c..9b525f5989f3d03f5c73d4c4dc8de83b0d9f99aa 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/StartupAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/StartupAdapterHandler.cs @@ -8,11 +8,11 @@ using SiMay.Core.Enums; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets.Startup; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class StartupAdapterHandler : AdapterHandlerBase + public class StartupAdapterHandler : ApplicationAdapterHandler { public readonly IReadOnlyList StartupGroupItems; @@ -62,33 +62,35 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters } [PacketHandler(MessageHead.C_STARTUP_LIST)] - private void HandlerStartupItems(SessionHandler session) + private void HandlerStartupItems(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); OnStartupItemHandlerEvent?.Invoke(this, pack.StartupItems); } public void GetStartup() { - SendAsyncMessage(MessageHead.S_STARTUP_GET_LIST); + SendTo(CurrentSession, MessageHead.S_STARTUP_GET_LIST); } public void AddStartupItem(string path, string name, StartupType startupType) { - SendAsyncMessage(MessageHead.S_STARTUP_ADD_ITEM, new StartupItemPack() - { - Name = name, - Path = path, - Type = startupType - }); + SendTo(CurrentSession, MessageHead.S_STARTUP_ADD_ITEM, + new StartupItemPack() + { + Name = name, + Path = path, + Type = startupType + }); } public void RemoveStartupItem(IEnumerable startupItems) { - SendAsyncMessage(MessageHead.S_STARTUP_REMOVE_ITEM, new StartupItemsPack() - { - StartupItems = startupItems.ToArray() - }); + SendTo(CurrentSession, MessageHead.S_STARTUP_REMOVE_ITEM, + new StartupItemsPack() + { + StartupItems = startupItems.ToArray() + }); } public class GroupItem { diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/SystemAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/SystemAdapterHandler.cs similarity index 67% rename from SiMay.RemoteControlsCore/HandlerAdapters/SystemAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/SystemAdapterHandler.cs index 7b340664fe2f58cd087ab6029200f47739d0d2f8..60c51fad9cd835baef51c1f21d5601feef34bad6 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/SystemAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/SystemAdapterHandler.cs @@ -8,11 +8,11 @@ using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.Core.Packets.SysManager; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class SystemAdapterHandler : AdapterHandlerBase + public class SystemAdapterHandler : ApplicationAdapterHandler { public event Action> OnProcessListHandlerEvent; @@ -23,45 +23,45 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public event Action OnOccupyHandlerEvent; [PacketHandler(MessageHead.C_SYSTEM_SYSTEMINFO)] - private void HandlerProcessList(SessionHandler session) + private void HandlerProcessList(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); OnSystemInfoHandlerEvent?.Invoke(this, pack.SystemInfos); } [PacketHandler(MessageHead.C_SYSTEM_OCCUPY_INFO)] - private void HandlerOccupy(SessionHandler session) + private void HandlerOccupy(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); OnOccupyHandlerEvent?.Invoke(this, pack.CpuUsage, pack.MemoryUsage); } [PacketHandler(MessageHead.C_SYSTEM_PROCESS_LIST)] - private void ProcessItemHandler(SessionHandler session) + private void ProcessItemHandler(SessionProviderContext session) { - var processLst = session.CompletedBuffer.GetMessageEntity().ProcessList; + var processLst = GetMessageEntity(session).ProcessList; OnProcessListHandlerEvent?.Invoke(this, processLst); } [PacketHandler(MessageHead.C_SYSTEM_SESSIONS)] - private void SessionsItemHandler(SessionHandler session) + private void SessionsItemHandler(SessionProviderContext session) { - var sessionLst = session.CompletedBuffer.GetMessageEntity().Sessions; + var sessionLst = GetMessageEntity(session).Sessions; this.OnSessionsEventHandler?.Invoke(this, sessionLst); } public void GetSystemInfoItems() { - SendAsyncMessage(MessageHead.S_SYSTEM_GET_SYSTEMINFO); + SendTo(CurrentSession, MessageHead.S_SYSTEM_GET_SYSTEMINFO); } public void GetProcessList() { - SendAsyncMessage(MessageHead.S_SYSTEM_GET_PROCESS_LIST); + SendTo(CurrentSession, MessageHead.S_SYSTEM_GET_PROCESS_LIST); } public void GetOccupy() { - SendAsyncMessage(MessageHead.S_SYSTEM_GET_OCCUPY); + SendTo(CurrentSession, MessageHead.S_SYSTEM_GET_OCCUPY); } public void SetProcessWindowMaxi(IEnumerable pids) @@ -76,12 +76,12 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public void EnumSession() { - SendAsyncMessage(MessageHead.S_SYSTEM_ENUMSESSIONS); + SendTo(CurrentSession, MessageHead.S_SYSTEM_ENUMSESSIONS); } public void CreateProcessAsUser(int sessionId) { - SendAsyncMessage(MessageHead.S_SYSTEM_CREATE_USER_PROCESS, + SendTo(CurrentSession, MessageHead.S_SYSTEM_CREATE_USER_PROCESS, new CreateProcessAsUserPack() { SessionId = sessionId @@ -90,7 +90,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public void KillProcess(IEnumerable pids) { - SendAsyncMessage(MessageHead.S_SYSTEM_KILL, + SendTo(CurrentSession, MessageHead.S_SYSTEM_KILL, new SysKillPack() { ProcessIds = pids.ToArray() @@ -99,7 +99,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters private void SetProcessWindowState(int state, IEnumerable pids) { - SendAsyncMessage(MessageHead.S_SYSTEM_MAXIMIZE, + SendTo(CurrentSession, MessageHead.S_SYSTEM_MAXIMIZE, new SysWindowMaxPack() { State = state, diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/TcpConnectionAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/TcpConnectionAdapterHandler.cs similarity index 66% rename from SiMay.RemoteControlsCore/HandlerAdapters/TcpConnectionAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/TcpConnectionAdapterHandler.cs index 0109c69f8b16461c6a884014a9a8c33dd19ace6b..e1e7e47c871addf6a5fb1cf499fffcb32312d132 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/TcpConnectionAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/TcpConnectionAdapterHandler.cs @@ -7,11 +7,11 @@ using SiMay.Core; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets.TcpConnection; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class TcpConnectionAdapterHandler : AdapterHandlerBase + public class TcpConnectionAdapterHandler : ApplicationAdapterHandler { /// /// Tcp连接信息 @@ -19,9 +19,9 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public event Action> OnTcpListHandlerEvent; [PacketHandler(MessageHead.C_TCP_LIST)] - private void TcpListHandler(SessionHandler session) + private void TcpListHandler(SessionProviderContext session) { - var pack = session.CompletedBuffer.GetMessageEntity(); + var pack = GetMessageEntity(session); this.OnTcpListHandlerEvent?.Invoke(this, pack.TcpConnections); } @@ -30,7 +30,7 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void GetTcpList() { - SendAsyncMessage(MessageHead.S_TCP_GET_LIST); + SendTo(CurrentSession, MessageHead.S_TCP_GET_LIST); } /// @@ -39,10 +39,11 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters /// public void CloseTcpList(IEnumerable killTcps) { - SendAsyncMessage(MessageHead.S_TCP_CLOSE_CHANNEL, new KillTcpConnectionPack() - { - Kills = killTcps.ToArray() - }); + SendTo(CurrentSession, MessageHead.S_TCP_CLOSE_CHANNEL, + new KillTcpConnectionPack() + { + Kills = killTcps.ToArray() + }); } } } diff --git a/SiMay.RemoteControlsCore/HandlerAdapters/VideoAppAdapterHandler.cs b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/VideoAppAdapterHandler.cs similarity index 69% rename from SiMay.RemoteControlsCore/HandlerAdapters/VideoAppAdapterHandler.cs rename to SiMay.RemoteControlsCore/ApplicationAdapterHandlers/VideoAppAdapterHandler.cs index f84f1a409af7b781137bfd297c3f7ccd5aa295c6..39089da148c700b07a0a401affb561ffe3b9bde0 100644 --- a/SiMay.RemoteControlsCore/HandlerAdapters/VideoAppAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/ApplicationAdapterHandlers/VideoAppAdapterHandler.cs @@ -9,11 +9,11 @@ using SiMay.Basic; using SiMay.Core; using SiMay.Core.PacketModelBinder.Attributes; using SiMay.Core.PacketModelBinding; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; namespace SiMay.RemoteControlsCore.HandlerAdapters { - public class VideoAppAdapterHandler : AdapterHandlerBase + public class VideoAppAdapterHandler : ApplicationAdapterHandler { /// /// 图帧处理事件 @@ -26,29 +26,29 @@ namespace SiMay.RemoteControlsCore.HandlerAdapters public event Action OnCameraNotStartupHandlerEvent; [PacketHandler(MessageHead.C_VIEDO_DATA)] - private void PlayerHandler(SessionHandler session) + private void PlayerHandler(SessionProviderContext session) { - var data = session.CompletedBuffer.GetMessagePayload(); + var data = GetMessage(session); using (MemoryStream ms = new MemoryStream(data)) OnImageFrameHandlerEvent?.Invoke(this, Image.FromStream(ms)); - SendAsyncMessage(MessageHead.S_VIEDO_GET_DATA); + SendTo(session, MessageHead.S_VIEDO_GET_DATA); } [PacketHandler(MessageHead.C_VIEDO_DEVICE_NOTEXIST)] - private void DeviceNotExistHandler(SessionHandler session) + private void DeviceNotExistHandler(SessionProviderContext session) { this.OnCameraNotStartupHandlerEvent?.Invoke(this, 0); } public void StartGetFrame() { - SendAsyncMessage(MessageHead.S_VIEDO_GET_DATA); + SendTo(CurrentSession, MessageHead.S_VIEDO_GET_DATA); } public void RemoteSetFrameQuantity(int level) { - SendAsyncMessage(MessageHead.S_VIEDO_RESET, new byte[] { level.ConvertTo() }); + SendTo(CurrentSession, MessageHead.S_VIEDO_RESET, new byte[] { (byte)level }); } } } diff --git a/SiMay.RemoteControlsCore/Attributes/Application.cs b/SiMay.RemoteControlsCore/Attributes/Application.cs index 6f394405b61f9dcca99199542848e0151844fabf..2f7c62954db65e8a6ba4edbd3642097796cd9ca3 100644 --- a/SiMay.RemoteControlsCore/Attributes/Application.cs +++ b/SiMay.RemoteControlsCore/Attributes/Application.cs @@ -12,10 +12,10 @@ namespace SiMay.RemoteControlsCore { public int Rank { get; set; } public Type AppHandlerAdapterType { get; set; } - public string AppKey { get; set; } + public string ApplicationKey { get; set; } public ApplicationAttribute(Type type, string appKey, int rank) { - AppKey = appKey; + ApplicationKey = appKey; AppHandlerAdapterType = type; Rank = rank; } diff --git a/SiMay.RemoteControlsCore/Entitys/SessionSyncContext.cs b/SiMay.RemoteControlsCore/Entitys/SessionSyncContext.cs index f8cd5e2846f1f63701aedae5ddaa2a8fe6cb72df..ef62dc419224de9f4376d1b30686154c99e6ebeb 100644 --- a/SiMay.RemoteControlsCore/Entitys/SessionSyncContext.cs +++ b/SiMay.RemoteControlsCore/Entitys/SessionSyncContext.cs @@ -1,4 +1,4 @@ -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; using System; using System.Collections.Generic; using System.Linq; @@ -8,7 +8,7 @@ namespace SiMay.RemoteControlsCore { public class SessionSyncContext { - public SessionSyncContext(SessionHandler session, IDictionary dictions) + public SessionSyncContext(SessionProviderContext session, IDictionary dictions) { Session = session; KeyDictions = dictions; @@ -25,7 +25,7 @@ namespace SiMay.RemoteControlsCore } } public string UniqueId { get; set; } = Guid.NewGuid().ToString(); - public SessionHandler Session { get; set; } + public SessionProviderContext Session { get; set; } public IDictionary KeyDictions { get; set; } } } diff --git a/SiMay.RemoteControlsCore/Entitys/SuspendTaskContext.cs b/SiMay.RemoteControlsCore/Entitys/SuspendTaskContext.cs index a05e2ed69bfbbd824d2d08ab80dfa0696188e732..4cafa755e478af20855b6ca64c79db8a6339590d 100644 --- a/SiMay.RemoteControlsCore/Entitys/SuspendTaskContext.cs +++ b/SiMay.RemoteControlsCore/Entitys/SuspendTaskContext.cs @@ -8,6 +8,6 @@ namespace SiMay.RemoteControlsCore public class SuspendTaskContext { public DateTime DisconnectTime { get; set; } - public AdapterHandlerBase AdapterHandler { get; set; } + public ApplicationAdapterHandler AdapterHandler { get; set; } } } diff --git a/SiMay.RemoteControlsCore/Extension/AppTypeExtension.cs b/SiMay.RemoteControlsCore/Extension/AppTypeExtension.cs index 95511c892d8a45ce4b2478e4f7fc240dc927048a..2a89b2c2c796e6f1c69de3d639449ec3fadb374e 100644 --- a/SiMay.RemoteControlsCore/Extension/AppTypeExtension.cs +++ b/SiMay.RemoteControlsCore/Extension/AppTypeExtension.cs @@ -13,10 +13,10 @@ namespace SiMay.RemoteControlsCore var attr = type.GetCustomAttribute(true); return attr.AppHandlerAdapterType; } - public static string GetAppKey(this Type type) + public static string GetApplicationKey(this Type type) { var attr = type.GetCustomAttribute(true); - return attr.AppKey; + return attr.ApplicationKey; } public static int GetRank(this Type type) diff --git a/SiMay.RemoteControlsCore/Helper/ServiceCOMHelper.cs b/SiMay.RemoteControlsCore/Helper/ServiceCOMHelper.cs deleted file mode 100644 index 97b3217714337454c5278161bd28c09f87025bf2..0000000000000000000000000000000000000000 --- a/SiMay.RemoteControlsCore/Helper/ServiceCOMHelper.cs +++ /dev/null @@ -1,67 +0,0 @@ -using SiMay.Core; -using SiMay.Core.Packets; -using SiMay.Net.SessionProvider.SessionBased; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace SiMay.RemoteControlsCore -{ - public static class ServiceCOMLoader - { - private static Dictionary ServiceCOMPlugins = new Dictionary(); - - static ServiceCOMLoader() - { - //string[] pluginFileNames = new string[] - //{ - // "SiMayServiceCore.dll", - // "SiMay.Core.dll", - // "SiMay.Serialize.dll", - // "SiMay.Basic.dll", - // "AForge.Video.dll", - // "AForge.Video.DirectShow.dll" - //}; - - //foreach (var fileName in pluginFileNames) - //{ - // var path = Path.Combine(Environment.CurrentDirectory, "plugins", fileName); - // if (File.Exists(path)) - // ServiceCOMPlugins.Add(fileName, File.ReadAllBytes(path)); - // else - // throw new FileNotFoundException("服务插件缺失:" + fileName); - //} - } - - /// - /// 主连接数据发送函数,使未加载服务插件的被控端加载插件,注意!!非主连接勿用 - /// - /// - /// - internal static void SendMessageDoHasCOM(this SessionHandler session, byte[] data) - { - //var syncContext = session.AppTokens[SysConstants.INDEX_WORKER] as SessionSyncContext; - //if (!syncContext.HasLoadServiceCOM) - // SendServicePlugins(session); - session.SendAsync(data); - } - - /// - /// 发送并加载插件 - /// - /// - private static void SendServicePlugins(SessionHandler session) - { - byte[] data = MessageHelper.CopyMessageHeadTo( - MessageHead.S_MAIN_PLUGIN_FILES, - new ServicePluginPack() - { - Files = ServiceCOMPlugins.Select(c => new PluginItem() { FileName = c.Key, PayLoad = c.Value }).ToArray() - }); - session.SendAsync(data); - } - } -} diff --git a/SiMay.RemoteControlsCore/Interface/IApplication.cs b/SiMay.RemoteControlsCore/Interface/IApplication.cs index 513b1c5dd4a00e4c51d58c02b47d74f93ea6685c..860162536a8b9c72671097d741afe49a7d877c8b 100644 --- a/SiMay.RemoteControlsCore/Interface/IApplication.cs +++ b/SiMay.RemoteControlsCore/Interface/IApplication.cs @@ -15,14 +15,20 @@ namespace SiMay.RemoteControlsCore /// void Start(); + /// + /// 设置参数 + /// + /// + void SetParameter(object arg); + /// /// 当会话断开时 /// - void SessionClose(AdapterHandlerBase handler); + void SessionClose(ApplicationAdapterHandler handler); /// /// 当会话恢复时 /// - void ContinueTask(AdapterHandlerBase handler); + void ContinueTask(ApplicationAdapterHandler handler); } } diff --git a/SiMay.RemoteControlsCore/Interface/IDesktopView.cs b/SiMay.RemoteControlsCore/Interface/IDesktopView.cs index 0b3a90d400a3e2f1e32e397ddfc2f5d8e9da2a21..cf19285e567230f4ac96b1cfc4a65f9ac329956b 100644 --- a/SiMay.RemoteControlsCore/Interface/IDesktopView.cs +++ b/SiMay.RemoteControlsCore/Interface/IDesktopView.cs @@ -21,6 +21,12 @@ namespace SiMay.RemoteControlsCore /// 视图标题 /// string Caption { get; set; } + + /// + /// 是否在可播放区域 + /// + bool InVisbleArea { get; set; } + /// /// 会话同步上下文 /// diff --git a/SiMay.RemoteControlsCore/Interface/IFileStream.cs b/SiMay.RemoteControlsCore/Interface/IFileStream.cs index 0c65c20e022bb5fe28656f16cdd099fc7ffdcc3c..a8695a4e0b32092e2ae87e4e19c74e6ebbcf6326 100644 --- a/SiMay.RemoteControlsCore/Interface/IFileStream.cs +++ b/SiMay.RemoteControlsCore/Interface/IFileStream.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace SiMay.RemoteControlsCore.Interface +namespace SiMay.RemoteControlsCore { /// /// 文件流接口(解耦各种实现方式) diff --git a/SiMay.RemoteControlsCore/AppMainAdapterHandler.cs b/SiMay.RemoteControlsCore/MainApplicationAdapterHandler.cs similarity index 60% rename from SiMay.RemoteControlsCore/AppMainAdapterHandler.cs rename to SiMay.RemoteControlsCore/MainApplicationAdapterHandler.cs index cb1b6d379e23c6c31b96da2176ffb7bac4f43bab..04476ce8dc1ca729400ec5baeb082ff33eb3338d 100644 --- a/SiMay.RemoteControlsCore/AppMainAdapterHandler.cs +++ b/SiMay.RemoteControlsCore/MainApplicationAdapterHandler.cs @@ -3,12 +3,11 @@ using SiMay.Core; using SiMay.Core.Enums; using SiMay.Core.Extensions; using SiMay.Core.PacketModelBinder.Attributes; -using SiMay.Core.PacketModelBinding; using SiMay.Core.Packets; using SiMay.Net.SessionProvider; -using SiMay.Net.SessionProvider.Delegate; -using SiMay.Net.SessionProvider.Notify; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider.Providers; +using SiMay.ServiceCore.Helper; +using SiMay.Sockets.Tcp; using System; using System.Collections.Generic; using System.Drawing; @@ -21,18 +20,18 @@ using System.Threading.Tasks; namespace SiMay.RemoteControlsCore { - public class AppMainAdapterHandler + public class MainApplicationAdapterHandler : MainApplicationBaseAdapterHandler { /// /// 当有数据上传时 /// - public event Action OnTransmitHandlerEvent; + public event Action OnTransmitHandlerEvent; /// /// 当正在接收数据时 /// - public event Action OnReceiveHandlerEvent; + public event Action OnReceiveHandlerEvent; /// /// 上线登陆处理事件 @@ -57,7 +56,13 @@ namespace SiMay.RemoteControlsCore /// /// 代理协议事件 /// - public event OnProxyNotify OnProxyNotifyHandlerEvent; + public event Action OnProxyNotifyHandlerEvent; + + /// + /// 当应用被创建 + /// + public event Action OnApplicationCreatedEventHandler; + /// /// 监听日志事件 @@ -68,8 +73,9 @@ namespace SiMay.RemoteControlsCore /// 视图墙刷新间隔 /// public int ViewRefreshInterval { get; set; } + /// - /// 线程同步上下文 + /// 主线程同步上下文 /// public SynchronizationContext SynchronizationContext { get; set; } @@ -79,53 +85,70 @@ namespace SiMay.RemoteControlsCore public SessionProvider SessionProvider { get; set; } /// - /// 主连接同步上下文对象集合 + /// 主连接同步上下文 /// - public List SyncContexts { get; set; } = new List(); + public List SessionSyncContexts { get; set; } = new List(); + /// - /// 离线重连池 + /// 中断任务上下文列表 /// - private ResetPool _resetPool; - private PacketModelBinder _handlerBinder = new PacketModelBinder(); + private List _suspendTaskContexts = new List(); - public void StartService() + /// + /// 是否已启动 + /// + private bool _launch; + + public void StartApp() { - this._resetPool = new ResetPool(SyncContexts); + if (_launch) + return; + + _launch = true; - if (!int.TryParse(AppConfiguration.SessionMode, out var sessionMode)) - sessionMode = 0; + ThreadHelper.CreateThread(ApplicationResetThread, true); - string ip = sessionMode == 0 - ? AppConfiguration.IPAddress - : AppConfiguration.ServiceIPAddress; + this.StartService(); + } - int port = int.Parse(sessionMode == 0 + public void StartService() + { + var providerType = int.Parse(AppConfiguration.SessionMode).ConvertTo(); + + string ip = providerType == SessionProviderType.TcpServiceSession + ? HostHelper.GetHostByName(AppConfiguration.IPAddress) + : HostHelper.GetHostByName(AppConfiguration.ServiceIPAddress); + + int port = providerType == SessionProviderType.TcpServiceSession ? AppConfiguration.Port - : AppConfiguration.ServicePort); + : AppConfiguration.ServicePort; + + AppConfiguration.UseAccessId = !AppConfiguration.EnabledAnonyMous ? AppConfiguration.AccessId : DateTime.Now.ToFileTimeUtc(); - if (!int.TryParse(AppConfiguration.MaxConnectCount, out var maxconnectCount)) - maxconnectCount = 0; + int maxConnectCount = AppConfiguration.MaxConnectCount; - var options = new SessionProviderOptions + var providerOptions = new SessionProviderOptions { ServiceIPEndPoint = new IPEndPoint(IPAddress.Parse(ip), port), - PendingConnectionBacklog = maxconnectCount, - AccessKey = long.Parse(AppConfiguration.AccessKey) + PendingConnectionBacklog = maxConnectCount, + AccessId = AppConfiguration.UseAccessId,//暂时使用UTC时间作为主控端标识 + MainAppAccessKey = AppConfiguration.MainAppAccessKey, + MaxPacketSize = 1024 * 1024 * 2, + AccessKey = long.Parse(AppConfiguration.AccessKey), + SessionProviderType = providerType }; - var providerType = int.Parse(AppConfiguration.SessionMode).ConvertTo(); - options.SessionProviderType = providerType; if (providerType == SessionProviderType.TcpServiceSession) { - if (StartServiceProvider(options)) + if (StartServiceProvider(providerOptions)) this.OnLogHandlerEvent?.Invoke($"SiMay远程监控管理系统端口 {port.ToString()} 监听成功!", LogSeverityLevel.Information); else this.OnLogHandlerEvent?.Invoke($"SiMay远程监控管理系统端口 {port.ToString()} 启动失败,请检查配置!", LogSeverityLevel.Warning); } else { - if (StartProxySessionProvider(options)) + if (StartProxySessionProvider(providerOptions)) this.OnLogHandlerEvent?.Invoke($"SiMay远程监控管理系统初始化成功!", LogSeverityLevel.Information); else this.OnLogHandlerEvent?.Invoke($"SiMay远程监控管理系统初始化发生错误,请注意检查配置!", LogSeverityLevel.Warning); @@ -133,7 +156,8 @@ namespace SiMay.RemoteControlsCore bool StartServiceProvider(SessionProviderOptions providerOptions) { - SessionProvider = SessionProviderFactory.CreateTcpSessionProvider(providerOptions, OnNotifyProc); + SessionProvider = SessionProviderFactory.CreateTcpSessionProvider(providerOptions); + SessionProvider.SessionNotifyEventHandler += OnNotifyProc; try { SessionProvider.StartSerivce(); @@ -148,7 +172,24 @@ namespace SiMay.RemoteControlsCore bool StartProxySessionProvider(SessionProviderOptions providerOptions) { - SessionProvider = SessionProviderFactory.CreateProxySessionProvider(options, OnNotifyProc, OnProxyNotifyHandlerEvent); + SessionProvider = SessionProviderFactory.CreateProxySessionProvider(providerOptions); + SessionProvider.SessionNotifyEventHandler += OnNotifyProc; + + LoginPack loginPack = new LoginPack() + { + IPV4 = SystemInfoHelper.GetLocalIPV4(), + MachineName = Environment.MachineName ?? string.Empty, + ProcessorCount = Environment.ProcessorCount, + ProcessorInfo = SystemInfoHelper.GetMyCpuInfo, + MemorySize = SystemInfoHelper.GetMyMemorySize, + UserName = Environment.UserName.ToString(), + OSVersion = SystemInfoHelper.GetOSFullName, + MacAddress = SystemInfoHelper.GetMacAddress + }; + TcpProxySessionProvider.loginPack = loginPack; + if (SessionProvider is TcpProxySessionProvider proxySessionProvider) + proxySessionProvider.ProxyProviderNotify += OnProxyNotifyHandlerEvent; + try { SessionProvider.StartSerivce(); @@ -167,20 +208,20 @@ namespace SiMay.RemoteControlsCore /// /// /// - private void OnNotifyProc(SessionCompletedNotify notify, SessionHandler session) + private void OnNotifyProc(SessionProviderContext session, TcpSessionNotify notify) { - if (SynchronizationContext == null) + if (SynchronizationContext.IsNull()) NotifyProc(null); else SynchronizationContext.Send(NotifyProc, null); - void NotifyProc(object val) + void NotifyProc(object @object) { try { switch (notify) { - case SessionCompletedNotify.OnConnected: + case TcpSessionNotify.OnConnected: //先分配好工作类型,等待工作指令分配新的工作类型 session.AppTokens = new object[SysConstants.INDEX_COUNT] { @@ -188,18 +229,19 @@ namespace SiMay.RemoteControlsCore null }; break; - case SessionCompletedNotify.OnSend: + case TcpSessionNotify.OnSend: //耗时操作会导致性能严重降低 this.OnTransmitHandlerEvent?.Invoke(session); break; - case SessionCompletedNotify.OnRecv: + case TcpSessionNotify.OnDataReceiveing: //耗时操作会导致性能严重降低 this.OnReceiveHandlerEvent?.Invoke(session); + break; - case SessionCompletedNotify.OnReceived: + case TcpSessionNotify.OnDataReceived: this.OnReceiveComplete(session); break; - case SessionCompletedNotify.OnClosed: + case TcpSessionNotify.OnClosed: this.OnClosed(session); break; } @@ -211,7 +253,7 @@ namespace SiMay.RemoteControlsCore } } - private void OnReceiveComplete(SessionHandler session) + private void OnReceiveComplete(SessionProviderContext session) { // Tokens参数说明 // [0]为该连接工作类型,MainWork为主连接,Work工作连接,NONE为未知连接 @@ -222,16 +264,16 @@ namespace SiMay.RemoteControlsCore if (sessionWorkType == ConnectionWorkType.WORKCON) { //消息传给消息处理器,由消息处理器所在App进行处理 - var app = appTokens[SysConstants.INDEX_WORKER].ConvertTo(); - if (app.IsClose) + var app = appTokens[SysConstants.INDEX_WORKER].ConvertTo(); + if (app.WhetherClose) return; - app.HandlerBinder.InvokePacketHandler(session, session.CompletedBuffer.GetMessageHead(), app); + app.HandlerBinder.InvokePacketHandler(session, GetMessageHead(session), app); } else if (sessionWorkType == ConnectionWorkType.MAINCON) - _handlerBinder.InvokePacketHandler(session, session.CompletedBuffer.GetMessageHead(), this); + this.HandlerBinder.InvokePacketHandler(session, GetMessageHead(session), this); else if (sessionWorkType == ConnectionWorkType.NONE) //未经过验证的连接的消息只能进入该方法块处理,连接密码验证正确才能正式处理消息 { - switch (session.CompletedBuffer.GetMessageHead()) + switch (GetMessageHead(session)) { case MessageHead.C_GLOBAL_CONNECT://连接确认包 this.ValiditySession(session); @@ -247,9 +289,10 @@ namespace SiMay.RemoteControlsCore /// 确认连接包 /// /// - private void ValiditySession(SessionHandler session) + private void ValiditySession(SessionProviderContext session) { - long accessKey = BitConverter.ToInt64(session.CompletedBuffer.GetMessagePayload(), 0); + var ack = GetMessageEntity(session); + long accessKey = ack.AccessKey; if (accessKey != int.Parse(AppConfiguration.ConnectPassWord)) { session.SessionClose(); @@ -259,13 +302,92 @@ namespace SiMay.RemoteControlsCore { //连接密码验证通过,设置成为主连接,正式接收处理数据包 session.AppTokens[SysConstants.INDEX_WORKTYPE] = ConnectionWorkType.MAINCON; - //告诉服务端一切就绪 - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_GLOBAL_OK); - session.SendAsync(data); + SendTo(session, MessageHead.S_GLOBAL_OK); + } + } + + /// + /// 中断任务重连线程 + /// + private void ApplicationResetThread() + { + while (this._launch) + { + for (int i = 0; i < _suspendTaskContexts.Count; i++) + { + SuspendTaskContext task = _suspendTaskContexts[i]; + + string id = task.AdapterHandler.IdentifyId.Split('|')[0]; + var syncContext = SessionSyncContexts.FirstOrDefault(x => x.KeyDictions[SysConstants.IdentifyId].ConvertTo() == id); + + LogHelper.WriteErrorByCurrentMethod("beigin Reset--{0},{1},{2}".FormatTo(task.AdapterHandler.ApplicationKey, task.AdapterHandler.IdentifyId, id)); + + if (!syncContext.IsNull()) + { + if (task.AdapterHandler.WhetherClose) + { + //窗口关闭将不再建立连接 + _suspendTaskContexts.Remove(task); i--; + continue; + } + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_ACTIVATE_APPLICATIONSERVICE, + new ActivateServicePack() + { + ApplicationKey = task.AdapterHandler.ApplicationKey + }); + + LogHelper.WriteErrorByCurrentMethod("send reset command--{0},{1},{2}".FormatTo(task.AdapterHandler.ApplicationKey, task.AdapterHandler.IdentifyId, id)); + } + } + Thread.Sleep(5000); + } + } + + /// + /// 加入重连线程 + /// + /// + public void AddSuspendTaskContext(SuspendTaskContext context) + { + _suspendTaskContexts.Add(context); + LogHelper.WriteErrorByCurrentMethod("Session Close--{0},{1}".FormatTo(context.AdapterHandler.ApplicationKey, context.AdapterHandler.IdentifyId)); + } + + /// + /// 根据被控服务组合id寻找中断应用 + /// + /// + /// + public SuspendTaskContext FindOfSuspendTaskContext(string identifyId) + { + var task = _suspendTaskContexts + .Where(x => x.AdapterHandler.IdentifyId.Split('|').FirstOrDefault() == identifyId) + .FirstOrDefault(); + + return task; + } + + /// + /// 移出重连线程 + /// + /// + /// + public bool RemoveSuspendTaskContext(string identifyId) + { + var task = _suspendTaskContexts.Where(x => x.AdapterHandler.IdentifyId.Split('|').FirstOrDefault().Equals(identifyId)).FirstOrDefault(); + if (task != null) + { + _suspendTaskContexts.Remove(task); + LogHelper.WriteErrorByCurrentMethod("ResetTask Remove--{0},{1}".FormatTo(task.AdapterHandler.ApplicationKey, task.AdapterHandler.IdentifyId)); } + else + return false; + + return true; } + /// /// 启动App /// @@ -273,22 +395,21 @@ namespace SiMay.RemoteControlsCore /// /// [PacketHandler(MessageHead.C_MAIN_ACTIVE_APP)] - private void OnActivateStartApp(SessionHandler session) + private void OnActivateStartApp(SessionProviderContext session) { - var openControl = session.CompletedBuffer.GetMessageEntity(); + var openControl = GetMessageEntity(session); string originName = openControl.OriginName; string appKey = openControl.ServiceKey; string identifyId = openControl.IdentifyId; //查找离线任务队列,如果有对应的任务则继续工作 - var task = _resetPool.FindTask(identifyId); - if (task != null) + var task = FindOfSuspendTaskContext(identifyId); + if (!task.IsNull()) { //再发出重连命令后,如果使用者主动关闭消息处理器将不再建立连接 - if (task.AdapterHandler.IsClose) + if (task.AdapterHandler.WhetherClose) { //通知远程释放资源 - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_GLOBAL_ONCLOSE); - session.SendAsync(data); + SendTo(session, MessageHead.S_GLOBAL_ONCLOSE); return; } @@ -296,34 +417,36 @@ namespace SiMay.RemoteControlsCore var tokens = session.AppTokens; tokens[SysConstants.INDEX_WORKTYPE] = ConnectionWorkType.WORKCON; tokens[SysConstants.INDEX_WORKER] = task.AdapterHandler; - task.AdapterHandler.Session = session; + task.AdapterHandler.SetSession(session); task.AdapterHandler.ContinueTask(session);//继续任务 - _resetPool.RemoveTask(identifyId); + RemoveSuspendTaskContext(identifyId); } else { var context = SysUtil.ApplicationTypes.FirstOrDefault(x => x.ApplicationKey.Equals(appKey)); - if (context != null) + if (!context.IsNull()) { var appHandlerType = context.Type.GetAppAdapterHandlerType(); - AdapterHandlerBase appHandlerBase = Activator.CreateInstance(appHandlerType).ConvertTo(); + ApplicationAdapterHandler appHandlerBase = Activator.CreateInstance(appHandlerType).ConvertTo(); IApplication app = Activator.CreateInstance(context.Type).ConvertTo(); appHandlerBase.App = app; - appHandlerBase.Session = session; appHandlerBase.IdentifyId = identifyId; appHandlerBase.OriginName = originName; - appHandlerBase.ResetApplicationKey = context.Type.GetAppKey(); + appHandlerBase.ApplicationKey = context.Type.GetApplicationKey(); + appHandlerBase.SetSession(session); //每个应用至少标记一个应用处理器属性 var handlerFieder = context .Type .GetProperties() - .Single(c => c.GetCustomAttribute(true) != null); + .Single(c => !c.GetCustomAttribute(true).IsNull()); handlerFieder.SetValue(app, appHandlerBase); + this.OnApplicationCreatedEventHandler?.Invoke(app); + //app.HandlerAdapter = handlerBase; app.Start(); @@ -344,35 +467,34 @@ namespace SiMay.RemoteControlsCore /// 创建桌面记录任务 /// /// - [PacketHandler(MessageHead.C_MAIN_SCREEN_RECORD_OPEN)] - private void StartScreenRecordTaskHandler(SessionHandler session) + [PacketHandler(MessageHead.C_MAIN_DESKTOPRECORD_OPEN)] + private void StartScreenRecordTaskHandler(SessionProviderContext session) { - string macName = session.CompletedBuffer.GetMessagePayload().ToUnicodeString(); + string macName = GetMessage(session).ToUnicodeString(); var syncContext = session.AppTokens[SysConstants.INDEX_WORKER].ConvertTo(); - syncContext.KeyDictions[SysConstants.RecordScreenIsAction] = true;//开启 + syncContext.KeyDictions[SysConstants.HasLaunchDesktopRecord] = true;//开启 syncContext.KeyDictions[SysConstants.MachineName] = macName;//标识名(用计算机名作为唯一标识) - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SCREEN_RECORD_GETIMG); - session.SendAsync(data); + SendTo(session, MessageHead.S_MAIN_DESKTOPRECORD_GETFRAME); } /// /// 储存桌面记录信息 /// /// - [PacketHandler(MessageHead.C_MAIN_SCREEN_RECORD_IMG)] - private void ScreenSaveHandler(SessionHandler session) + [PacketHandler(MessageHead.C_MAIN_DESKTOPRECORD_FRAME)] + private void ScreenSaveHandler(SessionProviderContext session) { var syncContext = session.AppTokens[SysConstants.INDEX_WORKER].ConvertTo(); - bool status = syncContext.KeyDictions[SysConstants.RecordScreenIsAction].ConvertTo(); - string macName = syncContext.KeyDictions[SysConstants.MachineName].ConvertTo(); + var status = syncContext.KeyDictions[SysConstants.HasLaunchDesktopRecord].ConvertTo(); + var macName = syncContext.KeyDictions[SysConstants.MachineName].ConvertTo(); - if (!Directory.Exists(Path.Combine("ScreenRecord", macName))) - Directory.CreateDirectory(Path.Combine("ScreenRecord", macName)); + if (!Directory.Exists(Path.Combine("DesktopRecord", macName))) + Directory.CreateDirectory(Path.Combine("DesktopRecord", macName)); - using (var ms = new MemoryStream(session.CompletedBuffer.GetMessagePayload())) + using (var ms = new MemoryStream(GetMessage(session))) { - string fileName = Path.Combine(Environment.CurrentDirectory, "ScreenRecord", macName, DateTime.Now.ToFileTime() + ".png"); + string fileName = Path.Combine(Environment.CurrentDirectory, "DesktopRecord", macName, DateTime.Now.ToFileTime() + ".png"); Image img = Image.FromStream(ms); img.Save(fileName); img.Dispose(); @@ -381,33 +503,24 @@ namespace SiMay.RemoteControlsCore if (!status) return; - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SCREEN_RECORD_GETIMG); - session.SendAsync(data); + SendTo(session, MessageHead.S_MAIN_DESKTOPRECORD_GETFRAME); } /// /// 创建桌面视图 /// /// - [PacketHandler(MessageHead.C_MAIN_USERDESKTOP_CREATE)] - private void OnCreateDesktopView(SessionHandler session) + [PacketHandler(MessageHead.C_MAIN_DESKTOPVIEW_CREATE)] + private void OnCreateDesktopView(SessionProviderContext session) { - var describePack = session.CompletedBuffer.GetMessageEntity(); + var describePack = GetMessageEntity(session); var syncContext = session.AppTokens[SysConstants.INDEX_WORKER].ConvertTo(); var view = this.OnCreateDesktopViewHandlerEvent?.Invoke(syncContext); - if (view == null) + if (view.IsNull()) return; view.Caption = describePack.MachineName + "-(" + describePack.RemarkInformation + ")"; syncContext.KeyDictions[SysConstants.DesktopView] = view; - - byte[] data = MessageHelper.CopyMessageHeadTo( - MessageHead.S_MAIN_SCREENWALL_GETIMG, new DesktopViewGetFramePack() - { - Height = view.Height, - Width = view.Width, - TimeSpan = this.ViewRefreshInterval - }); - session.SendAsync(data); + this.GetViewFrame(session, view); } @@ -415,28 +528,34 @@ namespace SiMay.RemoteControlsCore /// 显示桌面墙数据 /// /// - [PacketHandler(MessageHead.C_MAIN_SCREENWALL_IMG)] - private void PlayerDesktopImage(SessionHandler session) + [PacketHandler(MessageHead.C_MAIN_DESKTOPVIEW_FRAME)] + private void PlayerDesktopImage(SessionProviderContext session) { var syncContext = session.AppTokens[SysConstants.INDEX_WORKER].ConvertTo(); if (!syncContext.KeyDictions.ContainsKey(SysConstants.DesktopView) || - syncContext.KeyDictions[SysConstants.DesktopView] == null) + syncContext.KeyDictions[SysConstants.DesktopView].IsNull()) return; + var frameData = GetMessageEntity(session); var view = syncContext.KeyDictions[SysConstants.DesktopView].ConvertTo(); + if (frameData.InVisbleArea) + { + using (var ms = new MemoryStream(frameData.ViewData)) + view.PlayerDekstopView(Image.FromStream(ms)); + } + this.GetViewFrame(session, view); + } - using (var ms = new MemoryStream(session.CompletedBuffer.GetMessagePayload())) - view.PlayerDekstopView(Image.FromStream(ms)); - - byte[] data = MessageHelper.CopyMessageHeadTo( - MessageHead.S_MAIN_SCREENWALL_GETIMG, new DesktopViewGetFramePack() + private void GetViewFrame(SessionProviderContext session, IDesktopView view) + { + SendTo(session, MessageHead.S_MAIN_DESKTOPVIEW_GETFRAME, + new DesktopViewGetFramePack() { Height = view.Height, Width = view.Width, - TimeSpan = this.ViewRefreshInterval + TimeSpan = this.ViewRefreshInterval, + InVisbleArea = view.InVisbleArea }); - - session.SendAsync(data); } /// @@ -463,11 +582,12 @@ namespace SiMay.RemoteControlsCore syncContext.KeyDictions[SysConstants.OpenScreenRecord] = login.OpenScreenRecord; syncContext.KeyDictions[SysConstants.OpenScreenWall] = login.OpenScreenWall; syncContext.KeyDictions[SysConstants.IdentifyId] = login.IdentifyId; - syncContext.KeyDictions[SysConstants.RecordScreenIsAction] = false;//桌面记录状态 + syncContext.KeyDictions[SysConstants.HasLaunchDesktopRecord] = false;//桌面记录状态 syncContext.KeyDictions[SysConstants.RecordHeight] = login.RecordHeight;//用于桌面记录的高 syncContext.KeyDictions[SysConstants.RecordWidth] = login.RecordWidth;//用于桌面记录宽 syncContext.KeyDictions[SysConstants.RecordSpanTime] = login.RecordSpanTime; syncContext.KeyDictions[SysConstants.HasLoadServiceCOM] = login.HasLoadServiceCOM; + syncContext.KeyDictions[SysConstants.MacAddress] = login.MacAddress; this.OnLoginUpdateHandlerEvent?.Invoke(syncContext); } @@ -477,12 +597,12 @@ namespace SiMay.RemoteControlsCore /// /// [PacketHandler(MessageHead.C_MAIN_LOGIN)] - private void LoginHandler(SessionHandler session) + private void LoginHandler(SessionProviderContext session) { try { - var login = session.CompletedBuffer.GetMessageEntity(); - if (session.AppTokens[SysConstants.INDEX_WORKER] != null)//如果主连接同步对象存在,则对该对象更新 + var login = GetMessageEntity(session); + if (!session.AppTokens[SysConstants.INDEX_WORKER].IsNull())//如果主连接同步对象存在,则对该对象更新 { this.UpdateSyncContextHandler(session.AppTokens[SysConstants.INDEX_WORKER].ConvertTo(), login); return; @@ -507,21 +627,21 @@ namespace SiMay.RemoteControlsCore { SysConstants.OpenScreenWall, login.OpenScreenWall }, { SysConstants.IdentifyId, login.IdentifyId }, { SysConstants.OpenScreenRecord, login.OpenScreenRecord }, - { SysConstants.RecordScreenIsAction, false }, + { SysConstants.HasLaunchDesktopRecord, false }, { SysConstants.RecordHeight, login.RecordHeight }, { SysConstants.RecordWidth, login.RecordWidth }, { SysConstants.RecordSpanTime, login.RecordSpanTime }, - { SysConstants.HasLoadServiceCOM, login.HasLoadServiceCOM } + { SysConstants.HasLoadServiceCOM, login.HasLoadServiceCOM }, + { SysConstants.MacAddress,login.MacAddress } }; var syncContext = new SessionSyncContext(session, dictions); - SyncContexts.Add(syncContext); + SessionSyncContexts.Add(syncContext); session.AppTokens[SysConstants.INDEX_WORKER] = syncContext; //是否开启桌面视图 if (syncContext.KeyDictions[SysConstants.OpenScreenWall].ConvertTo()) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_DESKTOPVIEW, new byte[] { 0 });//强制创建视图 - session.SendMessageDoHasCOM(data); + HasComWithSendTo(session, MessageHead.S_MAIN_CREATE_DESKTOPVIEW, new byte[] { 0 });//TODO : 强制创建视图,此处会触发载入插件 } this.OnLoginHandlerEvent?.Invoke(syncContext); @@ -539,7 +659,7 @@ namespace SiMay.RemoteControlsCore /// 移除在线信息 /// /// - private void OnClosed(SessionHandler session) + private void OnClosed(SessionProviderContext session) { try { @@ -547,15 +667,15 @@ namespace SiMay.RemoteControlsCore var worktype = arguments[SysConstants.INDEX_WORKTYPE].ConvertTo(); if (worktype == ConnectionWorkType.WORKCON) { - var adapterHandler = arguments[SysConstants.INDEX_WORKER].ConvertTo(); + var adapterHandler = arguments[SysConstants.INDEX_WORKER].ConvertTo(); - if (adapterHandler.IsClose)//如果是手动结束任务 + if (adapterHandler.WhetherClose)//如果是手动结束任务 return; adapterHandler.StateContext = "工作连接已断开,正在重新连接中...."; adapterHandler.SessionClosed(session); - //非手动结束任务,将该任务扔到重连队列中 - _resetPool.Put(new SuspendTaskContext() + //非手动结束任务,将该任务扔到重连线程中 + AddSuspendTaskContext(new SuspendTaskContext() { DisconnectTime = DateTime.Now, AdapterHandler = adapterHandler @@ -564,7 +684,7 @@ namespace SiMay.RemoteControlsCore else if (worktype == ConnectionWorkType.MAINCON) { var syncContext = arguments[SysConstants.INDEX_WORKER].ConvertTo(); - SyncContexts.Remove(syncContext); + SessionSyncContexts.Remove(syncContext); if (syncContext.KeyDictions.ContainsKey(SysConstants.DesktopView) && syncContext.KeyDictions[SysConstants.DesktopView] != null) { @@ -586,15 +706,13 @@ namespace SiMay.RemoteControlsCore LogHelper.WriteErrorByCurrentMethod(ex); } } - /// /// 重新载入远程被控服务端 /// /// public void RemoteServiceReload(SessionSyncContext syncContext) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_RELOADER); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_RELOADER); } /// @@ -603,8 +721,7 @@ namespace SiMay.RemoteControlsCore /// public void InstallAutoStartService(SessionSyncContext syncContext) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_INSTANLL_SERVICE); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_INSTANLL_SERVICE); } /// @@ -613,8 +730,7 @@ namespace SiMay.RemoteControlsCore /// public void UnInStallAutoStartService(SessionSyncContext syncContext) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_UNINSTANLL_SERVICE); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_UNINSTANLL_SERVICE); } /// /// 远程服务文件更新 @@ -625,16 +741,59 @@ namespace SiMay.RemoteControlsCore /// public void RemoteServiceUpdate(SessionSyncContext syncContext, RemoteUpdateType updateType, byte[] file, string url) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_UPDATE, + UpdateFilePack = file; + int FilePackLength = (int)Math.Ceiling((double)UpdateFilePack.Length / 1048576); + byte[] bytPack = new byte[m_intPackSize]; + if (FilePackLength==1) + { + bytPack = new byte[UpdateFilePack.Length - m_intPackSize]; + } + Array.Copy(UpdateFilePack, 0, bytPack, 0, bytPack.Length); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_UPDATE, new RemoteUpdatePack() { UrlOrFileUpdate = updateType, DownloadUrl = updateType == RemoteUpdateType.Url ? url : string.Empty, - FileDate = updateType == RemoteUpdateType.File ? file : new byte[0] + FileDate = updateType == RemoteUpdateType.File ? bytPack : new byte[0], + FilePackLength = FilePackLength, + CurrentPack = 1 }); - syncContext.Session.SendMessageDoHasCOM(data); } - + /// + /// 远程服务文件更新 + /// + private int m_intPackSize = 1024 * 1024; + public static byte[] UpdateFilePack { get; set; } + [PacketHandler(MessageHead.S_MAIN_UPDATE)] + public void RemoteServiceUpdate(SessionProviderContext session) + { + var remoteUpdate = session.AppTokens[SysConstants.INDEX_WORKER].ConvertTo(); + var pack = GetMessageEntity(session); + int intCurrentPack = pack.CurrentPack; + if (intCurrentPack <= pack.FilePackLength) + { + byte[] bytPack = new byte[m_intPackSize]; + if (intCurrentPack == pack.FilePackLength) + { + bytPack = new byte[UpdateFilePack.Length - (intCurrentPack - 1) * m_intPackSize]; + } + Array.Copy(UpdateFilePack, (intCurrentPack - 1) * m_intPackSize, bytPack, 0, bytPack.Length); + HasComWithSendTo(remoteUpdate.Session, MessageHead.S_MAIN_UPDATE, + new RemoteUpdatePack() + { + UrlOrFileUpdate = RemoteUpdateType.File, + DownloadUrl = string.Empty, + FileDate = bytPack, + FilePackLength = pack.FilePackLength, + CurrentPack = intCurrentPack + }); + } + else + { + Console.WriteLine("客户端更新完成"); + } + + } /// /// 设置分组 /// @@ -642,8 +801,7 @@ namespace SiMay.RemoteControlsCore /// public void RemoteSetGroupName(SessionSyncContext syncContext, string groupName) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_GROUP, groupName); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_GROUP, groupName); } /// @@ -652,8 +810,7 @@ namespace SiMay.RemoteControlsCore /// public void RemoteOpenDesktopView(SessionSyncContext syncContext) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_DESKTOPVIEW, new byte[] { 1 }); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_CREATE_DESKTOPVIEW, new byte[] { 1 }); } /// @@ -669,8 +826,7 @@ namespace SiMay.RemoteControlsCore syncContext.KeyDictions.Remove(SysConstants.DesktopView); - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_USERDESKTOP_CLOSE); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_DESKTOPVIEW_CLOSE); } /// @@ -680,9 +836,7 @@ namespace SiMay.RemoteControlsCore /// public void RemoteOpenUrl(SessionSyncContext syncContext, string url) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_OPEN_WEBURL, - url); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_OPEN_WEBURL, url); } /// @@ -692,8 +846,7 @@ namespace SiMay.RemoteControlsCore /// public void RemoteSetSessionState(SessionSyncContext syncContext, SystemSessionType sessionType) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SESSION, new byte[] { (byte)sessionType }); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_SESSION, new byte[] { (byte)sessionType }); } /// @@ -703,9 +856,7 @@ namespace SiMay.RemoteControlsCore /// public void RemoteHttpDownloadExecute(SessionSyncContext syncContext, string url) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_HTTPDOWNLOAD, - url); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_HTTPDOWNLOAD, url); } /// @@ -717,15 +868,13 @@ namespace SiMay.RemoteControlsCore /// public void RemoteMessageBox(SessionSyncContext syncContext, string text, string title, MessageIcon icon) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_MESSAGEBOX, + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_MESSAGEBOX, new MessagePack() { MessageTitle = title, MessageBody = text, MessageIcon = (byte)icon }); - - syncContext.Session.SendMessageDoHasCOM(data); } /// @@ -735,8 +884,7 @@ namespace SiMay.RemoteControlsCore /// public void RemoteSetRemarkInformation(SessionSyncContext syncContext, string remark) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_REMARK, remark); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_REMARK, remark); } /// @@ -746,15 +894,18 @@ namespace SiMay.RemoteControlsCore /// public void RemoteActiveService(SessionSyncContext syncContext, string appKey) { - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_ACTIVATE_CTRLSERVICE, appKey); - syncContext.Session.SendMessageDoHasCOM(data); + HasComWithSendTo(syncContext.Session, MessageHead.S_MAIN_ACTIVATE_APPLICATIONSERVICE, + new ActivateServicePack() + { + ApplicationKey = appKey + }); } - public void CloseService() + public override void Dispose() { - SessionProvider.CloseService(); - this._handlerBinder.Dispose(); - this._resetPool.Stop(); + this._launch = false; + this.SessionProvider.CloseService(); + base.Dispose(); } } } diff --git a/SiMay.RemoteControlsCore/Properties/AssemblyInfo.cs b/SiMay.RemoteControlsCore/Properties/AssemblyInfo.cs index b5323a279f19637433e6e542c9538aeea9bfdde7..e63716e39660212ea9bdd4345f45fddabdfdff25 100644 Binary files a/SiMay.RemoteControlsCore/Properties/AssemblyInfo.cs and b/SiMay.RemoteControlsCore/Properties/AssemblyInfo.cs differ diff --git a/SiMay.RemoteControlsCore/ResetPool.cs b/SiMay.RemoteControlsCore/ResetPool.cs deleted file mode 100644 index 0b77db357bd860e341bb9f58b89dc0e70566cdd5..0000000000000000000000000000000000000000 --- a/SiMay.RemoteControlsCore/ResetPool.cs +++ /dev/null @@ -1,99 +0,0 @@ -using SiMay.Basic; -using SiMay.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading; - -namespace SiMay.RemoteControlsCore -{ - public class ResetPool - { - private bool _isRun = true; - private List _syncContexts; - private List _suspendWorkQueue = new List(); - public ResetPool(List syncContexts) - { - _syncContexts = syncContexts; - ThreadHelper.CreateThread(workerMethod, true); - } - - - private void workerMethod() - { - while (_isRun) - { - for (int i = 0; i < _suspendWorkQueue.Count; i++) - { - SuspendTaskContext task = _suspendWorkQueue[i]; - - //if ((int)(DateTime.Now - task.DisconnectTime).TotalSeconds > 60 * 5) - //{ - // LogHelper.WriteErrorByCurrentMethod("Reset TimeOut--{0},{1}".FormatTo(task.Adapter.ResetMsg, task.Adapter.IdentifyId)); - // //如果超时5分钟未重连就判定该任务已真正离线 - // task.Adapter.WindowClose();//关闭窗口 - // _suspendWorkQueue.Remove(task); - // i--; - //} - //else - //{ - string id = task.AdapterHandler.IdentifyId.Split('|')[0]; - var syncContext = _syncContexts.FirstOrDefault(x => x.KeyDictions[SysConstants.IdentifyId].ConvertTo() == id); - - LogHelper.WriteErrorByCurrentMethod("beigin Reset--{0},{1},{2}".FormatTo(task.AdapterHandler.ResetApplicationKey, task.AdapterHandler.IdentifyId, id)); - - if (syncContext != null) - { - if (task.AdapterHandler.IsClose) - { - //窗口关闭将不再建立连接 - _suspendWorkQueue.Remove(task); - i--; - continue; - } - byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_ACTIVATE_CTRLSERVICE, - task.AdapterHandler.ResetApplicationKey); - syncContext.Session.SendMessageDoHasCOM(data); - - LogHelper.WriteErrorByCurrentMethod("send reset command--{0},{1},{2}".FormatTo(task.AdapterHandler.ResetApplicationKey, task.AdapterHandler.IdentifyId, id)); - } - - //} - } - Thread.Sleep(5000); - } - } - public void Put(SuspendTaskContext context) - { - _suspendWorkQueue.Add(context); - LogHelper.WriteErrorByCurrentMethod("Session Close--{0},{1}".FormatTo(context.AdapterHandler.ResetApplicationKey, context.AdapterHandler.IdentifyId)); - } - public SuspendTaskContext FindTask(string identifyId) - { - var task = _suspendWorkQueue - .Where(x => x.AdapterHandler.IdentifyId.Split('|').FirstOrDefault() == identifyId) - .FirstOrDefault(); - - return task; - } - - public bool RemoveTask(string identifyId) - { - var task = _suspendWorkQueue.Where(x => x.AdapterHandler.IdentifyId.Split('|').FirstOrDefault() == identifyId).FirstOrDefault(); - if (task != null) - { - _suspendWorkQueue.Remove(task); - LogHelper.WriteErrorByCurrentMethod("ResetTask Remove--{0},{1}".FormatTo(task.AdapterHandler.ResetApplicationKey, task.AdapterHandler.IdentifyId)); - } - else - return false; - - return true; - } - public void Stop() - { - this._isRun = false; - } - } -} diff --git a/SiMay.RemoteControlsCore/SiMay.RemoteControlsCore.csproj b/SiMay.RemoteControlsCore/SiMay.RemoteControlsCore.csproj index bd8f3eefe6693cd032fbb61798f0c01968c37399..49e0e286bb889959e7faa1d72e2b25ebc2022b7a 100644 --- a/SiMay.RemoteControlsCore/SiMay.RemoteControlsCore.csproj +++ b/SiMay.RemoteControlsCore/SiMay.RemoteControlsCore.csproj @@ -9,7 +9,7 @@ Properties SiMay.RemoteControlsCore SiMay.RemoteControlsCore - v4.5 + v4.6.1 512 true @@ -46,8 +46,11 @@ + + - + + @@ -61,31 +64,29 @@ - - - - - - - - - - - - - + + + + + + + + + + + + - - {B30CD716-698A-4DA2-BD1A-C152B16993C0} + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F} SiMay.Basic @@ -93,12 +94,20 @@ SiMay.Core - {BF5B6F41-D688-447F-BF81-EA821216F188} + {71283236-56CB-481E-A644-B7F9AF9EFDF9} SiMay.Net.SessionProvider - - {4888d6bb-46d9-4519-8758-e13e397aa226} - SiMay.Serialize + + {8d061d46-9e59-42b0-91dc-4e380e4ae0ba} + SiMay.ServiceCore + + + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32} + SiMay.Serialize.Standard + + + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40} + SiMay.Sockets.Standard diff --git a/SiMay.RemoteControlsCore/SysConstants.cs b/SiMay.RemoteControlsCore/SysConstants.cs index ef07ce612e8980d4d18ab23dfcf5b7e6eeda0d7d..99a71f0faf47acbdf90acdad23d05274792bb785 100644 --- a/SiMay.RemoteControlsCore/SysConstants.cs +++ b/SiMay.RemoteControlsCore/SysConstants.cs @@ -28,12 +28,13 @@ namespace SiMay.RemoteControlsCore public const string OpenScreenWall = "OpenScreenWall"; public const string IdentifyId = "IdentifyId"; public const string OpenScreenRecord = "OpenScreenRecord"; - public const string RecordScreenIsAction = "RecordScreenIsAction"; + public const string HasLaunchDesktopRecord = "RecordScreenIsAction"; public const string RecordHeight = "RecordHeight"; public const string RecordWidth = "RecordWidth"; public const string RecordSpanTime = "RecordSpanTime"; public const string Session = "Session"; public const string HasLoadServiceCOM = "HasLoadServiceCOM"; public const string DesktopView = "DesktopView"; + public const string MacAddress = "MacAddress"; } } diff --git a/SiMay.RemoteControlsCore/SysUtil.cs b/SiMay.RemoteControlsCore/SysUtil.cs index dc91cbde778b7cdad6bae46bd332464d255d84be..cde9a63cc8f257b905443a96b1e7aa15dd6ca52b 100644 --- a/SiMay.RemoteControlsCore/SysUtil.cs +++ b/SiMay.RemoteControlsCore/SysUtil.cs @@ -27,7 +27,7 @@ namespace SiMay.RemoteControlsCore .Select(t => new ApplicationItem() { Rank = t.GetRank(), - ApplicationKey = t.GetAppKey() ?? throw new Exception(t.Name + ":The AppKey cannot be empty!"), + ApplicationKey = t.GetApplicationKey() ?? throw new Exception(t.Name + ":The AppKey cannot be empty!"), Type = t }) .ToList(); diff --git a/SiMay.RemoteMonitor/App.config b/SiMay.RemoteMonitor/App.config index 98ad47b3f864e4e3901a907a47e9cda0deabf361..07684763db3d77a59f8f0a8c91b1fce838f5f305 100644 --- a/SiMay.RemoteMonitor/App.config +++ b/SiMay.RemoteMonitor/App.config @@ -2,7 +2,7 @@ - + diff --git a/SiMay.RemoteMonitor/Application/AudioApplication.Designer.cs b/SiMay.RemoteMonitor/Application/AudioApplication.Designer.cs index 89c95784d10db8b9e1a2ea1bc9528477f8163c86..ea4af58ab7769d41062b05c1f4dd7fe615da87e3 100644 --- a/SiMay.RemoteMonitor/Application/AudioApplication.Designer.cs +++ b/SiMay.RemoteMonitor/Application/AudioApplication.Designer.cs @@ -54,18 +54,21 @@ this.groupBox1.Controls.Add(this.recvdataLen); this.groupBox1.Controls.Add(this.label2); this.groupBox1.Controls.Add(this.tip); - this.groupBox1.Location = new System.Drawing.Point(7, 1); + this.groupBox1.Location = new System.Drawing.Point(9, 1); + this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(519, 142); + this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.groupBox1.Size = new System.Drawing.Size(692, 178); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; // // checkBox2 // this.checkBox2.AutoSize = true; - this.checkBox2.Location = new System.Drawing.Point(157, 107); + this.checkBox2.Location = new System.Drawing.Point(209, 134); + this.checkBox2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.checkBox2.Name = "checkBox2"; - this.checkBox2.Size = new System.Drawing.Size(96, 16); + this.checkBox2.Size = new System.Drawing.Size(119, 19); this.checkBox2.TabIndex = 11; this.checkBox2.Text = "录制远程声音"; this.checkBox2.UseVisualStyleBackColor = true; @@ -74,17 +77,19 @@ // labRuntime // this.labRuntime.AutoSize = true; - this.labRuntime.Location = new System.Drawing.Point(304, 108); + this.labRuntime.Location = new System.Drawing.Point(405, 135); + this.labRuntime.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.labRuntime.Name = "labRuntime"; - this.labRuntime.Size = new System.Drawing.Size(113, 12); + this.labRuntime.Size = new System.Drawing.Size(148, 15); this.labRuntime.TabIndex = 10; this.labRuntime.Text = "已运行:00.00.00.00"; // // button1 // - this.button1.Location = new System.Drawing.Point(423, 103); + this.button1.Location = new System.Drawing.Point(564, 129); + this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 23); + this.button1.Size = new System.Drawing.Size(100, 29); this.button1.TabIndex = 9; this.button1.Text = "设置"; this.button1.UseVisualStyleBackColor = true; @@ -92,36 +97,40 @@ // // progressBar1 // - this.progressBar1.Location = new System.Drawing.Point(200, 55); + this.progressBar1.Location = new System.Drawing.Point(370, 69); + this.progressBar1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.progressBar1.Name = "progressBar1"; - this.progressBar1.Size = new System.Drawing.Size(298, 13); + this.progressBar1.Size = new System.Drawing.Size(294, 11); this.progressBar1.Style = System.Windows.Forms.ProgressBarStyle.Marquee; this.progressBar1.TabIndex = 7; // // sendataLen // this.sendataLen.AutoSize = true; - this.sendataLen.Location = new System.Drawing.Point(70, 75); + this.sendataLen.Location = new System.Drawing.Point(93, 94); + this.sendataLen.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.sendataLen.Name = "sendataLen"; - this.sendataLen.Size = new System.Drawing.Size(29, 12); + this.sendataLen.Size = new System.Drawing.Size(39, 15); this.sendataLen.TabIndex = 6; this.sendataLen.Text = "0 KB"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(17, 75); + this.label3.Location = new System.Drawing.Point(23, 94); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(47, 12); + this.label3.Size = new System.Drawing.Size(60, 15); this.label3.TabIndex = 5; this.label3.Text = "已发送:"; // // checkBox1 // this.checkBox1.AutoSize = true; - this.checkBox1.Location = new System.Drawing.Point(19, 107); + this.checkBox1.Location = new System.Drawing.Point(25, 134); + this.checkBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.checkBox1.Name = "checkBox1"; - this.checkBox1.Size = new System.Drawing.Size(132, 16); + this.checkBox1.Size = new System.Drawing.Size(164, 19); this.checkBox1.TabIndex = 3; this.checkBox1.Text = "发送本地语音到远程"; this.checkBox1.UseVisualStyleBackColor = true; @@ -130,18 +139,20 @@ // recvdataLen // this.recvdataLen.AutoSize = true; - this.recvdataLen.Location = new System.Drawing.Point(70, 55); + this.recvdataLen.Location = new System.Drawing.Point(93, 69); + this.recvdataLen.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.recvdataLen.Name = "recvdataLen"; - this.recvdataLen.Size = new System.Drawing.Size(29, 12); + this.recvdataLen.Size = new System.Drawing.Size(39, 15); this.recvdataLen.TabIndex = 2; this.recvdataLen.Text = "0 KB"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(17, 55); + this.label2.Location = new System.Drawing.Point(23, 69); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(47, 12); + this.label2.Size = new System.Drawing.Size(60, 15); this.label2.TabIndex = 1; this.label2.Text = "已接收:"; // @@ -149,21 +160,23 @@ // this.tip.AutoSize = true; this.tip.ForeColor = System.Drawing.Color.Red; - this.tip.Location = new System.Drawing.Point(17, 32); + this.tip.Location = new System.Drawing.Point(23, 40); + this.tip.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.tip.Name = "tip"; - this.tip.Size = new System.Drawing.Size(137, 12); + this.tip.Size = new System.Drawing.Size(175, 15); this.tip.TabIndex = 0; this.tip.Text = "正在监听远程声音......"; // - // AudioManager + // AudioApplication // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(533, 151); + this.ClientSize = new System.Drawing.Size(711, 189); this.Controls.Add(this.groupBox1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.MaximizeBox = false; - this.Name = "AudioManager"; + this.Name = "AudioApplication"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "语音监听"; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.AudioManager_FormClosing); diff --git a/SiMay.RemoteMonitor/Application/AudioApplication.cs b/SiMay.RemoteMonitor/Application/AudioApplication.cs index ea3b46c89044bd78e4e132ecb623f3b8a2cd9799..6f86f599db25edfaa2a1ecb3794de6888391ea1a 100644 --- a/SiMay.RemoteMonitor/Application/AudioApplication.cs +++ b/SiMay.RemoteMonitor/Application/AudioApplication.cs @@ -1,4 +1,5 @@ using SiMay.Basic; +using SiMay.Core; using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.HandlerAdapters; using SiMay.RemoteMonitor.Attributes; @@ -13,7 +14,7 @@ namespace SiMay.RemoteMonitor.Application [OnTools] [ApplicationName("远程语音")] [AppResourceName("AudioManager")] - [Application(typeof(AudioAdapterHandler), "RemoteAudioJob", 20)] + [Application(typeof(AudioAdapterHandler), AppJobConstant.REMOTE_AUDIO, 20)] public partial class AudioApplication : Form, IApplication { [ApplicationAdapterHandler] @@ -23,16 +24,21 @@ namespace SiMay.RemoteMonitor.Application private WinSoundRecord _recorder; private WinSoundPlayer _player; - private FileStream _fileStream; + private bool _isRun = false; private bool _isPlaying = true; private int _recvVoiceDataLength = 0; private int _sendVoiceDataLength = 0; private int _soundBufferCount = 8; + private int _samplesPerSecond; + private short _bitsPerSample; + private short _channels; + private int _dataBufferSize; + private bool _isRecord = false; private DateTime _runtimeSpan; - + private PCMStreamToWavHelper _pcmStreamToWavHelper; public AudioApplication() { InitializeComponent(); @@ -43,12 +49,17 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) { this.Text = this._title + " [" + this.AudioAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = this._title; } @@ -60,7 +71,7 @@ namespace SiMay.RemoteMonitor.Application this.AudioAdapterHandler.OnOpenDeviceStatusEventHandler += OnOpenDeviceStatusEventHandler; this.AudioAdapterHandler.OnPlayerEventHandler += OnPlayerEventHandler; Initialize(); - + this._runtimeSpan = DateTime.Now; System.Timers.Timer timer = new System.Timers.Timer(); timer.Interval = 1000; @@ -78,10 +89,10 @@ namespace SiMay.RemoteMonitor.Application }; timer.Start(); - + } - private async void OnPlayerEventHandler(AudioAdapterHandler adapterHandler, byte[] voiceData) + private void OnPlayerEventHandler(AudioAdapterHandler adapterHandler, byte[] voiceData) { if (this._isRun && this._player != null && this._isPlaying == true) { @@ -94,7 +105,7 @@ namespace SiMay.RemoteMonitor.Application })); this._player.PlayData(voiceData); if (this._isRecord) - await this._fileStream.WriteAsync(voiceData, 0, voiceData.Length); + this._pcmStreamToWavHelper.WritePCMDataChunk(voiceData); } catch { } } @@ -114,16 +125,17 @@ namespace SiMay.RemoteMonitor.Application private void Initialize() { - int samplesPerSecond = int.Parse(AppConfiguration.AudioSamplesPerSecond); - int bitsPerSample = int.Parse(AppConfiguration.AudioBitsPerSample); - int channels = int.Parse(AppConfiguration.AudioChannels); + _samplesPerSecond = AppConfiguration.AudioSamplesPerSecond; + _bitsPerSample = (short)AppConfiguration.AudioBitsPerSample; + _channels = (short)AppConfiguration.AudioChannels; + _dataBufferSize = 1280; string waveOutDeviceName = WinSound.GetWaveOutDeviceNames().Count > 0 ? WinSound.GetWaveOutDeviceNames()[0] : null; if (waveOutDeviceName != null) { _player = new WinSoundPlayer(); - _player.Open(waveOutDeviceName, samplesPerSecond, bitsPerSample, channels, 1280, _soundBufferCount); + _player.Open(waveOutDeviceName, _samplesPerSecond, _bitsPerSample, _channels, _dataBufferSize, _soundBufferCount); } else { @@ -136,13 +148,13 @@ namespace SiMay.RemoteMonitor.Application { _recorder = new WinSoundRecord(); _recorder.DataRecorded += Recorder_DataRecorded; - _recorder.Open(waveInDeviceName, samplesPerSecond, bitsPerSample, channels, 1280, _soundBufferCount); + _recorder.Open(waveInDeviceName, _samplesPerSecond, _bitsPerSample, _channels, _dataBufferSize, _soundBufferCount); } else { MessageBoxHelper.ShowBoxExclamation("本机未找到录音设备!"); } - this.AudioAdapterHandler.StartRemoteAudio(samplesPerSecond, bitsPerSample, channels); + this.AudioAdapterHandler.StartRemoteAudio(_samplesPerSecond, _bitsPerSample, _channels); this._isRun = true; } @@ -174,7 +186,7 @@ namespace SiMay.RemoteMonitor.Application this._isRun = false; this.AudioAdapterHandler.OnOpenDeviceStatusEventHandler -= OnOpenDeviceStatusEventHandler; this.AudioAdapterHandler.OnPlayerEventHandler -= OnPlayerEventHandler; - this.AudioAdapterHandler.CloseHandler(); + this.AudioAdapterHandler.CloseSession(); } private void checkBox1_CheckedChanged(object sender, EventArgs e) @@ -203,16 +215,22 @@ namespace SiMay.RemoteMonitor.Application private void checkBox2_CheckedChanged(object sender, EventArgs e) { - this._isRecord = checkBox2.Checked; if (checkBox2.Checked) - _fileStream = new FileStream(DateTime.Now.ToFileTime() + ".PCM", FileMode.CreateNew, FileAccess.ReadWrite, FileShare.ReadWrite); + { + var directory = Path.Combine(Environment.CurrentDirectory, AudioAdapterHandler.OriginName); + if (!Directory.Exists(directory)) + Directory.CreateDirectory(directory); + + var fileName = Path.Combine(directory, $"语音_{DateTime.Now.ToString("yyyy-MM-dd hh_mm_ss")}.wav"); + + _pcmStreamToWavHelper = new PCMStreamToWavHelper(fileName, _samplesPerSecond, _bitsPerSample, _channels, _dataBufferSize); + } else { - string name = _fileStream.Name; - _fileStream.Flush(); - _fileStream.Close(); - MessageBoxHelper.ShowBoxExclamation("录音已完成,文件位于:" + name); + _pcmStreamToWavHelper.Close(); + MessageBoxHelper.ShowBoxExclamation($"录音已完成,文件位于:{_pcmStreamToWavHelper.FileName}"); } + this._isRecord = checkBox2.Checked; } } } \ No newline at end of file diff --git a/SiMay.RemoteMonitor/Application/AudioConfigurationForm.cs b/SiMay.RemoteMonitor/Application/AudioConfigurationForm.cs index fc961b2e844676a0807896cada609efdd5d208ab..c29923b17847eb45c437b91d6bbed11811474fd8 100644 --- a/SiMay.RemoteMonitor/Application/AudioConfigurationForm.cs +++ b/SiMay.RemoteMonitor/Application/AudioConfigurationForm.cs @@ -20,18 +20,18 @@ namespace SiMay.RemoteMonitor.Application private void button1_Click(object sender, EventArgs e) { - AppConfiguration.AudioSamplesPerSecond = nSamplesPerSec.Text; - AppConfiguration.AudioBitsPerSample = wBitsPerSample.Text; - AppConfiguration.AudioChannels = nChannels.Text; + AppConfiguration.AudioSamplesPerSecond = int.Parse(nSamplesPerSec.Text); + AppConfiguration.AudioBitsPerSample = int.Parse(wBitsPerSample.Text); + AppConfiguration.AudioChannels = int.Parse(nChannels.Text); MessageBox.Show("设置保存成功,但设置需重新打开语音功能模块后才能生效。", "提示", 0, MessageBoxIcon.Exclamation); this.Close(); } private void AudioConfigurationManager_Load(object sender, EventArgs e) { - nSamplesPerSec.Text = AppConfiguration.AudioSamplesPerSecond; - wBitsPerSample.Text = AppConfiguration.AudioBitsPerSample; - nChannels.Text = AppConfiguration.AudioChannels; + nSamplesPerSec.Text = AppConfiguration.AudioSamplesPerSecond.ToString(); + wBitsPerSample.Text = AppConfiguration.AudioBitsPerSample.ToString(); + nChannels.Text = AppConfiguration.AudioChannels.ToString(); } } } diff --git a/SiMay.RemoteMonitor/Application/FileApplication.cs b/SiMay.RemoteMonitor/Application/FileApplication.cs index 46938eb789a6bee14341cc37bdfcbdbb65e783c3..407af22453a1334a16472f26f422d443099cb599 100644 --- a/SiMay.RemoteMonitor/Application/FileApplication.cs +++ b/SiMay.RemoteMonitor/Application/FileApplication.cs @@ -5,7 +5,6 @@ using SiMay.Core.Enums; using SiMay.Core.Packets; using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.HandlerAdapters; -using SiMay.RemoteControlsCore.Interface; using SiMay.RemoteMonitor.Application.FileCommon; using SiMay.RemoteMonitor.Attributes; using SiMay.RemoteMonitor.Enums; @@ -28,7 +27,7 @@ namespace SiMay.RemoteMonitor.Application [OnTools] [ApplicationName("文件管理")] [AppResourceName("FileManager")] - [Application(typeof(RemoteFileAdapterHandler), "FileManagerJob", 10)] + [Application(typeof(RemoteFileAdapterHandler), AppJobConstant.REMOTE_FILE, 10)] public partial class FileApplication : Form, IApplication { private const Int32 IDM_DIR_DESKTOP = 1000; @@ -62,32 +61,24 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) { this.Text = this._title + " [" + this.RemoteFileAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = this._title; } private void FileManager_Load(object sender, EventArgs e) { - this._closeTreeBtn = new Button(); - this._closeTreeBtn.Click += _closeTreeBtn_Click; - this._closeTreeBtn.Hide(); - this._closeTreeBtn.Text = "收起"; - this._closeTreeBtn.Height = 25; - this._closeTreeBtn.Width = 100; - this._remoteDirectoryTreeView = new TreeView(); - this._remoteDirectoryTreeView.ImageList = _imgList; - this._remoteDirectoryTreeView.ContextMenuStrip = this.treeContext; - this._remoteDirectoryTreeView.DoubleClick += remoteDirectoryTreeView_DoubleClick; - this._remoteDirectoryTreeView.Hide(); - this.Controls.Add(_remoteDirectoryTreeView); - this.Controls.Add(_closeTreeBtn); - this.Initialize(); + this.InitializeUI(); this.Text = this._title = this._title.Replace("#Name#", this.RemoteFileAdapterHandler.OriginName); this.RemoteFileAdapterHandler.OnRemoteExceptionEventHandler += OnRemoteExceptionEventHandler; @@ -102,7 +93,7 @@ namespace SiMay.RemoteMonitor.Application this.RemoteFileAdapterHandler.GetRemoteRootTreeItems(string.Empty); this.RemoteFileAdapterHandler.GetRemoteDriveItems(); } - private void Initialize() + private void InitializeUI() { string downPath = Path.Combine(Environment.CurrentDirectory, "download"); @@ -113,6 +104,20 @@ namespace SiMay.RemoteMonitor.Application this.fileList.SmallImageList = _imgList; this.fileList.LargeImageList = _imgList; + this._closeTreeBtn = new Button(); + this._closeTreeBtn.Click += _closeTreeBtn_Click; + this._closeTreeBtn.Hide(); + this._closeTreeBtn.Text = "收起"; + this._closeTreeBtn.Height = 25; + this._closeTreeBtn.Width = 100; + this._remoteDirectoryTreeView = new TreeView(); + this._remoteDirectoryTreeView.ImageList = _imgList; + this._remoteDirectoryTreeView.ContextMenuStrip = this.treeContext; + this._remoteDirectoryTreeView.DoubleClick += remoteDirectoryTreeView_DoubleClick; + this._remoteDirectoryTreeView.Hide(); + this.Controls.Add(_remoteDirectoryTreeView); + this.Controls.Add(_closeTreeBtn); + IntPtr sysMenuHandle = GetSystemMenu(this.Handle, false); int index = 7; @@ -257,7 +262,7 @@ namespace SiMay.RemoteMonitor.Application this.RemoteFileAdapterHandler.OnFileTransferProgressEventHandler -= OnFileTransferProgressEventHandler; this.RemoteFileAdapterHandler.OnDirectoryCreateFinishEventHandler -= OnDirectoryCreateFinishEventHandler; this.RemoteFileAdapterHandler.OnFileTreeItemsEventHandler -= OnFileTreeItemsEventHandler; - this.RemoteFileAdapterHandler.CloseHandler(); + this.RemoteFileAdapterHandler.CloseSession(); } private void 打开ToolStripMenuItem_Click(object sender, EventArgs e) @@ -582,7 +587,7 @@ namespace SiMay.RemoteMonitor.Application } if (this._transferMode == TransferMode.Cancel ||//选择取消传输 this.RemoteFileAdapterHandler.TransferTaskFlage == TransferTaskFlage.Abort ||//终止传输信号 - this.RemoteFileAdapterHandler.IsClose)//关闭应用 + this.RemoteFileAdapterHandler.WhetherClose)//关闭应用 break; } this.downloadMenuItem.Enabled = true; @@ -717,7 +722,7 @@ namespace SiMay.RemoteMonitor.Application private void OnFileTransferProgressEventHandler(RemoteFileAdapterHandler adapterHandler, FileTransferFlag state, string fileName, long position, long fileSize) { - if (this.RemoteFileAdapterHandler.IsClose)//UI未关闭时才允许操作控件 + if (this.RemoteFileAdapterHandler.WhetherClose)//UI未关闭时才允许操作控件 return; switch (state) diff --git a/SiMay.RemoteMonitor/Application/FileCommon/WindowsForFileStream.cs b/SiMay.RemoteMonitor/Application/FileCommon/WindowsForFileStream.cs index 2a866e5ecdf9eb214d1fb3cc296e8ca7bbf34522..a257c5762b29e0caca1f705d58a4ed6b496bb42e 100644 --- a/SiMay.RemoteMonitor/Application/FileCommon/WindowsForFileStream.cs +++ b/SiMay.RemoteMonitor/Application/FileCommon/WindowsForFileStream.cs @@ -1,4 +1,4 @@ -using SiMay.RemoteControlsCore.Interface; +using SiMay.RemoteControlsCore; using System; using System.Collections.Generic; using System.IO; diff --git a/SiMay.RemoteMonitor/Application/KeyboardApplication.cs b/SiMay.RemoteMonitor/Application/KeyboardApplication.cs index 5afd913a4386d2f72f4fc81e23fab2bf32b8afac..e64d7a7e4514ac0666d1ea992dd346cb039a8f2c 100644 --- a/SiMay.RemoteMonitor/Application/KeyboardApplication.cs +++ b/SiMay.RemoteMonitor/Application/KeyboardApplication.cs @@ -37,12 +37,17 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) { this.Text = _title + " [" + this.KeyboardAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = _title; } @@ -116,7 +121,7 @@ namespace SiMay.RemoteMonitor.Application { this.KeyboardAdapterHandler.OnKeyboardDataEventHandler -= OnKeyboardDataEventHandler; this.KeyboardAdapterHandler.OnOffLineKeyboradEventHandler -= OnOffLineKeyboradEventHandler; - this.KeyboardAdapterHandler.CloseHandler(); + this.KeyboardAdapterHandler.CloseSession(); } } } \ No newline at end of file diff --git a/SiMay.RemoteMonitor/Application/RegEditorApplication.cs b/SiMay.RemoteMonitor/Application/RegEditorApplication.cs index 249278911e7ae314dc49e083c3a9124bb783d56a..eb07beb3ed74d442e43d75917046bb9495eed690 100644 --- a/SiMay.RemoteMonitor/Application/RegEditorApplication.cs +++ b/SiMay.RemoteMonitor/Application/RegEditorApplication.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; using Microsoft.Win32; +using SiMay.Core; using SiMay.Core.Common; using SiMay.Core.Extensions; using SiMay.Core.Packets.RegEdit; @@ -17,7 +18,7 @@ namespace SiMay.RemoteMonitor.Application [OnTools] [ApplicationName("注册表管理")] [AppResourceName("RegEditManager")] - [Application(typeof(RegistryEditorAdapterHandler), "RemoteRegistryEditorJob", 50)] + [Application(typeof(RegistryEditorAdapterHandler), AppJobConstant.REMOTE_REGEDIT, 50)] public partial class RegEditorApplication : Form, IApplication { protected override CreateParams CreateParams @@ -43,12 +44,17 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) { this.Text = this._title + " [" + this.RegistryEditorAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = this._title; } @@ -79,7 +85,7 @@ namespace SiMay.RemoteMonitor.Application this.RegistryEditorAdapterHandler.OnValueDeletedEventHandler -= OnValueDeletedEventHandler; this.RegistryEditorAdapterHandler.OnValueRenamedEventHandler -= OnValueRenamedEventHandler; this.RegistryEditorAdapterHandler.OnValueChangedEventHandler -= OnValueChangedEventHandler; - this.RegistryEditorAdapterHandler.CloseHandler(); + this.RegistryEditorAdapterHandler.CloseSession(); } private void ShowErrorMessage(object sender, string errorMsg) diff --git a/SiMay.RemoteMonitor/Application/RegValueEditMultiStringForm.cs b/SiMay.RemoteMonitor/Application/RegValueEditMultiStringForm.cs index 26f2175887a56776e20adf4a76d4778a98d8f8e1..96952313995e1cc759df33e1e3351ecbe583d85d 100644 --- a/SiMay.RemoteMonitor/Application/RegValueEditMultiStringForm.cs +++ b/SiMay.RemoteMonitor/Application/RegValueEditMultiStringForm.cs @@ -16,12 +16,12 @@ namespace SiMay.RemoteMonitor.Application InitializeComponent(); this.valueNameTxtBox.Text = value.Name; - this.valueDataTxtBox.Text = string.Join("\r\n", ByteConverter.ToStringArray(value.Data)); + this.valueDataTxtBox.Text = string.Join("\r\n", ByteConverterHelper.ToStringArray(value.Data)); } private void okButton_Click(object sender, EventArgs e) { - _value.Data = ByteConverter.GetBytes(valueDataTxtBox.Text.Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries)); + _value.Data = ByteConverterHelper.GetBytes(valueDataTxtBox.Text.Split(new[] {"\r\n"}, StringSplitOptions.RemoveEmptyEntries)); this.Tag = _value; this.DialogResult = DialogResult.OK; this.Close(); diff --git a/SiMay.RemoteMonitor/Application/RegValueEditStringForm.cs b/SiMay.RemoteMonitor/Application/RegValueEditStringForm.cs index 06e5843b6fbd75c702f5d5c52291538cfb57ec79..bb5d02a788088b8a3da063b6c4ff54e0ef18e4a9 100644 --- a/SiMay.RemoteMonitor/Application/RegValueEditStringForm.cs +++ b/SiMay.RemoteMonitor/Application/RegValueEditStringForm.cs @@ -17,12 +17,12 @@ namespace SiMay.RemoteMonitor.Application InitializeComponent(); this.valueNameTxtBox.Text = RegValueHelper.GetName(value.Name); - this.valueDataTxtBox.Text = ByteConverter.ToString(value.Data); + this.valueDataTxtBox.Text = ByteConverterHelper.ToString(value.Data); } private void okButton_Click(object sender, EventArgs e) { - _value.Data = ByteConverter.GetBytes(valueDataTxtBox.Text); + _value.Data = ByteConverterHelper.GetBytes(valueDataTxtBox.Text); this.Tag = _value; this.DialogResult = DialogResult.OK; this.Close(); diff --git a/SiMay.RemoteMonitor/Application/RegValueEditWordForm.cs b/SiMay.RemoteMonitor/Application/RegValueEditWordForm.cs index 8418d4ca6a8ab2bd7bfe1077016f8ae6e4883953..266109cf88a0fc1b6fb4cf69cdc48bffc3b292d3 100644 --- a/SiMay.RemoteMonitor/Application/RegValueEditWordForm.cs +++ b/SiMay.RemoteMonitor/Application/RegValueEditWordForm.cs @@ -26,13 +26,13 @@ namespace SiMay.RemoteMonitor.Application { this.Text = "Edit DWORD (32-bit) Value"; this.valueDataTxtBox.Type = WordType.DWORD; - this.valueDataTxtBox.Text = ByteConverter.ToUInt32(value.Data).ToString("x"); + this.valueDataTxtBox.Text = ByteConverterHelper.ToUInt32(value.Data).ToString("x"); } else { this.Text = "Edit QWORD (64-bit) Value"; this.valueDataTxtBox.Type = WordType.QWORD; - this.valueDataTxtBox.Text = ByteConverter.ToUInt64(value.Data).ToString("x"); + this.valueDataTxtBox.Text = ByteConverterHelper.ToUInt64(value.Data).ToString("x"); } } @@ -52,8 +52,8 @@ namespace SiMay.RemoteMonitor.Application if (valueDataTxtBox.IsConversionValid() || IsOverridePossible()) { _value.Data = _value.Kind == RegistryValueKind.DWord - ? ByteConverter.GetBytes(valueDataTxtBox.UIntValue) - : ByteConverter.GetBytes(valueDataTxtBox.ULongValue); + ? ByteConverterHelper.GetBytes(valueDataTxtBox.UIntValue) + : ByteConverterHelper.GetBytes(valueDataTxtBox.ULongValue); this.Tag = _value; this.DialogResult = DialogResult.OK; } diff --git a/SiMay.RemoteMonitor/Application/ScreenApplication.cs b/SiMay.RemoteMonitor/Application/ScreenApplication.cs index 39940a8e22cdf32773bd3f046930d111c812c0c4..6cebe01eec58268d218f4f3f1ee23f2f2b14f00a 100644 --- a/SiMay.RemoteMonitor/Application/ScreenApplication.cs +++ b/SiMay.RemoteMonitor/Application/ScreenApplication.cs @@ -10,17 +10,21 @@ using System.Windows.Forms; using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.Enum; using SiMay.RemoteMonitor.MainApplication; -using SiMay.Net.SessionProvider.SessionBased; using SiMay.RemoteControlsCore.HandlerAdapters; using static SiMay.RemoteMonitor.Win32Api; -using static SiMay.Serialize.PacketSerializeHelper; +using static SiMay.Serialize.Standard.PacketSerializeHelper; +using System.Diagnostics; +using Accord.Video.FFMPEG; +using System.Threading; +using System.Threading.Tasks; +using SiMay.Core.ScreenSpy.Entitys; namespace SiMay.RemoteMonitor.Application { [OnTools] [ApplicationName("远程桌面")] [AppResourceName("ScreenManager")] - [Application(typeof(RemoteScreenAdapterHandler), "RemoteDesktopJob", 0)] + [Application(typeof(RemoteScreenAdapterHandler), AppJobConstant.REMOTE_DESKTOP, 0)] public partial class ScreenApplication : Form, IApplication { private const Int32 IDM_SCREENMON = 1000; @@ -40,6 +44,7 @@ namespace SiMay.RemoteMonitor.Application private const Int32 IDM_CTRL_ALT_DEL = 1014; private const Int32 IDM_DELETE_WALLPAPER = 1015; private const Int32 IDM_CHANGE_MONITOR = 1016; + private const Int32 IDM_RECORD = 1017; [ApplicationAdapterHandler] public RemoteScreenAdapterHandler RemoteScreenAdapterHandler { get; set; } @@ -58,9 +63,14 @@ namespace SiMay.RemoteMonitor.Application private int _currenMonitorIndex = 0; private MonitorItem[] _monitorItems; - private Bitmap _image; - private Timer _timer; + private Graphics _currentFrameGraphics; + private Graphics _videoFrameGraphics; + private Bitmap _currentFrame; + private Bitmap _videoFrame; + private System.Windows.Forms.Timer _timer; + private bool _stop = true; + private int _menuContextIndex; public ScreenApplication() { InitializeComponent(); @@ -70,13 +80,19 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + + public void SessionClose(ApplicationAdapterHandler handler) { _timer.Stop(); this.Text = this._title.FormatTo(0, (_traffic / (float)1024).ToString("0.00")) + " [" + this.RemoteScreenAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { _continueTask = true; _timer.Start(); @@ -110,104 +126,25 @@ namespace SiMay.RemoteMonitor.Application InsertMenu(sysMenuHandle, index++, MF_BYPOSITION, IDM_CHANGE_MONITOR, "监视器设置"); InsertMenu(sysMenuHandle, index++, MF_BYPOSITION, IDM_CTRL_ALT_DEL, "Ctrl + Alt + Del"); + _menuContextIndex = index++; + InsertMenu(sysMenuHandle, _menuContextIndex, MF_BYPOSITION, IDM_RECORD, "开始录制"); + CheckMenuItem(sysMenuHandle, IDM_FULL_SCREEN, MF_CHECKED); CheckMenuItem(sysMenuHandle, IDM_FULL_DIFFER, MF_CHECKED); CheckMenuItem(sysMenuHandle, IDM_16X, MF_CHECKED); - _timer = new Timer(); + _timer = new System.Windows.Forms.Timer(); _timer.Interval = 1000; _timer.Tick += Timer_Tick; _timer.Start(); this.Text = string.Format(this._title = this._title.Replace("#Name#", this.RemoteScreenAdapterHandler.OriginName), "0", "0.0"); - this.RemoteScreenAdapterHandler.Session.Socket.NoDelay = false; this.RemoteScreenAdapterHandler.OnClipoardReceivedEventHandler += OnClipoardReceivedEventHandler; this.RemoteScreenAdapterHandler.OnServcieInitEventHandler += OnServcieInitEventHandler; this.RemoteScreenAdapterHandler.OnScreenFragmentEventHandler += OnScreenFragmentEventHandler; this.RemoteScreenAdapterHandler.GetInitializeBitInfo(); } - private void OnServcieInitEventHandler(RemoteScreenAdapterHandler adapterHandler, int height, int width, int currentMonitorIndex, MonitorItem[] monitorItems) - { - this._currenMonitorIndex = currentMonitorIndex; - this._monitorItems = monitorItems; - this._srcImageWidth = width; - this._srcImageHeight = height; - _image = new Bitmap(width, height); - Graphics g = Graphics.FromImage(_image); - g.Clear(Color.Black); - g.DrawString("桌面加载中...", new Font("微软雅黑", 15, FontStyle.Regular), new SolidBrush(Color.Red), new Point((height / 2) - 40, width / 2)); - g.Dispose(); - this.StartGetScreen(); - } - - private void OnScreenFragmentEventHandler(RemoteScreenAdapterHandler adapterHandler, Core.ScreenSpy.Entitys.Fragment[] fragments, ScreenReceivedType type) - { - switch (type) - { - case ScreenReceivedType.Noninterlaced: - foreach (var fragment in fragments) - { - using (MemoryStream ms = new MemoryStream(fragment.FragmentData)) - { - this.DisplayScreen(Image.FromStream(ms), new Rectangle(fragment.X, fragment.Y, fragment.Width, fragment.Height)); - _traffic += ms.Length; - } - } - _recvImgCount++; - this.GetNextScreen(); - break; - case ScreenReceivedType.Difference: - - foreach (var fragment in fragments) - { - using (MemoryStream ms = new MemoryStream(fragment.FragmentData)) - { - this.DisplayScreen(Image.FromStream(ms), new Rectangle(fragment.X, fragment.Y, fragment.Width, fragment.Height)); - _traffic += ms.Length; - } - } - break; - case ScreenReceivedType.DifferenceEnd: - _recvImgCount++; - this.GetNextScreen(); - break; - default: - break; - } - } - - private void StartGetScreen() - { - if (_screenDisplayMode == ScreenDisplayMode.Fullscreen) - this.RemoteScreenAdapterHandler.StartGetScreen(this._image.Height, this._image.Width, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), this._screenDisplayMode); - else - this.RemoteScreenAdapterHandler.StartGetScreen(this.ClientSize.Height, this.ClientSize.Width, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), this._screenDisplayMode); - } - - private void GetNextScreen() - { - if (_screenDisplayMode == ScreenDisplayMode.Fullscreen) - this.RemoteScreenAdapterHandler.GetNextScreen(this._image.Height, this._image.Width, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), this._screenDisplayMode); - else - this.RemoteScreenAdapterHandler.GetNextScreen(this.ClientSize.Height, this.ClientSize.Width, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), this._screenDisplayMode); - } - - private void OnClipoardReceivedEventHandler(RemoteScreenAdapterHandler adapterHandler, string text) - { - Clipboard.SetText(text); - MessageBoxHelper.ShowBoxExclamation("已获取剪切板内容!"); - } - - private void Timer_Tick(object sender, EventArgs e) - { - if (_continueTask) - { - this.Text = string.Format(_title, _recvImgCount.ToString(), (_traffic / (float)1024).ToString("0.00")); - _recvImgCount = 0; - } - } - protected override void WndProc(ref Message m) { if (m.Msg == WM_SYSCOMMAND) @@ -350,21 +287,156 @@ namespace SiMay.RemoteMonitor.Application case IDM_DELETE_WALLPAPER: this.RemoteScreenAdapterHandler.RemoteDeleteWallPaper(); break; + case IDM_RECORD: + if (_stop) + { + if (_srcImageHeight == 0 || _srcImageWidth == 0) + return; + if (!_videoFrameGraphics.IsNull()) + _videoFrameGraphics.Dispose(); + if (!_videoFrame.IsNull()) + _videoFrame.Dispose(); + lock (this) + { + _videoFrame = new Bitmap(this._srcImageWidth, this._srcImageHeight); + _videoFrameGraphics = Graphics.FromImage(_videoFrame); + _videoFrameGraphics.DrawImage(_currentFrame, 0, 0); + } + _stop = false; + ModifyMenu(sysMenuHandle, _menuContextIndex, MF_BYPOSITION, IDM_RECORD, "停止录制"); + Task.Run(CreateDesktopRecordThread); + } + else + { + _stop = true; + ModifyMenu(sysMenuHandle, _menuContextIndex, MF_BYPOSITION, IDM_RECORD, "开始录制"); + } + break; } } base.WndProc(ref m); } - private void DisplayScreen(Image bit, Rectangle rect) + private void OnServcieInitEventHandler(RemoteScreenAdapterHandler adapterHandler, int height, int width, int currentMonitorIndex, MonitorItem[] monitorItems) { - if (this.RemoteScreenAdapterHandler.IsClose) - return; + if (!_videoFrameGraphics.IsNull()) + _videoFrameGraphics.Dispose(); + + this._currenMonitorIndex = currentMonitorIndex; + this._monitorItems = monitorItems; + this._srcImageWidth = width; + this._srcImageHeight = height; + + _currentFrame = new Bitmap(width, height); + _currentFrameGraphics = Graphics.FromImage(_currentFrame); - Graphics g = Graphics.FromImage(_image); - g.DrawImage(bit, rect); + Graphics g = Graphics.FromImage(_currentFrame); + g.Clear(Color.Black); + g.DrawString("桌面加载中...", new Font("微软雅黑", 15, FontStyle.Regular), new SolidBrush(Color.Red), new Point((height / 2) - 40, width / 2)); g.Dispose(); - bit.Dispose(); - imgDesktop.Image = _image; + this.StartGetScreen(); + } + + private void OnScreenFragmentEventHandler(RemoteScreenAdapterHandler adapterHandler, Fragment[] fragments, ScreenReceivedType type) + { + switch (type) + { + case ScreenReceivedType.Noninterlaced: + this.FrameDataHandler(fragments); + _recvImgCount++; + this.GetNextScreen(); + break; + case ScreenReceivedType.Difference: + this.FrameDataHandler(fragments); + break; + case ScreenReceivedType.DifferenceEnd: + _recvImgCount++; + this.GetNextScreen(); + break; + default: + break; + } + this.imgDesktop.Image = this._currentFrame; + } + + private void FrameDataHandler(Fragment[] fragments) + { + if (this.RemoteScreenAdapterHandler.WhetherClose) + return; + lock (this) + { + foreach (var fragment in fragments) + { + using (MemoryStream ms = new MemoryStream(fragment.FragmentData)) + { + var rect = new Rectangle(fragment.X, fragment.Y, fragment.Width, fragment.Height); + var childFrame = Image.FromStream(ms); + + this._currentFrameGraphics.DrawImage(childFrame, rect); + + if (!_stop) + this._videoFrameGraphics.DrawImage(childFrame, rect); + + childFrame.Dispose(); + _traffic += ms.Length; + } + } + } + } + + private void StartGetScreen() + { + //if (_screenDisplayMode == ScreenDisplayMode.Fullscreen) + this.RemoteScreenAdapterHandler.StartGetScreen(this._srcImageHeight, this._srcImageWidth, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), ScreenDisplayMode.Original); + //else + // this.RemoteScreenAdapterHandler.StartGetScreen(this.ClientSize.Height, this.ClientSize.Width, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), this._screenDisplayMode); + } + + private void GetNextScreen() + { + //if (_screenDisplayMode == ScreenDisplayMode.Fullscreen) + this.RemoteScreenAdapterHandler.GetNextScreen(this._srcImageHeight, this._srcImageWidth, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), ScreenDisplayMode.Original); + //else + // this.RemoteScreenAdapterHandler.GetNextScreen(this.ClientSize.Height, this.ClientSize.Width, Math.Abs(this.imgDesktop.Left), Math.Abs(this.imgDesktop.Top), this._screenDisplayMode); + } + + private void OnClipoardReceivedEventHandler(RemoteScreenAdapterHandler adapterHandler, string text) + { + Clipboard.SetText(text); + MessageBoxHelper.ShowBoxExclamation("已获取剪切板内容!"); + } + + private void Timer_Tick(object sender, EventArgs e) + { + if (_continueTask) + { + this.Text = string.Format(_title, _recvImgCount.ToString(), (_traffic / (float)1024).ToString("0.00")); + _recvImgCount = 0; + } + } + + private async void CreateDesktopRecordThread() + { + var targetDirectory = Path.Combine(Environment.CurrentDirectory, RemoteScreenAdapterHandler.OriginName); + if (!Directory.Exists(targetDirectory)) + Directory.CreateDirectory(targetDirectory); + + var fileName = Path.Combine(targetDirectory, $"远程桌面_{RemoteScreenAdapterHandler.OriginName}_{DateTime.Now.ToString("yyyy-MM-dd hhmmss")}.avi"); + + var videoWriter = new VideoFileWriter(); + videoWriter.Open(fileName, _srcImageWidth, _srcImageHeight, 10, VideoCodec.H264); + + while (!_stop) + { + if (_videoFrame.IsNull()) + continue; + + lock (this) + videoWriter.WriteVideoFrame(_videoFrame); + GC.Collect(); + await Task.Delay(100); //帧率控制,每秒10帧,防止写入过快 + } + videoWriter.Close(); } private void ScreenSpyForm_KeyDown(object sender, KeyEventArgs e) @@ -457,12 +529,13 @@ namespace SiMay.RemoteMonitor.Application private void ScreenSpyForm_FormClosing(object sender, FormClosingEventArgs e) { + _stop = true; _timer.Stop(); _timer.Dispose(); this.RemoteScreenAdapterHandler.OnClipoardReceivedEventHandler -= OnClipoardReceivedEventHandler; this.RemoteScreenAdapterHandler.OnServcieInitEventHandler -= OnServcieInitEventHandler; this.RemoteScreenAdapterHandler.OnScreenFragmentEventHandler -= OnScreenFragmentEventHandler; - this.RemoteScreenAdapterHandler.CloseHandler(); + this.RemoteScreenAdapterHandler.CloseSession(); } private void m_desktop_MouseMove(object sender, MouseEventArgs e) diff --git a/SiMay.RemoteMonitor/Application/ShellApplication.cs b/SiMay.RemoteMonitor/Application/ShellApplication.cs index 6803b18b35f7b4555a7b0a4eaf06b04dd1f4139a..0e35993f4277c141919e0da95d17f6853088e5d5 100644 --- a/SiMay.RemoteMonitor/Application/ShellApplication.cs +++ b/SiMay.RemoteMonitor/Application/ShellApplication.cs @@ -1,4 +1,5 @@ -using SiMay.RemoteControlsCore; +using SiMay.Core; +using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.HandlerAdapters; using SiMay.RemoteMonitor.Attributes; using System; @@ -10,7 +11,7 @@ namespace SiMay.RemoteMonitor.Application [OnTools] [ApplicationName("远程终端")] [AppResourceName("ShellManager")] - [Application(typeof(ShellAdapterHandler), "RemoteShellJob", 60)] + [Application(typeof(ShellAdapterHandler), AppJobConstant.REMOTE_SHELL, 60)] public partial class ShellApplication : Form, IApplication { @@ -30,12 +31,17 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) { this.Text = _title + " [" + this.ShellAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = _title; } @@ -66,7 +72,7 @@ namespace SiMay.RemoteMonitor.Application private void ShellForm_FormClosing(object sender, FormClosingEventArgs e) { this.ShellAdapterHandler.OnOutputCommandEventHandler -= OnOutputCommandEventHandler; - this.ShellAdapterHandler.CloseHandler(); + this.ShellAdapterHandler.CloseSession(); } private void textBox1_KeyPress(object sender, KeyPressEventArgs e) diff --git a/SiMay.RemoteMonitor/Application/StartupApplication.cs b/SiMay.RemoteMonitor/Application/StartupApplication.cs index b8a5e7c405a40240ed7891bd8d563e233a3ed3cb..da6b1cb1bf5c7802ed84eb4191f980515b6f4545 100644 --- a/SiMay.RemoteMonitor/Application/StartupApplication.cs +++ b/SiMay.RemoteMonitor/Application/StartupApplication.cs @@ -1,4 +1,5 @@ -using SiMay.Core.Enums; +using SiMay.Core; +using SiMay.Core.Enums; using SiMay.Core.Packets.Startup; using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.HandlerAdapters; @@ -16,7 +17,7 @@ using System.Windows.Forms; namespace SiMay.RemoteMonitor.Application { [ApplicationName("启动项管理")] - [Application(typeof(StartupAdapterHandler), "StartupManagerJob", 100)] + [Application(typeof(StartupAdapterHandler), AppJobConstant.REMOTE_STARTUP, 100)] public partial class StartupApplication : Form, IApplication { [ApplicationAdapterHandler] @@ -35,12 +36,17 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) { this.Text = _title + " [" + this.StartupAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = _title; } @@ -109,7 +115,7 @@ namespace SiMay.RemoteMonitor.Application private void StartupManager_FormClosing(object sender, FormClosingEventArgs e) { this.StartupAdapterHandler.OnStartupItemHandlerEvent -= OnStartupItemHandlerEvent; - this.StartupAdapterHandler.CloseHandler(); + this.StartupAdapterHandler.CloseSession(); } } } diff --git a/SiMay.RemoteMonitor/Application/SystemApplication.Designer.cs b/SiMay.RemoteMonitor/Application/SystemApplication.Designer.cs index 0eb7077138f1e315edc0451d2f1888ddcb83f559..35b0143e1564ffc6be52f3530cb2914a10b88556 100644 --- a/SiMay.RemoteMonitor/Application/SystemApplication.Designer.cs +++ b/SiMay.RemoteMonitor/Application/SystemApplication.Designer.cs @@ -36,12 +36,9 @@ namespace SiMay.RemoteMonitor.Application this.button4 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.button2 = new System.Windows.Forms.Button(); - this.processList = new SiMay.RemoteMonitor.UserControls.UListView(); this.tabPage3 = new System.Windows.Forms.TabPage(); + this.button1 = new System.Windows.Forms.Button(); this.tabPage2 = new System.Windows.Forms.TabPage(); - this.systemInfoList = new SiMay.RemoteMonitor.UserControls.UListView(); - this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.menuStrip1 = new System.Windows.Forms.MenuStrip(); this.文件ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.关闭窗口ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -59,13 +56,16 @@ namespace SiMay.RemoteMonitor.Application this.toolStripStatusLabel2 = new System.Windows.Forms.ToolStripStatusLabel(); this.moryUse = new System.Windows.Forms.ToolStripStatusLabel(); this.refreshTimer = new System.Windows.Forms.Timer(this.components); + this.processList = new SiMay.RemoteMonitor.UserControls.UListView(); this.sessionsListView = new SiMay.RemoteMonitor.UserControls.UListView(); this.userName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.sessionId = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.state = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.windowsStationName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.userProcessCreated = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); - this.button1 = new System.Windows.Forms.Button(); + this.systemInfoList = new SiMay.RemoteMonitor.UserControls.UListView(); + this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); + this.columnHeader2 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.tabControl1.SuspendLayout(); this.tabPage1.SuspendLayout(); this.tabPage3.SuspendLayout(); @@ -82,10 +82,11 @@ namespace SiMay.RemoteMonitor.Application this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Controls.Add(this.tabPage3); this.tabControl1.Controls.Add(this.tabPage2); - this.tabControl1.Location = new System.Drawing.Point(7, 29); + this.tabControl1.Location = new System.Drawing.Point(9, 36); + this.tabControl1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(616, 430); + this.tabControl1.Size = new System.Drawing.Size(821, 538); this.tabControl1.TabIndex = 0; // // tabPage1 @@ -95,19 +96,21 @@ namespace SiMay.RemoteMonitor.Application this.tabPage1.Controls.Add(this.button3); this.tabPage1.Controls.Add(this.button2); this.tabPage1.Controls.Add(this.processList); - this.tabPage1.Location = new System.Drawing.Point(4, 22); + this.tabPage1.Location = new System.Drawing.Point(4, 25); + this.tabPage1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(3); - this.tabPage1.Size = new System.Drawing.Size(608, 404); + this.tabPage1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tabPage1.Size = new System.Drawing.Size(813, 509); this.tabPage1.TabIndex = 0; this.tabPage1.Text = "进程管理"; // // button4 // this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button4.Location = new System.Drawing.Point(319, 370); + this.button4.Location = new System.Drawing.Point(425, 462); + this.button4.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(88, 24); + this.button4.Size = new System.Drawing.Size(117, 30); this.button4.TabIndex = 14; this.button4.Text = "最小化"; this.button4.UseVisualStyleBackColor = true; @@ -116,9 +119,10 @@ namespace SiMay.RemoteMonitor.Application // button3 // this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button3.Location = new System.Drawing.Point(413, 370); + this.button3.Location = new System.Drawing.Point(551, 462); + this.button3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(88, 24); + this.button3.Size = new System.Drawing.Size(117, 30); this.button3.TabIndex = 13; this.button3.Text = "最大化"; this.button3.UseVisualStyleBackColor = true; @@ -127,92 +131,61 @@ namespace SiMay.RemoteMonitor.Application // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.Location = new System.Drawing.Point(507, 370); + this.button2.Location = new System.Drawing.Point(676, 462); + this.button2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(88, 24); + this.button2.Size = new System.Drawing.Size(117, 30); this.button2.TabIndex = 12; this.button2.Text = "结束进程"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // - // processList - // - this.processList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.processList.BackColor = System.Drawing.SystemColors.ControlLightLight; - this.processList.CheckBoxes = true; - this.processList.FullRowSelect = true; - this.processList.HideSelection = false; - this.processList.Location = new System.Drawing.Point(13, 14); - this.processList.Name = "processList"; - this.processList.Size = new System.Drawing.Size(582, 351); - this.processList.TabIndex = 11; - this.processList.UseCompatibleStateImageBehavior = false; - this.processList.UseWindowsThemStyle = true; - this.processList.View = System.Windows.Forms.View.Details; - // // tabPage3 // this.tabPage3.Controls.Add(this.button1); this.tabPage3.Controls.Add(this.sessionsListView); - this.tabPage3.Location = new System.Drawing.Point(4, 22); + this.tabPage3.Location = new System.Drawing.Point(4, 25); + this.tabPage3.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.tabPage3.Name = "tabPage3"; - this.tabPage3.Padding = new System.Windows.Forms.Padding(3); - this.tabPage3.Size = new System.Drawing.Size(608, 404); + this.tabPage3.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tabPage3.Size = new System.Drawing.Size(813, 509); this.tabPage3.TabIndex = 2; this.tabPage3.Text = "会话管理"; this.tabPage3.UseVisualStyleBackColor = true; // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(676, 461); + this.button1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(117, 30); + this.button1.TabIndex = 13; + this.button1.Text = "创建用户进程"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // // tabPage2 // this.tabPage2.BackColor = System.Drawing.SystemColors.ButtonHighlight; this.tabPage2.Controls.Add(this.systemInfoList); - this.tabPage2.Location = new System.Drawing.Point(4, 22); + this.tabPage2.Location = new System.Drawing.Point(4, 25); + this.tabPage2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(3); - this.tabPage2.Size = new System.Drawing.Size(608, 404); + this.tabPage2.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4); + this.tabPage2.Size = new System.Drawing.Size(813, 509); this.tabPage2.TabIndex = 1; this.tabPage2.Text = "系统信息"; // - // systemInfoList - // - this.systemInfoList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.systemInfoList.BackColor = System.Drawing.SystemColors.ButtonHighlight; - this.systemInfoList.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.systemInfoList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeader1, - this.columnHeader2}); - this.systemInfoList.FullRowSelect = true; - this.systemInfoList.HideSelection = false; - this.systemInfoList.Location = new System.Drawing.Point(6, 6); - this.systemInfoList.Name = "systemInfoList"; - this.systemInfoList.Size = new System.Drawing.Size(596, 395); - this.systemInfoList.TabIndex = 12; - this.systemInfoList.UseCompatibleStateImageBehavior = false; - this.systemInfoList.UseWindowsThemStyle = true; - this.systemInfoList.View = System.Windows.Forms.View.Details; - // - // columnHeader1 - // - this.columnHeader1.Text = "信息项"; - this.columnHeader1.Width = 150; - // - // columnHeader2 - // - this.columnHeader2.Text = "值"; - this.columnHeader2.Width = 300; - // // menuStrip1 // + this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.文件ToolStripMenuItem, this.刷新信息ToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; - this.menuStrip1.Size = new System.Drawing.Size(629, 25); + this.menuStrip1.Size = new System.Drawing.Size(1049, 38); this.menuStrip1.TabIndex = 1; this.menuStrip1.Text = "menuStrip1"; // @@ -221,13 +194,13 @@ namespace SiMay.RemoteMonitor.Application this.文件ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.关闭窗口ToolStripMenuItem}); this.文件ToolStripMenuItem.Name = "文件ToolStripMenuItem"; - this.文件ToolStripMenuItem.Size = new System.Drawing.Size(44, 21); + this.文件ToolStripMenuItem.Size = new System.Drawing.Size(53, 34); this.文件ToolStripMenuItem.Text = "文件"; // // 关闭窗口ToolStripMenuItem // this.关闭窗口ToolStripMenuItem.Name = "关闭窗口ToolStripMenuItem"; - this.关闭窗口ToolStripMenuItem.Size = new System.Drawing.Size(124, 22); + this.关闭窗口ToolStripMenuItem.Size = new System.Drawing.Size(152, 26); this.关闭窗口ToolStripMenuItem.Text = "关闭窗口"; this.关闭窗口ToolStripMenuItem.Click += new System.EventHandler(this.关闭窗口ToolStripMenuItem_Click); // @@ -237,13 +210,13 @@ namespace SiMay.RemoteMonitor.Application this.立即刷新ToolStripMenuItem, this.更新速度ToolStripMenuItem}); this.刷新信息ToolStripMenuItem.Name = "刷新信息ToolStripMenuItem"; - this.刷新信息ToolStripMenuItem.Size = new System.Drawing.Size(44, 21); + this.刷新信息ToolStripMenuItem.Size = new System.Drawing.Size(53, 34); this.刷新信息ToolStripMenuItem.Text = "选项"; // // 立即刷新ToolStripMenuItem // this.立即刷新ToolStripMenuItem.Name = "立即刷新ToolStripMenuItem"; - this.立即刷新ToolStripMenuItem.Size = new System.Drawing.Size(124, 22); + this.立即刷新ToolStripMenuItem.Size = new System.Drawing.Size(152, 26); this.立即刷新ToolStripMenuItem.Text = "立即刷新"; this.立即刷新ToolStripMenuItem.Click += new System.EventHandler(this.立即刷新ToolStripMenuItem_Click); // @@ -255,13 +228,13 @@ namespace SiMay.RemoteMonitor.Application this.低ToolStripMenuItem, this.暂停ToolStripMenuItem}); this.更新速度ToolStripMenuItem.Name = "更新速度ToolStripMenuItem"; - this.更新速度ToolStripMenuItem.Size = new System.Drawing.Size(124, 22); + this.更新速度ToolStripMenuItem.Size = new System.Drawing.Size(152, 26); this.更新速度ToolStripMenuItem.Text = "更新速度"; // // 高ToolStripMenuItem // this.高ToolStripMenuItem.Name = "高ToolStripMenuItem"; - this.高ToolStripMenuItem.Size = new System.Drawing.Size(100, 22); + this.高ToolStripMenuItem.Size = new System.Drawing.Size(122, 26); this.高ToolStripMenuItem.Text = "高"; this.高ToolStripMenuItem.Click += new System.EventHandler(this.高ToolStripMenuItem_Click); // @@ -270,68 +243,70 @@ namespace SiMay.RemoteMonitor.Application this.正常ToolStripMenuItem.Checked = true; this.正常ToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.正常ToolStripMenuItem.Name = "正常ToolStripMenuItem"; - this.正常ToolStripMenuItem.Size = new System.Drawing.Size(100, 22); + this.正常ToolStripMenuItem.Size = new System.Drawing.Size(122, 26); this.正常ToolStripMenuItem.Text = "正常"; this.正常ToolStripMenuItem.Click += new System.EventHandler(this.正常ToolStripMenuItem_Click); // // 低ToolStripMenuItem // this.低ToolStripMenuItem.Name = "低ToolStripMenuItem"; - this.低ToolStripMenuItem.Size = new System.Drawing.Size(100, 22); + this.低ToolStripMenuItem.Size = new System.Drawing.Size(122, 26); this.低ToolStripMenuItem.Text = "低"; this.低ToolStripMenuItem.Click += new System.EventHandler(this.低ToolStripMenuItem_Click); // // 暂停ToolStripMenuItem // this.暂停ToolStripMenuItem.Name = "暂停ToolStripMenuItem"; - this.暂停ToolStripMenuItem.Size = new System.Drawing.Size(100, 22); + this.暂停ToolStripMenuItem.Size = new System.Drawing.Size(122, 26); this.暂停ToolStripMenuItem.Text = "暂停"; this.暂停ToolStripMenuItem.Click += new System.EventHandler(this.暂停ToolStripMenuItem_Click); // // statusStrip1 // + this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripStatusLabel1, this.m_proNum, this.cpuUse, this.toolStripStatusLabel2, this.moryUse}); - this.statusStrip1.Location = new System.Drawing.Point(0, 460); + this.statusStrip1.Location = new System.Drawing.Point(0, 578); this.statusStrip1.Name = "statusStrip1"; + this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 19, 0); this.statusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode; - this.statusStrip1.Size = new System.Drawing.Size(629, 26); + this.statusStrip1.Size = new System.Drawing.Size(839, 30); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // // toolStripStatusLabel1 // this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(47, 21); + this.toolStripStatusLabel1.Size = new System.Drawing.Size(58, 24); this.toolStripStatusLabel1.Text = "进程数:"; // // m_proNum // this.m_proNum.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Right; this.m_proNum.Name = "m_proNum"; - this.m_proNum.Size = new System.Drawing.Size(19, 21); + this.m_proNum.Size = new System.Drawing.Size(22, 24); this.m_proNum.Text = "0"; // // cpuUse // this.cpuUse.Name = "cpuUse"; - this.cpuUse.Size = new System.Drawing.Size(93, 21); + this.cpuUse.Size = new System.Drawing.Size(114, 24); this.cpuUse.Text = "CPU 使用率:0%"; // // toolStripStatusLabel2 // this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; - this.toolStripStatusLabel2.Size = new System.Drawing.Size(359, 21); + this.toolStripStatusLabel2.Size = new System.Drawing.Size(504, 24); this.toolStripStatusLabel2.Spring = true; // // moryUse // this.moryUse.Name = "moryUse"; - this.moryUse.Size = new System.Drawing.Size(96, 21); + this.moryUse.Size = new System.Drawing.Size(121, 24); this.moryUse.Text = "内存:1024/1024"; // // refreshTimer @@ -340,6 +315,24 @@ namespace SiMay.RemoteMonitor.Application this.refreshTimer.Interval = 1500; this.refreshTimer.Tick += new System.EventHandler(this.RefreshTimer_Tick); // + // processList + // + this.processList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.processList.BackColor = System.Drawing.SystemColors.ControlLightLight; + this.processList.CheckBoxes = true; + this.processList.FullRowSelect = true; + this.processList.HideSelection = false; + this.processList.Location = new System.Drawing.Point(17, 18); + this.processList.Margin = new System.Windows.Forms.Padding(4); + this.processList.Name = "processList"; + this.processList.Size = new System.Drawing.Size(775, 438); + this.processList.TabIndex = 11; + this.processList.UseCompatibleStateImageBehavior = false; + this.processList.UseWindowsThemStyle = true; + this.processList.View = System.Windows.Forms.View.Details; + // // sessionsListView // this.sessionsListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) @@ -355,9 +348,10 @@ namespace SiMay.RemoteMonitor.Application this.userProcessCreated}); this.sessionsListView.FullRowSelect = true; this.sessionsListView.HideSelection = false; - this.sessionsListView.Location = new System.Drawing.Point(13, 14); + this.sessionsListView.Location = new System.Drawing.Point(17, 18); + this.sessionsListView.Margin = new System.Windows.Forms.Padding(4); this.sessionsListView.Name = "sessionsListView"; - this.sessionsListView.Size = new System.Drawing.Size(582, 349); + this.sessionsListView.Size = new System.Drawing.Size(775, 435); this.sessionsListView.TabIndex = 12; this.sessionsListView.UseCompatibleStateImageBehavior = false; this.sessionsListView.UseWindowsThemStyle = true; @@ -388,26 +382,47 @@ namespace SiMay.RemoteMonitor.Application this.userProcessCreated.Text = "被控用户进程"; this.userProcessCreated.Width = 100; // - // button1 + // systemInfoList // - this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(507, 369); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(88, 24); - this.button1.TabIndex = 13; - this.button1.Text = "创建用户进程"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); + this.systemInfoList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.systemInfoList.BackColor = System.Drawing.SystemColors.ButtonHighlight; + this.systemInfoList.BorderStyle = System.Windows.Forms.BorderStyle.None; + this.systemInfoList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { + this.columnHeader1, + this.columnHeader2}); + this.systemInfoList.FullRowSelect = true; + this.systemInfoList.HideSelection = false; + this.systemInfoList.Location = new System.Drawing.Point(8, 8); + this.systemInfoList.Margin = new System.Windows.Forms.Padding(4); + this.systemInfoList.Name = "systemInfoList"; + this.systemInfoList.Size = new System.Drawing.Size(795, 494); + this.systemInfoList.TabIndex = 12; + this.systemInfoList.UseCompatibleStateImageBehavior = false; + this.systemInfoList.UseWindowsThemStyle = true; + this.systemInfoList.View = System.Windows.Forms.View.Details; + // + // columnHeader1 + // + this.columnHeader1.Text = "信息项"; + this.columnHeader1.Width = 150; + // + // columnHeader2 + // + this.columnHeader2.Text = "值"; + this.columnHeader2.Width = 300; // // SystemApplication // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(629, 486); + this.ClientSize = new System.Drawing.Size(839, 608); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.tabControl1); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; + this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4); this.Name = "SystemApplication"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "SystemManager"; diff --git a/SiMay.RemoteMonitor/Application/SystemApplication.cs b/SiMay.RemoteMonitor/Application/SystemApplication.cs index 91623cbf455e148c19b9d2a17650d2c7a3f82348..471203c9a84eb3766566ea4d2081a92a138acfeb 100644 --- a/SiMay.RemoteMonitor/Application/SystemApplication.cs +++ b/SiMay.RemoteMonitor/Application/SystemApplication.cs @@ -1,4 +1,5 @@ using SiMay.Basic; +using SiMay.Core; using SiMay.Core.Packets; using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.HandlerAdapters; @@ -17,7 +18,7 @@ namespace SiMay.RemoteMonitor.Application [OnTools] [ApplicationName("系统管理")] [AppResourceName("SystemManager")] - [Application(typeof(SystemAdapterHandler), "SystemManagerJob", 70)] + [Application(typeof(SystemAdapterHandler), AppJobConstant.REMOTE_SYSMANAGER, 70)] public partial class SystemApplication : Form, IApplication { private string _title = "//系统管理 #Name#"; @@ -34,12 +35,17 @@ namespace SiMay.RemoteMonitor.Application this.Show(); } - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) { this.Text = _title + " [" + this.SystemAdapterHandler.StateContext.ToString() + "]"; } - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = _title; } @@ -47,13 +53,13 @@ namespace SiMay.RemoteMonitor.Application private void SystemManager_Load(object sender, EventArgs e) { this.Text = _title; - this.processList.Columns.Add("映像名称", 130); + this.processList.Columns.Add("映像名称", 150); this.processList.Columns.Add("窗口标题", 150); - this.processList.Columns.Add("窗口句柄", 70); - this.processList.Columns.Add("内存", 70); - this.processList.Columns.Add("线程数量", 70); - this.processList.Columns.Add("会话标识", 70); - this.processList.Columns.Add("用户名称", 70); + this.processList.Columns.Add("窗口句柄", 100); + this.processList.Columns.Add("内存", 100); + this.processList.Columns.Add("线程数量", 100); + this.processList.Columns.Add("会话标识", 100); + this.processList.Columns.Add("用户名称", 100); this.processList.Columns.Add("文件位置", 300); this.SystemAdapterHandler.OnProcessListHandlerEvent += OnProcessListHandlerEvent; @@ -147,7 +153,7 @@ namespace SiMay.RemoteMonitor.Application this.SystemAdapterHandler.OnSystemInfoHandlerEvent -= OnSystemInfoHandlerEvent; this.SystemAdapterHandler.OnOccupyHandlerEvent -= OnOccupyHandlerEvent; this.SystemAdapterHandler.OnSessionsEventHandler -= OnSessionsEventHandler; - this.SystemAdapterHandler.CloseHandler(); + this.SystemAdapterHandler.CloseSession(); } private void GetSystemInfos() diff --git a/SiMay.RemoteMonitor/Application/TcpConnectionApplication.cs b/SiMay.RemoteMonitor/Application/TcpConnectionApplication.cs index 8e0974a7a33736db17d9e7ef31d9a4ca9f243955..48316e6be22811f67a15c2c8e0632e2936b5d216 100644 --- a/SiMay.RemoteMonitor/Application/TcpConnectionApplication.cs +++ b/SiMay.RemoteMonitor/Application/TcpConnectionApplication.cs @@ -1,4 +1,5 @@ -using SiMay.Core.Packets.TcpConnection; +using SiMay.Core; +using SiMay.Core.Packets.TcpConnection; using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.HandlerAdapters; using SiMay.RemoteMonitor.Attributes; @@ -9,7 +10,7 @@ using System.Windows.Forms; namespace SiMay.RemoteMonitor.Application { [ApplicationName("Tcp连接管理")] - [Application(typeof(TcpConnectionAdapterHandler), "TcpConnectionManagerJob", 90)] + [Application(typeof(TcpConnectionAdapterHandler), AppJobConstant.REMOTE_TCP, 90)] public partial class TcpConnectionApplication : Form, IApplication { [ApplicationAdapterHandler] @@ -30,11 +31,19 @@ namespace SiMay.RemoteMonitor.Application public void Start() => this.Show(); - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + public void SessionClose(ApplicationAdapterHandler handler) => this.Text = _title + " [" + handler.StateContext.ToString() + "]"; - public void ContinueTask(AdapterHandlerBase handler) - => this.Text = _title; + public void ContinueTask(ApplicationAdapterHandler handler) + { + this.Text = _title; + TcpConnectionAdapterHandler.GetTcpList(); + } private void TcpConnectionManager_Load(object sender, EventArgs e) { @@ -81,7 +90,7 @@ namespace SiMay.RemoteMonitor.Application private void TestApp_FormClosing(object sender, FormClosingEventArgs e) { TcpConnectionAdapterHandler.OnTcpListHandlerEvent -= OnTcpListHandlerEvent; - TcpConnectionAdapterHandler.CloseHandler(); + TcpConnectionAdapterHandler.CloseSession(); } private void 刷新列表ToolStripMenuItem_Click(object sender, EventArgs e) { diff --git a/SiMay.RemoteMonitor/Application/VideoApplication.cs b/SiMay.RemoteMonitor/Application/VideoApplication.cs index 978ccb5addbdf4f2ab4f549f1595fe2fb285bef6..2d9d9995a502840ec94157419090b7f985cd93b6 100644 --- a/SiMay.RemoteMonitor/Application/VideoApplication.cs +++ b/SiMay.RemoteMonitor/Application/VideoApplication.cs @@ -1,12 +1,17 @@ -using SiMay.Basic; +using Accord.Video.FFMPEG; +using SiMay.Basic; +using SiMay.Core; using SiMay.RemoteControlsCore; using SiMay.RemoteControlsCore.HandlerAdapters; using SiMay.RemoteMonitor.Attributes; using System; using System.Drawing; +using System.Drawing.Imaging; using System.IO; using System.Net; using System.Runtime.InteropServices; +using System.Threading; +using System.Threading.Tasks; using System.Windows.Forms; using static SiMay.RemoteMonitor.Win32Api; @@ -16,7 +21,7 @@ namespace SiMay.RemoteMonitor.Application [OnTools] [ApplicationName("视频监控")] [AppResourceName("ViedoManager")] - [Application(typeof(VideoAppAdapterHandler), "RemoteViedoJob", 30)] + [Application(typeof(VideoAppAdapterHandler), AppJobConstant.REMOTE_VIDEO, 30)] public partial class VideoApplication : Form, IApplication { private string _title = "//视频监控 #Name#"; @@ -32,11 +37,17 @@ namespace SiMay.RemoteMonitor.Application => this.Show(); - public void SessionClose(AdapterHandlerBase handler) + public void SetParameter(object arg) + { + throw new NotImplementedException(); + } + + + public void SessionClose(ApplicationAdapterHandler handler) => this.Text = _title + " [" + VideoAppAdapterHandler.StateContext.ToString() + "]"; - public void ContinueTask(AdapterHandlerBase handler) + public void ContinueTask(ApplicationAdapterHandler handler) { this.Text = _title; VideoAppAdapterHandler.StartGetFrame(); @@ -46,20 +57,27 @@ namespace SiMay.RemoteMonitor.Application const Int32 IDM_DEFAULT = 1001; const Int32 IDM_LOW = 1002; const Int32 IDM_SAVE = 1003; + const Int32 IDM_RECORD = 1004; + private int _videoFrameWidth = 0; + private int _videoFrameHeight = 0; + private Bitmap _videoFrame; + private bool _stop = true; + private int _menuContextIndex = 0; private void VedioManager_Load(object sender, EventArgs e) { int index = 7; IntPtr sysMenuHandle = GetSystemMenu(this.Handle, false); - InsertMenu(sysMenuHandle, index, MF_SEPARATOR, 0, null); + InsertMenu(sysMenuHandle, index++, MF_SEPARATOR, 0, null); InsertMenu(sysMenuHandle, index++, MF_BYPOSITION, IDM_HEIGHT, "高画质"); InsertMenu(sysMenuHandle, index++, MF_BYPOSITION, IDM_DEFAULT, "中画质"); InsertMenu(sysMenuHandle, index++, MF_BYPOSITION, IDM_LOW, "低画质"); InsertMenu(sysMenuHandle, index++, MF_SEPARATOR, 0, null); InsertMenu(sysMenuHandle, index++, MF_BYPOSITION, IDM_SAVE, "保存快照"); + _menuContextIndex = index++; + InsertMenu(sysMenuHandle, _menuContextIndex, MF_BYPOSITION, IDM_RECORD, "开始录制"); CheckMenuItem(sysMenuHandle, IDM_DEFAULT, MF_CHECKED); - this.Text = _title = _title.Replace("#Name#", VideoAppAdapterHandler.OriginName); this.ShowTip("视频帧加载中..."); @@ -75,6 +93,19 @@ namespace SiMay.RemoteMonitor.Application private void OnImageFrameHandlerEvent(VideoAppAdapterHandler adapterHandler, Image image) { + lock (this) + { + _videoFrameHeight = image.Height; + _videoFrameWidth = image.Width; + + if (!_videoFrame.IsNull()) + _videoFrame.Dispose(); + + _videoFrame = new Bitmap(image.Width, image.Height); + Graphics g = Graphics.FromImage(_videoFrame); + g.DrawImage(image, 0, 0); + g.Dispose(); + } this.pictureBox.Image = image; } @@ -119,12 +150,51 @@ namespace SiMay.RemoteMonitor.Application img.Dispose(); MessageBoxHelper.ShowBoxExclamation("快照已保存到:" + fileName); + break; + case IDM_RECORD: + if (_stop) + { + if (_videoFrameWidth == 0 || _videoFrameHeight == 0) + return; + _stop = false; + ModifyMenu(sysMenuHandle, _menuContextIndex, MF_BYPOSITION, IDM_RECORD, "停止录制"); + Task.Run(CreateDesktopRecordThread); + } + else + { + _stop = true; + ModifyMenu(sysMenuHandle, _menuContextIndex, MF_BYPOSITION, IDM_RECORD, "开始录制"); + } break; } } base.WndProc(ref m); } + private async void CreateDesktopRecordThread() + { + var targetDirectory = Path.Combine(Environment.CurrentDirectory, VideoAppAdapterHandler.OriginName); + if (!Directory.Exists(targetDirectory)) + Directory.CreateDirectory(targetDirectory); + + var fileName = Path.Combine(targetDirectory, $"摄像头查看_{VideoAppAdapterHandler.OriginName}_{DateTime.Now.ToString("yyyy-MM-dd hhmmss")}.avi"); + + var videoWriter = new VideoFileWriter(); + videoWriter.Open(fileName, _videoFrameWidth, _videoFrameHeight, 10, VideoCodec.H264); + + do + { + if (!_videoFrame.IsNull()) + { + lock (this) + videoWriter.WriteVideoFrame(_videoFrame); + GC.Collect(); + } + await Task.Delay(100); //帧率控制,每秒10帧,防止写入过快 + } while (!_stop); + videoWriter.Close(); + } + private void ShowTip(string str) { if (pictureBox.Image != null) @@ -140,9 +210,10 @@ namespace SiMay.RemoteMonitor.Application private void VedioManager_FormClosing(object sender, FormClosingEventArgs e) { + _stop = true; VideoAppAdapterHandler.OnImageFrameHandlerEvent -= OnImageFrameHandlerEvent; VideoAppAdapterHandler.OnCameraNotStartupHandlerEvent -= OnCameraNotStartupHandlerEvent; - VideoAppAdapterHandler.CloseHandler(); + VideoAppAdapterHandler.CloseSession(); } } } \ No newline at end of file diff --git a/SiMay.RemoteMonitor/Helper/KeygenHelper.cs b/SiMay.RemoteMonitor/Helper/KeygenHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..1bc1e29b435430c7c9c052cd59ea1fa6780b1a01 --- /dev/null +++ b/SiMay.RemoteMonitor/Helper/KeygenHelper.cs @@ -0,0 +1,35 @@ +using SiMay.Basic; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Management; +using System.Text; +using System.Threading.Tasks; + +namespace SiMay.RemoteMonitor +{ + class KeygenHelper + { + private static string GetDiskVolumeSerialNumber() + { + ManagementObject disk = new ManagementObject("win32_logicaldisk.deviceid=\"c:\""); + disk.Get(); + return disk.GetPropertyValue("VolumeSerialNumber").ToString(); + } + + private static string GetCpuSerialNumber() + { + string strCpu = null; + ManagementClass myCpu = new ManagementClass("win32_Processor"); + ManagementObjectCollection myCpuCollection = myCpu.GetInstances(); + foreach (ManagementObject myObject in myCpuCollection) + { + strCpu = myObject.Properties["Processorid"].Value.ToString(); + } + return strCpu; + } + + public static string GetRegSerializeKey() + => GetDiskVolumeSerialNumber() + GetCpuSerialNumber() + Environment.MachineName; + } +} diff --git a/SiMay.RemoteMonitor/Helper/ListViewSortHelper.cs b/SiMay.RemoteMonitor/Helper/ListViewSortHelper.cs index f8ed5cb5e92ae0abda584bb979e850e9716319d8..c9af699adcd4e3ab2f40ab503a908982eb7467fc 100644 --- a/SiMay.RemoteMonitor/Helper/ListViewSortHelper.cs +++ b/SiMay.RemoteMonitor/Helper/ListViewSortHelper.cs @@ -4,215 +4,170 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace SiMay.RemoteMonitor.Entitys +namespace SiMay.RemoteMonitor { - using System; - using System.Collections; - using System.Windows.Forms; - namespace Common + /// + /// 继承自IComparer + /// + public class ListViewColumnSorter : System.Collections.IComparer { /// - /// 对ListView点击列标题自动排序功能 + /// 指定按照哪个列排序 /// - public class ListViewHelper + private int ColumnToSort; + /// + /// 指定排序的方式 + /// + private System.Windows.Forms.SortOrder OrderOfSort; + /// + /// 声明CaseInsensitiveComparer类对象 + /// + private System.Collections.CaseInsensitiveComparer ObjectCompare; + /// + /// 构造函数 + /// + public ListViewColumnSorter() + { + // 默认按第一列排序 + ColumnToSort = 0; + // 排序方式为不排序 + OrderOfSort = System.Windows.Forms.SortOrder.None; + // 初始化CaseInsensitiveComparer类对象 + ObjectCompare = new System.Collections.CaseInsensitiveComparer(); + } + /// + /// 重写IComparer接口. + /// + /// 要比较的第一个对象 + /// 要比较的第二个对象 + /// 比较的结果.如果相等返回0,如果x大于y返回1,如果x小于y返回-1 + public int Compare(object x, object y) { - /// - /// 构造函数 - /// - public ListViewHelper() + int compareResult; + System.Windows.Forms.ListViewItem listviewX, listviewY; + // 将比较对象转换为ListViewItem对象 + listviewX = (System.Windows.Forms.ListViewItem)x; + listviewY = (System.Windows.Forms.ListViewItem)y; + string xText = listviewX.SubItems[SortColumn].Text; + string yText = listviewY.SubItems[SortColumn].Text; + int xInt, yInt; + // 比较,如果值为IP地址,则根据IP地址的规则排序。 + if (IsIP(xText) && IsIP(yText)) { - // - // TODO: 在此处添加构造函数逻辑 - // + compareResult = CompareIp(xText, yText); } - public static void ListView_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e) + else if (int.TryParse(xText, out xInt) && int.TryParse(yText, out yInt)) //是否全为数字 { - System.Windows.Forms.ListView lv = sender as System.Windows.Forms.ListView; - // 检查点击的列是不是现在的排序列. - if (e.Column == (lv.ListViewItemSorter as ListViewColumnSorter).SortColumn) - { - // 重新设置此列的排序方法. - if ((lv.ListViewItemSorter as ListViewColumnSorter).Order == System.Windows.Forms.SortOrder.Ascending) - { - (lv.ListViewItemSorter as ListViewColumnSorter).Order = System.Windows.Forms.SortOrder.Descending; - } - else - { - (lv.ListViewItemSorter as ListViewColumnSorter).Order = System.Windows.Forms.SortOrder.Ascending; - } - } - else - { - // 设置排序列,默认为正向排序 - (lv.ListViewItemSorter as ListViewColumnSorter).SortColumn = e.Column; - (lv.ListViewItemSorter as ListViewColumnSorter).Order = System.Windows.Forms.SortOrder.Ascending; - } - // 用新的排序方法对ListView排序 - ((System.Windows.Forms.ListView)sender).Sort(); + //比较数字 + compareResult = CompareInt(xInt, yInt); + } + else + { + //比较对象 + compareResult = ObjectCompare.Compare(xText, yText); + } + // 根据上面的比较结果返回正确的比较结果 + if (OrderOfSort == System.Windows.Forms.SortOrder.Ascending) + { + // 因为是正序排序,所以直接返回结果 + return compareResult; + } + else if (OrderOfSort == System.Windows.Forms.SortOrder.Descending) + { + // 如果是反序排序,所以要取负值再返回 + return (-compareResult); + } + else + { + // 如果相等返回0 + return 0; } } /// - /// 继承自IComparer + /// 判断是否为正确的IP地址,IP范围(0.0.0.0~255.255.255) /// - public class ListViewColumnSorter : System.Collections.IComparer + /// 需验证的IP地址 + /// + public bool IsIP(String ip) { - /// - /// 指定按照哪个列排序 - /// - private int ColumnToSort; - /// - /// 指定排序的方式 - /// - private System.Windows.Forms.SortOrder OrderOfSort; - /// - /// 声明CaseInsensitiveComparer类对象 - /// - private System.Collections.CaseInsensitiveComparer ObjectCompare; - /// - /// 构造函数 - /// - public ListViewColumnSorter() + return System.Text.RegularExpressions.Regex.Match(ip, @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$").Success; + } + /// + /// 比较两个数字的大小 + /// + /// 要比较的第一个对象 + /// 要比较的第二个对象 + /// 比较的结果.如果相等返回0,如果x大于y返回1,如果x小于y返回-1 + private int CompareInt(int x, int y) + { + if (x > y) { - // 默认按第一列排序 - ColumnToSort = 0; - // 排序方式为不排序 - OrderOfSort = System.Windows.Forms.SortOrder.None; - // 初始化CaseInsensitiveComparer类对象 - ObjectCompare = new System.Collections.CaseInsensitiveComparer(); + return 1; } - /// - /// 重写IComparer接口. - /// - /// 要比较的第一个对象 - /// 要比较的第二个对象 - /// 比较的结果.如果相等返回0,如果x大于y返回1,如果x小于y返回-1 - public int Compare(object x, object y) + else if (x < y) { - int compareResult; - System.Windows.Forms.ListViewItem listviewX, listviewY; - // 将比较对象转换为ListViewItem对象 - listviewX = (System.Windows.Forms.ListViewItem)x; - listviewY = (System.Windows.Forms.ListViewItem)y; - string xText = listviewX.SubItems[ColumnToSort].Text; - string yText = listviewY.SubItems[ColumnToSort].Text; - int xInt, yInt; - // 比较,如果值为IP地址,则根据IP地址的规则排序。 - if (IsIP(xText) && IsIP(yText)) - { - compareResult = CompareIp(xText, yText); - } - else if (int.TryParse(xText, out xInt) && int.TryParse(yText, out yInt)) //是否全为数字 - { - //比较数字 - compareResult = CompareInt(xInt, yInt); - } - else - { - //比较对象 - compareResult = ObjectCompare.Compare(xText, yText); - } - // 根据上面的比较结果返回正确的比较结果 - if (OrderOfSort == System.Windows.Forms.SortOrder.Ascending) - { - // 因为是正序排序,所以直接返回结果 - return compareResult; - } - else if (OrderOfSort == System.Windows.Forms.SortOrder.Descending) - { - // 如果是反序排序,所以要取负值再返回 - return (-compareResult); - } - else - { - // 如果相等返回0 - return 0; - } + return -1; } - /// - /// 判断是否为正确的IP地址,IP范围(0.0.0.0~255.255.255) - /// - /// 需验证的IP地址 - /// - public bool IsIP(String ip) + else { - return System.Text.RegularExpressions.Regex.Match(ip, @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$").Success; + return 0; } - /// - /// 比较两个数字的大小 - /// - /// 要比较的第一个对象 - /// 要比较的第二个对象 - /// 比较的结果.如果相等返回0,如果x大于y返回1,如果x小于y返回-1 - private int CompareInt(int x, int y) + } + /// + /// 比较两个IP地址的大小 + /// + /// 要比较的第一个对象 + /// 要比较的第二个对象 + /// 比较的结果.如果相等返回0,如果x大于y返回1,如果x小于y返回-1 + private int CompareIp(string ipx, string ipy) + { + string[] ipxs = ipx.Split('.'); + string[] ipys = ipy.Split('.'); + for (int i = 0; i < 4; i++) { - if (x > y) + if (Convert.ToInt32(ipxs[i]) > Convert.ToInt32(ipys[i])) { return 1; } - else if (x < y) + else if (Convert.ToInt32(ipxs[i]) < Convert.ToInt32(ipys[i])) { return -1; } else { - return 0; + continue; } } - /// - /// 比较两个IP地址的大小 - /// - /// 要比较的第一个对象 - /// 要比较的第二个对象 - /// 比较的结果.如果相等返回0,如果x大于y返回1,如果x小于y返回-1 - private int CompareIp(string ipx, string ipy) + return 0; + } + /// + /// 获取或设置按照哪一列排序. + /// + public int SortColumn + { + set { - string[] ipxs = ipx.Split('.'); - string[] ipys = ipy.Split('.'); - for (int i = 0; i < 4; i++) - { - if (Convert.ToInt32(ipxs[i]) > Convert.ToInt32(ipys[i])) - { - return 1; - } - else if (Convert.ToInt32(ipxs[i]) < Convert.ToInt32(ipys[i])) - { - return -1; - } - else - { - continue; - } - } - return 0; + ColumnToSort = value; } - /// - /// 获取或设置按照哪一列排序. - /// - public int SortColumn + get { - set - { - ColumnToSort = value; - } - get - { - return ColumnToSort; - } + return ColumnToSort; } - /// - /// 获取或设置排序方式. - /// - public System.Windows.Forms.SortOrder Order + } + /// + /// 获取或设置排序方式. + /// + public System.Windows.Forms.SortOrder Order + { + set { - set - { - OrderOfSort = value; - } - get - { - return OrderOfSort; - } + OrderOfSort = value; + } + get + { + return OrderOfSort; } } } + } diff --git a/SiMay.Basic/MessageBoxHelper.cs b/SiMay.RemoteMonitor/Helper/MessageBoxHelper.cs similarity index 95% rename from SiMay.Basic/MessageBoxHelper.cs rename to SiMay.RemoteMonitor/Helper/MessageBoxHelper.cs index 3868ea700d8e99fd6972e58875368fe5240186a5..d4bf4ee3164f7bc7c42824af2f9e632b6a04e61d 100644 --- a/SiMay.Basic/MessageBoxHelper.cs +++ b/SiMay.RemoteMonitor/Helper/MessageBoxHelper.cs @@ -4,7 +4,7 @@ using System.Linq; using System.Text; using System.Windows.Forms; -namespace SiMay.Basic +namespace SiMay.RemoteMonitor { public class MessageBoxHelper { diff --git a/SiMay.RemoteMonitor/Helper/PCMStreamToWavHelper.cs b/SiMay.RemoteMonitor/Helper/PCMStreamToWavHelper.cs new file mode 100644 index 0000000000000000000000000000000000000000..7d69e6f45044ebfe04da07554e79f16c87f2da3f --- /dev/null +++ b/SiMay.RemoteMonitor/Helper/PCMStreamToWavHelper.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SiMay.RemoteMonitor +{ + public class PCMStreamToWavHelper + { + private BinaryWriter _binaryWriter; + private FileStream _fileStream; + private int _samplesPerSecond; + private short _bitsPerSample; + private short _channels; + private int _dataBufferSize; + private bool _disposed; + /// + /// 累计写入长度 + /// + private int _writeLength = 0; + + public string FileName { get; set; } + + + /// + /// + /// + /// 输出文件名 + /// 采样频率 + /// 每个采样需要的bit数 + /// 声道数量 + public PCMStreamToWavHelper(string fileName, int samplesPerSecond, short bitsPerSample, short channels, int dataBufferSize) + { + _samplesPerSecond = samplesPerSecond; + _bitsPerSample = bitsPerSample; + _channels = channels; + _dataBufferSize = dataBufferSize; + FileName = fileName; + this.CreateSoundFile(fileName); + } + + public void WritePCMDataChunk(byte[] data) + { + if (_disposed) + return; + + _writeLength += data.Length; + _binaryWriter.Write(data, 0, data.Length); + } + + private void CreateSoundFile(string path) + { + _fileStream = new FileStream(path, FileMode.Create); + + _binaryWriter = new BinaryWriter(_fileStream); + + //Set up file with RIFF chunk info. 每个WAVE文件的头四个字节便是“RIFF”。 + char[] ChunkRiff = { 'R', 'I', 'F', 'F' }; + char[] ChunkType = { 'W', 'A', 'V', 'E' }; + char[] ChunkFmt = { 'f', 'm', 't', ' ' }; + char[] ChunkData = { 'd', 'a', 't', 'a' }; + + short shPad = 1; // File padding + + int nFormatChunkLength = 0x10; // Format chunk length. + + int nLength = 0; // File length, minus first 8 bytes of RIFF description. This will be filled in later. + + // 一个样本点的字节数目 + short shBytesPerSample = 2; + + // RIFF 块 + _binaryWriter.Write(ChunkRiff); + _binaryWriter.Write(nLength); + _binaryWriter.Write(ChunkType); + + // WAVE块 + _binaryWriter.Write(ChunkFmt); + _binaryWriter.Write(nFormatChunkLength); + _binaryWriter.Write(shPad); + + + _binaryWriter.Write(_channels); // Mono,声道数目,1-- 单声道;2-- 双声道 + _binaryWriter.Write(_samplesPerSecond);// 16KHz 采样频率 + _binaryWriter.Write(_dataBufferSize); //每秒所需字节数 + _binaryWriter.Write(shBytesPerSample);//数据块对齐单位(每个采样需要的字节数) + _binaryWriter.Write(_bitsPerSample); // 16Bit,每个采样需要的bit数 + + // 数据块 + _binaryWriter.Write(ChunkData); + _binaryWriter.Write((int)0); // The sample length will be written in later. + } + + public void Close() + { + _disposed = true; + _binaryWriter.Seek(4, SeekOrigin.Begin); + _binaryWriter.Write(_writeLength + 36); // 写文件长度 + _binaryWriter.Seek(40, SeekOrigin.Begin); + _binaryWriter.Write(_writeLength); + _fileStream.Close(); + } + } +} diff --git a/SiMay.RemoteMonitor/MainApplication/AppSettingForm.Designer.cs b/SiMay.RemoteMonitor/MainApplication/AppSettingForm.Designer.cs index cf4e10be95882fe55835ade2a17caa4b0b2e31f0..502da12fdb3dbb6fa5f7681960b49e05bd178352 100644 --- a/SiMay.RemoteMonitor/MainApplication/AppSettingForm.Designer.cs +++ b/SiMay.RemoteMonitor/MainApplication/AppSettingForm.Designer.cs @@ -29,7 +29,7 @@ private void InitializeComponent() { this.save = new System.Windows.Forms.Button(); - this.connectNum = new System.Windows.Forms.TextBox(); + this.connectLimitCount = new System.Windows.Forms.TextBox(); this.label3 = new System.Windows.Forms.Label(); this.port = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); @@ -42,6 +42,11 @@ this.label4 = new System.Windows.Forms.Label(); this.maximizeCheckBox = new System.Windows.Forms.CheckBox(); this.panel2 = new System.Windows.Forms.Panel(); + this.enableAnonymous = new System.Windows.Forms.CheckBox(); + this.txtAccessId = new System.Windows.Forms.TextBox(); + this.label16 = new System.Windows.Forms.Label(); + this.txtMainAppAccessKey = new System.Windows.Forms.TextBox(); + this.label15 = new System.Windows.Forms.Label(); this.label13 = new System.Windows.Forms.Label(); this.txtservice_port = new System.Windows.Forms.TextBox(); this.label12 = new System.Windows.Forms.Label(); @@ -66,86 +71,96 @@ // save // this.save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.save.Location = new System.Drawing.Point(338, 10); + this.save.Location = new System.Drawing.Point(451, 12); + this.save.Margin = new System.Windows.Forms.Padding(4); this.save.Name = "save"; - this.save.Size = new System.Drawing.Size(75, 26); + this.save.Size = new System.Drawing.Size(100, 32); this.save.TabIndex = 0; this.save.Text = "保存设置"; this.save.UseVisualStyleBackColor = true; this.save.Click += new System.EventHandler(this.save_Click); // - // connectNum + // connectLimitCount // - this.connectNum.Location = new System.Drawing.Point(185, 135); - this.connectNum.Name = "connectNum"; - this.connectNum.Size = new System.Drawing.Size(115, 21); - this.connectNum.TabIndex = 13; + this.connectLimitCount.Location = new System.Drawing.Point(247, 169); + this.connectLimitCount.Margin = new System.Windows.Forms.Padding(4); + this.connectLimitCount.Name = "connectLimitCount"; + this.connectLimitCount.Size = new System.Drawing.Size(152, 25); + this.connectLimitCount.TabIndex = 13; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(107, 137); + this.label3.Location = new System.Drawing.Point(143, 171); + this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(71, 12); + this.label3.Size = new System.Drawing.Size(90, 15); this.label3.TabIndex = 12; this.label3.Text = "最大连接数:"; // // port // - this.port.Location = new System.Drawing.Point(185, 81); + this.port.Location = new System.Drawing.Point(247, 101); + this.port.Margin = new System.Windows.Forms.Padding(4); this.port.Name = "port"; - this.port.Size = new System.Drawing.Size(115, 21); + this.port.Size = new System.Drawing.Size(152, 25); this.port.TabIndex = 11; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(119, 84); + this.label2.Location = new System.Drawing.Point(159, 105); + this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(59, 12); + this.label2.Size = new System.Drawing.Size(75, 15); this.label2.TabIndex = 10; this.label2.Text = "监听端口:"; // // ip // - this.ip.Location = new System.Drawing.Point(185, 54); + this.ip.Location = new System.Drawing.Point(247, 68); + this.ip.Margin = new System.Windows.Forms.Padding(4); this.ip.Name = "ip"; - this.ip.Size = new System.Drawing.Size(115, 21); + this.ip.Size = new System.Drawing.Size(152, 25); this.ip.TabIndex = 9; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(108, 57); + this.label1.Location = new System.Drawing.Point(144, 71); + this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(71, 12); + this.label1.Size = new System.Drawing.Size(90, 15); this.label1.TabIndex = 8; this.label1.Text = "服务器地址:"; // // conPwd // - this.conPwd.Location = new System.Drawing.Point(185, 108); + this.conPwd.Location = new System.Drawing.Point(247, 135); + this.conPwd.Margin = new System.Windows.Forms.Padding(4); this.conPwd.MaxLength = 6; this.conPwd.Name = "conPwd"; - this.conPwd.Size = new System.Drawing.Size(115, 21); + this.conPwd.Size = new System.Drawing.Size(152, 25); this.conPwd.TabIndex = 17; this.conPwd.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.conPwd_KeyPress); // // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(119, 111); + this.label5.Location = new System.Drawing.Point(159, 139); + this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(59, 12); + this.label5.Size = new System.Drawing.Size(75, 15); this.label5.TabIndex = 16; this.label5.Text = "连接密码:"; // // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button1.Location = new System.Drawing.Point(419, 10); + this.button1.Location = new System.Drawing.Point(559, 12); + this.button1.Margin = new System.Windows.Forms.Padding(4); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 26); + this.button1.Size = new System.Drawing.Size(100, 32); this.button1.TabIndex = 18; this.button1.Text = "关闭"; this.button1.UseVisualStyleBackColor = true; @@ -156,32 +171,40 @@ this.funComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.funComboBox.FlatStyle = System.Windows.Forms.FlatStyle.System; this.funComboBox.FormattingEnabled = true; - this.funComboBox.Location = new System.Drawing.Point(185, 161); + this.funComboBox.Location = new System.Drawing.Point(247, 201); + this.funComboBox.Margin = new System.Windows.Forms.Padding(4); this.funComboBox.Name = "funComboBox"; - this.funComboBox.Size = new System.Drawing.Size(115, 20); + this.funComboBox.Size = new System.Drawing.Size(152, 23); this.funComboBox.TabIndex = 26; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(95, 165); + this.label4.Location = new System.Drawing.Point(127, 206); + this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(83, 12); + this.label4.Size = new System.Drawing.Size(105, 15); this.label4.TabIndex = 25; this.label4.Text = "双击屏幕打开:"; // // maximizeCheckBox // this.maximizeCheckBox.AutoSize = true; - this.maximizeCheckBox.Location = new System.Drawing.Point(185, 190); + this.maximizeCheckBox.Location = new System.Drawing.Point(247, 238); + this.maximizeCheckBox.Margin = new System.Windows.Forms.Padding(4); this.maximizeCheckBox.Name = "maximizeCheckBox"; - this.maximizeCheckBox.Size = new System.Drawing.Size(96, 16); + this.maximizeCheckBox.Size = new System.Drawing.Size(119, 19); this.maximizeCheckBox.TabIndex = 24; this.maximizeCheckBox.Text = "启动时最大化"; this.maximizeCheckBox.UseVisualStyleBackColor = true; // // panel2 // + this.panel2.Controls.Add(this.enableAnonymous); + this.panel2.Controls.Add(this.txtAccessId); + this.panel2.Controls.Add(this.label16); + this.panel2.Controls.Add(this.txtMainAppAccessKey); + this.panel2.Controls.Add(this.label15); this.panel2.Controls.Add(this.label13); this.panel2.Controls.Add(this.txtservice_port); this.panel2.Controls.Add(this.label12); @@ -202,70 +225,123 @@ this.panel2.Controls.Add(this.conPwd); this.panel2.Controls.Add(this.label1); this.panel2.Controls.Add(this.label4); - this.panel2.Controls.Add(this.connectNum); + this.panel2.Controls.Add(this.connectLimitCount); this.panel2.Controls.Add(this.label2); this.panel2.Controls.Add(this.label5); - this.panel2.Location = new System.Drawing.Point(32, 2); - this.panel2.Margin = new System.Windows.Forms.Padding(2); + this.panel2.Location = new System.Drawing.Point(43, 2); + this.panel2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.panel2.Name = "panel2"; - this.panel2.Size = new System.Drawing.Size(405, 438); + this.panel2.Size = new System.Drawing.Size(550, 655); this.panel2.TabIndex = 0; // + // enableAnonymous + // + this.enableAnonymous.AutoSize = true; + this.enableAnonymous.Location = new System.Drawing.Point(163, 428); + this.enableAnonymous.Name = "enableAnonymous"; + this.enableAnonymous.Size = new System.Drawing.Size(354, 19); + this.enableAnonymous.TabIndex = 45; + this.enableAnonymous.Text = "匿名登陆(随机Id,需中间服务开启允许匿名登陆)"; + this.enableAnonymous.UseVisualStyleBackColor = true; + this.enableAnonymous.CheckedChanged += new System.EventHandler(this.enableAnonymous_CheckedChanged); + // + // txtAccessId + // + this.txtAccessId.Location = new System.Drawing.Point(247, 396); + this.txtAccessId.Margin = new System.Windows.Forms.Padding(4); + this.txtAccessId.Name = "txtAccessId"; + this.txtAccessId.Size = new System.Drawing.Size(152, 25); + this.txtAccessId.TabIndex = 44; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(160, 399); + this.label16.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(79, 15); + this.label16.TabIndex = 43; + this.label16.Text = "AccessId:"; + // + // txtMainAppAccessKey + // + this.txtMainAppAccessKey.Location = new System.Drawing.Point(247, 503); + this.txtMainAppAccessKey.Margin = new System.Windows.Forms.Padding(4); + this.txtMainAppAccessKey.Name = "txtMainAppAccessKey"; + this.txtMainAppAccessKey.Size = new System.Drawing.Size(152, 25); + this.txtMainAppAccessKey.TabIndex = 42; + // + // label15 + // + this.label15.AutoSize = true; + this.label15.Location = new System.Drawing.Point(96, 506); + this.label15.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label15.Name = "label15"; + this.label15.Size = new System.Drawing.Size(143, 15); + this.label15.TabIndex = 41; + this.label15.Text = "MainAppAccessKey:"; + // // label13 // this.label13.AutoSize = true; - this.label13.Location = new System.Drawing.Point(95, 190); + this.label13.Location = new System.Drawing.Point(127, 238); + this.label13.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label13.Name = "label13"; - this.label13.Size = new System.Drawing.Size(83, 12); + this.label13.Size = new System.Drawing.Size(105, 15); this.label13.TabIndex = 40; this.label13.Text = "窗口启动状态:"; // // txtservice_port // - this.txtservice_port.Location = new System.Drawing.Point(185, 282); + this.txtservice_port.Location = new System.Drawing.Point(247, 352); + this.txtservice_port.Margin = new System.Windows.Forms.Padding(4); this.txtservice_port.Name = "txtservice_port"; - this.txtservice_port.Size = new System.Drawing.Size(115, 21); + this.txtservice_port.Size = new System.Drawing.Size(152, 25); this.txtservice_port.TabIndex = 39; // // label12 // this.label12.AutoSize = true; - this.label12.Location = new System.Drawing.Point(120, 286); + this.label12.Location = new System.Drawing.Point(164, 355); + this.label12.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label12.Name = "label12"; - this.label12.Size = new System.Drawing.Size(59, 12); + this.label12.Size = new System.Drawing.Size(75, 15); this.label12.TabIndex = 38; this.label12.Text = "服务端口:"; // // txtservice_address // - this.txtservice_address.Location = new System.Drawing.Point(185, 255); + this.txtservice_address.Location = new System.Drawing.Point(247, 319); + this.txtservice_address.Margin = new System.Windows.Forms.Padding(4); this.txtservice_address.Name = "txtservice_address"; - this.txtservice_address.Size = new System.Drawing.Size(115, 21); + this.txtservice_address.Size = new System.Drawing.Size(152, 25); this.txtservice_address.TabIndex = 37; // // label10 // this.label10.AutoSize = true; - this.label10.Location = new System.Drawing.Point(107, 258); + this.label10.Location = new System.Drawing.Point(149, 322); + this.label10.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label10.Name = "label10"; - this.label10.Size = new System.Drawing.Size(71, 12); + this.label10.Size = new System.Drawing.Size(90, 15); this.label10.TabIndex = 36; this.label10.Text = "服务器地址:"; // // accessKey // - this.accessKey.Location = new System.Drawing.Point(185, 309); + this.accessKey.Location = new System.Drawing.Point(247, 470); + this.accessKey.Margin = new System.Windows.Forms.Padding(4); this.accessKey.Name = "accessKey"; - this.accessKey.Size = new System.Drawing.Size(115, 21); + this.accessKey.Size = new System.Drawing.Size(152, 25); this.accessKey.TabIndex = 35; - this.accessKey.UseSystemPasswordChar = true; // // label11 // this.label11.AutoSize = true; - this.label11.Location = new System.Drawing.Point(113, 312); + this.label11.Location = new System.Drawing.Point(151, 474); + this.label11.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label11.Name = "label11"; - this.label11.Size = new System.Drawing.Size(65, 12); + this.label11.Size = new System.Drawing.Size(87, 15); this.label11.TabIndex = 34; this.label11.Text = "AccessKey:"; // @@ -273,27 +349,28 @@ // this.label9.AutoSize = true; this.label9.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label9.Location = new System.Drawing.Point(95, 227); - this.label9.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label9.Location = new System.Drawing.Point(127, 284); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(70, 12); + this.label9.Size = new System.Drawing.Size(87, 15); this.label9.TabIndex = 31; this.label9.Text = "会话服务器"; // // pwdTextBox // - this.pwdTextBox.Location = new System.Drawing.Point(185, 383); + this.pwdTextBox.Location = new System.Drawing.Point(247, 594); + this.pwdTextBox.Margin = new System.Windows.Forms.Padding(4); this.pwdTextBox.Name = "pwdTextBox"; - this.pwdTextBox.Size = new System.Drawing.Size(115, 21); + this.pwdTextBox.Size = new System.Drawing.Size(152, 25); this.pwdTextBox.TabIndex = 30; this.pwdTextBox.UseSystemPasswordChar = true; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(95, 386); + this.label8.Location = new System.Drawing.Point(127, 597); + this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(83, 12); + this.label8.Size = new System.Drawing.Size(105, 15); this.label8.TabIndex = 29; this.label8.Text = "修改解锁密码:"; // @@ -301,10 +378,9 @@ // this.label7.AutoSize = true; this.label7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label7.Location = new System.Drawing.Point(95, 352); - this.label7.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label7.Location = new System.Drawing.Point(143, 555); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(57, 12); + this.label7.Size = new System.Drawing.Size(71, 15); this.label7.TabIndex = 28; this.label7.Text = "锁定密码"; // @@ -312,10 +388,9 @@ // this.label6.AutoSize = true; this.label6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.label6.Location = new System.Drawing.Point(95, 18); - this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0); + this.label6.Location = new System.Drawing.Point(127, 22); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(57, 12); + this.label6.Size = new System.Drawing.Size(71, 15); this.label6.TabIndex = 27; this.label6.Text = "基本设置"; // @@ -326,10 +401,10 @@ this.panel4.Controls.Add(this.button1); this.panel4.Controls.Add(this.save); this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom; - this.panel4.Location = new System.Drawing.Point(0, 300); - this.panel4.Margin = new System.Windows.Forms.Padding(2); + this.panel4.Location = new System.Drawing.Point(0, 375); + this.panel4.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.panel4.Name = "panel4"; - this.panel4.Size = new System.Drawing.Size(503, 45); + this.panel4.Size = new System.Drawing.Size(671, 56); this.panel4.TabIndex = 28; // // sessionModeList @@ -340,17 +415,19 @@ this.sessionModeList.Items.AddRange(new object[] { "本地服务器", "中间会话服务"}); - this.sessionModeList.Location = new System.Drawing.Point(63, 11); + this.sessionModeList.Location = new System.Drawing.Point(84, 14); + this.sessionModeList.Margin = new System.Windows.Forms.Padding(4); this.sessionModeList.Name = "sessionModeList"; - this.sessionModeList.Size = new System.Drawing.Size(121, 20); + this.sessionModeList.Size = new System.Drawing.Size(160, 23); this.sessionModeList.TabIndex = 20; // // label14 // this.label14.AutoSize = true; - this.label14.Location = new System.Drawing.Point(4, 15); + this.label14.Location = new System.Drawing.Point(5, 19); + this.label14.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label14.Name = "label14"; - this.label14.Size = new System.Drawing.Size(59, 12); + this.label14.Size = new System.Drawing.Size(75, 15); this.label14.TabIndex = 19; this.label14.Text = "会话模式:"; // @@ -360,21 +437,22 @@ this.panel1.Controls.Add(this.panel2); this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; this.panel1.Location = new System.Drawing.Point(0, 0); - this.panel1.Margin = new System.Windows.Forms.Padding(2); + this.panel1.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(503, 300); + this.panel1.Size = new System.Drawing.Size(671, 375); this.panel1.TabIndex = 29; // - // AppSettingDialog + // AppSettingForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(503, 345); + this.ClientSize = new System.Drawing.Size(671, 431); this.Controls.Add(this.panel1); this.Controls.Add(this.panel4); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(4); this.MaximizeBox = false; - this.Name = "AppSettingDialog"; + this.Name = "AppSettingForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "系统设置"; this.Load += new System.EventHandler(this.SetForm_Load); @@ -390,7 +468,7 @@ #endregion private System.Windows.Forms.Button save; - private System.Windows.Forms.TextBox connectNum; + private System.Windows.Forms.TextBox connectLimitCount; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox port; private System.Windows.Forms.Label label2; @@ -419,5 +497,10 @@ private System.Windows.Forms.TextBox txtservice_address; private System.Windows.Forms.Label label10; private System.Windows.Forms.Label label13; + private System.Windows.Forms.CheckBox enableAnonymous; + private System.Windows.Forms.TextBox txtAccessId; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.TextBox txtMainAppAccessKey; + private System.Windows.Forms.Label label15; } } \ No newline at end of file diff --git a/SiMay.RemoteMonitor/MainApplication/AppSettingForm.cs b/SiMay.RemoteMonitor/MainApplication/AppSettingForm.cs index 9fc5d8d876aed365ec61f63bd2a242b1caa40269..73f285e167bf66fe837ae2df63f2fcee70921958 100644 --- a/SiMay.RemoteMonitor/MainApplication/AppSettingForm.cs +++ b/SiMay.RemoteMonitor/MainApplication/AppSettingForm.cs @@ -19,23 +19,26 @@ namespace SiMay.RemoteMonitor.MainApplication private void save_Click(object sender, EventArgs e) { - if (ip.Text == "" || port.Text == "" || connectNum.Text == "" || conPwd.Text == "") + if (ip.Text == "" || port.Text == "" || connectLimitCount.Text == "" || conPwd.Text == "") { MessageBoxHelper.ShowBoxExclamation("请正确完整填写设置,否则可能导致客户端上线失败!"); return; } AppConfiguration.IPAddress = ip.Text; - AppConfiguration.Port = port.Text; - AppConfiguration.MaxConnectCount = connectNum.Text; + AppConfiguration.Port = int.Parse(port.Text); + AppConfiguration.MaxConnectCount = int.Parse(connectLimitCount.Text); AppConfiguration.ConnectPassWord = conPwd.Text; AppConfiguration.DbClickViewExc = (funComboBox.Items[funComboBox.SelectedIndex] as KeyValueItem).Value; - AppConfiguration.WindowMaximize = maximizeCheckBox.Checked.ToString(); + AppConfiguration.WindowMaximize = maximizeCheckBox.Checked; AppConfiguration.LockPassWord = pwdTextBox.Text; AppConfiguration.AccessKey = accessKey.Text; AppConfiguration.SessionMode = sessionModeList.SelectedIndex.ToString(); AppConfiguration.ServiceIPAddress = txtservice_address.Text; - AppConfiguration.ServicePort = txtservice_port.Text; + AppConfiguration.ServicePort = int.Parse(txtservice_port.Text); + AppConfiguration.AccessId = long.Parse(txtAccessId.Text); + AppConfiguration.EnabledAnonyMous = enableAnonymous.Checked; + AppConfiguration.MainAppAccessKey = long.Parse(txtMainAppAccessKey.Text); DialogResult result = MessageBox.Show("设置完成,是否重启生效设置?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); @@ -64,20 +67,24 @@ namespace SiMay.RemoteMonitor.MainApplication ip.Text = AppConfiguration.IPAddress; conPwd.Text = AppConfiguration.ConnectPassWord; - port.Text = AppConfiguration.Port; - connectNum.Text = AppConfiguration.MaxConnectCount; + port.Text = AppConfiguration.Port.ToString(); + connectLimitCount.Text = AppConfiguration.MaxConnectCount.ToString(); pwdTextBox.Text = AppConfiguration.LockPassWord; accessKey.Text = AppConfiguration.AccessKey; txtservice_address.Text = AppConfiguration.ServiceIPAddress; - txtservice_port.Text = AppConfiguration.ServicePort; + txtservice_port.Text = AppConfiguration.ServicePort.ToString(); + txtAccessId.Text = AppConfiguration.AccessId.ToString(); + txtMainAppAccessKey.Text = AppConfiguration.MainAppAccessKey.ToString(); int index = int.Parse(AppConfiguration.SessionMode); sessionModeList.SelectedIndex = index; - if (Boolean.Parse(AppConfiguration.WindowMaximize)) - maximizeCheckBox.Checked = true; - else - maximizeCheckBox.Checked = false; + maximizeCheckBox.Checked = AppConfiguration.WindowMaximize; + + enableAnonymous.Checked = AppConfiguration.EnabledAnonyMous; + txtAccessId.Enabled = AppConfiguration.EnabledAnonyMous; + + txtAccessId.Enabled = enableAnonymous.Checked ? false : true; } private void conPwd_KeyPress(object sender, KeyPressEventArgs e) @@ -94,5 +101,10 @@ namespace SiMay.RemoteMonitor.MainApplication { this.Close(); } + + private void enableAnonymous_CheckedChanged(object sender, EventArgs e) + { + txtAccessId.Enabled = enableAnonymous.Checked ? false : true; + } } } \ No newline at end of file diff --git a/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.Designer.cs b/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.Designer.cs index 05aa6d39544c680192fd396979a08a6019e22277..a1990aba76eff39875f16771d9059e55976074d7 100644 --- a/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.Designer.cs +++ b/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.Designer.cs @@ -63,20 +63,18 @@ // this.label7.AutoSize = true; this.label7.ForeColor = System.Drawing.Color.Silver; - this.label7.Location = new System.Drawing.Point(17, 571); - this.label7.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label7.Location = new System.Drawing.Point(13, 457); this.label7.Name = "label7"; - this.label7.Size = new System.Drawing.Size(345, 15); + this.label7.Size = new System.Drawing.Size(275, 12); this.label7.TabIndex = 29; this.label7.Text = "-本程序严禁使用于非法目的,否则一切后果自负。"; // // mutex // this.mutex.AutoSize = true; - this.mutex.Location = new System.Drawing.Point(132, 26); - this.mutex.Margin = new System.Windows.Forms.Padding(4); + this.mutex.Location = new System.Drawing.Point(99, 21); this.mutex.Name = "mutex"; - this.mutex.Size = new System.Drawing.Size(89, 19); + this.mutex.Size = new System.Drawing.Size(72, 16); this.mutex.TabIndex = 11; this.mutex.Text = "进程互斥"; this.mutex.UseVisualStyleBackColor = true; @@ -84,10 +82,9 @@ // ishide // this.ishide.AutoSize = true; - this.ishide.Location = new System.Drawing.Point(16, 26); - this.ishide.Margin = new System.Windows.Forms.Padding(4); + this.ishide.Location = new System.Drawing.Point(12, 21); this.ishide.Name = "ishide"; - this.ishide.Size = new System.Drawing.Size(89, 19); + this.ishide.Size = new System.Drawing.Size(72, 16); this.ishide.TabIndex = 10; this.ishide.Text = "隐藏文件"; this.ishide.UseVisualStyleBackColor = true; @@ -108,11 +105,9 @@ this.groupBox3.Controls.Add(this.label1); this.groupBox3.Controls.Add(this.label2); this.groupBox3.Controls.Add(this.button1); - this.groupBox3.Location = new System.Drawing.Point(15, 19); - this.groupBox3.Margin = new System.Windows.Forms.Padding(4); + this.groupBox3.Location = new System.Drawing.Point(11, 15); this.groupBox3.Name = "groupBox3"; - this.groupBox3.Padding = new System.Windows.Forms.Padding(4); - this.groupBox3.Size = new System.Drawing.Size(536, 190); + this.groupBox3.Size = new System.Drawing.Size(402, 152); this.groupBox3.TabIndex = 27; this.groupBox3.TabStop = false; this.groupBox3.Text = "配置信息"; @@ -120,59 +115,53 @@ // label5 // this.label5.AutoSize = true; - this.label5.Location = new System.Drawing.Point(13, 144); - this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label5.Location = new System.Drawing.Point(10, 115); this.label5.Name = "label5"; - this.label5.Size = new System.Drawing.Size(45, 15); + this.label5.Size = new System.Drawing.Size(35, 12); this.label5.TabIndex = 15; this.label5.Text = "分组:"; // // groupNameBox // - this.groupNameBox.Location = new System.Drawing.Point(68, 140); - this.groupNameBox.Margin = new System.Windows.Forms.Padding(4); + this.groupNameBox.Location = new System.Drawing.Point(51, 112); this.groupNameBox.MaxLength = 20; this.groupNameBox.Name = "groupNameBox"; - this.groupNameBox.Size = new System.Drawing.Size(232, 25); + this.groupNameBox.Size = new System.Drawing.Size(175, 21); this.groupNameBox.TabIndex = 16; this.groupNameBox.Text = "默认分组"; // // label4 // this.label4.AutoSize = true; - this.label4.Location = new System.Drawing.Point(309, 68); - this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label4.Location = new System.Drawing.Point(232, 54); this.label4.Name = "label4"; - this.label4.Size = new System.Drawing.Size(210, 15); + this.label4.Size = new System.Drawing.Size(167, 12); this.label4.TabIndex = 14; this.label4.Text = "创建服务端前请连接测试一下!"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(13, 105); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Location = new System.Drawing.Point(10, 84); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(45, 15); + this.label3.Size = new System.Drawing.Size(35, 12); this.label3.TabIndex = 12; this.label3.Text = "密码:"; // // txtAccesskey // - this.txtAccesskey.Location = new System.Drawing.Point(68, 101); - this.txtAccesskey.Margin = new System.Windows.Forms.Padding(4); + this.txtAccesskey.Location = new System.Drawing.Point(51, 81); this.txtAccesskey.MaxLength = 20; this.txtAccesskey.Name = "txtAccesskey"; - this.txtAccesskey.Size = new System.Drawing.Size(232, 25); + this.txtAccesskey.Size = new System.Drawing.Size(175, 21); this.txtAccesskey.TabIndex = 13; this.txtAccesskey.Text = "5200"; // // button4 // - this.button4.Location = new System.Drawing.Point(331, 99); - this.button4.Margin = new System.Windows.Forms.Padding(4); + this.button4.Location = new System.Drawing.Point(248, 79); this.button4.Name = "button4"; - this.button4.Size = new System.Drawing.Size(95, 28); + this.button4.Size = new System.Drawing.Size(71, 22); this.button4.TabIndex = 11; this.button4.Text = "保存记录"; this.button4.UseVisualStyleBackColor = true; @@ -180,10 +169,9 @@ // // button2 // - this.button2.Location = new System.Drawing.Point(433, 99); - this.button2.Margin = new System.Windows.Forms.Padding(4); + this.button2.Location = new System.Drawing.Point(325, 79); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(95, 28); + this.button2.Size = new System.Drawing.Size(71, 22); this.button2.TabIndex = 10; this.button2.Text = "删除记录"; this.button2.UseVisualStyleBackColor = true; @@ -192,68 +180,61 @@ // mls_port // this.mls_port.FormattingEnabled = true; - this.mls_port.Location = new System.Drawing.Point(349, 29); - this.mls_port.Margin = new System.Windows.Forms.Padding(4); + this.mls_port.Location = new System.Drawing.Point(262, 23); this.mls_port.Name = "mls_port"; - this.mls_port.Size = new System.Drawing.Size(75, 23); + this.mls_port.Size = new System.Drawing.Size(57, 20); this.mls_port.TabIndex = 9; // // mls_address // this.mls_address.FormattingEnabled = true; - this.mls_address.Location = new System.Drawing.Point(68, 29); - this.mls_address.Margin = new System.Windows.Forms.Padding(4); + this.mls_address.Location = new System.Drawing.Point(51, 23); this.mls_address.Name = "mls_address"; - this.mls_address.Size = new System.Drawing.Size(232, 23); + this.mls_address.Size = new System.Drawing.Size(175, 20); this.mls_address.TabIndex = 8; this.mls_address.SelectedIndexChanged += new System.EventHandler(this.mls_address_SelectedIndexChanged); // // label6 // this.label6.AutoSize = true; - this.label6.Location = new System.Drawing.Point(13, 68); - this.label6.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label6.Location = new System.Drawing.Point(10, 54); this.label6.Name = "label6"; - this.label6.Size = new System.Drawing.Size(45, 15); + this.label6.Size = new System.Drawing.Size(35, 12); this.label6.TabIndex = 6; this.label6.Text = "备注:"; // // txtInitName // - this.txtInitName.Location = new System.Drawing.Point(68, 64); - this.txtInitName.Margin = new System.Windows.Forms.Padding(4); + this.txtInitName.Location = new System.Drawing.Point(51, 51); this.txtInitName.MaxLength = 20; this.txtInitName.Name = "txtInitName"; - this.txtInitName.Size = new System.Drawing.Size(232, 25); + this.txtInitName.Size = new System.Drawing.Size(175, 21); this.txtInitName.TabIndex = 7; this.txtInitName.Text = "SiMay远程管理"; // // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(13, 32); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(10, 26); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(45, 15); + this.label1.Size = new System.Drawing.Size(35, 12); this.label1.TabIndex = 0; this.label1.Text = "地址:"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(307, 32); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label2.Location = new System.Drawing.Point(230, 26); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(45, 15); + this.label2.Size = new System.Drawing.Size(35, 12); this.label2.TabIndex = 1; this.label2.Text = "端口:"; // // button1 // - this.button1.Location = new System.Drawing.Point(433, 29); - this.button1.Margin = new System.Windows.Forms.Padding(4); + this.button1.Location = new System.Drawing.Point(325, 23); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(95, 28); + this.button1.Size = new System.Drawing.Size(71, 22); this.button1.TabIndex = 4; this.button1.Text = "连接测试"; this.button1.UseVisualStyleBackColor = true; @@ -262,11 +243,9 @@ // groupBox2 // this.groupBox2.Controls.Add(this.logList); - this.groupBox2.Location = new System.Drawing.Point(15, 216); - this.groupBox2.Margin = new System.Windows.Forms.Padding(4); + this.groupBox2.Location = new System.Drawing.Point(11, 173); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Padding = new System.Windows.Forms.Padding(4); - this.groupBox2.Size = new System.Drawing.Size(536, 190); + this.groupBox2.Size = new System.Drawing.Size(402, 152); this.groupBox2.TabIndex = 26; this.groupBox2.TabStop = false; this.groupBox2.Text = "配置日志"; @@ -276,19 +255,17 @@ this.logList.BackColor = System.Drawing.Color.Black; this.logList.ForeColor = System.Drawing.Color.Lime; this.logList.FormattingEnabled = true; - this.logList.ItemHeight = 15; - this.logList.Location = new System.Drawing.Point(16, 25); - this.logList.Margin = new System.Windows.Forms.Padding(4); + this.logList.ItemHeight = 12; + this.logList.Location = new System.Drawing.Point(12, 20); this.logList.Name = "logList"; - this.logList.Size = new System.Drawing.Size(508, 154); + this.logList.Size = new System.Drawing.Size(382, 124); this.logList.TabIndex = 9; // // button3 // - this.button3.Location = new System.Drawing.Point(416, 541); - this.button3.Margin = new System.Windows.Forms.Padding(4); + this.button3.Location = new System.Drawing.Point(312, 433); this.button3.Name = "button3"; - this.button3.Size = new System.Drawing.Size(135, 49); + this.button3.Size = new System.Drawing.Size(101, 39); this.button3.TabIndex = 25; this.button3.Text = "创建服务端文件"; this.button3.UseVisualStyleBackColor = true; @@ -302,19 +279,17 @@ this.sessionModeList.Items.AddRange(new object[] { "本地服务器", "中间会话服务"}); - this.sessionModeList.Location = new System.Drawing.Point(100, 541); - this.sessionModeList.Margin = new System.Windows.Forms.Padding(4); + this.sessionModeList.Location = new System.Drawing.Point(75, 433); this.sessionModeList.Name = "sessionModeList"; - this.sessionModeList.Size = new System.Drawing.Size(137, 23); + this.sessionModeList.Size = new System.Drawing.Size(104, 20); this.sessionModeList.TabIndex = 31; // // label8 // this.label8.AutoSize = true; - this.label8.Location = new System.Drawing.Point(17, 544); - this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label8.Location = new System.Drawing.Point(13, 435); this.label8.Name = "label8"; - this.label8.Size = new System.Drawing.Size(75, 15); + this.label8.Size = new System.Drawing.Size(59, 12); this.label8.TabIndex = 30; this.label8.Text = "会话模式:"; // @@ -322,11 +297,9 @@ // this.groupBox1.Controls.Add(this.mutex); this.groupBox1.Controls.Add(this.ishide); - this.groupBox1.Location = new System.Drawing.Point(15, 414); - this.groupBox1.Margin = new System.Windows.Forms.Padding(4); + this.groupBox1.Location = new System.Drawing.Point(11, 331); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Padding = new System.Windows.Forms.Padding(4); - this.groupBox1.Size = new System.Drawing.Size(536, 65); + this.groupBox1.Size = new System.Drawing.Size(402, 52); this.groupBox1.TabIndex = 32; this.groupBox1.TabStop = false; this.groupBox1.Text = "功能选项"; @@ -340,27 +313,25 @@ "仅执行", "注册启动", "服务安装"}); - this.installMode.Location = new System.Drawing.Point(100, 512); - this.installMode.Margin = new System.Windows.Forms.Padding(4); + this.installMode.Location = new System.Drawing.Point(75, 410); this.installMode.Name = "installMode"; - this.installMode.Size = new System.Drawing.Size(137, 23); + this.installMode.Size = new System.Drawing.Size(104, 20); this.installMode.TabIndex = 34; // // label9 // this.label9.AutoSize = true; - this.label9.Location = new System.Drawing.Point(17, 515); - this.label9.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label9.Location = new System.Drawing.Point(13, 412); this.label9.Name = "label9"; - this.label9.Size = new System.Drawing.Size(75, 15); + this.label9.Size = new System.Drawing.Size(59, 12); this.label9.TabIndex = 33; this.label9.Text = "安装方式:"; // // BuilderServiceForm // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(567, 611); + this.ClientSize = new System.Drawing.Size(425, 489); this.Controls.Add(this.groupBox1); this.Controls.Add(this.installMode); this.Controls.Add(this.sessionModeList); @@ -371,7 +342,6 @@ this.Controls.Add(this.groupBox2); this.Controls.Add(this.button3); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Margin = new System.Windows.Forms.Padding(4); this.MaximizeBox = false; this.Name = "BuilderServiceForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; diff --git a/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.cs b/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.cs index 2c0ae181f3c7470be0d71abf86d3e401f6f7ac3e..9d084c37490d29d6ec8ddcff7346663525256319 100644 --- a/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.cs +++ b/SiMay.RemoteMonitor/MainApplication/BuilderServiceForm.cs @@ -1,8 +1,7 @@ using SiMay.Basic; using SiMay.Core.Entitys; using SiMay.RemoteControlsCore; -using SiMay.RemoteMonitor.Entitys; -using SiMay.Serialize; +using SiMay.Serialize.Standard; using System; using System.Collections.Generic; using System.IO; @@ -37,7 +36,7 @@ namespace SiMay.RemoteMonitor.MainApplication Socket testSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { - testSock.Connect(IPHelper.GetHostByName(mls_address.Text), int.Parse(mls_port.Text)); + testSock.Connect(HostHelper.GetHostByName(mls_address.Text), int.Parse(mls_port.Text)); testSock.Close(); MessageBoxHelper.ShowBoxExclamation("连接: " + mls_address.Text + ":" + mls_port.Text + " 成功!", "连接成功"); } diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopRecordForm.cs b/SiMay.RemoteMonitor/MainApplication/DesktopRecordForm.cs index 5a8c2f6539fa63045480f00fc873518658cc8954..2a18bae8c745d1ff402c62e90a28f50eaa2cf1b6 100644 --- a/SiMay.RemoteMonitor/MainApplication/DesktopRecordForm.cs +++ b/SiMay.RemoteMonitor/MainApplication/DesktopRecordForm.cs @@ -23,7 +23,7 @@ namespace SiMay.RemoteMonitor.MainApplication private void DesktopRecordManager_Load(object sender, EventArgs e) { - bool isAction = _syncContext.KeyDictions[SysConstants.RecordScreenIsAction].ConvertTo(); + bool isAction = _syncContext.KeyDictions[SysConstants.HasLaunchDesktopRecord].ConvertTo(); string macName = _syncContext.KeyDictions[SysConstants.MachineName].ConvertTo(); int screenHeight = _syncContext.KeyDictions[SysConstants.RecordHeight].ConvertTo(); int screenWidth = _syncContext.KeyDictions[SysConstants.RecordWidth].ConvertTo(); @@ -68,7 +68,7 @@ namespace SiMay.RemoteMonitor.MainApplication //_session.SendAsync(data); - _syncContext.KeyDictions[SysConstants.RecordScreenIsAction] = true; + _syncContext.KeyDictions[SysConstants.HasLaunchDesktopRecord] = true; _syncContext.KeyDictions[SysConstants.RecordHeight] = screenHeight; _syncContext.KeyDictions[SysConstants.RecordWidth] = screenWidth; _syncContext.KeyDictions[SysConstants.RecordSpanTime] = spantime; @@ -82,7 +82,7 @@ namespace SiMay.RemoteMonitor.MainApplication //byte[] data = MessageHelper.CopyMessageHeadTo(MessageHead.S_MAIN_SCREEN_RECORD_CLOSE); //_session.SendAsync(data); - _syncContext.KeyDictions[SysConstants.RecordScreenIsAction] = false; + _syncContext.KeyDictions[SysConstants.HasLaunchDesktopRecord] = false; startbtn.Enabled = true; stopbtn.Enabled = false; } diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopRecordViewerForm.Designer.cs b/SiMay.RemoteMonitor/MainApplication/DesktopRecordViewerForm.Designer.cs index 6221e67c0502cb1ff54a82e934676dc786bd251b..ccc89691d84e9c810aa86c1ab082418817d531a2 100644 --- a/SiMay.RemoteMonitor/MainApplication/DesktopRecordViewerForm.Designer.cs +++ b/SiMay.RemoteMonitor/MainApplication/DesktopRecordViewerForm.Designer.cs @@ -47,9 +47,9 @@ | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); this.pictureBox.BackColor = System.Drawing.Color.Black; - this.pictureBox.Location = new System.Drawing.Point(0, 0); + this.pictureBox.Location = new System.Drawing.Point(9, 10); this.pictureBox.Name = "pictureBox"; - this.pictureBox.Size = new System.Drawing.Size(861, 520); + this.pictureBox.Size = new System.Drawing.Size(993, 579); this.pictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; this.pictureBox.TabIndex = 0; this.pictureBox.TabStop = false; @@ -57,7 +57,7 @@ // startimeBox // this.startimeBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.startimeBox.Location = new System.Drawing.Point(197, 525); + this.startimeBox.Location = new System.Drawing.Point(197, 599); this.startimeBox.Name = "startimeBox"; this.startimeBox.Size = new System.Drawing.Size(122, 21); this.startimeBox.TabIndex = 1; @@ -66,7 +66,7 @@ // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(325, 529); + this.label1.Location = new System.Drawing.Point(325, 603); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(17, 12); this.label1.TabIndex = 2; @@ -75,7 +75,7 @@ // endtimeBox // this.endtimeBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.endtimeBox.Location = new System.Drawing.Point(348, 525); + this.endtimeBox.Location = new System.Drawing.Point(348, 599); this.endtimeBox.Name = "endtimeBox"; this.endtimeBox.Size = new System.Drawing.Size(122, 21); this.endtimeBox.TabIndex = 3; @@ -83,7 +83,7 @@ // button1 // this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.button1.Location = new System.Drawing.Point(476, 524); + this.button1.Location = new System.Drawing.Point(476, 598); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(75, 23); this.button1.TabIndex = 4; @@ -94,7 +94,7 @@ // button2 // this.button2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button2.Location = new System.Drawing.Point(774, 524); + this.button2.Location = new System.Drawing.Point(924, 598); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(75, 23); this.button2.TabIndex = 5; @@ -105,7 +105,7 @@ // button3 // this.button3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button3.Location = new System.Drawing.Point(693, 524); + this.button3.Location = new System.Drawing.Point(843, 598); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(75, 23); this.button3.TabIndex = 6; @@ -116,7 +116,7 @@ // button4 // this.button4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button4.Location = new System.Drawing.Point(612, 524); + this.button4.Location = new System.Drawing.Point(762, 598); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(75, 23); this.button4.TabIndex = 7; @@ -128,7 +128,7 @@ // this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(3, 529); + this.label2.Location = new System.Drawing.Point(3, 603); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(59, 12); this.label2.TabIndex = 8; @@ -138,17 +138,17 @@ // this.usersCombox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.usersCombox.FormattingEnabled = true; - this.usersCombox.Location = new System.Drawing.Point(60, 526); + this.usersCombox.Location = new System.Drawing.Point(60, 600); this.usersCombox.Name = "usersCombox"; this.usersCombox.Size = new System.Drawing.Size(121, 20); this.usersCombox.TabIndex = 9; this.usersCombox.SelectedIndexChanged += new System.EventHandler(this.usersCombox_SelectedIndexChanged); // - // DesktopRecordViewerDialog + // DesktopRecordViewerForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(861, 550); + this.ClientSize = new System.Drawing.Size(1011, 624); this.Controls.Add(this.usersCombox); this.Controls.Add(this.label2); this.Controls.Add(this.button4); @@ -159,7 +159,7 @@ this.Controls.Add(this.label1); this.Controls.Add(this.startimeBox); this.Controls.Add(this.pictureBox); - this.Name = "DesktopRecordViewerDialog"; + this.Name = "DesktopRecordViewerForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "桌面记录查看"; this.Load += new System.EventHandler(this.DesktopRecordViewer_Load); diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.Designer.cs b/SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.Designer.cs deleted file mode 100644 index d190fe0a63aa39d417c9426709a58c685572aa6b..0000000000000000000000000000000000000000 --- a/SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.Designer.cs +++ /dev/null @@ -1,48 +0,0 @@ -namespace SiMay.RemoteMonitor.MainApplication -{ - partial class DesktopViewWallSettingForm - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.SuspendLayout(); - // - // DesktopViewWallSettingForm - // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(558, 322); - this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.MaximizeBox = false; - this.Name = "DesktopViewWallSettingForm"; - this.Text = "视图墙设置"; - this.ResumeLayout(false); - - } - - #endregion - } -} \ No newline at end of file diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewSettingContext.cs b/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewSettingContext.cs new file mode 100644 index 0000000000000000000000000000000000000000..6524a29f0cc984bc21863c449ffc18e09f7dbce2 --- /dev/null +++ b/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewSettingContext.cs @@ -0,0 +1,107 @@ +using SiMay.RemoteControlsCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SiMay.RemoteMonitor.MainApplication +{ + public class DesktopViewSettingContext + { + /// + /// 轮播间隔 + /// + public int ViewCarouselInterval + { + get + { + return AppConfiguration.CarouselInterval; + } + set + { + AppConfiguration.CarouselInterval = value; + } + } + + /// + /// 视图刷新间隔 + /// + public int ViewFreshInterval + { + get + { + return AppConfiguration.DesktopRefreshInterval; + } + set + { + AppConfiguration.DesktopRefreshInterval = value; + } + } + + /// + /// 视图行 + /// + public int ViewRow + { + get + { + return AppConfiguration.ViewRow; + } + set + { + AppConfiguration.ViewRow = value; + } + } + + /// + /// 视图列 + /// + public int ViewColum + { + get + { + return AppConfiguration.ViewColumn; + } + set + { + AppConfiguration.ViewColumn = value; + } + } + + /// + /// 停留视图 + /// + public IList AlwaysViews { get; set; } + + /// + /// 视图高 + /// + public int ViewHeight { get; set; } + + /// + /// 视图宽 + /// + public int ViewWidth { get; set; } + + /// + /// 是否启用轮播 + /// + public bool CarouselEnabled + { + get + { + return AppConfiguration.CarouselEnabled; + } + set + { + AppConfiguration.CarouselEnabled = value; + } + } + + public DesktopViewSettingContext() + { + AlwaysViews = new List(); + } + } +} diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.Designer.cs b/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.Designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..01e794ef7c29a1186e284a59fd27fab554abc496 --- /dev/null +++ b/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.Designer.cs @@ -0,0 +1,191 @@ +namespace SiMay.RemoteMonitor.MainApplication +{ + partial class DesktopViewWallSettingForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.label2 = new System.Windows.Forms.Label(); + this.deskrefreshTimeInterval = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.enabled = new System.Windows.Forms.CheckBox(); + this.button1 = new System.Windows.Forms.Button(); + this.label3 = new System.Windows.Forms.Label(); + this.carouselInterval = new System.Windows.Forms.NumericUpDown(); + ((System.ComponentModel.ISupportInitialize)(this.deskrefreshTimeInterval)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.carouselInterval)).BeginInit(); + this.SuspendLayout(); + // + // label2 + // + this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(112, 43); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(59, 12); + this.label2.TabIndex = 12; + this.label2.Text = "刷新间隔:"; + // + // deskrefreshTimeInterval + // + this.deskrefreshTimeInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.deskrefreshTimeInterval.Increment = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.deskrefreshTimeInterval.Location = new System.Drawing.Point(172, 38); + this.deskrefreshTimeInterval.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.deskrefreshTimeInterval.Minimum = new decimal(new int[] { + 300, + 0, + 0, + 0}); + this.deskrefreshTimeInterval.Name = "deskrefreshTimeInterval"; + this.deskrefreshTimeInterval.ReadOnly = true; + this.deskrefreshTimeInterval.Size = new System.Drawing.Size(92, 21); + this.deskrefreshTimeInterval.TabIndex = 11; + this.deskrefreshTimeInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.deskrefreshTimeInterval.Value = new decimal(new int[] { + 300, + 0, + 0, + 0}); + // + // label1 + // + this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(112, 93); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(59, 12); + this.label1.TabIndex = 13; + this.label1.Text = "启用轮播:"; + // + // enabled + // + this.enabled.AutoSize = true; + this.enabled.Location = new System.Drawing.Point(173, 92); + this.enabled.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.enabled.Name = "enabled"; + this.enabled.Size = new System.Drawing.Size(48, 16); + this.enabled.TabIndex = 14; + this.enabled.Text = "启用"; + this.enabled.UseVisualStyleBackColor = true; + this.enabled.CheckedChanged += new System.EventHandler(this.checkBox1_CheckedChanged); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(296, 116); + this.button1.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(82, 33); + this.button1.TabIndex = 15; + this.button1.Text = "保存"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // label3 + // + this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(112, 70); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(59, 12); + this.label3.TabIndex = 17; + this.label3.Text = "轮播间隔:"; + // + // carouselInterval + // + this.carouselInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.carouselInterval.Increment = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.carouselInterval.Location = new System.Drawing.Point(172, 65); + this.carouselInterval.Maximum = new decimal(new int[] { + 10000, + 0, + 0, + 0}); + this.carouselInterval.Minimum = new decimal(new int[] { + 300, + 0, + 0, + 0}); + this.carouselInterval.Name = "carouselInterval"; + this.carouselInterval.ReadOnly = true; + this.carouselInterval.Size = new System.Drawing.Size(92, 21); + this.carouselInterval.TabIndex = 16; + this.carouselInterval.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; + this.carouselInterval.Value = new decimal(new int[] { + 300, + 0, + 0, + 0}); + // + // DesktopViewWallSettingForm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(393, 158); + this.Controls.Add(this.label3); + this.Controls.Add(this.carouselInterval); + this.Controls.Add(this.button1); + this.Controls.Add(this.enabled); + this.Controls.Add(this.label1); + this.Controls.Add(this.label2); + this.Controls.Add(this.deskrefreshTimeInterval); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; + this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2); + this.MaximizeBox = false; + this.Name = "DesktopViewWallSettingForm"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "视图墙设置"; + this.Load += new System.EventHandler(this.DesktopViewWallSettingForm_Load); + ((System.ComponentModel.ISupportInitialize)(this.deskrefreshTimeInterval)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.carouselInterval)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label label2; + private System.Windows.Forms.NumericUpDown deskrefreshTimeInterval; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.CheckBox enabled; + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.NumericUpDown carouselInterval; + } +} \ No newline at end of file diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.cs b/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.cs new file mode 100644 index 0000000000000000000000000000000000000000..e8144049caa92fb57f127d476326311ef3c270e2 --- /dev/null +++ b/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using SiMay.Basic; + +namespace SiMay.RemoteMonitor.MainApplication +{ + public partial class DesktopViewWallSettingForm : Form + { + DesktopViewSettingContext _settingContext; + public DesktopViewWallSettingForm(DesktopViewSettingContext settingContext) + { + _settingContext = settingContext; + InitializeComponent(); + } + + private void button1_Click(object sender, EventArgs e) + { + if (deskrefreshTimeInterval.Value < 300) + { + MessageBoxHelper.ShowBoxError("设置未保存,刷新间隔不能小于300!", "error"); + return; + } + this._settingContext.ViewFreshInterval = (int)deskrefreshTimeInterval.Value; + this._settingContext.CarouselEnabled = this.enabled.Checked; + this._settingContext.ViewCarouselInterval = (int)carouselInterval.Value; + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void checkBox1_CheckedChanged(object sender, EventArgs e) + { + this.SwithTip(); + } + + private void SwithTip() + { + if (enabled.Checked) + enabled.Text = "启用"; + else + enabled.Text = "不启用"; + } + + private void DesktopViewWallSettingForm_Load(object sender, EventArgs e) + { + //this.DialogResult = DialogResult.Cancel; + this.deskrefreshTimeInterval.Value = this._settingContext.ViewFreshInterval; + this.carouselInterval.Value = this._settingContext.ViewCarouselInterval; + this.enabled.Checked = this._settingContext.CarouselEnabled; + this.SwithTip(); + } + } +} diff --git a/SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.resx b/SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.resx similarity index 100% rename from SiMay.RemoteMonitor/MainApplication/DesktopView/DesktopViewWallSettingForm.resx rename to SiMay.RemoteMonitor/MainApplication/DesktopViewCarousel/DesktopViewWallSettingForm.resx diff --git a/SiMay.RemoteMonitor/MainApplication/LockWindowsForm.cs b/SiMay.RemoteMonitor/MainApplication/LockWindowsForm.cs index 064f71c9883a237f10868f35138bb573ae3638ad..b8b221276e3223c70e859a939637ec67a31d2ffb 100644 --- a/SiMay.RemoteMonitor/MainApplication/LockWindowsForm.cs +++ b/SiMay.RemoteMonitor/MainApplication/LockWindowsForm.cs @@ -24,7 +24,7 @@ namespace SiMay.RemoteMonitor.MainApplication if (pwdTextBox.Text.Equals(AppConfiguration.LockPassWord)) { this._ifree = true; - AppConfiguration.WindowsIsLock = "false"; + AppConfiguration.WindowsIsLock = false; this.Close(); } else diff --git a/SiMay.RemoteMonitor/MainApplication/MainApplication.Designer.cs b/SiMay.RemoteMonitor/MainApplication/MainApplication.Designer.cs index 2bb4d98c24a73fde2ec23dd6b2ffa89d044f7a05..30689dc968e49f153e5a2c903d7cf17ab7014a25 100644 --- a/SiMay.RemoteMonitor/MainApplication/MainApplication.Designer.cs +++ b/SiMay.RemoteMonitor/MainApplication/MainApplication.Designer.cs @@ -29,7 +29,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - this.CmdContext = new System.Windows.Forms.ContextMenuStrip(this.components); + this.cmdContext = new System.Windows.Forms.ContextMenuStrip(this.components); this.toolStripMenuItem11 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem6 = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); @@ -43,6 +43,7 @@ this.关闭计算机ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.重启计算机ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator8 = new System.Windows.Forms.ToolStripSeparator(); + this.ReStartServiceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.installServiceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.unInstallServiceMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); @@ -65,26 +66,25 @@ this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.desktopViewLayout = new System.Windows.Forms.FlowLayoutPanel(); this.panel1 = new System.Windows.Forms.Panel(); + this.linkLabel2 = new System.Windows.Forms.LinkLabel(); this.label3 = new System.Windows.Forms.Label(); this.groupBox = new System.Windows.Forms.ComboBox(); - this.label2 = new System.Windows.Forms.Label(); - this.deskrefreshTimeSpan = new System.Windows.Forms.NumericUpDown(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); - this.column = new System.Windows.Forms.Label(); + this.viewColumn = new System.Windows.Forms.Label(); this.fsd = new System.Windows.Forms.Label(); - this.row = new System.Windows.Forms.Label(); - this.rowtrackBar = new System.Windows.Forms.TrackBar(); + this.viewRow = new System.Windows.Forms.Label(); + this.columntrackBar = new System.Windows.Forms.TrackBar(); this.linkLabel1 = new System.Windows.Forms.LinkLabel(); this.label1 = new System.Windows.Forms.Label(); - this.columntrackBar = new System.Windows.Forms.TrackBar(); - this.splitContainer2 = new System.Windows.Forms.SplitContainer(); + this.rowtrackBar = new System.Windows.Forms.TrackBar(); + this.splitContainer = new System.Windows.Forms.SplitContainer(); this.tabControl2 = new System.Windows.Forms.TabControl(); this.tabPage2 = new System.Windows.Forms.TabPage(); this.logList = new SiMay.RemoteMonitor.UserControls.UListView(); this.tabControl1 = new System.Windows.Forms.TabControl(); this.tabPage1 = new System.Windows.Forms.TabPage(); - this.onlineList = new SiMay.RemoteMonitor.UserControls.UListView(); + this.servicesOnlineList = new SiMay.RemoteMonitor.UserControls.UListView(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel(); this.stripHost = new System.Windows.Forms.ToolStripStatusLabel(); @@ -118,21 +118,19 @@ this.桌面记录查看ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.锁定ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolStripMenuItem3 = new System.Windows.Forms.ToolStripMenuItem(); - this.linkLabel2 = new System.Windows.Forms.LinkLabel(); - this.CmdContext.SuspendLayout(); + this.cmdContext.SuspendLayout(); this.logsContext.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); this.splitContainer1.SuspendLayout(); this.panel1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.deskrefreshTimeSpan)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.rowtrackBar)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.columntrackBar)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); - this.splitContainer2.Panel1.SuspendLayout(); - this.splitContainer2.Panel2.SuspendLayout(); - this.splitContainer2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.rowtrackBar)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); + this.splitContainer.Panel1.SuspendLayout(); + this.splitContainer.Panel2.SuspendLayout(); + this.splitContainer.SuspendLayout(); this.tabControl2.SuspendLayout(); this.tabPage2.SuspendLayout(); this.tabControl1.SuspendLayout(); @@ -142,10 +140,10 @@ this.menuStrip1.SuspendLayout(); this.SuspendLayout(); // - // CmdContext + // cmdContext // - this.CmdContext.ImageScalingSize = new System.Drawing.Size(20, 20); - this.CmdContext.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.cmdContext.ImageScalingSize = new System.Drawing.Size(20, 20); + this.cmdContext.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolStripMenuItem11, this.toolStripMenuItem6, this.toolStripMenuItem1, @@ -159,50 +157,50 @@ this.toolStripSeparator1, this.选择全部ToolStripMenuItem, this.取消选择ToolStripMenuItem}); - this.CmdContext.Name = "CmdContext"; - this.CmdContext.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.CmdContext.Size = new System.Drawing.Size(154, 280); - this.CmdContext.Opening += new System.ComponentModel.CancelEventHandler(this.CmdContext_Opening); + this.cmdContext.Name = "CmdContext"; + this.cmdContext.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; + this.cmdContext.Size = new System.Drawing.Size(137, 258); + this.cmdContext.Opening += new System.ComponentModel.CancelEventHandler(this.CmdContext_Opening); // // toolStripMenuItem11 // this.toolStripMenuItem11.Name = "toolStripMenuItem11"; - this.toolStripMenuItem11.Size = new System.Drawing.Size(153, 24); + this.toolStripMenuItem11.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem11.Text = "桌面记录"; this.toolStripMenuItem11.Click += new System.EventHandler(this.toolStripMenuItem11_Click); // // toolStripMenuItem6 // this.toolStripMenuItem6.Name = "toolStripMenuItem6"; - this.toolStripMenuItem6.Size = new System.Drawing.Size(153, 24); + this.toolStripMenuItem6.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem6.Text = "打开网页"; this.toolStripMenuItem6.Click += new System.EventHandler(this.toolStripMenuItem6_Click_1); // // toolStripMenuItem1 // this.toolStripMenuItem1.Name = "toolStripMenuItem1"; - this.toolStripMenuItem1.Size = new System.Drawing.Size(153, 24); + this.toolStripMenuItem1.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem1.Text = "下载执行"; this.toolStripMenuItem1.Click += new System.EventHandler(this.RemoteDownloadExecete); // // 发送信息ToolStripMenuItem // this.发送信息ToolStripMenuItem.Name = "发送信息ToolStripMenuItem"; - this.发送信息ToolStripMenuItem.Size = new System.Drawing.Size(153, 24); + this.发送信息ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.发送信息ToolStripMenuItem.Text = "发送信息"; this.发送信息ToolStripMenuItem.Click += new System.EventHandler(this.SendMessageBox); // // 备注更改ToolStripMenuItem // this.备注更改ToolStripMenuItem.Name = "备注更改ToolStripMenuItem"; - this.备注更改ToolStripMenuItem.Size = new System.Drawing.Size(153, 24); + this.备注更改ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.备注更改ToolStripMenuItem.Text = "备注更改"; this.备注更改ToolStripMenuItem.Click += new System.EventHandler(this.ModifyRemark); // // toolStripMenuItem7 // this.toolStripMenuItem7.Name = "toolStripMenuItem7"; - this.toolStripMenuItem7.Size = new System.Drawing.Size(153, 24); + this.toolStripMenuItem7.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem7.Text = "分组更改"; this.toolStripMenuItem7.Click += new System.EventHandler(this.ToolStripMenuItem7_Click); // @@ -215,6 +213,7 @@ this.关闭计算机ToolStripMenuItem, this.重启计算机ToolStripMenuItem, this.toolStripSeparator8, + this.ReStartServiceMenuItem, this.installServiceMenuItem, this.unInstallServiceMenuItem, this.toolStripSeparator2, @@ -225,141 +224,148 @@ this.toolStripSeparator3, this.卸载控制端ToolStripMenuItem}); this.会话管理ToolStripMenuItem.Name = "会话管理ToolStripMenuItem"; - this.会话管理ToolStripMenuItem.Size = new System.Drawing.Size(153, 24); + this.会话管理ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.会话管理ToolStripMenuItem.Text = "会话管理"; // // updateClient // this.updateClient.Name = "updateClient"; - this.updateClient.Size = new System.Drawing.Size(167, 26); + this.updateClient.Size = new System.Drawing.Size(136, 22); this.updateClient.Text = "远程更新"; this.updateClient.Click += new System.EventHandler(this.UpdateClient_Click); // // toolStripMenuItem8 // this.toolStripMenuItem8.Name = "toolStripMenuItem8"; - this.toolStripMenuItem8.Size = new System.Drawing.Size(167, 26); + this.toolStripMenuItem8.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem8.Text = "重新载入"; this.toolStripMenuItem8.Click += new System.EventHandler(this.ToolStripMenuItem8_Click); // // toolStripSeparator6 // this.toolStripSeparator6.Name = "toolStripSeparator6"; - this.toolStripSeparator6.Size = new System.Drawing.Size(164, 6); + this.toolStripSeparator6.Size = new System.Drawing.Size(133, 6); // // 关闭计算机ToolStripMenuItem // this.关闭计算机ToolStripMenuItem.Name = "关闭计算机ToolStripMenuItem"; - this.关闭计算机ToolStripMenuItem.Size = new System.Drawing.Size(167, 26); + this.关闭计算机ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.关闭计算机ToolStripMenuItem.Text = "关闭计算机"; this.关闭计算机ToolStripMenuItem.Click += new System.EventHandler(this.RemoteShutdown); // // 重启计算机ToolStripMenuItem // this.重启计算机ToolStripMenuItem.Name = "重启计算机ToolStripMenuItem"; - this.重启计算机ToolStripMenuItem.Size = new System.Drawing.Size(167, 26); + this.重启计算机ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.重启计算机ToolStripMenuItem.Text = "重启计算机"; this.重启计算机ToolStripMenuItem.Click += new System.EventHandler(this.RemoteReboot); // // toolStripSeparator8 // this.toolStripSeparator8.Name = "toolStripSeparator8"; - this.toolStripSeparator8.Size = new System.Drawing.Size(164, 6); + this.toolStripSeparator8.Size = new System.Drawing.Size(133, 6); + // + // ReStartServiceMenuItem + // + this.ReStartServiceMenuItem.Name = "ReStartServiceMenuItem"; + this.ReStartServiceMenuItem.Size = new System.Drawing.Size(136, 22); + this.ReStartServiceMenuItem.Text = "重启服务"; + this.ReStartServiceMenuItem.Click += new System.EventHandler(this.ReStartServiceMenuItem_Click); // // installServiceMenuItem // this.installServiceMenuItem.Name = "installServiceMenuItem"; - this.installServiceMenuItem.Size = new System.Drawing.Size(167, 26); + this.installServiceMenuItem.Size = new System.Drawing.Size(136, 22); this.installServiceMenuItem.Text = "服务安装"; this.installServiceMenuItem.Click += new System.EventHandler(this.installServiceMenuItem_Click); // // unInstallServiceMenuItem // this.unInstallServiceMenuItem.Name = "unInstallServiceMenuItem"; - this.unInstallServiceMenuItem.Size = new System.Drawing.Size(167, 26); + this.unInstallServiceMenuItem.Size = new System.Drawing.Size(136, 22); this.unInstallServiceMenuItem.Text = "服务卸载"; this.unInstallServiceMenuItem.Click += new System.EventHandler(this.unInstallServiceMenuItem_Click); // // toolStripSeparator2 // this.toolStripSeparator2.Name = "toolStripSeparator2"; - this.toolStripSeparator2.Size = new System.Drawing.Size(164, 6); + this.toolStripSeparator2.Size = new System.Drawing.Size(133, 6); // // 开机启动ToolStripMenuItem // this.开机启动ToolStripMenuItem.Name = "开机启动ToolStripMenuItem"; - this.开机启动ToolStripMenuItem.Size = new System.Drawing.Size(167, 26); + this.开机启动ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.开机启动ToolStripMenuItem.Text = "注册表启动"; this.开机启动ToolStripMenuItem.Click += new System.EventHandler(this.RemoteStartup); // // 取消自启动ToolStripMenuItem // this.取消自启动ToolStripMenuItem.Name = "取消自启动ToolStripMenuItem"; - this.取消自启动ToolStripMenuItem.Size = new System.Drawing.Size(167, 26); + this.取消自启动ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.取消自启动ToolStripMenuItem.Text = "取消自启动"; this.取消自启动ToolStripMenuItem.Click += new System.EventHandler(this.RemoteUnStarup); // // 隐藏服务端ToolStripMenuItem // this.隐藏服务端ToolStripMenuItem.Name = "隐藏服务端ToolStripMenuItem"; - this.隐藏服务端ToolStripMenuItem.Size = new System.Drawing.Size(167, 26); + this.隐藏服务端ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.隐藏服务端ToolStripMenuItem.Text = "隐藏服务端"; this.隐藏服务端ToolStripMenuItem.Click += new System.EventHandler(this.RemoteHideServiceFile); // // toolStripMenuItem2 // this.toolStripMenuItem2.Name = "toolStripMenuItem2"; - this.toolStripMenuItem2.Size = new System.Drawing.Size(167, 26); + this.toolStripMenuItem2.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem2.Text = "显示服务端"; this.toolStripMenuItem2.Click += new System.EventHandler(this.ToolStripMenuItem2_Click); // // toolStripSeparator3 // this.toolStripSeparator3.Name = "toolStripSeparator3"; - this.toolStripSeparator3.Size = new System.Drawing.Size(164, 6); + this.toolStripSeparator3.Size = new System.Drawing.Size(133, 6); // // 卸载控制端ToolStripMenuItem // this.卸载控制端ToolStripMenuItem.Name = "卸载控制端ToolStripMenuItem"; - this.卸载控制端ToolStripMenuItem.Size = new System.Drawing.Size(167, 26); + this.卸载控制端ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.卸载控制端ToolStripMenuItem.Text = "卸载服务端"; this.卸载控制端ToolStripMenuItem.Click += new System.EventHandler(this.UninstallService); // // toolStripSeparator4 // this.toolStripSeparator4.Name = "toolStripSeparator4"; - this.toolStripSeparator4.Size = new System.Drawing.Size(150, 6); + this.toolStripSeparator4.Size = new System.Drawing.Size(133, 6); // // toolStripMenuItem4 // this.toolStripMenuItem4.Name = "toolStripMenuItem4"; - this.toolStripMenuItem4.Size = new System.Drawing.Size(153, 24); + this.toolStripMenuItem4.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem4.Text = "开启屏幕墙"; this.toolStripMenuItem4.Click += new System.EventHandler(this.toolStripMenuItem4_Click); // // toolStripMenuItem5 // this.toolStripMenuItem5.Name = "toolStripMenuItem5"; - this.toolStripMenuItem5.Size = new System.Drawing.Size(153, 24); + this.toolStripMenuItem5.Size = new System.Drawing.Size(136, 22); this.toolStripMenuItem5.Text = "关闭屏幕墙"; this.toolStripMenuItem5.Click += new System.EventHandler(this.toolStripMenuItem5_Click); // // toolStripSeparator1 // this.toolStripSeparator1.Name = "toolStripSeparator1"; - this.toolStripSeparator1.Size = new System.Drawing.Size(150, 6); + this.toolStripSeparator1.Size = new System.Drawing.Size(133, 6); // // 选择全部ToolStripMenuItem // this.选择全部ToolStripMenuItem.Name = "选择全部ToolStripMenuItem"; - this.选择全部ToolStripMenuItem.Size = new System.Drawing.Size(153, 24); + this.选择全部ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.选择全部ToolStripMenuItem.Text = "选择全部"; this.选择全部ToolStripMenuItem.Click += new System.EventHandler(this.OnlineList_OnSelected); // // 取消选择ToolStripMenuItem // this.取消选择ToolStripMenuItem.Name = "取消选择ToolStripMenuItem"; - this.取消选择ToolStripMenuItem.Size = new System.Drawing.Size(153, 24); + this.取消选择ToolStripMenuItem.Size = new System.Drawing.Size(136, 22); this.取消选择ToolStripMenuItem.Text = "取消选择"; this.取消选择ToolStripMenuItem.Click += new System.EventHandler(this.OnileList_OnUnSelected); // @@ -372,34 +378,33 @@ this.清空日志ToolStripMenuItem1}); this.logsContext.Name = "logsContext"; this.logsContext.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.logsContext.Size = new System.Drawing.Size(139, 76); + this.logsContext.Size = new System.Drawing.Size(125, 70); // // 复制日志ToolStripMenuItem // this.复制日志ToolStripMenuItem.Name = "复制日志ToolStripMenuItem"; - this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(138, 24); + this.复制日志ToolStripMenuItem.Size = new System.Drawing.Size(124, 22); this.复制日志ToolStripMenuItem.Text = "复制日志"; this.复制日志ToolStripMenuItem.Click += new System.EventHandler(this.CopyRuningLog); // // 删除日志ToolStripMenuItem // this.删除日志ToolStripMenuItem.Name = "删除日志ToolStripMenuItem"; - this.删除日志ToolStripMenuItem.Size = new System.Drawing.Size(138, 24); + this.删除日志ToolStripMenuItem.Size = new System.Drawing.Size(124, 22); this.删除日志ToolStripMenuItem.Text = "删除日志"; this.删除日志ToolStripMenuItem.Click += new System.EventHandler(this.DeleteRuningLog); // // 清空日志ToolStripMenuItem1 // this.清空日志ToolStripMenuItem1.Name = "清空日志ToolStripMenuItem1"; - this.清空日志ToolStripMenuItem1.Size = new System.Drawing.Size(138, 24); + this.清空日志ToolStripMenuItem1.Size = new System.Drawing.Size(124, 22); this.清空日志ToolStripMenuItem1.Text = "清空日志"; this.清空日志ToolStripMenuItem1.Click += new System.EventHandler(this.ClearRuningLog); // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer1.Location = new System.Drawing.Point(0, 87); - this.splitContainer1.Margin = new System.Windows.Forms.Padding(4); + this.splitContainer1.Location = new System.Drawing.Point(0, 81); this.splitContainer1.Name = "splitContainer1"; this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal; // @@ -410,9 +415,9 @@ // // splitContainer1.Panel2 // - this.splitContainer1.Panel2.Controls.Add(this.splitContainer2); - this.splitContainer1.Size = new System.Drawing.Size(1476, 825); - this.splitContainer1.SplitterDistance = 597; + this.splitContainer1.Panel2.Controls.Add(this.splitContainer); + this.splitContainer1.Size = new System.Drawing.Size(1083, 598); + this.splitContainer1.SplitterDistance = 432; this.splitContainer1.SplitterWidth = 1; this.splitContainer1.TabIndex = 7; // @@ -422,42 +427,51 @@ this.desktopViewLayout.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; this.desktopViewLayout.Dock = System.Windows.Forms.DockStyle.Fill; this.desktopViewLayout.Location = new System.Drawing.Point(0, 0); - this.desktopViewLayout.Margin = new System.Windows.Forms.Padding(4); + this.desktopViewLayout.Margin = new System.Windows.Forms.Padding(0); this.desktopViewLayout.Name = "desktopViewLayout"; - this.desktopViewLayout.Size = new System.Drawing.Size(1476, 567); + this.desktopViewLayout.Size = new System.Drawing.Size(1083, 408); this.desktopViewLayout.TabIndex = 3; + this.desktopViewLayout.Resize += new System.EventHandler(this.desktopViewLayout_Resize); // // panel1 // this.panel1.Controls.Add(this.linkLabel2); this.panel1.Controls.Add(this.label3); this.panel1.Controls.Add(this.groupBox); - this.panel1.Controls.Add(this.label2); - this.panel1.Controls.Add(this.deskrefreshTimeSpan); this.panel1.Controls.Add(this.button2); this.panel1.Controls.Add(this.button1); - this.panel1.Controls.Add(this.column); + this.panel1.Controls.Add(this.viewColumn); this.panel1.Controls.Add(this.fsd); - this.panel1.Controls.Add(this.row); - this.panel1.Controls.Add(this.rowtrackBar); + this.panel1.Controls.Add(this.viewRow); + this.panel1.Controls.Add(this.columntrackBar); this.panel1.Controls.Add(this.linkLabel1); this.panel1.Controls.Add(this.label1); - this.panel1.Controls.Add(this.columntrackBar); + this.panel1.Controls.Add(this.rowtrackBar); this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; - this.panel1.Location = new System.Drawing.Point(0, 567); - this.panel1.Margin = new System.Windows.Forms.Padding(4); + this.panel1.Location = new System.Drawing.Point(0, 408); this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(1476, 30); + this.panel1.Size = new System.Drawing.Size(1083, 24); this.panel1.TabIndex = 4; // + // linkLabel2 + // + this.linkLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.linkLabel2.AutoSize = true; + this.linkLabel2.Location = new System.Drawing.Point(1024, 6); + this.linkLabel2.Name = "linkLabel2"; + this.linkLabel2.Size = new System.Drawing.Size(53, 12); + this.linkLabel2.TabIndex = 13; + this.linkLabel2.TabStop = true; + this.linkLabel2.Text = "视图设置"; + this.linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel2_LinkClicked); + // // label3 // this.label3.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(553, 6); - this.label3.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label3.Location = new System.Drawing.Point(518, 6); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(45, 15); + this.label3.Size = new System.Drawing.Size(35, 12); this.label3.TabIndex = 12; this.label3.Text = "分组:"; // @@ -469,61 +483,17 @@ this.groupBox.FormattingEnabled = true; this.groupBox.Items.AddRange(new object[] { "全部"}); - this.groupBox.Location = new System.Drawing.Point(601, 2); - this.groupBox.Margin = new System.Windows.Forms.Padding(4); + this.groupBox.Location = new System.Drawing.Point(554, 3); this.groupBox.Name = "groupBox"; - this.groupBox.Size = new System.Drawing.Size(152, 23); + this.groupBox.Size = new System.Drawing.Size(115, 20); this.groupBox.TabIndex = 11; this.groupBox.SelectedIndexChanged += new System.EventHandler(this.GroupBox_SelectedIndexChanged); // - // label2 - // - this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(763, 8); - this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(75, 15); - this.label2.TabIndex = 10; - this.label2.Text = "刷新间隔:"; - // - // deskrefreshTimeSpan - // - this.deskrefreshTimeSpan.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.deskrefreshTimeSpan.Increment = new decimal(new int[] { - 100, - 0, - 0, - 0}); - this.deskrefreshTimeSpan.Location = new System.Drawing.Point(843, 2); - this.deskrefreshTimeSpan.Margin = new System.Windows.Forms.Padding(4); - this.deskrefreshTimeSpan.Maximum = new decimal(new int[] { - 10000, - 0, - 0, - 0}); - this.deskrefreshTimeSpan.Minimum = new decimal(new int[] { - 300, - 0, - 0, - 0}); - this.deskrefreshTimeSpan.Name = "deskrefreshTimeSpan"; - this.deskrefreshTimeSpan.ReadOnly = true; - this.deskrefreshTimeSpan.Size = new System.Drawing.Size(63, 25); - this.deskrefreshTimeSpan.TabIndex = 9; - this.deskrefreshTimeSpan.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.deskrefreshTimeSpan.Value = new decimal(new int[] { - 300, - 0, - 0, - 0}); - // // button2 // - this.button2.Location = new System.Drawing.Point(88, 2); - this.button2.Margin = new System.Windows.Forms.Padding(4); + this.button2.Location = new System.Drawing.Point(66, 2); this.button2.Name = "button2"; - this.button2.Size = new System.Drawing.Size(75, 25); + this.button2.Size = new System.Drawing.Size(56, 20); this.button2.TabIndex = 8; this.button2.Text = "反选"; this.button2.UseVisualStyleBackColor = true; @@ -531,71 +501,65 @@ // // button1 // - this.button1.Location = new System.Drawing.Point(5, 2); - this.button1.Margin = new System.Windows.Forms.Padding(4); + this.button1.Location = new System.Drawing.Point(4, 2); this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(75, 25); + this.button1.Size = new System.Drawing.Size(56, 20); this.button1.TabIndex = 7; this.button1.Text = "全选"; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // - // column + // viewColumn // - this.column.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.column.AutoSize = true; - this.column.Location = new System.Drawing.Point(1267, 8); - this.column.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.column.Name = "column"; - this.column.Size = new System.Drawing.Size(31, 15); - this.column.TabIndex = 6; - this.column.Text = "150"; + this.viewColumn.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.viewColumn.AutoSize = true; + this.viewColumn.Location = new System.Drawing.Point(939, 6); + this.viewColumn.Name = "viewColumn"; + this.viewColumn.Size = new System.Drawing.Size(11, 12); + this.viewColumn.TabIndex = 6; + this.viewColumn.Text = "3"; // // fsd // this.fsd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.fsd.AutoSize = true; - this.fsd.Location = new System.Drawing.Point(913, 8); - this.fsd.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.fsd.Location = new System.Drawing.Point(674, 6); this.fsd.Name = "fsd"; - this.fsd.Size = new System.Drawing.Size(45, 15); + this.fsd.Size = new System.Drawing.Size(47, 12); this.fsd.TabIndex = 5; - this.fsd.Text = "宽度:"; + this.fsd.Text = "视图列:"; // - // row + // viewRow // - this.row.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.row.AutoSize = true; - this.row.Location = new System.Drawing.Point(1071, 8); - this.row.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.row.Name = "row"; - this.row.Size = new System.Drawing.Size(31, 15); - this.row.TabIndex = 4; - this.row.Text = "150"; + this.viewRow.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.viewRow.AutoSize = true; + this.viewRow.Location = new System.Drawing.Point(792, 6); + this.viewRow.Name = "viewRow"; + this.viewRow.Size = new System.Drawing.Size(11, 12); + this.viewRow.TabIndex = 4; + this.viewRow.Text = "4"; // - // rowtrackBar + // columntrackBar // - this.rowtrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.rowtrackBar.AutoSize = false; - this.rowtrackBar.Location = new System.Drawing.Point(956, 6); - this.rowtrackBar.Margin = new System.Windows.Forms.Padding(4); - this.rowtrackBar.Maximum = 1000; - this.rowtrackBar.Minimum = 1; - this.rowtrackBar.Name = "rowtrackBar"; - this.rowtrackBar.Size = new System.Drawing.Size(120, 21); - this.rowtrackBar.TabIndex = 3; - this.rowtrackBar.TickStyle = System.Windows.Forms.TickStyle.None; - this.rowtrackBar.Value = 170; - this.rowtrackBar.Scroll += new System.EventHandler(this.RowtrackBar_Scroll); + this.columntrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.columntrackBar.AutoSize = false; + this.columntrackBar.Location = new System.Drawing.Point(727, 5); + this.columntrackBar.Maximum = 50; + this.columntrackBar.Minimum = 1; + this.columntrackBar.Name = "columntrackBar"; + this.columntrackBar.Size = new System.Drawing.Size(71, 17); + this.columntrackBar.TabIndex = 3; + this.columntrackBar.TickStyle = System.Windows.Forms.TickStyle.None; + this.columntrackBar.Value = 4; + this.columntrackBar.Scroll += new System.EventHandler(this.RowtrackBar_Scroll); // // linkLabel1 // this.linkLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.linkLabel1.AutoSize = true; - this.linkLabel1.Location = new System.Drawing.Point(1316, 8); - this.linkLabel1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.linkLabel1.Location = new System.Drawing.Point(964, 6); this.linkLabel1.Name = "linkLabel1"; - this.linkLabel1.Size = new System.Drawing.Size(67, 15); + this.linkLabel1.Size = new System.Drawing.Size(53, 12); this.linkLabel1.TabIndex = 2; this.linkLabel1.TabStop = true; this.linkLabel1.Text = "保存设置"; @@ -605,46 +569,44 @@ // this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(1113, 8); - this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.label1.Location = new System.Drawing.Point(815, 6); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(45, 15); + this.label1.Size = new System.Drawing.Size(47, 12); this.label1.TabIndex = 1; - this.label1.Text = "高度:"; + this.label1.Text = "视图行:"; // - // columntrackBar + // rowtrackBar // - this.columntrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.columntrackBar.AutoSize = false; - this.columntrackBar.Location = new System.Drawing.Point(1152, 6); - this.columntrackBar.Margin = new System.Windows.Forms.Padding(4); - this.columntrackBar.Maximum = 1000; - this.columntrackBar.Minimum = 1; - this.columntrackBar.Name = "columntrackBar"; - this.columntrackBar.Size = new System.Drawing.Size(120, 21); - this.columntrackBar.TabIndex = 0; - this.columntrackBar.TickStyle = System.Windows.Forms.TickStyle.None; - this.columntrackBar.Value = 150; - this.columntrackBar.Scroll += new System.EventHandler(this.ColumntrackBar_Scroll); + this.rowtrackBar.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.rowtrackBar.AutoSize = false; + this.rowtrackBar.Location = new System.Drawing.Point(866, 5); + this.rowtrackBar.Maximum = 50; + this.rowtrackBar.Minimum = 1; + this.rowtrackBar.Name = "rowtrackBar"; + this.rowtrackBar.Size = new System.Drawing.Size(76, 17); + this.rowtrackBar.TabIndex = 0; + this.rowtrackBar.TickStyle = System.Windows.Forms.TickStyle.None; + this.rowtrackBar.Value = 3; + this.rowtrackBar.Scroll += new System.EventHandler(this.ColumntrackBar_Scroll); // - // splitContainer2 + // splitContainer // - this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill; - this.splitContainer2.Location = new System.Drawing.Point(0, 0); - this.splitContainer2.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.splitContainer2.Name = "splitContainer2"; + this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; + this.splitContainer.Location = new System.Drawing.Point(0, 0); + this.splitContainer.Margin = new System.Windows.Forms.Padding(2); + this.splitContainer.Name = "splitContainer"; // - // splitContainer2.Panel1 + // splitContainer.Panel1 // - this.splitContainer2.Panel1.Controls.Add(this.tabControl2); + this.splitContainer.Panel1.Controls.Add(this.tabControl2); // - // splitContainer2.Panel2 + // splitContainer.Panel2 // - this.splitContainer2.Panel2.Controls.Add(this.tabControl1); - this.splitContainer2.Size = new System.Drawing.Size(1476, 227); - this.splitContainer2.SplitterDistance = 368; - this.splitContainer2.SplitterWidth = 1; - this.splitContainer2.TabIndex = 0; + this.splitContainer.Panel2.Controls.Add(this.tabControl1); + this.splitContainer.Size = new System.Drawing.Size(1083, 165); + this.splitContainer.SplitterDistance = 268; + this.splitContainer.SplitterWidth = 1; + this.splitContainer.TabIndex = 0; // // tabControl2 // @@ -652,10 +614,9 @@ this.tabControl2.Controls.Add(this.tabPage2); this.tabControl2.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl2.Location = new System.Drawing.Point(0, 0); - this.tabControl2.Margin = new System.Windows.Forms.Padding(4); this.tabControl2.Name = "tabControl2"; this.tabControl2.SelectedIndex = 0; - this.tabControl2.Size = new System.Drawing.Size(368, 227); + this.tabControl2.Size = new System.Drawing.Size(268, 165); this.tabControl2.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; this.tabControl2.TabIndex = 1; // @@ -663,30 +624,25 @@ // this.tabPage2.Controls.Add(this.logList); this.tabPage2.Location = new System.Drawing.Point(4, 4); - this.tabPage2.Margin = new System.Windows.Forms.Padding(4); this.tabPage2.Name = "tabPage2"; - this.tabPage2.Padding = new System.Windows.Forms.Padding(4); - this.tabPage2.Size = new System.Drawing.Size(360, 198); + this.tabPage2.Padding = new System.Windows.Forms.Padding(3); + this.tabPage2.Size = new System.Drawing.Size(260, 139); this.tabPage2.TabIndex = 2; this.tabPage2.Text = "运行日志"; this.tabPage2.UseVisualStyleBackColor = true; // // logList // - this.logList.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.logList.ContextMenuStrip = this.logsContext; this.logList.Dock = System.Windows.Forms.DockStyle.Fill; this.logList.FullRowSelect = true; this.logList.HideSelection = false; - this.logList.Location = new System.Drawing.Point(4, 4); - this.logList.Margin = new System.Windows.Forms.Padding(4); + this.logList.Location = new System.Drawing.Point(3, 3); this.logList.Name = "logList"; - this.logList.Size = new System.Drawing.Size(352, 190); + this.logList.Size = new System.Drawing.Size(254, 133); this.logList.TabIndex = 0; this.logList.UseCompatibleStateImageBehavior = false; this.logList.UseWindowsThemStyle = true; this.logList.View = System.Windows.Forms.View.Details; - this.logList.MouseEnter += new System.EventHandler(this.logList_MouseEnter); // // tabControl1 // @@ -694,42 +650,36 @@ this.tabControl1.Controls.Add(this.tabPage1); this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill; this.tabControl1.Location = new System.Drawing.Point(0, 0); - this.tabControl1.Margin = new System.Windows.Forms.Padding(4); this.tabControl1.Name = "tabControl1"; this.tabControl1.SelectedIndex = 0; - this.tabControl1.Size = new System.Drawing.Size(1107, 227); + this.tabControl1.Size = new System.Drawing.Size(814, 165); this.tabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed; this.tabControl1.TabIndex = 0; // // tabPage1 // - this.tabPage1.Controls.Add(this.onlineList); + this.tabPage1.Controls.Add(this.servicesOnlineList); this.tabPage1.Location = new System.Drawing.Point(4, 4); - this.tabPage1.Margin = new System.Windows.Forms.Padding(4); this.tabPage1.Name = "tabPage1"; - this.tabPage1.Padding = new System.Windows.Forms.Padding(4); - this.tabPage1.Size = new System.Drawing.Size(1099, 198); + this.tabPage1.Padding = new System.Windows.Forms.Padding(3); + this.tabPage1.Size = new System.Drawing.Size(806, 139); this.tabPage1.TabIndex = 2; this.tabPage1.Text = "在线列表"; this.tabPage1.UseVisualStyleBackColor = true; // - // onlineList - // - this.onlineList.BorderStyle = System.Windows.Forms.BorderStyle.None; - this.onlineList.CheckBoxes = true; - this.onlineList.ContextMenuStrip = this.CmdContext; - this.onlineList.Dock = System.Windows.Forms.DockStyle.Fill; - this.onlineList.FullRowSelect = true; - this.onlineList.HideSelection = false; - this.onlineList.Location = new System.Drawing.Point(4, 4); - this.onlineList.Margin = new System.Windows.Forms.Padding(4); - this.onlineList.Name = "onlineList"; - this.onlineList.Size = new System.Drawing.Size(1091, 190); - this.onlineList.TabIndex = 0; - this.onlineList.UseCompatibleStateImageBehavior = false; - this.onlineList.UseWindowsThemStyle = false; - this.onlineList.View = System.Windows.Forms.View.Details; - this.onlineList.MouseEnter += new System.EventHandler(this.onlineList_MouseEnter); + // servicesOnlineList + // + this.servicesOnlineList.ContextMenuStrip = this.cmdContext; + this.servicesOnlineList.Dock = System.Windows.Forms.DockStyle.Fill; + this.servicesOnlineList.FullRowSelect = true; + this.servicesOnlineList.HideSelection = false; + this.servicesOnlineList.Location = new System.Drawing.Point(3, 3); + this.servicesOnlineList.Name = "servicesOnlineList"; + this.servicesOnlineList.Size = new System.Drawing.Size(800, 133); + this.servicesOnlineList.TabIndex = 0; + this.servicesOnlineList.UseCompatibleStateImageBehavior = false; + this.servicesOnlineList.UseWindowsThemStyle = true; + this.servicesOnlineList.View = System.Windows.Forms.View.Details; // // statusStrip1 // @@ -748,11 +698,10 @@ this.stripPort, this.toolStripStatusLabel6, this.stripConnectedNum}); - this.statusStrip1.Location = new System.Drawing.Point(0, 912); + this.statusStrip1.Location = new System.Drawing.Point(0, 679); this.statusStrip1.Name = "statusStrip1"; - this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 19, 0); this.statusStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.ManagerRenderMode; - this.statusStrip1.Size = new System.Drawing.Size(1476, 30); + this.statusStrip1.Size = new System.Drawing.Size(1083, 26); this.statusStrip1.TabIndex = 2; this.statusStrip1.Text = "statusStrip1"; // @@ -760,56 +709,56 @@ // this.toolStripStatusLabel1.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.toolStripStatusLabel1.Name = "toolStripStatusLabel1"; - this.toolStripStatusLabel1.Size = new System.Drawing.Size(88, 24); + this.toolStripStatusLabel1.Size = new System.Drawing.Size(71, 21); this.toolStripStatusLabel1.Text = "服务器地址:"; // // stripHost // this.stripHost.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.stripHost.Name = "stripHost"; - this.stripHost.Size = new System.Drawing.Size(57, 24); + this.stripHost.Size = new System.Drawing.Size(45, 21); this.stripHost.Text = "0.0.0.0"; // // toolStripStatusLabel5 // this.toolStripStatusLabel5.Name = "toolStripStatusLabel5"; - this.toolStripStatusLabel5.Size = new System.Drawing.Size(873, 24); + this.toolStripStatusLabel5.Size = new System.Drawing.Size(594, 21); this.toolStripStatusLabel5.Spring = true; // // toolStripStatusLabel2 // this.toolStripStatusLabel2.Name = "toolStripStatusLabel2"; - this.toolStripStatusLabel2.Size = new System.Drawing.Size(43, 24); + this.toolStripStatusLabel2.Size = new System.Drawing.Size(35, 21); this.toolStripStatusLabel2.Text = "上传:"; // // struflow // this.struflow.Name = "struflow"; - this.struflow.Size = new System.Drawing.Size(40, 24); + this.struflow.Size = new System.Drawing.Size(32, 21); this.struflow.Text = "0.00"; // // toolStripStatusLabel4 // this.toolStripStatusLabel4.Name = "toolStripStatusLabel4"; - this.toolStripStatusLabel4.Size = new System.Drawing.Size(43, 24); + this.toolStripStatusLabel4.Size = new System.Drawing.Size(36, 21); this.toolStripStatusLabel4.Text = "KB/S"; // // toolStripStatusLabel7 // this.toolStripStatusLabel7.Name = "toolStripStatusLabel7"; - this.toolStripStatusLabel7.Size = new System.Drawing.Size(43, 24); + this.toolStripStatusLabel7.Size = new System.Drawing.Size(35, 21); this.toolStripStatusLabel7.Text = "下传:"; // // strdownflow // this.strdownflow.Name = "strdownflow"; - this.strdownflow.Size = new System.Drawing.Size(40, 24); + this.strdownflow.Size = new System.Drawing.Size(32, 21); this.strdownflow.Text = "0.00"; // // toolStripStatusLabel8 // this.toolStripStatusLabel8.Name = "toolStripStatusLabel8"; - this.toolStripStatusLabel8.Size = new System.Drawing.Size(43, 24); + this.toolStripStatusLabel8.Size = new System.Drawing.Size(36, 21); this.toolStripStatusLabel8.Text = "KB/S"; // // toolStripStatusLabel3 @@ -817,14 +766,14 @@ this.toolStripStatusLabel3.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left; this.toolStripStatusLabel3.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.toolStripStatusLabel3.Name = "toolStripStatusLabel3"; - this.toolStripStatusLabel3.Size = new System.Drawing.Size(47, 24); + this.toolStripStatusLabel3.Size = new System.Drawing.Size(39, 21); this.toolStripStatusLabel3.Text = "端口:"; // // stripPort // this.stripPort.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.stripPort.Name = "stripPort"; - this.stripPort.Size = new System.Drawing.Size(45, 24); + this.stripPort.Size = new System.Drawing.Size(36, 21); this.stripPort.Text = "5200"; // // toolStripStatusLabel6 @@ -832,14 +781,14 @@ this.toolStripStatusLabel6.BorderSides = System.Windows.Forms.ToolStripStatusLabelBorderSides.Left; this.toolStripStatusLabel6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.toolStripStatusLabel6.Name = "toolStripStatusLabel6"; - this.toolStripStatusLabel6.Size = new System.Drawing.Size(77, 24); + this.toolStripStatusLabel6.Size = new System.Drawing.Size(63, 21); this.toolStripStatusLabel6.Text = "主机数量:"; // // stripConnectedNum // this.stripConnectedNum.Font = new System.Drawing.Font("微软雅黑", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.stripConnectedNum.Name = "stripConnectedNum"; - this.stripConnectedNum.Size = new System.Drawing.Size(17, 24); + this.stripConnectedNum.Size = new System.Drawing.Size(14, 21); this.stripConnectedNum.Text = "0"; // // toolStrip1 @@ -855,9 +804,9 @@ this.toolStripButton6, this.toolStripButton14, this.toolStripButton8}); - this.toolStrip1.Location = new System.Drawing.Point(0, 28); + this.toolStrip1.Location = new System.Drawing.Point(0, 25); this.toolStrip1.Name = "toolStrip1"; - this.toolStrip1.Size = new System.Drawing.Size(1476, 59); + this.toolStrip1.Size = new System.Drawing.Size(1083, 56); this.toolStrip1.TabIndex = 6; this.toolStrip1.Text = "toolStrip1"; // @@ -867,7 +816,7 @@ this.toolStripButton10.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButton10.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton10.Name = "toolStripButton10"; - this.toolStripButton10.Size = new System.Drawing.Size(73, 56); + this.toolStripButton10.Size = new System.Drawing.Size(64, 53); this.toolStripButton10.Text = "系统设置"; this.toolStripButton10.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.toolStripButton10.Click += new System.EventHandler(this.toolStripButton10_Click); @@ -878,7 +827,7 @@ this.toolStripButton9.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButton9.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton9.Name = "toolStripButton9"; - this.toolStripButton9.Size = new System.Drawing.Size(73, 56); + this.toolStripButton9.Size = new System.Drawing.Size(64, 53); this.toolStripButton9.Text = "创建客户"; this.toolStripButton9.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.toolStripButton9.Click += new System.EventHandler(this.toolStripButton9_Click); @@ -886,7 +835,7 @@ // toolStripSeparator5 // this.toolStripSeparator5.Name = "toolStripSeparator5"; - this.toolStripSeparator5.Size = new System.Drawing.Size(6, 59); + this.toolStripSeparator5.Size = new System.Drawing.Size(6, 56); // // toolStripButton7 // @@ -894,7 +843,7 @@ this.toolStripButton7.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButton7.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton7.Name = "toolStripButton7"; - this.toolStripButton7.Size = new System.Drawing.Size(73, 56); + this.toolStripButton7.Size = new System.Drawing.Size(64, 53); this.toolStripButton7.Text = "消息通知"; this.toolStripButton7.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.toolStripButton7.Click += new System.EventHandler(this.toolStripButton7_Click); @@ -905,7 +854,7 @@ this.toolStripButton6.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButton6.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton6.Name = "toolStripButton6"; - this.toolStripButton6.Size = new System.Drawing.Size(73, 56); + this.toolStripButton6.Size = new System.Drawing.Size(64, 53); this.toolStripButton6.Text = "下载执行"; this.toolStripButton6.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.toolStripButton6.Click += new System.EventHandler(this.toolStripButton6_Click); @@ -916,7 +865,7 @@ this.toolStripButton14.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButton14.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton14.Name = "toolStripButton14"; - this.toolStripButton14.Size = new System.Drawing.Size(73, 56); + this.toolStripButton14.Size = new System.Drawing.Size(64, 53); this.toolStripButton14.Text = "关闭屏幕"; this.toolStripButton14.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.toolStripButton14.Click += new System.EventHandler(this.toolStripButton14_Click); @@ -927,7 +876,7 @@ this.toolStripButton8.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None; this.toolStripButton8.ImageTransparentColor = System.Drawing.Color.Magenta; this.toolStripButton8.Name = "toolStripButton8"; - this.toolStripButton8.Size = new System.Drawing.Size(73, 56); + this.toolStripButton8.Size = new System.Drawing.Size(64, 53); this.toolStripButton8.Text = "卸载程序"; this.toolStripButton8.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageAboveText; this.toolStripButton8.Click += new System.EventHandler(this.toolStripButton8_Click); @@ -943,8 +892,9 @@ this.toolStripMenuItem3}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; + this.menuStrip1.Padding = new System.Windows.Forms.Padding(4, 2, 0, 2); this.menuStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.menuStrip1.Size = new System.Drawing.Size(1476, 28); + this.menuStrip1.Size = new System.Drawing.Size(1083, 25); this.menuStrip1.TabIndex = 0; this.menuStrip1.Text = "menuStrip1"; // @@ -952,7 +902,7 @@ // this.系统设置ToolStripMenuItem.Name = "系统设置ToolStripMenuItem"; this.系统设置ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.F))); - this.系统设置ToolStripMenuItem.Size = new System.Drawing.Size(101, 24); + this.系统设置ToolStripMenuItem.Size = new System.Drawing.Size(82, 21); this.系统设置ToolStripMenuItem.Text = "系统设置(&F)"; this.系统设置ToolStripMenuItem.Click += new System.EventHandler(this.SystemOption); // @@ -960,7 +910,7 @@ // this.创建客户ToolStripMenuItem.Name = "创建客户ToolStripMenuItem"; this.创建客户ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.E))); - this.创建客户ToolStripMenuItem.Size = new System.Drawing.Size(101, 24); + this.创建客户ToolStripMenuItem.Size = new System.Drawing.Size(83, 21); this.创建客户ToolStripMenuItem.Text = "创建客户(&E)"; this.创建客户ToolStripMenuItem.Click += new System.EventHandler(this.CreateService); // @@ -974,7 +924,7 @@ this.桌面记录查看ToolStripMenuItem}); this.查看ToolStripMenuItem.Name = "查看ToolStripMenuItem"; this.查看ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.V))); - this.查看ToolStripMenuItem.Size = new System.Drawing.Size(103, 24); + this.查看ToolStripMenuItem.Size = new System.Drawing.Size(84, 21); this.查看ToolStripMenuItem.Text = "视图查看(&V)"; // // ToolStripMenuItem @@ -982,7 +932,7 @@ this.ToolStripMenuItem.Checked = true; this.ToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.ToolStripMenuItem.Name = "ToolStripMenuItem"; - this.ToolStripMenuItem.Size = new System.Drawing.Size(182, 26); + this.ToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.ToolStripMenuItem.Text = "工具栏"; this.ToolStripMenuItem.Click += new System.EventHandler(this.ToolStripMenuItem_Click); // @@ -991,7 +941,7 @@ this.statusToolStripMenuItem.Checked = true; this.statusToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.statusToolStripMenuItem.Name = "statusToolStripMenuItem"; - this.statusToolStripMenuItem.Size = new System.Drawing.Size(182, 26); + this.statusToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.statusToolStripMenuItem.Text = "状态栏"; this.statusToolStripMenuItem.Click += new System.EventHandler(this.statusToolStripMenuItem_Click); // @@ -1000,19 +950,19 @@ this.onlineToolStripMenuItem.Checked = true; this.onlineToolStripMenuItem.CheckState = System.Windows.Forms.CheckState.Checked; this.onlineToolStripMenuItem.Name = "onlineToolStripMenuItem"; - this.onlineToolStripMenuItem.Size = new System.Drawing.Size(182, 26); + this.onlineToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.onlineToolStripMenuItem.Text = "选项栏"; this.onlineToolStripMenuItem.Click += new System.EventHandler(this.onlineToolStripMenuItem_Click); // // toolStripSeparator7 // this.toolStripSeparator7.Name = "toolStripSeparator7"; - this.toolStripSeparator7.Size = new System.Drawing.Size(179, 6); + this.toolStripSeparator7.Size = new System.Drawing.Size(145, 6); // // 桌面记录查看ToolStripMenuItem // this.桌面记录查看ToolStripMenuItem.Name = "桌面记录查看ToolStripMenuItem"; - this.桌面记录查看ToolStripMenuItem.Size = new System.Drawing.Size(182, 26); + this.桌面记录查看ToolStripMenuItem.Size = new System.Drawing.Size(148, 22); this.桌面记录查看ToolStripMenuItem.Text = "桌面记录查看"; this.桌面记录查看ToolStripMenuItem.Click += new System.EventHandler(this.viewReviewToolStripMenuItem_Click); // @@ -1020,7 +970,7 @@ // this.锁定ToolStripMenuItem.Name = "锁定ToolStripMenuItem"; this.锁定ToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.G))); - this.锁定ToolStripMenuItem.Size = new System.Drawing.Size(74, 24); + this.锁定ToolStripMenuItem.Size = new System.Drawing.Size(61, 21); this.锁定ToolStripMenuItem.Text = "锁定(&G)"; this.锁定ToolStripMenuItem.Click += new System.EventHandler(this.lockToolStripMenuItem_Click); // @@ -1028,38 +978,25 @@ // this.toolStripMenuItem3.Name = "toolStripMenuItem3"; this.toolStripMenuItem3.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.H))); - this.toolStripMenuItem3.Size = new System.Drawing.Size(105, 24); + this.toolStripMenuItem3.Size = new System.Drawing.Size(85, 21); this.toolStripMenuItem3.Text = "关于程序(&H)"; this.toolStripMenuItem3.Click += new System.EventHandler(this.About); // - // linkLabel2 - // - this.linkLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.linkLabel2.AutoSize = true; - this.linkLabel2.Location = new System.Drawing.Point(1396, 8); - this.linkLabel2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); - this.linkLabel2.Name = "linkLabel2"; - this.linkLabel2.Size = new System.Drawing.Size(67, 15); - this.linkLabel2.TabIndex = 13; - this.linkLabel2.TabStop = true; - this.linkLabel2.Text = "视图设置"; - // // MainApplication // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1476, 942); + this.ClientSize = new System.Drawing.Size(1083, 705); this.Controls.Add(this.splitContainer1); this.Controls.Add(this.statusStrip1); this.Controls.Add(this.toolStrip1); this.Controls.Add(this.menuStrip1); this.MainMenuStrip = this.menuStrip1; - this.Margin = new System.Windows.Forms.Padding(4); this.Name = "MainApplication"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainApplication_FormClosing); this.Load += new System.EventHandler(this.MainApplication_Load); - this.CmdContext.ResumeLayout(false); + this.cmdContext.ResumeLayout(false); this.logsContext.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); @@ -1067,13 +1004,12 @@ this.splitContainer1.ResumeLayout(false); this.panel1.ResumeLayout(false); this.panel1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.deskrefreshTimeSpan)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.rowtrackBar)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.columntrackBar)).EndInit(); - this.splitContainer2.Panel1.ResumeLayout(false); - this.splitContainer2.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); - this.splitContainer2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.rowtrackBar)).EndInit(); + this.splitContainer.Panel1.ResumeLayout(false); + this.splitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); + this.splitContainer.ResumeLayout(false); this.tabControl2.ResumeLayout(false); this.tabPage2.ResumeLayout(false); this.tabControl1.ResumeLayout(false); @@ -1094,7 +1030,6 @@ private System.Windows.Forms.MenuStrip menuStrip1; private System.Windows.Forms.ToolStripMenuItem 系统设置ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 创建客户ToolStripMenuItem; - private UserControls.UListView logList; private System.Windows.Forms.StatusStrip statusStrip1; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1; private System.Windows.Forms.ToolStripStatusLabel stripHost; @@ -1103,7 +1038,7 @@ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel5; private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel6; private System.Windows.Forms.ToolStripStatusLabel stripConnectedNum; - private System.Windows.Forms.ContextMenuStrip CmdContext; + private System.Windows.Forms.ContextMenuStrip cmdContext; private System.Windows.Forms.ToolStripMenuItem 发送信息ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 备注更改ToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem 会话管理ToolStripMenuItem; @@ -1132,14 +1067,14 @@ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem4; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem5; private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; - private System.Windows.Forms.TrackBar columntrackBar; + private System.Windows.Forms.TrackBar rowtrackBar; private System.Windows.Forms.Panel panel1; private System.Windows.Forms.Label label1; private System.Windows.Forms.LinkLabel linkLabel1; private System.Windows.Forms.Label fsd; - private System.Windows.Forms.Label row; - private System.Windows.Forms.TrackBar rowtrackBar; - private System.Windows.Forms.Label column; + private System.Windows.Forms.Label viewRow; + private System.Windows.Forms.TrackBar columntrackBar; + private System.Windows.Forms.Label viewColumn; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button1; private System.Windows.Forms.ToolStrip toolStrip1; @@ -1163,13 +1098,10 @@ private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem11; private System.Windows.Forms.ToolStripSeparator toolStripSeparator7; private System.Windows.Forms.ToolStripMenuItem 桌面记录查看ToolStripMenuItem; - private System.Windows.Forms.Label label2; - private System.Windows.Forms.NumericUpDown deskrefreshTimeSpan; - private System.Windows.Forms.SplitContainer splitContainer2; + private System.Windows.Forms.SplitContainer splitContainer; private System.Windows.Forms.TabControl tabControl2; private System.Windows.Forms.TabPage tabPage2; private System.Windows.Forms.TabPage tabPage1; - private UserControls.UListView onlineList; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem7; private System.Windows.Forms.ComboBox groupBox; @@ -1181,6 +1113,9 @@ private System.Windows.Forms.ToolStripMenuItem installServiceMenuItem; private System.Windows.Forms.ToolStripMenuItem unInstallServiceMenuItem; private System.Windows.Forms.LinkLabel linkLabel2; + private System.Windows.Forms.ToolStripMenuItem ReStartServiceMenuItem; + private UserControls.UListView logList; + private UserControls.UListView servicesOnlineList; } } diff --git a/SiMay.RemoteMonitor/MainApplication/MainApplication.cs b/SiMay.RemoteMonitor/MainApplication/MainApplication.cs index fb9385ee77035c86c86f3662dc791e085444bcf7..4361f8d26e3aa448a3aaee3ee8fb9dca42e7b02e 100644 --- a/SiMay.RemoteMonitor/MainApplication/MainApplication.cs +++ b/SiMay.RemoteMonitor/MainApplication/MainApplication.cs @@ -1,8 +1,7 @@ using SiMay.Basic; using SiMay.Core; using SiMay.Core.Enums; -using SiMay.Net.SessionProvider.Notify; -using SiMay.Net.SessionProvider.SessionBased; +using SiMay.Net.SessionProvider; using SiMay.RemoteControlsCore; using SiMay.RemoteMonitor.Extensions; using SiMay.RemoteMonitor.Properties; @@ -32,20 +31,20 @@ namespace SiMay.RemoteMonitor.MainApplication private bool _isRun = true; private int _connect_count = 0; - private int _desktopViewHeight = 150; - private int _desktopViewWidth = 250; - private int _deskrefreshTimeSpan = 1500; private long _sendTransferredBytes = 0; private long _receiveTransferredBytes = 0; private const string GROUP_ALL = "全部"; - private System.Timers.Timer _timer; + private System.Timers.Timer _flowCalcTimer; + private System.Timers.Timer _viewCarouselTimer; + private DesktopViewSettingContext _viewCarouselContext = new DesktopViewSettingContext(); private Color _closeScreenColor = Color.FromArgb(127, 175, 219); private ImageList _imgList; - private AppMainAdapterHandler _appMainAdapterHandler = new AppMainAdapterHandler(); + private MainApplicationAdapterHandler _appMainAdapterHandler = new MainApplicationAdapterHandler(); private void MainApplication_Load(object sender, EventArgs e) { + this.ViewOnAdaptiveHandler(); this.OnLoadConfiguration(); this.RegisterMessageHandler(); } @@ -57,26 +56,22 @@ namespace SiMay.RemoteMonitor.MainApplication { this.Text = "SiMay远程监控管理系统-IOASJHD 正式版_" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); - bool maximized; - if (bool.TryParse(AppConfiguration.WindowMaximize, out maximized)) - { - if (maximized) - this.WindowState = FormWindowState.Maximized; - } + if (AppConfiguration.WindowMaximize) + this.WindowState = FormWindowState.Maximized; this._imgList = new ImageList(); this._imgList.Images.Add("ok", Resources.ok); this._imgList.Images.Add("error", Resources.erro); //计算实时上下传输流量 - this._timer = new System.Timers.Timer(); - this._timer.Interval = 1000; - this._timer.Elapsed += (a, b) => + this._flowCalcTimer = new System.Timers.Timer(); + this._flowCalcTimer.Interval = 1000; + this._flowCalcTimer.Elapsed += (a, b) => { if (!_isRun) { - _timer.Stop(); - _timer.Dispose(); + _flowCalcTimer.Stop(); + _flowCalcTimer.Dispose(); return; } @@ -90,41 +85,28 @@ namespace SiMay.RemoteMonitor.MainApplication })); }; - this._timer.Start(); - - if (!int.TryParse(AppConfiguration.DesktopViewHeight, out this._desktopViewHeight)) - this._desktopViewHeight = 220; - - if (!int.TryParse(AppConfiguration.DesktopViewWidth, out this._desktopViewWidth)) - this._desktopViewHeight = 280; - - if (!int.TryParse(AppConfiguration.DesktopRefreshTimeSpan, out this._deskrefreshTimeSpan)) - this._deskrefreshTimeSpan = 1500; - + this._flowCalcTimer.Start(); if (AppConfiguration.SessionMode == "1") { this.stripHost.Text = AppConfiguration.ServiceIPAddress; - this.stripPort.Text = AppConfiguration.ServicePort; + this.stripPort.Text = AppConfiguration.ServicePort.ToString(); } else { this.stripHost.Text = AppConfiguration.IPAddress; - this.stripPort.Text = AppConfiguration.Port; + this.stripPort.Text = AppConfiguration.Port.ToString(); } - this.columntrackBar.Value = this._desktopViewHeight; - this.rowtrackBar.Value = this._desktopViewWidth; - this.row.Text = rowtrackBar.Value.ToString(); - this.column.Text = columntrackBar.Value.ToString(); - this.deskrefreshTimeSpan.Value = _deskrefreshTimeSpan; - this.splitContainer2.SplitterDistance = (splitContainer2.Width / 4); + this.rowtrackBar.Value = this._viewCarouselContext.ViewRow; + this.columntrackBar.Value = this._viewCarouselContext.ViewColum; + this.viewRow.Text = columntrackBar.Value.ToString(); + this.viewColumn.Text = rowtrackBar.Value.ToString(); + this.splitContainer.SplitterDistance = (splitContainer.Width / 4); this.logList.SmallImageList = _imgList; this.logList.Columns.Add("发生时间", 150); this.logList.Columns.Add("发生事件", 1000); - this.onlineList.ListViewItemSorter = new Entitys.Common.ListViewColumnSorter(); - //this.onlineList.ColumnClick += new ColumnClickEventHandler(Entitys.Common.ListViewHelper.ListView_ColumnClick); this.groupBox.Text = GROUP_ALL; string[] columnsTitle = new string[] { @@ -141,11 +123,12 @@ namespace SiMay.RemoteMonitor.MainApplication "备注信息", "服务版本", "启动时间", - "分组名称" + "分组名称", + "物理地址" }; for (int i = 0; i < columnsTitle.Length; i++) - this.onlineList.Columns.Insert(i, columnsTitle[i], 150); + this.servicesOnlineList.Columns.Insert(i, columnsTitle[i], 150); var apps = SysUtil.ApplicationTypes.OrderByDescending(x => x.Rank).ToList(); apps.ForEach(c => @@ -153,7 +136,7 @@ namespace SiMay.RemoteMonitor.MainApplication var type = c.Type; var stripMenu = new UToolStripMenuItem(type.GetApplicationName(), c.Type); stripMenu.Click += StripMenu_Click; - this.CmdContext.Items.Insert(0, stripMenu); + this.cmdContext.Items.Insert(0, stripMenu); if (c.Type.OnTools()) { @@ -163,18 +146,104 @@ namespace SiMay.RemoteMonitor.MainApplication } }); - if (bool.TryParse(AppConfiguration.WindowsIsLock, out var isLock)) + if (AppConfiguration.WindowsIsLock) //锁住主控界面 + LockWindow(); + + _viewCarouselTimer = new System.Timers.Timer(_viewCarouselContext.ViewCarouselInterval); + _viewCarouselTimer.Elapsed += ViewCarouselFunc; + + if (_viewCarouselContext.CarouselEnabled) + _viewCarouselTimer.Start(); + + } + private void desktopViewLayout_Resize(object sender, EventArgs e) + { + this.ViewOnAdaptiveHandler(); + } + private void desktopViewLayout_Scroll(object sender, ScrollEventArgs e) + { + //this.ViewOnAdaptiveHandler(); + } + private void ViewOnAdaptiveHandler() + { + var viewCount = _viewCarouselContext.ViewColum * _viewCarouselContext.ViewRow; + var containerRectangle = this.desktopViewLayout.DisplayRectangle; + var marginalRight = (_viewCarouselContext.ViewColum * 9) / this._viewCarouselContext.ViewColum; + var width = (this.desktopViewLayout.Width / _viewCarouselContext.ViewColum) - marginalRight; + var height = (this.desktopViewLayout.Height / _viewCarouselContext.ViewRow) - marginalRight; + + this._viewCarouselContext.ViewWidth = width; + this._viewCarouselContext.ViewHeight = height; + foreach (var view in desktopViewLayout.Controls.Cast()) { - if (isLock) //锁住主控界面 - LockWindow(); + if (view.Width == width && view.Height == height) + continue; + + this.InvokeUI(() => + { + view.Height = height; + view.Width = width; + }); } + + //if (this.desktopViewLayout.Controls.Count <= 0) + // return; + + //var displayTop = Math.Abs(containerRectangle.Y);//容器的可视top(y偏差纠正) + //var displayBottom = Math.Abs(displayTop + desktopViewLayout.Height);//容器的可视bottom + + //var startControlIndex = (displayTop / height) * this._viewCarouselContext.ViewColum; + //var endControlIndex = (displayBottom / height) * this._viewCarouselContext.ViewColum; + + //Console.WriteLine(containerRectangle.Top + "|" + containerRectangle.Bottom); + //Console.WriteLine($"{startControlIndex} | {endControlIndex}"); + + //int index = 0; + //foreach (var view in desktopViewLayout.Controls.Cast()) + //{ + // if (view is Control control) + // { + // var viewX = Math.Abs(control.Location.X); + // var viewY = Math.Abs(control.Location.Y); + // var controlRectangle = new Rectangle(viewX, viewY, control.Width, control.Height); + // view.InVisbleArea = RectangleHelper.WhetherContainsInDisplayRectangle(new Rectangle(0, displayTop, this.desktopViewLayout.Width, this.desktopViewLayout.Height), controlRectangle); + // Console.WriteLine($"{startControlIndex} | {endControlIndex} - " + view.InVisbleArea + " " + index); + // } + // if (view.Width == width && view.Height == height && index++ == viewCount) + // continue; + + // this.InvokeUI(() => + // { + // view.Height = height; + // view.Width = width; + // }); + //} + } + + private void ViewCarouselFunc(object sender, System.Timers.ElapsedEventArgs e) + { + var viewCount = _viewCarouselContext.ViewColum * _viewCarouselContext.ViewRow; + if (this.desktopViewLayout.Controls.Count > viewCount) + { + this.InvokeUI(() => + { + var view = this.desktopViewLayout.Controls[this.desktopViewLayout.Controls.Count - 1].ConvertTo(); + if (!_viewCarouselContext.AlwaysViews.Contains(view)) + this.desktopViewLayout.Controls.SetChildIndex(view as Control, _viewCarouselContext.AlwaysViews.Count); + }); + } + + this.ViewOnAdaptiveHandler(); } + + private void InvokeUI(Action action) => this.Invoke(new Action(action)); + /// /// 初始化通信库 /// private void RegisterMessageHandler() { - this._appMainAdapterHandler.ViewRefreshInterval = _deskrefreshTimeSpan; + this._appMainAdapterHandler.ViewRefreshInterval = _viewCarouselContext.ViewFreshInterval; this._appMainAdapterHandler.SynchronizationContext = SynchronizationContext.Current; this._appMainAdapterHandler.OnProxyNotifyHandlerEvent += OnProxyNotify; this._appMainAdapterHandler.OnReceiveHandlerEvent += OnReceiveHandlerEvent; @@ -183,8 +252,14 @@ namespace SiMay.RemoteMonitor.MainApplication this._appMainAdapterHandler.OnCreateDesktopViewHandlerEvent += OnCreateDesktopViewHandlerEvent; this._appMainAdapterHandler.OnLoginHandlerEvent += OnLoginHandlerEvent; this._appMainAdapterHandler.OnLoginUpdateHandlerEvent += OnLoginUpdateHandlerEvent; + this._appMainAdapterHandler.OnApplicationCreatedEventHandler += OnApplicationCreatedEventHandler; this._appMainAdapterHandler.OnLogHandlerEvent += OnLogHandlerEvent; - this._appMainAdapterHandler.StartService(); + this._appMainAdapterHandler.StartApp(); + } + + private void OnApplicationCreatedEventHandler(IApplication app) + { + } private void OnLoginUpdateHandlerEvent(SessionSyncContext syncContext) @@ -217,21 +292,24 @@ namespace SiMay.RemoteMonitor.MainApplication { var listItem = new USessionListItem(syncContext); syncContext.KeyDictions.Add(SysConstantsExtend.SessionListItem, listItem); - + //是否开启桌面视图 if (!syncContext.KeyDictions[SysConstants.OpenScreenWall].ConvertTo()) listItem.BackColor = _closeScreenColor; var groupName = syncContext.KeyDictions[SysConstants.GroupName].ConvertTo(); if (!groupBox.Items.Contains(groupName)) - groupBox.Items.Add(groupName); + this.groupBox.Items.Add(groupName); //分组 if (groupBox.Text == groupName || groupBox.Text == GROUP_ALL) - this.onlineList.Items.Add(listItem); + this.servicesOnlineList.Items.Add(listItem); - _connect_count++; - stripConnectedNum.Text = _connect_count.ToString(); + //加载完数据调整列宽 + AutoResizeColumnWidth(servicesOnlineList); + + this._connect_count++; + this.stripConnectedNum.Text = _connect_count.ToString(); Win32Api.FlashWindow(this.Handle, true); //上线任务栏图标闪烁 } @@ -251,8 +329,8 @@ namespace SiMay.RemoteMonitor.MainApplication { var view = new UDesktopView(syncContext) { - Width = _desktopViewWidth, - Height = _desktopViewHeight, + Height = this._viewCarouselContext.ViewHeight, + Width = this._viewCarouselContext.ViewWidth }; view.OnDoubleClickEvent += DesktopViewDbClick; this.desktopViewLayout.Controls.Add(view); @@ -260,10 +338,10 @@ namespace SiMay.RemoteMonitor.MainApplication return view; } - private void OnTransmitHandlerEvent(SessionHandler session) + private void OnTransmitHandlerEvent(SessionProviderContext session) => this._sendTransferredBytes += session.SendTransferredBytes; - private void OnReceiveHandlerEvent(SessionHandler session) + private void OnReceiveHandlerEvent(SessionProviderContext session) => this._receiveTransferredBytes += session.ReceiveTransferredBytes; @@ -271,17 +349,17 @@ namespace SiMay.RemoteMonitor.MainApplication /// 代理协议事件 /// /// - private void OnProxyNotify(ProxyNotify notify) + private void OnProxyNotify(ProxyProviderNotify notify, EventArgs arg) { switch (notify) { - case ProxyNotify.AccessKeyWrong: - MessageBoxHelper.ShowBoxExclamation("AccessKey错误,与会话服务器的连接自动关闭!"); + case ProxyProviderNotify.AccessIdOrKeyWrong: + this.InvokeUI(() => this.WriteRuninglog("AccessKey错误,与会话服务器的连接自动关闭!", "error")); break; - case ProxyNotify.LogOut: - if (MessageBox.Show("已有其他控制端连接服务器,本次连接已自动关闭,是否重新连接?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) == DialogResult.OK) + case ProxyProviderNotify.LogOut: + if (MessageBox.Show($"{arg.ConvertTo().Message},本次连接已自动关闭,是否重新连接?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) == DialogResult.OK) { - this._appMainAdapterHandler.SessionProvider.StartSerivce(); + this._appMainAdapterHandler.StartService(); } break; } @@ -324,13 +402,13 @@ namespace SiMay.RemoteMonitor.MainApplication /// private IEnumerable GetSelectedListItem() { - if (onlineList.SelectedItems.Count != 0) + if (servicesOnlineList.SelectedItems.Count != 0) { - var SelectItem = onlineList.SelectedItems; + var SelectItem = servicesOnlineList.SelectedItems; for (int i = 0; i < SelectItem.Count; i++) - onlineList.Items[SelectItem[i].Index].Checked = true; + servicesOnlineList.Items[SelectItem[i].Index].Checked = true; - foreach (USessionListItem item in onlineList.Items) + foreach (USessionListItem item in servicesOnlineList.Items) { if (item.Checked) { @@ -344,7 +422,7 @@ namespace SiMay.RemoteMonitor.MainApplication private void LockWindow() { this.Hide(); - AppConfiguration.WindowsIsLock = "true"; + AppConfiguration.WindowsIsLock = true; LockWindowsForm form = new LockWindowsForm(); form.ShowDialog(); this.Show(); @@ -353,7 +431,7 @@ namespace SiMay.RemoteMonitor.MainApplication private void StripButton_Click(object sender, EventArgs e) { var ustripbtn = sender as UToolStripButton; - string appkey = ustripbtn.CtrlType.GetAppKey(); + string appkey = ustripbtn.CtrlType.GetApplicationKey(); this.GetSelectedDesktopView().ForEach(c => { this._appMainAdapterHandler.RemoteActiveService(c.SessionSyncContext, appkey); @@ -363,7 +441,7 @@ namespace SiMay.RemoteMonitor.MainApplication private void StripMenu_Click(object sender, EventArgs e) { var ustripbtn = sender as UToolStripMenuItem; - string appkey = ustripbtn.CtrlType.GetAppKey(); + string appkey = ustripbtn.ApplicationType.GetApplicationKey(); this.GetSelectedListItem().ForEach(c => { this._appMainAdapterHandler.RemoteActiveService(c.SessionSyncContext, appkey); @@ -421,10 +499,10 @@ namespace SiMay.RemoteMonitor.MainApplication private void CmdContext_Opening(object sender, CancelEventArgs e) { - if (onlineList.SelectedItems.Count == 0) - CmdContext.Enabled = false; + if (servicesOnlineList.SelectedItems.Count == 0) + cmdContext.Enabled = false; else - CmdContext.Enabled = true; + cmdContext.Enabled = true; } private void CreateService(object sender, EventArgs e) @@ -534,13 +612,13 @@ namespace SiMay.RemoteMonitor.MainApplication private void OnlineList_OnSelected(object sender, EventArgs e) { - foreach (ListViewItem item in onlineList.Items) + foreach (ListViewItem item in servicesOnlineList.Items) item.Checked = true; } private void OnileList_OnUnSelected(object sender, EventArgs e) { - foreach (ListViewItem item in onlineList.Items) + foreach (ListViewItem item in servicesOnlineList.Items) item.Checked = false; } @@ -642,40 +720,22 @@ namespace SiMay.RemoteMonitor.MainApplication private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { - if (deskrefreshTimeSpan.Value < 300) - { - this.WriteRuninglog("设置未保存,刷新间隔不能小于300!", "error"); - return; - } - - this._desktopViewHeight = columntrackBar.Value; - this._desktopViewWidth = rowtrackBar.Value; + this._viewCarouselContext.ViewRow = rowtrackBar.Value; + this._viewCarouselContext.ViewColum = columntrackBar.Value; - AppConfiguration.DesktopViewHeight = _desktopViewHeight.ToString(); - AppConfiguration.DesktopViewWidth = _desktopViewWidth.ToString(); - AppConfiguration.DesktopRefreshTimeSpan = deskrefreshTimeSpan.Value.ToString(); - - this._deskrefreshTimeSpan = (int)deskrefreshTimeSpan.Value; - - this._appMainAdapterHandler.ViewRefreshInterval = _deskrefreshTimeSpan; - - foreach (UDesktopView item in desktopViewLayout.Controls) - { - item.Width = _desktopViewWidth; - item.Height = _desktopViewHeight; - } + this.ViewOnAdaptiveHandler(); this.WriteRuninglog("设置已保存!", "ok"); } private void RowtrackBar_Scroll(object sender, EventArgs e) { - this.row.Text = rowtrackBar.Value.ToString(); + this.viewRow.Text = columntrackBar.Value.ToString(); } private void ColumntrackBar_Scroll(object sender, EventArgs e) { - this.column.Text = columntrackBar.Value.ToString(); + this.viewColumn.Text = rowtrackBar.Value.ToString(); } private void button1_Click(object sender, EventArgs e) @@ -776,7 +836,7 @@ namespace SiMay.RemoteMonitor.MainApplication if (MessageBox.Show("是否确认退出系统吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { this._isRun = false; - this._appMainAdapterHandler.CloseService(); + this._appMainAdapterHandler.Dispose(); } else { @@ -820,12 +880,12 @@ namespace SiMay.RemoteMonitor.MainApplication private void logList_MouseEnter(object sender, EventArgs e) { - this.splitContainer2.SplitterDistance = splitContainer2.Width - (splitContainer2.Width / 4); + this.splitContainer.SplitterDistance = splitContainer.Width - (splitContainer.Width / 4); } private void onlineList_MouseEnter(object sender, EventArgs e) { - this.splitContainer2.SplitterDistance = (splitContainer2.Width / 4); + this.splitContainer.SplitterDistance = (splitContainer.Width / 4); } private void ToolStripMenuItem7_Click(object sender, EventArgs e) @@ -846,13 +906,13 @@ namespace SiMay.RemoteMonitor.MainApplication { //界面初始化完成会被触发一次。。 - foreach (var item in this._appMainAdapterHandler.SyncContexts) + foreach (var item in this._appMainAdapterHandler.SessionSyncContexts) item.KeyDictions[SysConstantsExtend.SessionListItem].ConvertTo().Remove(); - foreach (var item in this._appMainAdapterHandler.SyncContexts) + foreach (var item in this._appMainAdapterHandler.SessionSyncContexts) { if (item.KeyDictions[SysConstants.GroupName].ConvertTo() == groupBox.Text || groupBox.Text == GROUP_ALL) - this.onlineList.Items.Add(item.KeyDictions[SysConstantsExtend.SessionListItem].ConvertTo()); + this.servicesOnlineList.Items.Add(item.KeyDictions[SysConstantsExtend.SessionListItem].ConvertTo()); } } @@ -862,9 +922,10 @@ namespace SiMay.RemoteMonitor.MainApplication { if (dlg.ShowDialog() == DialogResult.OK) { + byte[] bytFile = File.ReadAllBytes(dlg.Value); this.GetSelectedListItem().ForEach(c => { - this._appMainAdapterHandler.RemoteServiceUpdate(c.SessionSyncContext, dlg.UrlOrFileUpdate, File.ReadAllBytes(dlg.Value), dlg.Value); + this._appMainAdapterHandler.RemoteServiceUpdate(c.SessionSyncContext, dlg.UrlOrFileUpdate, bytFile, dlg.Value); }); } } @@ -900,5 +961,66 @@ namespace SiMay.RemoteMonitor.MainApplication this._appMainAdapterHandler.RemoteSetSessionState(c.SessionSyncContext, SystemSessionType.UnInstallService); }); } + + private void linkLabel2_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + var dialog = new DesktopViewWallSettingForm(_viewCarouselContext); + if (dialog.ShowDialog() == DialogResult.OK) + { + _appMainAdapterHandler.ViewRefreshInterval = _viewCarouselContext.ViewFreshInterval; + + if (!_viewCarouselContext.CarouselEnabled) + this._viewCarouselTimer.Stop(); + else + { + this._viewCarouselTimer.Interval = _viewCarouselContext.ViewCarouselInterval; + this._viewCarouselTimer.Start(); + } + this.ViewOnAdaptiveHandler(); + } + } + /// + /// 重启服务项 + /// + /// + /// + private void ReStartServiceMenuItem_Click(object sender, EventArgs e) + { + if (MessageBox.Show("确定重启系统服务吗?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) != DialogResult.OK) + return; + this.GetSelectedListItem().ForEach(c => + { + this._appMainAdapterHandler.RemoteSetSessionState(c.SessionSyncContext, SystemSessionType.ReStartService); + }); + } + /// + /// 自动调整ListView列宽 + /// + /// + public void AutoResizeColumnWidth(ListView listView) + { + int intColumnCount = listView.Columns.Count; + Graphics graphics = listView.CreateGraphics(); + Font font = listView.Font; + ListView.ListViewItemCollection items = listView.Items; + + listView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.HeaderSize); + + for (int intCount = 0; intCount < intColumnCount; intCount++) + { + int intMaxWidth = listView.Columns[intCount].Width; + + foreach (ListViewItem item in items) + { + string strContent = item.SubItems[intCount].Text; + int intWidth = (int)graphics.MeasureString(strContent, font).Width; + if (intWidth > intMaxWidth) + { + intMaxWidth = intWidth; + } + } + listView.Columns[intCount].Width = intMaxWidth; + } + } } } \ No newline at end of file diff --git a/SiMay.RemoteMonitor/MainApplication/MainApplication.resx b/SiMay.RemoteMonitor/MainApplication/MainApplication.resx index 89939ae670cd47b5453fe9edd1371fda4d00b0cc..e8efdc0cea7b4acc07551fbd65fa857bc6f6ec7e 100644 --- a/SiMay.RemoteMonitor/MainApplication/MainApplication.resx +++ b/SiMay.RemoteMonitor/MainApplication/MainApplication.resx @@ -117,20 +117,20 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 137, 17 + + 17, 17 - 262, 17 + 260, 17 - 384, 17 + 382, 17 - 505, 17 + 503, 17 - 17, 17 + 140, 17 51 diff --git a/SiMay.RemoteMonitor/MainApplication/RemoteUpdateServiceForm.cs b/SiMay.RemoteMonitor/MainApplication/RemoteUpdateServiceForm.cs index 03c095cf513bf5a004190c76bc241e9dcee393a9..0979b5eb93305766615b1f469ed43e17e93b8af4 100644 --- a/SiMay.RemoteMonitor/MainApplication/RemoteUpdateServiceForm.cs +++ b/SiMay.RemoteMonitor/MainApplication/RemoteUpdateServiceForm.cs @@ -33,11 +33,11 @@ namespace SiMay.RemoteMonitor.MainApplication MessageBoxHelper.ShowBoxError("请选择正确的文件路径!"); return; } - if (new FileInfo(txtPath.Text).Length > 1024 * 1024) - { - MessageBoxHelper.ShowBoxError("文件大于1M!"); - return; - } + //if (new FileInfo(txtPath.Text).Length > 1024 * 1024) + //{ + // MessageBoxHelper.ShowBoxError("文件大于1M!"); + // return; + //} Value = txtPath.Text; UrlOrFileUpdate = RemoteUpdateType.File; } diff --git a/SiMay.RemoteMonitor/Properties/AssemblyInfo.cs b/SiMay.RemoteMonitor/Properties/AssemblyInfo.cs index d65fcccb775432eda04150338e3b72eb8e8d6d2d..98116f01d86668209d28bf310e41ae44ed6ef399 100644 Binary files a/SiMay.RemoteMonitor/Properties/AssemblyInfo.cs and b/SiMay.RemoteMonitor/Properties/AssemblyInfo.cs differ diff --git a/SiMay.RemoteMonitor/Properties/Settings.Designer.cs b/SiMay.RemoteMonitor/Properties/Settings.Designer.cs index b0916e5cc386b9f7936a55c24d68a82a40c3a0d1..5bca977b90bb515a6805476b9d4f126b90154164 100644 --- a/SiMay.RemoteMonitor/Properties/Settings.Designer.cs +++ b/SiMay.RemoteMonitor/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace SiMay.RemoteMonitor.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.0.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.3.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/SiMay.RemoteMonitor/SiMay.RemoteMonitor.csproj b/SiMay.RemoteMonitor/SiMay.RemoteMonitor.csproj index 5b8ef1fd6630a98c5f9ed7007e61a5f08e706395..c1c592fcd96ed515051f795849178583cf8c8de7 100644 --- a/SiMay.RemoteMonitor/SiMay.RemoteMonitor.csproj +++ b/SiMay.RemoteMonitor/SiMay.RemoteMonitor.csproj @@ -9,10 +9,12 @@ Properties SiMay.RemoteMonitor SiMayRemoteMonitor - v4.5 + v4.6.1 512 + + AnyCPU @@ -45,7 +47,7 @@ true - bin\x86\Debug\ + ..\Bin\ DEBUG;TRACE full x86 @@ -55,7 +57,7 @@ 8.0 - bin\x86\Release\ + ..\Bin\ TRACE true pdbonly @@ -69,10 +71,20 @@ app.manifest + + ..\packages\Accord.3.8.0\lib\net46\Accord.dll + + + ..\packages\Accord.Video.3.8.0\lib\net46\Accord.Video.dll + + + ..\packages\Accord.Video.FFMPEG.3.8.0\lib\net46\Accord.Video.FFMPEG.dll + + @@ -155,21 +167,26 @@ TcpConnectionApplication.cs + - + + + Form - + DesktopViewWallSettingForm.cs + Form RemoteUpdateServiceForm.cs + @@ -383,7 +400,7 @@ DesktopRecordViewerForm.cs - + DesktopViewWallSettingForm.cs @@ -440,6 +457,7 @@ Designer + SettingsSingleFileGenerator Settings.Designer.cs @@ -496,7 +514,7 @@ - {b30cd716-698a-4da2-bd1a-c152b16993c0} + {8f2f35cb-d5ee-4d92-b42f-bcffbf9c9d4f} SiMay.Basic @@ -504,20 +522,29 @@ SiMay.Core - {BF5B6F41-D688-447F-BF81-EA821216F188} + {71283236-56cb-481e-a644-b7f9af9efdf9} SiMay.Net.SessionProvider {44dfa13c-03c3-4f07-9d78-30f981bfabc5} SiMay.RemoteControlsCore - - {4888d6bb-46d9-4519-8758-e13e397aa226} - SiMay.Serialize + + {9525a4aa-6731-4ab2-8cd0-addf7940fe32} + SiMay.Serialize.Standard + + + + 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。 + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SiMay.UpdateClient/Properties/Settings.Designer.cs b/SiMay.UpdateClient/Properties/Settings.Designer.cs deleted file mode 100644 index b2953e24bf2386f814139d0da38ea59e82f59f73..0000000000000000000000000000000000000000 --- a/SiMay.UpdateClient/Properties/Settings.Designer.cs +++ /dev/null @@ -1,30 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.42000 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace SiMay.UpdateClient.Properties -{ - - - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.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; - } - } - } -} diff --git a/SiMay.UpdateClient/Properties/Settings.settings b/SiMay.UpdateClient/Properties/Settings.settings deleted file mode 100644 index 39645652af62950ebf3b28ec3a5400dcec30b1c4..0000000000000000000000000000000000000000 --- a/SiMay.UpdateClient/Properties/Settings.settings +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/SiMay.UpdateClient/SiMay.UpdateClient.csproj b/SiMay.UpdateClient/SiMay.UpdateClient.csproj deleted file mode 100644 index a8a9cd86a6af6a6b92aae55f2e866a8da313c645..0000000000000000000000000000000000000000 --- a/SiMay.UpdateClient/SiMay.UpdateClient.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - - Debug - AnyCPU - {76E07A4F-8839-4260-925A-3179DB1C6045} - WinExe - SiMay.UpdateClient - SiMay.UpdateClient - v4.0 - 512 - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - \ No newline at end of file diff --git a/SiMay.UpdateClient/SiMaySeriver.NewCore.mm b/SiMay.UpdateClient/SiMaySeriver.NewCore.mm deleted file mode 100644 index a21b725e69ce35951eb7544cde51cb16aad0b9a2..0000000000000000000000000000000000000000 Binary files a/SiMay.UpdateClient/SiMaySeriver.NewCore.mm and /dev/null differ diff --git a/SiMayRemoteManager.sln b/SiMayRemoteMonitorOS.sln similarity index 52% rename from SiMayRemoteManager.sln rename to SiMayRemoteMonitorOS.sln index 9e3c09d98b07779709b58dff25b96e6802119991..36abc69f81625da12810136e8d3d32bc307b4f13 100644 --- a/SiMayRemoteManager.sln +++ b/SiMayRemoteMonitorOS.sln @@ -7,43 +7,39 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.RemoteMonitor", "SiMa EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Core", "SiMay.Core\SiMay.Core.csproj", "{1AADC6F7-6FF9-4C68-8A26-E507F22B9060}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Daemon", "SiMay.Daemon\SiMay.Daemon.csproj", "{77867DE2-193E-4533-B365-31CEF16A876B}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.UpdateClient", "SiMay.UpdateClient\SiMay.UpdateClient.csproj", "{76E07A4F-8839-4260-925A-3179DB1C6045}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Sockets", "SiMay.Sockets\SiMay.Sockets.csproj", "{B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.ServiceCore", "SiMay.RemoteClient.NewCore\SiMay.ServiceCore.csproj", "{8D061D46-9E59-42B0-91DC-4E380E4AE0BA}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Sockets.V4", "SiMay.Sockets.V4\SiMay.Sockets.V4.csproj", "{D181FCCE-ECC7-4710-89CC-D97F94A6181B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Net.SessionProviderService", "SiMay.Net.SessionProviderService\SiMay.Net.SessionProviderService.csproj", "{61FB6C20-4541-40D1-AC4B-3ECDACF5F633}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Net.SessionProvider", "SiMay.Net.SessionProvider\SiMay.Net.SessionProvider.csproj", "{BF5B6F41-D688-447F-BF81-EA821216F188}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.RemoteService", "SiMay.RemoteService", "{FBA5D1FE-11EA-4FAE-B88F-7E2E809419C9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Net.SessionProviderService", "SiMay.Net.SessionProviderService\SiMay.Net.SessionProviderService.csproj", "{61FB6C20-4541-40D1-AC4B-3ECDACF5F633}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.RemoteMonitor", "SiMay.RemoteMonitor", "{A86A6BBD-1122-4993-B472-6A0265E5F2A1}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Net.HttpRemoteMonitorService", "SiMay.Net.HttpRemoteMonitorService\SiMay.Net.HttpRemoteMonitorService.csproj", "{3D24108A-C922-4BAB-9D2B-060480B7A46C}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.Core", "SiMay.Core", "{5E72F9F6-8DB0-4727-92F3-D05A3CC0348E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Net.SessionProvider.Core", "SiMay.Net.SessionProvider.Core\SiMay.Net.SessionProvider.Core.csproj", "{8BFDB408-D26D-4689-B426-BE45AD195880}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.Sockets", "SiMay.Sockets", "{D0952F11-B4B6-4AD4-8F72-C35BD6A33D59}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Basic", "SiMay.Basic\SiMay.Basic.csproj", "{B30CD716-698A-4DA2-BD1A-C152B16993C0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.SessionProvider", "SiMay.SessionProvider", "{9328FEED-6E95-4863-BB7B-521D0D02D7FA}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.RemoteService", "SiMay.RemoteService", "{FBA5D1FE-11EA-4FAE-B88F-7E2E809419C9}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.RemoteControlsCore", "SiMay.RemoteControlsCore\SiMay.RemoteControlsCore.csproj", "{44DFA13C-03C3-4F07-9D78-30F981BFABC5}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.RemoteMonitor.Windows", "SiMay.RemoteMonitor.Windows", "{A86A6BBD-1122-4993-B472-6A0265E5F2A1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiMay.Sockets.Standard", "SiMay.Sockets.Standard\SiMay.Sockets.Standard.csproj", "{866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.Common.Core", "SiMay.Common.Core", "{5E72F9F6-8DB0-4727-92F3-D05A3CC0348E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.RemoteService.Loader", "SiMay.RemoteService.Loader\SiMay.RemoteService.Loader.csproj", "{7EFE8058-F772-40EB-8E12-6E88E2A9E19A}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.Sockets", "SiMay.Sockets", "{D0952F11-B4B6-4AD4-8F72-C35BD6A33D59}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiMay.Net.SessionProviderServiceCore", "SiMay.Net.SessionProviderServiceCore\SiMay.Net.SessionProviderServiceCore.csproj", "{3C91F949-5187-4CDF-9A5B-AA3C20F7544B}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.Web.MonitorService", "SiMay.Web.MonitorService", "{ED3E9905-4EBF-4D77-8354-5A7D315C28C2}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiMay.Basic", "SiMay.Basic\SiMay.Basic.csproj", "{8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SiMay.SessionProvider", "SiMay.SessionProvider", "{9328FEED-6E95-4863-BB7B-521D0D02D7FA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiMay.Serialize.Standard", "SiMay.Serialize.Standard\SiMay.Serialize.Standard.csproj", "{9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Serialize", "SiMay.Serialize\SiMay.Serialize.csproj", "{4888D6BB-46D9-4519-8758-E13E397AA226}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiMay.Net.SessionProvider", "SiMay.Net.SessionProvider\SiMay.Net.SessionProvider.csproj", "{71283236-56CB-481E-A644-B7F9AF9EFDF9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.RemoteService", "SiMay.RemoteService\SiMay.RemoteService.csproj", "{7EFE8058-F772-40EB-8E12-6E88E2A9E19A}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiMay.Net.SessionProvider.Core", "SiMay.Net.SessionProvider.Core\SiMay.Net.SessionProvider.Core.csproj", "{0B2B697D-DD20-4869-836C-08C848E1813F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.RemoteControlsCore", "SiMay.RemoteControlsCore\SiMay.RemoteControlsCore.csproj", "{44DFA13C-03C3-4F07-9D78-30F981BFABC5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiMay.RemoteMonitorForWeb", "SiMay.RemoteMonitorForWeb\SiMay.RemoteMonitorForWeb.csproj", "{55F9EAC2-AA55-4E10-8B00-404EBC7E164D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiMay.Net.SessionProviderService.NetCore", "SiMay.Net.SessionProviderService.NetCore\SiMay.Net.SessionProviderService.NetCore.csproj", "{8CB7B268-478C-48C0-B205-CC81CC32A970}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -80,42 +76,6 @@ Global {1AADC6F7-6FF9-4C68-8A26-E507F22B9060}.Release|x64.Build.0 = Release|Any CPU {1AADC6F7-6FF9-4C68-8A26-E507F22B9060}.Release|x86.ActiveCfg = Release|Any CPU {1AADC6F7-6FF9-4C68-8A26-E507F22B9060}.Release|x86.Build.0 = Release|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Debug|x64.ActiveCfg = Debug|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Debug|x64.Build.0 = Debug|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Debug|x86.ActiveCfg = Debug|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Debug|x86.Build.0 = Debug|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Release|Any CPU.Build.0 = Release|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Release|x64.ActiveCfg = Release|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Release|x64.Build.0 = Release|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Release|x86.ActiveCfg = Release|Any CPU - {77867DE2-193E-4533-B365-31CEF16A876B}.Release|x86.Build.0 = Release|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Debug|Any CPU.Build.0 = Debug|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Debug|x64.ActiveCfg = Debug|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Debug|x64.Build.0 = Debug|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Debug|x86.ActiveCfg = Debug|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Debug|x86.Build.0 = Debug|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Release|Any CPU.ActiveCfg = Release|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Release|Any CPU.Build.0 = Release|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Release|x64.ActiveCfg = Release|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Release|x64.Build.0 = Release|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Release|x86.ActiveCfg = Release|Any CPU - {76E07A4F-8839-4260-925A-3179DB1C6045}.Release|x86.Build.0 = Release|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Debug|x64.ActiveCfg = Debug|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Debug|x64.Build.0 = Debug|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Debug|x86.ActiveCfg = Debug|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Debug|x86.Build.0 = Debug|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Release|Any CPU.Build.0 = Release|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Release|x64.ActiveCfg = Release|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Release|x64.Build.0 = Release|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Release|x86.ActiveCfg = Release|Any CPU - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE}.Release|x86.Build.0 = Release|Any CPU {8D061D46-9E59-42B0-91DC-4E380E4AE0BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {8D061D46-9E59-42B0-91DC-4E380E4AE0BA}.Debug|Any CPU.Build.0 = Debug|Any CPU {8D061D46-9E59-42B0-91DC-4E380E4AE0BA}.Debug|x64.ActiveCfg = Debug|x64 @@ -128,30 +88,6 @@ Global {8D061D46-9E59-42B0-91DC-4E380E4AE0BA}.Release|x64.Build.0 = Release|x64 {8D061D46-9E59-42B0-91DC-4E380E4AE0BA}.Release|x86.ActiveCfg = Release|Any CPU {8D061D46-9E59-42B0-91DC-4E380E4AE0BA}.Release|x86.Build.0 = Release|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Debug|x64.ActiveCfg = Debug|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Debug|x64.Build.0 = Debug|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Debug|x86.ActiveCfg = Debug|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Debug|x86.Build.0 = Debug|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Release|Any CPU.Build.0 = Release|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Release|x64.ActiveCfg = Release|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Release|x64.Build.0 = Release|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Release|x86.ActiveCfg = Release|Any CPU - {D181FCCE-ECC7-4710-89CC-D97F94A6181B}.Release|x86.Build.0 = Release|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Debug|x64.ActiveCfg = Debug|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Debug|x64.Build.0 = Debug|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Debug|x86.ActiveCfg = Debug|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Debug|x86.Build.0 = Debug|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Release|Any CPU.Build.0 = Release|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Release|x64.ActiveCfg = Release|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Release|x64.Build.0 = Release|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Release|x86.ActiveCfg = Release|Any CPU - {BF5B6F41-D688-447F-BF81-EA821216F188}.Release|x86.Build.0 = Release|Any CPU {61FB6C20-4541-40D1-AC4B-3ECDACF5F633}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {61FB6C20-4541-40D1-AC4B-3ECDACF5F633}.Debug|Any CPU.Build.0 = Debug|Any CPU {61FB6C20-4541-40D1-AC4B-3ECDACF5F633}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -164,66 +100,6 @@ Global {61FB6C20-4541-40D1-AC4B-3ECDACF5F633}.Release|x64.Build.0 = Release|Any CPU {61FB6C20-4541-40D1-AC4B-3ECDACF5F633}.Release|x86.ActiveCfg = Release|Any CPU {61FB6C20-4541-40D1-AC4B-3ECDACF5F633}.Release|x86.Build.0 = Release|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Debug|x64.ActiveCfg = Debug|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Debug|x64.Build.0 = Debug|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Debug|x86.ActiveCfg = Debug|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Debug|x86.Build.0 = Debug|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Release|Any CPU.Build.0 = Release|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Release|x64.ActiveCfg = Release|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Release|x64.Build.0 = Release|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Release|x86.ActiveCfg = Release|Any CPU - {3D24108A-C922-4BAB-9D2B-060480B7A46C}.Release|x86.Build.0 = Release|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Debug|x64.ActiveCfg = Debug|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Debug|x64.Build.0 = Debug|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Debug|x86.ActiveCfg = Debug|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Debug|x86.Build.0 = Debug|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Release|Any CPU.Build.0 = Release|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Release|x64.ActiveCfg = Release|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Release|x64.Build.0 = Release|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Release|x86.ActiveCfg = Release|Any CPU - {8BFDB408-D26D-4689-B426-BE45AD195880}.Release|x86.Build.0 = Release|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Debug|x64.ActiveCfg = Debug|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Debug|x64.Build.0 = Debug|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Debug|x86.ActiveCfg = Debug|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Debug|x86.Build.0 = Debug|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Release|Any CPU.Build.0 = Release|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Release|x64.ActiveCfg = Release|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Release|x64.Build.0 = Release|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Release|x86.ActiveCfg = Release|Any CPU - {B30CD716-698A-4DA2-BD1A-C152B16993C0}.Release|x86.Build.0 = Release|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Debug|x64.ActiveCfg = Debug|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Debug|x64.Build.0 = Debug|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Debug|x86.ActiveCfg = Debug|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Debug|x86.Build.0 = Debug|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Release|Any CPU.Build.0 = Release|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Release|x64.ActiveCfg = Release|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Release|x64.Build.0 = Release|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Release|x86.ActiveCfg = Release|Any CPU - {4888D6BB-46D9-4519-8758-E13E397AA226}.Release|x86.Build.0 = Release|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x64.ActiveCfg = Debug|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x64.Build.0 = Debug|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x86.ActiveCfg = Debug|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x86.Build.0 = Debug|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|Any CPU.Build.0 = Release|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x64.ActiveCfg = Release|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x64.Build.0 = Release|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x86.ActiveCfg = Release|Any CPU - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x86.Build.0 = Release|Any CPU {44DFA13C-03C3-4F07-9D78-30F981BFABC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {44DFA13C-03C3-4F07-9D78-30F981BFABC5}.Debug|Any CPU.Build.0 = Debug|Any CPU {44DFA13C-03C3-4F07-9D78-30F981BFABC5}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -236,6 +112,114 @@ Global {44DFA13C-03C3-4F07-9D78-30F981BFABC5}.Release|x64.Build.0 = Release|Any CPU {44DFA13C-03C3-4F07-9D78-30F981BFABC5}.Release|x86.ActiveCfg = Release|Any CPU {44DFA13C-03C3-4F07-9D78-30F981BFABC5}.Release|x86.Build.0 = Release|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Debug|Any CPU.Build.0 = Debug|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Debug|x64.ActiveCfg = Debug|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Debug|x64.Build.0 = Debug|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Debug|x86.ActiveCfg = Debug|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Debug|x86.Build.0 = Debug|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Release|Any CPU.ActiveCfg = Release|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Release|Any CPU.Build.0 = Release|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Release|x64.ActiveCfg = Release|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Release|x64.Build.0 = Release|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Release|x86.ActiveCfg = Release|Any CPU + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40}.Release|x86.Build.0 = Release|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x64.ActiveCfg = Debug|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x64.Build.0 = Debug|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x86.ActiveCfg = Debug|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Debug|x86.Build.0 = Debug|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|Any CPU.Build.0 = Release|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x64.ActiveCfg = Release|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x64.Build.0 = Release|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x86.ActiveCfg = Release|Any CPU + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A}.Release|x86.Build.0 = Release|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Debug|x64.ActiveCfg = Debug|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Debug|x64.Build.0 = Debug|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Debug|x86.ActiveCfg = Debug|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Debug|x86.Build.0 = Debug|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Release|Any CPU.Build.0 = Release|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Release|x64.ActiveCfg = Release|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Release|x64.Build.0 = Release|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Release|x86.ActiveCfg = Release|Any CPU + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B}.Release|x86.Build.0 = Release|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Debug|x64.ActiveCfg = Debug|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Debug|x64.Build.0 = Debug|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Debug|x86.ActiveCfg = Debug|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Debug|x86.Build.0 = Debug|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Release|Any CPU.Build.0 = Release|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Release|x64.ActiveCfg = Release|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Release|x64.Build.0 = Release|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Release|x86.ActiveCfg = Release|Any CPU + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F}.Release|x86.Build.0 = Release|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Debug|x64.ActiveCfg = Debug|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Debug|x64.Build.0 = Debug|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Debug|x86.ActiveCfg = Debug|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Debug|x86.Build.0 = Debug|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Release|Any CPU.Build.0 = Release|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Release|x64.ActiveCfg = Release|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Release|x64.Build.0 = Release|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Release|x86.ActiveCfg = Release|Any CPU + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32}.Release|x86.Build.0 = Release|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Debug|x64.ActiveCfg = Debug|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Debug|x64.Build.0 = Debug|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Debug|x86.ActiveCfg = Debug|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Debug|x86.Build.0 = Debug|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Release|Any CPU.Build.0 = Release|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Release|x64.ActiveCfg = Release|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Release|x64.Build.0 = Release|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Release|x86.ActiveCfg = Release|Any CPU + {71283236-56CB-481E-A644-B7F9AF9EFDF9}.Release|x86.Build.0 = Release|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Debug|x64.ActiveCfg = Debug|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Debug|x64.Build.0 = Debug|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Debug|x86.ActiveCfg = Debug|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Debug|x86.Build.0 = Debug|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Release|Any CPU.Build.0 = Release|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Release|x64.ActiveCfg = Release|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Release|x64.Build.0 = Release|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Release|x86.ActiveCfg = Release|Any CPU + {0B2B697D-DD20-4869-836C-08C848E1813F}.Release|x86.Build.0 = Release|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Debug|x64.ActiveCfg = Debug|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Debug|x64.Build.0 = Debug|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Debug|x86.ActiveCfg = Debug|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Debug|x86.Build.0 = Debug|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Release|Any CPU.Build.0 = Release|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Release|x64.ActiveCfg = Release|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Release|x64.Build.0 = Release|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Release|x86.ActiveCfg = Release|Any CPU + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D}.Release|x86.Build.0 = Release|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Debug|x64.ActiveCfg = Debug|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Debug|x64.Build.0 = Debug|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Debug|x86.ActiveCfg = Debug|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Debug|x86.Build.0 = Debug|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Release|Any CPU.Build.0 = Release|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Release|x64.ActiveCfg = Release|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Release|x64.Build.0 = Release|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Release|x86.ActiveCfg = Release|Any CPU + {8CB7B268-478C-48C0-B205-CC81CC32A970}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -243,19 +227,18 @@ Global GlobalSection(NestedProjects) = preSolution {97E36F9B-145B-41DB-B6CF-E054B010869E} = {A86A6BBD-1122-4993-B472-6A0265E5F2A1} {1AADC6F7-6FF9-4C68-8A26-E507F22B9060} = {5E72F9F6-8DB0-4727-92F3-D05A3CC0348E} - {77867DE2-193E-4533-B365-31CEF16A876B} = {FBA5D1FE-11EA-4FAE-B88F-7E2E809419C9} - {76E07A4F-8839-4260-925A-3179DB1C6045} = {FBA5D1FE-11EA-4FAE-B88F-7E2E809419C9} - {B0F8473C-10B8-4CF7-AE18-32037FA9BBAE} = {D0952F11-B4B6-4AD4-8F72-C35BD6A33D59} {8D061D46-9E59-42B0-91DC-4E380E4AE0BA} = {FBA5D1FE-11EA-4FAE-B88F-7E2E809419C9} - {D181FCCE-ECC7-4710-89CC-D97F94A6181B} = {D0952F11-B4B6-4AD4-8F72-C35BD6A33D59} - {BF5B6F41-D688-447F-BF81-EA821216F188} = {9328FEED-6E95-4863-BB7B-521D0D02D7FA} {61FB6C20-4541-40D1-AC4B-3ECDACF5F633} = {9328FEED-6E95-4863-BB7B-521D0D02D7FA} - {3D24108A-C922-4BAB-9D2B-060480B7A46C} = {ED3E9905-4EBF-4D77-8354-5A7D315C28C2} - {8BFDB408-D26D-4689-B426-BE45AD195880} = {9328FEED-6E95-4863-BB7B-521D0D02D7FA} - {B30CD716-698A-4DA2-BD1A-C152B16993C0} = {5E72F9F6-8DB0-4727-92F3-D05A3CC0348E} - {4888D6BB-46D9-4519-8758-E13E397AA226} = {5E72F9F6-8DB0-4727-92F3-D05A3CC0348E} - {7EFE8058-F772-40EB-8E12-6E88E2A9E19A} = {FBA5D1FE-11EA-4FAE-B88F-7E2E809419C9} {44DFA13C-03C3-4F07-9D78-30F981BFABC5} = {A86A6BBD-1122-4993-B472-6A0265E5F2A1} + {866F8FE0-EE58-4D38-8BE7-CBDD19DD1B40} = {D0952F11-B4B6-4AD4-8F72-C35BD6A33D59} + {7EFE8058-F772-40EB-8E12-6E88E2A9E19A} = {FBA5D1FE-11EA-4FAE-B88F-7E2E809419C9} + {3C91F949-5187-4CDF-9A5B-AA3C20F7544B} = {9328FEED-6E95-4863-BB7B-521D0D02D7FA} + {8F2F35CB-D5EE-4D92-B42F-BCFFBF9C9D4F} = {5E72F9F6-8DB0-4727-92F3-D05A3CC0348E} + {9525A4AA-6731-4AB2-8CD0-ADDF7940FE32} = {5E72F9F6-8DB0-4727-92F3-D05A3CC0348E} + {71283236-56CB-481E-A644-B7F9AF9EFDF9} = {9328FEED-6E95-4863-BB7B-521D0D02D7FA} + {0B2B697D-DD20-4869-836C-08C848E1813F} = {9328FEED-6E95-4863-BB7B-521D0D02D7FA} + {55F9EAC2-AA55-4E10-8B00-404EBC7E164D} = {A86A6BBD-1122-4993-B472-6A0265E5F2A1} + {8CB7B268-478C-48C0-B205-CC81CC32A970} = {9328FEED-6E95-4863-BB7B-521D0D02D7FA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A0BD3F74-AC23-4649-932F-ECB61CF9EED6} diff --git a/SiMaySerializeTestApp2/App.config b/SiMaySerializeTestApp2/App.config new file mode 100644 index 0000000000000000000000000000000000000000..d1428ad712d72a50520dab5091ddcb5ea2b5f3e6 --- /dev/null +++ b/SiMaySerializeTestApp2/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/SiMay.Serialize/SiMaySerializeTestApp/Program.cs b/SiMaySerializeTestApp2/Program.cs similarity index 100% rename from SiMay.Serialize/SiMaySerializeTestApp/Program.cs rename to SiMaySerializeTestApp2/Program.cs diff --git a/SiMay.Serialize/SiMaySerializeTestApp/Properties/AssemblyInfo.cs b/SiMaySerializeTestApp2/Properties/AssemblyInfo.cs similarity index 83% rename from SiMay.Serialize/SiMaySerializeTestApp/Properties/AssemblyInfo.cs rename to SiMaySerializeTestApp2/Properties/AssemblyInfo.cs index 61059ab50d94b2f2ef1134f6491c46ce16a4d93e..b43e3693154d9a4baa8b085a9469fdf71dd40d59 100644 --- a/SiMay.Serialize/SiMaySerializeTestApp/Properties/AssemblyInfo.cs +++ b/SiMaySerializeTestApp2/Properties/AssemblyInfo.cs @@ -5,12 +5,12 @@ using System.Runtime.InteropServices; // 有关程序集的一般信息由以下 // 控制。更改这些特性值可修改 // 与程序集关联的信息。 -[assembly: AssemblyTitle("SiMaySerializeTestApp")] +[assembly: AssemblyTitle("SiMaySerializeTestApp2")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("SiMaySerializeTestApp")] -[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyProduct("SiMaySerializeTestApp2")] +[assembly: AssemblyCopyright("Copyright © 2020")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: ComVisible(false)] // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID -[assembly: Guid("84a4241a-3773-4b84-868f-9573fff7f161")] +[assembly: Guid("263a26f1-5235-4ea5-b2d6-adf219a07cd2")] // 程序集的版本信息由下列四个值组成: // diff --git a/SiMay.Serialize/SiMaySerializeTestApp/SiMaySerializeTestApp.csproj b/SiMaySerializeTestApp2/SiMaySerializeTestApp2.csproj similarity index 77% rename from SiMay.Serialize/SiMaySerializeTestApp/SiMaySerializeTestApp.csproj rename to SiMaySerializeTestApp2/SiMaySerializeTestApp2.csproj index 4f425a869223909437eac24d7d691672e339086e..01f2d745713c9c41c316cf51cd73364d0911bf92 100644 --- a/SiMay.Serialize/SiMaySerializeTestApp/SiMaySerializeTestApp.csproj +++ b/SiMaySerializeTestApp2/SiMaySerializeTestApp2.csproj @@ -4,13 +4,15 @@ Debug AnyCPU - {84A4241A-3773-4B84-868F-9573FFF7F161} + {263A26F1-5235-4EA5-B2D6-ADF219A07CD2} Exe - SiMaySerializeTestApp - SiMaySerializeTestApp - v4.0 + SiMaySerializeTestApp2 + SiMaySerializeTestApp2 + v4.5 512 + true true + AnyCPU @@ -32,12 +34,16 @@ 4 + + ..\SiMay.Serialize\SiMaySerializeTestApp\bin\Debug\SiMay.Serialize.dll + + @@ -45,10 +51,7 @@ - - {4888D6BB-46D9-4519-8758-E13E397AA226} - SiMay.Serialize - + \ No newline at end of file