商品活动上传逻辑优化 商品添加缓存查看 商品添加支持按类目筛选
This commit is contained in:
1 parent
4fcfb2875a
commit
d01d3bc306
12 files changed
+1136
-136
No files matched your search
@@ -1,4 +1,7 @@
|
||||
using System;
|
||||
using AllBase;
|
||||
using NaiBa.Util;
|
||||
using NaiBa.Util.Extension;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -531,5 +534,85 @@ namespace TemuKJD.Extension
|
||||
};
|
||||
}
|
||||
|
||||
public static void AddImgColumn(this DataGridView dgv, string imgColumn, string imgPathColumn, bool isSetHttpsHttp = true)
|
||||
{
|
||||
dgv.Scroll += (s, e) =>
|
||||
{
|
||||
ShowDgvImg(dgv, null, imgColumn, imgPathColumn, isSetHttpsHttp);
|
||||
};
|
||||
dgv.Resize += (s, e) =>
|
||||
{
|
||||
ShowDgvImg(dgv, null, imgColumn, imgPathColumn, isSetHttpsHttp);
|
||||
};
|
||||
dgv.Sorted += (s, e) =>
|
||||
{
|
||||
ShowDgvImg(dgv, null, imgColumn, imgPathColumn, isSetHttpsHttp);
|
||||
};
|
||||
dgv.RowsAdded += (s, e) =>
|
||||
{
|
||||
ShowDgvImg(dgv, new ConcurrentList<DataGridViewRow> { dgv.Rows[e.RowIndex] }, imgColumn, imgPathColumn, isSetHttpsHttp);
|
||||
};
|
||||
}
|
||||
static Bitmap defaultBitmap = new Bitmap(1,1);
|
||||
static void ShowDgvImg(DataGridView dgv, ConcurrentList<DataGridViewRow> rowLst, string imgColumn, string imgPathColumn, bool isSetHttpsHttp = true)
|
||||
{
|
||||
Task.Run(() =>
|
||||
{
|
||||
if (rowLst == null)
|
||||
{
|
||||
rowLst = new ConcurrentList<DataGridViewRow>();
|
||||
rowLst.AddRange(dgv.Rows.Cast<DataGridViewRow>());
|
||||
}
|
||||
foreach (DataGridViewRow row in rowLst)
|
||||
{
|
||||
if (row.Index > 1 && row.Cells[imgColumn].Displayed == false)
|
||||
{
|
||||
try
|
||||
{
|
||||
dgv.Invoke(new Action(() =>
|
||||
{
|
||||
row.Cells[imgColumn].Value = defaultBitmap;
|
||||
}));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (row.Index >= 0 && row.Cells[imgColumn].Value != null && row.Cells[imgColumn].Value != defaultBitmap)
|
||||
continue;
|
||||
|
||||
Image image = null;
|
||||
if (row.Index >= 0)
|
||||
{
|
||||
string imgUrl = row.Cells[imgPathColumn]?.Value.ParseToString();
|
||||
if (isSetHttpsHttp == true)
|
||||
imgUrl = imgUrl.Replace("https://", "http://");
|
||||
string getImgError = "";
|
||||
if (!string.IsNullOrWhiteSpace(imgUrl))
|
||||
image = GetHtml.GetUrlImg(imgUrl, out getImgError);
|
||||
if (!string.IsNullOrEmpty(getImgError))
|
||||
//BaseMsgForm.ShowError("图片加载失败 " + getImgError);
|
||||
image = TemuKJD.Properties.Resources.errpic;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
dgv.Invoke(new Action(() =>
|
||||
{
|
||||
if (row.Index >= 0)
|
||||
{
|
||||
row.Cells[imgColumn].Value = image;
|
||||
}
|
||||
}));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user