mirror of
https://git.oceanpay.cc/danial/kami_itunes_june.git
synced 2025-12-18 22:31:24 +00:00
- Removed DotRas library dependency in RasTools.cs, providing empty implementations for Connect and Disconnect methods. - Updated context menu implementation in ReddemHelp.cs to use ToolStripMenuItem and ContextMenuStrip. - Replaced caching mechanism in SiteHelper.cs with a custom dictionary-based implementation, removing reliance on HttpRuntime.Cache. - Switched from JavaScriptSerializer to Newtonsoft.Json for JSON serialization/deserialization in multiple files (Tools.cs, addMaterial.cs). - Added WebHeaderCollection property to HttpItem.cs for better header management. - Deleted obsolete AssemblyInfo.cs file. - Introduced apple_balance_query.py for querying Apple ID balance via Privacy Center, implementing authentication and balance retrieval logic.
478 lines
16 KiB
C#
478 lines
16 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Drawing;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Net;
|
||
using System.Text;
|
||
using Newtonsoft.Json;
|
||
using System.Windows.Forms;
|
||
using AppleBatch_June.Model;
|
||
using AppleBatch_June.Properties;
|
||
using DotNet.Utilities;
|
||
|
||
namespace AppleBatch_June
|
||
{
|
||
public class FromFileInput : Form
|
||
{
|
||
private CountriesReachableAt reachableAt;
|
||
|
||
private StringBuilder filetemplate = new StringBuilder();
|
||
|
||
private IContainer components;
|
||
|
||
private TextBox txtfilePach;
|
||
|
||
private Label label1;
|
||
|
||
private Button button1;
|
||
|
||
private Label label2;
|
||
|
||
private GroupBox groupBox1;
|
||
|
||
private Label label3;
|
||
|
||
private ComboBox comGuojia;
|
||
|
||
private Button btnDownload;
|
||
|
||
private Label label4;
|
||
|
||
private ComboBox comShengshi;
|
||
|
||
private Label label5;
|
||
|
||
private TextBox txtShengValue;
|
||
|
||
private GroupBox groupBox2;
|
||
|
||
private Button button3;
|
||
|
||
private Label label6;
|
||
|
||
private Label label7;
|
||
|
||
private Label labIdCount;
|
||
|
||
private Label label8;
|
||
|
||
private CheckBox checkBox1;
|
||
|
||
public string path { get; set; }
|
||
|
||
public FromFileInput()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
private void FromFileInput_Load(object sender, EventArgs e)
|
||
{
|
||
comShengshi.Enabled = false;
|
||
btnDownload.Enabled = false;
|
||
string @string = Encoding.UTF8.GetString(Resources.localizedResources);
|
||
reachableAt = JsonConvert.DeserializeObject<CountriesReachableAt>(@string);
|
||
CountriesReachableAt.Smssupportedcountriesreachableat[] smsSupportedCountriesReachableAt = reachableAt.smsSupportedCountriesReachableAt;
|
||
foreach (CountriesReachableAt.Smssupportedcountriesreachableat smssupportedcountriesreachableat in smsSupportedCountriesReachableAt)
|
||
{
|
||
comGuojia.Items.Add(smssupportedcountriesreachableat.name + "-" + smssupportedcountriesreachableat.code);
|
||
}
|
||
}
|
||
|
||
public HttpResult getCitityInfo(string citity)
|
||
{
|
||
btnDownload.Enabled = false;
|
||
HttpHelper httpHelper = new HttpHelper();
|
||
HttpItem httpItem = new HttpItem
|
||
{
|
||
URL = "https://appleid.apple.com/resources/addressFormat/" + citity,
|
||
Method = "GET",
|
||
Timeout = 100000,
|
||
ReadWriteTimeout = 30000,
|
||
IsToLower = false,
|
||
Cookie = " dslang=CN-ZH; geo=CN;",
|
||
UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.157 Safari/537.36",
|
||
Accept = "application/json",
|
||
ContentType = "application/json",
|
||
Referer = "https://appleid.apple.com/account/manage",
|
||
WebProxy = WebRequest.DefaultWebProxy,
|
||
ResultType = ResultType.String
|
||
};
|
||
httpItem.Header.Add("X-Apple-Api-Key", "cbf64fd6843ee630b463f358ea0b707b");
|
||
httpItem.Header.Add("X-Requested-With", "XMLHttpRequest");
|
||
httpItem.Header.Add("Accept-Encoding", "gzip, deflate");
|
||
return httpHelper.GetHtml(httpItem);
|
||
}
|
||
|
||
private void btnDownload_Click(object sender, EventArgs e)
|
||
{
|
||
string text = comGuojia.Text;
|
||
if (string.IsNullOrEmpty(text))
|
||
{
|
||
MessageBox.Show("请先选择国家");
|
||
return;
|
||
}
|
||
string text2 = filetemplate.ToString();
|
||
if (text2.Length == 0)
|
||
{
|
||
MessageBox.Show("请先选择国家");
|
||
return;
|
||
}
|
||
if (checkBox1.Checked)
|
||
{
|
||
text2 += ",卡号,有效期限年,有效期限月,安全码";
|
||
}
|
||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||
saveFileDialog.Filter = "csv文件|*.csv";
|
||
saveFileDialog.FilterIndex = 0;
|
||
saveFileDialog.Title = text.Split('-')[0] + "_账单地址修改模板";
|
||
saveFileDialog.FileName = saveFileDialog.Title;
|
||
if (saveFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
StreamWriter streamWriter = new StreamWriter(saveFileDialog.FileName, append: true, Encoding.UTF8);
|
||
streamWriter.Write(text2);
|
||
streamWriter.Close();
|
||
MessageBox.Show("下载模板完成");
|
||
}
|
||
}
|
||
|
||
private void comGuojia_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
string text = comGuojia.Text;
|
||
if (!string.IsNullOrEmpty(text))
|
||
{
|
||
string citity = text.Split('-')[1];
|
||
HttpResult citityInfo = getCitityInfo(citity);
|
||
if (citityInfo.StatusCode == HttpStatusCode.OK)
|
||
{
|
||
filetemplate.Clear();
|
||
dynamic val = Tools.Todejosn<object>(citityInfo.Html);
|
||
Dictionary<string, object> dictionary = val["fields"];
|
||
filetemplate.Append("账号(必填),密码(必填),答案1(必填),答案2(必填),答案3(必填),姓氏,名字,账单姓氏,账单名字,");
|
||
if (dictionary.ContainsKey("line1"))
|
||
{
|
||
filetemplate.Append("街道地址,");
|
||
}
|
||
if (dictionary.ContainsKey("line2"))
|
||
{
|
||
filetemplate.Append("楼号单元,");
|
||
}
|
||
if (dictionary.ContainsKey("suburb"))
|
||
{
|
||
filetemplate.Append("区,");
|
||
}
|
||
if (dictionary.ContainsKey("county"))
|
||
{
|
||
filetemplate.Append("县,");
|
||
}
|
||
if (dictionary.ContainsKey("city"))
|
||
{
|
||
filetemplate.Append("城市,");
|
||
}
|
||
if (dictionary.ContainsKey("postalCode"))
|
||
{
|
||
filetemplate.Append("邮编,");
|
||
}
|
||
if (dictionary.ContainsKey("taxId"))
|
||
{
|
||
filetemplate.Append("税号,");
|
||
}
|
||
if (!dictionary.ContainsKey("stateProvince"))
|
||
{
|
||
comGuojia.Text = "";
|
||
comShengshi.Enabled = false;
|
||
txtShengValue.Text = "该国家ID无法修改省市";
|
||
}
|
||
else
|
||
{
|
||
filetemplate.Append("省/市,");
|
||
comShengshi.Enabled = true;
|
||
comShengshi.Items.Clear();
|
||
foreach (dynamic item2 in ((dynamic)dictionary["stateProvince"])["values"])
|
||
{
|
||
string item = item2["title"] + "-" + item2["name"];
|
||
comShengshi.Items.Add(item);
|
||
}
|
||
if (comShengshi.Items.Count > 0)
|
||
{
|
||
comShengshi.SelectedIndex = 0;
|
||
}
|
||
}
|
||
if (dictionary.ContainsKey("phoneAreaCode"))
|
||
{
|
||
filetemplate.Append("区号,");
|
||
}
|
||
filetemplate.Append("电话");
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("网络错误");
|
||
}
|
||
}
|
||
btnDownload.Enabled = true;
|
||
}
|
||
|
||
private void comShengshi_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
string text = comShengshi.Text;
|
||
if (!string.IsNullOrEmpty(text))
|
||
{
|
||
string text2 = text.Split('-')[1];
|
||
txtShengValue.Text = text2;
|
||
}
|
||
}
|
||
|
||
private void button1_Click(object sender, EventArgs e)
|
||
{
|
||
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||
openFileDialog.Filter = "csv文件|*.csv";
|
||
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||
{
|
||
string fileName = openFileDialog.FileName;
|
||
txtfilePach.Text = fileName;
|
||
int num = (from c in Tools.readFile(fileName).Split('\n')
|
||
where !string.IsNullOrEmpty(c)
|
||
select c).Count() - 1;
|
||
labIdCount.Text = num.ToString();
|
||
}
|
||
}
|
||
|
||
private void button3_Click(object sender, EventArgs e)
|
||
{
|
||
path = txtfilePach.Text;
|
||
base.DialogResult = DialogResult.OK;
|
||
}
|
||
|
||
private void FromFileInput_DragDrop(object sender, DragEventArgs e)
|
||
{
|
||
string[] array = (string[])e.Data.GetData(DataFormats.FileDrop);
|
||
int num = 0;
|
||
string text;
|
||
while (true)
|
||
{
|
||
if (num < array.Length)
|
||
{
|
||
text = array[num];
|
||
if (Path.GetExtension(text).ToLower() == ".csv")
|
||
{
|
||
break;
|
||
}
|
||
MessageBox.Show("请导入CSV 模板文件");
|
||
num++;
|
||
continue;
|
||
}
|
||
return;
|
||
}
|
||
string url = text;
|
||
txtfilePach.Text = url;
|
||
int num2 = (from c in Tools.readFile(url).Split('\n')
|
||
where !string.IsNullOrEmpty(c)
|
||
select c).Count() - 1;
|
||
labIdCount.Text = num2.ToString();
|
||
}
|
||
|
||
private void FromFileInput_DragEnter(object sender, DragEventArgs e)
|
||
{
|
||
if (e.Data.GetDataPresent(DataFormats.FileDrop))
|
||
{
|
||
e.Effect = DragDropEffects.Copy;
|
||
}
|
||
}
|
||
|
||
protected override void Dispose(bool disposing)
|
||
{
|
||
if (disposing && components != null)
|
||
{
|
||
components.Dispose();
|
||
}
|
||
base.Dispose(disposing);
|
||
}
|
||
|
||
private void InitializeComponent()
|
||
{
|
||
this.txtfilePach = new System.Windows.Forms.TextBox();
|
||
this.label1 = new System.Windows.Forms.Label();
|
||
this.button1 = new System.Windows.Forms.Button();
|
||
this.label2 = new System.Windows.Forms.Label();
|
||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||
this.checkBox1 = new System.Windows.Forms.CheckBox();
|
||
this.label6 = new System.Windows.Forms.Label();
|
||
this.groupBox2 = new System.Windows.Forms.GroupBox();
|
||
this.label4 = new System.Windows.Forms.Label();
|
||
this.txtShengValue = new System.Windows.Forms.TextBox();
|
||
this.comShengshi = new System.Windows.Forms.ComboBox();
|
||
this.label5 = new System.Windows.Forms.Label();
|
||
this.btnDownload = new System.Windows.Forms.Button();
|
||
this.label3 = new System.Windows.Forms.Label();
|
||
this.comGuojia = new System.Windows.Forms.ComboBox();
|
||
this.button3 = new System.Windows.Forms.Button();
|
||
this.label7 = new System.Windows.Forms.Label();
|
||
this.labIdCount = new System.Windows.Forms.Label();
|
||
this.label8 = new System.Windows.Forms.Label();
|
||
this.groupBox1.SuspendLayout();
|
||
this.groupBox2.SuspendLayout();
|
||
base.SuspendLayout();
|
||
this.txtfilePach.Location = new System.Drawing.Point(68, 33);
|
||
this.txtfilePach.Name = "txtfilePach";
|
||
this.txtfilePach.ReadOnly = true;
|
||
this.txtfilePach.Size = new System.Drawing.Size(377, 21);
|
||
this.txtfilePach.TabIndex = 0;
|
||
this.label1.AutoSize = true;
|
||
this.label1.Location = new System.Drawing.Point(4, 37);
|
||
this.label1.Name = "label1";
|
||
this.label1.Size = new System.Drawing.Size(53, 12);
|
||
this.label1.TabIndex = 1;
|
||
this.label1.Text = "文件地址";
|
||
this.button1.Location = new System.Drawing.Point(456, 32);
|
||
this.button1.Name = "button1";
|
||
this.button1.Size = new System.Drawing.Size(75, 23);
|
||
this.button1.TabIndex = 2;
|
||
this.button1.Text = "选择文件";
|
||
this.button1.UseVisualStyleBackColor = true;
|
||
this.button1.Click += new System.EventHandler(button1_Click);
|
||
this.label2.AutoSize = true;
|
||
this.label2.Location = new System.Drawing.Point(66, 11);
|
||
this.label2.Name = "label2";
|
||
this.label2.Size = new System.Drawing.Size(149, 12);
|
||
this.label2.TabIndex = 3;
|
||
this.label2.Text = "请选择或者拖拽文件到此处";
|
||
this.groupBox1.Controls.Add(this.checkBox1);
|
||
this.groupBox1.Controls.Add(this.label6);
|
||
this.groupBox1.Controls.Add(this.groupBox2);
|
||
this.groupBox1.Controls.Add(this.btnDownload);
|
||
this.groupBox1.Controls.Add(this.label3);
|
||
this.groupBox1.Controls.Add(this.comGuojia);
|
||
this.groupBox1.Location = new System.Drawing.Point(21, 120);
|
||
this.groupBox1.Name = "groupBox1";
|
||
this.groupBox1.Size = new System.Drawing.Size(509, 153);
|
||
this.groupBox1.TabIndex = 4;
|
||
this.groupBox1.TabStop = false;
|
||
this.groupBox1.Text = "模板下载------请用 WPS 或者 Excel 打开模板文件";
|
||
this.checkBox1.AutoSize = true;
|
||
this.checkBox1.Location = new System.Drawing.Point(277, 25);
|
||
this.checkBox1.Name = "checkBox1";
|
||
this.checkBox1.Size = new System.Drawing.Size(108, 16);
|
||
this.checkBox1.TabIndex = 9;
|
||
this.checkBox1.Text = "添加借记卡内容";
|
||
this.checkBox1.UseVisualStyleBackColor = true;
|
||
this.label6.AutoSize = true;
|
||
this.label6.Location = new System.Drawing.Point(287, 79);
|
||
this.label6.Name = "label6";
|
||
this.label6.Size = new System.Drawing.Size(149, 60);
|
||
this.label6.TabIndex = 8;
|
||
this.label6.Text = "有省市修改的ID,\r\n\r\n请使用对应省份的填写值,\r\n\r\n否则无法修改成功";
|
||
this.groupBox2.Controls.Add(this.label4);
|
||
this.groupBox2.Controls.Add(this.txtShengValue);
|
||
this.groupBox2.Controls.Add(this.comShengshi);
|
||
this.groupBox2.Controls.Add(this.label5);
|
||
this.groupBox2.Location = new System.Drawing.Point(21, 56);
|
||
this.groupBox2.Name = "groupBox2";
|
||
this.groupBox2.Size = new System.Drawing.Size(251, 85);
|
||
this.groupBox2.TabIndex = 7;
|
||
this.groupBox2.TabStop = false;
|
||
this.groupBox2.Text = "省/市填写值查询";
|
||
this.label4.AutoSize = true;
|
||
this.label4.Location = new System.Drawing.Point(7, 26);
|
||
this.label4.Name = "label4";
|
||
this.label4.Size = new System.Drawing.Size(53, 12);
|
||
this.label4.TabIndex = 3;
|
||
this.label4.Text = "选择省市";
|
||
this.txtShengValue.Location = new System.Drawing.Point(67, 56);
|
||
this.txtShengValue.Name = "txtShengValue";
|
||
this.txtShengValue.ReadOnly = true;
|
||
this.txtShengValue.Size = new System.Drawing.Size(164, 21);
|
||
this.txtShengValue.TabIndex = 6;
|
||
this.comShengshi.FormattingEnabled = true;
|
||
this.comShengshi.Location = new System.Drawing.Point(68, 22);
|
||
this.comShengshi.Name = "comShengshi";
|
||
this.comShengshi.Size = new System.Drawing.Size(163, 20);
|
||
this.comShengshi.TabIndex = 2;
|
||
this.comShengshi.SelectedIndexChanged += new System.EventHandler(comShengshi_SelectedIndexChanged);
|
||
this.label5.AutoSize = true;
|
||
this.label5.Location = new System.Drawing.Point(13, 59);
|
||
this.label5.Name = "label5";
|
||
this.label5.Size = new System.Drawing.Size(41, 12);
|
||
this.label5.TabIndex = 5;
|
||
this.label5.Text = "填写值";
|
||
this.btnDownload.Location = new System.Drawing.Point(391, 20);
|
||
this.btnDownload.Name = "btnDownload";
|
||
this.btnDownload.Size = new System.Drawing.Size(107, 23);
|
||
this.btnDownload.TabIndex = 4;
|
||
this.btnDownload.Text = "下载该国家模板";
|
||
this.btnDownload.UseVisualStyleBackColor = true;
|
||
this.btnDownload.Click += new System.EventHandler(btnDownload_Click);
|
||
this.label3.AutoSize = true;
|
||
this.label3.Location = new System.Drawing.Point(19, 28);
|
||
this.label3.Name = "label3";
|
||
this.label3.Size = new System.Drawing.Size(53, 12);
|
||
this.label3.TabIndex = 1;
|
||
this.label3.Text = "选择国家";
|
||
this.comGuojia.FormattingEnabled = true;
|
||
this.comGuojia.Location = new System.Drawing.Point(78, 23);
|
||
this.comGuojia.Name = "comGuojia";
|
||
this.comGuojia.Size = new System.Drawing.Size(185, 20);
|
||
this.comGuojia.TabIndex = 0;
|
||
this.comGuojia.SelectedIndexChanged += new System.EventHandler(comGuojia_SelectedIndexChanged);
|
||
this.button3.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
|
||
this.button3.ForeColor = System.Drawing.Color.Green;
|
||
this.button3.Location = new System.Drawing.Point(141, 60);
|
||
this.button3.Name = "button3";
|
||
this.button3.Size = new System.Drawing.Size(132, 36);
|
||
this.button3.TabIndex = 5;
|
||
this.button3.Text = "使用该文件导入";
|
||
this.button3.UseVisualStyleBackColor = true;
|
||
this.button3.Click += new System.EventHandler(button3_Click);
|
||
this.label7.AutoSize = true;
|
||
this.label7.Location = new System.Drawing.Point(308, 73);
|
||
this.label7.Name = "label7";
|
||
this.label7.Size = new System.Drawing.Size(77, 12);
|
||
this.label7.TabIndex = 6;
|
||
this.label7.Text = "文件ID数量:";
|
||
this.labIdCount.AutoSize = true;
|
||
this.labIdCount.Location = new System.Drawing.Point(392, 73);
|
||
this.labIdCount.Name = "labIdCount";
|
||
this.labIdCount.Size = new System.Drawing.Size(11, 12);
|
||
this.labIdCount.TabIndex = 7;
|
||
this.labIdCount.Text = "0";
|
||
this.label8.AutoSize = true;
|
||
this.label8.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
|
||
this.label8.ForeColor = System.Drawing.Color.Red;
|
||
this.label8.Location = new System.Drawing.Point(231, 11);
|
||
this.label8.Name = "label8";
|
||
this.label8.Size = new System.Drawing.Size(226, 12);
|
||
this.label8.TabIndex = 9;
|
||
this.label8.Text = "模板内容有值才会修改,留空则不修改";
|
||
this.AllowDrop = true;
|
||
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
|
||
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||
base.ClientSize = new System.Drawing.Size(542, 283);
|
||
base.Controls.Add(this.label8);
|
||
base.Controls.Add(this.labIdCount);
|
||
base.Controls.Add(this.label7);
|
||
base.Controls.Add(this.button3);
|
||
base.Controls.Add(this.groupBox1);
|
||
base.Controls.Add(this.label2);
|
||
base.Controls.Add(this.button1);
|
||
base.Controls.Add(this.label1);
|
||
base.Controls.Add(this.txtfilePach);
|
||
base.MaximizeBox = false;
|
||
base.MinimizeBox = false;
|
||
base.Name = "FromFileInput";
|
||
base.ShowIcon = false;
|
||
base.ShowInTaskbar = false;
|
||
base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||
this.Text = "文件导入";
|
||
base.Load += new System.EventHandler(FromFileInput_Load);
|
||
base.DragDrop += new System.Windows.Forms.DragEventHandler(FromFileInput_DragDrop);
|
||
base.DragEnter += new System.Windows.Forms.DragEventHandler(FromFileInput_DragEnter);
|
||
this.groupBox1.ResumeLayout(false);
|
||
this.groupBox1.PerformLayout();
|
||
this.groupBox2.ResumeLayout(false);
|
||
this.groupBox2.PerformLayout();
|
||
base.ResumeLayout(false);
|
||
base.PerformLayout();
|
||
}
|
||
}
|
||
}
|