Imports WINDREAMLib Imports DLLLicenseManager Imports DevExpress.LookAndFeel Imports System.Globalization Imports DevExpress.Utils Imports DevExpress.XtraGrid.Views.Grid.ViewInfo Imports DevExpress.XtraGrid.Views.Grid Public Class frmMain Private _windreamPM As ClassPMWindream Private UserLoggedin As Integer = 0 Private PROFILE_COUNT As Integer = 0 Private DTPROFIL As DataTable Private RedDocuments As Integer = 0 Private YellowDocuments As Integer = 0 Private GreenDocuments As Integer = 0 Private Sub frmProfiles_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing Try TBPM_USERTableAdapter.cmdLoginOut(False, Environment.MachineName, Environment.UserName) ClassLogger.Add("## ProcessManager beendet - " & Now, False) ClassLogger.Add("", False) Catch ex As Exception ClassLogger.Add("### Fehler bei LogOut") ClassLogger.Add("### Fehler: " & ex.Message) End Try Try ' Position und Größe speichern My.Settings.frmMainSize = Me.Size My.Settings.frmMainPosition = Me.Location My.Settings.Save() Catch ex As Exception ClassLogger.Add("Error in Save FormLayout: " & ex.Message) End Try Try Dim XMLPath = GetXML_LayoutName() GridViewProfile.SaveLayoutToXml(XMLPath) Catch ex As Exception End Try End Sub Private Sub frmProfiles_KeyUp(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp Select Case e.KeyCode Case Keys.F12 frmLicense.ShowDialog() End Select End Sub Private Sub frmProfiles_Load(sender As Object, e As System.EventArgs) Handles Me.Load UserLookAndFeel.Default.SetSkinStyle("VS2010") tslblVersion.Text = String.Format("Version {0}", My.Application.Info.Version.ToString) If ERROR_STATE = "NO DB-CONNECTION" Or ERROR_STATE = "FAILED DBCONNECTION" Then MsgBox("Bitte hinterlegen Sie die Datenbankverbindung in der Konfiguration!", MsgBoxStyle.Critical, "Fehlende Konfiguration:") frmKonfig.ShowDialog() End If Try If CultureInfo.CurrentUICulture.ThreeLetterISOLanguageName = "eng" Then ClassLogger.Add("## CurrentUICulture.Name: " & CultureInfo.CurrentUICulture.Name, False) IDX_DMS_ERSTELLT = "DMS Created" IDX_DMS_ERSTELLT_ZEIT = "DMS Created Time" My.Settings.Save() End If Catch ex As Exception MessageBox.Show("Fehler bei Laden der CurrentUICulture-Info!", "Achtung:", MessageBoxButtons.OK, MessageBoxIcon.Exclamation) End Try If Refresh_ConnectionString() = True Then Try tslblLicenses.Text = "Anzahl Lizenzen: " & LICENSE_COUNT 'userexists = TBPM_USERTableAdapter.CmdUser_exists(Environment.UserName) If ERROR_STATE = "NO USER" Then MsgBox("Achtung: Sie sind nicht für die Nutzung von ProcessManager freigegeben!" & vbNewLine & "Bitte setzen Sie sich mit dem Systembetreuer in Verbindung!", MsgBoxStyle.Critical, "Achtung:") Me.Close() Else ClassLogger.Add(">> Username: " & Environment.UserName, False) 'Wenn license abgelaufen und der User nicht admin ist! If LICENSE_EXPIRED = True Then If USER_IS_ADMIN = False Then Me.Close() End If End If If USER_IS_ADMIN = True Then tstrpbtn_Config.Visible = True Else tstrpbtn_Config.Visible = False End If 'Anzahl der eingeloggten User 'UserLoggedin = TBPM_USERTableAdapter.CmdGetAnzahl_loggedIn tslblUserLoggedin.Text = "Anzahl User eingeloggt: " & USERCOUNT_LOGGED_IN End If Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fehler bei User Check:") End Try Try tsstlblUser.Text = Environment.UserName LoadProfile_PM() Catch ex As System.Exception MsgBox("Fehler bei Laden des Formulars: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Achtung:") End Try If UniversalViewer = "" And Viewer = "uviewer" Then MsgBox("Definieren Sie wo UniversalViewer abgelegt wurde!", MsgBoxStyle.Critical, "Fehlende Konfiguration") frmKonfig.ShowDialog() End If Timer.Start() Check_Timer_Notification() Restore_Form_Position() End If End Sub Sub Check_Timer_Notification() If My.Settings.IntervallReminder <> 0 Then TimerReminder.Stop() TimerReminder.Interval = My.Settings.IntervallReminder * 60000 TimerReminder.Start() Else TimerReminder.Enabled = False TimerReminder.Stop() End If End Sub Sub Restore_Form_Position() Try ' Sind Werte hinterlegt? If My.Settings.frmMainPosition.IsEmpty = False Then If My.Settings.frmMainPosition.X > 0 And My.Settings.frmMainPosition.Y > 0 Then ' Gespeicherte Werte verwenden Me.Location = My.Settings.frmMainPosition End If End If ' Sind Werte hinterlegt? If Not My.Settings.frmMainSize.IsEmpty Then ' Gespeicherte Werte verwenden Me.Size = My.Settings.frmMainSize End If Catch ex As Exception ClassLogger.Add("Error in Load FormLayout: " & ex.Message) End Try End Sub Function Refresh_ConnectionString() Try TBPM_KONFIGURATIONTableAdapter.Connection.ConnectionString = MyConnectionString Me.TBPM_PROFILETableAdapter.Connection.ConnectionString = MyConnectionString Me.TBPM_USERTableAdapter.Connection.ConnectionString = MyConnectionString Me.VWPM_PROFILE_USERTableAdapter.Connection.ConnectionString = MyConnectionString Me.TBPM_PROFILE_FILESTableAdapter.Connection.ConnectionString = MyConnectionString Return True Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Fehler bei Refresh_ConnectionString:") Return False End Try End Function Private Function GetXML_LayoutName() Dim Filename As String = String.Format("GridViewProfiles_UserLayout.xml") Return System.IO.Path.Combine(Application.UserAppDataPath(), Filename) End Function Sub LoadProfile_PM() Try If Me.Visible = True And frmProfileDesigner.Visible = False Then DTPROFIL = ClassDatabase.Return_Datatable("SELECT * FROM TBPM_PROFILE WHERE GUID = " & CURRENT_ProfilGUID) PROFILE_COUNT = 0 Dim sql = CURRENT_DT_CONFIG.Rows(0).Item("SQL_PROFILE_MAIN_VIEW") sql = sql.replace("@USER", Environment.UserName) sql = sql.replace("@MACHINE_NAME", Environment.MachineName) sql = sql.replace("@DATE", Now.ToShortDateString) 'String.Format("SELECT '1' TL_STATE,T.PROFIL_ID,T1.TITLE, T.DOC_ID, T.FILE_PATH, T.DMS_ERSTELLT_DATE,[dbo].[FNPM_LAST_WORKUSER_DOC] (T.PROFIL_ID,T.DOC_ID) AS 'Last User',[dbo].[FNPM_LAST_EDITED_DOC] (T.PROFIL_ID,T.DOC_ID) as 'Last edited' FROM TBPM_PROFILE_FILES T, VWPM_PROFILE_USER T1 " & ' "WHERE T.PROFIL_ID = T1.PROFIL_ID " & ' "AND T1.ACTIVE = 1 And (UPPER(T1.USERNAME) = UPPER('{0}')) Order By T1.PRIORITY", Environment.UserName) Dim DTGRID As DataTable = ClassDatabase.Return_Datatable(sql, True) If Not IsNothing(DTGRID) Then ' Spalte für Status Icon erstellen Dim columnStateIcon As New DataColumn() columnStateIcon.DataType = GetType(Image) columnStateIcon.ColumnName = "ICON" columnStateIcon.Caption = "" DTGRID.Columns.Add(columnStateIcon) RedDocuments = 0 YellowDocuments = 0 GreenDocuments = 0 For Each row As DataRow In DTGRID.Rows Dim State As Integer = row.Item("TL_STATE") Select Case State Case 1 RedDocuments += 1 row.Item("ICON") = My.Resources.ampel_rot Case 2 YellowDocuments += 1 row.Item("ICON") = My.Resources.ampel_gelb Case 3 GreenDocuments += 1 row.Item("ICON") = My.Resources.ampel_gruen End Select Next GridControlProfile.DataSource = DTGRID 'GridControlProfile.ForceInitialize() Try Dim XMLPath = GetXML_LayoutName() GridViewProfile.RestoreLayoutFromXml(XMLPath) Catch ex As Exception End Try Try GridViewProfile.Columns.Item("TITLE").GroupIndex = 0 GridViewProfile.Columns.Item("TITLE").Visible = False GridViewProfile.Columns.Item("PROFILE_ID").Visible = False GridViewProfile.Columns.Item("FULL_FILE_PATH").Visible = False GridViewProfile.Columns.Item("DOC_ID").Visible = False GridViewProfile.Columns.Item("ICON").MaxWidth = 24 GridViewProfile.Columns.Item("ICON").MinWidth = 24 GridViewProfile.Columns.Item("ICON").AppearanceCell.BackColor = Color.White GridViewProfile.Columns.Item("TL_STATE").SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Max GridViewProfile.Columns.Item("TL_STATE").SummaryItem.DisplayFormat = "Max: {0}" GridViewProfile.Columns.Item("TL_STATE").SummaryItem.FieldName = "TL_STATE" GridViewProfile.Columns("Last edited").DisplayFormat.FormatType = FormatType.DateTime GridViewProfile.Columns("Last edited").DisplayFormat.FormatString = "dd.MM.yyyy HH:MM:ss" 'GridViewProfile.OptionsBehavior.AlignGroupSummaryInGroupRow = True GridViewProfile.OptionsView.ShowGroupPanel = False GridViewProfile.OptionsBehavior.AutoExpandAllGroups = True Catch ex As Exception ClassLogger.Add("Unexpected Error in Formatting Grid: " & ex.Message) End Try Else GridControlProfile.DataSource = Nothing Try GridViewProfile.Columns.Clear() Catch ex As Exception End Try End If Me.VWPM_PROFILE_USERTableAdapter.FillByActive(Me.DD_DMSLiteDataSet.VWPM_PROFILE_USER, Environment.UserName) Dim DT As DataTable = DD_DMSLiteDataSet.Tables("VWPM_PROFILE_USER") If LogErrorsOnly = False Then ClassLogger.Add("", False) If DT.Rows.Count > 0 Then For Each row As DataRow In DT.Rows ' If LogErrorsOnly = False Then ClassLogger.Add("## Profil zugeordnet: " & row.Item("PROFIL_NAME"), False) Dim anz As Integer = TBPM_PROFILE_FILESTableAdapter.cmdGet_Anzahl(row.Item("PROFIL_ID")) If anz > 0 Then Dim img As Integer If CBool(row.Item("Active")) = True Then img = 0 Else img = 1 End If PROFILE_COUNT += 1 Else ClassLogger.Add(">> Keine Dateien für Profil '" & row.Item("TITLE").ToString & "' vorhanden!!", False) End If Next Else ClassLogger.Add(" >> KEINE PROFILE FÜR USER: '" & Environment.UserName & "' hinterlegt?!", False) MsgBox("KEINE PROFILE FÜR USER: '" & Environment.UserName & "' hinterlegt", MsgBoxStyle.Exclamation, "Achtung:") End If End If Catch ex As Exception ClassLogger.Add("LoadProfile_PM - Fehler: " & ex.Message) MsgBox("Fehler LoadProfile_PM - Fehler: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Achtung:") End Try End Sub Private Function file_exists(ByVal _file As String) Try If System.IO.File.Exists(_file) Then Return True Else Return False End If Catch ex As Exception MsgBox("Fehler in Funktion bei file_exists - Fehler: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Achtung:") Return False End Try End Function Private Sub ListViewProfile_DoubleClick(sender As System.Object, e As System.EventArgs) End Sub Private Sub tsbtnStartValidation_Click(sender As System.Object, e As System.EventArgs) Handles tsbtnStartValidation.Click End Sub Private Sub ToolStripButton1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton1.Click Try frmKonfig.ShowDialog() Refresh_ConnectionString() ' Load_Profil() Check_Timer_Notification() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical, "Fehler beim Laden Grundeinstellungen:") End Try End Sub Private Sub NotifyIcon1_MouseDoubleClick(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseDoubleClick Me.BringToFront() Me.Visible = True End Sub Private Sub Timer_Tick(sender As System.Object, e As System.EventArgs) Handles Timer.Tick LoadProfile_PM() End Sub Private Sub NotifyIcon1_Click(sender As System.Object, e As System.EventArgs) Handles NotifyIcon1.Click Me.BringToFront() Me.Visible = True End Sub Private Sub ToolStripButton2_Click(sender As System.Object, e As System.EventArgs) Handles tstrpbtn_Config.Click Dim AdminSecurity As Boolean = False AdminSecurity = TBPM_KONFIGURATIONTableAdapter.cmdGetAdminSecurity() If AdminSecurity = True Then frmLoginAdmin.ShowDialog() Else frmProfileDesigner.ShowDialog() End If LoadProfile_PM() End Sub Private Sub ToolStripButton2_Click_1(sender As Object, e As EventArgs) Handles tsbtnrefresh.Click LoadProfile_PM() End Sub Private Sub ToolStripButton2_Click_2(sender As Object, e As EventArgs) frmAdminPasswort.ShowDialog() End Sub Private Sub ToolStripButton2_Click_3(sender As Object, e As EventArgs) Handles ToolStripButton2.Click frmAbout.ShowDialog() End Sub Public Sub New() Dim splash As New frmSplash() splash.ShowDialog() ' Dieser Aufruf ist für den Designer erforderlich. InitializeComponent() ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. End Sub Private Sub TimerReminder_Tick(sender As Object, e As EventArgs) Handles TimerReminder.Tick If PROFILE_COUNT > 0 Then NotifyIcon1.ShowBalloonTip(30000, "Validation-Reminder", "Sie haben unerledigte Dokumente in Ihrem Verantwortungsbereich.", ToolTipIcon.Info) End Sub Private Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown End Sub Private Sub GridViewProfile_DoubleClick(sender As Object, e As EventArgs) Handles GridViewProfile.DoubleClick Try Dim PROFIL_ID = GridViewProfile.GetFocusedRowCellValue(GridViewProfile.Columns("PROFIL_ID")) If IsNumeric(PROFIL_ID) Then Load_Profil_from_Grid(PROFIL_ID) End If Catch ex As Exception End Try End Sub Sub Load_Profil_from_Grid(ID As Integer) Try Me.Visible = False CURRENT_ProfilGUID = ID CURRENT_ProfilName = ClassDatabase.Execute_Scalar("SELECT NAME FROM TBPM_PROFILE WHERE GUID = " & CURRENT_ProfilGUID, MyConnectionString) My.Settings.Save() frmValidator.ShowDialog() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try Me.Visible = True LoadProfile_PM() End Sub Private Sub GridViewProfile_CustomDrawGroupRow(sender As Object, e As DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs) Handles GridViewProfile.CustomDrawGroupRow Dim info As GridGroupRowInfo = TryCast(e.Info, GridGroupRowInfo) Dim view As GridView = sender If info.Column.FieldName = "TITLE" Then info.GroupText = info.GroupValueText info.Appearance.BackColor = Color.LightGray End If End Sub Private Sub GridViewProfile_RowStyle(sender As Object, e As RowStyleEventArgs) Handles GridViewProfile.RowStyle Dim view As GridView = TryCast(sender, GridView) Dim row As DataRow = view.GetDataRow(e.RowHandle) If IsNothing(row) Then Exit Sub End If Dim state = row.Item("TL_STATE") e.HighPriority = True Select Case state Case 1 e.Appearance.BackColor = Color.LightSalmon Case 2 e.Appearance.BackColor = Color.LightGoldenrodYellow Case 3 e.Appearance.BackColor = Color.LightGreen End Select End Sub Private Sub GridViewProfile_Layout(sender As Object, e As EventArgs) Handles GridViewProfile.Layout Try Dim XMLPath = GetXML_LayoutName() GridViewProfile.SaveLayoutToXml(XMLPath) Catch ex As Exception End Try End Sub End Class