diff --git a/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.Designer.cs b/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.Designer.cs index e40d5fa..b4fdb19 100644 --- a/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.Designer.cs +++ b/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.Designer.cs @@ -30,12 +30,12 @@ namespace TemuKJD.ToolForms private void InitializeComponent() { this.components = new System.ComponentModel.Container(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle9 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle10 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle11 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle12 = new System.Windows.Forms.DataGridViewCellStyle(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.ucTabControlMetro1 = new TemuKJD.UserControls.UcTabControlMetro(); this.tabPage1 = new System.Windows.Forms.TabPage(); @@ -63,6 +63,7 @@ namespace TemuKJD.ToolForms this.cmbMultiCookieName = new DevComponents.DotNetBar.Controls.ComboBoxEx(); this.btnMultiLogin = new DevComponents.DotNetBar.PanelEx(); this.btnDel = new DevComponents.DotNetBar.PanelEx(); + this.chkKeepOldData = new TemuKJD.UserComponent.UcCheckBox(this.components); this.btnClear = new DevComponents.DotNetBar.PanelEx(); this.label2 = new System.Windows.Forms.Label(); this.txtFilterTotalSaleCount = new System.Windows.Forms.TextBox(); @@ -120,6 +121,7 @@ namespace TemuKJD.ToolForms // splitContainer1.Panel2 // this.splitContainer1.Panel2.BackColor = System.Drawing.Color.White; + this.splitContainer1.Panel2.Controls.Add(this.chkKeepOldData); this.splitContainer1.Panel2.Controls.Add(this.btnClear); this.splitContainer1.Panel2.Controls.Add(this.label2); this.splitContainer1.Panel2.Controls.Add(this.txtFilterTotalSaleCount); @@ -254,20 +256,20 @@ namespace TemuKJD.ToolForms // this.dgvProduct.AllowUserToAddRows = false; this.dgvProduct.AllowUserToDeleteRows = false; - dataGridViewCellStyle1.BackColor = System.Drawing.Color.WhiteSmoke; - this.dgvProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + dataGridViewCellStyle7.BackColor = System.Drawing.Color.WhiteSmoke; + this.dgvProduct.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle7; this.dgvProduct.AutoRowNumber = true; this.dgvProduct.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dgvProduct.BackgroundColor = System.Drawing.Color.White; this.dgvProduct.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255))))); - dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle2; + dataGridViewCellStyle8.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle8.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle8.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle8.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle8.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle8.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvProduct.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle8; this.dgvProduct.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvProduct.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colCheck, @@ -343,8 +345,8 @@ namespace TemuKJD.ToolForms // // colGoodsName // - dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.colGoodsName.DefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle9.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.colGoodsName.DefaultCellStyle = dataGridViewCellStyle9; this.colGoodsName.HeaderText = "商品名称"; this.colGoodsName.Name = "colGoodsName"; this.colGoodsName.ReadOnly = true; @@ -365,8 +367,8 @@ namespace TemuKJD.ToolForms // // colCate // - dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.colCate.DefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle10.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.colCate.DefaultCellStyle = dataGridViewCellStyle10; this.colCate.FillWeight = 80F; this.colCate.HeaderText = "类目"; this.colCate.Name = "colCate"; @@ -375,8 +377,8 @@ namespace TemuKJD.ToolForms // // colPrice // - dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.colPrice.DefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle11.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.colPrice.DefaultCellStyle = dataGridViewCellStyle11; this.colPrice.FillWeight = 70F; this.colPrice.HeaderText = "价格"; this.colPrice.Name = "colPrice"; @@ -391,8 +393,8 @@ namespace TemuKJD.ToolForms // // colMsg // - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.colMsg.DefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle12.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.colMsg.DefaultCellStyle = dataGridViewCellStyle12; this.colMsg.FillWeight = 190F; this.colMsg.HeaderText = "操作结果"; this.colMsg.Name = "colMsg"; @@ -470,6 +472,19 @@ namespace TemuKJD.ToolForms this.btnDel.TabIndex = 409; this.btnDel.Text = "删"; // + // chkKeepOldData + // + this.chkKeepOldData.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.chkKeepOldData.AutoSize = true; + this.chkKeepOldData.Checked = true; + this.chkKeepOldData.CheckState = System.Windows.Forms.CheckState.Checked; + this.chkKeepOldData.Location = new System.Drawing.Point(1163, 26); + this.chkKeepOldData.Name = "chkKeepOldData"; + this.chkKeepOldData.Size = new System.Drawing.Size(123, 21); + this.chkKeepOldData.TabIndex = 1196; + this.chkKeepOldData.Text = "保留上次查询数据"; + this.chkKeepOldData.UseVisualStyleBackColor = true; + // // btnClear // this.btnClear.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); @@ -921,5 +936,6 @@ namespace TemuKJD.ToolForms private System.Windows.Forms.DataGridViewLinkColumn colDel; private System.Windows.Forms.DataGridViewTextBoxColumn colMsg; private DevComponents.DotNetBar.PanelEx btnClear; + private UserComponent.UcCheckBox chkKeepOldData; } } \ No newline at end of file diff --git a/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.cs b/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.cs index 92d5c90..641bb4b 100644 --- a/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.cs +++ b/TEMUKJD/WXForms/AdminForms/WXSaleAssistantForm.cs @@ -490,8 +490,11 @@ namespace TemuKJD.ToolForms cancellationTokenSource.Cancel(); cancellationTokenSource = new CancellationTokenSource(); - dgvProduct.Rows.Clear(); - lstWxSaleAssistantSpuItemInfo.Clear(); + if (chkKeepOldData.Checked == false) + { + dgvProduct.Rows.Clear(); + lstWxSaleAssistantSpuItemInfo.Clear(); + } searchPageCount = 0; spuItemsBase = null; getSpuItemsParams = null; @@ -565,15 +568,28 @@ namespace TemuKJD.ToolForms } //{"code":0,"pageContextResp":{"hasNext":false},"requestId":"1778688044492"} + int errorCnt = 0; var spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams); - if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false")) - spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams); - if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false")) - spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams); - if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false")) - spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams); - if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false")) - spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams); + for (int i = 1; i <= 50; i++) // 重试50次 + { + if (!spuItemsData.Contains("\"code\":0") || spuItemsData.Contains("\"hasNext\":false")) + { + if (!spuItemsData.Contains("\"code\":0")) + errorCnt++; + if (errorCnt > 5) + break; + + sleepTime = (int)(getDetailWaitSeconds * 1000) - 100 + Randomx.GetId(101, 501); + Thread.Sleep(Math.Max(100, sleepTime)); + + spuItemsData = GetAssistant.wxGetAssistant(cookieShop, getSpuItemsParams); + } + if (i % 10 == 0 && spuItemsData.Contains("\"hasNext\":false")) + { + if (BaseMsgForm.ShowConfirm("已连续" + i + "次未查询到下一页商品,是否继续?").DialogResult != DialogResult.OK) + break; + } + } if (!spuItemsData.Contains("\"code\":0")) { BaseMsgForm.ShowError(spuItemsData);