diff --git a/Connect_Netzlaufwerk/ApplicationEvents.vb b/Connect_Netzlaufwerk/ApplicationEvents.vb new file mode 100644 index 0000000..cf403a0 --- /dev/null +++ b/Connect_Netzlaufwerk/ApplicationEvents.vb @@ -0,0 +1,29 @@ +Imports Microsoft.VisualBasic.ApplicationServices + +Namespace My + ' The following events are available for MyApplication: + ' Startup: Raised when the application starts, before the startup form is created. + ' Shutdown: Raised after all application forms are closed. This event is not raised if the application terminates abnormally. + ' UnhandledException: Raised if the application encounters an unhandled exception. + ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. + ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected. + + ' **NEW** ApplyApplicationDefaults: Raised when the application queries default values to be set for the application. + + ' Example: + ' Private Sub MyApplication_ApplyApplicationDefaults(sender As Object, e As ApplyApplicationDefaultsEventArgs) Handles Me.ApplyApplicationDefaults + ' + ' ' Setting the application-wide default Font: + ' e.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Regular) + ' + ' ' Setting the HighDpiMode for the Application: + ' e.HighDpiMode = HighDpiMode.PerMonitorV2 + ' + ' ' If a splash dialog is used, this sets the minimum display time: + ' e.MinimumSplashScreenDisplayTime = 4000 + ' End Sub + + Partial Friend Class MyApplication + + End Class +End Namespace diff --git a/Connect_Netzlaufwerk/Connect_Netzlaufwerk.vbproj b/Connect_Netzlaufwerk/Connect_Netzlaufwerk.vbproj new file mode 100644 index 0000000..ab6dbe6 --- /dev/null +++ b/Connect_Netzlaufwerk/Connect_Netzlaufwerk.vbproj @@ -0,0 +1,32 @@ + + + + WinExe + net8.0-windows + Sub Main + true + WindowsForms + + + + + + + + + + + True + True + Application.myapp + + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + + \ No newline at end of file diff --git a/Connect_Netzlaufwerk/Form1.Designer.vb b/Connect_Netzlaufwerk/Form1.Designer.vb new file mode 100644 index 0000000..02ebd2e --- /dev/null +++ b/Connect_Netzlaufwerk/Form1.Designer.vb @@ -0,0 +1,98 @@ + +Partial Class Form1 + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + + Private Sub InitializeComponent() + lblConnect = New Label() + lblDriveCaption = New Label() + ComboDrive = New ComboBox() + Button1 = New Button() + Button2 = New Button() + SuspendLayout() + ' + ' lblConnect + ' + lblConnect.AutoSize = True + lblConnect.Location = New Point(25, 19) + lblConnect.Name = "lblConnect" + lblConnect.Size = New Size(41, 15) + lblConnect.TabIndex = 0 + lblConnect.Text = "Label1" + ' + ' lblDriveCaption + ' + lblDriveCaption.AutoSize = True + lblDriveCaption.Location = New Point(25, 52) + lblDriveCaption.Name = "lblDriveCaption" + lblDriveCaption.Size = New Size(41, 15) + lblDriveCaption.TabIndex = 1 + lblDriveCaption.Text = "Label1" + ' + ' ComboDrive + ' + ComboDrive.FormattingEnabled = True + ComboDrive.Location = New Point(121, 52) + ComboDrive.Name = "ComboDrive" + ComboDrive.Size = New Size(121, 23) + ComboDrive.TabIndex = 2 + ' + ' Button1 + ' + Button1.Location = New Point(25, 100) + Button1.Name = "Button1" + Button1.Size = New Size(75, 23) + Button1.TabIndex = 3 + Button1.Text = "Connect" + Button1.UseVisualStyleBackColor = True + ' + ' Button2 + ' + Button2.Location = New Point(121, 100) + Button2.Name = "Button2" + Button2.Size = New Size(75, 23) + Button2.TabIndex = 4 + Button2.Text = "Disconnect" + Button2.UseVisualStyleBackColor = True + ' + ' Form1 + ' + AutoScaleDimensions = New SizeF(7F, 15F) + AutoScaleMode = AutoScaleMode.Font + ClientSize = New Size(800, 450) + Controls.Add(Button2) + Controls.Add(Button1) + Controls.Add(ComboDrive) + Controls.Add(lblDriveCaption) + Controls.Add(lblConnect) + Name = "Form1" + Text = "Form1" + ResumeLayout(False) + PerformLayout() + End Sub + + Friend WithEvents lblConnect As Label + Friend WithEvents lblDriveCaption As Label + Friend WithEvents ComboDrive As ComboBox + Friend WithEvents Button1 As Button + Friend WithEvents Button2 As Button + +End Class diff --git a/Connect_Netzlaufwerk/Form1.resx b/Connect_Netzlaufwerk/Form1.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/Connect_Netzlaufwerk/Form1.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Connect_Netzlaufwerk/Form1.vb b/Connect_Netzlaufwerk/Form1.vb new file mode 100644 index 0000000..edb5fd1 --- /dev/null +++ b/Connect_Netzlaufwerk/Form1.vb @@ -0,0 +1,124 @@ +Imports System.IO + +Public Class Form1 + Dim strUserName As String ' UserName für Anmelden beim Netzlaufwerk + Dim strUserPassword As String ' Password für die Anmeldung + Dim strDrive As String ' Laufwerksbuchstabe + + ' Dieser Source stammt von http://www.activevb.de + ' und kann frei verwendet werden. Für eventuelle Schäden + ' wird nicht gehaftet. + + ' Um Fehler oder Fragen zu klären, nutzen Sie bitte unser Forum. + ' Ansonsten viel Spaß und Erfolg mit diesem Source ! + + ' Deklaration: Globale Form API-Konstanten + ' Private Const RESOURCETYPE_DISK As Int32 = &H1 + Const RESOURCETYPE_DISK = &H1 + + ' Deklaration: Globale Form API-Typen + Public Structure NETRESOURCE + Public dwScope As Integer + Public dwType As Integer + Public dwDisplayType As Integer + Public dwUsage As Integer + Public lpLocalName As String + Public lpRemoteName As String + Public lpComment As String + Public lpProvider As String + + End Structure + ' Deklaration: Globale Form API-Funktionen + Private Declare Function WNetAddConnection2 Lib "mpr.dll" _ + Alias "WNetAddConnection2A" ( + ByRef lpNetResource As NETRESOURCE, + ByVal lpPassword As String, + ByVal lpUserName As String, + ByVal dwFlags As Integer) As Integer + + Private Declare Function WNetCancelConnection2 Lib "mpr.dll" _ + Alias "WNetCancelConnection2A" ( + ByVal lpName As String, + ByVal dwFlags As Integer, + ByVal fForce As Integer) As Integer + + Dim udtNetzResource As NETRESOURCE + + Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load + lblConnect.Text = "Es ist keine Verbindung hergestellt." + + ' Freien Laufwerks-Buchstaben ermitteln + Dim i As Integer + + Dim sDrives As String = Join(Directory.GetLogicalDrives(), "") + Dim sNextDrive As String = "" + + For i = 68 To 90 + + If Not sDrives.Contains(Chr(i) & ":") Then + sNextDrive = Chr(i) & ":" + ComboDrive.Items.Add(sNextDrive) + End If + + Next + + ' R1 = Rechnername, C_SYSTEM = Name des zuzuweisenden Laufwerks + udtNetzResource.lpRemoteName = "\\SDD-VMP03-VM09\DataFiles$\Digital Data\EnvelopeGenerator\EnvelopeGeneratorExport" + + ' Username & Passwort (anhängig vom Freigabestatus des Laufwerks). Inhalt ist + ' bestenfalls egal + strUserName = "dd-san01\Administrator" + strUserPassword = "##25!45!3_works" + + udtNetzResource.dwType = RESOURCETYPE_DISK + lblDriveCaption.Text = "" + End Sub + + Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click + ' Abfrage ob ein Laufwerksbuchstabe ausgewählt wurde + If ComboDrive.Text = "" Then + + MsgBox("Es wurde kein freier Laufwerks-Buchstabe ausgewählt.") + + Else + + ' gewählter Laufwerksbuchstabe sichern für die Trennung + strDrive = ComboDrive.Text + + udtNetzResource.lpLocalName = ComboDrive.Text + + Dim lngResult As Integer + + ' Hier wird verbunden + ' dwFlag muss 1 sein + lngResult = WNetAddConnection2(udtNetzResource, strUserPassword, strUserName, 1) + + If lngResult = 0 Then + lblConnect.Text = "Verbunden." + + Else + + lblConnect.Text = "Verbindung nicht möglich." + End If + End If + End Sub + + Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click + ' gewählter Laufwerksbuchstabe sichern für die Trennung + strDrive = ComboDrive.Text + + udtNetzResource.lpLocalName = ComboDrive.Text + + Dim lngResult As Integer + + lngResult = WNetCancelConnection2(strDrive, 0, True) + + If lngResult = 0 Then + lblConnect.Text = "Getrennt." + + Else + + lblConnect.Text = "Trennung nicht möglich." + End If + End Sub +End Class diff --git a/Connect_Netzlaufwerk/My Project/Application.Designer.vb b/Connect_Netzlaufwerk/My Project/Application.Designer.vb new file mode 100644 index 0000000..007b31f --- /dev/null +++ b/Connect_Netzlaufwerk/My Project/Application.Designer.vb @@ -0,0 +1,37 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + +Namespace My + + 'NOTE: This file is auto-generated; do not modify it directly. To make changes, + ' or if you encounter build errors in this file, go to the Project Designer + ' (go to Project Properties or double-click the My Project node in + ' Solution Explorer), and make changes on the Application tab. + ' + Partial Friend Class MyApplication + + + Public Sub New() + MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) + Me.IsSingleInstance = False + Me.EnableVisualStyles = True + Me.SaveMySettingsOnExit = True + Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses + End Sub + + + Protected Overrides Sub OnCreateMainForm() + Me.MainForm = Form1 + End Sub + End Class +End Namespace diff --git a/Connect_Netzlaufwerk/My Project/Application.myapp b/Connect_Netzlaufwerk/My Project/Application.myapp new file mode 100644 index 0000000..0f12f32 --- /dev/null +++ b/Connect_Netzlaufwerk/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + true + Form1 + false + 0 + true + 0 + true + \ No newline at end of file diff --git a/signFLOW_Folder_sync.sln b/signFLOW_Folder_sync.sln new file mode 100644 index 0000000..1cb3164 --- /dev/null +++ b/signFLOW_Folder_sync.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "signFLOW_Folder_sync", "signFLOW_Folder_sync\signFLOW_Folder_sync.vbproj", "{B362E61A-A4BF-4A95-A4D6-8FA79B476126}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Connect_Netzlaufwerk", "Connect_Netzlaufwerk\Connect_Netzlaufwerk.vbproj", "{323640B0-C044-48A9-AE27-B95D267CE87F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B362E61A-A4BF-4A95-A4D6-8FA79B476126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B362E61A-A4BF-4A95-A4D6-8FA79B476126}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B362E61A-A4BF-4A95-A4D6-8FA79B476126}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B362E61A-A4BF-4A95-A4D6-8FA79B476126}.Release|Any CPU.Build.0 = Release|Any CPU + {323640B0-C044-48A9-AE27-B95D267CE87F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {323640B0-C044-48A9-AE27-B95D267CE87F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {323640B0-C044-48A9-AE27-B95D267CE87F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {323640B0-C044-48A9-AE27-B95D267CE87F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {BE72D76C-04FF-4D49-9958-63AAA43C5161} + EndGlobalSection +EndGlobal diff --git a/signFLOW_Folder_sync/App.config b/signFLOW_Folder_sync/App.config new file mode 100644 index 0000000..0ec5a4d --- /dev/null +++ b/signFLOW_Folder_sync/App.config @@ -0,0 +1,35 @@ + + + + +
+ + + + + + + + + + + + 1 + + + SELECT GUID, [ENVELOPE_UUID] + FROM [DD_ECM].[dbo].[TBSIG_ENVELOPE] where STATUS = 1004 and DMZ_MOVED = 0 + + + sd + + + sd + + + True + + + + \ No newline at end of file diff --git a/signFLOW_Folder_sync/My Project/Application.Designer.vb b/signFLOW_Folder_sync/My Project/Application.Designer.vb new file mode 100644 index 0000000..88dd01c --- /dev/null +++ b/signFLOW_Folder_sync/My Project/Application.Designer.vb @@ -0,0 +1,13 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + diff --git a/signFLOW_Folder_sync/My Project/Application.myapp b/signFLOW_Folder_sync/My Project/Application.myapp new file mode 100644 index 0000000..602de37 --- /dev/null +++ b/signFLOW_Folder_sync/My Project/Application.myapp @@ -0,0 +1,10 @@ + + + false + false + 0 + true + 0 + 3 + true + diff --git a/signFLOW_Folder_sync/My Project/AssemblyInfo.vb b/signFLOW_Folder_sync/My Project/AssemblyInfo.vb new file mode 100644 index 0000000..2c77c0f --- /dev/null +++ b/signFLOW_Folder_sync/My Project/AssemblyInfo.vb @@ -0,0 +1,35 @@ +Imports System +Imports System.Reflection +Imports System.Runtime.InteropServices + +' Allgemeine Informationen über eine Assembly werden über die folgenden +' Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +' die einer Assembly zugeordnet sind. + +' Werte der Assemblyattribute überprüfen + + + + + + + + + + +'Die folgende GUID wird für die typelib-ID verwendet, wenn dieses Projekt für COM verfügbar gemacht wird. + + +' Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +' +' Hauptversion +' Nebenversion +' Buildnummer +' Revision +' +' Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +' indem Sie "*" wie unten gezeigt eingeben: +' + + + diff --git a/signFLOW_Folder_sync/My Project/Resources.Designer.vb b/signFLOW_Folder_sync/My Project/Resources.Designer.vb new file mode 100644 index 0000000..bb79bd5 --- /dev/null +++ b/signFLOW_Folder_sync/My Project/Resources.Designer.vb @@ -0,0 +1,62 @@ +'------------------------------------------------------------------------------ +' +' This code was generated by a tool. +' Runtime Version:4.0.30319.42000 +' +' Changes to this file may cause incorrect behavior and will be lost if +' the code is regenerated. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My.Resources + + 'This class was auto-generated by the StronglyTypedResourceBuilder + 'class via a tool like ResGen or Visual Studio. + 'To add or remove a member, edit your .ResX file then rerun ResGen + 'with the /str option, or rebuild your VS project. + ''' + ''' A strongly-typed resource class, for looking up localized strings, etc. + ''' + _ + Friend Module Resources + + Private resourceMan As Global.System.Resources.ResourceManager + + Private resourceCulture As Global.System.Globalization.CultureInfo + + ''' + ''' Returns the cached ResourceManager instance used by this class. + ''' + _ + Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager + Get + If Object.ReferenceEquals(resourceMan, Nothing) Then + Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("signFLOW_Folder_sync.Resources", GetType(Resources).Assembly) + resourceMan = temp + End If + Return resourceMan + End Get + End Property + + ''' + ''' Overrides the current thread's CurrentUICulture property for all + ''' resource lookups using this strongly typed resource class. + ''' + _ + Friend Property Culture() As Global.System.Globalization.CultureInfo + Get + Return resourceCulture + End Get + Set(ByVal value As Global.System.Globalization.CultureInfo) + resourceCulture = value + End Set + End Property + End Module +End Namespace diff --git a/signFLOW_Folder_sync/My Project/Resources.resx b/signFLOW_Folder_sync/My Project/Resources.resx new file mode 100644 index 0000000..af7dbeb --- /dev/null +++ b/signFLOW_Folder_sync/My Project/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/signFLOW_Folder_sync/My Project/Settings.Designer.vb b/signFLOW_Folder_sync/My Project/Settings.Designer.vb new file mode 100644 index 0000000..426bfe5 --- /dev/null +++ b/signFLOW_Folder_sync/My Project/Settings.Designer.vb @@ -0,0 +1,130 @@ +'------------------------------------------------------------------------------ +' +' Dieser Code wurde von einem Tool generiert. +' Laufzeitversion:4.0.30319.42000 +' +' Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +' der Code erneut generiert wird. +' +'------------------------------------------------------------------------------ + +Option Strict On +Option Explicit On + + +Namespace My + + _ + Partial Friend NotInheritable Class MySettings + Inherits Global.System.Configuration.ApplicationSettingsBase + + Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings()),MySettings) + +#Region "Automatische My.Settings-Speicherfunktion" +#If _MyType = "WindowsForms" Then + Private Shared addedHandler As Boolean + + Private Shared addedHandlerLockObject As New Object + + _ + Private Shared Sub AutoSaveSettings(sender As Global.System.Object, e As Global.System.EventArgs) + If My.Application.SaveMySettingsOnExit Then + My.Settings.Save() + End If + End Sub +#End If +#End Region + + Public Shared ReadOnly Property [Default]() As MySettings + Get + +#If _MyType = "WindowsForms" Then + If Not addedHandler Then + SyncLock addedHandlerLockObject + If Not addedHandler Then + AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings + addedHandler = True + End If + End SyncLock + End If +#End If + Return defaultInstance + End Get + End Property + + _ + Public ReadOnly Property TimerIntervall() As Integer + Get + Return CType(Me("TimerIntervall"),Integer) + End Get + End Property + + _ + Public ReadOnly Property DD_ECM_CS() As String + Get + Return CType(Me("DD_ECM_CS"),String) + End Get + End Property + + _ + Public ReadOnly Property Select_Status1_Send() As String + Get + Return CType(Me("Select_Status1_Send"),String) + End Get + End Property + + _ + Public ReadOnly Property NetUse_Usr() As String + Get + Return CType(Me("NetUse_Usr"),String) + End Get + End Property + + _ + Public ReadOnly Property NetUse_PW() As String + Get + Return CType(Me("NetUse_PW"),String) + End Get + End Property + + _ + Public ReadOnly Property DEBUG() As Boolean + Get + Return CType(Me("DEBUG"),Boolean) + End Get + End Property + End Class +End Namespace + +Namespace My + + _ + Friend Module MySettingsProperty + + _ + Friend ReadOnly Property Settings() As Global.signFLOW_Folder_sync.My.MySettings + Get + Return Global.signFLOW_Folder_sync.My.MySettings.Default + End Get + End Property + End Module +End Namespace diff --git a/signFLOW_Folder_sync/My Project/Settings.settings b/signFLOW_Folder_sync/My Project/Settings.settings new file mode 100644 index 0000000..9a8402b --- /dev/null +++ b/signFLOW_Folder_sync/My Project/Settings.settings @@ -0,0 +1,30 @@ + + + + + + 1 + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <ConnectionString>Data Source=SDD-VMP04-SQL17\DD_DEVELOP01;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=dd</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=SDD-VMP04-SQL17\DD_DEVELOP01;Initial Catalog=DD_ECM;Persist Security Info=True;User ID=sa;Password=dd + + + SELECT GUID, [ENVELOPE_UUID] + FROM [DD_ECM].[dbo].[TBSIG_ENVELOPE] where STATUS = 1004 and DMZ_MOVED = 0 + + + sd + + + sd + + + True + + + \ No newline at end of file diff --git a/signFLOW_Folder_sync/ProjectInstaller.Designer.vb b/signFLOW_Folder_sync/ProjectInstaller.Designer.vb new file mode 100644 index 0000000..f52cfeb --- /dev/null +++ b/signFLOW_Folder_sync/ProjectInstaller.Designer.vb @@ -0,0 +1,48 @@ + Partial Class ProjectInstaller + Inherits System.Configuration.Install.Installer + + 'Installer überschreibt den Löschvorgang zum Bereinigen der Komponentenliste. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Wird vom Komponenten-Designer benötigt. + Private components As System.ComponentModel.IContainer + + 'Hinweis: Die folgende Prozedur ist für den Komponenten-Designer erforderlich. + 'Das Bearbeiten ist mit dem Komponenten-Designer möglich. + 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. + _ + Private Sub InitializeComponent() + Me.ServiceProcessInstaller1 = New System.ServiceProcess.ServiceProcessInstaller() + Me.ServiceInstaller1 = New System.ServiceProcess.ServiceInstaller() + ' + 'ServiceProcessInstaller1 + ' + Me.ServiceProcessInstaller1.Account = System.ServiceProcess.ServiceAccount.LocalService + Me.ServiceProcessInstaller1.Password = Nothing + Me.ServiceProcessInstaller1.Username = Nothing + ' + 'ServiceInstaller1 + ' + Me.ServiceInstaller1.Description = "Syncronizes all folders between DMZ and network" + Me.ServiceInstaller1.DisplayName = "DDsignFLOW_FolderSync" + Me.ServiceInstaller1.ServiceName = "DDsignFLOW_FolderSync" + Me.ServiceInstaller1.StartType = System.ServiceProcess.ServiceStartMode.Automatic + ' + 'ProjectInstaller + ' + Me.Installers.AddRange(New System.Configuration.Install.Installer() {Me.ServiceProcessInstaller1, Me.ServiceInstaller1}) + + End Sub + + Friend WithEvents ServiceProcessInstaller1 As ServiceProcess.ServiceProcessInstaller + Friend WithEvents ServiceInstaller1 As ServiceProcess.ServiceInstaller +End Class diff --git a/signFLOW_Folder_sync/ProjectInstaller.resx b/signFLOW_Folder_sync/ProjectInstaller.resx new file mode 100644 index 0000000..e1b81e8 --- /dev/null +++ b/signFLOW_Folder_sync/ProjectInstaller.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 56 + + + 197, 17 + + + False + + \ No newline at end of file diff --git a/signFLOW_Folder_sync/ProjectInstaller.vb b/signFLOW_Folder_sync/ProjectInstaller.vb new file mode 100644 index 0000000..733dfc0 --- /dev/null +++ b/signFLOW_Folder_sync/ProjectInstaller.vb @@ -0,0 +1,16 @@ +Imports System.ComponentModel +Imports System.Configuration.Install + +Public Class ProjectInstaller + + Public Sub New() + MyBase.New() + + 'Dieser Aufruf ist für den Komponenten-Designer erforderlich. + InitializeComponent() + + 'Initialisierungscode nach dem Aufruf von InitializeComponent hinzufügen + + End Sub + +End Class diff --git a/signFLOW_Folder_sync/Service1.Designer.vb b/signFLOW_Folder_sync/Service1.Designer.vb new file mode 100644 index 0000000..038ed6c --- /dev/null +++ b/signFLOW_Folder_sync/Service1.Designer.vb @@ -0,0 +1,52 @@ +Imports System.ServiceProcess + + _ +Partial Class MyService + Inherits System.ServiceProcess.ServiceBase + + 'UserService überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + ' Der Haupteinstiegspunkt für den Prozess + _ + _ + Shared Sub Main() + Dim ServicesToRun() As System.ServiceProcess.ServiceBase + + ' Innerhalb eines Prozesses können mehrere NT-Dienste ausgeführt werden. Um einen + ' weiteren Dienst zu diesem Prozess hinzuzufügen, ändern Sie die folgende Zeile, + ' um ein zweites Dienstobjekt zu erstellen. Zum Beispiel + ' + ' ServicesToRun = New System.ServiceProcess.ServiceBase () {New Service1, New MySecondUserService} + ' + ServicesToRun = New System.ServiceProcess.ServiceBase() {New MyService} + + System.ServiceProcess.ServiceBase.Run(ServicesToRun) + End Sub + + 'Wird vom Komponenten-Designer benötigt. + Private components As System.ComponentModel.IContainer + + ' Hinweis: Die folgende Prozedur ist für den Komponenten-Designer erforderlich. + ' Das Bearbeiten ist mit dem Komponenten-Designer möglich. + ' Das Bearbeiten mit dem Code-Editor ist nicht möglich. + + Private Sub InitializeComponent() + ' + 'MyService + ' + Me.AutoLog = False + Me.ServiceName = "DDsignFLOW_FolderSync" + + End Sub + +End Class diff --git a/signFLOW_Folder_sync/Service1.resx b/signFLOW_Folder_sync/Service1.resx new file mode 100644 index 0000000..e5858cc --- /dev/null +++ b/signFLOW_Folder_sync/Service1.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + False + + \ No newline at end of file diff --git a/signFLOW_Folder_sync/Service1.vb b/signFLOW_Folder_sync/Service1.vb new file mode 100644 index 0000000..a0aaeca --- /dev/null +++ b/signFLOW_Folder_sync/Service1.vb @@ -0,0 +1,245 @@ +Imports DigitalData.Modules.Database +Imports DigitalData.Modules.Logging +Imports System.ComponentModel +Imports System.IO +Imports System.Security.Cryptography +Imports System.Text + +Public Class MyService +#Region "+++++ variables +++++" + Private _threadRunner As BackgroundWorker + Private MyLogger As LogConfig + Private Logger As Logger + Private Database_ECM As MSSQLServer = Nothing + Private DT_CONFIG As DataTable + Private oENVELOPE_ID As Integer = 0 + Private oENVELOPE_UUID As String = "" + Private Directory2Delete As String = "" + Private DOCUMENT_PATH_MOVE_AFTSEND As String = "" + Private DOCUMENT_PATH As String = "" + Private FILE_NAME As String = "" +#End Region + Protected Overrides Sub OnStart(ByVal args() As String) + Try + MyLogger = New LogConfig(LogConfig.PathType.CustomPath, Path.Combine(My.Application.Info.DirectoryPath, "Log"), Nothing, "Digital Data", "DDsignFLOWFolderSync") + Logger = MyLogger.GetLogger + MyLogger.Debug = My.Settings.DEBUG + Database_ECM = New MSSQLServer(MyLogger, My.Settings.DD_ECM_CS) + If Database_ECM.DBInitialized = False Then + Logger.Warn("ATTENTION: No Connection was established - Check Config") + Else + DT_CONFIG = Database_ECM.GetDatatable("SELECT * FROM TBSIG_CONFIG ") + DOCUMENT_PATH_MOVE_AFTSEND = DT_CONFIG.Rows(0).Item("DOCUMENT_PATH_MOVE_AFTSEND") + DOCUMENT_PATH = DT_CONFIG.Rows(0).Item("DOCUMENT_PATH") + '### Thread für das nachträgliche Setzen von Rechten generieren + _threadRunner = New BackgroundWorker() + _threadRunner.WorkerReportsProgress = True + _threadRunner.WorkerSupportsCancellation = True + AddHandler _threadRunner.DoWork, AddressOf RUN_THREAD + AddHandler _threadRunner.RunWorkerCompleted, AddressOf Thread1_Completed + '### Den Timer generieren + Dim Timer_Durchlauf As New System.Timers.Timer() + 'Das Event hinterlegen welches bei "Tick" ausgelöst wird + AddHandler Timer_Durchlauf.Elapsed, AddressOf Thread_Run + ' Set the Interval + Timer_Durchlauf.Interval = (My.Settings.TimerIntervall * 60000) + Timer_Durchlauf.Enabled = True + Logger.Debug("...Timer started.") + ' Und den Durchlauf das erste Mal starten + _threadRunner.RunWorkerAsync() + End If + Catch ex As Exception + Logger.Error(ex) + End Try + End Sub + Public Sub Thread_Run() + If Not _threadRunner.IsBusy Then + _threadRunner.RunWorkerAsync() + End If + End Sub + Public Sub RUN_THREAD(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) + Try + Work_Envelopes() + Catch ex As Exception + Logger.Error(ex) + End Try + End Sub + Private Sub Work_Envelopes() + Try + Dim oDT_Envelopes As DataTable = Database_ECM.GetDatatable(My.Settings.Select_Status1_Send) + oENVELOPE_ID = 0 + If Not IsNothing(oDT_Envelopes) Then + + For Each oRow As DataRow In oDT_Envelopes.Rows + oENVELOPE_ID = 0 + oENVELOPE_UUID = "" + oENVELOPE_UUID = oRow.Item("ENVELOPE_UUID") + oENVELOPE_ID = oRow.Item("GUID") + Logger.Info($"Working on Envelope-UUID [{oENVELOPE_UUID}] - ENVELOPE_ID: {oENVELOPE_ID}") + Dim oSourcePath As String + Dim oDestinationPath As String + Dim oDT_Files As DataTable = Database_ECM.GetDatatable("SELECT * FROM TBSIG_ENVELOPE_DOCUMENT where ENVELOPE_ID = " & oENVELOPE_ID) + If oDT_Files.Rows.Count > 0 Then + Logger.Debug("Working on [{0}] file(s) ", oDT_Files.Rows.Count) + For Each ofileRow As DataRow In oDT_Files.Rows + FILE_NAME = "" + FILE_NAME = ofileRow.Item("FILENAME") + oSourcePath = IO.Path.Combine(DOCUMENT_PATH, oENVELOPE_UUID, FILE_NAME) + oDestinationPath = IO.Path.Combine(DOCUMENT_PATH_MOVE_AFTSEND, oENVELOPE_UUID) + If CopyFileWithNetUse(oSourcePath, oDestinationPath) = True Then + Database_ECM.ExecuteNonQuery($"UPDATE TBSIG_ENVELOPE SET DMZ_MOVED = 1 WHERE GUID = {oENVELOPE_ID}") + If Directory2Delete <> String.Empty Then + Logger.Debug("Now Deleting SourcePath: {0} ...", Directory2Delete) + Try + System.IO.Directory.Delete(Directory2Delete, True) + Logger.Debug("Successfully deleted Sourcepath!") + Catch ex As Exception + Logger.Warn($"Unexpected Error while deleting SourcePath {Directory2Delete}") + Logger.Warn("ErrorMessage: {0}", ex.Message) + End Try + + End If + End If + Next + End If + Next + End If + Catch ex As Exception + Logger.Error(ex) + End Try + End Sub + Private Shared key As String = "$xzBvyPETUS&amm8)D8x#)f;4%;?[BPd" ' Passwort-Schlüssel (16, 24, or 32 bytes) + Private Shared iv As String = "1wN&e[zrQ6_B7X/0" ' Initialisierungsvektor (16 bytes) + + + ' Entschlüsselungsfunktion + Private Function Decrypt(cipherText As String) As String + 'Logger.Debug("cipherText: {0}", cipherText) + ' Logger.Debug("Aes.Create ...") + Dim aesAlg As Aes = Aes.Create() + ' Logger.Debug("Encoding UTF8 GetBytes key ...") + aesAlg.Key = Encoding.UTF8.GetBytes(key) + 'Logger.Debug("Encoding UTF8 GetBytes iv ...") + aesAlg.IV = Encoding.UTF8.GetBytes(iv) + 'Logger.Debug("aesAlg.CreateDecryptor ...") + Dim decryptor As ICryptoTransform = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV) + 'Logger.Debug("Convert.FromBase64String ...") + Dim cipherBytes As Byte() = Convert.FromBase64String(cipherText) + + Dim msDecrypt As New IO.MemoryStream(cipherBytes) + Using csDecrypt As New CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read) + Using srDecrypt As New IO.StreamReader(csDecrypt) + Return srDecrypt.ReadToEnd() + End Using + End Using + End Function + Private Function CopyFileWithNetUse(pSourcePath As String, pDestinationPath As String) As Boolean + Logger.Debug("EXECUTING CopyFileWithNetUse for " & pDestinationPath) + Dim oDirectoryExists As Boolean = False + Try + If Directory.Exists(DOCUMENT_PATH_MOVE_AFTSEND) Then + Logger.Debug($"Access to [{DOCUMENT_PATH_MOVE_AFTSEND}] already succeeded!") + oDirectoryExists = True + End If + Catch ex As Exception + Logger.Warn("CopyFileWithNetUse - path not accessible or existing: {0}", ex.Message) + Logger.Error(ex) + End Try + Logger.Debug("CopyFileWithNetUse - Folder accessible [{0}]", oDirectoryExists.ToString) + + If oDirectoryExists = False Then + Dim oDectryptedPW = Decrypt(My.Settings.NetUse_PW) + Logger.Debug("Successfully decrypted PW!") + Dim netUseCommand As String = $"net use {DOCUMENT_PATH_MOVE_AFTSEND} /user:{My.Settings.NetUse_Usr} {oDectryptedPW}" + Dim processInfo As New ProcessStartInfo("cmd.exe", $"/C {netUseCommand}") + processInfo.RedirectStandardOutput = True + processInfo.RedirectStandardInput = True + processInfo.UseShellExecute = False + processInfo.CreateNoWindow = True + Using oProcess As Process = Process.Start(processInfo) + oProcess.WaitForExit() + ' Prüfe den Rückgabewert des net use Befehls + If oProcess.ExitCode = 0 Then + ' Verschiebe die Datei + Try + Dim oReturn = COPY_TO_DMZ(pSourcePath, pDestinationPath) + oProcess.Close() + Return oReturn + Catch ex As Exception + oProcess.Close() + Logger.Warn($"Unexpected error in CopyFileWithNetUse [" & pDestinationPath + "]") + Logger.Warn(ex.Message) + Logger.Error(ex) + Return False + End Try + + Else + Logger.Warn("Error while connecting to network-path: " & pDestinationPath) + Return False + End If + End Using + Else + Return COPY_TO_DMZ(pSourcePath, pDestinationPath) + End If + End Function + Private Function COPY_TO_DMZ(pSourcePath As String, pDestinationPath As String) As Boolean + Try + Logger.Debug("EXECUTING COPY_TO_DMZ {0} ...", pDestinationPath) + Dim oFilename = System.IO.Path.GetFileName(pSourcePath) + Dim oFilePath As String = pSourcePath + Dim oSourceDirectory As String = Path.GetDirectoryName(oFilePath) + + Dim split As String() = oFilePath.Split("\") + Dim parentFolder As String = split(split.Length - 2) + If Not pDestinationPath.EndsWith(parentFolder) Then + pDestinationPath &= "\" + parentFolder + Logger.Debug("new oSourceDirectory = {0} ...", pDestinationPath) + End If + + If Not System.IO.Directory.Exists(pDestinationPath) Then + Logger.Debug("Creating Folder {0} ...", pDestinationPath) + System.IO.Directory.CreateDirectory(pDestinationPath) + Logger.Debug("...Folder successfully created!") + End If + If Not System.IO.Directory.Exists(pDestinationPath) Then + Logger.Warn("Folder {0} could not be created!", pDestinationPath) + Return False + End If + pDestinationPath &= "\" + oFilename + If File.Exists(pDestinationPath) Then + File.Delete(pDestinationPath) + End If + Logger.Debug("Now copying file ...") + Logger.Debug("from [{0}] ", pSourcePath) + Logger.Debug("to [{0}]... ", pDestinationPath) + System.IO.File.Copy(pSourcePath, pDestinationPath) + Logger.Info($"Successfully copied file to DMZ [{pDestinationPath}]") + Directory2Delete = oSourceDirectory + Return True + Catch ex As Exception + Logger.Warn("COPY_TO_DMZ - Unexpected error {0}", ex.Message) + Logger.Error(ex) + Return False + End Try + + End Function + Protected Overrides Sub OnStop() + ' Hier Code zum Ausführen erforderlicher Löschvorgänge zum Beenden des Dienstes einfügen. + Logger.Info("## Service was stopped manually. ##") + End Sub + Private Sub Thread1_Completed(ByVal sender As Object, ByVal e As System.ComponentModel.RunWorkerCompletedEventArgs) 'Handles threadDateiimport.RunWorkerCompleted + 'This event fires when the DoWork event completes + Try + Dim result As String = "" + If e.Cancelled Then + EventLog.WriteEntry("DDsignFLOWFolderSync", "The thread was cancelled!", EventLogEntryType.Error) + Logger.Warn("## The thread was cancelled.") + ElseIf e.Error IsNot Nothing Then + EventLog.WriteEntry("DDsignFLOWFolderSync", "Unexpected error in thread!", EventLogEntryType.Error) + Logger.Warn("Unexpected error in thread: " & e.Error.Message) + End If + Catch ex As Exception + Logger.Error(ex) + End Try + End Sub +End Class diff --git a/signFLOW_Folder_sync/packages.config b/signFLOW_Folder_sync/packages.config new file mode 100644 index 0000000..ce98cd2 --- /dev/null +++ b/signFLOW_Folder_sync/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/signFLOW_Folder_sync/signFLOW_Folder_sync.vbproj b/signFLOW_Folder_sync/signFLOW_Folder_sync.vbproj new file mode 100644 index 0000000..53cc186 --- /dev/null +++ b/signFLOW_Folder_sync/signFLOW_Folder_sync.vbproj @@ -0,0 +1,141 @@ + + + + + Debug + AnyCPU + {B362E61A-A4BF-4A95-A4D6-8FA79B476126} + WinExe + signFLOW_Folder_sync.MyService + signFLOW_Folder_sync + signFLOW_Folder_sync + 512 + Console + v4.6.2 + true + true + + + AnyCPU + true + full + true + true + bin\Debug\ + signFLOW_Folder_sync.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + AnyCPU + pdbonly + false + true + true + bin\Release\ + signFLOW_Folder_sync.xml + 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + + + On + + + Binary + + + Off + + + On + + + + ..\..\DDModules\Database\bin\Debug\DigitalData.Modules.Database.dll + + + ..\..\DDModules\Logging\bin\Debug\DigitalData.Modules.Logging.dll + + + ..\packages\NLog.5.0.5\lib\net46\NLog.dll + + + + + + + + + + + + + + + + + + + + + + + + + + + + True + Application.myapp + + + ProjectInstaller.vb + + + Component + + + Component + + + Service1.vb + + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + Designer + + + ProjectInstaller.vb + + + Service1.vb + + + + + MyApplicationCodeGenerator + Application.Designer.vb + + + SettingsSingleFileGenerator + My + Settings.Designer.vb + + + + + + \ No newline at end of file