Skip to content

Commit

Permalink
Release 1.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeric-X committed May 12, 2021
1 parent 82d9a95 commit 006af3c
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Changes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
v1.3.3(working)
v1.3.3
- Add cookie support.
- Add CommandService.
- Optimize Log system.
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Control/MainController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Windows.Forms;
using Microsoft.Win32;
using SyncClipboard.Utility;
using SyncClipboard.Module;

namespace SyncClipboard.Control
{
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Control/SettingsForm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Windows.Forms;
using SyncClipboard.Control;
using SyncClipboard.Module;

namespace SyncClipboard
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
14 changes: 10 additions & 4 deletions SyncClipboard/UserConfig.cs → SyncClipboard/Module/UserConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using System.Windows.Forms;
using System;

namespace SyncClipboard
namespace SyncClipboard.Module
{
internal static class UserConfig
{
Expand All @@ -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();
}

Expand All @@ -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
{
Expand All @@ -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)
{
Expand All @@ -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()
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SyncClipboard.Control;
using SyncClipboard.Utility;
using SyncClipboard.Service;
using SyncClipboard.Module;
namespace SyncClipboard
{
static class Program
Expand Down
20 changes: 15 additions & 5 deletions SyncClipboard/Service/CommandService/CommandService.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using SyncClipboard.Utility;
using SyncClipboard.Module;

namespace SyncClipboard.Service
{
Expand All @@ -15,6 +16,7 @@ public class Command

private CancellationTokenSource _cancelSource;
private CancellationToken _cancelToken;
private bool _isError = false;

protected override void StartService()
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Service/SyncService/PullService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using SyncClipboard.Control;
using SyncClipboard.Service;
using SyncClipboard.Utility;
using SyncClipboard.Module;

namespace SyncClipboard
{
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Service/SyncService/PushService.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 2 additions & 2 deletions SyncClipboard/SyncClipboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Service\SyncService\PushService.cs" />
<Compile Include="Env.cs" />
<Compile Include="UserConfig.cs" />
<Compile Include="Module\UserConfig.cs" />
<Compile Include="Control\SettingsForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Control\SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<Compile Include="Service\SyncService\PullService.cs" />
<Compile Include="UpdateChecker.cs" />
<Compile Include="Module\UpdateChecker.cs" />
<Compile Include="Utility\Log.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Utility/HttpWebUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Net;
using System.Text;
using SyncClipboard.Module;

namespace SyncClipboard.Utility
{
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Utility/Nextcloud.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Web.Script.Serialization;
using System.Windows.Forms;
using SyncClipboard.Control;
using SyncClipboard.Module;

namespace SyncClipboard.Utility
{
Expand Down
1 change: 1 addition & 0 deletions SyncClipboard/Utility/WebDav.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Net;
using System.Threading.Tasks;
using SyncClipboard.Module;

namespace SyncClipboard.Utility
{
Expand Down

0 comments on commit 006af3c

Please sign in to comment.