Files
KJD_WebService/TEMUKJD/WXForms/AdminForms/WXAdminQualificationImageForm.cs
T

258 lines
9.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using AllBase;
using AllBase.Model.Param.TemuProductManage;
using AllBase.Model.Result;
using NaiBa.Util.Extension;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using TemuKJD.BLL;
using TemuKJD.Extension;
using TemuKJD.BaseForms;
using Work;
using NaiBa.Util;
using TemuKJD.WXForms.ShopForms;
namespace TemuKJD.WXForms.AdminForms
{
public partial class WXAdminQualificationImageForm : BaseGeneralForm
{
static WXAdminQualificationImageForm inst = null;
public static WXAdminQualificationImageForm Instance
{
get { if (inst == null) inst = new WXAdminQualificationImageForm(); return inst; }
set { inst = value; }
}
public static ConcurrentList<ShopLoginInfo> lstAdminShopInfo { get; set; } = new ConcurrentList<ShopLoginInfo>();
public WXAdminQualificationImageForm()
{
InitializeComponent();
Instance = this;
}
private void AdminShopForm_Load(object sender, EventArgs e)
{
this.ucSplitPage1.PageChange += UcSplitPage1_PageChange;
this.dgvShop.AddSelectorColumn("colSelect");
}
bool firstLoad = true;
private void AdminShopForm_VisibleChanged(object sender, EventArgs e)
{
if (this.Visible == true && firstLoad)
{
firstLoad = false;
this.pbLoading.Visible = true;
SearchImg(this.ucSplitPage1.CurrentPage);
}
}
private void UcSplitPage1_PageChange(object obj)
{
SearchImg(this.ucSplitPage1.CurrentPage);
}
public void SearchImg(int page)
{
List<string> shopIdList = GetCheckedShopIdList();
if (InvokeRequired)
{
Invoke(new Action(() =>
{
this.pbLoading.Visible = true;
this.dgvShop.Rows.Clear();
lstAdminShopInfo.Clear();
}));
}
else
{
this.pbLoading.Visible = true;
this.dgvShop.Rows.Clear();
lstAdminShopInfo.Clear();
}
Task.Run(() =>
{
int pageCount;
decimal seconds = 0;
var list = AdminGetServerQualificationImageLst(out pageCount, out seconds, page, ucSplitPage1.PageSize);
lstAdminShopInfo.AddRange(list);
this.ucSplitPage1.TotalPage = pageCount;
foreach (var shop in lstAdminShopInfo)
{
Invoke(new Action(() =>
{
int rowIndex = this.dgvShop.Rows.Add(
shopIdList.Contains(shop.ShopId + shop.UserName),
shop.LoginName,
shop.ShopId,
shop.ShopAccount,
shop.Notes,
shop.GroupName,
"-",
shop.AddProductRemaining,
"+",
//"±",
shop.Cookies,
shop.UserName,
shop.SubUserName,
shop.UploadAccount,
shop.BuyAccount,
shop.ChatAccount,
"",
"进入",
"检测",
string.IsNullOrWhiteSpace(shop.LoginStatus) ? "未登录" : shop.LoginStatus.Trim(),
string.IsNullOrWhiteSpace(shop.LoginStatus2) ? "国际版未登录" : shop.LoginStatus2.Trim(),
"购买",
"多重登录",
shop.ApiAuthStatus,
shop.BuyApiAuth.ApiAuthStatus,
"导入Cookie",
"复制Cookie",
"上传",
shop.OperateSubSaName,
"编辑",
"删除");
}));
}
Invoke(new Action(() =>
{
this.pbLoading.Visible = false;
this.statusBar.lblTaskStatus.Text = "店铺查询完毕";
#if DEBUG
this.statusBar.lblTaskStatus.Text += ",耗时:" + seconds;
#endif
}));
});
}
private void btnSearch_Click(object sender, EventArgs e)
{
if (this.ucSplitPage1.CurrentPage != 1)
this.ucSplitPage1.CurrentPage = 1;
else
SearchImg(1);
}
private void pnlEmpty_Click(object sender, EventArgs e)
{
this.txtUserName.Text = "";
this.txtLoginName.Text = "";
this.txtNotes.Text = "";
this.txtShopId.Text = "";
this.txtShopName.Text = "";
}
bool IsOperate { get; set; } = false;
private void shopLoginForm_SaveComplete(object obj)
{
SearchImg(this.ucSplitPage1.CurrentPage);
}
private void dgvShop_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex < 0 || e.RowIndex < 0)
return;
string headerText = dgvShop.Columns[e.ColumnIndex].HeaderText;
switch (headerText)
{
case "进入店铺":
//IsOperate = true;
//{
// WXAdminShopLoginForm adminLoginForm = new WXAdminShopLoginForm(shop);
// adminLoginForm.openType = EnumOpenType.manage;
// adminLoginForm.WindowState = FormWindowState.Maximized;
// adminLoginForm.InitUrl = "https://store.weixin.qq.com/shop/home";
// adminLoginForm.Show();
//}
//IsOperate = false;
break;
case "删除":
if (BaseMsgForm.ShowConfirm("确定删除吗?删除后不可恢复!").DialogResult == DialogResult.Cancel)
return;
//if (ShopBLL.AdminDelServerShop(shop))
// SearchImg(this.ucSplitPage1.CurrentPage);
break;
case "更改图片":
IsOperate = true;
{
//UploadProduct(shop);
}
IsOperate = false;
break;
case "":
dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value = !(bool)dgvShop.Rows[e.RowIndex].Cells["colSelect"].Value;
break;
default:
break;
}
}
private List<string> GetCheckedShopIdList()
{
List<string> shopNameList = new List<string>();
for (int i = 0; i < dgvShop.Rows.Count; i++)
{
if (dgvShop.Rows[i].Cells["colSelect"].Value.ParseToBool())
{
string shopName = dgvShop.Rows[i].Cells["colShopId"].Value.ParseToString();
shopName += dgvShop.Rows[i].Cells["colUser"].Value.ParseToString();
shopNameList.Add(shopName);
}
}
return shopNameList;
}
public List<ShopLoginInfo> AdminGetServerQualificationImageLst(out int pageCount, out decimal seconds, int page = 1, int pageSize = 50)
{
List<ShopLoginInfo> list = new List<ShopLoginInfo>();
pageCount = 1;
seconds = 0;
var url = BaseClass.BuildObjString("shop/admin_get_server_qualification_image_list");
var data = UserLogin.GetSignaturex() +
"&page=" + page +
"&page_size=" + pageSize +
"&search_user_name=" + txtUserName.Text.Trim() +
"&search_login_name=" + txtLoginName.Text.Trim() +
"&search_notes=" + txtNotes.Text.Trim() +
"&search_id=" + txtShopId.Text.Trim() +
"&search_name=" + txtShopName.Text.Trim();
if (BaseClass.SaLevel > 1)
data += "&operate_sub_sa_name=" + BaseClass.UserName;
var html = GetHtml.PostUtf8(url, data);
if (string.IsNullOrEmpty(html)
|| !html.Contains("shop_id") || !html.Contains("shop_account") || !html.Contains("login_pass"))
{
return list;
}
int count = BaseRegex.GetIntJson(ref html, "count");
pageCount = Math.Ceiling(1.0 * count / pageSize).ParseToInt();
pageCount = Math.Max(pageCount, 1);
seconds = BaseRegex.GetDecimalJson(ref html, "seconds");
return ShopBLL.DeserializationShop(html);
}
private void dgvShop_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
}
}
}