ソースを参照

修改数组格式化工具默认值,创建nuget包

yuzhengyang 7 年 前
コミット
41b0d5dd88

BIN
Azylee.Utils/.vs/Azylee.Utils/v15/Server/sqlite3/storage.ide


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

@@ -58,6 +58,7 @@
     <Compile Include="DataUtils\DateTimeUtils\DateTimeTool.cs" />
     <Compile Include="DataUtils\DateTimeUtils\DateTool.cs" />
     <Compile Include="DataUtils\DateTimeUtils\TimerTool.cs" />
+    <Compile Include="DataUtils\DateTimeUtils\TimeStampTool.cs" />
     <Compile Include="DataUtils\DateTimeUtils\UnixTimeTool.cs" />
     <Compile Include="DataUtils\DateTimeUtils\WeekDayTool.cs" />
     <Compile Include="DataUtils\EncryptUtils\AesTool.cs" />

+ 22 - 0
Azylee.Utils/Azylee.Core/DataUtils/CollectionUtils/ArrayTool.cs

@@ -31,5 +31,27 @@ namespace Azylee.Core.DataUtils.CollectionUtils
             }
             return rs;
         }
+        /// <summary>
+        /// 格式化[]数组个数
+        /// </summary>
+        /// <typeparam name="T"></typeparam>
+        /// <param name="array">数组</param>
+        /// <param name="defaultValue">默认值</param>
+        /// <param name="size">要格式化为多少个</param>
+        /// <returns></returns>
+        public static T[] Formatter<T>(T[] array, T defaultValue, int size = 10)
+        {
+            T[] rs = new T[size];
+            for (int i = 0; i < size; i++) rs[i] = defaultValue;
+
+            if (ListTool.HasElements(array))
+            {
+                for (int i = 0; i < rs.Length; i++)
+                {
+                    if (array.Length > i) rs[i] = array[i];
+                }
+            }
+            return rs;
+        }
     }
 }

+ 20 - 0
Azylee.Utils/Azylee.Core/DataUtils/DateTimeUtils/TimeStampTool.cs

@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.DataUtils.DateTimeUtils
+{
+    public class TimeStampTool
+    {
+        /// <summary>  
+        /// 获取时间戳  
+        /// </summary>  
+        /// <returns></returns>  
+        public static long Get()
+        {
+            TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0);
+            return (long)ts.TotalSeconds;
+        }
+    }
+}

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

@@ -63,6 +63,7 @@
     <Compile Include="HttpUtils\Models\UserAgents.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="SocketUtils\SocketTool.cs" />
+    <Compile Include="TencentWebAPI\PictureAI\PictureScener.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\Azylee.Core\Azylee.Core.csproj">
@@ -73,5 +74,6 @@
   <ItemGroup>
     <None Include="packages.config" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
 </Project>

+ 32 - 0
Azylee.Utils/Azylee.YeahWeb/TencentWebAPI/PictureAI/PictureScener.cs

@@ -0,0 +1,32 @@
+using Azylee.YeahWeb.HttpUtils;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.YeahWeb.TencentWebAPI.PictureAI
+{
+    public class PictureScener
+    {
+        public static string GetInfo(int app_id, int time_stamp, string nonce_str, string sign, int format, int topk, string image)
+        {
+            try
+            {
+                string url = $"https://api.ai.qq.com/fcgi-bin/vision/vision_scener?";
+                StringBuilder param = new StringBuilder();
+                param.Append($"app_id={app_id}");
+                param.Append($"&time_stamp={time_stamp}");
+                param.Append($"&nonce_str={nonce_str}");
+                param.Append($"&sign={sign}");
+                param.Append($"&format={format}");
+                param.Append($"&topk={topk}");
+                param.Append($"&image={image}");
+                string rs = HttpTool.Post(url, param.ToString());
+
+            }
+            catch { }
+            return null;
+        }
+    }
+}

+ 16 - 12
Azylee.Utils/Tests/Test.YeahWeb/Program.cs

@@ -1,5 +1,7 @@
-using Azylee.Core.IOUtils.ImageUtils;
+using Azylee.Core.DataUtils.DateTimeUtils;
+using Azylee.Core.IOUtils.ImageUtils;
 using Azylee.YeahWeb.BaiDuWebAPI.GPSAPI;
+using Azylee.YeahWeb.TencentWebAPI.PictureAI;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -12,19 +14,21 @@ namespace Test.YeahWeb
     {
         static void Main(string[] args)
         {
-            if (GPSConverter.DeviceGPSToBaiduGPS("iAe652kYOgleRHUYQkW1E8MIHEptnMb5", 120.379235583333, 36.19172925, out double x, out double y))
-            {
-                Console.WriteLine($"120.379235583333 - 36.19172925");
-                Console.WriteLine($"{x} - {y}");
-            }
+            PictureScener.GetInfo(1107006764,(int)TimeStampTool.Get(), "fa577ce340859f9fe",);
+
+            //if (GPSConverter.DeviceGPSToBaiduGPS("iAe652kYOgleRHUYQkW1E8MIHEptnMb5", 120.379235583333, 36.19172925, out double x, out double y))
+            //{
+            //    Console.WriteLine($"120.379235583333 - 36.19172925");
+            //    Console.WriteLine($"{x} - {y}");
+            //}
 
           
-            GPSInfoWebModel model = GPSInfoTool.GetInfo("iAe652kYOgleRHUYQkW1E8MIHEptnMb5", 40.039669, 252.129464);
-            if (model != null)
-            {
-                GPSInfoModel info = model.ToGPSInfoModel();
-                Console.WriteLine(info);
-            }
+            //GPSInfoWebModel model = GPSInfoTool.GetInfo("iAe652kYOgleRHUYQkW1E8MIHEptnMb5", 40.039669, 252.129464);
+            //if (model != null)
+            //{
+            //    GPSInfoModel info = model.ToGPSInfoModel();
+            //    Console.WriteLine(info);
+            //}
             Console.ReadLine();
         }
     }

BIN
nuget/Azylee.Core/Azylee.Core.1.0.0.nupkg


BIN
nuget/Azylee.Core/dlls/Azylee.Core.dll