146 lines
5.7 KiB
C#
146 lines
5.7 KiB
C#
using AllBase;
|
|
using AllBase.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
using Work;
|
|
using Work.BaseForms;
|
|
|
|
namespace _29WxOrder.ToolForms
|
|
{
|
|
public partial class ImportPddMultiBuyerForm : BaseGeneralForm
|
|
{
|
|
List<string> strList = new List<string>();
|
|
List<PddMultiBuyerInfo> pddMultiBuyerList = new List<PddMultiBuyerInfo>();
|
|
|
|
public ImportPddMultiBuyerForm()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void pnlOpenFile_Click(object sender, EventArgs e)
|
|
{
|
|
strList.Clear();
|
|
strList = OpenFile();
|
|
pddMultiBuyerList.Clear();
|
|
foreach (string shops in strList)
|
|
{
|
|
try
|
|
{
|
|
string[] strlist = System.Text.RegularExpressions.Regex.Split(shops, "----", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
|
pddMultiBuyerList.Add(new PddMultiBuyerInfo() { pdd_user_id = strlist[0], cookies = strlist[1], times = Convert.ToInt32(strlist[2]) });
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
}
|
|
DgvCookiesList.AutoGenerateColumns = false;
|
|
DgvCookiesList.DataSource = pddMultiBuyerList;
|
|
}
|
|
|
|
public List<string> OpenFile()
|
|
{
|
|
List<string> txt = new List<string>();
|
|
System.Windows.Forms.OpenFileDialog openFile = new System.Windows.Forms.OpenFileDialog();
|
|
openFile.Filter = "文本文件(*.txt)|*.txt|(*.rtf)|*.rtf";
|
|
if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
{
|
|
using (StreamReader sr = new StreamReader(openFile.FileName, Encoding.Default))
|
|
{
|
|
int lineCount = 0;
|
|
while (sr.Peek() > 0)
|
|
{
|
|
lineCount++;
|
|
string temp = sr.ReadLine();
|
|
|
|
string[] strlist = System.Text.RegularExpressions.Regex.Split(temp, "----", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
|
|
int strcount = strlist.Count();
|
|
string cookies = "";
|
|
if (strcount == 1)
|
|
{
|
|
cookies = strlist[0];
|
|
}
|
|
else
|
|
{
|
|
cookies = strlist[1];
|
|
}
|
|
bool ontimes = false;
|
|
if (strcount == 2 && cookies.Length <= 2)
|
|
{
|
|
ontimes = true;
|
|
cookies = strlist[0];
|
|
}
|
|
string datahtml = GetPostTaobaoHtml.UploadTaobaoPost("https://yangkeduo.com/proxy/api/api/apollo/v3/user/active",
|
|
"https://yangkeduo.com", true, "", true, "PDDAccessToken=" + cookies + ";");
|
|
string uid = "";
|
|
if (datahtml.Contains("\"uid\":"))
|
|
{
|
|
uid = AllBase.BaseRegex.GetStringJson(ref datahtml, "uid");
|
|
}
|
|
if (!string.IsNullOrEmpty(uid))
|
|
{
|
|
if (strcount == 1)
|
|
{
|
|
temp = uid + "----" + temp + "----" + nudMultiTimes.Text;
|
|
}
|
|
else if (strcount == 2 && ontimes)//cookie+次数
|
|
{
|
|
temp = uid + "----" + temp;
|
|
}
|
|
else if (strcount == 2)//编号+cookie
|
|
{
|
|
temp = temp + "----" + nudMultiTimes.Text;
|
|
}
|
|
txt.Add(temp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return txt;
|
|
}
|
|
|
|
private void DgvCookiesList_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void pnlSaveImport_Click(object sender, EventArgs e)
|
|
{
|
|
pnlSaveImport.Enabled = false;
|
|
Task.Run(() =>
|
|
{
|
|
string datajson = Newtonsoft.Json.JsonConvert.SerializeObject(pddMultiBuyerList);
|
|
//string html = AllBase.GetHtml.PostUtf8(ViewModel.BaseWindows.BaseClass.ServerApiUrl + "/?obj=" + ViewModel.BaseWindows.BaseClass.routeInUse + "/pdd_user_cookies&act=add", ViewModel.BaseWindows.BaseClass.GetSignaturex("", "") + "¶ms=" + ViewModel.BaseWindows.HttpHelper.UrlEncodeUtf8(datajson));
|
|
string url = BaseClass.Build29WxObjString("pdd_user_cookies&act=add");
|
|
string data = UserLogin.GetSignaturex() + "¶ms=" + GetHtml.UrlEncodeUtf8(datajson);
|
|
string html = GetHtml.PostUtf8(url, data);
|
|
Invoke(new Action(() =>
|
|
{
|
|
if (html.Contains("\"code\":200"))
|
|
{
|
|
BaseMsgForm.ShowInfo("保存导入成功", "提示");
|
|
|
|
pddMultiBuyerList.Clear();
|
|
DgvCookiesList.DataSource = pddMultiBuyerList;
|
|
pnlSaveImport.Enabled = true;
|
|
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
BaseMsgForm.ShowError("保存导入失败,请重试", "错误");
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
}
|
|
}
|