浏览代码

修改日志工具,整合日志输出到一个txt文件中;添加CMD操作Windows服务工具(安装、卸载服务)

yuzhengyang 6 年之前
父节点
当前提交
e6f13c6f2f

+ 2 - 0
Azylee.Utils/Azylee.Core/Azylee.Core.csproj

@@ -149,6 +149,7 @@
     <Compile Include="ThreadUtils\SleepUtils\SleepTool.cs" />
     <Compile Include="VersionUtils\VersionTool.cs" />
     <Compile Include="WindowsUtils\AdminUtils\AdminTool.cs" />
+    <Compile Include="WindowsUtils\AdminUtils\WindowsAccountModel.cs" />
     <Compile Include="WindowsUtils\APIUtils\ApplicationAPI.cs" />
     <Compile Include="WindowsUtils\APIUtils\ExplorerAPI.cs" />
     <Compile Include="WindowsUtils\APIUtils\PermissionAPI.cs" />
@@ -160,6 +161,7 @@
     <Compile Include="WindowsUtils\ClipboardUtils\ClipboardTool.cs" />
     <Compile Include="WindowsUtils\CMDUtils\CMDNetstatTool.cs" />
     <Compile Include="WindowsUtils\CMDUtils\CMDProcessTool.cs" />
+    <Compile Include="WindowsUtils\CMDUtils\CMDServiceTool.cs" />
     <Compile Include="WindowsUtils\ConsoleUtils\Cons.cs" />
     <Compile Include="WindowsUtils\ConsoleUtils\ConsColorMode.cs" />
     <Compile Include="WindowsUtils\HookUtils\KeyboardHook.cs" />

+ 18 - 16
Azylee.Utils/Azylee.Core/LogUtils/SimpleLogUtils/Log.cs

@@ -45,7 +45,7 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
         //输出的 Log 格式
         const string LOG_FORMAT = "{0}  {1}  {2}";
         const string TIME_FORMAT = "HH:mm:ss.fff";
-        const string LOG_PATH = "azylee.log";
+        const string LOG_PATH = @"azylee.log\log";
 
         private int CACHE_DAYS = 30;//缓存天数
         private object LogFileLock = new object();//写日志文件锁
