diff --git a/BackupTool.csproj b/BackupTool.csproj
index b235068..e334aa4 100644
--- a/BackupTool.csproj
+++ b/BackupTool.csproj
@@ -125,9 +125,43 @@
packages\SharpZipLib.1.2.0\lib\net45\ICSharpCode.SharpZipLib.dll
+
+ packages\Microsoft.Graph.3.8.0\lib\net461\Microsoft.Graph.dll
+
+
+ packages\Microsoft.Graph.Core.1.20.1\lib\net45\Microsoft.Graph.Core.dll
+
+
+ packages\Microsoft.Identity.Client.4.16.1\lib\net45\Microsoft.Identity.Client.dll
+
+
+ packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll
+
+
+ packages\System.Buffers.4.4.0\lib\netstandard2.0\System.Buffers.dll
+
+
+ packages\System.Diagnostics.DiagnosticSource.4.6.0\lib\net46\System.Diagnostics.DiagnosticSource.dll
+
+
+
+ packages\System.Memory.4.5.3\lib\netstandard2.0\System.Memory.dll
+
+
+
+ packages\System.Numerics.Vectors.4.4.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ packages\System.Runtime.CompilerServices.Unsafe.4.5.2\lib\netstandard2.0\System.Runtime.CompilerServices.Unsafe.dll
+
+
+ packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll
+ True
+ True
+
@@ -157,6 +191,12 @@
Form3.cs
+
+ Form
+
+
+ Form4.cs
+
@@ -168,6 +208,9 @@
Form3.cs
+
+ Form4.cs
+
ResXFileCodeGenerator
Resources.Designer.cs
@@ -178,6 +221,7 @@
Resources.resx
True
+
@@ -194,6 +238,7 @@
+
diff --git a/Form1.Designer.cs b/Form1.Designer.cs
index c9aa39d..5959a0b 100644
--- a/Form1.Designer.cs
+++ b/Form1.Designer.cs
@@ -45,6 +45,8 @@ private void InitializeComponent()
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
+ this.工具TToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.oneDrive备份BToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.工具ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1.SuspendLayout();
@@ -108,7 +110,7 @@ private void InitializeComponent()
this.button1.TabIndex = 3;
this.button1.Text = "...";
this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
+ this.button1.Click += new System.EventHandler(this.Button1_Click);
//
// textBox1
//
@@ -217,6 +219,7 @@ private void InitializeComponent()
this.menuStrip1.GripMargin = new System.Windows.Forms.Padding(2, 2, 0, 2);
this.menuStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.工具TToolStripMenuItem,
this.工具ToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
@@ -224,6 +227,21 @@ private void InitializeComponent()
this.menuStrip1.TabIndex = 5;
this.menuStrip1.Text = "menuStrip1";
//
+ // 工具TToolStripMenuItem
+ //
+ this.工具TToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.oneDrive备份BToolStripMenuItem});
+ this.工具TToolStripMenuItem.Name = "工具TToolStripMenuItem";
+ this.工具TToolStripMenuItem.Size = new System.Drawing.Size(84, 28);
+ this.工具TToolStripMenuItem.Text = "工具(&T)";
+ //
+ // oneDrive备份BToolStripMenuItem
+ //
+ this.oneDrive备份BToolStripMenuItem.Name = "oneDrive备份BToolStripMenuItem";
+ this.oneDrive备份BToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
+ this.oneDrive备份BToolStripMenuItem.Text = "OneDrive 备份(&B)";
+ this.oneDrive备份BToolStripMenuItem.Click += new System.EventHandler(this.oneDrive备份BToolStripMenuItem_Click);
+ //
// 工具ToolStripMenuItem
//
this.工具ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
@@ -236,7 +254,7 @@ private void InitializeComponent()
// toolStripMenuItem2
//
this.toolStripMenuItem2.Name = "toolStripMenuItem2";
- this.toolStripMenuItem2.Size = new System.Drawing.Size(183, 34);
+ this.toolStripMenuItem2.Size = new System.Drawing.Size(270, 34);
this.toolStripMenuItem2.Text = "关于(&A)...";
this.toolStripMenuItem2.Click += new System.EventHandler(this.toolStripMenuItem2_Click);
//
@@ -288,6 +306,8 @@ private void InitializeComponent()
private System.Windows.Forms.MenuStrip menuStrip1;
private System.Windows.Forms.ToolStripMenuItem 工具ToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
+ private System.Windows.Forms.ToolStripMenuItem 工具TToolStripMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem oneDrive备份BToolStripMenuItem;
}
}
diff --git a/Form1.cs b/Form1.cs
index 347cc18..1a14f0e 100644
--- a/Form1.cs
+++ b/Form1.cs
@@ -84,7 +84,7 @@ private void Bw_DoWork(object sender, DoWorkEventArgs e)
throw new NotImplementedException();
}
- private void button1_Click(object sender, EventArgs e)
+ private void Button1_Click(object sender, EventArgs e)
{
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.Description = "请选择国服游戏目录:";
@@ -360,5 +360,10 @@ private void 工具ToolStripMenuItem_Click(object sender, EventArgs e)
}
+ private void oneDrive备份BToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ Form about = new Form4();
+ about.Show();
+ }
}
}
diff --git a/Form4.Designer.cs b/Form4.Designer.cs
new file mode 100644
index 0000000..bd7e5fc
--- /dev/null
+++ b/Form4.Designer.cs
@@ -0,0 +1,122 @@
+namespace FFXIVBackupTool
+{
+ partial class Form4
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.pictureBox1 = new System.Windows.Forms.PictureBox();
+ this.label1 = new System.Windows.Forms.Label();
+ this.button2 = new System.Windows.Forms.Button();
+ this.statusStrip1 = new System.Windows.Forms.StatusStrip();
+ this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
+ this.statusStrip1.SuspendLayout();
+ this.SuspendLayout();
+ //
+ // pictureBox1
+ //
+ this.pictureBox1.Image = global::FFXIVBackupTool.Properties.Resources.ms_symbollockup_signin_dark;
+ this.pictureBox1.Location = new System.Drawing.Point(178, 83);
+ this.pictureBox1.Name = "pictureBox1";
+ this.pictureBox1.Size = new System.Drawing.Size(215, 41);
+ this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
+ this.pictureBox1.TabIndex = 0;
+ this.pictureBox1.TabStop = false;
+ this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click);
+ this.pictureBox1.MouseLeave += new System.EventHandler(this.pictureBox1_MouseLeave);
+ this.pictureBox1.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBox1_MouseMove);
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(74, 40);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(422, 18);
+ this.label1.TabIndex = 1;
+ this.label1.Text = "请点击下方图标,使用微软账号登录并授权本应用。";
+ //
+ // button2
+ //
+ this.button2.Location = new System.Drawing.Point(222, 142);
+ this.button2.Name = "button2";
+ this.button2.Size = new System.Drawing.Size(126, 41);
+ this.button2.TabIndex = 7;
+ this.button2.Text = "开始备份(&B)";
+ this.button2.UseVisualStyleBackColor = true;
+ this.button2.Visible = false;
+ this.button2.Click += new System.EventHandler(this.button2_Click);
+ //
+ // statusStrip1
+ //
+ this.statusStrip1.ImageScalingSize = new System.Drawing.Size(24, 24);
+ this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.toolStripStatusLabel1});
+ this.statusStrip1.Location = new System.Drawing.Point(0, 214);
+ this.statusStrip1.Name = "statusStrip1";
+ this.statusStrip1.Size = new System.Drawing.Size(570, 31);
+ this.statusStrip1.SizingGrip = false;
+ this.statusStrip1.TabIndex = 9;
+ this.statusStrip1.Text = "statusStrip1";
+ //
+ // toolStripStatusLabel1
+ //
+ this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";
+ this.toolStripStatusLabel1.Size = new System.Drawing.Size(154, 24);
+ this.toolStripStatusLabel1.Text = "当前登录账户:无";
+ //
+ // Form4
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(570, 245);
+ this.Controls.Add(this.statusStrip1);
+ this.Controls.Add(this.button2);
+ this.Controls.Add(this.label1);
+ this.Controls.Add(this.pictureBox1);
+ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
+ this.MaximizeBox = false;
+ this.Name = "Form4";
+ this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+ this.Text = "OneDrive 备份(实验性功能)";
+ this.Load += new System.EventHandler(this.Form4_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
+ this.statusStrip1.ResumeLayout(false);
+ this.statusStrip1.PerformLayout();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.PictureBox pictureBox1;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.Button button2;
+ private System.Windows.Forms.StatusStrip statusStrip1;
+ private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;
+ }
+}
\ No newline at end of file
diff --git a/Form4.cs b/Form4.cs
new file mode 100644
index 0000000..2e2e341
--- /dev/null
+++ b/Form4.cs
@@ -0,0 +1,155 @@
+//using Microsoft.Graph;
+using Microsoft.Graph;
+using Microsoft.Identity.Client;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Windows.Forms;
+using System.IO;
+
+namespace FFXIVBackupTool
+{
+
+ public partial class Form4 : Form
+ {
+ public static IPublicClientApplication PublicClientApp;
+ public static string ClientId = "954b1a06-5cbe-42e1-9061-d16329fe40e6";
+ public static string[] scopes = { "user.read", "Files.Read.All","Files.ReadWrite.All","Sites.Read.All","Sites.ReadWrite.All"};//权限
+ public string AccessToken;
+
+
+ public Form4()
+ {
+ InitializeComponent();
+ }
+
+ private void Form4_Load(object sender, EventArgs e)
+ {
+ PublicClientApp = PublicClientApplicationBuilder.Create(ClientId)
+.WithRedirectUri("https://login.microsoftonline.com/common/oauth2/nativeclient")
+.Build();
+ }
+ private async void pictureBox1_Click(object sender, EventArgs e)
+ {
+ AuthenticationResult authResult = null;
+ var accounts = await PublicClientApp.GetAccountsAsync();
+ //textBox1.Text = authResult.Account.Username;
+ try
+ {
+ authResult = await PublicClientApp.AcquireTokenInteractive(scopes).ExecuteAsync();
+ }
+ catch (MsalException msalex)
+ {
+ if (msalex.ErrorCode == MsalError.AuthenticationCanceledError)
+ {
+ MessageBox.Show("中止登录");
+ }
+ else if (msalex.ErrorCode == MsalError.RequestTimeout)
+ {
+ MessageBox.Show("请求超时");
+
+ }
+ else if (msalex.ErrorCode == MsalError.AccessDenied)
+ {
+ MessageBox.Show("用户拒绝授权");
+ }
+
+ }
+ if (authResult != null)
+ {
+ toolStripStatusLabel1.Text= "当前登录账户:" + authResult.Account.Username;
+ AccessToken = authResult.AccessToken;
+ pictureBox1.Enabled = false;
+ button2.Visible = true;
+ }
+
+
+ }
+
+
+
+
+ private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
+ {
+ this.Cursor = Cursors.Hand;
+ }
+
+ private void pictureBox1_MouseLeave(object sender, EventArgs e)
+ {
+ this.Cursor = Cursors.Default;
+ }
+
+ private async void button3_Click(object sender, EventArgs e)
+ {
+
+ }
+
+ private void button2_Click(object sender, EventArgs e)
+ {
+ DialogResult result = MessageBox.Show("即将把当前目录下的备份文件上传到当前用户OneDrive网盘,特别提醒:由于本功能为实验性功能,可能会有诸多不稳定因素,请不要过于依赖该功能!\n\n确认要开始备份吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
+ if(result == DialogResult.Yes)
+ {
+ if (System.IO.File.Exists(@".\FFXIVBackupPackage-CHN.zip") && System.IO.File.Exists(@".\FFXIVBackupPackage-Intl.zip"))
+ {
+ toolStripStatusLabel1.Text = "正在上传文件,在提示完成前请勿关闭本窗口!";
+ UploadToOneDrive(@".\FFXIVBackupPackage-CHN.zip", @"/FFXIVBackupPackage-CHN.zip");
+ UploadToOneDrive(@".\FFXIVBackupPackage-Intl.zip", @"/FFXIVBackupPackage-Intl.zip");
+ }
+ else
+ {
+ MessageBox.Show("请将国服和国际服都备份后再上传!","提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
+ return;
+ }
+ }
+ }
+ public async void UploadToOneDrive(string filepath, string onedrivepath)
+ {
+ GraphServiceClient graphClient = new GraphServiceClient("https://graph.microsoft.com/v1.0", new DelegateAuthenticationProvider(async (requestMessage) => {
+ requestMessage.Headers.Authorization = new AuthenticationHeaderValue("bearer", AccessToken);
+ }));
+
+ using (var fileStream = System.IO.File.OpenRead(filepath))
+ {
+ // Use properties to specify the conflict behavior
+ // in this case, replace
+ var uploadProps = new DriveItemUploadableProperties
+ {
+ ODataType = null,
+ AdditionalData = new Dictionary
+ {
+ { "@microsoft.graph.conflictBehavior", "replace" }
+ }
+ };
+
+ // Create the upload session
+ // itemPath does not need to be a path to an existing item
+ var uploadSession = await graphClient.Me.Drive.Root.ItemWithPath(onedrivepath).CreateUploadSession(uploadProps).Request().PostAsync();
+
+ // Max slice size must be a multiple of 320 KiB
+ int maxSliceSize = 320 * 1024;
+ var fileUploadTask =
+ new LargeFileUploadTask(uploadSession, fileStream, maxSliceSize);
+ try
+ {
+ // Upload the file
+ var uploadResult = await fileUploadTask.UploadAsync();
+ if (uploadResult.UploadSucceeded)
+ {
+ toolStripStatusLabel1.Text = filepath + " 上传成功";
+ }
+ else
+ {
+ MessageBox.Show("上传失败,请检查网络!");
+ }
+ }
+ catch (ServiceException ex)
+ {
+ MessageBox.Show($"在上传过程中出现错误: {ex.ToString()}");
+ }
+ }
+
+ }
+ }
+}
diff --git a/Form4.resx b/Form4.resx
new file mode 100644
index 0000000..174ebc7
--- /dev/null
+++ b/Form4.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs
index ecc8f2c..8b8352c 100644
--- a/Properties/Resources.Designer.cs
+++ b/Properties/Resources.Designer.cs
@@ -59,5 +59,15 @@ internal Resources() {
resourceCulture = value;
}
}
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap ms_symbollockup_signin_dark {
+ get {
+ object obj = ResourceManager.GetObject("ms-symbollockup_signin_dark", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
}
}
diff --git a/Properties/Resources.resx b/Properties/Resources.resx
index af7dbeb..5d413c4 100644
--- a/Properties/Resources.resx
+++ b/Properties/Resources.resx
@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
- : System.Serialization.Formatters.Binary.BinaryFormatter
+ : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
+
@@ -68,9 +69,10 @@
-
+
+
@@ -85,9 +87,10 @@
-
+
+
@@ -109,9 +112,13 @@
2.0
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ ..\Resources\ms-symbollockup_signin_dark.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/Resources/ms-symbollockup_signin_dark.png b/Resources/ms-symbollockup_signin_dark.png
new file mode 100644
index 0000000..dbe5900
Binary files /dev/null and b/Resources/ms-symbollockup_signin_dark.png differ
diff --git a/app.config b/app.config
new file mode 100644
index 0000000..9d2c332
--- /dev/null
+++ b/app.config
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/packages.config b/packages.config
index 9afcbf0..3f2a674 100644
--- a/packages.config
+++ b/packages.config
@@ -2,5 +2,15 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file