Browse Source

添加Plus工具包,完善Log日志为任务队列

yuzhengyang 8 years ago
parent
commit
3f675e8c4e

BIN
Fork.Net/.vs/Fork.Net/v15/Server/sqlite3/storage.ide


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


+ 59 - 0
Fork.Net/Azylee.Utils/Azylee.Core.Plus/Azylee.Core.Plus.csproj

@@ -0,0 +1,59 @@
+<?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>{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>Azylee.Core.Plus</RootNamespace>
+    <AssemblyName>Azylee.Core.Plus</AssemblyName>
+    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <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' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
+      <HintPath>..\..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
+    </Reference>
+    <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.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="DataUtils\JsonUtils\ConvertJson.cs" />
+    <Compile Include="DataUtils\JsonUtils\JsonTool.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="packages.config" />
+  </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>

+ 326 - 0
Fork.Net/Azylee.Utils/Azylee.Core.Plus/DataUtils/JsonUtils/ConvertJson.cs

@@ -0,0 +1,326 @@
+//############################################################
+//      https://github.com/yuzhengyang
+//      author:yuzhengyang
+//############################################################
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Data;
+using System.Reflection;
+using System.Collections;
+using System.Data.Common;
+
+namespace Azylee.Core.Plus.DataUtils.JsonUtils
+{
+    //JSON转换类
+    public class ConvertJson
+    {
+        #region 私有方法
+        /// <summary>
+        /// 过滤特殊字符
+        /// </summary>
+        private static string String2Json(String s)
+        {
+            StringBuilder sb = new StringBuilder();
+            for (int i = 0; i < s.Length; i++)
+            {
+                char c = s.ToCharArray()[i];
+                switch (c)
+                {
+                    case '\"':
+                        sb.Append("\\\""); break;
+                    case '\\':
+                        sb.Append("\\\\"); break;
+                    case '/':
+                        sb.Append("\\/"); break;
+                    case '\b':
+                        sb.Append("\\b"); break;
+                    case '\f':
+                        sb.Append("\\f"); break;
+                    case '\n':
+                        sb.Append("\\n"); break;
+                    case '\r':
+                        sb.Append("\\r"); break;
+                    case '\t':
+                        sb.Append("\\t"); break;
+                    default:
+                        sb.Append(c); break;
+                }
+            }
+            return sb.ToString();
+        }
+
+        /// <summary>
+        /// 格式化字符型、日期型、布尔型
+        /// </summary>
+        private static string StringFormat(string str, Type type)
+        {
+            if (type == typeof(string))
+            {
+                str = String2Json(str);
+                str = "\"" + str + "\"";
+            }
+            else if (type == typeof(DateTime))
+            {
+                str = "\"" + str + "\"";
+            }
+            else if (type == typeof(bool))
+            {
+                str = str.ToLower();
+            }
+            else if (type != typeof(string) && string.IsNullOrEmpty(str))
+            {
+                str = "\"" + str + "\"";
+            }
+            return str;
+        }
+        #endregion
+
+        #region List转换成Json
+        /// <summary>
+        /// List转换成Json
+        /// </summary>
+        public static string ListToJson<T>(IList<T> list)
+        {
+            object obj = list[0];
+            return ListToJson<T>(list, obj.GetType().Name);
+        }
+
+        /// <summary>
+        /// List转换成Json 
+        /// </summary>
+        public static string ListToJson<T>(IList<T> list, string jsonName)
+        {
+            StringBuilder Json = new StringBuilder();
+            if (string.IsNullOrEmpty(jsonName)) jsonName = list[0].GetType().Name;
+            Json.Append("{\"" + jsonName + "\":[");
+            if (list.Count > 0)
+            {
+                for (int i = 0; i < list.Count; i++)
+                {
+                    T obj = Activator.CreateInstance<T>();
+                    PropertyInfo[] pi = obj.GetType().GetProperties();
+                    Json.Append("{");
+                    for (int j = 0; j < pi.Length; j++)
+                    {
+                        Type type = pi[j].GetValue(list[i], null).GetType();
+                        Json.Append("\"" + pi[j].Name.ToString() + "\":" + StringFormat(pi[j].GetValue(list[i], null).ToString(), type));
+
+                        if (j < pi.Length - 1)
+                        {
+                            Json.Append(",");
+                        }
+                    }
+                    Json.Append("}");
+                    if (i < list.Count - 1)
+                    {
+                        Json.Append(",");
+                    }
+                }
+            }
+            Json.Append("]}");
+            return Json.ToString();
+        }
+        #endregion
+
+        #region 对象转换为Json
+        /// <summary> 
+        /// 对象转换为Json 
+        /// </summary> 
+        /// <param name="jsonObject">对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(object jsonObject)
+        {
+            string jsonString = "{";
+            PropertyInfo[] propertyInfo = jsonObject.GetType().GetProperties();
+            for (int i = 0; i < propertyInfo.Length; i++)
+            {
+                object objectValue = propertyInfo[i].GetGetMethod().Invoke(jsonObject, null);
+                string value = string.Empty;
+                if (objectValue is DateTime || objectValue is Guid || objectValue is TimeSpan)
+                {
+                    value = "'" + objectValue.ToString() + "'";
+                }
+                else if (objectValue is string)
+                {
+                    value = "'" + ToJson(objectValue.ToString()) + "'";
+                }
+                else if (objectValue is IEnumerable)
+                {
+                    value = ToJson((IEnumerable)objectValue);
+                }
+                else
+                {
+                    value = ToJson(objectValue.ToString());
+                }
+                jsonString += "\"" + ToJson(propertyInfo[i].Name) + "\":" + value + ",";
+            }
+            jsonString.Remove(jsonString.Length - 1, jsonString.Length);
+            return jsonString + "}";
+        }
+        #endregion
+
+        #region 对象集合转换Json
+        /// <summary> 
+        /// 对象集合转换Json 
+        /// </summary> 
+        /// <param name="array">集合对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(IEnumerable array)
+        {
+            string jsonString = "[";
+            foreach (object item in array)
+            {
+                jsonString += ToJson(item) + ",";
+            }
+            jsonString.Remove(jsonString.Length - 1, jsonString.Length);
+            return jsonString + "]";
+        }
+        #endregion
+
+        #region 普通集合转换Json
+        /// <summary> 
+        /// 普通集合转换Json 
+        /// </summary> 
+        /// <param name="array">集合对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToArrayString(IEnumerable array)
+        {
+            string jsonString = "[";
+            foreach (object item in array)
+            {
+                jsonString = ToJson(item.ToString()) + ",";
+            }
+            jsonString.Remove(jsonString.Length - 1, jsonString.Length);
+            return jsonString + "]";
+        }
+        #endregion
+
+        #region  DataSet转换为Json
+        /// <summary> 
+        /// DataSet转换为Json 
+        /// </summary> 
+        /// <param name="dataSet">DataSet对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(DataSet dataSet)
+        {
+            string jsonString = "{";
+            foreach (DataTable table in dataSet.Tables)
+            {
+                jsonString += "\"" + table.TableName + "\":" + ToJson(table) + ",";
+            }
+            jsonString = jsonString.TrimEnd(',');
+            return jsonString + "}";
+        }
+        #endregion
+
+        #region Datatable转换为Json
+        /// <summary> 
+        /// Datatable转换为Json 
+        /// </summary> 
+        /// <param name="table">Datatable对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(DataTable dt)
+        {
+            StringBuilder jsonString = new StringBuilder();
+            jsonString.Append("[");
+            DataRowCollection drc = dt.Rows;
+            for (int i = 0; i < drc.Count; i++)
+            {
+                jsonString.Append("{");
+                for (int j = 0; j < dt.Columns.Count; j++)
+                {
+                    string strKey = dt.Columns[j].ColumnName;
+                    string strValue = drc[i][j].ToString();
+                    Type type = dt.Columns[j].DataType;
+                    jsonString.Append("\"" + strKey + "\":");
+                    strValue = StringFormat(strValue, type);
+                    if (j < dt.Columns.Count - 1)
+                    {
+                        jsonString.Append(strValue + ",");
+                    }
+                    else
+                    {
+                        jsonString.Append(strValue);
+                    }
+                }
+                jsonString.Append("},");
+            }
+            jsonString.Remove(jsonString.Length - 1, 1);
+            jsonString.Append("]");
+            return jsonString.ToString();
+        }
+
+        /// <summary>
+        /// DataTable转换为Json 
+        /// </summary>
+        public static string ToJson(DataTable dt, string jsonName)
+        {
+            StringBuilder Json = new StringBuilder();
+            if (string.IsNullOrEmpty(jsonName)) jsonName = dt.TableName;
+            Json.Append("{\"" + jsonName + "\":[");
+            if (dt.Rows.Count > 0)
+            {
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    Json.Append("{");
+                    for (int j = 0; j < dt.Columns.Count; j++)
+                    {
+                        Type type = dt.Rows[i][j].GetType();
+                        Json.Append("\"" + dt.Columns[j].ColumnName.ToString() + "\":" + StringFormat(dt.Rows[i][j].ToString(), type));
+                        if (j < dt.Columns.Count - 1)
+                        {
+                            Json.Append(",");
+                        }
+                    }
+                    Json.Append("}");
+                    if (i < dt.Rows.Count - 1)
+                    {
+                        Json.Append(",");
+                    }
+                }
+            }
+            Json.Append("]}");
+            return Json.ToString();
+        }
+        #endregion
+
+        #region DataReader转换为Json
+        /// <summary> 
+        /// DataReader转换为Json 
+        /// </summary> 
+        /// <param name="dataReader">DataReader对象</param> 
+        /// <returns>Json字符串</returns> 
+        public static string ToJson(DbDataReader dataReader)
+        {
+            StringBuilder jsonString = new StringBuilder();
+            jsonString.Append("[");
+            while (dataReader.Read())
+            {
+                jsonString.Append("{");
+                for (int i = 0; i < dataReader.FieldCount; i++)
+                {
+                    Type type = dataReader.GetFieldType(i);
+                    string strKey = dataReader.GetName(i);
+                    string strValue = dataReader[i].ToString();
+                    jsonString.Append("\"" + strKey + "\":");
+                    strValue = StringFormat(strValue, type);
+                    if (i < dataReader.FieldCount - 1)
+                    {
+                        jsonString.Append(strValue + ",");
+                    }
+                    else
+                    {
+                        jsonString.Append(strValue);
+                    }
+                }
+                jsonString.Append("},");
+            }
+            dataReader.Close();
+            jsonString.Remove(jsonString.Length - 1, 1);
+            jsonString.Append("]");
+            return jsonString.ToString();
+        }
+        #endregion
+    }
+}