@@ -179,7 +179,8 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
             lock (LogFileLock)
             {
                 //设置日志目录和日志文件
-                string filePath = GetFilePath(log.Type);
+                string filePath = LogPath;
+                //string filePath = GetFilePath(log.Type);//根据分类分配目录
                 string file = DirTool.Combine(filePath, DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
                 //创建日志目录
                 DirTool.Create(filePath);
@@ -201,25 +202,26 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
         /// </summary>
         /// <param name="type"></param>
         /// <returns></returns>
-        private string GetFilePath(LogType type)
-        {
-            string filePath = LogPath;
-            switch (type)
-            {
-                case LogType.d: filePath = DirTool.Combine(LogPath, "debug"); break;
-                case LogType.i: filePath = DirTool.Combine(LogPath, "information"); break;
-                case LogType.e: filePath = DirTool.Combine(LogPath, "error"); break;
-                case LogType.w: filePath = DirTool.Combine(LogPath, "warning"); break;
-                case LogType.v: filePath = DirTool.Combine(LogPath, "verbose"); break;
-            }
-            return filePath;
-        }
+        //private string GetFilePath(LogType type)
+        //{
+        //    string filePath = LogPath;
+        //    switch (type)
+        //    {
+        //        case LogType.d: filePath = DirTool.Combine(LogPath, "debug"); break;
+        //        case LogType.i: filePath = DirTool.Combine(LogPath, "information"); break;
+        //        case LogType.e: filePath = DirTool.Combine(LogPath, "error"); break;
+        //        case LogType.w: filePath = DirTool.Combine(LogPath, "warning"); break;
+        //        case LogType.v: filePath = DirTool.Combine(LogPath, "verbose"); break;
+        //    }
+        //    return filePath;
+        //}
         /// <summary>
         /// 清理过多的日志文件
         /// </summary>
         private void Cleaner(LogType type)
         {
-            List<string> files = FileTool.GetFile(GetFilePath(type));
+            List<string> files = FileTool.GetFile(LogPath);
+            //List<string> files = FileTool.GetFile(GetFilePath(type));//根据分类分配目录
             if (ListTool.HasElements(files))
             {
                 files.ForEach(f =>

+ 14 - 9
Azylee.Utils/Azylee.Core/ProcessUtils/ProcessStarter.cs

@@ -43,20 +43,25 @@ namespace Azylee.Core.ProcessUtils
         /// </summary>
         /// <param name="password"></param>
         /// <returns></returns>
-        private static SecureString ConvertToSecureString(this string password)
+        public static SecureString ConvertToSecureString(this string password)
         {
-            if (password == null)
-                throw new ArgumentNullException("password");
-
-            unsafe
+            try
             {
-                fixed (char* passwordChars = password)
+                if (password != null)
                 {
-                    var securePassword = new SecureString(passwordChars, password.Length);
-                    securePassword.MakeReadOnly();
-                    return securePassword;
+                    unsafe
+                    {
+                        fixed (char* passwordChars = password)
+                        {
+                            var securePassword = new SecureString(passwordChars, password.Length);
+                            securePassword.MakeReadOnly();
+                            return securePassword;
+                        }
+                    }
                 }
             }
+            catch { }
+            return null;
         }
         /// <summary>
         /// 开始运行

+ 66 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/AdminUtils/WindowsAccountModel.cs

@@ -0,0 +1,66 @@
+using Azylee.Core.ProcessUtils;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.AdminUtils
+{
+    /// <summary>
+    /// Windows 系统账号信息
+    /// </summary>
+    public class WindowsAccountModel
+    {
+        /// <summary>
+        /// 域
+        /// </summary>
+        public string Domain { get; set; }
+        /// <summary>
+        /// 账号
+        /// </summary>
+        public string UserName { get; set; }
+        /// <summary>
+        /// 密码
+        /// </summary>
+        public string Password { get; set; }
+        /// <summary>
+        /// 构造函数
+        /// </summary>
+        /// <param name="domain"></param>
+        /// <param name="username"></param>
+        /// <param name="password"></param>
+        public WindowsAccountModel(string domain = "", string username = "", string password = "")
+        {
+            Domain = domain;
+            UserName = username;
+            Password = password;
+        }
+        /// <summary>
+        /// 验证账号密码正确性
+        /// </summary>
+        public bool Check()
+        {
+            try
+            {
+                Process process = ProcessStarter.NewProcess(
+                   exe: "cmd.exe",
+                   domain: Domain,
+                   username: UserName,
+                   password: Password);
+                bool flag = process.Start();
+                process.Kill();
+                return flag;
+            }
+            catch { return false; }
+        }
+        /// <summary>
+        /// 验证账号密码为管理员账号
+        /// </summary>
+        /// <returns></returns>
+        public bool CheckAdmin(string password)
+        {
+            return AdminTool.CheckPassword(password);
+        }
+    }
+}

+ 14 - 5
Azylee.Utils/Azylee.Core/WindowsUtils/CMDUtils/CMDProcessTool.cs

@@ -5,7 +5,9 @@
 //      Copyright (c) yuzhengyang. All rights reserved.
 //************************************************************************
 using Azylee.Core.DataUtils.StringUtils;
+using Azylee.Core.ProcessUtils;
 using Azylee.Core.ThreadUtils.SleepUtils;
+using Azylee.Core.WindowsUtils.AdminUtils;
 using System;
 using System.Collections.Generic;
 using System.Diagnostics;
@@ -20,9 +22,16 @@ namespace Azylee.Core.WindowsUtils.CMDUtils
         /// 创建cmd的进程
         /// </summary>
         /// <returns></returns>
-        public static Process GetProcess(string verb = "RunAs")
+        public static Process GetProcess(string verb = "RunAs", WindowsAccountModel account = null)
         {
             ProcessStartInfo startInfo = new ProcessStartInfo();
+            if (account != null && account.Check())
+            {
+                if (Str.Ok(account.Domain)) startInfo.Domain = account.Domain;
+                if (Str.Ok(account.UserName)) startInfo.UserName = account.UserName;
+                if (Str.Ok(account.Password)) startInfo.Password = ProcessStarter.ConvertToSecureString(account.Password);
+            }
+
             startInfo.FileName = "cmd.exe";
             startInfo.Arguments = @"/c C:\Windows\System32\cmd.exe";
             startInfo.RedirectStandardInput = true;
@@ -40,13 +49,13 @@ namespace Azylee.Core.WindowsUtils.CMDUtils
         /// </summary>
         /// <param name="cmd"></param>
         /// <param name="output">输出动作</param>
-        public static void Execute(string cmd, Action<string> output)
+        public static void Execute(string cmd, Action<string> output, WindowsAccountModel account = null)
         {
             StreamReader reader = null;
             Process process = null;
             try
             {
-                process = GetProcess();
+                process = GetProcess(account: account);
                 process.Start();
                 process.StandardInput.AutoFlush = true;
                 process.StandardInput.WriteLine(cmd);
@@ -67,14 +76,14 @@ namespace Azylee.Core.WindowsUtils.CMDUtils
         /// </summary>
         /// <param name="cmd"></param>
         /// <returns></returns>
-        public static List<string> Execute(string cmd)
+        public static List<string> Execute(string cmd, WindowsAccountModel account = null)
         {
             List<string> result = null;
             StreamReader reader = null;
             Process process = null;
             try
             {
-                process = GetProcess();
+                process = GetProcess(account: account);
                 process.Start();
                 process.StandardInput.WriteLine(cmd);
                 process.StandardInput.WriteLine("exit");

+ 59 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/CMDUtils/CMDServiceTool.cs

@@ -0,0 +1,59 @@
+using Azylee.Core.DataUtils.CollectionUtils;
+using Azylee.Core.DataUtils.StringUtils;
+using Azylee.Core.WindowsUtils.AdminUtils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.CMDUtils
+{
+    /// <summary>
+    /// CMD 系统服务工具类
+    /// </summary>
+    public static class CMDServiceTool
+    {
+        /// <summary>
+        /// 安装服务(安装、运行、设置自启,一条龙服务)
+        /// </summary>
+        /// <param name="name">服务名</param>
+        /// <param name="path">应用程序路径</param>
+        /// <param name="account">运行账户信息</param>
+        /// <returns></returns>
+        public static bool Install(string name, string path, WindowsAccountModel account = null)
+        {
+            try
+            {
+                List<string> createResult = CMDProcessTool.Execute($"sc create {name} binPath= \"{path}\"", account);
+                List<string> startResult = CMDProcessTool.Execute($"net start {name}", account);
+                List<string> configResult = CMDProcessTool.Execute($"sc config {name} start= AUTO", account);
+                if (Ls.Ok(createResult))
+                {
+                    return createResult.Any(x => x.Contains("成功") || x.Contains("服务已存在"));
+                }
+                return false;
+            }
+            catch { return false; }
+        }
+        /// <summary>
+        /// 卸载服务(关闭、删除,一条龙服务)
+        /// </summary>
+        /// <param name="name"></param>
+        /// <param name="account">运行账户信息</param>
+        public static bool Uninstall(string name, WindowsAccountModel account = null)
+        {
+            try
+            {
+                List<string> stopResult = CMDProcessTool.Execute($"sc stop {name}", account);
+                List<string> deleteResult = CMDProcessTool.Execute($"sc delete {name}", account);
+                List<string> queryResult = CMDProcessTool.Execute($"sc query {name}");
+                if (Ls.Ok(queryResult))
+                {
+                    return queryResult.Any(x => x.Contains("失败") || x.Contains("1060") || x.Contains("服务未安装"));
+                }
+                return false;
+            }
+            catch { return false; }
+        }
+    }
+}

+ 7 - 0
Azylee.Utils/Azylee.Utils.sln

@@ -45,6 +45,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.Ext.NetworkX", "Azyl
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.WifiManTest", "Tests\Test.WifiManTest\Test.WifiManTest.csproj", "{A5702F35-A589-4F03-9468-72BD4A6B57A9}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.SysServiceApp", "Tests\Test.SysServiceApp\Test.SysServiceApp.csproj", "{CFDD901D-004E-4336-B949-46B7128180C6}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -123,6 +125,10 @@ Global
 		{A5702F35-A589-4F03-9468-72BD4A6B57A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{A5702F35-A589-4F03-9468-72BD4A6B57A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{A5702F35-A589-4F03-9468-72BD4A6B57A9}.Release|Any CPU.Build.0 = Release|Any CPU
+		{CFDD901D-004E-4336-B949-46B7128180C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{CFDD901D-004E-4336-B949-46B7128180C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{CFDD901D-004E-4336-B949-46B7128180C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{CFDD901D-004E-4336-B949-46B7128180C6}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -145,6 +151,7 @@ Global
 		{0497D55F-332B-40CC-A8C6-8D3AF98FEBAD} = {9351FC10-E8D0-41BB-A813-0B5B3EA90605}
 		{A320E11D-D771-4BBD-913F-DD0E87090943} = {618CFF8A-0137-4E15-BC07-4E172B7FC5DA}
 		{A5702F35-A589-4F03-9468-72BD4A6B57A9} = {9351FC10-E8D0-41BB-A813-0B5B3EA90605}
+		{CFDD901D-004E-4336-B949-46B7128180C6} = {9351FC10-E8D0-41BB-A813-0B5B3EA90605}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {3A021A3E-4C98-47CD-B4E8-912E12611C2E}

+ 75 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Form1.Designer.cs

@@ -0,0 +1,75 @@
+namespace Test.SysServiceApp
+{
+    partial class Form1
+    {
+        /// <summary>
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows 窗体设计器生成的代码
+
+        /// <summary>
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.button1 = new System.Windows.Forms.Button();
+            this.button2 = new System.Windows.Forms.Button();
+            this.SuspendLayout();
+            // 
+            // button1
+            // 
+            this.button1.Location = new System.Drawing.Point(38, 48);
+            this.button1.Name = "button1";
+            this.button1.Size = new System.Drawing.Size(75, 23);
+            this.button1.TabIndex = 0;
+            this.button1.Text = "button1";
+            this.button1.UseVisualStyleBackColor = true;
+            this.button1.Click += new System.EventHandler(this.button1_Click);
+            // 
+            // button2
+            // 
+            this.button2.Location = new System.Drawing.Point(38, 142);
+            this.button2.Name = "button2";
+            this.button2.Size = new System.Drawing.Size(75, 23);
+            this.button2.TabIndex = 1;
+            this.button2.Text = "button2";
+            this.button2.UseVisualStyleBackColor = true;
+            this.button2.Click += new System.EventHandler(this.button2_Click);
+            // 
+            // Form1
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.Controls.Add(this.button2);
+            this.Controls.Add(this.button1);
+            this.Name = "Form1";
+            this.Text = "Form1";
+            this.Load += new System.EventHandler(this.Form1_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Button button1;
+        private System.Windows.Forms.Button button2;
+    }
+}
+

+ 40 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Form1.cs

@@ -0,0 +1,40 @@
+using Azylee.Core.WindowsUtils.AdminUtils;
+using Azylee.Core.WindowsUtils.CMDUtils;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace Test.SysServiceApp
+{
+    public partial class Form1 : Form
+    {
+        public Form1()
+        {
+            InitializeComponent();
+        }
+
+        private void Form1_Load(object sender, EventArgs e)
+        {
+
+        }
+
+        private void button1_Click(object sender, EventArgs e)
+        {
+            var result = CMDServiceTool.Install(
+                 "AccessSecurityService",
+                 @"F:\InstallServer\AccessSecurity.Service.exe",
+                 new WindowsAccountModel("", "administrator", "yzy123"));
+        }
+
+        private void button2_Click(object sender, EventArgs e)
+        {
+            var result = CMDServiceTool.Uninstall("AccessSecurityService",
+                new WindowsAccountModel("", "administrator", "yzy123"));
+        }
+    }
+}

+ 120 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Form1.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 21 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Program.cs

@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace Test.SysServiceApp
+{
+    static class Program
+    {
+        /// <summary>
+        /// 应用程序的主入口点。
+        /// </summary>
+        [STAThread]
+        static void Main()
+        {
+            Application.EnableVisualStyles();
+            Application.SetCompatibleTextRenderingDefault(false);
+            Application.Run(new Form1());
+        }
+    }
+}

+ 36 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("Test.SysServiceApp")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Test.SysServiceApp")]
+[assembly: AssemblyCopyright("Copyright ©  2019")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("cfdd901d-004e-4336-b949-46b7128180c6")]
+
+// 程序集的版本信息由下列四个值组成: 
+//
+//      主版本
+//      次版本
+//      生成号
+//      修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Properties/Resources.Designer.cs

@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     此代码由工具生成。
+//     运行时版本: 4.0.30319.42000
+//
+//     对此文件的更改可能导致不正确的行为,如果
+//     重新生成代码,则所做更改将丢失。
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Test.SysServiceApp.Properties
+{
+
+
+    /// <summary>
+    ///   强类型资源类,用于查找本地化字符串等。
+    /// </summary>
+    // 此类是由 StronglyTypedResourceBuilder
+    // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+    // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+    // (以 /str 作为命令选项),或重新生成 VS 项目。
+    [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+    [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+    [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+    internal class Resources
+    {
+
+        private static global::System.Resources.ResourceManager resourceMan;
+
+        private static global::System.Globalization.CultureInfo resourceCulture;
+
+        [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+        internal Resources()
+        {
+        }
+
+        /// <summary>
+        ///   返回此类使用的缓存 ResourceManager 实例。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Resources.ResourceManager ResourceManager
+        {
+            get
+            {
+                if ((resourceMan == null))
+                {
+                    global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.SysServiceApp.Properties.Resources", typeof(Resources).Assembly);
+                    resourceMan = temp;
+                }
+                return resourceMan;
+            }
+        }
+
+        /// <summary>
+        ///   覆盖当前线程的 CurrentUICulture 属性
+        ///   使用此强类型的资源类的资源查找。
+        /// </summary>
+        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+        internal static global::System.Globalization.CultureInfo Culture
+        {
+            get
+            {
+                return resourceCulture;
+            }
+            set
+            {
+                resourceCulture = value;
+            }
+        }
+    }
+}

+ 117 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Properties/Resources.resx

@@ -0,0 +1,117 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 30 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Properties/Settings.Designer.cs

@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+// <auto-generated>
+//     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.
+// </auto-generated>
+//------------------------------------------------------------------------------
+
+namespace Test.SysServiceApp.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;
+            }
+        }
+    }
+}

+ 7 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Properties/Settings.settings

@@ -0,0 +1,7 @@
+<?xml version='1.0' encoding='utf-8'?>
+<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
+  <Profiles>
+    <Profile Name="(Default)" />
+  </Profiles>
+  <Settings />
+</SettingsFile>

+ 83 - 0
Azylee.Utils/Tests/Test.SysServiceApp/Test.SysServiceApp.csproj

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{CFDD901D-004E-4336-B949-46B7128180C6}</ProjectGuid>
+    <OutputType>WinExe</OutputType>
+    <RootNamespace>Test.SysServiceApp</RootNamespace>
+    <AssemblyName>Test.SysServiceApp</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <PlatformTarget>AnyCPU</PlatformTarget>
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Deployment" />
+    <Reference Include="System.Drawing" />
+    <Reference Include="System.Windows.Forms" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Form1.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="Form1.Designer.cs">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </Compile>
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+    <EmbeddedResource Include="Form1.resx">
+      <DependentUpon>Form1.cs</DependentUpon>
+    </EmbeddedResource>
+    <EmbeddedResource Include="Properties\Resources.resx">
+      <Generator>ResXFileCodeGenerator</Generator>
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+      <SubType>Designer</SubType>
+    </EmbeddedResource>
+    <Compile Include="Properties\Resources.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Resources.resx</DependentUpon>
+    </Compile>
+    <None Include="Properties\Settings.settings">
+      <Generator>SettingsSingleFileGenerator</Generator>
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+    </None>
+    <Compile Include="Properties\Settings.Designer.cs">
+      <AutoGen>True</AutoGen>
+      <DependentUpon>Settings.settings</DependentUpon>
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
+    </Compile>
+  </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="..\..\Azylee.Core\Azylee.Core.csproj">
+      <Project>{88dc61fa-95f0-41b7-9d7d-ab0f3cbd169c}</Project>
+      <Name>Azylee.Core</Name>
+    </ProjectReference>
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+</Project>