微信导入数据 页面卡死Bug
This commit is contained in:
1 parent
bbcc45625c
commit
423fb3d4f3
1 file changed
+47
-33
@@ -525,7 +525,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
}
|
||||
|
||||
if (isNotCount)
|
||||
data += "&is_not_count=true";
|
||||
data += "&is_not_count=true";
|
||||
}));
|
||||
var html = GetHtml.PostUtf8(url, data);
|
||||
if (string.IsNullOrEmpty(html) || !html.Contains("\"code\":200"))
|
||||
@@ -1205,7 +1205,7 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
bool isCollectAuthorityUser = true;
|
||||
Get1688ProductForm.Out1688ProductImport(isCollectAuthorityUser, this.statusBar, this.pbLoading, OutProdSaveDbCallBack);
|
||||
}
|
||||
private void bt_import_wx_Click(object sender, EventArgs e)
|
||||
private async void bt_import_wx_Click(object sender, EventArgs e)
|
||||
{
|
||||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Multiselect = true;
|
||||
@@ -1214,44 +1214,58 @@ namespace TemuKJD.WXForms.ProductForms
|
||||
// 显示对话框并获取结果
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var filePathLst = openFileDialog.FileNames.ToList();
|
||||
int successNum = 0;
|
||||
int failedNum = 0;
|
||||
var pddtoWxFactory = new PDDProdFormConverter();
|
||||
|
||||
foreach (var filePath in filePathLst)
|
||||
try
|
||||
{
|
||||
string sourceContent = "";
|
||||
string content = "";
|
||||
string rst = "商品未识别";
|
||||
int day = txt_listing_time.Text.ParseToInt(0) * -1;
|
||||
try
|
||||
{
|
||||
rst = pddtoWxFactory.PddFrontToPddBackConvertFactory(filePath, true, null, true, listingTime: DateTime.Now.AddDays(day));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rst = ex.Message;
|
||||
}
|
||||
if (string.IsNullOrEmpty(rst))
|
||||
successNum++;
|
||||
else
|
||||
failedNum++;
|
||||
btn_import_wx.Enabled = false;
|
||||
var filePathLst = openFileDialog.FileNames.ToList();
|
||||
int successNum = 0;
|
||||
int failedNum = 0;
|
||||
var pddtoWxFactory = new PDDProdFormConverter();
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
foreach (var filePath in filePathLst)
|
||||
{
|
||||
string sourceContent = "";
|
||||
string content = "";
|
||||
string rst = "商品未识别";
|
||||
int day = txt_listing_time.Text.ParseToInt(0) * -1;
|
||||
try
|
||||
{
|
||||
rst = pddtoWxFactory.PddFrontToPddBackConvertFactory(filePath, true, null, true, listingTime: DateTime.Now.AddDays(day));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
rst = ex.Message;
|
||||
}
|
||||
if (string.IsNullOrEmpty(rst))
|
||||
successNum++;
|
||||
else
|
||||
failedNum++;
|
||||
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
|
||||
this.statusBar.lblTaskStatus.Text = "正在导入,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum;
|
||||
}));
|
||||
}
|
||||
});
|
||||
SearchDbProd(1, " 导入完成,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum);
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
this.statusBar.UpdateProgressBar(this.statusBar.pgbTaskProgress.Value + 1);
|
||||
this.statusBar.lblTaskStatus.Text = "正在导入,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum;
|
||||
btn_import_wx.Enabled = true;
|
||||
pbLoading.Visible = false;
|
||||
this.statusBar.lblTaskStatus.Text = "导入完成,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum;
|
||||
BaseMsgForm.ShowInfo("导入完成!");
|
||||
}));
|
||||
}
|
||||
|
||||
SearchDbProd(1, " 导入完成,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum);
|
||||
Invoke(new Action(() =>
|
||||
finally
|
||||
{
|
||||
pbLoading.Visible = false;
|
||||
this.statusBar.lblTaskStatus.Text = "导入完成,尝试导入" + (successNum + failedNum) + ",成功" + successNum + ",失败" + failedNum;
|
||||
BaseMsgForm.ShowInfo("导入完成!");
|
||||
}));
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
btn_import_wx.Enabled = true;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user