+ 48 - 0
Fork.Net/Azylee.Utils/Azylee.Core.Plus/DataUtils/JsonUtils/JsonTool.cs

@@ -0,0 +1,48 @@
+//************************************************************************
+//      https://github.com/yuzhengyang
+//      author:     yuzhengyang
+//      date:       2017.3.29 - 2017.8.24
+//      desc:       Json转换工具类(需要Newtonsoft.Json支持)
+//      Copyright (c) yuzhengyang. All rights reserved.
+//************************************************************************
+using Azylee.Core.IOUtils.TxtUtils;
+using Newtonsoft.Json;
+using System; 
+
+namespace Azylee.Core.Plus.DataUtils.JsonUtils
+{
+    public class JsonTool
+    {
+        public static string ToStr(object value)
+        {
+            return JsonConvert.SerializeObject(value);
+        }
+        public static object ToObjFromStr(string str)
+        {
+            string json = str;
+            if (!string.IsNullOrWhiteSpace(json))
+            {
+                try { return JsonConvert.DeserializeObject(json); } catch (Exception e) { }
+            }
+            return null;
+        }
+        public static T ToObjFromStr<T>(string str)
+        {
+            string json = str;
+            if (!string.IsNullOrWhiteSpace(json))
+            {
+                try { return JsonConvert.DeserializeObject<T>(json); } catch (Exception e) { }
+            }
+            return default(T);
+        }
+        public static T ToObjFromFile<T>(string file)
+        {
+            string json = TxtTool.Read(file);
+            if (!string.IsNullOrWhiteSpace(json))
+            {
+                try { return JsonConvert.DeserializeObject<T>(json); } catch (Exception e) { }
+            }
+            return default(T);
+        }
+    }
+}

