Skip to content

Commit

Permalink
开始实现 dp2Commander
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalPlatform committed May 30, 2020
1 parent a533990 commit bb94877
Show file tree
Hide file tree
Showing 15 changed files with 1,802 additions and 267 deletions.
4 changes: 3 additions & 1 deletion DigitalPlatform.LibraryServer/AppReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,9 @@ int DoReaderChange(
DomUtil.SetElementText(domNewRec.DocumentElement, "libraryCode", strLibraryCode);

// 2014/7/4
if (this.VerifyReaderType == true)
if (this.VerifyReaderType == true
&& strAction == "change" // 2020/5/28 除了 change 以外的 changestate changeforegift changereaderbarcode 都不需要检查 readerType 元素
&& bForce == false) // 2020/5/28
{
string strReaderDbName = "";

Expand Down
26 changes: 26 additions & 0 deletions TestService/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public Worker(ILogger<Worker> logger)
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
Test();
await Task.Delay(TimeSpan.FromSeconds(10), stoppingToken);
ExitProcess("dp2SSL");
while (!stoppingToken.IsCancellationRequested)
{
Console.WriteLine("running ...");
Expand Down Expand Up @@ -95,5 +97,29 @@ public static string GetShortcutFilePath(string strApplicationName)
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), strApplicationName) + ".appref-ms";
}

// https://stackoverflow.com/questions/3411982/gracefully-killing-a-process
public static bool ExitProcess(string processName)
{
int count = 0;
foreach (var process in Process.GetProcessesByName(processName))
{
// 返回结果:
// true if the close message was successfully sent; false if the associated process
// does not have a main window or if the main window is disabled (for example if
// a modal dialog is being shown).
//
// 异常:
// T:System.InvalidOperationException:
// The process has already exited. -or- No process is associated with this System.Diagnostics.Process
// object.
if (process.CloseMainWindow() == false)
{
process.Kill(true);
}
count++;
}

return count != 0;
}
}
}
20 changes: 20 additions & 0 deletions dp2-net40.sln
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestService", "TestService\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUHF", "TestUHF\TestUHF.csproj", "{C8113357-AF6E-423E-87DD-1F3504EC31A8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dp2Commander", "dp2Commander\dp2Commander.csproj", "{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -2094,6 +2096,24 @@ Global
{C8113357-AF6E-423E-87DD-1F3504EC31A8}.Test|Mixed Platforms.Build.0 = Release|Any CPU
{C8113357-AF6E-423E-87DD-1F3504EC31A8}.Test|x86.ActiveCfg = Release|Any CPU
{C8113357-AF6E-423E-87DD-1F3504EC31A8}.Test|x86.Build.0 = Release|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Debug|x86.ActiveCfg = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Debug|x86.Build.0 = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Release|Any CPU.Build.0 = Release|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Release|x86.ActiveCfg = Release|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Release|x86.Build.0 = Release|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Test|Any CPU.ActiveCfg = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Test|Any CPU.Build.0 = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Test|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Test|Mixed Platforms.Build.0 = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Test|x86.ActiveCfg = Debug|Any CPU
{2541D0A3-4273-4835-BAE4-46BD7C7CA5E3}.Test|x86.Build.0 = Debug|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Loading

0 comments on commit bb94877

Please sign in to comment.