From 5355352f0777ddedd517e37c3dd4db4c9d057e6b Mon Sep 17 00:00:00 2001 From: 8402134 <8402134@qq.com> Date: Fri, 27 Jan 2023 17:53:21 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BB=A3=E8=BF=90=E8=90=A5=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=B7=9F=E5=8F=91=E6=9D=A5=E6=BA=90=E8=AE=BE=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 应用/ProductClient/Class1.cs | 15 +++- 应用/ProductClient/Config.cs | 7 +- 应用/ProductClient/MainForm.Designer.cs | 27 +++++++ 应用/ProductClient/MainForm.cs | 96 +++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 3 deletions(-) diff --git a/应用/ProductClient/Class1.cs b/应用/ProductClient/Class1.cs index b58d36b..9a35d3a 100644 --- a/应用/ProductClient/Class1.cs +++ b/应用/ProductClient/Class1.cs @@ -102,7 +102,7 @@ namespace ProductClient private static Dictionary CacheDic = new Dictionary(); - private void EventClient_DyyNoticeEvent(object sender, Api.Framework.Events.DyyNoticeEvent e) + private void EventClient_DyyNoticeEvent(object sender, DyyNoticeEvent e) { try { @@ -110,6 +110,8 @@ namespace ProductClient var json = e.Data; //{"Id":"122522636742819840","TaskId":"122522636742819840","IsGoods":true} + //var json = "{\"TaskId\":\"133038429393911808\",\"CollectionSourceId\":\"129505086429724672\",\"IsGoods\":true}"; + var jObj = JObject.Parse(json); var taskId = jObj["TaskId"]?.Value(); if (string.IsNullOrWhiteSpace(taskId)) @@ -121,7 +123,16 @@ namespace ProductClient { return; } - CacheDic[taskId] = taskId; + + //发送任务来源Id + var collectionSourceId = jObj["CollectionSourceId"]?.Value(); + + if (Config.sourceId != collectionSourceId) + { + return; + } + + CacheDic[taskId] = collectionSourceId; HttpHelper http = new HttpHelper(); var html = http diff --git a/应用/ProductClient/Config.cs b/应用/ProductClient/Config.cs index b453484..f8424fb 100644 --- a/应用/ProductClient/Config.cs +++ b/应用/ProductClient/Config.cs @@ -21,6 +21,11 @@ namespace ProductClient public DwzType dwzType { get; set; } + /// + /// 商品采集源Id + /// + public string sourceId { get; set; } + public string tbPid { get; set; } public string pddPid { get; set; } @@ -56,7 +61,7 @@ namespace ProductClient /// 是否评论 /// public bool isPl { get; set; } - + /// /// 追加自定义评语 /// diff --git a/应用/ProductClient/MainForm.Designer.cs b/应用/ProductClient/MainForm.Designer.cs index 417d5bc..48e3352 100644 --- a/应用/ProductClient/MainForm.Designer.cs +++ b/应用/ProductClient/MainForm.Designer.cs @@ -61,6 +61,8 @@ this.labelControl1 = new DevExpress.XtraEditors.LabelControl(); this.xtraTabPage3 = new DevExpress.XtraTab.XtraTabPage(); this.label2 = new System.Windows.Forms.Label(); + this.comboBoxEdit3 = new DevExpress.XtraEditors.ComboBoxEdit(); + this.labelControl11 = new DevExpress.XtraEditors.LabelControl(); ((System.ComponentModel.ISupportInitialize)(this.xtraTabControl1)).BeginInit(); this.xtraTabControl1.SuspendLayout(); this.xtraTabPage1.SuspendLayout(); @@ -74,6 +76,7 @@ ((System.ComponentModel.ISupportInitialize)(this.textEdit2.Properties)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).BeginInit(); this.xtraTabPage3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit3.Properties)).BeginInit(); this.SuspendLayout(); // // xtraTabControl1 @@ -110,6 +113,8 @@ // // xtraTabPage2 // + this.xtraTabPage2.Controls.Add(this.comboBoxEdit3); + this.xtraTabPage2.Controls.Add(this.labelControl11); this.xtraTabPage2.Controls.Add(this.label3); this.xtraTabPage2.Controls.Add(this.checkBox2); this.xtraTabPage2.Controls.Add(this.memoEdit1); @@ -417,6 +422,25 @@ this.label2.TabIndex = 0; this.label2.Text = "内测中..."; // + // comboBoxEdit3 + // + this.comboBoxEdit3.EditValue = ""; + this.comboBoxEdit3.Location = new System.Drawing.Point(158, 171); + this.comboBoxEdit3.Name = "comboBoxEdit3"; + this.comboBoxEdit3.Properties.Buttons.AddRange(new DevExpress.XtraEditors.Controls.EditorButton[] { + new DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)}); + this.comboBoxEdit3.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor; + this.comboBoxEdit3.Size = new System.Drawing.Size(245, 20); + this.comboBoxEdit3.TabIndex = 27; + // + // labelControl11 + // + this.labelControl11.Location = new System.Drawing.Point(65, 177); + this.labelControl11.Name = "labelControl11"; + this.labelControl11.Size = new System.Drawing.Size(72, 14); + this.labelControl11.TabIndex = 26; + this.labelControl11.Text = "商品采集源:"; + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 14F); @@ -446,6 +470,7 @@ ((System.ComponentModel.ISupportInitialize)(this.textEdit1.Properties)).EndInit(); this.xtraTabPage3.ResumeLayout(false); this.xtraTabPage3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.comboBoxEdit3.Properties)).EndInit(); this.ResumeLayout(false); } @@ -485,5 +510,7 @@ private System.Windows.Forms.Label label3; private DevExpress.XtraEditors.TextEdit textEdit4; private DevExpress.XtraEditors.LabelControl labelControl10; + private DevExpress.XtraEditors.ComboBoxEdit comboBoxEdit3; + private DevExpress.XtraEditors.LabelControl labelControl11; } } \ No newline at end of file diff --git a/应用/ProductClient/MainForm.cs b/应用/ProductClient/MainForm.cs index 12164ba..cbe4fbc 100644 --- a/应用/ProductClient/MainForm.cs +++ b/应用/ProductClient/MainForm.cs @@ -5,8 +5,13 @@ using Api.Framework.Tools; using DevExpress.XtraEditors; using ProductClient.Properties; using System; +using System.Collections.Generic; +using System.Linq; using System.Text.RegularExpressions; using System.Windows.Forms; +using CsharpHttpHelper; +using DevExpress.Utils.Filtering.Internal; +using Newtonsoft.Json.Linq; using UI.Framework.Forms; using static Api.Framework.ApiClient; @@ -52,12 +57,99 @@ namespace ProductClient this.comboBoxEdit2.Properties.Items.AddRange(Enum.GetNames(typeof(DwzType))); comboBoxEdit2.SelectedIndex = (int)Class1.Config.dwzType; + SetComboBox_GetCollectionSource(); + comboBoxEdit1.SelectedIndex = (int)Class1.Config.qrImageType; memoEdit1.Text = Class1.Config.appendComment; } + /// + /// 赋值采集源 + /// + private void SetComboBox_GetCollectionSource() + { + if (Class1.Config.sourceId == null) + { + Class1.Config.sourceId = "129505086429724672"; + } + + + + var collectionSources = GetCollectionSourceAll(); + if (collectionSources != null) + { + int index = 0; + foreach (var item in collectionSources) + { + this.comboBoxEdit3.Properties.Items.Add(item); + this.comboBoxEdit3.SelectedText = item.Nick; + if (Class1.Config.sourceId == item.SourceId) + { + comboBoxEdit3.SelectedIndex = index; + } + index++; + } + } + } + + /// + /// 获取代运营朋友圈采集源头 + /// + /// + public List GetCollectionSourceAll() + { + //http://goods.api.52cmg.cn/api/WechatMomentsGoods-WechatMoments/GetCollectionSourceAll + //{"Code":0,"Result":[{"Id":"129505086429724672","NickName":"壮壮"}]} + + var html = new HttpHelper().GetHtml( + "http://goods.api.52cmg.cn/api/WechatMomentsGoods-WechatMoments/GetCollectionSourceAll").Html; + + var jObj = JObject.Parse(html); + if (jObj["Code"]?.Value() != 0) + { + return null; + } + + var list = new List(); + var jArr = jObj["Result"]?.ToArray(); + if (jArr != null && jArr.Length > 0) + { + foreach (var jToken in jArr) + { + var item = new CollectionSourceResult(); + item.SourceId = jToken["Id"]?.Value(); + item.Nick = jToken["NickName"]?.Value(); + list.Add(item); + } + } + return list; + } + + /// + /// 朋友圈采集源头数据 + /// + public class CollectionSourceResult + { + /// + /// 来源Id + /// + public string SourceId { get; set; } + + /// + /// 昵称 + /// + public string Nick { get; set; } + + /// 返回表示当前对象的字符串。 + /// 表示当前对象的字符串。 + public override string ToString() + { + return Nick; + } + } + private void hyperlinkLabelControl_Click(object sender, EventArgs e) { try @@ -117,6 +209,10 @@ namespace ProductClient Class1.Config.qrImageType = (QrImageType)comboBoxEdit1.SelectedIndex; Class1.Config.Monitor_Interval = (int)numericUpDown1.Value; Class1.Config.dwzType = (DwzType)comboBoxEdit2.SelectedIndex; + if (comboBoxEdit3.SelectedItem != null) + { + Class1.Config.sourceId = ((CollectionSourceResult)comboBoxEdit3.SelectedItem)?.SourceId; + } Class1.Config.isPyTkl = checkBox1.Checked; Class1.Config.isPl = checkBox2.Checked; Class1.Config.appendComment = memoEdit1.Text;