Browse Source

Merge branch 'master' of https://github.com/yuzhengyang/Fork

yuzhengyang 7 years ago
parent
commit
17f8633c35

+ 218 - 24
.gitignore

@@ -1,35 +1,74 @@
-#################
-## Visual Studio
-#################
-
 ## Ignore Visual Studio temporary files, build results, and
 ## files generated by popular Visual Studio add-ons.
+##
+## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
 
 # User-specific files
 *.suo
 *.user
+*.userosscache
 *.sln.docstates
 
-# Build results
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
 
+# Build results
 [Dd]ebug/
+[Dd]ebugPublic/
 [Rr]elease/
+[Rr]eleases/
 x64/
-build/
+x86/
+bld/
 [Bb]in/
 [Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
 
 # MSTest test Results
 [Tt]est[Rr]esult*/
 [Bb]uild[Ll]og.*
 
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+**/Properties/launchSettings.json
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
 *_i.c
 *_p.c
+*_i.h
 *.ilk
 *.meta
 *.obj
+*.iobj
 *.pch
 *.pdb
+*.ipdb
 *.pgc
 *.pgd
 *.rsp
@@ -44,21 +83,34 @@ build/
 *.vssscc
 .builds
 *.pidb
-*.log
+*.svclog
 *.scc
 
+# Chutzpah Test files
+_Chutzpah*
+
 # Visual C++ cache files
 ipch/
 *.aps
 *.ncb
+*.opendb
 *.opensdf
 *.sdf
 *.cachefile
+*.VC.db
+*.VC.VC.opendb
 
 # Visual Studio profiler
 *.psess
 *.vsp
 *.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
 
 # Guidance Automation Toolkit
 *.gpState
@@ -66,6 +118,10 @@ ipch/
 # ReSharper is a .NET coding add-in
 _ReSharper*/
 *.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
 
 # TeamCity is a build add-in
 _TeamCity*
@@ -73,9 +129,25 @@ _TeamCity*
 # DotCover is a Code Coverage Tool
 *.dotCover
 
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
 # NCrunch
-*.ncrunch*
+_NCrunch_*
 .*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
 
 # Installshield output folder
 [Ee]xpress/
@@ -94,44 +166,166 @@ DocProject/Help/html
 publish/
 
 # Publish Web Output
-*.Publish.xml
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be unencrypted
 *.pubxml
 *.publishproj
 
-# NuGet Packages Directory
-## TODO: If you have NuGet Package Restore enabled, uncomment the next line
-#packages/
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
 
-# Windows Azure Build Output
-csx
+# Microsoft Azure Build Output
+csx/
 *.build.csdef
 
-# Windows Store app package directory
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
 AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
 
 # Others
-sql/
-*.Cache
 ClientBin/
-[Ss]tyle[Cc]op.*
 ~$*
 *~
 *.dbmdl
-*.[Pp]ublish.xml
+*.dbproj.schemaview
+*.jfm
 *.pfx
 *.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk 
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
 
 # RIA/Silverlight projects
 Generated_Code/
 
-# Backup & report files from converting an old project file to a newer
-# Visual Studio version. Backup files are not needed, because we have git ;-)
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
 _UpgradeReport_Files/
 Backup*/
 UpgradeLog*.XML
 UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
 
 # SQL Server files
-App_Data/*.mdf
-App_Data/*.ldf
-.vs
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output 
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder 
+.mfractor/

+ 0 - 0
Azylee.Utils/.vs/Azylee.Utils/v15/Server/sqlite3/db.lock


+ 1 - 0
Azylee.Utils/Azylee.Core/AppUtils/AppInfoTool.cs

@@ -117,6 +117,7 @@ namespace Azylee.Core.AppUtils
             {
                 p = Process.GetCurrentProcess();
                 value = p.WorkingSet64 / 1024;
+                //value = p.PeakWorkingSet64 / 1024;
             }
             catch { }
             finally { p?.Dispose(); }

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

@@ -151,11 +151,15 @@
     <Compile Include="WindowsUtils\ClipboardUtils\ClipboardTool.cs" />
     <Compile Include="WindowsUtils\CMDUtils\CMDNetstatTool.cs" />
     <Compile Include="WindowsUtils\CMDUtils\CMDProcessTool.cs" />
+    <Compile Include="WindowsUtils\ConsoleUtils\Cons.cs" />
+    <Compile Include="WindowsUtils\ConsoleUtils\ConsColorMode.cs" />
     <Compile Include="WindowsUtils\HookUtils\KeyboardHook.cs" />
     <Compile Include="WindowsUtils\HookUtils\KeyboardHookHelper.cs" />
     <Compile Include="WindowsUtils\HookUtils\UserActivityHook.cs" />
     <Compile Include="WindowsUtils\InfoUtils\ComputerInfoTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\ComputerStatusTool.cs" />
+    <Compile Include="WindowsUtils\InfoUtils\ComputerType.cs" />
+    <Compile Include="WindowsUtils\InfoUtils\ComputerTypeTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\NetcardInfoTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\PatchInfoTool.cs" />
     <Compile Include="WindowsUtils\InfoUtils\OSInfoTool.cs" />

+ 142 - 51
Azylee.Utils/Azylee.Core/LogUtils/SimpleLogUtils/Log.cs

@@ -19,6 +19,7 @@ using Azylee.Core.DataUtils.StringUtils;
 using Azylee.Core.IOUtils.DirUtils;
 using Azylee.Core.IOUtils.FileUtils;
 using Azylee.Core.IOUtils.TxtUtils;
+using Azylee.Core.WindowsUtils.ConsoleUtils;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
@@ -48,21 +49,43 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
 
         private int CACHE_DAYS = 30;//缓存天数
         private object LogFileLock = new object();//写日志文件锁
-        private bool IsWriteFile = false;//是否写日志文件
         private string LogPath = AppDomain.CurrentDomain.BaseDirectory + LOG_PATH;
-        public LogLevel LogLevel = LogLevel.All;//日志输出等级
+        private LogLevel ConsoleLogLevel = LogLevel.All;//日志输出到"控制台"等级
+        private LogLevel FileLogLevel = LogLevel.All;//日志输出到"文件"等级
         #endregion
 
-        public Log() { }
-        public Log(bool isWrite, LogLevel level = LogLevel.All)
+        private Log() { }
+        /// <summary>
+        /// 初始化 Log 工具
+        /// </summary>
+        /// <param name="isWrite">已失效,使用WriteLevel代替</param>
+        /// <param name="logLevel"></param>
+        /// <param name="writeLevel"></param>
+        [Obsolete]
+        public Log(bool isWrite, LogLevel logLevel = LogLevel.All, LogLevel writeLevel = LogLevel.All)
         {
             if (isWrite)
             {
-                IsWriteFile = true;
-                LogLevel = level;
+                //IsWriteFile = true;//已禁用,使用文件输出等级控制
+                ConsoleLogLevel = logLevel;
+                FileLogLevel = writeLevel;
             }
         }
+        /// <summary>
+        /// 初始化 Log 工具
+        /// </summary>
+        /// <param name="console">控制台输出级别</param>
+        /// <param name="file">文件输出级别</param>
+        public Log(LogLevel console = LogLevel.All, LogLevel file = LogLevel.All)
+        {
+            ConsoleLogLevel = console;
+            FileLogLevel = file;
+        }
 
+        /// <summary>
+        /// 设置日志路径
+        /// </summary>
+        /// <param name="path"></param>
         public void SetLogPath(string path)
         {
             if (!string.IsNullOrWhiteSpace(path))
@@ -70,13 +93,26 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
                 LogPath = DirTool.Combine(path, LOG_PATH);
             }
         }
+        /// <summary>
+        /// 设置日志缓存天数(默认30天)
+        /// </summary>
+        /// <param name="days"></param>
         public void SetCacheDays(int days)
         {
             if (days >= 0) CACHE_DAYS = days;
         }
+
         #region Console 开启/关闭 API
+        /// <summary>
+        /// 启用系统控制台输出
+        /// </summary>
+        /// <returns></returns>
         [DllImport("kernel32.dll")]
         public static extern Boolean AllocConsole();
+        /// <summary>
+        /// 关闭系统控制台
+        /// </summary>
+        /// <returns></returns>
         [DllImport("kernel32.dll")]
         public static extern Boolean FreeConsole();
         #endregion
@@ -103,21 +139,18 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
         /// 写出到控制台
         /// </summary>
         /// <param name="type">类型</param>
-        /// <param name="tag">标记</param>
         /// <param name="message">消息</param>
-        private void Write(LogType type, string message)
+        private void WriteConsole(LogType type, string message)
         {
             try
             {
-                Console.ForegroundColor = GetColor(type);
+                message = Cons.FormatLine(message); //处理日志信息(换行)
+
+                Cons.SetColor(GetColor(type), ConsoleColor.Black);
                 Console.WriteLine(LOG_FORMAT, DateTime.Now.ToString(TIME_FORMAT), type.ToString(), message);
-            }
-            catch { }
-            try
-            {
+                Cons.ResetColor();
                 //取消单独线程输出日志文件(单独线程输出日志必然会有延迟)
                 //if (IsWriteFile) Queue.Enqueue(new LogModel() { Type = type, Message = message, CreateTime = DateTime.Now });
-                if (IsWriteFile) WriteFile(new LogModel() { Type = type, Message = message, CreateTime = DateTime.Now });
             }
             catch { }
         }
@@ -127,26 +160,26 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
         /// <param name="log"></param>
         private void WriteFile(LogModel log)
         {
-            if (IsWriteFile)
+            lock (LogFileLock)
             {
-                lock (LogFileLock)
-                {
-                    //设置日志目录和日志文件
-                    string filePath = GetFilePath(log.Type);
-                    string file = DirTool.Combine(filePath, DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
-                    //创建日志目录
-                    DirTool.Create(filePath);
-                    //写出日志
-                    TxtTool.Append(
-                        file,
-                        string.Format(LOG_FORMAT,
-                            log.CreateTime.ToString(TIME_FORMAT),
-                            log.Type.ToString(),
-                            StringTool.ReplaceNewLine(log.Message)));
-                    Cleaner(log.Type);
-                }
+                //设置日志目录和日志文件
+                string filePath = GetFilePath(log.Type);
+                string file = DirTool.Combine(filePath, DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
+                //创建日志目录
+                DirTool.Create(filePath);
+                //处理日志信息(换行)
+                log.Message = Cons.FormatLine(log.Message);
+                //写出日志
+                TxtTool.Append(
+                    file,
+                    string.Format(LOG_FORMAT,
+                        log.CreateTime.ToString(TIME_FORMAT),
+                        log.Type.ToString(),
+                        log.Message));
+                Cleaner(log.Type);
             }
         }
+
         /// <summary>
         /// 根据分类分配目录
         /// </summary>
@@ -191,55 +224,113 @@ namespace Azylee.Core.LogUtils.SimpleLogUtils
         }
 
         #region 分类详细输出
+        #region 因大小写命名规范冲突,将次类方法标记为弃用
         /// <summary>
         /// 输出 verbose (啰嗦信息)
         /// </summary>
-        /// <param name="message">消息</param>
-        /// <param name="tag">可选:标记</param>
+        /// <param name="msg">消息</param>
+        [Obsolete]
         public void v<T>(T msg)
         {
-            if ((LogLevel & LogLevel.Verbose) == LogLevel.Verbose)
-                Write(LogType.v, msg.ToString());
+            V(msg);
         }
         /// <summary>
         /// 输出 Debug (调试信息)
         /// </summary>
-        /// <param name="message">消息</param>
-        /// <param name="tag">可选:标记</param>
+        /// <param name="msg">消息</param>
+        [Obsolete]
         public void d<T>(T msg)
         {
-            if ((LogLevel & LogLevel.Debug) == LogLevel.Debug)
-                Write(LogType.d, msg.ToString());
+            D(msg);
         }
         /// <summary>
         /// 输出 Information (重要信息)
         /// </summary>
-        /// <param name="message">消息</param>
-        /// <param name="tag">可选:标记</param>
+        /// <param name="msg">消息</param>
+        [Obsolete]
         public void i<T>(T msg)
         {
-            if ((LogLevel & LogLevel.Information) == LogLevel.Information)
-                Write(LogType.i, msg.ToString());
+            I(msg);
         }
         /// <summary>
         /// 输出 Warning (警告信息)
         /// </summary>
-        /// <param name="message">消息</param>
-        /// <param name="tag">可选:标记</param>
+        /// <param name="msg">消息</param>
+        [Obsolete]
         public void w<T>(T msg)
         {
-            if ((LogLevel & LogLevel.Warning) == LogLevel.Warning)
-                Write(LogType.w, msg.ToString());
+            W(msg);
         }
         /// <summary>
         /// 输出 Error (错误信息)
         /// </summary>
-        /// <param name="message">消息</param>
-        /// <param name="tag">可选:标记</param>
+        /// <param name="msg">消息</param>
+        [Obsolete]
         public void e<T>(T msg)
         {
-            if ((LogLevel & LogLevel.Error) == LogLevel.Error)
-                Write(LogType.e, msg.ToString());
+            E(msg);
+        }
+        #endregion
+
+        /// <summary>
+        /// 输出 verbose (啰嗦信息)
+        /// </summary>
+        /// <param name="msg">消息</param>
+        public void V<T>(T msg)
+        {
+            if ((ConsoleLogLevel & LogLevel.Verbose) == LogLevel.Verbose)
+                WriteConsole(LogType.v, msg?.ToString());
+
+            if ((FileLogLevel & LogLevel.Verbose) == LogLevel.Verbose)
+                WriteFile(new LogModel() { Type = LogType.v, Message = msg?.ToString(), CreateTime = DateTime.Now });
+        }
+        /// <summary>
+        /// 输出 Debug (调试信息)
+        /// </summary>
+        /// <param name="msg">消息</param>
+        public void D<T>(T msg)
+        {
+            if ((ConsoleLogLevel & LogLevel.Debug) == LogLevel.Debug)
+                WriteConsole(LogType.d, msg?.ToString());
+
+            if ((FileLogLevel & LogLevel.Debug) == LogLevel.Debug)
+                WriteFile(new LogModel() { Type = LogType.d, Message = msg?.ToString(), CreateTime = DateTime.Now });
+        }
+        /// <summary>
+        /// 输出 Information (重要信息)
+        /// </summary>
+        /// <param name="msg">消息</param>
+        public void I<T>(T msg)
+        {
+            if ((ConsoleLogLevel & LogLevel.Information) == LogLevel.Information)
+                WriteConsole(LogType.i, msg?.ToString());
+
+            if ((FileLogLevel & LogLevel.Information) == LogLevel.Information)
+                WriteFile(new LogModel() { Type = LogType.i, Message = msg?.ToString(), CreateTime = DateTime.Now });
+        }
+        /// <summary>
+        /// 输出 Warning (警告信息)
+        /// </summary>
+        /// <param name="msg">消息</param>
+        public void W<T>(T msg)
+        {
+            if ((ConsoleLogLevel & LogLevel.Warning) == LogLevel.Warning)
+                WriteConsole(LogType.w, msg?.ToString());
+
+            if ((FileLogLevel & LogLevel.Warning) == LogLevel.Warning)
+                WriteFile(new LogModel() { Type = LogType.w, Message = msg?.ToString(), CreateTime = DateTime.Now });
+        }
+        /// <summary>
+        /// 输出 Error (错误信息)
+        /// </summary>
+        /// <param name="msg">消息</param>
+        public void E<T>(T msg)
+        {
+            if ((ConsoleLogLevel & LogLevel.Error) == LogLevel.Error)
+                WriteConsole(LogType.e, msg?.ToString());
+
+            if ((FileLogLevel & LogLevel.Error) == LogLevel.Error)
+                WriteFile(new LogModel() { Type = LogType.e, Message = msg?.ToString(), CreateTime = DateTime.Now });
         }
         #endregion
     }

+ 107 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/ConsoleUtils/Cons.cs

@@ -0,0 +1,107 @@
+using Azylee.Core.DataUtils.CollectionUtils;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.ConsoleUtils
+{
+    /// <summary>
+    /// 控制台输出工具
+    /// </summary>
+    public static class Cons
+    {
+        const string LOG_FORMAT = "{0}  {1}  ";
+        const string TIME_FORMAT = "HH:mm:ss.fff";
+        /// <summary>
+        /// 输出换行内容(advanced 高级版)
+        /// </summary>
+        /// <param name="value">内容</param>
+        /// <param name="mode">文字颜色</param>
+        public static void Log(string value, ConsColorMode mode = ConsColorMode.Default)
+        {
+            ConsoleColor headcolor = ConsoleColor.White, headbgcolor = ConsoleColor.DarkRed;
+            ConsoleColor bodycolor = ConsoleColor.White, bodybgcolor = ConsoleColor.DarkRed;
+            #region 设置内容颜色,格式化内容
+            switch (mode)
+            {
+                case ConsColorMode.Default: bodycolor = ConsoleColor.Gray; bodybgcolor = ConsoleColor.Black; break;
+                case ConsColorMode.Muted: bodycolor = ConsoleColor.Gray; bodybgcolor = ConsoleColor.DarkGray; break;
+                case ConsColorMode.Primary: bodycolor = ConsoleColor.White; bodybgcolor = ConsoleColor.DarkGray; break;
+                case ConsColorMode.Secondary: bodycolor = ConsoleColor.Cyan; bodybgcolor = ConsoleColor.DarkGray; break;
+                case ConsColorMode.Success: bodycolor = ConsoleColor.Green; bodybgcolor = ConsoleColor.DarkGray; break;
+                case ConsColorMode.Info: bodycolor = ConsoleColor.Blue; bodybgcolor = ConsoleColor.DarkGray; break;
+                case ConsColorMode.Warning: bodycolor = ConsoleColor.Yellow; bodybgcolor = ConsoleColor.DarkGray; break;
+                case ConsColorMode.Danger: bodycolor = ConsoleColor.Red; bodybgcolor = ConsoleColor.DarkGray; break;
+                case ConsColorMode.Dark: bodycolor = ConsoleColor.White; bodybgcolor = ConsoleColor.Black; break;
+                case ConsColorMode.Light: bodycolor = ConsoleColor.Black; bodybgcolor = ConsoleColor.White; break;
+            }
+            value = FormatLine(value);
+            #endregion
+
+
+            #region 输出内容
+            SetColor(headcolor, headbgcolor);
+            Write(string.Format(LOG_FORMAT, DateTime.Now.ToString(TIME_FORMAT), ">"));
+
+            SetColor(bodycolor, bodybgcolor);
+            Write(value);
+            WriteLine("");
+
+            ResetColor();
+            #endregion
+        }
+
+
+        /// <summary>
+        /// 输出内容
+        /// </summary>
+        /// <param name="value">内容</param>
+        /// <param name="color">文字颜色</param>
+        /// <param name="bgcolor">背景颜色</param>
+        public static void Write(string value)
+        {
+            try { Console.Write(value); } catch { }
+        }
+        /// <summary>
+        /// 输出换行内容
+        /// </summary>
+        /// <param name="value">内容</param>
+        /// <param name="color">文字颜色</param>
+        /// <param name="bgcolor">背景颜色</param>
+        public static void WriteLine(string value)
+        {
+            try { Console.WriteLine(value); } catch { }
+        }
+
+        public static string FormatLine(string value)
+        {
+            string s = value;
+            try
+            {
+                s = s.Replace("\n\r", "\n").Replace("\r\n", "\n").Replace("\r", "\n");
+                string[] lines = s.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries);
+                s = String.Join<string>($"{Environment.NewLine}{new string(' ', 18)}L> ", lines);
+            }
+            catch { s = value; }
+            return s;
+        }
+        public static void SetColor(ConsoleColor color, ConsoleColor bgcolor)
+        {
+            try
+            {
+                Console.ForegroundColor = color;
+                Console.BackgroundColor = bgcolor;
+            }
+            catch { }
+        }
+        public static void ResetColor()
+        {
+            try
+            {
+                Console.ResetColor();
+            }
+            catch { }
+        }
+    }
+}

+ 54 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/ConsoleUtils/ConsColorMode.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.ConsoleUtils
+{
+    /// <summary>
+    /// 控制台颜色模式
+    /// </summary>
+    public enum ConsColorMode
+    {
+        /// <summary>
+        /// 默认
+        /// </summary>
+        Default,
+        /// <summary>
+        /// 柔和
+        /// </summary>
+        Muted,
+        /// <summary>
+        /// 重要
+        /// </summary>
+        Primary,
+        /// <summary>
+        /// 副标题
+        /// </summary>
+        Secondary,
+        /// <summary>
+        /// 成功
+        /// </summary>
+        Success,
+        /// <summary>
+        /// 提示
+        /// </summary>
+        Info,
+        /// <summary>
+        /// 警告
+        /// </summary>
+        Warning,
+        /// <summary>
+        /// 危险
+        /// </summary>
+        Danger,
+        /// <summary>
+        /// 深色
+        /// </summary>
+        Dark,
+        /// <summary>
+        /// 浅色
+        /// </summary>
+        Light,
+    }
+}

+ 39 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/ComputerType.cs

@@ -0,0 +1,39 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.InfoUtils
+{
+    /// <summary>
+    /// 计算机类型
+    /// </summary>
+    public enum ComputerType : int
+    {
+        Other = 1,
+        Unknown = 2,
+        Desktop = 3,
+        Low_Profile_Desktop = 4,
+        Pizza_Box = 5,
+        Mini_Tower = 6,
+        Tower = 7,
+        Portable = 8,
+        Laptop = 9,
+        Notebook = 10,
+        Hand_Held = 11,
+        Docking_Station = 12,
+        All_in_One = 13,
+        Sub_Notebook = 14,
+        Space_Saving = 15,
+        Lunch_Box = 16,
+        Main_System_Chassis = 17,
+        Expansion_Chassis = 18,
+        SubChassis = 19,
+        Bus_Expansion_Chassis = 20,
+        Peripheral_Chassis = 21,
+        Storage_Chassis = 22,
+        Rack_Mount_Chassis = 23,
+        Sealed_Case_PC = 24,
+        INVALID_ENUM_VALUE = 0,
+    }
+}

+ 36 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/ComputerTypeTool.cs

@@ -0,0 +1,36 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.InfoUtils
+{
+    /// <summary>
+    /// 获取计算机类型
+    /// </summary>
+    public static class ComputerTypeTool
+    {
+        /// <summary>
+        /// 获取类型
+        /// </summary>
+        /// <returns></returns>
+        public static ComputerType Get()
+        {
+            ComputerType type = ComputerType.Unknown;
+            try
+            {
+                ManagementClass systemEnclosures = new ManagementClass("Win32_SystemEnclosure");
+                foreach (ManagementObject obj in systemEnclosures.GetInstances())
+                {
+                    foreach (ComputerType i in (short[])(obj["ChassisTypes"]))
+                    {
+                        type = i;
+                    }
+                }
+            }
+            catch { }
+            return type;
+        }
+    }
+}

+ 11 - 2
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/PatchInfoTool.cs

@@ -16,6 +16,10 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
 {
     public static class PatchInfoTool
     {
+        /// <summary>
+        /// 获取计算机所有补丁
+        /// </summary>
+        /// <returns></returns>
         public static List<string> Get()
         {
             List<string> rs = new List<string>();
@@ -27,19 +31,24 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
                     string _HotFixID = item.GetPropertyValue("HotFixID").ToString().Trim();
                     if (!string.IsNullOrWhiteSpace(_HotFixID) && !rs.Contains(_HotFixID))
                     {
-                        rs.Add(_HotFixID);
+                        rs.Add(_HotFixID.ToUpper());
                     }
                 }
             }
             catch { }
             return rs;
         }
+        /// <summary>
+        /// 检查是否存在补丁
+        /// </summary>
+        /// <param name="name"></param>
+        /// <returns></returns>
         public static bool Exist(string name)
         {
             List<string> list = Get();
             if (StringTool.Ok(name) && ListTool.HasElements(list))
             {
-                if (list.Any(x => x == name.Trim())) return true;
+                if (list.Any(x => x == name.ToUpper().Trim())) return true;
             }
             return false;
         }

+ 14 - 7
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/SoftwareTool.cs

@@ -1,10 +1,4 @@
-//************************************************************************
-//      author:     yuzhengyang
-//      date:       2018.3.27 - 2018.6.3
-//      desc:       工具描述
-//      Copyright (c) yuzhengyang. All rights reserved.
-//************************************************************************
-using Azylee.Core.DataUtils.CollectionUtils;
+using Azylee.Core.DataUtils.CollectionUtils;
 using Azylee.Core.ProcessUtils;
 using Microsoft.Win32;
 using System;
@@ -105,6 +99,19 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
         {
             return ProcessTool.IsExists(name);
         }
+        /// <summary>
+        /// 存在进程(单字符串 [,/,] 分割)
+        /// </summary>
+        /// <param name="names"></param>
+        /// <returns></returns>
+        public static bool ExistProcess2(string names)
+        {
+            try
+            {
+                return ExistProcess(names.Replace(',', ',').Replace('/', ',').Split(','));
+            }
+            catch { return false; }
+        }
         public static bool ExistProcess(string[] names)
         {
             bool flag = false;

+ 25 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/RegisterUtils/RegisterTool.cs

@@ -4,6 +4,7 @@
 //      desc:       注册表操作工具
 //      Copyright (c) yuzhengyang. All rights reserved.
 //************************************************************************
+using Azylee.Core.DataUtils.StringUtils;
 using Microsoft.Win32;
 using System;
 
@@ -189,5 +190,29 @@ namespace Azylee.Core.WindowsUtils.RegisterUtils
             }
             return Registry.CurrentUser.CreateSubKey(subkey);
         }
+
+        /// <summary>
+        /// 判断是否存在项、键、值匹配
+        /// </summary>
+        /// <param name="key"></param>
+        /// <param name="name"></param>
+        /// <param name="value"></param>
+        /// <returns></returns>
+        public static bool Exist(string key, string name, string value)
+        {
+            if (Str.Ok(key) && Str.Ok(name))
+            {
+                string val = RegisterTool.GetValue(key, name);
+                if (Str.Ok(value))
+                {
+                    if (Str.Ok(val) && value == val) return true;
+                }
+                else
+                {
+                    if (val != null) return true;
+                }
+            }
+            return false;
+        }
     }
 }

+ 30 - 2
Azylee.Utils/Tests/Test.ProcessTool/Program.cs

@@ -1,4 +1,9 @@
-using System;
+using Azylee.Core.AppUtils;
+using Azylee.Core.LogUtils.SimpleLogUtils;
+using Azylee.Core.ThreadUtils.SleepUtils;
+using Azylee.Core.WindowsUtils.ConsoleUtils;
+using Azylee.Core.WindowsUtils.ShortcutUtils;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
@@ -9,7 +14,30 @@ namespace Test.ProcessTool
     {
         static void Main(string[] args)
         {
-            Azylee.Core.ProcessUtils.ProcessTool.Start("CPAU.EXE","-u Zephyr -p 123456 ");
+            Log log = new Log(LogLevel.All, LogLevel.Information);
+
+            Cons.Log("测试 Default 测试");
+            log.V<string>(null);
+            Cons.Log("测试 Muted 测试\r\n\r\n测试 Muted 测试\r\n\r\n测试 Muted 测试\r\n\r\n测试 Muted 测试", ConsColorMode.Muted);
+            log.V("测试 Log V \r\n\r\n 测试 Log V \r\n\r\n 测试 Log V \r\n\r\n");
+
+            Cons.Log("测试 Muted 测试\r\n\r\n测试 Muted 测试\r\n\r\n测试 Muted 测试\r\n\r\n测试 Muted 测试", ConsColorMode.Muted);
+            log.I("测试 Log V \r\n\r\n 测试 Log V \r\n\r\n 测试 Log V \r\n\r\n");
+
+            Cons.Log("测试 Primary 测试", ConsColorMode.Primary);
+            Cons.Log("测试 Secondary 测试", ConsColorMode.Secondary);
+            Cons.Log("测试 Success 测试", ConsColorMode.Success);
+            Cons.Log("测试 Info 测试", ConsColorMode.Info);
+            Cons.Log("测试 Warning 测试", ConsColorMode.Warning);
+            Cons.Log("测试 Danger 测试", ConsColorMode.Danger);
+            Cons.Log("测试 Dark 测试", ConsColorMode.Dark);
+            Cons.Log("测试 Light 测试", ConsColorMode.Light);
+
+            Console.WriteLine();
+            Console.WriteLine("====================");
+            Console.WriteLine("====================");
+            Console.ReadLine();
+            //Azylee.Core.ProcessUtils.ProcessTool.Start("CPAU.EXE","-u Zephyr -p 123456 ");
         }
     }
 }

BIN
Fork.Net/.vs/Fork.Net/v15/sqlite3/storage.ide-shm


BIN
Fork.Net/.vs/Fork.Net/v15/sqlite3/storage.ide-wal


+ 123 - 10
README.md

@@ -1,10 +1,23 @@
-# Fork
+# Fork
+
+[![NuGet](https://img.shields.io/nuget/dt/Azylee.Core.svg)](https://www.nuget.org/packages/Azylee.Core) 
+[![Fork](https://img.shields.io/github/forks/yuzhengyang/Fork.svg?style=social&label=Fork)](https://github.com/yuzhengyang/Fork/fork) 
+[![Stars](https://img.shields.io/github/stars/yuzhengyang/Fork.svg?style=social&label=Stars)](https://github.com/yuzhengyang/Fork) 
 
 Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,包括各种常用的工具和方法,窗口控件等。
 
 持续完善更新中……
 
-------
+已添加到 Nuget 的库,可直接在 VS 中搜索安装。
+
+| # | 模块     | DLL        | Nuget                                                  | 支持 .NET 版本|
+|---|---------|------------|---------------------------------------------------------|---------------|
+| 1 | 核心库 | Azylee.Core | [1.0.0.4](https://www.nuget.org/packages/Azylee.Core/)  | 4.0          |
+| 2 | 增强库 | Azylee.Core.Plus | -                                                  | 4.0          |
+
+
+
+---
 
 ## Azylee.Utils 工具组
 
@@ -14,7 +27,8 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
 2. Azylee.Core.Plus : 带其他引用的扩展方法
 3. Azylee.Update : 更新工具包
 4. Azylee.YeahWeb : Http 及网络相关工具包
-5. Azylee.WinformSkin : Winform 样式和控件
+5. Azylee.WinformMan : Winform 窗体管理
+6. Azylee.WinformSkin : Winform 样式和控件
 
 ### Azylee.Core 模块:
 
@@ -32,7 +46,12 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
  
 ● DataUtils:数据处理
   ┣ CollectionUtils:集合处理
-    ┗ ListTool.cs               // 列表内容判断
+    ┣ ArrayTool.cs              // 数组格式化
+    ┣ ListTool.cs               // 列表内容判断
+    ┗ Ls.cs                     // 列表内容判断(ListTool)
+    
+  ┣ CurrencyUtils:货币处理
+    ┗ RMB.cs:集合处理          // 人民币格式化
     
   ┣ DateTimeUtils:日期时间处理
     ┣ ChineseHourTool.cs        // 中文时辰转换
@@ -40,13 +59,18 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
     ┣ DateTimeTool.cs           // 日期时间处理
     ┣ DateTool.cs               // 日期处理
     ┣ TimerTool.cs              // 时间处理
+    ┣ TimeStampTool.cs          // 时间戳
     ┣ UnixTimeTool.cs           // Unix 时间换算
     ┗ WeekDayTool.cs            // 时间 - 周 换算
    
   ┣ EncryptUtils:加密解密
     ┣ AesTool.cs                // AES 加密解密
     ┣ DesTool.cs                // DES 加密解密
-    ┗ MD5Tool.cs                // 计算 MD5
+    ┣ MD5OTool.cs               // MD5 原生算法
+    ┗ MD5Tool.cs                // MD5 算法(依赖系统)
+    
+  ┣ EnumUtils:枚举处理
+    ┗ FlagsEnumTool.cs          // 标志枚举运算
    
   ┣ GuidUtils:Guid 处理
     ┗ GuidTool.cs               // Guid 格式处理
@@ -55,6 +79,8 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
     ┗ SerializeTool.cs          // 模型序列化
    
   ┣ StringUtils:字符串处理
+    ┣ Str.cs                    // 字符串处理(StringTool)
+    ┣ StringArrayTool.cs        // 字符串数组处理
     ┗ StringTool.cs             // 字符串处理
    
   ┗ UnitConvertUtils:单位转换
@@ -65,26 +91,57 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
     ┣ ProgressDelegate.cs       // 进度委托
     ┗ ProgressEventArgs.cs      // 进度委托参数
 
+● DllUtils:Dll 加载
+  ┗ DllInvokeTool.cs            // Dll 加载
+  
+● DrawingUtils:绘图
+  ┗ ColorUtils:颜色
+    ┗ ColorStyle.cs             // 颜色
+    
+● FormUtils:窗体工具
+  ┗ FormManTool.cs              // 窗口管理器
+
 ● IOUtils:输入输出
   ┣ BinaryUtils:二进制文件
     ┗ BinaryFileTool.cs         // 二进制文件读写
     
   ┣ DirUtils:路径
+    ┣ DirFinder.cs              // 目录搜索
     ┗ DirTool.cs                // 目录操作
     
+  ┣ ExifUtils:图片信息
+    ┣ ExifHelper.cs             // 图片信息查看
+    ┗ ExifTagNames.cs           // 信息项
+    
+  ┣ FileManUtils:文件管理
+    ┣ FileWatcher.cs            // 文件监控
+    ┗ FileWatcherEventArgs.cs   // 文件监控事件
+    
   ┣ FileUtils:文件
     ┣ FileCodeTool.cs           // 文件特征码
     ┣ FileCompressTool.cs       // 文件压缩
     ┣ FileEncryptTool.cs        // 文件加密解密
+    ┣ FileFinder.cs             // 文件搜索
     ┣ FilePackageModel.cs       // 文件打包模型
     ┣ FilePackageTool.cs        // 文件打包
     ┗ FileTool.cs               // 文件操作
     
+  ┣ ImageUtils:图片
+    ┣ AffineTool.cs             // 图片仿射
+    ┣ BarCodeToHTML.cs          // 网页一维码
+    ┣ CaptchaHelper.cs          // 验证码
+    ┣ IconTool.cs               // 生成 Icon
+    ┣ ImageHelper.cs            // 缩略图
+    ┣ ImageSpliter.cs           // 图片分割
+    ┣ RotateImageTool.cs        // 图像旋转
+    ┣ ScreenCapture.cs          // 截屏
+    ┗ ThunbnailTool.cs          // 缩略图
+    
   ┣ PathUtils:路径
     ┗ AppDirTool.cs             // 程序目录操作
     
   ┣ TxtUtils:文本
-    ┣ ConfigTool.cs             // (暂无)
+    ┣ ConfigTool.cs             // 读取配置
     ┣ IniTool.cs                // 操作 ini 配置文件
     ┣ TxtTool.cs                // 操作文本文件
     ┗ XmlTool.cs                // (暂无)
@@ -100,11 +157,45 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
     ┣ StatusLog.cs              // 状态日志工具
     ┗ StatusLogModel.cs         // 状态日志模型
     
+● NetUtils:网络
+  ┣ IPFormatter.cs              // IP 格式化检查
+  ┣ MacFormatter.cs             // MAC 格式化检查
+  ┣ NetConnectionInfo.cs        // 网络连接信息
+  ┣ NetFlowService.cs           // 网络流量监控
+  ┣ NetflowTool.cs              // 网络流量监控
+  ┣ NetPacketTool.cs            // 网络数据包工具
+  ┣ NetProcessInfo.cs           // 联网进程信息
+  ┣ NetProcessInfo.cs           // 联网进程读取
+  ┗ PingTool.cs                 // 网络连通
+  
 ● ProcessUtils:进程
+  ┣ ProcessInfoTool.cs          // 进程信息读取
+  ┣ ProcessStarter.cs           // 进程启动器
   ┗ ProcessTool.cs              // 进程操作
   
+● ProxyUtils:代理
+  ┣ SimpleProxyUtils:简单代理
+    ┣ RunMode.cs                // 运行模式
+    ┗ SimpleProxyTool.cs        // 代理工具
+    
+● ReflectionUtils:反射
+  ┣ AttributeUtils:反射属性
+    ┣ AttributeTool.cs          // 加载属性
+    ┣ ControlAttribute.cs       // (暂无)
+    ┣ ControlAttributeEvent.cs  // (暂无)
+    ┗ CustomAttributeHelper.cs  // 加载属性
+    
+  ┣ ReflectionCoreUtils:反射处理
+    ┣ DomainTool.cs             // 应用程序域
+    ┗ SimpleReflection.cs       // 反射执行
+
 ● TaskUtils:任务
   ┗ TaskSupport.cs              // 辅助启动线程任务
+  
+● ThreadUtils:线程
+  ┣ SleepUtils:线程休眠
+    ┣ Sleep.cs                  // 休眠(SleepTool)
+    ┗ SleepTool.cs              // 休眠
 
 ● VersionUtils:版本
   ┗ VersionTool.cs              // 版本处理
@@ -115,19 +206,40 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
     ┣ ExplorerAPI.cs            // Explorer:可打开指定文件夹窗口
     ┣ PermissionAPI.cs          // 执行权限
     ┣ SystemSleepAPI.cs         // 系统睡眠
-    ┗ WindowsAPI.cs             // 窗口信息
+    ┣ WindowsAPI.cs             // 窗口信息
+    ┣ WindowsDrawerAPI.cs       // 桌面绘图
+    ┗ WindowsHotKeyAPI.cs       // 热键
+    
+  ┣ BrowserUtils:浏览器
+    ┗ BrowserSelector.cs        // 浏览器选择
+    
+  ┣ ClipboardUtils:剪贴板
+    ┗ ClipboardTool.cs          // 剪贴板
     
   ┣ CMDUtils:API
     ┣ CMDNetstatTool.cs         // CMD网络指令包装
     ┗ CMDProcessTool.cs         // CMD进程启动工具
     
+  ┣ HookUtils:Hook
+    ┣ KeyboardHook.cs           // 键盘钩子
+    ┣ KeyboardHookHelper.cs     // (暂无)
+    ┗ UserActivityHook.cs       // 用户动作监控
+    
   ┣ InfoUtils:信息
     ┣ ComputerInfoTool.cs       // 计算机信息
     ┣ ComputerStatusTool.cs     // 计算机性能计数器
-    ┗ NetcardInfoTool.cs        // 网卡信息
+    ┣ NetcardInfoTool.cs        // 网卡信息
+    ┣ OSInfoTool.cs             // 操作系统
+    ┣ OSName.cs                 // 操作系统清单
+    ┣ PatchInfoTool.cs          // 计算机补丁
+    ┣ SoftwareInfo.cs           // 软件信息
+    ┗ SoftwareTool.cs           // 已装软件列表
     
   ┣ RegisterUtils:注册表
     ┗ RegisterTool.cs           // 操作注册表
+    
+  ┣ ShareUtils:共享
+    ┗ ShareInfoTool.cs           // 计算机共享
   
   ┗ ShortcutUtils:快捷方式
     ┗ ShortcutTool.cs           // 操作快捷方式
@@ -177,6 +289,8 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
   ┗ HttpToolPlus.cs             // 增强Http工具(如携带Cookie)
 ```
 
+### Azylee.WinformMan
+——暂无
 
 ### Azylee.WinformSkin
 ——暂无
@@ -188,5 +302,4 @@ Fork 是平时在做 C# 项目的时候,收藏整理的一个工具项目,
 - 在使用过程中,遇到问题可以给我发邮件,希望能帮助到你,更期待你的建议 ~~~
 
 
-
-![image](https://raw.githubusercontent.com/yuzhengyang/Fork/master/Documents/QRCode/WeiXinQRCodeMini.jpg)
+![image](https://raw.githubusercontent.com/yuzhengyang/Fork/master/Documents/QRCode/WeiXinQRCodeMini.jpg)