+ 36 - 0
Fork.Net/Azylee.Utils/Azylee.Core.Plus/Properties/AssemblyInfo.cs

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

+ 4 - 0
Fork.Net/Azylee.Utils/Azylee.Core.Plus/packages.config

@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+  <package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" />
+</packages>

+ 1 - 0
Fork.Net/Azylee.Utils/Azylee.Core/Azylee.Core.csproj

@@ -67,6 +67,7 @@
     <Compile Include="IOUtils\TxtUtils\XmlTool.cs" />
     <Compile Include="LogUtils\Log.cs" />
     <Compile Include="LogUtils\LogLevel.cs" />
+    <Compile Include="LogUtils\LogModel.cs" />
     <Compile Include="LogUtils\LogType.cs" />
     <Compile Include="ProcessUtils\ProcessTool.cs" />
     <Compile Include="IOUtils\DirUtils\DirTool.cs" />

+ 64 - 3
Fork.Net/Azylee.Utils/Azylee.Core/LogUtils/Log.cs

@@ -15,10 +15,16 @@
 //R.Log.w("this is w 警告");
 //R.Log.e("this is e 错误");
 
+using Azylee.Core.DataUtils.CollectionUtils;
 using Azylee.Core.IOUtils.DirUtils;
 using Azylee.Core.IOUtils.TxtUtils;
 using System;
