Skip to content

Commit e59979e

Browse files
tested
1 parent 06aeea8 commit e59979e

14 files changed

+1041
-0
lines changed

.gitignore

Lines changed: 400 additions & 0 deletions
Large diffs are not rendered by default.

App/App.config

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8.1" />
5+
</startup>
6+
<runtime>
7+
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
8+
<dependentAssembly>
9+
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
10+
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
11+
</dependentAssembly>
12+
<dependentAssembly>
13+
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
14+
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
15+
</dependentAssembly>
16+
<dependentAssembly>
17+
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
18+
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
19+
</dependentAssembly>
20+
</assemblyBinding>
21+
</runtime>
22+
</configuration>

App/AssemblyInfo.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyTitle("SSH-FileGrabber")]
5+
[assembly: AssemblyDescription("")]
6+
[assembly: AssemblyConfiguration("")]
7+
[assembly: AssemblyCompany("")]
8+
[assembly: AssemblyProduct("SSH-FileGrabber")]
9+
[assembly: AssemblyCopyright("Copyright © 2024")]
10+
[assembly: AssemblyTrademark("")]
11+
[assembly: AssemblyCulture("")]
12+
13+
[assembly: ComVisible(false)]
14+
15+
[assembly: Guid("305d3d7e-daac-4bc9-81f0-51c2bca3fbed")]
16+
17+
[assembly: AssemblyVersion("1.0.0.0")]
18+
[assembly: AssemblyFileVersion("1.0.0.0")]
19+
[assembly: AssemblyInformationalVersion("1.0 dev")]

App/app.manifest

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
3+
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
4+
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
5+
<security>
6+
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
7+
<!-- UAC-Manifestoptionen
8+
Wenn Sie die Ebene der Benutzerkontensteuerung für Windows ändern möchten, ersetzen Sie den
9+
Knoten "requestedExecutionLevel" wie folgt.
10+
11+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
12+
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
13+
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
14+
15+
Durch Angabe des Elements "requestedExecutionLevel" wird die Datei- und Registrierungsvirtualisierung deaktiviert.
16+
Entfernen Sie dieses Element, wenn diese Virtualisierung aus Gründen der Abwärtskompatibilität
17+
für die Anwendung erforderlich ist.
18+
-->
19+
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
20+
</requestedPrivileges>
21+
</security>
22+
</trustInfo>
23+
24+
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
25+
<application>
26+
<!-- Eine Liste der Windows-Versionen, unter denen diese Anwendung getestet
27+
und für die sie entwickelt wurde. Wenn Sie die Auskommentierung der entsprechenden Elemente aufheben,
28+
wird von Windows automatisch die kompatibelste Umgebung ausgewählt. -->
29+
30+
<!-- Windows Vista -->
31+
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
32+
33+
<!-- Windows 7 -->
34+
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
35+
36+
<!-- Windows 8 -->
37+
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
38+
39+
<!-- Windows 8.1 -->
40+
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
41+
42+
<!-- Windows 10 -->
43+
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
44+
45+
</application>
46+
</compatibility>
47+
48+
<!-- Gibt an, dass die Anwendung mit DPI-Werten kompatibel ist und von Windows nicht automatisch auf höhere
49+
DPI-Werte skaliert wird. WPF-Anwendungen (Windows Presentation Foundation) sind automatisch mit DPI-Werten kompatibel, eine Aktivierung
50+
ist nicht erforderlich. Für Windows Forms-Anwendungen für .NET Framework 4.6, die diese Einstellung aktivieren, muss
51+
auch die Einstellung "'EnableWindowsFormsHighDpiAutoResizing" in der Datei "app.config" auf TRUE festgelegt werden.
52+
53+
Hierdurch können für die Anwendung lange Pfade verwendet werden. Weitere Informationen finden Sie unter https://docs.microsoft.com/windows/win32/fileio/maximum-file-path-limitation.-->
54+
<!--
55+
<application xmlns="urn:schemas-microsoft-com:asm.v3">
56+
<windowsSettings>
57+
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
58+
<longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
59+
</windowsSettings>
60+
</application>
61+
-->
62+
63+
<!-- Designs für allgemeine Windows-Steuerelemente und -Dialogfelder (Windows XP und höher) aktivieren -->
64+
<!--
65+
<dependency>
66+
<dependentAssembly>
67+
<assemblyIdentity
68+
type="win32"
69+
name="Microsoft.Windows.Common-Controls"
70+
version="6.0.0.0"
71+
processorArchitecture="*"
72+
publicKeyToken="6595b64144ccf1df"
73+
language="*"
74+
/>
75+
</dependentAssembly>
76+
</dependency>
77+
-->
78+
79+
</assembly>

App/mshtml_2680.ico

766 Bytes
Binary file not shown.

App/packages.config

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net481" />
4+
<package id="SSH.NET" version="2024.1.0" targetFramework="net481" />
5+
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net481" />
6+
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net481" />
7+
</packages>

