diff --git a/.gitignore b/.gitignore
index 4322f6b..94142a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,5 @@
/JdShopListener/JdShopListener/obj
/JdShopListener/JdShopListener/bin
/JdShopListener/.vs
+/JdShopListener/WpfNoticeMsg/bin
+/JdShopListener/WpfNoticeMsg/obj
diff --git a/JdShopListener/JdShopListener.sln b/JdShopListener/JdShopListener.sln
index 2aa4823..2867f65 100644
--- a/JdShopListener/JdShopListener.sln
+++ b/JdShopListener/JdShopListener.sln
@@ -1,9 +1,11 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30804.86
+# Visual Studio Version 17
+VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JdShopListener", "JdShopListener\JdShopListener.csproj", "{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JdShopListener", "JdShopListener\JdShopListener.csproj", "{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WpfNoticeMsg", "WpfNoticeMsg\WpfNoticeMsg.csproj", "{67CEC78B-30B2-43EC-B254-C9CA133C3C55}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -15,6 +17,10 @@ Global
{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ED16D55D-BE5B-4206-8A0D-6C91A7A583B1}.Release|Any CPU.Build.0 = Release|Any CPU
+ {67CEC78B-30B2-43EC-B254-C9CA133C3C55}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {67CEC78B-30B2-43EC-B254-C9CA133C3C55}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {67CEC78B-30B2-43EC-B254-C9CA133C3C55}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {67CEC78B-30B2-43EC-B254-C9CA133C3C55}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/JdShopListener/JdShopListener/ApiHelper.cs b/JdShopListener/JdShopListener/ApiHelper.cs
new file mode 100644
index 0000000..85fd8e7
--- /dev/null
+++ b/JdShopListener/JdShopListener/ApiHelper.cs
@@ -0,0 +1,126 @@
+using JdShopListener.Models;
+using System;
+using System.Collections.Generic;
+using System.Net.Http;
+using System.Text;
+using System.Threading;
+using System.Windows;
+
+namespace Utils
+{
+ public class ApiHelper
+ {
+ public static string ApiBase { get; set; } = "http://localhost:5000";
+ //public static string ApiBase { get; set; } = "http://hyapi.qiyue666.com";
+
+
+ static string jwtToken;
+
+ public static string JwtToken
+ {
+ get
+ {
+ if (string.IsNullOrEmpty(jwtToken))
+ {
+ jwtToken = Utils.MemoryHelper.GetMemoryToken();
+ }
+
+ return jwtToken;
+ }
+
+ }
+
+
+ ///
+ /// 获取标签信息
+ ///
+ ///
+ ///
+ ///
+ public static (bool isOk,List datas) GetLabelByItemIds(int type=1)
+ {
+ try
+ {
+ var result = Http($"http://hyapi.qiyue666.com/HuiYan/itemlabels/GetItemsByJpLabels?type={type}");
+
+ var data = Newtonsoft.Json.JsonConvert.DeserializeObject(result);
+
+ string json = data.Data.ToString();
+
+ var datas = Newtonsoft.Json.JsonConvert.DeserializeObject>(json);
+
+ bool isSuccess = data.Success;
+
+ return (isSuccess, datas ?? new List());
+ }
+ catch
+ {
+ return (false, new List());
+ }
+ }
+
+ ///
+ /// http接口调用
+ ///
+ ///
+ ///
+ ///
+ private static string Http(string api, string postData = null, bool isAgain = false)
+ {
+ try
+ {
+ string url = api;
+
+ if (!url.StartsWith("http"))
+ {
+ url = ApiBase + api;
+ }
+
+ HttpClient http = new HttpClient();
+ http.Timeout = new TimeSpan(0, 0, 35);
+ http.DefaultRequestHeaders.Add("Authorization", "Bearer " + JwtToken);
+ if (postData!=null)
+ {
+ StringContent content = new StringContent(postData);
+ content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
+ var result = http.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
+ return result;
+ }
+
+ var request = new HttpRequestMessage() { Method = HttpMethod.Get, RequestUri = new Uri(url) };
+
+ var res = http.SendAsync(request).Result;
+
+ if (res.StatusCode == System.Net.HttpStatusCode.Unauthorized)
+ {
+ return string.Empty;
+ }
+ else
+ {
+ //服务器挂掉
+ if (res.StatusCode != System.Net.HttpStatusCode.OK)
+ {
+ if (isAgain)
+ return null;
+
+ Thread.Sleep(60000);
+ return Http(api, postData, true);
+ }
+ return res.Content.ReadAsStringAsync().Result;
+ }
+
+ }
+ catch (HttpRequestException ex)
+ {
+ if (isAgain)
+ return null;
+ Thread.Sleep(60000);
+ return Http(api, postData, true);
+ }
+ catch (Exception ex)
+ {
+ return null;
+ }
+ }
+ }
+}
diff --git a/JdShopListener/JdShopListener/JdShopListener.csproj b/JdShopListener/JdShopListener/JdShopListener.csproj
index 3b6f303..599d7d5 100644
--- a/JdShopListener/JdShopListener/JdShopListener.csproj
+++ b/JdShopListener/JdShopListener/JdShopListener.csproj
@@ -5,9 +5,19 @@
netcoreapp3.1
true
跟屁虫
+ AnyCPU;x86
+ true
-
+
+ false
+
+
+
+ false
+
+
+
all
@@ -29,6 +39,10 @@
+
+
+
+
True
diff --git a/JdShopListener/JdShopListener/JdShopListener.csproj.user b/JdShopListener/JdShopListener/JdShopListener.csproj.user
index 85013cc..640ad33 100644
--- a/JdShopListener/JdShopListener/JdShopListener.csproj.user
+++ b/JdShopListener/JdShopListener/JdShopListener.csproj.user
@@ -1,7 +1,7 @@
- <_LastSelectedProfileId>D:\2019\齐论项目\京东竞品监控\JdShopListener\JdShopListener\Properties\PublishProfiles\FolderProfile.pubxml
+ <_LastSelectedProfileId>D:\2019\齐论项目\跟屁虫\JdShopListener\JdShopListener\Properties\PublishProfiles\FolderProfile.pubxml
diff --git a/JdShopListener/JdShopListener/MainWindow.xaml b/JdShopListener/JdShopListener/MainWindow.xaml
index 62d9fdc..e6470e2 100644
--- a/JdShopListener/JdShopListener/MainWindow.xaml
+++ b/JdShopListener/JdShopListener/MainWindow.xaml
@@ -200,7 +200,7 @@
-
+
@@ -332,5 +332,13 @@
+
+
+
+
+
+
+
+
diff --git a/JdShopListener/JdShopListener/MainWindow.xaml.cs b/JdShopListener/JdShopListener/MainWindow.xaml.cs
index c45214d..402dbf7 100644
--- a/JdShopListener/JdShopListener/MainWindow.xaml.cs
+++ b/JdShopListener/JdShopListener/MainWindow.xaml.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
@@ -12,6 +13,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using Utils;
namespace JdShopListener
{
diff --git a/JdShopListener/JdShopListener/MainWindowViewModel.cs b/JdShopListener/JdShopListener/MainWindowViewModel.cs
index 57c9522..a80b9db 100644
--- a/JdShopListener/JdShopListener/MainWindowViewModel.cs
+++ b/JdShopListener/JdShopListener/MainWindowViewModel.cs
@@ -12,6 +12,7 @@ using System.Linq;
using System.Threading;
using Newtonsoft.Json.Linq;
using PuppeteerSharp;
+using Utils;
namespace JdShopListener
{
@@ -29,6 +30,17 @@ namespace JdShopListener
}
}
+ private bool _IsInitLoding;
+ ///
+ /// 是否正在初始化
+ ///
+ public bool IsInitLoding
+ {
+ get { return _IsInitLoding; }
+ set { Set(ref _IsInitLoding, value); }
+ }
+
+
DingApiHelper dingApi=null;
public string JDCookie { get; set; }
@@ -57,6 +69,7 @@ namespace JdShopListener
SkuList = new System.Collections.ObjectModel.ObservableCollection();
SelectDate = DateList.FirstOrDefault();
SelectPro = ProList.FirstOrDefault();
+
Init();
if (System.IO.File.Exists(ddFileName))
@@ -74,8 +87,59 @@ namespace JdShopListener
dingApi = new DingApiHelper(DDSecret, Webhook);
}
+
+ LoadHYItems();
+ }
+
+ private string _InitText= "正在加载慧眼竞品商品数据, 请稍后...";
+
+ public string InitText
+ {
+ get { return _InitText; }
+ set { Set(ref _InitText, value); }
+ }
+
+
+ public void LoadHYItems()
+ {
+ Thread t = new Thread(() =>
+ {
+ try
+ {
+ IsInitLoding = true;
+ var result = ApiHelper.GetLabelByItemIds();
+
+ result.datas.ForEach(item => {
+
+ var last = skuList.FirstOrDefault(c => c.SkuId == item.GoodsId);
+ if (last != null)
+ {
+ if (last.IsShow != 1)
+ {
+ last.IsShow = 1;
+ DbHelper.Db.UpdateSkuModel(last);
+ }
+ }
+ //新增
+ else {
+ Application.Current.Dispatcher.Invoke(() => {
+ InitText = $"正在添加【{item.GoodsId}】...";
+ });
+ AddSku(item.GoodsId);
+ }
+ //
+ });
+
+ }
+ finally {
+ IsInitLoding = false;
+ }
+ });
+ t.IsBackground = true;
+ t.Start();
}
+ List skuList;
///
/// 初始化
///
@@ -83,6 +147,9 @@ namespace JdShopListener
{
SkuList.Clear();
var list= DbHelper.Db.GetSkuList();
+
+ skuList = list;
+
list.ForEach(c => {
if (c.IsShow == 1)
{
@@ -272,7 +339,7 @@ namespace JdShopListener
if (IsStart !=false)
{
- MessageBox.Show("采集中不可操作!");
+ WpfNoticeMsg.NoticeMessage.Show("采集中不可操作!");
return;
}
@@ -284,134 +351,137 @@ namespace JdShopListener
{
try
{
+ AddSku(Sku);
+ IsAdd = false;
+ }
+ catch(Exception ex)
+ {
+ WpfNoticeMsg.NoticeMessage.Show("添加失败,异常信息:"+ex.Message);
+ }
+ });
+ addThread.Start();
+ }
- if (string.IsNullOrEmpty(JDCookie))
- {
- AddLog("开始获取Cookie!");
- InitLoginCookie();
- }
-
- var detail = GetItemDetail(Sku);
-
- JArray list = detail.product.colorSize as JArray;
- //spuId
- string spuId = detail.product.mainSkuId;
+ private void AddSku(string newSku)
+ {
+ if (string.IsNullOrEmpty(JDCookie))
+ {
+ AddLog("开始获取Cookie!");
+ InitLoginCookie();
+ }
- if (list==null||list.Count == 0)
- {
- list = new JArray();
- list.Add(JToken.FromObject(new { skuId=Sku }));
- }
+ var detail = GetItemDetail(newSku);
+ JArray list = detail.product.colorSize as JArray;
- List skus = new List();
+ //spuId
+ string spuId = detail.product.mainSkuId;
+ if (list == null || list.Count == 0)
+ {
+ list = new JArray();
+ list.Add(JToken.FromObject(new { skuId = newSku }));
+ }
- foreach (JObject sku in list)
- {
- SkuModel model = new SkuModel()
- {
- Desc = Desc,
- SkuId = sku["skuId"].ToString(),
- SpuId = spuId
- };
- if (model.SkuId == Sku)
- {
- model.IsShow = 1;
- }
+ List skus = new List();
+ foreach (JObject sku in list)
+ {
+ SkuModel model = new SkuModel()
+ {
+ Desc = Desc,
+ SkuId = sku["skuId"].ToString(),
+ SpuId = spuId
+ };
- //去除重复
- if (SkuList.Count(c => c.SkuId == model.SkuId) > 0)
- {
+ if (model.SkuId == newSku)
+ {
+ model.IsShow = 1;
+ }
- if (model.IsShow == 1)
- {
- var osku = SkuList.FirstOrDefault(c => c.SkuId == model.SkuId);
- if (osku.IsShow != 1)
- {
- osku.IsShow = 1;
- DbHelper.Db.UpdateSkuModel(osku);
- }
+ //去除重复
+ if (SkuList.Count(c => c.SkuId == model.SkuId) > 0)
+ {
- }
+ if (model.IsShow == 1)
+ {
+ var osku = SkuList.FirstOrDefault(c => c.SkuId == model.SkuId);
+ if (osku.IsShow != 1)
+ {
- continue;
+ osku.IsShow = 1;
+ DbHelper.Db.UpdateSkuModel(osku);
}
-
-
- //加入本地数据库
- skus.Add(model);
- Application.Current.Dispatcher.Invoke(() =>
- {
- SkuList.Add(model);
- });
}
- //加载sku详情
- skus.ForEach(sku =>
- {
- var detail = GetItemDetail(sku.SkuId);
- //主图
- string src = detail.product.src;
- var catIds = detail.product.cat;
+ continue;
+ }
- List cats = new List();
- foreach (var catId in catIds)
- {
- cats.Add((int)catId);
- }
+ //加入本地数据库
+ skus.Add(model);
- string cat = string.Join(",", cats);
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ SkuList.Add(model);
+ });
+ }
- //标题
- string title = detail.product.name;
+ //加载sku详情
+ skus.ForEach(sku =>
+ {
+ var detail = GetItemDetail(sku.SkuId);
+
+ //主图
+ string src = detail.product.src;
+ var catIds = detail.product.cat;
- string shopId = detail.product.shopId;
+ List cats = new List();
- string vid = detail.product.venderId;
+ foreach (var catId in catIds)
+ {
+ cats.Add((int)catId);
+ }
- sku.ImgUrl = "http://img11.360buyimg.com/n1/" + src;
- sku.Title = title;
- sku.Cat = cat;
- sku.ShopId = shopId;
- sku.VenderId = vid;
+ string cat = string.Join(",", cats);
- if (DbHelper.Db.AddSkuModel(sku))
- {
- AddLog($"{sku.SkuId}添加监控成功!");
- }
- else {
- AddLog($"{sku.SkuId}添加监控列表失败!");
- }
+ //标题
+ string title = detail.product.name;
- Thread.Sleep(3000);
- });
+ string shopId = detail.product.shopId;
- //if (DbHelper.Db.AddSkuModel(skus))
- //{
- MessageBox.Show("添加成功", "提示");
- AddLog("全部相关sku添加成功!");
- //}
+ string vid = detail.product.venderId;
+ sku.ImgUrl = "http://img11.360buyimg.com/n1/" + src;
+ sku.Title = title;
+ sku.Cat = cat;
+ sku.ShopId = shopId;
+ sku.VenderId = vid;
- IsAdd = false;
+ if (DbHelper.Db.AddSkuModel(sku))
+ {
+ AddLog($"{sku.SkuId}添加监控成功!");
}
- catch(Exception ex)
+ else
{
- MessageBox.Show("添加失败,异常信息:"+ex.Message);
+ AddLog($"{sku.SkuId}添加监控列表失败!");
}
+
+ Thread.Sleep(3000);
});
- addThread.Start();
+
+ //if (DbHelper.Db.AddSkuModel(skus))
+ //{
+ WpfNoticeMsg.NoticeMessage.Show($"{newSku}添加成功", "提示");
+ AddLog("全部相关sku添加成功!");
}
///
@@ -431,7 +501,7 @@ namespace JdShopListener
{
if (IsAdd)
{
- MessageBox.Show("请等待添加完成之后操作!");
+ WpfNoticeMsg.NoticeMessage.Show("请等待添加完成之后操作!");
return;
}
@@ -699,7 +769,7 @@ namespace JdShopListener
dingApi = new DingApiHelper(DDSecret, Webhook);
- MessageBox.Show("保存成功!", "提示");
+ WpfNoticeMsg.NoticeMessage.Show("保存成功!", "提示");
}
diff --git a/JdShopListener/JdShopListener/MemoryHelper.cs b/JdShopListener/JdShopListener/MemoryHelper.cs
new file mode 100644
index 0000000..567d477
--- /dev/null
+++ b/JdShopListener/JdShopListener/MemoryHelper.cs
@@ -0,0 +1,88 @@
+using System;
+using System.Collections.Generic;
+using System.IO.MemoryMappedFiles;
+using System.Text;
+
+namespace Utils
+{
+ public class MemoryHelper
+ {
+ public static string GetMemoryToken()
+ {
+ string memoryName = string.Empty;
+ string[] args = Environment.GetCommandLineArgs();
+ foreach (var arg in args)
+ {
+ if (arg.StartsWith("uid:"))
+ {
+ memoryName = arg;
+ }
+ }
+
+ var result = MemoryHelper.ReadMMF(memoryName);
+
+ if (result.isOk)
+ {
+ return result.content;
+ }
+ else
+ {
+ System.Environment.Exit(0);
+ return string.Empty;
+ }
+ }
+
+ ///
+ /// 写入映射文件
+ ///
+ ///
+ ///
+ public static bool WriteMMF(string mapname, string content)
+ {
+ MemoryMappedFile mmf = MemoryMappedFile.CreateOrOpen(mapname, 1000, MemoryMappedFileAccess.ReadWrite);
+ if (!string.IsNullOrEmpty(content))
+ {
+ using (var mmfStream = mmf.CreateViewStream())
+ {
+ using (var sw = new System.IO.StreamWriter(mmfStream))
+ {
+ sw.Write(content.Trim());
+ }
+ }
+
+ return true;
+ }
+ return false;
+ }
+
+ ///
+ /// 读取映射文件
+ ///
+ ///
+ public static (bool isOk,string content) ReadMMF(string mapname)
+ {
+ try
+ {
+ MemoryMappedFile mmf = MemoryMappedFile.OpenExisting(mapname);
+ using (var mmfStream = mmf.CreateViewStream(0, 1000, MemoryMappedFileAccess.ReadWrite))
+ {
+ byte[] buffer = new byte[128];
+ int nLength = 0;
+ StringBuilder sb = new StringBuilder();
+ do
+ {
+ nLength = mmfStream.Read(buffer, 0, 128);
+ sb.AppendLine(System.Text.ASCIIEncoding.Default.GetString(buffer));
+
+ } while (nLength > 0);
+
+ return (true, sb.ToString().Replace("\0", null).TrimEnd());
+ }
+ }
+ catch (Exception ex)
+ {
+ return (false, null);
+ }
+ }
+ }
+}
diff --git a/JdShopListener/JdShopListener/Models/ItemlabelInfoDto.cs b/JdShopListener/JdShopListener/Models/ItemlabelInfoDto.cs
new file mode 100644
index 0000000..55f3010
--- /dev/null
+++ b/JdShopListener/JdShopListener/Models/ItemlabelInfoDto.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace JdShopListener.Models
+{
+ public class ItemlabelInfoDto: itemlabels
+ {
+ ///
+ /// 平台
+ ///
+ public int Platform { get; set; }
+
+ ///
+ /// 是否集团过滤
+ ///
+ public bool HasFilter { get; set; }
+
+ ///
+ /// 宝贝ID
+ ///
+ public string GoodsId { get; set; }
+ }
+
+ public class itemlabels
+ {
+ public String Id { get; set; }
+
+ ///
+ /// 创建时间
+ ///
+ public DateTime CreateTime { get; set; }
+
+ ///
+ /// 创建人Id
+ ///
+ public String CreatorId { get; set; }
+
+ ///
+ /// 否已删除
+ ///
+ public Boolean Deleted { get; set; }
+
+ ///
+ /// 宝贝ID
+ ///
+ public String ItemsId { get; set; }
+
+ ///
+ /// 是否筛选
+ ///
+ public Boolean IsScreening { get; set; }
+
+ ///
+ /// 是否过滤
+ ///
+ public Boolean IsFilter { get; set; }
+
+ ///
+ /// 是否竞品
+ ///
+ public Boolean IsCompeting { get; set; }
+
+ ///
+ /// 是否加入产品库
+ ///
+ public Boolean IsAdded { get; set; }
+
+ ///
+ /// 添加人
+ ///
+ public String UserId { get; set; }
+
+ ///
+ /// 团队ID
+ ///
+ public String TeamId { get; set; }
+
+ }
+}
diff --git a/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml b/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml
index 7f4e43d..d61bf9a 100644
--- a/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml
+++ b/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml
@@ -11,7 +11,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
netcoreapp3.1
win-x64
true
- True
+ False
False
False
diff --git a/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml.user b/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml.user
index 312c6e3..0a4153d 100644
--- a/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/JdShopListener/JdShopListener/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -3,4 +3,7 @@
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
+
+ True|2021-11-11T10:06:38.5161322Z;True|2021-11-11T17:53:13.2835443+08:00;True|2021-11-11T17:52:00.9170918+08:00;True|2021-11-11T17:51:37.4852682+08:00;True|2021-11-11T17:49:30.9386192+08:00;True|2021-11-11T17:44:28.5146341+08:00;True|2021-11-11T17:42:26.8480671+08:00;True|2021-11-11T17:37:14.4108790+08:00;True|2021-11-11T17:30:25.4460722+08:00;
+
\ No newline at end of file
diff --git a/JdShopListener/JdShopListener/SqlHelpers/DbHelper.cs b/JdShopListener/JdShopListener/SqlHelpers/DbHelper.cs
index be0d482..b1bc097 100644
--- a/JdShopListener/JdShopListener/SqlHelpers/DbHelper.cs
+++ b/JdShopListener/JdShopListener/SqlHelpers/DbHelper.cs
@@ -83,7 +83,6 @@ namespace JdShopListener.SqlHelpers
{
using (var db = new JdDBContext())
{
-
db.SkuItems.Remove(model);
return db.SaveChanges()>0;
}
diff --git a/JdShopListener/WpfNoticeMsg/NoticeMessage.xaml b/JdShopListener/WpfNoticeMsg/NoticeMessage.xaml
new file mode 100644
index 0000000..5881742
--- /dev/null
+++ b/JdShopListener/WpfNoticeMsg/NoticeMessage.xaml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/JdShopListener/WpfNoticeMsg/NoticeMessage.xaml.cs b/JdShopListener/WpfNoticeMsg/NoticeMessage.xaml.cs
new file mode 100644
index 0000000..957c167
--- /dev/null
+++ b/JdShopListener/WpfNoticeMsg/NoticeMessage.xaml.cs
@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Shapes;
+
+namespace WpfNoticeMsg
+{
+ ///
+ /// NoticeMessage.xaml 的交互逻辑
+ ///
+ public partial class NoticeMessage : Window
+ {
+ public NoticeMessage()
+ {
+ InitializeComponent();
+ }
+
+ ///
+ /// 显示消息
+ ///
+ ///
+ ///
+ ///
+ public static void Show(string msg, string title = "提示", int sleep = 2000)
+ {
+ Application.Current.Dispatcher.BeginInvoke(new Action(() =>
+ {
+ NoticeMessage noticeMessage = new NoticeMessage();
+ noticeMessage.Owner = Application.Current.MainWindow;
+ noticeMessage.txt_Title.Text = title;
+ noticeMessage.txtMsg.Text = msg;
+
+ noticeMessage.Height= noticeMessage.grid.ActualHeight;
+ noticeMessage.Width = noticeMessage.grid.ActualWidth + 30;
+
+ noticeMessage.Show();
+
+ Task.Factory.StartNew(() =>
+ {
+ Thread.Sleep(sleep);
+ Application.Current.Dispatcher.Invoke(() =>
+ {
+ noticeMessage.Close();
+ });
+ });
+ }));
+ }
+
+ private void close_Click(object sender, RoutedEventArgs e)
+ {
+ this.Close();
+ }
+ }
+}
diff --git a/JdShopListener/WpfNoticeMsg/WpfNoticeMsg.csproj b/JdShopListener/WpfNoticeMsg/WpfNoticeMsg.csproj
new file mode 100644
index 0000000..80afe0a
--- /dev/null
+++ b/JdShopListener/WpfNoticeMsg/WpfNoticeMsg.csproj
@@ -0,0 +1,23 @@
+
+
+
+ netcoreapp3.1
+ true
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
diff --git a/JdShopListener/WpfNoticeMsg/WpfNoticeMsg.csproj.user b/JdShopListener/WpfNoticeMsg/WpfNoticeMsg.csproj.user
new file mode 100644
index 0000000..a291fdf
--- /dev/null
+++ b/JdShopListener/WpfNoticeMsg/WpfNoticeMsg.csproj.user
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Code
+
+
+
+
+ Designer
+
+
+
\ No newline at end of file