diff --git a/Changes.md b/Changes.md
index e2c9e9bd..21b250a8 100644
--- a/Changes.md
+++ b/Changes.md
@@ -1,4 +1,4 @@
-v1.3.3(working)
+v1.3.3
- Add cookie support.
- Add CommandService.
- Optimize Log system.
diff --git a/SyncClipboard/Control/MainController.cs b/SyncClipboard/Control/MainController.cs
index a6b20643..9e026fd7 100644
--- a/SyncClipboard/Control/MainController.cs
+++ b/SyncClipboard/Control/MainController.cs
@@ -2,6 +2,7 @@
using System.Windows.Forms;
using Microsoft.Win32;
using SyncClipboard.Utility;
+using SyncClipboard.Module;
namespace SyncClipboard.Control
{
diff --git a/SyncClipboard/Control/SettingsForm.cs b/SyncClipboard/Control/SettingsForm.cs
index 1fffb051..c2d63bfe 100644
--- a/SyncClipboard/Control/SettingsForm.cs
+++ b/SyncClipboard/Control/SettingsForm.cs
@@ -1,6 +1,7 @@
using System;
using System.Windows.Forms;
using SyncClipboard.Control;
+using SyncClipboard.Module;
namespace SyncClipboard
{
diff --git a/SyncClipboard/UpdateChecker.cs b/SyncClipboard/Module/UpdateChecker.cs
similarity index 98%
rename from SyncClipboard/UpdateChecker.cs
rename to SyncClipboard/Module/UpdateChecker.cs
index 297b7cf2..24b78632 100644
--- a/SyncClipboard/UpdateChecker.cs
+++ b/SyncClipboard/Module/UpdateChecker.cs
@@ -7,7 +7,7 @@ namespace SyncClipboard
{
internal class UpdateChecker
{
- public const string Version = "1.3.2";
+ public const string Version = "1.3.3";
public const int VersionPartNumber = 3;
public const string UpdateUrl = "https://api.github.com/repos/Jeric-X/SyncClipboard/releases/latest";
public const string ReleaseUrl = "https://github.com/Jeric-X/SyncClipboard/releases/latest";
diff --git a/SyncClipboard/UserConfig.cs b/SyncClipboard/Module/UserConfig.cs
similarity index 88%
rename from SyncClipboard/UserConfig.cs
rename to SyncClipboard/Module/UserConfig.cs
index d041486d..b1dc1931 100644
--- a/SyncClipboard/UserConfig.cs
+++ b/SyncClipboard/Module/UserConfig.cs
@@ -4,7 +4,7 @@
using System.Windows.Forms;
using System;
-namespace SyncClipboard
+namespace SyncClipboard.Module
{
internal static class UserConfig
{
@@ -29,7 +29,13 @@ public class CSyncService
public bool IsNextcloud = false;
}
+ public class CCommandService
+ {
+ public int Shutdowntime = 30;
+ }
+
public CSyncService SyncService = new CSyncService();
+ public CCommandService CommandService = new CCommandService();
public CProgram Program = new CProgram();
}
@@ -41,7 +47,7 @@ internal static void Save()
var configStr = serializer.Serialize(Config);
try
{
- System.IO.File.WriteAllText(Env.FullPath(CONFIG_FILE), configStr);
+ File.WriteAllText(Env.FullPath(CONFIG_FILE), configStr);
}
catch
{
@@ -56,7 +62,7 @@ internal static void Load()
string text;
try
{
- text = System.IO.File.ReadAllText(Env.FullPath(CONFIG_FILE));
+ text = File.ReadAllText(Env.FullPath(CONFIG_FILE));
}
catch (FileNotFoundException)
{
@@ -78,7 +84,7 @@ internal static void Load()
WriteDefaultConfigFile();
}
- Auth = FormatHttpAuthHeader(UserConfig.Config.SyncService.UserName, UserConfig.Config.SyncService.Password);
+ Auth = FormatHttpAuthHeader(Config.SyncService.UserName, Config.SyncService.Password);
}
private static void WriteDefaultConfigFile()
diff --git a/SyncClipboard/Program.cs b/SyncClipboard/Program.cs
index 2e2b6a61..d940b2a6 100644
--- a/SyncClipboard/Program.cs
+++ b/SyncClipboard/Program.cs
@@ -4,6 +4,7 @@
using SyncClipboard.Control;
using SyncClipboard.Utility;
using SyncClipboard.Service;
+using SyncClipboard.Module;
namespace SyncClipboard
{
static class Program
diff --git a/SyncClipboard/Service/CommandService/CommandService.cs b/SyncClipboard/Service/CommandService/CommandService.cs
index f6c0b7cc..224926ab 100644
--- a/SyncClipboard/Service/CommandService/CommandService.cs
+++ b/SyncClipboard/Service/CommandService/CommandService.cs
@@ -1,6 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using SyncClipboard.Utility;
+using SyncClipboard.Module;
namespace SyncClipboard.Service
{
@@ -15,6 +16,7 @@ public class Command
private CancellationTokenSource _cancelSource;
private CancellationToken _cancelToken;
+ private bool _isError = false;
protected override void StartService()
{
@@ -42,10 +44,16 @@ private async void StartServiceAsync(CancellationToken cancelToken)
Command command = await GetRemoteCommand().ConfigureAwait(false);
await ResetRemoteCommand(new Command()).ConfigureAwait(false);
ExecuteCommand(command);
+
+ _isError = false;
}
catch (System.Exception ex)
{
- Program.notifyer.ToastNotify("CommandService failed", ex.ToString());
+ if (!_isError)
+ {
+ Program.notifyer.ToastNotify("CommandService failed", ex.ToString());
+ _isError = true;
+ }
}
await Task.Delay(UserConfig.Config.Program.IntervalTime).ConfigureAwait(false);
@@ -74,10 +82,12 @@ private void ExecuteCommand(Command command)
{
if (command.CommandStr == "shutdown")
{
- System.Diagnostics.Process open = new System.Diagnostics.Process();
- open.StartInfo.FileName = "cmd";
- open.StartInfo.Arguments = @"/k shutdown.exe /s /t 60 /c ""use [ shutdown /a ] in 60s to undo shutdown.""";
- open.Start();
+ var shutdownTime = UserConfig.Config.CommandService.Shutdowntime;
+
+ var process = new System.Diagnostics.Process();
+ process.StartInfo.FileName = "cmd";
+ process.StartInfo.Arguments = $@"/k shutdown.exe /s /t {shutdownTime} /c ""use [ shutdown /a ] in {shutdownTime}s to undo shutdown.""";
+ process.Start();
}
}
diff --git a/SyncClipboard/Service/SyncService/Profile/ProfileFactory.cs b/SyncClipboard/Service/SyncService/Profile/ProfileFactory.cs
index d2638747..d61dcd02 100644
--- a/SyncClipboard/Service/SyncService/Profile/ProfileFactory.cs
+++ b/SyncClipboard/Service/SyncService/Profile/ProfileFactory.cs
@@ -5,6 +5,7 @@
using System.Threading;
using System.Web.Script.Serialization;
using System.Windows.Forms;
+using SyncClipboard.Module;
using static SyncClipboard.Service.ProfileType;
namespace SyncClipboard.Service
diff --git a/SyncClipboard/Service/SyncService/PullService.cs b/SyncClipboard/Service/SyncService/PullService.cs
index c8daf4d6..b2f0a8ef 100644
--- a/SyncClipboard/Service/SyncService/PullService.cs
+++ b/SyncClipboard/Service/SyncService/PullService.cs
@@ -3,6 +3,7 @@
using SyncClipboard.Control;
using SyncClipboard.Service;
using SyncClipboard.Utility;
+using SyncClipboard.Module;
namespace SyncClipboard
{
diff --git a/SyncClipboard/Service/SyncService/PushService.cs b/SyncClipboard/Service/SyncService/PushService.cs
index f55bd3e4..6d1b81be 100644
--- a/SyncClipboard/Service/SyncService/PushService.cs
+++ b/SyncClipboard/Service/SyncService/PushService.cs
@@ -1,6 +1,7 @@
using SyncClipboard.Control;
using SyncClipboard.Service;
using SyncClipboard.Utility;
+using SyncClipboard.Module;
using System;
using System.Threading;
using System.Threading.Tasks;
diff --git a/SyncClipboard/SyncClipboard.csproj b/SyncClipboard/SyncClipboard.csproj
index a35b7328..5370e887 100644
--- a/SyncClipboard/SyncClipboard.csproj
+++ b/SyncClipboard/SyncClipboard.csproj
@@ -116,7 +116,7 @@
-
+
Form
@@ -124,7 +124,7 @@
SettingsForm.cs
-
+
ResXFileCodeGenerator
diff --git a/SyncClipboard/Utility/HttpWebUtility.cs b/SyncClipboard/Utility/HttpWebUtility.cs
index 273f706b..b8f50f36 100644
--- a/SyncClipboard/Utility/HttpWebUtility.cs
+++ b/SyncClipboard/Utility/HttpWebUtility.cs
@@ -3,6 +3,7 @@
using System.IO;
using System.Net;
using System.Text;
+using SyncClipboard.Module;
namespace SyncClipboard.Utility
{
diff --git a/SyncClipboard/Utility/Nextcloud.cs b/SyncClipboard/Utility/Nextcloud.cs
index 5dfdb8d4..2830d9b4 100644
--- a/SyncClipboard/Utility/Nextcloud.cs
+++ b/SyncClipboard/Utility/Nextcloud.cs
@@ -4,6 +4,7 @@
using System.Web.Script.Serialization;
using System.Windows.Forms;
using SyncClipboard.Control;
+using SyncClipboard.Module;
namespace SyncClipboard.Utility
{
diff --git a/SyncClipboard/Utility/WebDav.cs b/SyncClipboard/Utility/WebDav.cs
index 4819f027..57841508 100644
--- a/SyncClipboard/Utility/WebDav.cs
+++ b/SyncClipboard/Utility/WebDav.cs
@@ -1,6 +1,7 @@
using System;
using System.Net;
using System.Threading.Tasks;
+using SyncClipboard.Module;
namespace SyncClipboard.Utility
{