+using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
 using System.Runtime.InteropServices;
+using System.Threading;
+using System.Threading.Tasks;
 
 namespace Azylee.Core.LogUtils
 {
@@ -43,6 +49,9 @@ namespace Azylee.Core.LogUtils
         public string LogPath = LOG_PATH;
         public LogLevel LogLevel = LogLevel.All;//日志输出等级
 
+        bool IsStart = false;
+        ConcurrentQueue<LogModel> Queue = new ConcurrentQueue<LogModel>();
+
         public Log()
         { }
         public Log(bool isWrite, string logPath = LOG_PATH, LogLevel level = LogLevel.All)
@@ -54,6 +63,36 @@ namespace Azylee.Core.LogUtils
                 LogLevel = level;
             }
         }
+        public void Start()
+        {
+            if (!IsStart)
+            {
+                IsStart = true;
+                Task.Factory.StartNew(() =>
+                {
+                    while (IsStart)
+                    {
+                        Thread.Sleep(10 * 1000);
+
+                        if (Queue.Any())
+                        {
+                            List<LogModel> list = new List<LogModel>();
+                            for (int i = 0; i < Queue.Count; i++)
+                            {
+                                LogModel model = null;
+                                if (Queue.TryDequeue(out model)) list.Add(model);
+                            }
+                            if (ListTool.HasElements(list)) WriteFile(list);
+                        }
+                    }
+                });
+            }
+        }
+        void Stop()
+        {
+            if (IsStart)
+                IsStart = false;
+        }
         public bool SetWriteFile(bool isWrite, string logPath)
         {
             if (isWrite && !string.IsNullOrWhiteSpace(logPath))
@@ -101,10 +140,26 @@ namespace Azylee.Core.LogUtils
         {
             Console.ForegroundColor = GetColor(type);
             Console.WriteLine(LOG_FORMAT, DateTime.Now.ToString(TIME_FORMAT), type.ToString(), message);
-            if (IsWriteFile) WriteFile(type, message);
+            if (IsWriteFile) Queue.Enqueue(new LogModel() { Type = type, Message = message, CreateTime = DateTime.Now });
         }
 
-        private void WriteFile(LogType type, string message)
+        private void WriteFile(LogModel log)
+        {
+            if (IsWriteFile)
+            {
+                lock (LogFileLock)
+                {
+                    //设置日志目录
+                    string logPath = AppDomain.CurrentDomain.BaseDirectory + LogPath;
+                    string file = string.Format(@"{0}\{1}.txt", logPath, DateTime.Now.ToString("yyyy-MM-dd"));
+                    //创建日志目录
+                    DirTool.Create(logPath);
+                    //写出日志
+                    TxtTool.Append(file, string.Format(LOG_FORMAT, log.CreateTime.ToString(TIME_FORMAT), log.Type.ToString(), log.Message));
+                }
+            }
+        }
+        private void WriteFile(List<LogModel> list)
         {
             if (IsWriteFile)
             {
@@ -115,8 +170,14 @@ namespace Azylee.Core.LogUtils
                     string file = string.Format(@"{0}\{1}.txt", logPath, DateTime.Now.ToString("yyyy-MM-dd"));
                     //创建日志目录
                     DirTool.Create(logPath);
+                    //整理要输出的内容
+                    List<string> txts = new List<string>();
+                    foreach (var item in list)
+                    {
+                        txts.Add(string.Format(LOG_FORMAT, item.CreateTime.ToString(TIME_FORMAT), item.Type.ToString(), item.Message));
+                    }
                     //写出日志
-                    TxtTool.Append(file, string.Format(LOG_FORMAT, DateTime.Now.ToString(TIME_FORMAT), type.ToString(), message));
+                    TxtTool.Append(file, txts);
                 }
             }
         }

