|
@@ -1,7 +1,10 @@
|
|
-using Microsoft.Win32;
|
|
|
|
|
|
+using Microsoft.IdentityModel.Tokens;
|
|
|
|
+using Microsoft.Win32;
|
|
using System.Data;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Diagnostics;
|
|
|
|
+using System.Net.Sockets;
|
|
using System.Text;
|
|
using System.Text;
|
|
|
|
+using Universal;
|
|
|
|
|
|
namespace Test;
|
|
namespace Test;
|
|
|
|
|
|
@@ -9,14 +12,8 @@ internal class Program
|
|
{
|
|
{
|
|
static void Main()
|
|
static void Main()
|
|
{
|
|
{
|
|
- int[,] timeStamp = { { 1, 2 }, { 3, 4 }, { 5, 6 } };
|
|
|
|
- int s = timeStamp[0, 1];
|
|
|
|
- int length = timeStamp.Length;
|
|
|
|
- foreach (var item in timeStamp)
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- var t = timeStamp.GetValue(0,0);
|
|
|
|
|
|
+ CompressTest test = new();
|
|
|
|
+ test.Test();
|
|
|
|
|
|
//DBTest test = new();
|
|
//DBTest test = new();
|
|
//test.Initialize();
|
|
//test.Initialize();
|
|
@@ -25,12 +22,12 @@ internal class Program
|
|
//test.TestOthers();
|
|
//test.TestOthers();
|
|
//test.TestRaw();
|
|
//test.TestRaw();
|
|
|
|
|
|
- ProcessTest processTest = new();
|
|
|
|
- processTest.Initialize();
|
|
|
|
- processTest.BackUp("10.4.6.48", 5432, "postgres", "123456", "D://source_db_dump.custom", "tin01_db");
|
|
|
|
|
|
+ //ProcessTest processTest = new();
|
|
|
|
+ //processTest.Initialize();
|
|
|
|
+ //processTest.BackUp("10.4.6.48", 5432, "postgres", "123456", "D://source_db_dump.custom", "tin01_db");
|
|
//processTest.BackUpSingleTable("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "FROMTIN", "20250630.PM1");
|
|
//processTest.BackUpSingleTable("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "FROMTIN", "20250630.PM1");
|
|
//processTest.BackUpByDateTime("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "FROMTIN", "20250630");
|
|
//processTest.BackUpByDateTime("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "FROMTIN", "20250630");
|
|
- processTest.Restore("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "DBTestTIN");
|
|
|
|
|
|
+ //processTest.Restore("localhost", 5432, "postgres", "123456", "D://source_db_dump.custom", "DBTestTIN");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -131,4 +128,48 @@ internal class ProcessTest
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+internal class CompressTest
|
|
|
|
+{
|
|
|
|
+ public void Test()
|
|
|
|
+ {
|
|
|
|
+ using MemoryStream stream = new();
|
|
|
|
+
|
|
|
|
+ Compressor.CompressZipFileDirectory(new(@"E:\Recipes"), stream);
|
|
|
|
+ Console.WriteLine(this.SplitSpan(stream, CallBack) ? "Send Success" : "Send Failed");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private bool CallBack(byte[] input, int current, int total)
|
|
|
|
+ {
|
|
|
|
+ Console.WriteLine($"{input.Length} {current} / {total}");
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private bool SplitSpan(MemoryStream stream, Func<byte[], int, int, bool> callBack, int packLength = 4096)
|
|
|
|
+ {
|
|
|
|
+ if (packLength < 256)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ Span<byte> t = stream.ToArray();
|
|
|
|
+ int count = t.Length / packLength;
|
|
|
|
+
|
|
|
|
+ Span<byte> ts;
|
|
|
|
+ for (int i = 0; i <= count; i++)
|
|
|
|
+ {
|
|
|
|
+ if (i == count)
|
|
|
|
+ {
|
|
|
|
+ ts = t.Slice(i * packLength);
|
|
|
|
+ if (callBack?.Invoke(ts.ToArray(), i, count) != true)
|
|
|
|
+ return false;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ ts = t.Slice(i * packLength, packLength);
|
|
|
|
+ if (callBack?.Invoke(ts.ToArray(), i, count) != true)
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|