Files
kami_itunes_june/AppleBatch_June.Forms/FromCreateFamily.cs
2024-07-22 00:43:14 +08:00

545 lines
20 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using AppleBatch_June.ExecuteTasks;
using AppleBatch_June.Model;
using AppleBatch_June.Views;
namespace AppleBatch_June.Forms
{
public class FromCreateFamily : BaseForm
{
private IContainer components;
private GroupBox groupBox9;
private TextBox textBox2;
private CheckBox ckCreateFamilyVpn;
private Label labCreateFamilyInter;
private Label label10;
private Label label13;
private GroupBox groupBox10;
private Label labCreateFamilyCount;
private Label label16;
private Button btnLiteClre;
private Button btnCreateFamilyQuery;
private Button btnCreateFamilyInput;
private Button btnCreateFamilyExper;
private Button btnCreateFamilyStart;
private GroupBox groupBox12;
private DoubleBufferListView listCreateFamily;
private ColumnHeader columnHeader8;
private ColumnHeader columnHeader9;
private ColumnHeader columnHeader10;
private ColumnHeader columnHeader2;
private ColumnHeader columnHeader11;
private ColumnHeader columnHeader1;
private ColumnHeader columnHeader14;
public FromCreateFamily()
: base("开通家庭共享", CreateFamilyTask.Instance)
{
InitializeComponent();
}
private void btnCreateFamilyInput_Click(object sender, EventArgs e)
{
FromInputAcount fromInputAcount = new FromInputAcount();
fromInputAcount.tipMssage = textBox2.Text;
fromInputAcount.isOpenSysVpn = ckCreateFamilyVpn.Checked;
if (fromInputAcount.ShowDialog() == DialogResult.OK)
{
List<AppleAcount> list = AppleUtlis.accountInput(fromInputAcount.StrInput);
int num = 0;
base.listData.ListViewItemSorter = new ListViewItemComparer(0, 1);
base.listData.Sort();
if (base.listData.Items.Count > 0 && int.TryParse(base.listData.Items[base.listData.Items.Count - 1].SubItems[0].Text, out var result))
{
num = result;
}
foreach (AppleAcount item in list)
{
num++;
ListViewItem listViewItem = new ListViewItem(num.ToString());
listViewItem.UseItemStyleForSubItems = false;
listViewItem.SubItems.Add(item.appleId);
listViewItem.SubItems.Add(item.applePwd);
if (item.overflow.Split('-').Length == 2)
{
listViewItem.SubItems.Add(item.overflow.Split('-')[0].Trim());
listViewItem.SubItems.Add(item.overflow.Split('-')[1].Trim());
}
else
{
if (item.overflow.Split('-').Length <= 2 || !string.IsNullOrEmpty(item.appleQt1))
{
try
{
string obj = item.sourceInputData.Substring(item.sourceInputData.IndexOf(item.appleId) + item.appleId.Length).TrimStart('-');
List<AppleAcount> list2 = AppleUtlis.accountInput(obj.Substring(obj.IndexOf(item.applePwd) + item.applePwd.Length).TrimStart('-'));
if (list2.Count == 1)
{
listViewItem.SubItems.Add(list2[0].appleId.Trim());
listViewItem.SubItems.Add(list2[0].applePwd.Trim());
goto IL_02cb;
}
}
catch (Exception)
{
}
continue;
}
try
{
int num2 = item.overflow.LastIndexOf('-');
string text = item.overflow.Substring(0, num2);
string text2 = item.overflow.Substring(num2 + 1);
listViewItem.SubItems.Add(text);
listViewItem.SubItems.Add(text2);
}
catch (Exception)
{
continue;
}
}
goto IL_02cb;
IL_02cb:
listViewItem.SubItems.Add("-");
listViewItem.SubItems.Add("-");
base.listData.Items.Add(listViewItem);
}
}
base.labCout.Text = string.Concat(base.listData.Items.Count);
}
private void FromCreateFamily_Load(object sender, EventArgs e)
{
base.listData = listCreateFamily;
base.labCout = labCreateFamilyCount;
base.startBtn = btnCreateFamilyStart;
labCreateFamilyInter.Text = AppSysConfig.getTypeById(32).consNum.ToString();
ckCreateFamilyVpn.Checked = ((ConfigUtlis.getConfigValue("ckCreateFamilyVpn") == "True") ? true : false);
InitLv(base.listData);
BindMenuStrip(addTwoFactor: true);
}
private void btnCreateFamilyStart_Click(object sender, EventArgs e)
{
if (!CreateFamilyTask.Instance.isRun && !CreateFamilyTask.Instance.TaskIsRun)
{
List<AppleAcount> lvItems = (from ListViewItem c in base.listData.Items
where c.SubItems[5].Text == "-"
select new AppleAcount
{
appleId = c.SubItems[1].Text,
applePwd = c.SubItems[2].Text,
newAppleId = c.SubItems[3].Text,
newApplePopPwd = c.SubItems[4].Text
}).ToList();
RearTaskRun(lvItems);
return;
}
CreateFamilyTask.Instance.Stop();
if (!base.IsDisposed)
{
Invoke((Action)delegate
{
base.startBtn.Text = "正在停止";
base.startBtn.ForeColor = Color.Red;
});
}
}
private void RearTaskRun(List<AppleAcount> lvItems)
{
int id = 32;
int count = lvItems.Count;
if (AppSysConfig.integral < count * AppSysConfig.getTypeById(32).consNum)
{
MessageBox.Show("账号点数不足 , 执行账号数量:" + count + " ,至少需要 " + count * AppSysConfig.getTypeById(id).consNum + " 点数。");
}
else
{
ConfigUtlis.saveConfigKey("ckCreateFamilyVpn", ckCreateFamilyVpn.Checked.ToString());
CreateFamilyTask.Instance.ExecuteCreateFamily(2, ckCreateFamilyVpn.Checked, lvItems, base.startAct, base.endTakAct, sucessAct, _action);
}
}
public void sucessAct(string AppleId)
{
UpdataUi(delegate
{
ListViewItem listViewItem = (from ListViewItem c in base.listData.Items
where c.SubItems[1].Text == AppleId
select c).FirstOrDefault();
if (listViewItem != null)
{
SqliteHelper.ExecuteInsert("itunes_db", new Dictionary<string, string>
{
{ "type", "createFamily" },
{
"addTime",
Tools.GenerateTimeStamp().ToString()
},
{
"value1",
listViewItem.SubItems[1].Text
},
{
"value2",
listViewItem.SubItems[2].Text
},
{
"value3",
listViewItem.SubItems[3].Text
},
{
"value4",
listViewItem.SubItems[4].Text
},
{
"value5",
listViewItem.SubItems[5].Text
},
{
"value6",
listViewItem.SubItems[6].Text
}
});
}
});
}
public void _action(string key, DisplyType type, string reust)
{
UpdataUi(delegate
{
IEnumerable<ListViewItem> enumerable = from ListViewItem c in base.listData.Items
where c.SubItems[1].Text == key
select c;
Font font = new Font(Font, FontStyle.Bold);
foreach (ListViewItem item in enumerable)
{
switch (type)
{
case DisplyType.forbidden:
item.SubItems[5].Text = reust;
item.SubItems[5].Font = font;
item.SubItems[5].ForeColor = Color.Green;
break;
case DisplyType.xinxi:
item.SubItems[6].Text = reust;
break;
case DisplyType.error:
item.SubItems[5].Text = reust;
item.SubItems[5].Font = font;
item.SubItems[5].ForeColor = Color.Red;
break;
case DisplyType.chongzhi:
item.SubItems[5].Text = reust;
item.SubItems[5].ForeColor = Color.Black;
break;
}
}
});
}
private void btnLiteClre_Click(object sender, EventArgs e)
{
if (MessageBox.Show("确认删除列表数据吗", "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
{
base.listData.Items.Clear();
}
base.labCout.Text = string.Concat(base.listData.Items.Count);
}
private void btnCreateFamilyExper_Click(object sender, EventArgs e)
{
ExperList(base.listData);
}
public override void ReExecute_Click(object sender, EventArgs e)
{
if (CreateFamilyTask.Instance.TaskIsRun)
{
MessageBox.Show("请先停止");
return;
}
List<AppleAcount> list = new List<AppleAcount>();
foreach (ListViewItem selectedItem in base.listData.SelectedItems)
{
list.Add(new AppleAcount
{
appleId = selectedItem.SubItems[1].Text,
applePwd = selectedItem.SubItems[2].Text,
newAppleId = selectedItem.SubItems[3].Text,
newApplePopPwd = selectedItem.SubItems[4].Text
});
}
RearTaskRun(list);
}
public override void TwoFactorItem_over_Click(string reust)
{
List<AppleAcount> list = new List<AppleAcount>();
foreach (ListViewItem selectedItem in base.listData.SelectedItems)
{
list.Add(new AppleAcount
{
appleId = selectedItem.SubItems[1].Text,
applePwd = selectedItem.SubItems[2].Text + reust,
newAppleId = selectedItem.SubItems[3].Text,
newApplePopPwd = selectedItem.SubItems[4].Text
});
}
RearTaskRun(list);
}
private void btnCreateFamilyQuery_Click(object sender, EventArgs e)
{
FromDBDataQuery fromDBDataQuery = new FromDBDataQuery();
fromDBDataQuery.sqlTitle = new Dictionary<string, string>
{
{ "value1", "账号|180" },
{ "value2", "密码|100" },
{ "value3", "付款账号|180" },
{ "value4", "付款密码|100" },
{ "value5", "状态|100" },
{ "value6", "信息|150" }
};
fromDBDataQuery.type = "createFamily";
fromDBDataQuery.typeName = "开通家庭共享记录";
fromDBDataQuery.Show();
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.groupBox9 = new System.Windows.Forms.GroupBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.ckCreateFamilyVpn = new System.Windows.Forms.CheckBox();
this.labCreateFamilyInter = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label13 = new System.Windows.Forms.Label();
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.labCreateFamilyCount = new System.Windows.Forms.Label();
this.label16 = new System.Windows.Forms.Label();
this.btnLiteClre = new System.Windows.Forms.Button();
this.btnCreateFamilyQuery = new System.Windows.Forms.Button();
this.btnCreateFamilyInput = new System.Windows.Forms.Button();
this.btnCreateFamilyExper = new System.Windows.Forms.Button();
this.btnCreateFamilyStart = new System.Windows.Forms.Button();
this.groupBox12 = new System.Windows.Forms.GroupBox();
this.listCreateFamily = new AppleBatch_June.Views.DoubleBufferListView();
this.columnHeader8 = new System.Windows.Forms.ColumnHeader();
this.columnHeader9 = new System.Windows.Forms.ColumnHeader();
this.columnHeader10 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.columnHeader11 = new System.Windows.Forms.ColumnHeader();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader14 = new System.Windows.Forms.ColumnHeader();
this.groupBox9.SuspendLayout();
this.groupBox10.SuspendLayout();
this.groupBox12.SuspendLayout();
base.SuspendLayout();
this.groupBox9.Controls.Add(this.textBox2);
this.groupBox9.Controls.Add(this.ckCreateFamilyVpn);
this.groupBox9.Controls.Add(this.labCreateFamilyInter);
this.groupBox9.Controls.Add(this.label10);
this.groupBox9.Controls.Add(this.label13);
this.groupBox9.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.groupBox9.Location = new System.Drawing.Point(455, 12);
this.groupBox9.Name = "groupBox9";
this.groupBox9.Size = new System.Drawing.Size(510, 126);
this.groupBox9.TabIndex = 17;
this.groupBox9.TabStop = false;
this.groupBox9.Text = "开通家庭共享 功能说明";
this.textBox2.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.textBox2.Location = new System.Drawing.Point(150, 80);
this.textBox2.Name = "textBox2";
this.textBox2.ReadOnly = true;
this.textBox2.Size = new System.Drawing.Size(324, 23);
this.textBox2.TabIndex = 11;
this.textBox2.Text = "xxx@xx.com----密码--付款AppleID账号--付款密码";
this.ckCreateFamilyVpn.AutoSize = true;
this.ckCreateFamilyVpn.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.ckCreateFamilyVpn.ForeColor = System.Drawing.Color.Red;
this.ckCreateFamilyVpn.Location = new System.Drawing.Point(18, 84);
this.ckCreateFamilyVpn.Name = "ckCreateFamilyVpn";
this.ckCreateFamilyVpn.Size = new System.Drawing.Size(111, 21);
this.ckCreateFamilyVpn.TabIndex = 10;
this.ckCreateFamilyVpn.Text = "使用随机IP代理";
this.ckCreateFamilyVpn.UseVisualStyleBackColor = true;
this.labCreateFamilyInter.AutoSize = true;
this.labCreateFamilyInter.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.labCreateFamilyInter.ForeColor = System.Drawing.Color.Crimson;
this.labCreateFamilyInter.Location = new System.Drawing.Point(103, 60);
this.labCreateFamilyInter.Name = "labCreateFamilyInter";
this.labCreateFamilyInter.Size = new System.Drawing.Size(18, 19);
this.labCreateFamilyInter.TabIndex = 2;
this.labCreateFamilyInter.Text = "0";
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(15, 62);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(92, 17);
this.label10.TabIndex = 1;
this.label10.Text = "查询消耗点数:";
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(4, 31);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(500, 17);
this.label13.TabIndex = 0;
this.label13.Text = "开通家庭共享需要主账号绑定付款方式或者拥有付款方式的账号,付款账号可以是组织者账号\r\n";
this.groupBox10.Controls.Add(this.labCreateFamilyCount);
this.groupBox10.Controls.Add(this.label16);
this.groupBox10.Controls.Add(this.btnLiteClre);
this.groupBox10.Controls.Add(this.btnCreateFamilyQuery);
this.groupBox10.Controls.Add(this.btnCreateFamilyInput);
this.groupBox10.Controls.Add(this.btnCreateFamilyExper);
this.groupBox10.Controls.Add(this.btnCreateFamilyStart);
this.groupBox10.Location = new System.Drawing.Point(12, 12);
this.groupBox10.Name = "groupBox10";
this.groupBox10.Size = new System.Drawing.Size(437, 126);
this.groupBox10.TabIndex = 16;
this.groupBox10.TabStop = false;
this.groupBox10.Text = "操作";
this.labCreateFamilyCount.AutoSize = true;
this.labCreateFamilyCount.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.labCreateFamilyCount.ForeColor = System.Drawing.Color.OrangeRed;
this.labCreateFamilyCount.Location = new System.Drawing.Point(282, 15);
this.labCreateFamilyCount.Name = "labCreateFamilyCount";
this.labCreateFamilyCount.Size = new System.Drawing.Size(15, 17);
this.labCreateFamilyCount.TabIndex = 7;
this.labCreateFamilyCount.Text = "0";
this.label16.AutoSize = true;
this.label16.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.label16.Location = new System.Drawing.Point(179, 16);
this.label16.Name = "label16";
this.label16.Size = new System.Drawing.Size(95, 17);
this.label16.TabIndex = 6;
this.label16.Text = "列表中账号数量:";
this.btnLiteClre.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.btnLiteClre.Location = new System.Drawing.Point(325, 75);
this.btnLiteClre.Name = "btnLiteClre";
this.btnLiteClre.Size = new System.Drawing.Size(96, 23);
this.btnLiteClre.TabIndex = 5;
this.btnLiteClre.Text = "清空账号列表";
this.btnLiteClre.UseVisualStyleBackColor = true;
this.btnLiteClre.Click += new System.EventHandler(btnLiteClre_Click);
this.btnCreateFamilyQuery.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.btnCreateFamilyQuery.Location = new System.Drawing.Point(179, 42);
this.btnCreateFamilyQuery.Name = "btnCreateFamilyQuery";
this.btnCreateFamilyQuery.Size = new System.Drawing.Size(140, 23);
this.btnCreateFamilyQuery.TabIndex = 4;
this.btnCreateFamilyQuery.Text = "开通家庭共享记录";
this.btnCreateFamilyQuery.UseVisualStyleBackColor = true;
this.btnCreateFamilyQuery.Click += new System.EventHandler(btnCreateFamilyQuery_Click);
this.btnCreateFamilyInput.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.btnCreateFamilyInput.Location = new System.Drawing.Point(179, 76);
this.btnCreateFamilyInput.Name = "btnCreateFamilyInput";
this.btnCreateFamilyInput.Size = new System.Drawing.Size(140, 23);
this.btnCreateFamilyInput.TabIndex = 3;
this.btnCreateFamilyInput.Text = "账号输入";
this.btnCreateFamilyInput.UseVisualStyleBackColor = true;
this.btnCreateFamilyInput.Click += new System.EventHandler(btnCreateFamilyInput_Click);
this.btnCreateFamilyExper.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.btnCreateFamilyExper.Location = new System.Drawing.Point(325, 42);
this.btnCreateFamilyExper.Name = "btnCreateFamilyExper";
this.btnCreateFamilyExper.Size = new System.Drawing.Size(96, 23);
this.btnCreateFamilyExper.TabIndex = 2;
this.btnCreateFamilyExper.Text = "导出账号";
this.btnCreateFamilyExper.UseVisualStyleBackColor = true;
this.btnCreateFamilyExper.Click += new System.EventHandler(btnCreateFamilyExper_Click);
this.btnCreateFamilyStart.Font = new System.Drawing.Font("微软雅黑", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
this.btnCreateFamilyStart.ForeColor = System.Drawing.Color.Green;
this.btnCreateFamilyStart.Location = new System.Drawing.Point(18, 33);
this.btnCreateFamilyStart.Name = "btnCreateFamilyStart";
this.btnCreateFamilyStart.Size = new System.Drawing.Size(110, 65);
this.btnCreateFamilyStart.TabIndex = 1;
this.btnCreateFamilyStart.Text = "开始执行";
this.btnCreateFamilyStart.UseVisualStyleBackColor = true;
this.btnCreateFamilyStart.Click += new System.EventHandler(btnCreateFamilyStart_Click);
this.groupBox12.Controls.Add(this.listCreateFamily);
this.groupBox12.Location = new System.Drawing.Point(9, 144);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(956, 408);
this.groupBox12.TabIndex = 15;
this.groupBox12.TabStop = false;
this.groupBox12.Text = "iCloud账号列表";
this.listCreateFamily.Columns.AddRange(new System.Windows.Forms.ColumnHeader[7] { this.columnHeader8, this.columnHeader9, this.columnHeader10, this.columnHeader2, this.columnHeader11, this.columnHeader1, this.columnHeader14 });
this.listCreateFamily.Dock = System.Windows.Forms.DockStyle.Fill;
this.listCreateFamily.Font = new System.Drawing.Font("微软雅黑", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
this.listCreateFamily.FullRowSelect = true;
this.listCreateFamily.HideSelection = false;
this.listCreateFamily.Location = new System.Drawing.Point(3, 17);
this.listCreateFamily.Name = "listCreateFamily";
this.listCreateFamily.Size = new System.Drawing.Size(950, 388);
this.listCreateFamily.TabIndex = 0;
this.listCreateFamily.UseCompatibleStateImageBehavior = false;
this.listCreateFamily.View = System.Windows.Forms.View.Details;
this.columnHeader8.Text = "序号";
this.columnHeader9.Text = "账号";
this.columnHeader9.Width = 150;
this.columnHeader10.Text = "密码";
this.columnHeader10.Width = 100;
this.columnHeader2.Text = "付款账号";
this.columnHeader2.Width = 150;
this.columnHeader11.Text = "付款密码";
this.columnHeader11.Width = 100;
this.columnHeader1.Text = "状态";
this.columnHeader1.Width = 80;
this.columnHeader14.Text = "信息";
this.columnHeader14.Width = 250;
base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
base.ClientSize = new System.Drawing.Size(975, 565);
base.Controls.Add(this.groupBox9);
base.Controls.Add(this.groupBox10);
base.Controls.Add(this.groupBox12);
base.MaximizeBox = false;
base.Name = "FromCreateFamily";
base.ShowIcon = false;
this.Text = "开通家庭共享";
base.Load += new System.EventHandler(FromCreateFamily_Load);
this.groupBox9.ResumeLayout(false);
this.groupBox9.PerformLayout();
this.groupBox10.ResumeLayout(false);
this.groupBox10.PerformLayout();
this.groupBox12.ResumeLayout(false);
base.ResumeLayout(false);
}
}
}