+ 14 - 0
Fork.Net/Azylee.Utils/Azylee.Core/LogUtils/LogModel.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.LogUtils
+{
+    public  class LogModel
+    {
+        public LogType Type { get; set; }
+        public string Message { get; set; }
+        public DateTime CreateTime { get; set; }
+    }
+}

+ 13 - 0
Fork.Net/Azylee.Utils/Azylee.Core/ProcessUtils/ProcessTool.cs

@@ -83,6 +83,19 @@ namespace Azylee.Core.ProcessUtils
             catch (Exception ex) { }
             return false;
         }
+        public static bool SimpleStart(string file, string args = "")
+        {
+            if (File.Exists(file))
+            {
+                try
+                {
+                    Process.Start(file, args);
+                    return true;
+                }
+                catch { }
+            }
+            return false;
+        }
         public static void Starts(string[] files)
         {
             if (ListTool.HasElements(files))

+ 13 - 0
Fork.Net/Azylee.Utils/Azylee.Core/VersionUtils/VersionTool.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Linq;
 using System.Text;
 
@@ -18,5 +19,17 @@ namespace Azylee.Core.VersionUtils
             catch (Exception e) { }
             return version;
         }
+        public static Version GetVersion(string appFile)
+        {
+            try
+            {
+                FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(appFile);
+                return Format(fileVersionInfo.FileVersion);
+            }
+            catch
+            {
+                return null;
+            }
+        }
     }
 }

+ 4 - 0
Fork.Net/Azylee.Utils/Azylee.Update/Azylee.Update.csproj

@@ -46,6 +46,10 @@
     <Compile Include="UpdateUtils\AppUpdateTool.cs" />
   </ItemGroup>
   <ItemGroup>
