gx
This commit is contained in:
1 parent
0a3e5af6a9
commit
c2dcedd238
59 files changed
+2053
-1274
No files matched your search
@@ -1,5 +1,6 @@
|
||||
using AllBase;
|
||||
using AllBase.Extension;
|
||||
using NaiBa.Util.Extension;
|
||||
using AllBase.Helper;
|
||||
using AllBase.Model.Config;
|
||||
using AllBase.Model.DBModel;
|
||||
@@ -20,7 +21,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Work;
|
||||
|
||||
namespace Store.Product.Publish.Steps.Wx;
|
||||
@@ -34,24 +34,24 @@ public sealed class AddRandomImageBorderStep : WxProductPublishStepBase
|
||||
|
||||
protected override Task ExecuteProvider(WXPublishContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
if (selectProd.is_fission_title && chkRandomImgBorder.Checked)
|
||||
if (context.Parameters.SelectProduct.is_fission_title && context.Parameters.IsRandomImageBorder)
|
||||
{
|
||||
// selectProd.isFission
|
||||
int mainCount = 9;
|
||||
int detailCount = 1;
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
mainCount = txtMainBorderImgCount.Text.Trim().ParseToInt();
|
||||
detailCount = txtDetailBorderImgCount.Text.Trim().ParseToInt();
|
||||
mainCount = context.Parameters.MainBorderImageCount;
|
||||
detailCount = context.Parameters.DetailBorderImageCount;
|
||||
}));
|
||||
// api上传图片文件 边框主图
|
||||
if (1 == 1)
|
||||
{
|
||||
if (chkRandomMainImgOrder.Checked)
|
||||
upProdParam.product.info.headImg = upProdParam.product.info.headImg.OrderBy(x => Guid.NewGuid()).Take(100).ToList();
|
||||
for (int n = 0; n < upProdParam.product.info.headImg.Count && n < mainCount; n++)
|
||||
if (context.Parameters.IsRandomMainImageOrder)
|
||||
context.Parameters.ProductParameter.product.info.headImg = context.Parameters.ProductParameter.product.info.headImg.OrderBy(x => Guid.NewGuid()).Take(100).ToList();
|
||||
for (int n = 0; n < context.Parameters.ProductParameter.product.info.headImg.Count && n < mainCount; n++)
|
||||
{
|
||||
var imgUrl = upProdParam.product.info.headImg[n];
|
||||
var imgUrl = context.Parameters.ProductParameter.product.info.headImg[n];
|
||||
try
|
||||
{
|
||||
string errMsg = "";
|
||||
@@ -64,7 +64,7 @@ public sealed class AddRandomImageBorderStep : WxProductPublishStepBase
|
||||
|
||||
var urlImg = BaseClass.BuildWXImgObjString("product/wx_api_upload_image");
|
||||
var upDate = UserLogin.GetSignaturex();
|
||||
upDate += "&token=" + token.accessToken;
|
||||
upDate += "&token=" + context.Parameters.Token.accessToken;
|
||||
//upDate += "&is_file=true";
|
||||
//if (needAddRandomBlock || wantAddRandomBlock)
|
||||
// upDate += "&random_code=true";
|
||||
@@ -73,24 +73,24 @@ public sealed class AddRandomImageBorderStep : WxProductPublishStepBase
|
||||
|
||||
var sTime = DateTime.Now;
|
||||
var apiUpImgFileRst = GetHtml.PostUtf8(urlImg, upDate);
|
||||
if (cell != null)
|
||||
if (context.Progress != null)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
cell.Value = "正在优化主图文件 " + (DateTime.Now - sTime).TotalMilliseconds.ParseToInt();
|
||||
context.Progress.Report("正在优化主图文件 " + (DateTime.Now - sTime).TotalMilliseconds.ParseToInt());
|
||||
}));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5 && apiUpImgFileRst.Contains("access_token expired"); i++)
|
||||
{
|
||||
token.mdyTime = DateTime.Now.AddDays(-100);
|
||||
token = new WxApiBLL().GetRandomWxToken();
|
||||
context.Parameters.Token.mdyTime = DateTime.Now.AddDays(-100);
|
||||
context.Parameters.Token = new WxApiBLL().GetRandomWxToken();
|
||||
apiUpImgFileRst = GetHtml.PostUtf8(urlImg, upDate);
|
||||
}
|
||||
var upImgUrl = BaseRegex.GetStringJson(ref apiUpImgFileRst, "img_url");
|
||||
if (apiUpImgFileRst.Contains("\"errcode\":0") && !string.IsNullOrEmpty(upImgUrl))
|
||||
{
|
||||
upProdParam.product.info.headImg[n] = upImgUrl;
|
||||
context.Parameters.ProductParameter.product.info.headImg[n] = upImgUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -107,11 +107,11 @@ public sealed class AddRandomImageBorderStep : WxProductPublishStepBase
|
||||
// api上传图片文件 边框详情图
|
||||
if (1 == 1)
|
||||
{
|
||||
if (chkRandomDetailImgOrder.Checked)
|
||||
upProdParam.product.info.detail.detailImg = upProdParam.product.info.detail.detailImg.OrderBy(x => Guid.NewGuid()).Take(100).ToList();
|
||||
for (int n = 0; n < upProdParam.product.info.detail.detailImg.Count && n < detailCount; n++)
|
||||
if (context.Parameters.IsRandomDetailImageOrder)
|
||||
context.Parameters.ProductParameter.product.info.detail.detailImg = context.Parameters.ProductParameter.product.info.detail.detailImg.OrderBy(x => Guid.NewGuid()).Take(100).ToList();
|
||||
for (int n = 0; n < context.Parameters.ProductParameter.product.info.detail.detailImg.Count && n < detailCount; n++)
|
||||
{
|
||||
var imgUrl = upProdParam.product.info.detail.detailImg[n];
|
||||
var imgUrl = context.Parameters.ProductParameter.product.info.detail.detailImg[n];
|
||||
try
|
||||
{
|
||||
string errMsg = "";
|
||||
@@ -124,7 +124,7 @@ public sealed class AddRandomImageBorderStep : WxProductPublishStepBase
|
||||
|
||||
var urlImg = BaseClass.BuildWXImgObjString("product/wx_api_upload_image");
|
||||
var upDate = UserLogin.GetSignaturex();
|
||||
upDate += "&token=" + token.accessToken;
|
||||
upDate += "&token=" + context.Parameters.Token.accessToken;
|
||||
//upDate += "&is_file=true";
|
||||
//if (needAddRandomBlock || wantAddRandomBlock)
|
||||
// upDate += "&random_code=true";
|
||||
@@ -133,24 +133,24 @@ public sealed class AddRandomImageBorderStep : WxProductPublishStepBase
|
||||
|
||||
var sTime = DateTime.Now;
|
||||
var apiUpImgFileRst = GetHtml.PostUtf8(urlImg, upDate);
|
||||
if (cell != null)
|
||||
if (context.Progress != null)
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
cell.Value = "正在优化详情图文件 " + (DateTime.Now - sTime).TotalMilliseconds.ParseToInt();
|
||||
context.Progress.Report("正在优化详情图文件 " + (DateTime.Now - sTime).TotalMilliseconds.ParseToInt());
|
||||
}));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 5 && apiUpImgFileRst.Contains("access_token expired"); i++)
|
||||
{
|
||||
token.mdyTime = DateTime.Now.AddDays(-100);
|
||||
token = new WxApiBLL().GetRandomWxToken();
|
||||
context.Parameters.Token.mdyTime = DateTime.Now.AddDays(-100);
|
||||
context.Parameters.Token = new WxApiBLL().GetRandomWxToken();
|
||||
apiUpImgFileRst = GetHtml.PostUtf8(urlImg, upDate);
|
||||
}
|
||||
var upImgUrl = BaseRegex.GetStringJson(ref apiUpImgFileRst, "img_url");
|
||||
if (apiUpImgFileRst.Contains("\"errcode\":0") && !string.IsNullOrEmpty(upImgUrl))
|
||||
{
|
||||
upProdParam.product.info.detail.detailImg[n] = upImgUrl;
|
||||
context.Parameters.ProductParameter.product.info.detail.detailImg[n] = upImgUrl;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -165,5 +165,6 @@ public sealed class AddRandomImageBorderStep : WxProductPublishStepBase
|
||||
}
|
||||
}
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user