Browse Source

修改通知格式

master
С·æ 4 years ago
parent
commit
782b916f08
  1. 18
      JdShopListener/JdShopListener/DingApiHelper.cs
  2. 52
      JdShopListener/JdShopListener/MainWindowViewModel.cs
  3. 4
      JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml

18
JdShopListener/JdShopListener/DingApiHelper.cs

@ -12,12 +12,12 @@ namespace JdShopListener
/// <summary>
/// 钉钉Secret
/// </summary>
private string dDSecret = "SEC23f4c5aa97b598b5a81b29ecb4b4facc5863e15e6b3c38c02f406c6541fdbb8e";
private string dDSecret = string.Empty;
/// <summary>
/// 钉钉的webHookUrl
/// 钉钉的webHook地址
/// </summary>
private string webHookUrl = "https://oapi.dingtalk.com/robot/send?access_token=ce194adc85ffc4438b894c20c895ba3e3eb2bfeea1cde4d0e9b4bd1122f905dc";
private string webHookUrl = string.Empty;
/// <summary>
/// 初始化
@ -79,23 +79,21 @@ namespace JdShopListener
return true;
}
catch
catch(Exception ex)
{
return false;
}
}
public String GetHash(String text, String key)
public string GetHash(string text, string key)
{
// change according to your needs, an UTF8Encoding
// could be more suitable in certain situations
ASCIIEncoding encoding = new ASCIIEncoding();
Byte[] textBytes = encoding.GetBytes(text);
Byte[] keyBytes = encoding.GetBytes(key);
byte[] textBytes = encoding.GetBytes(text);
byte[] keyBytes = encoding.GetBytes(key);
Byte[] hashBytes;
byte[] hashBytes;
using (HMACSHA256 hash = new HMACSHA256(keyBytes))
hashBytes = hash.ComputeHash(textBytes);

52
JdShopListener/JdShopListener/MainWindowViewModel.cs

@ -899,8 +899,56 @@ namespace JdShopListener
item.NewSkus = Newtonsoft.Json.JsonConvert.SerializeObject(newSkus);
#endregion
bool isChange = false;
StringBuilder sbMsg = new StringBuilder();
sbMsg.AppendLine("监控竞品发生变化:");
if (lastSku.NewSkus != item.NewSkus)
{
sbMsg.AppendLine("Sku");
sbMsg.AppendLine($"原:{lastSku.NewSkus}");
sbMsg.AppendLine($"新:{item.NewSkus}");
isChange = true;
}
if (lastSku.NewActive != item.NewActive)
{
sbMsg.AppendLine("活动");
sbMsg.AppendLine($"原:{lastSku.NewActive}");
sbMsg.AppendLine($"新:{item.NewActive}");
isChange = true;
}
if (lastSku.NewCoupons != item.NewCoupons)
{
sbMsg.AppendLine("优惠券");
sbMsg.AppendLine($"原:{lastSku.NewCoupons}");
sbMsg.AppendLine($"新:{item.NewCoupons}");
isChange = true;
}
if (lastSku.NewPrice != item.NewPrice)
{
sbMsg.AppendLine("价格");
sbMsg.AppendLine($"原:{lastSku.NewPrice}");
sbMsg.AppendLine($"新:{item.NewPrice}");
isChange = true;
}
if (lastSku.NewPromotion != item.NewPromotion)
{
sbMsg.AppendLine("促销");
sbMsg.AppendLine($"原:{lastSku.NewPromotion}");
sbMsg.AppendLine($"新:{item.NewPromotion}");
isChange = true;
}
sbMsg.AppendLine($"商品链接:https://item.jd.com/{lastSku.SkuId}.html");
//判断是否有变化
if (lastSku.NewSkus!=item.NewSkus|| lastSku.NewActive != item.NewActive || lastSku.NewCoupons != item.NewCoupons || lastSku.NewPrice != item.NewPrice || lastSku.NewPromotion != item.NewPromotion)
if (isChange)
{
item.OldActive = lastSku.NewActive;
item.OldCoupons = lastSku.NewCoupons;
@ -912,7 +960,7 @@ namespace JdShopListener
if (IsUseDingDing)
{
dingApi.SendNotify($"{sku.SkuId}监控完成!已产生变化记录");
dingApi.SendNotify(sbMsg.ToString());
}
AddLog($"{sku.SkuId}监控完成!已产生变化记录");

4
JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml

@ -9,9 +9,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>False</PublishSingleFile>
<PublishSingleFile>True</PublishSingleFile>
<PublishReadyToRun>False</PublishReadyToRun>
<PublishTrimmed>False</PublishTrimmed>
</PropertyGroup>

Loading…
Cancel
Save