+    <ProjectReference Include="..\Azylee.Core.Plus\Azylee.Core.Plus.csproj">
+      <Project>{915ae524-7efd-4ecc-b731-de1d1f5558f0}</Project>
+      <Name>Azylee.Core.Plus</Name>
+    </ProjectReference>
     <ProjectReference Include="..\Azylee.Core\Azylee.Core.csproj">
       <Project>{88dc61fa-95f0-41b7-9d7d-ab0f3cbd169c}</Project>
       <Name>Azylee.Core</Name>

+ 32 - 0
Fork.Net/Azylee.Utils/Azylee.Update/UpdateUtils/AppUpdateTool.cs

@@ -10,6 +10,7 @@ using Azylee.Core.DelegateUtils.ProcessDelegateUtils;
 using Azylee.Core.IOUtils.DirUtils;
 using Azylee.Core.IOUtils.FileUtils;
 using Azylee.Core.IOUtils.PathUtils;
+using Azylee.Core.Plus.DataUtils.JsonUtils;
 using Azylee.Core.VersionUtils;
 using Azylee.YeahWeb.FTPUtils;
 using Azylee.YeahWeb.HttpUtils;
@@ -28,6 +29,37 @@ namespace Azylee.Update.UpdateUtils
         /// <summary>
         /// 获取新版本
         /// </summary>
+        /// <param name="s"></param>
+        /// <param name="version"></param>
+        /// <param name="info"></param>
+        /// <returns>
+        /// -10;//请求版本失败
+        /// -20;//没有更新的版本
+        /// </returns>
+        public int GetNewVersionByString(string s, Version version, out AppUpdateInfo info)
+        {
+            Stopwatch stopwatch = new Stopwatch();
+            stopwatch.Start();
+
+            info = JsonTool.ToObjFromStr<AppUpdateInfo>(s);
+            if (info != null)
+            {
+                Version newVersion = VersionTool.Format(info.Version);
+                if (newVersion != null && newVersion > version)
+                {
+                    stopwatch.Stop();
+                    return (int)stopwatch.Elapsed.TotalSeconds;//成功返回操作时长
+                }
+                else
+                {
+                    return -20;//没有更新的版本
+                }
+            }
+            return -10;//请求版本失败
+        }
+        /// <summary>
+        /// 获取新版本
+        /// </summary>
         /// <param name="url"></param>
         /// <param name="version"></param>
         /// <param name="info"></param>

+ 11 - 0
Fork.Net/Fork.Net.sln

@@ -73,6 +73,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.DB", "Azylee.Utils\A
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.Update", "Azylee.Utils\Azylee.Update\Azylee.Update.csproj", "{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azylee.Core.Plus", "Azylee.Utils\Azylee.Core.Plus\Azylee.Core.Plus.csproj", "{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -321,6 +323,14 @@ Global
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}.Release|Any CPU.Build.0 = Release|Any CPU
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}.Release|x86.ActiveCfg = Release|Any CPU
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91}.Release|x86.Build.0 = Release|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Debug|x86.ActiveCfg = Debug|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Debug|x86.Build.0 = Debug|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Release|Any CPU.Build.0 = Release|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Release|x86.ActiveCfg = Release|Any CPU
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0}.Release|x86.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -355,6 +365,7 @@ Global
 		{0783D6B7-A0E9-4E3B-B2E8-C72D318F99CE} = {C34A95B5-5F83-46E3-868A-56BDDA2D0B87}
 		{EF587677-DC59-4C46-B1AB-92904CD3F187} = {C34A95B5-5F83-46E3-868A-56BDDA2D0B87}
 		{76F92BAE-8C9C-42AA-85E8-51F2EA8A0C91} = {C34A95B5-5F83-46E3-868A-56BDDA2D0B87}
+		{915AE524-7EFD-4ECC-B731-DE1D1F5558F0} = {C34A95B5-5F83-46E3-868A-56BDDA2D0B87}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {5436696D-5F55-490A-AB40-050B54BE2AB4}