我的商品库增加AI识图

This commit is contained in:
chfei committed 2026-11-06 19:23:00 +08:00
1 parent ff94184a0c
commit 013d343fe9
12 files changed
+880 -377

No files matched your search

@@ -22,165 +22,346 @@ namespace TemuKJD.KJDForms.SystemForms
private void InitializeComponent()
{
this.imagesGroup = new GroupBox();
this.mainLabel = new Label();
this.main = new ComboBox();
this.mainCount = new NumericUpDown();
this.mainUnit = new Label();
this.detailLabel = new Label();
this.detail = new ComboBox();
this.detailCount = new NumericUpDown();
this.detailUnit = new Label();
this.sku = new CheckBox();
this.keywordsGroup = new GroupBox();
this.keywords = new TextBox();
this.keywordsHint = new Label();
this.btnSaveDetection = new Button();
this.imagesGroup.SuspendLayout();
this.keywordsGroup.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.mainCount)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.detailCount)).BeginInit();
this.SuspendLayout();
this.imagesGroup = new System.Windows.Forms.GroupBox();
this.mainLabel = new System.Windows.Forms.Label();
this.main = new System.Windows.Forms.ComboBox();
this.mainCount = new System.Windows.Forms.NumericUpDown();
this.mainUnit = new System.Windows.Forms.Label();
this.detailLabel = new System.Windows.Forms.Label();
this.detail = new System.Windows.Forms.ComboBox();
this.detailCount = new System.Windows.Forms.NumericUpDown();
this.detailUnit = new System.Windows.Forms.Label();
this.sku = new System.Windows.Forms.CheckBox();
this.keywordsGroup = new System.Windows.Forms.GroupBox();
this.keywords = new System.Windows.Forms.TextBox();
this.keywordsHint = new System.Windows.Forms.Label();
this.btnSaveDetection = new System.Windows.Forms.Button();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.num_points = new System.Windows.Forms.NumericUpDown();
this.lb_imagequtoa = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.btn_Exchange = new System.Windows.Forms.Button();
this.label4 = new System.Windows.Forms.Label();
this.imagesGroup.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.mainCount)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.detailCount)).BeginInit();
this.keywordsGroup.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.num_points)).BeginInit();
this.SuspendLayout();
//
// imagesGroup
//
this.imagesGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.imagesGroup.Controls.Add(this.mainLabel);
this.imagesGroup.Controls.Add(this.main);
this.imagesGroup.Controls.Add(this.mainCount);
this.imagesGroup.Controls.Add(this.mainUnit);
this.imagesGroup.Controls.Add(this.detailLabel);
this.imagesGroup.Controls.Add(this.detail);
this.imagesGroup.Controls.Add(this.detailCount);
this.imagesGroup.Controls.Add(this.detailUnit);
this.imagesGroup.Controls.Add(this.sku);
this.imagesGroup.Location = new System.Drawing.Point(20, 71);
this.imagesGroup.Name = "imagesGroup";
this.imagesGroup.Size = new System.Drawing.Size(760, 153);
this.imagesGroup.TabIndex = 0;
this.imagesGroup.TabStop = false;
this.imagesGroup.Text = "检测图片";
//
// mainLabel
//
this.mainLabel.AutoSize = true;
this.mainLabel.Location = new System.Drawing.Point(16, 34);
this.mainLabel.Name = "mainLabel";
this.mainLabel.Size = new System.Drawing.Size(56, 17);
this.mainLabel.TabIndex = 0;
this.mainLabel.Text = "商品主图";
//
// main
//
this.main.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.main.Items.AddRange(new object[] {
"全部",
"前几张"});
this.main.Location = new System.Drawing.Point(106, 30);
this.main.Name = "main";
this.main.Size = new System.Drawing.Size(110, 25);
this.main.TabIndex = 1;
this.main.SelectedIndexChanged += new System.EventHandler(this.ImageRangeChanged);
//
// mainCount
//
this.mainCount.AccessibleName = "商品主图检测张数";
this.mainCount.Enabled = false;
this.mainCount.Location = new System.Drawing.Point(228, 30);
this.mainCount.Maximum = new decimal(new int[] {
999,
0,
0,
0});
this.mainCount.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.mainCount.Name = "mainCount";
this.mainCount.Size = new System.Drawing.Size(60, 23);
this.mainCount.TabIndex = 2;
this.mainCount.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// mainUnit
//
this.mainUnit.AutoSize = true;
this.mainUnit.Location = new System.Drawing.Point(294, 34);
this.mainUnit.Name = "mainUnit";
this.mainUnit.Size = new System.Drawing.Size(20, 17);
this.mainUnit.TabIndex = 3;
this.mainUnit.Text = "张";
//
// detailLabel
//
this.detailLabel.AutoSize = true;
this.detailLabel.Location = new System.Drawing.Point(16, 72);
this.detailLabel.Name = "detailLabel";
this.detailLabel.Size = new System.Drawing.Size(44, 17);
this.detailLabel.TabIndex = 4;
this.detailLabel.Text = "详情图";
//
// detail
//
this.detail.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.detail.Items.AddRange(new object[] {
"不检测",
"前几张",
"全部"});
this.detail.Location = new System.Drawing.Point(106, 68);
this.detail.Name = "detail";
this.detail.Size = new System.Drawing.Size(110, 25);
this.detail.TabIndex = 5;
this.detail.SelectedIndexChanged += new System.EventHandler(this.ImageRangeChanged);
//
// detailCount
//
this.detailCount.AccessibleName = "详情图检测张数";
this.detailCount.Enabled = false;
this.detailCount.Location = new System.Drawing.Point(228, 68);
this.detailCount.Maximum = new decimal(new int[] {
999,
0,
0,
0});
this.detailCount.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.detailCount.Name = "detailCount";
this.detailCount.Size = new System.Drawing.Size(60, 23);
this.detailCount.TabIndex = 6;
this.detailCount.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// detailUnit
//
this.detailUnit.AutoSize = true;
this.detailUnit.Location = new System.Drawing.Point(294, 72);
this.detailUnit.Name = "detailUnit";
this.detailUnit.Size = new System.Drawing.Size(20, 17);
this.detailUnit.TabIndex = 7;
this.detailUnit.Text = "张";
//
// sku
//
this.sku.AutoSize = true;
this.sku.Location = new System.Drawing.Point(106, 112);
this.sku.Name = "sku";
this.sku.Size = new System.Drawing.Size(107, 21);
this.sku.TabIndex = 8;
this.sku.Text = "检测 SKU 图片";
//
// keywordsGroup
//
this.keywordsGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.keywordsGroup.Controls.Add(this.keywords);
this.keywordsGroup.Controls.Add(this.keywordsHint);
this.keywordsGroup.Location = new System.Drawing.Point(20, 238);
this.keywordsGroup.Name = "keywordsGroup";
this.keywordsGroup.Size = new System.Drawing.Size(760, 143);
this.keywordsGroup.TabIndex = 1;
this.keywordsGroup.TabStop = false;
this.keywordsGroup.Text = "检测关键词";
//
// keywords
//
this.keywords.AcceptsReturn = true;
this.keywords.AccessibleName = "检测关键词";
this.keywords.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.keywords.Location = new System.Drawing.Point(16, 27);
this.keywords.Multiline = true;
this.keywords.Name = "keywords";
this.keywords.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.keywords.Size = new System.Drawing.Size(728, 68);
this.keywords.TabIndex = 0;
//
// keywordsHint
//
this.keywordsHint.AutoSize = true;
this.keywordsHint.ForeColor = System.Drawing.SystemColors.GrayText;
this.keywordsHint.Location = new System.Drawing.Point(16, 105);
this.keywordsHint.Name = "keywordsHint";
this.keywordsHint.Size = new System.Drawing.Size(260, 17);
this.keywordsHint.TabIndex = 1;
this.keywordsHint.Text = "多个关键词可用逗号、分号、空格或换行分隔。";
//
// btnSaveDetection
//
this.btnSaveDetection.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btnSaveDetection.Cursor = System.Windows.Forms.Cursors.Hand;
this.btnSaveDetection.FlatAppearance.BorderSize = 0;
this.btnSaveDetection.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btnSaveDetection.ForeColor = System.Drawing.Color.White;
this.btnSaveDetection.Location = new System.Drawing.Point(20, 396);
this.btnSaveDetection.Name = "btnSaveDetection";
this.btnSaveDetection.Size = new System.Drawing.Size(96, 32);
this.btnSaveDetection.TabIndex = 2;
this.btnSaveDetection.Text = "保存条件";
this.btnSaveDetection.UseVisualStyleBackColor = false;
this.btnSaveDetection.Click += new System.EventHandler(this.SaveDetectionClick);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.btn_Exchange);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.num_points);
this.groupBox1.Controls.Add(this.lb_imagequtoa);
this.groupBox1.Controls.Add(this.label1);
this.groupBox1.Location = new System.Drawing.Point(20, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(760, 53);
this.groupBox1.TabIndex = 3;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "积分兑换";
//
// num_points
//
this.num_points.Location = new System.Drawing.Point(269, 20);
this.num_points.Maximum = new decimal(new int[] {
1000,
0,
0,
0});
this.num_points.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.num_points.Name = "num_points";
this.num_points.Size = new System.Drawing.Size(120, 23);
this.num_points.TabIndex = 2;
this.num_points.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// lb_imagequtoa
//
this.lb_imagequtoa.AutoSize = true;
this.lb_imagequtoa.Location = new System.Drawing.Point(130, 23);
this.lb_imagequtoa.Name = "lb_imagequtoa";
this.lb_imagequtoa.Size = new System.Drawing.Size(50, 17);
this.lb_imagequtoa.TabIndex = 1;
this.lb_imagequtoa.Text = "999999";
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(65, 23);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(68, 17);
this.label1.TabIndex = 0;
this.label1.Text = "检测图片:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(195, 23);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 17);
this.label3.TabIndex = 3;
this.label3.Text = "积分兑换";
//
// btn_Exchange
//
this.btn_Exchange.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(126)))), ((int)(((byte)(255)))));
this.btn_Exchange.Cursor = System.Windows.Forms.Cursors.Hand;
this.btn_Exchange.FlatAppearance.BorderSize = 0;
this.btn_Exchange.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.btn_Exchange.ForeColor = System.Drawing.Color.White;
this.btn_Exchange.Location = new System.Drawing.Point(395, 19);
this.btn_Exchange.Name = "btn_Exchange";
this.btn_Exchange.Size = new System.Drawing.Size(68, 24);
this.btn_Exchange.TabIndex = 4;
this.btn_Exchange.Text = "兑换";
this.btn_Exchange.UseVisualStyleBackColor = false;
this.btn_Exchange.Click += new System.EventHandler(this.btn_Exchange_Click);
//
// label4
//
this.label4.AutoSize = true;
this.label4.ForeColor = System.Drawing.SystemColors.ControlDark;
this.label4.Location = new System.Drawing.Point(478, 23);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(165, 17);
this.label4.TabIndex = 5;
this.label4.Text = "兑换比例:1积分=100张图片";
//
// SystemGoodsComplianceForm
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.AutoScroll = true;
this.AutoScrollMinSize = new System.Drawing.Size(365, 390);
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.imagesGroup);
this.Controls.Add(this.keywordsGroup);
this.Controls.Add(this.btnSaveDetection);
this.Font = new System.Drawing.Font("微软雅黑", 9F);
this.Name = "SystemGoodsComplianceForm";
this.Text = "商品 AI 检测";
this.imagesGroup.ResumeLayout(false);
this.imagesGroup.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.mainCount)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.detailCount)).EndInit();
this.keywordsGroup.ResumeLayout(false);
this.keywordsGroup.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.num_points)).EndInit();
this.ResumeLayout(false);
this.imagesGroup.Name = "imagesGroup";
this.imagesGroup.Location = new Point(20, 16);
this.imagesGroup.TabIndex = 0;
this.imagesGroup.Size = new Size(760, 153);
this.imagesGroup.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
this.imagesGroup.Text = "检测图片";
this.imagesGroup.Controls.Add(this.mainLabel);
this.imagesGroup.Controls.Add(this.main);
this.imagesGroup.Controls.Add(this.mainCount);
this.imagesGroup.Controls.Add(this.mainUnit);
this.imagesGroup.Controls.Add(this.detailLabel);
this.imagesGroup.Controls.Add(this.detail);
this.imagesGroup.Controls.Add(this.detailCount);
this.imagesGroup.Controls.Add(this.detailUnit);
this.imagesGroup.Controls.Add(this.sku);
this.mainLabel.Name = "mainLabel";
this.mainLabel.Location = new Point(16, 34);
this.mainLabel.TabIndex = 0;
this.mainLabel.AutoSize = true;
this.mainLabel.Text = "商品主图";
this.main.Name = "main";
this.main.Location = new Point(106, 30);
this.main.TabIndex = 1;
this.main.Width = 110;
this.main.DropDownStyle = ComboBoxStyle.DropDownList;
this.main.Items.AddRange(new object[] { "全部", "前几张" });
this.main.SelectedIndexChanged += new System.EventHandler(this.ImageRangeChanged);
this.mainCount.Name = "mainCount";
this.mainCount.Location = new Point(228, 30);
this.mainCount.TabIndex = 2;
this.mainCount.Enabled = false;
this.mainCount.Minimum = 1M;
this.mainCount.Maximum = 999M;
this.mainCount.Value = 1M;
this.mainCount.Width = 60;
this.mainCount.AccessibleName = "商品主图检测张数";
this.mainUnit.Name = "mainUnit";
this.mainUnit.Location = new Point(294, 34);
this.mainUnit.TabIndex = 3;
this.mainUnit.AutoSize = true;
this.mainUnit.Text = "张";
this.detailLabel.Name = "detailLabel";
this.detailLabel.Location = new Point(16, 72);
this.detailLabel.TabIndex = 4;
this.detailLabel.AutoSize = true;
this.detailLabel.Text = "详情图";
this.detail.Name = "detail";
this.detail.Location = new Point(106, 68);
this.detail.TabIndex = 5;
this.detail.Width = 110;
this.detail.DropDownStyle = ComboBoxStyle.DropDownList;
this.detail.Items.AddRange(new object[] { "不检测", "前几张", "全部" });
this.detail.SelectedIndexChanged += new System.EventHandler(this.ImageRangeChanged);
this.detailCount.Name = "detailCount";
this.detailCount.Location = new Point(228, 68);
this.detailCount.TabIndex = 6;
this.detailCount.Enabled = false;
this.detailCount.Minimum = 1M;
this.detailCount.Maximum = 999M;
this.detailCount.Value = 1M;
this.detailCount.Width = 60;
this.detailCount.AccessibleName = "详情图检测张数";
this.detailUnit.Name = "detailUnit";
this.detailUnit.Location = new Point(294, 72);
this.detailUnit.TabIndex = 7;
this.detailUnit.AutoSize = true;
this.detailUnit.Text = "张";
this.sku.Name = "sku";
this.sku.Location = new Point(106, 112);
this.sku.TabIndex = 8;
this.sku.AutoSize = true;
this.sku.Text = "检测 SKU 图片";
this.keywordsGroup.Name = "keywordsGroup";
this.keywordsGroup.Location = new Point(20, 183);
this.keywordsGroup.TabIndex = 1;
this.keywordsGroup.Size = new Size(760, 143);
this.keywordsGroup.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
this.keywordsGroup.Text = "检测关键词";
this.keywordsGroup.Controls.Add(this.keywords);
this.keywordsGroup.Controls.Add(this.keywordsHint);
this.keywords.Name = "keywords";
this.keywords.Location = new Point(16, 27);
this.keywords.TabIndex = 0;
this.keywords.Size = new Size(728, 68);
this.keywords.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
this.keywords.Multiline = true;
this.keywords.AcceptsReturn = true;
this.keywords.ScrollBars = ScrollBars.Vertical;
this.keywords.AccessibleName = "检测关键词";
this.keywordsHint.Name = "keywordsHint";
this.keywordsHint.Location = new Point(16, 105);
this.keywordsHint.TabIndex = 1;
this.keywordsHint.AutoSize = true;
this.keywordsHint.ForeColor = SystemColors.GrayText;
this.keywordsHint.Text = "多个关键词可用逗号、分号、空格或换行分隔。";
this.btnSaveDetection.Name = "btnSaveDetection";
this.btnSaveDetection.Location = new Point(20, 341);
this.btnSaveDetection.TabIndex = 2;
this.btnSaveDetection.Size = new Size(96, 32);
this.btnSaveDetection.Text = "保存条件";
this.btnSaveDetection.BackColor = Color.FromArgb(63, 126, 255);
this.btnSaveDetection.ForeColor = Color.White;
this.btnSaveDetection.FlatStyle = FlatStyle.Flat;
this.btnSaveDetection.UseVisualStyleBackColor = false;
this.btnSaveDetection.Cursor = Cursors.Hand;
this.btnSaveDetection.FlatAppearance.BorderSize = 0;
this.btnSaveDetection.Click += new System.EventHandler(this.SaveDetectionClick);
this.AutoScaleMode = AutoScaleMode.None;
this.AutoScroll = true;
this.AutoScrollMinSize = new Size(365, 390);
this.BackColor = Color.White;
this.ClientSize = new Size(800, 450);
this.Font = new Font("微软雅黑", 9F);
this.Controls.Add(this.imagesGroup);
this.Controls.Add(this.keywordsGroup);
this.Controls.Add(this.btnSaveDetection);
this.Name = "SystemGoodsComplianceForm";
this.Text = "商品 AI 检测";
this.imagesGroup.ResumeLayout(false);
this.imagesGroup.PerformLayout();
this.keywordsGroup.ResumeLayout(false);
this.keywordsGroup.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.mainCount)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.detailCount)).EndInit();
this.ResumeLayout(false);
}
}
private GroupBox groupBox1;
private NumericUpDown num_points;
private Label lb_imagequtoa;
private Label label1;
private Label label4;
private Button btn_Exchange;
private Label label3;
}
}
@@ -1,64 +1,109 @@
using System;
using System.Windows.Forms;
using Work.Services;
using AllBase;
using AllBase.Helper;
using AllBase.Model.Result;
using Newtonsoft.Json;
using System;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Threading.Tasks;
using System.Windows.Forms;
using TemuKJD.BaseForms;
using Work;
using Work.Services;
namespace TemuKJD.KJDForms.SystemForms
{
public partial class SystemGoodsComplianceForm : BaseForm
{
public SystemGoodsComplianceForm()
{
InitializeComponent();
public partial class SystemGoodsComplianceForm : BaseForm
{
public SystemGoodsComplianceForm()
{
InitializeComponent();
VisibleChanged += (sender, e) => { if (Visible) LoadSettings(); };
LoadSettings();
}
VisibleChanged += (sender, e) => { if (Visible) LoadSettings(); };
LoadSettings();
}
private void LoadSettings()
{
var options = GlobalConfig.GlobalSettings.GoodsCompliance ?? new ComplianceOptions();
main.SelectedIndex = options.MainCount.HasValue ? 1 : 0;
detail.SelectedIndex = options.DetailCount == null ? 2 : options.DetailCount == 0 ? 0 : 1;
mainCount.Value = Math.Min(mainCount.Maximum, Math.Max(1, options.MainCount ?? 1));
detailCount.Value = Math.Min(detailCount.Maximum, Math.Max(1, options.DetailCount ?? 1));
sku.Checked = options.IncludeSku;
keywords.Text = options.Keywords;
}
private void LoadSettings()
{
lb_imagequtoa.Text = BaseClass.ImageAnalysisQuota.ToString();
private void ImageRangeChanged(object sender, EventArgs e)
{
mainCount.Enabled = main.SelectedIndex == 1;
detailCount.Enabled = detail.SelectedIndex == 1;
}
private void SaveDetectionClick(object sender, EventArgs e)
{
if (GoodsComplianceService.Keywords(keywords.Text).Length == 0)
{
MessageBox.Show(this, "请输入检测关键词。");
keywords.Focus();
return;
}
var settings = GlobalConfig.GlobalSettings;
var previous = settings.GoodsCompliance;
settings.GoodsCompliance = new ComplianceOptions
{
MainCount = main.SelectedIndex == 0 ? (int?)null : (int)mainCount.Value,
DetailCount = detail.SelectedIndex == 2 ? (int?)null : detail.SelectedIndex == 0 ? 0 : (int)detailCount.Value,
IncludeSku = sku.Checked,
Keywords = keywords.Text.Trim()
};
try { StartUp.SaveGlobalSettings(); }
catch (Exception ex)
{
settings.GoodsCompliance = previous;
MessageBox.Show(this, "保存检测条件失败:" + ex.Message);
return;
}
MessageBox.Show(this, "已保存 AI 检测条件。");
}
}
var options = GlobalConfig.GlobalSettings.GoodsCompliance ?? new ComplianceOptions();
main.SelectedIndex = options.MainCount.HasValue ? 1 : 0;
detail.SelectedIndex = options.DetailCount == null ? 2 : options.DetailCount == 0 ? 0 : 1;
mainCount.Value = Math.Min(mainCount.Maximum, Math.Max(1, options.MainCount ?? 1));
detailCount.Value = Math.Min(detailCount.Maximum, Math.Max(1, options.DetailCount ?? 1));
sku.Checked = options.IncludeSku;
keywords.Text = options.Keywords;
}
private void ImageRangeChanged(object sender, EventArgs e)
{
mainCount.Enabled = main.SelectedIndex == 1;
detailCount.Enabled = detail.SelectedIndex == 1;
}
private void SaveDetectionClick(object sender, EventArgs e)
{
if (GoodsComplianceService.Keywords(keywords.Text).Length == 0)
{
MessageBox.Show(this, "请输入检测关键词。");
keywords.Focus();
return;
}
var settings = GlobalConfig.GlobalSettings;
var previous = settings.GoodsCompliance;
settings.GoodsCompliance = new ComplianceOptions
{
MainCount = main.SelectedIndex == 0 ? (int?)null : (int)mainCount.Value,
DetailCount = detail.SelectedIndex == 2 ? (int?)null : detail.SelectedIndex == 0 ? 0 : (int)detailCount.Value,
IncludeSku = sku.Checked,
Keywords = keywords.Text.Trim()
};
try { StartUp.SaveGlobalSettings(); }
catch (Exception ex)
{
settings.GoodsCompliance = previous;
MessageBox.Show(this, "保存检测条件失败:" + ex.Message);
return;
}
MessageBox.Show(this, "已保存 AI 检测条件。");
}
private async void btn_Exchange_Click(object sender, EventArgs e)
{
try
{
btn_Exchange.Enabled = false;
int points = (int)num_points.Value;
if (BaseMsgForm.ShowConfirm($"是否要兑换 {points} 积分,共:{points * 100}张图片检测?", "提示").DialogResult != DialogResult.OK)
{
return;
}
var url = BaseClass.BuildObjString("user/BuyImageAnalysisQuota");
var data = UserLogin.GetSignPostData(new
{
Amount = points,
});
string html = await GetHtml.PostJsonAsync(url, data);
var ret = JsonConvert.DeserializeObject<Result<int>>(html);
if (ret.Code == 200)
{
BaseClass.ImageAnalysisQuota += ret.Data;
lb_imagequtoa.Text = BaseClass.ImageAnalysisQuota.ToString();
BaseMsgForm.ShowInfo("兑换成功");
}
}
catch (Exception ex)
{
BaseMsgForm.ShowInfo("兑换失败:" + ex.Message);
}
finally
{
btn_Exchange.Enabled = true;
}
}
}
}
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>