From 418b0d0a4002bc06ba3a55d1809fe46043f06c09 Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期一, 26 九月 2022 14:07:58 +0800
Subject: [PATCH] 光伏更新,金茂科技系统更新
---
HDL_ON/Common/ImageUtlis.cs | 68 ++++++++++++++++++++++++++++------
1 files changed, 56 insertions(+), 12 deletions(-)
diff --git a/HDL_ON/Common/ImageUtlis.cs b/HDL_ON/Common/ImageUtlis.cs
index b13acd1..54cdb55 100644
--- a/HDL_ON/Common/ImageUtlis.cs
+++ b/HDL_ON/Common/ImageUtlis.cs
@@ -4,6 +4,8 @@
using System.IO;
using HDL_ON.Common;
using System.Collections.Generic;
+using System.Text;
+using System.Security.Cryptography;
namespace HDL_ON
{
@@ -179,19 +181,26 @@
/// </summary>
public byte[] GetImageDownloadUrl(string imageKey)
{
- var requestJson = HttpUtil.GetSignRequestJson(new GetImageUrlObj()
+ if (imageKey.StartsWith("https:"))
{
- imageKey = imageKey,
- });
- var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetImageUrl, requestJson);
- if (revertObj.Code == StateCode.SUCCESS)
+ return HttpUtil.HttpsDownload(imageKey);
+ }
+ else
{
- if (revertObj.Data != null)
+ var requestJson = HttpUtil.GetSignRequestJson(new GetImageUrlObj()
{
- if (!string.IsNullOrEmpty(revertObj.Data.ToString()))
+ imageKey = imageKey,
+ });
+ var revertObj = HttpUtil.RequestHttpsPostFroHome(NewAPI.API_POST_GetImageUrl, requestJson);
+ if (revertObj.Code == StateCode.SUCCESS)
+ {
+ if (revertObj.Data != null)
{
- var url = revertObj.Data.ToString();
- return HttpUtil.HttpsDownload(url);
+ if (!string.IsNullOrEmpty(revertObj.Data.ToString()))
+ {
+ var url = revertObj.Data.ToString();
+ return HttpUtil.HttpsDownload(url);
+ }
}
}
}
@@ -294,6 +303,34 @@
}
}
+
+ string strKey = "abcdefgh";//娉ㄦ剰锛氳繖閲岀殑瀵嗛挜sKey蹇呴』鑳借浆涓�8涓猙yte锛屽嵆杈撳叆瀵嗛挜涓�8鍗婅涓瓧绗︽垨鑰�4涓叏瑙掑瓧绗︽垨鑰�4涓眽瀛楃殑瀛楃涓�
+ string strIV = "ijklmnop";
+
+ // 鍔犲瘑
+ private string Encrypt(string _strQ)
+ {
+ byte[] buffer = Encoding.UTF8.GetBytes(_strQ);
+ MemoryStream ms = new MemoryStream();
+ DESCryptoServiceProvider des = new DESCryptoServiceProvider();
+ CryptoStream encStream = new CryptoStream(ms, des.CreateEncryptor(Encoding.UTF8.GetBytes(strKey), Encoding.UTF8.GetBytes(strIV)), CryptoStreamMode.Write);
+ encStream.Write(buffer, 0, buffer.Length);
+ encStream.FlushFinalBlock();
+ return Convert.ToBase64String(ms.ToArray());
+ }
+
+ // 瑙e瘑
+ private string Decrypt(string _strQ)
+ {
+ byte[] buffer = Convert.FromBase64String(_strQ);
+ MemoryStream ms = new MemoryStream();
+ DESCryptoServiceProvider des = new DESCryptoServiceProvider();
+ CryptoStream encStream = new CryptoStream(ms, des.CreateDecryptor(Encoding.UTF8.GetBytes(strKey), Encoding.UTF8.GetBytes(strIV)), CryptoStreamMode.Write);
+ encStream.Write(buffer, 0, buffer.Length);
+ encStream.FlushFinalBlock();
+ return Encoding.UTF8.GetString(ms.ToArray());
+ }
+
/// <summary>
/// 2020-12-03
/// 妫�娴嬪姞杞藉浘鐗�
@@ -306,6 +343,13 @@
{
try
{
+ var imageUrl = imageKey;
+
+ if (imageUrl.StartsWith("http"))
+ {
+ imageKey = Encrypt(imageKey);
+ }
+
//1.鏈湴榛樿鍥惧簱鍥剧墖锛岀洿鎺ュ姞杞芥湰鍦�
if (imageKey.Contains("Classification/Room/Roombg") || imageKey.Contains("Intelligence/Gallery/scenebg"))
{
@@ -333,7 +377,7 @@
//2.2 鏈湴娌$紦瀛橈紝寮�鍚嚎绋嬩簯绔笅杞界劧鍚庣紦瀛�
System.Threading.Tasks.Task.Run(() =>
{
- byte[] imageBytes = GetImageDownloadUrl(imageKey);
+ byte[] imageBytes = GetImageDownloadUrl(imageUrl);
if (imageBytes != null)
{
WriteFileByBytes(imageKey, imageBytes);
@@ -343,14 +387,14 @@
if (frameLayout != null)
{
frameLayout.BackgroundImagePath = imageKey;
- //Utlis.WriteLine("imageKey 鍔犺浇浜戠涓嬭浇鍥剧墖鎴愬姛");
+ Utlis.WriteLine("imageKey 鍔犺浇浜戠涓嬭浇鍥剧墖鎴愬姛");
}
});
}
else
{
//2.4 涓嬭浇鏄惁锛屾槸鍚︿娇鐢ㄩ粯璁ゅ浘鐗�
- //Utlis.WriteLine("imageKey 鍔犺浇浜戠鍥剧墖澶辫触");
+ Utlis.WriteLine("imageKey 鍔犺浇浜戠鍥剧墖澶辫触");
}
});
}
--
Gitblit v1.8.0