Logging/Interface.cs

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
using System;
2+
using System.IO;
3+
using System.Reflection;
4+
using System.Text;
5+
6+
#pragma warning disable CS8618
7+
#pragma warning disable CS8625
8+
9+
namespace BSS.Logging
10+
{
11+
internal static class Log
12+
{
13+
private static Boolean _isInitialized = false;
14+
private static String _assemblyPath;
15+
private static readonly Object _fileLock = new();
16+
17+
internal static void Initialize(String assemblyPath = null)
18+
{
19+
if (_isInitialized) return;
20+
21+
_assemblyPath = assemblyPath ?? Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
22+
23+
if (Directory.Exists($"{_assemblyPath}\\logs"))
24+
{
25+
DateTime now = DateTime.Now;
26+
27+
if (File.Exists($"{_assemblyPath}\\logs\\{now:dd.MM.yyyy}.txt"))
28+
{
29+
using (StreamWriter streamWriter = new($"{_assemblyPath}\\logs\\{now:dd.MM.yyyy}.txt", true, Encoding.UTF8))
30+
{
31+
streamWriter.WriteLine();
32+
}
33+
}
34+
}
35+
36+
_isInitialized = true;
37+
}
38+
39+
// #######################################################################################
40+
41+
internal static void FastLog(String message, LogSeverity severity, String source)
42+
{
43+
DateTime now = DateTime.Now;
44+
45+
LogMessage logMessage;
46+
logMessage.Message = message;
47+
logMessage.Severity = severity;
48+
logMessage.Source = source;
49+
50+
WriteFile(ref logMessage, ref now);
51+
}
52+
53+
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
54+
55+
internal static void WriteFile(ref readonly LogMessage formattedLogMessage, ref readonly DateTime timeStamp)
56+
{
57+
if (!_isInitialized) throw new MethodAccessException("Logging class not initialized");
58+
59+
if (!Directory.Exists($"{_assemblyPath}\\logs"))
60+
{
61+
Directory.CreateDirectory($"{_assemblyPath}\\logs");
62+
}
63+
64+
String logLine = "";
65+
UInt16 lineLength = 27;
66+
67+
logLine += $"[{timeStamp:dd.MM.yyyy HH:mm:ss}] [";
68+
69+
switch (formattedLogMessage.Severity)
70+
{
71+
case LogSeverity.Info:
72+
lineLength += 4;
73+
logLine += "Info";
74+
break;
75+
case LogSeverity.Debug:
76+
lineLength += 5;
77+
logLine += "Debug";
78+
break;
79+
case LogSeverity.Warning:
80+
lineLength += 7;
81+
logLine += "Warning";
82+
break;
83+
case LogSeverity.Verbose:
84+
lineLength += 7;
85+
logLine += "Verbose";
86+
break;
87+
case LogSeverity.Error:
88+
lineLength += 5;
89+
logLine += "Error";
90+
break;
91+
case LogSeverity.Critical:
92+
lineLength += 8;
93+
logLine += "Critical";
94+
break;
95+
case LogSeverity.Alert:
96+
lineLength += 5;
97+
logLine += "Alert";
98+
break;
99+
}
100+
101+
logLine += $"]-[{formattedLogMessage.Source}]";
102+
103+
lineLength += (UInt16)formattedLogMessage.Source.Length;
104+
105+
if (lineLength < 52)
106+
{
107+
for (UInt16 i = lineLength; i < 52; ++i)
108+
{
109+
logLine += " ";
110+
}
111+
}
112+
else
113+
{
114+
logLine += " ";
115+
}
116+
117+
logLine += formattedLogMessage.Message;
118+
119+
//
120+
121+
try
122+
{
123+
lock (_fileLock)
124+
{
125+
xDebug.WriteLine(logLine);
126+
127+
using (StreamWriter streamWriter = new($"{_assemblyPath}\\logs\\{timeStamp:dd.MM.yyyy}.txt", true, Encoding.UTF8))
128+
{
129+
streamWriter.WriteLine(logLine);
130+
}
131+
}
132+
}
133+
catch (Exception ex)
134+
{
135+
throw new FieldAccessException($"Unable to write log file to:\n{_assemblyPath}\\logs\\{timeStamp:dd.MM.yyyy}.txt\n\nError: {ex.Message}");
136+
}
137+
}
138+
}
139+
}

Logging/LogMessage.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System;
2+
3+
namespace BSS.Logging
4+
{
5+
internal ref struct LogMessage
6+
{
7+
internal LogMessage(String message, LogSeverity severity, String source)
8+
{
9+
Message = message;
10+
Severity = severity;
11+
Source = source;
12+
}
13+
14+
internal LogSeverity Severity;
15+
16+
internal String Source;
17+
internal String Message;
18+
}
19+
}

Logging/LogSeverity.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
namespace BSS.Logging
2+
{
3+
internal enum LogSeverity
4+
{
5+
///<summary>Logs that contain the most severe level of error. This type of error indicates that immediate attention may be required.</summary>
6+
Critical = 0,
7+
///<summary>Logs that highlight when the flow of execution is stopped due to a failure.</summary>
8+
Error = 1,
9+
///<summary>Logs that highlight an abnormal activity in the flow of execution.</summary>
10+
Warning = 2,
11+
///<summary>Logs that track the general flow of the application.</summary>
12+
Info = 3,
13+
///<summary>Logs that are used for interactive investigation during development.</summary>
14+
Verbose = 4,
15+
///<summary>Logs that contain the most detailed messages.</summary>
16+
Debug = 5,
17+
///<summary>Logs that highlight an abnormal activity in the flow of execution. This type of error indicates that immediate attention may be required.</summary>
18+
Alert = 6,
19+
}
20+
}

Logging/xDebug.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Diagnostics;
3+
using System.Runtime.InteropServices;
4+
5+
namespace BSS.Logging
6+
{
7+
internal static class xDebug
8+
{
9+
[DllImport("kernel32.dll")]
10+
static extern Boolean AllocConsole();
11+
12+
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
13+
[Conditional("DEBUG")]
14+
internal static void Initialize() => AllocConsole();
15+
16+
// # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
17+
[Conditional("DEBUG")]
18+
internal static void Write(Object input) => Console.Write(input);
19+
[Conditional("DEBUG")]
20+
internal static void WriteLine(Object input) => Console.WriteLine(input);
21+
}
22+
}

0 commit comments

Comments
 (0)