Imports DevExpress.LookAndFeel Imports System.Globalization Imports DevExpress.Utils Imports DevExpress.XtraGrid.Views.Grid.ViewInfo Imports DevExpress.XtraGrid.Views.Grid Imports DevExpress.XtraGrid Imports DevExpress.XtraNavBar Imports DevExpress.XtraGrid.Columns Imports DevExpress.XtraCharts Public Class frmMain Private _windreamPM As ClassPMWindream Private UserLoggedin As Integer = 0 Private PROFILE_COUNT As Integer = 0 Private CURR_DT_VWPM_PROFILE_ACTIVE As DataTable Private CURR_DT_PROFILEGRID As DataTable Private RedDocuments As Integer = 0 Private YellowDocuments As Integer = 0 Private GreenDocuments As Integer = 0 Private GridViewItem_Clicked = Nothing Private GridCursorLocation As Point Private GRID_LOAD_TYPE As String = "OVERVIEW" Private GRID_INV_COL_REMOVED As Boolean = False Private _windream As New ClassWindream_allgemein Private Sub frmProfiles_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Try ClassAllgemeineFunktionen.LoginOut("LOGOUT") 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() SaveGridLayout() Catch ex As Exception ClassLogger.Add("Error in Save FormLayout: " & ex.Message) 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 If LogErrorsOnly = False Then ClassLogger.Add(" >> Initializing MainForm....", False) Try UserLookAndFeel.Default.SetSkinStyle("VS2010") Catch ex As Exception End Try 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 If LogErrorsOnly = False Then ClassLogger.Add(" >> Initializing MainForm....", False) If ERROR_STATE = "NO USER" Then MsgBox("Achtung: Sie sind nicht in der Userverwaltung hinterlegt!" & vbNewLine & "Bitte setzen Sie sich mit dem Systembetreuer in Verbindung!", MsgBoxStyle.Critical, "Achtung:") Me.Close() ElseIf USER_IN_MODULE = False Then If USER_IS_ADMIN = False 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() End If 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 MsgBox("Achtung: Lizenz ist abgelaufen oder ungültig!" & vbNewLine & "Bitte setzen Sie sich mit dem Systembetreuer in Verbindung!", MsgBoxStyle.Critical, "Achtung:") 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 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 Decide_Load() Catch ex As 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 If TimerRefresh.Enabled = False Then TimerRefresh.Start() End If Load_Profile_items() Check_Timer_Notification() Restore_Form_Position() If LogErrorsOnly = False Then ClassLogger.Add(" >> MainForm initialized!", False) End If End Sub Sub Check_Timer_Notification() Try If My.Settings.IntervallReminder <> 0 Then TimerReminder.Stop() TimerReminder.Interval = My.Settings.IntervallReminder * 60000 TimerReminder.Start() Else TimerReminder.Enabled = False TimerReminder.Stop() End If Catch ex As Exception End Try 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 TBPM_PROFILETableAdapter.Connection.ConnectionString = MyConnectionString TBPM_USERTableAdapter.Connection.ConnectionString = MyConnectionString 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("GridView_Docs_UserLayout_{0}.xml", GRID_LOAD_TYPE) Return System.IO.Path.Combine(Application.UserAppDataPath(), Filename) End Function Private Sub SaveGridLayout() Try Dim xml As String = GetXML_LayoutName() Dim xmlDefault = xml & ".default" If IO.File.Exists(xmlDefault) = False Then GridView_Docs.SaveLayoutToXml(xmlDefault, OptionsLayoutBase.FullLayout) End If GridView_Docs.SaveLayoutToXml(xml, OptionsLayoutBase.FullLayout) Catch ex As Exception ClassLogger.Add("Error while saving GridLayout: " & ex.Message) End Try End Sub Private Sub RestoreLayout() Try Dim xml As String = GetXML_LayoutName() GridView_Docs.RestoreLayoutFromXml(xml, OptionsLayoutBase.FullLayout) Catch ex As Exception ClassLogger.Add("Error while restoring layout: " & ex.Message) End Try End Sub Private Sub ResetLayout() Try Dim xml As String = GetXML_LayoutName() Dim xmlDefault = xml & ".default" IO.File.Delete(xml) GridView_Docs.RestoreLayoutFromXml(xmlDefault, OptionsLayoutBase.FullLayout) Catch ex As Exception ClassLogger.Add("Error while resetting layout: " & ex.Message) End Try End Sub Sub Load_Profile_items() Cursor = Cursors.WaitCursor Try Dim CurrGroup As NavBarGroup = NavBarControl1.Groups(0) Try CurrGroup.ItemLinks.Clear() Catch ex As Exception ClassLogger.Add("CurrGroupClear - Error: " & ex.Message) End Try Load_Profiles_for_User() For Each profile As DataRow In CURR_DT_VWPM_PROFILE_ACTIVE.Rows Dim item1 As NavBarItem = NavBarControl1.Items.Add() item1.Caption = profile.Item("TITLE") item1.Tag = "itmProfile#" & profile.Item("GUID").ToString Dim _image As Image = Nothing _image = DevExpress.Images.ImageResourceCache.Default.GetImage("images/actions/add_16x16.png") item1.LargeImage = _image NavBarControl1.Groups(0).ItemLinks.Add(item1) AddHandler NavBarControl1.LinkClicked, AddressOf navBar_LinkClicked Next If GRID_LOAD_TYPE = "OVERVIEW" Then CurrGroup.Expanded = False End If Catch ex As Exception ClassLogger.Add("Load_Profile_items - Error: " & ex.Message) MsgBox("Unexpected Error in Load_Profile_items - Error: " & vbNewLine & ex.Message, MsgBoxStyle.Critical) End Try Cursor = Cursors.Default End Sub Private Sub navBar_LinkClicked(ByVal sender As Object, ByVal e As NavBarLinkEventArgs) ' Das aktuelle Layout speichern, bevor das neue geladen wird ' und GRID_LOAD_TYPE gesetzt wird. SaveGridLayout() Dim _tag = e.Link.Item.Tag If Not IsNothing(_tag) Then If _tag.ToString.Contains("itmProfile#") Then _tag = _tag.ToString.Replace("itmProfile#", "") If IsNumeric(_tag) Then If CURRENT_CLICKED_PROFILE_ID <> _tag Then CURRENT_CLICKED_PROFILE_ID = _tag CURRENT_CLICKED_PROFILE_TITLE = e.Link.Item.Caption GRID_LOAD_TYPE = "PROFILE#" & CURRENT_CLICKED_PROFILE_ID.ToString Load_single_Profile() End If End If End If End If End Sub Sub Load_Profiles_for_User() Try Dim sql = String.Format("SELECT T.* FROM VWPM_PROFILE_ACTIVE T WHERE T.GUID IN (SELECT PROFILE_ID FROM [dbo].[FNPM_GET_ACTIVE_PROFILES_USER] ({0}))", CURRENT_USER_ID) CURR_DT_VWPM_PROFILE_ACTIVE = ClassDatabase.Return_Datatable(sql) Catch ex As Exception ClassLogger.Add("Load_Profiles_for_User - Error: " & ex.Message) End Try End Sub Sub Layout_Single_Profile() If GridControl_Docs.Visible = False Then GridControl_Docs.Visible = True pnlNavigator.Visible = True SplitContainerDashboard.Visible = False End If End Sub Sub Layout_Dashboard() Try If GridControl_Docs.Visible = True Then GridControl_Docs.Visible = False pnlNavigator.Visible = False Dim groupCount As Integer Dim charts As List(Of ChartControl) SplitContainerDashboard.Visible = True Dim DT_CHARTS As DataTable Dim sql = "SELECT * FROM TBPM_CHART" DT_CHARTS = ClassDatabase.Return_Datatable(sql, True) Dim Groups As DataRowCollection = DT_CHARTS.Rows groupCount = Groups.Count Configure_Split_Containers(groupCount) charts = New List(Of ChartControl) From {ChartTopLeft, ChartTopRight, ChartBottomLeft, ChartBottomRight} If groupCount > 1 Then For Each gRow As DataRow In Groups Dim groupIndex As Integer = Groups.IndexOf(gRow) Dim groupName As String = gRow.Item("GROUP_ID") Dim groupCharts = DT_CHARTS.Select(String.Format("GROUP_ID = '{0}'", groupName)) Dim chart As ChartControl For Each cRow As DataRow In groupCharts Dim type = cRow.Item("TYPE_CHART") Dim title = cRow.Item("TITLE") Dim guid = cRow.Item("GUID") Dim value = cRow.Item("VALUE") Dim argument = cRow.Item("ARGUMENT") Dim sqlchart = cRow.Item("SQL_COMMAND") sqlchart = sqlchart.ToString.ToUpper.Replace("@USER", USER_USERNAME) Dim DATA_DT As DataTable = ClassDatabase.Return_Datatable(sqlchart) Dim series As Series = Create_Series(title, type) ' Select Current Chart chart = Select_Chart(groupIndex) chart = charts.Item(groupIndex) Try chart.Series.Clear() Catch ex As Exception End Try ' Set DataSource chart.DataSource = DATA_DT ' Set shown Columns for Chart series.ArgumentDataMember = argument series.ValueDataMembers.AddRange(New String() {value}) 'set some options chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True ' Show Data chart.Series.Add(series) Next ' End Charts Next 'End Groups Else ' Create Charts For Each row As DataRow In DT_CHARTS.Rows Dim chart As ChartControl Dim chartIndex As Integer = DT_CHARTS.Rows.IndexOf(row) Dim type = row.Item("TYPE_CHART") Dim title = row.Item("TITLE") Dim guid = row.Item("GUID") Dim value = row.Item("VALUE") Dim argument = row.Item("ARGUMENT") Dim sqlchart = row.Item("SQL_COMMAND") sqlchart = sqlchart.ToString.ToUpper.Replace("@USER_ID", CURRENT_USER_ID) sqlchart = sqlchart.ToString.ToUpper.Replace("@USER", USER_USERNAME) Dim DATA_DT As DataTable = ClassDatabase.Return_Datatable(sqlchart) ' Create Series based on type Dim series As Series = Create_Series(title, type) ' Select Current Chart chart = Select_Chart(chartIndex) Try chart.Series.Clear() Catch ex As Exception End Try ' Set DataSource chart.DataSource = DATA_DT ' Set shown Columns for Chart series.ArgumentDataMember = argument series.ValueDataMembers.AddRange(New String() {value}) 'set some options chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True chart.OptionsPrint.SizeMode = Printing.PrintSizeMode.Stretch ' Show Data chart.Series.Add(series) Next End If End If Catch ex As Exception ClassLogger.Add("Layout Dashboard - Error: " & ex.Message) MsgBox("Unexpected Error in Layout Dashboard - Error: " & vbNewLine & ex.Message, MsgBoxStyle.Critical) End Try End Sub Private Function Create_Series(title As String, type As String) As Series Dim series As Series Select Case type Case "BAR" series = New Series(title, ViewType.Bar) Case "LINE" series = New Series(title, ViewType.Line) Case "AREA" series = New Series(title, ViewType.Area) Case "PIE" series = New Series(title, ViewType.Pie) series.Label.TextPattern = "{A}: {VP:p0}" Dim view As PieSeriesView = DirectCast(series.View, PieSeriesView) view.Titles.Add(New SeriesTitle()) view.Titles(0).Text = title Case Else series = New Series(title, ViewType.Bar) End Select Return series End Function Private Function Select_Chart(index As Integer) Select Case index Case 0 Return ChartTopLeft Case 1 Return ChartTopRight Case 2 Return ChartBottomLeft Case Else Return ChartBottomRight End Select End Function Private Sub Configure_Split_Containers(VisibleContainers As Integer) Select Case VisibleContainers Case 1 ' Show only ChartTopLeft SplitContainerTop.Panel2Collapsed = True ' Collapse SplitContainerBottom SplitContainerDashboard.Panel2Collapsed = True Case 2 ' Collapse SplitContainerBottom SplitContainerDashboard.Panel2Collapsed = True Case 3 ' Collapse ChartBottomRight SplitContainerBottom.Panel2Collapsed = True ' Show SplitContainerBottom SplitContainerDashboard.Panel2Collapsed = False Case 4 ' Show SplitContainerBottom SplitContainerDashboard.Panel2Collapsed = False End Select End Sub Sub Load_single_Profile() Try Load_Profiles_for_User() Layout_Single_Profile() Dim expression As String expression = "GUID = " & CURRENT_CLICKED_PROFILE_ID Dim TEMP_TABLE = CURR_DT_VWPM_PROFILE_ACTIVE Dim foundRows() As DataRow foundRows = TEMP_TABLE.Select(expression) Dim result = 0 For i = 0 To foundRows.GetUpperBound(0) result += 1 Next If result = 1 Then lblViewType.Text = "Detailansicht Profil: " & CURRENT_CLICKED_PROFILE_TITLE Dim sql = foundRows(0)("SQL_VIEW") sql = sql.Replace("@USER_ID", CURRENT_USER_ID) sql = sql.Replace("@USERNAME", Environment.UserName) sql = sql.Replace("@MACHINE_NAME", Environment.MachineName) sql = sql.Replace("@DATE", Now.ToShortDateString) sql = sql.Replace("@PROFILE_ID", CURRENT_CLICKED_PROFILE_ID) CURR_DT_PROFILEGRID = ClassDatabase.Return_Datatable(sql, True) Create_Basic_View() Dim Columns_Removed = GridView_CheckInvalidColumns() RestoreLayout() lblViewType.Text = "Detailansicht Profil: " & CURRENT_CLICKED_PROFILE_TITLE End If Catch ex As Exception ClassLogger.Add("Load_single_Profile - Error: " & ex.Message) End Try End Sub Sub Create_Basic_View() GridControl_Docs.DataSource = Nothing Try GridView_Docs.Columns.Clear() Catch ex As Exception End Try ' Spalte für Status Icon erstellen Dim columnStateIcon As New DataColumn() columnStateIcon.DataType = GetType(Image) columnStateIcon.ColumnName = "ICON" columnStateIcon.Caption = "" CURR_DT_PROFILEGRID.Columns.Add(columnStateIcon) RedDocuments = 0 YellowDocuments = 0 GreenDocuments = 0 For Each row As DataRow In CURR_DT_PROFILEGRID.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 bindsourcegrid.DataSource = CURR_DT_PROFILEGRID GridControl_Docs.DataSource = bindsourcegrid 'GridControlDocRow.ForceInitialize() RestoreLayout() GridView_Docs.Columns.Item("PROFILE_ID").Visible = False GridView_Docs.Columns.Item("GUID").Visible = False GridView_Docs.Columns.Item("FULL_FILE_PATH").Visible = False GridView_Docs.Columns.Item("DOC_ID").Visible = False GridView_Docs.Columns.Item("TL_STATE").Visible = False GridView_Docs.Columns.Item("ICON").MaxWidth = 24 GridView_Docs.Columns.Item("ICON").MinWidth = 24 GridView_Docs.Columns.Item("ICON").AppearanceCell.BackColor = Color.White GridView_Docs.Columns.Item("ICON").Fixed = FixedStyle.Left GridView_Docs.Columns("Last edited").DisplayFormat.FormatType = FormatType.DateTime GridView_Docs.Columns("Last edited").DisplayFormat.FormatString = "dd.MM.yyyy HH:MM:ss" GridView_Docs.Columns.Item("PROFILE_GROUP_TEXT").Visible = False GridView_Docs.Columns.Item("PROFILE_GROUP_COLOR").Visible = False End Sub Private Function GridView_CheckInvalidColumns() As Boolean Dim Columns_Removed = False GRID_INV_COL_REMOVED = False Try For Each grid_column As GridColumn In GridView_Docs.Columns Dim GridDXCaption = grid_column.Caption Dim GridDXTextCaption = grid_column.GetTextCaption Dim GridDXColumnEditName = grid_column.ColumnEditName Dim GridDXFieldName = grid_column.FieldName Dim exists As Boolean = False For Each col As DataColumn In CURR_DT_PROFILEGRID.Columns If col.Caption = GridDXTextCaption Then exists = True Exit For End If Next If exists = False Then If grid_column.Visible = True Then Try grid_column.Dispose() Columns_Removed = True GRID_INV_COL_REMOVED = True Catch ex As Exception End Try End If End If Next Return Columns_Removed Catch ex As Exception ClassLogger.Add("Unexpected Error in GridView_CheckInvalidColumns: " & ex.Message) End Try End Function Sub LoadProfile_PM() Try If Me.Visible = True And frmAdministration.Visible = False Then Load_Profiles_for_User() PROFILE_COUNT = 0 ClassInit.InitBasics() Dim sql = CURRENT_DT_CONFIG.Rows(0).Item("SQL_PROFILE_MAIN_VIEW") sql = sql.Replace("@USER_ID", CURRENT_USER_ID) sql = sql.Replace("@USERNAME", Environment.UserName) sql = sql.Replace("@MACHINE_NAME", Environment.MachineName) sql = sql.Replace("@DATE", Now.ToShortDateString) sql = sql.Replace("@PROFILE_ID", CURRENT_CLICKED_PROFILE_ID) '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) CURR_DT_PROFILEGRID = ClassDatabase.Return_Datatable(sql, True) If Not IsNothing(CURR_DT_PROFILEGRID) Then Create_Basic_View() Try GridView_Docs.Columns.Item("PROFILE_GROUP_TEXT").GroupIndex = 0 GridView_Docs.Columns.Item("PROFILE_GROUP_TEXT").Visible = False GridView_Docs.Columns.Item("PROFILE_GROUP_COLOR").Visible = False For I = 0 To GridView_Docs.GroupCount - 1 Dim v = GridView_Docs.GroupedColumns(I).ToString Dim ii = Nothing GridView_Docs.GroupedColumns(I).Tag = GridView_Docs.Columns.Item("PROFILE_ID") Next GridView_Docs.OptionsBehavior.AutoExpandAllGroups = True GridView_Docs.OptionsView.ShowGroupedColumns = False Catch ex As Exception ClassLogger.Add("Unexpected Error in Formatting Grid: " & ex.Message) End Try Dim Columns_Removed = GridView_CheckInvalidColumns() RestoreLayout() Else GridControl_Docs.DataSource = Nothing Try GridView_Docs.Columns.Clear() Catch ex As Exception End Try 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 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 TimerRefresh.Tick Load_Profile_items() Decide_Load() tsslblLastSysnc.Text = "Letzte Synchronisation: " & Now.ToLongTimeString 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 Decide_Load() Try If USER_EXISTS = False Then Exit Sub End If If TimerRefresh.Enabled = True Then TimerRefresh.Stop() End If If GRID_LOAD_TYPE = "OVERVIEW" Then Load_Grid_Overview() ElseIf GRID_LOAD_TYPE.StartsWith("PROFILE#") Then Load_single_Profile() End If Catch ex As Exception ClassLogger.Add("Unexpected error in Decide_load: " & ex.Message) End Try If TimerRefresh.Enabled = False Then TimerRefresh.Start() End If 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 frmAdministration.ShowDialog() End If Decide_Load() End Sub Private Sub ToolStripButton2_Click_1(sender As Object, e As EventArgs) Handles tsbtnrefresh.Click Load_Profile_items() Decide_Load() 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() Try splash.ShowDialog() Catch ex As Exception ClassLogger.Add($"Error in Splash: {ex.Message}") End Try Try InitializeComponent() ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu. Catch ex As Exception ClassLogger.Add($"Error in InitializeComponent: {ex.Message}") End Try End Sub Private Sub TimerReminder_Tick(sender As Object, e As EventArgs) Handles TimerReminder.Tick If PROFILE_COUNT > 0 Then NotifyIcon1.ShowBalloonTip(30000, "ProcessManager-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 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) CURRENT_DT_PROFILE = ClassDatabase.Return_Datatable(String.Format("select * from TBPM_PROFILE where GUID = {0}", CURRENT_ProfilGUID)) My.Settings.Save() If TimerRefresh.Enabled Then TimerRefresh.Stop() End If frmValidator.ShowDialog() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Critical) End Try Me.Visible = True Decide_Load() End Sub Private Sub ContextMenuGrid_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuGrid.Opening CMFileStart.Enabled = False CMGroupStart.Enabled = False Select Case GridViewItem_Clicked Case "GROUP" CMGroupStart.Enabled = True Case "ROW" Dim selectedRows As Integer() = GridView_Docs.GetSelectedRows() If selectedRows.Count > 1 Then CMFileStart.Enabled = False Else CMFileStart.Enabled = True End If End Select End Sub Private Sub CMFileStart_Click(sender As Object, e As EventArgs) Handles CMFileStart.Click Item_Scope() End Sub Private Sub Item_Scope() Try CURRENT_JUMP_DOC_GUID = 0 Dim hitInfo As GridHitInfo = GridView_Docs.CalcHitInfo(GridCursorLocation) Dim groupRowText Dim PROFIL_ID If hitInfo.InGroupRow Then GridViewItem_Clicked = "GROUP" groupRowText = GridView_Docs.GetGroupRowDisplayText(hitInfo.RowHandle) PROFIL_ID = GridView_Docs.GetRowCellValue(GridView_Docs.GetDataRowHandleByGroupRowHandle(hitInfo.RowHandle), GridView_Docs.Columns("PROFILE_ID")) ElseIf hitInfo.InDataRow Then GridViewItem_Clicked = "ROW" If GRID_LOAD_TYPE = "OVERVIEW" Then groupRowText = GridView_Docs.GetGroupRowDisplayText(GridView_Docs.GetParentRowHandle(hitInfo.RowHandle)) PROFIL_ID = GridView_Docs.GetRowCellValue(GridView_Docs.GetDataRowHandleByGroupRowHandle(GridView_Docs.GetParentRowHandle(hitInfo.RowHandle)), GridView_Docs.Columns("PROFILE_ID")) Else PROFIL_ID = CURRENT_CLICKED_PROFILE_ID End If Else Exit Sub End If Dim PROFIL_TITLE If GRID_LOAD_TYPE = "OVERVIEW" Then groupRowText = LTrim(RTrim(groupRowText.ToString.Replace("PROFILE_GROUP_TEXT: ", ""))) Dim _SPLIT As String() _SPLIT = groupRowText.Split("|") PROFIL_TITLE = LTrim(RTrim(_SPLIT(0).ToString)) Else End If If Not IsNothing(PROFIL_ID) And IsNumeric(PROFIL_ID) Then Dim expression As String expression = "PROFILE_ID = " & PROFIL_ID If hitInfo.InGroupRow Then CURRENT_JUMP_DOC_GUID = 0 CURRENT_DOC_GUID = 0 CURRENT_ProfilGUID = PROFIL_ID Load_Profil_from_Grid(PROFIL_ID) ElseIf hitInfo.InDataRow Then Dim DOC_GUID = GridView_Docs.GetFocusedRowCellValue(GridView_Docs.Columns("GUID")) Dim DOC_ID = GridView_Docs.GetFocusedRowCellValue(GridView_Docs.Columns("DOC_ID")) If IsNothing(DOC_ID) Then Exit Sub Dim DOC_PATH = GridView_Docs.GetFocusedRowCellValue(GridView_Docs.Columns("FULL_FILE_PATH")) 'Checking if table really contains one record with profile-id and docid expression = expression & " AND DOC_ID = " & DOC_ID Dim TEMP_TABLE = CURR_DT_PROFILEGRID Dim foundRows() As DataRow foundRows = TEMP_TABLE.Select(expression) Dim result = 0 For i = 0 To foundRows.GetUpperBound(0) result += 1 Next If result = 1 Then CURRENT_DOC_ID = DOC_ID CURRENT_JUMP_DOC_GUID = DOC_GUID CURRENT_DOC_GUID = CURRENT_JUMP_DOC_GUID CURRENT_DOC_PATH = DOC_PATH Load_Profil_from_Grid(PROFIL_ID) Else Exit Sub End If End If End If Catch ex As Exception MsgBox("Unexpected error in Item_Scope: " & ex.Message, MsgBoxStyle.Critical) End Try End Sub Private Function Init_windream() Try _windream = New ClassWindream_allgemein _windream.Init() If LogErrorsOnly = False Then ClassLogger.Add(" >> windream initialized", False) Return True Catch ex As Exception MsgBox("Error Init_windream:" & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Attention:") ClassLogger.Add(">> Unexpected error in Init_windream: " & ex.Message, True) Return False End Try End Function Private Sub MarkierteDateienAbschliessenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles MarkierteDateienAbschliessenToolStripMenuItem.Click Dim selectedRows As Integer() = GridView_Docs.GetSelectedRows() Dim hitInfo As GridHitInfo = GridView_Docs.CalcHitInfo(GridCursorLocation) Dim workedFiles As Integer = 0 Dim dt As New DataTable dt.Columns.Add("DOC_ID") dt.Columns.Add("DOC_GUID") dt.Columns.Add("FULL_PATH") If Init_windream() = True Then CURRENT_ProfilGUID = 0 Dim i As Integer = 0 For Each rowhandle As Integer In selectedRows Dim R As DataRow = dt.NewRow Dim PROFILE_ID As Integer = 0 PROFILE_ID = GridView_Docs.GetRowCellValue(GridView_Docs.GetDataRowHandleByGroupRowHandle(GridView_Docs.GetParentRowHandle(hitInfo.RowHandle)), GridView_Docs.Columns("PROFILE_ID")) If i = 0 And CURRENT_ProfilGUID = 0 Then CURRENT_ProfilGUID = PROFILE_ID CURRENT_DT_FINAL_INDEXING = ClassDatabase.Return_Datatable(String.Format("select * from TBPM_PROFILE_FINAL_INDEXING where PROFIL_ID = {0}", CURRENT_ProfilGUID)) CURRENT_DT_PROFILE = ClassDatabase.Return_Datatable(String.Format("select * from TBPM_PROFILE where GUID = {0}", CURRENT_ProfilGUID)) CURRENT_PROFILE_VEKTOR_LOG = CURRENT_DT_PROFILE.Rows(0).Item("PM_VEKTOR_INDEX") If CURRENT_PROFILE_VEKTOR_LOG = "" Then CURRENT_PROFILE_VEKTOR_LOG = CURRENT_DT_PROFILE.Rows(0).Item("LOG_INDEX") End If End If If PROFILE_ID <> CURRENT_ProfilGUID Then If CURRENT_USER_LANGUAGE <> "de_DE" Then MsgBox("Sorry but You can only mass-validate docs which belong to he same profile!", MsgBoxStyle.Exclamation) Else MsgBox("Bitte bachten Sie dass Sie nur Dokumente, welche zum gleichen Profil gehören, mit der Massenfunktion bearbeiten können!", MsgBoxStyle.Exclamation) End If Exit Sub End If Dim DOC_ID = GridView_Docs.GetRowCellValue(rowhandle, "DOC_ID") CURRENT_DOC_ID = DOC_ID Dim DOC_PATH = GridView_Docs.GetRowCellValue(rowhandle, "FULL_FILE_PATH") CURRENT_DOC_PATH = DOC_PATH CURRENT_DOC_GUID = GridView_Docs.GetRowCellValue(rowhandle, "GUID") R("DOC_ID") = CURRENT_DOC_ID R("FULL_PATH") = CURRENT_DOC_PATH R("DOC_GUID") = GridView_Docs.GetRowCellValue(rowhandle, "GUID") dt.Rows.Add(R) CURRENT_DT_MASS_CHANGE_DOCS = Nothing CURRENT_DT_MASS_CHANGE_DOCS = dt Next End If frmMassValidator.ShowDialog() Load_Profile_items() Decide_Load() End Sub Private Sub CMGroupStart_Click(sender As Object, e As EventArgs) Handles CMGroupStart.Click Item_Scope() End Sub Private Sub NavBarItemOverview_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles NavBarItemOverview.LinkClicked ' Das aktuelle Layout speichern, bevor das neue geladen wird ' und GRID_LOAD_TYPE gesetzt wird. SaveGridLayout() Load_Grid_Overview() End Sub Sub Load_Grid_Overview() SplitContainerDashboard.Visible = False Layout_Single_Profile() GRID_LOAD_TYPE = "OVERVIEW" CURRENT_CLICKED_PROFILE_ID = 0 lblViewType.Text = "Gesamtübersicht" Cursor = Cursors.WaitCursor Try Dim sel = String.Format("SELECT * FROM VWPM_PROFILE_USER WHERE USER_ID ={0}", CURRENT_USER_ID) CURRENT_DT_VW_PROFILE_USER = ClassDatabase.Return_Datatable(sel, True) tslblmessage.Text = "" If CURRENT_DT_VW_PROFILE_USER.Rows.Count = 0 Then ClassLogger.Add(" >> no profiles for user: '" & Environment.UserName & "' configured!", False) tslblmessage.Text = "Keine Profile für Ihren User hinterlegt" Cursor = Cursors.Default Exit Sub End If Load_Profiles_for_User() PROFILE_COUNT = 0 ClassInit.InitBasics() Dim sql = CURRENT_DT_CONFIG.Rows(0).Item("SQL_PROFILE_MAIN_VIEW") If IsDBNull(sql) Then tslblmessage.Text = "No GROUP-CONFIG (SQL_PROFILE_MAIN_VIEW) in Baseconfig" Exit Sub End If sql = sql.Replace("@USER_ID", CURRENT_USER_ID) sql = sql.Replace("@USERNAME", Environment.UserName) sql = sql.Replace("@MACHINE_NAME", Environment.MachineName) sql = sql.Replace("@DATE", Now.ToShortDateString) sql = sql.Replace("@PROFILE_ID", CURRENT_CLICKED_PROFILE_ID) '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) CURR_DT_PROFILEGRID = ClassDatabase.Return_Datatable(sql, True) If Not IsNothing(CURR_DT_PROFILEGRID) Then If CURR_DT_PROFILEGRID.Rows.Count = 0 Then lblViewType.Text = "Aktuell keine Workflowdaten vorhanden!" 'MsgBox("Aktuell keine Workflowdaten vorhanden!", MsgBoxStyle.Information) GridControl_Docs.Visible = False pnlNavigator.Visible = False GridControl_Docs.DataSource = Nothing Try GridView_Docs.Columns.Clear() Catch ex As Exception End Try Cursor = Cursors.Default Exit Sub End If GridControl_Docs.Visible = True pnlNavigator.Visible = True ' Spalte für Status Icon erstellen Dim columnStateIcon As New DataColumn() columnStateIcon.DataType = GetType(Image) columnStateIcon.ColumnName = "ICON" columnStateIcon.Caption = "" CURR_DT_PROFILEGRID.Columns.Add(columnStateIcon) RedDocuments = 0 YellowDocuments = 0 GreenDocuments = 0 For Each row As DataRow In CURR_DT_PROFILEGRID.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 bindsourcegrid.DataSource = CURR_DT_PROFILEGRID GridControl_Docs.DataSource = bindsourcegrid lblViewType.Text = "Gesamtübersicht" 'GridControlDocRow.ForceInitialize() ' GridControl1.DataSource = CURR_DT_PROFILEGRID Dim Columns_Removed = GridView_CheckInvalidColumns() RestoreLayout() Try GridView_Docs.Columns.Item("PROFILE_GROUP_TEXT").GroupIndex = 0 GridView_Docs.Columns.Item("PROFILE_GROUP_TEXT").Visible = False GridView_Docs.Columns.Item("PROFILE_GROUP_COLOR").Visible = False For I = 0 To GridView_Docs.GroupCount - 1 Dim v = GridView_Docs.GroupedColumns(I).ToString Dim ii = Nothing GridView_Docs.GroupedColumns(I).Tag = GridView_Docs.Columns.Item("PROFILE_ID") Next GridView_Docs.Columns.Item("PROFILE_ID").Visible = False GridView_Docs.Columns.Item("GUID").Visible = False GridView_Docs.Columns.Item("FULL_FILE_PATH").Visible = False GridView_Docs.Columns.Item("DOC_ID").Visible = False GridView_Docs.Columns.Item("TL_STATE").Visible = False GridView_Docs.Columns.Item("ICON").MaxWidth = 24 GridView_Docs.Columns.Item("ICON").MinWidth = 24 GridView_Docs.Columns.Item("ICON").AppearanceCell.BackColor = Color.White GridView_Docs.Columns.Item("ICON").Fixed = DevExpress.XtraGrid.Columns.FixedStyle.Left GridView_Docs.Columns("Last edited").DisplayFormat.FormatType = FormatType.DateTime GridView_Docs.Columns("Last edited").DisplayFormat.FormatString = "dd.MM.yyyy HH:MM:ss" GridView_Docs.OptionsBehavior.AutoExpandAllGroups = True GridView_Docs.OptionsView.ShowGroupedColumns = False Catch ex As Exception ClassLogger.Add("Unexpected Error in Formatting Grid: " & ex.Message) End Try Try For Each grid_column As GridColumn In GridView_Docs.Columns Dim GridDXCaption = grid_column.Caption Dim GridDXTextCaption = grid_column.GetTextCaption Dim GridDXColumnEditName = grid_column.ColumnEditName Dim GridDXFieldName = grid_column.FieldName Dim exists As Boolean = False For Each col As DataColumn In CURR_DT_PROFILEGRID.Columns If col.Caption = GridDXTextCaption Then exists = True Exit For End If Next If exists = False Then If grid_column.Visible = True Then Try grid_column.Dispose() Catch ex As Exception End Try End If End If Next Catch ex As Exception ClassLogger.Add("Unexpected Error in Checking ColumnsGrid: " & ex.Message) End Try 'GridView_Docs.SaveLayoutToXml(GetXML_LayoutName()) SaveGridLayout() Else GridControl_Docs.Visible = False pnlNavigator.Visible = False GridControl_Docs.DataSource = Nothing Try GridView_Docs.Columns.Clear() Catch ex As Exception End Try End If Catch ex As Exception ClassLogger.Add("Load_Grid_Overview - Fehler: " & ex.Message) MsgBox("Fehler Load_Grid_Overview - Fehler: " & vbNewLine & ex.Message, MsgBoxStyle.Critical, "Achtung:") End Try Cursor = Cursors.Default End Sub Private Sub tsmiValidationProfil_Click(sender As Object, e As EventArgs) Handles tsmiValidationProfil.Click If CURRENT_CLICKED_PROFILE_ID <> 0 Then Load_Profil_from_Grid(CURRENT_CLICKED_PROFILE_ID) Else MsgBox("Bitte wählen Sie zuerst ein Profil aus!", MsgBoxResult.Ok) End If End Sub Private Sub NavBarItemDashboard_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles NavBarItemDashboard.LinkClicked If TimerRefresh.Enabled = True Then TimerRefresh.Stop() End If Layout_Dashboard() End Sub Private Sub TabellenlayoutZurücksetzenToolStripMenuItem_Click_1(sender As Object, e As EventArgs) Handles TabellenlayoutZurücksetzenToolStripMenuItem.Click ResetLayout() End Sub Private Sub GridView1_CustomDrawGroupRow(sender As Object, e As Views.Base.RowObjectCustomDrawEventArgs) Try Dim info As GridGroupRowInfo = TryCast(e.Info, GridGroupRowInfo) Dim view As GridView = sender Dim item As GridGroupSummaryItem = CType(view.GroupSummary(Tag), GridGroupSummaryItem) ' Dim value As Object = view.GetGroupSummaryValue(e.RowHandle, item) If info.Column.FieldName = "PROFILE_GROUP_TEXT" Then info.GroupText = info.GroupValueText Dim _color As String = "Grey" For Each row As DataRow In CURR_DT_VWPM_PROFILE_ACTIVE.Rows If row.Item("PROFILE_GROUP_TEXT") = info.GroupValueText Then _color = row.Item("PROFILE_GROUP_COLOR") End If Next Select Case _color Case "Red" info.Appearance.BackColor = Color.LightSalmon Case "Green" info.Appearance.BackColor = Color.LightGreen Case "Yellow" info.Appearance.BackColor = Color.LightYellow Case "Grey" info.Appearance.BackColor = Color.LightGray End Select End If Catch ex As Exception End Try End Sub Private Sub GridView_Docs_RowClick(sender As Object, e As RowClickEventArgs) Handles GridView_Docs.RowClick End Sub Private Sub GridView_Docs_DoubleClick(sender As Object, e As EventArgs) Handles GridView_Docs.DoubleClick Item_Scope() End Sub Private Sub GridView_Docs_CustomDrawGroupRow(sender As Object, e As Views.Base.RowObjectCustomDrawEventArgs) Handles GridView_Docs.CustomDrawGroupRow Try Dim info As GridGroupRowInfo = TryCast(e.Info, GridGroupRowInfo) Dim view As GridView = sender Dim item As GridGroupSummaryItem = CType(view.GroupSummary(Tag), GridGroupSummaryItem) ' Dim value As Object = view.GetGroupSummaryValue(e.RowHandle, item) If info.Column.FieldName = "PROFILE_GROUP_TEXT" Then info.GroupText = info.GroupValueText Dim _color As String = "Grey" For Each row As DataRow In CURR_DT_VWPM_PROFILE_ACTIVE.Rows If row.Item("PROFILE_GROUP_TEXT") = info.GroupValueText Then _color = row.Item("PROFILE_GROUP_COLOR") End If Next Select Case _color Case "Red" info.Appearance.BackColor = Color.LightSalmon Case "Green" info.Appearance.BackColor = Color.LightGreen Case "Yellow" info.Appearance.BackColor = Color.LightYellow Case "Grey" info.Appearance.BackColor = Color.LightGray End Select End If Catch ex As Exception End Try End Sub Private Sub GridView_Docs_MouseDown(sender As Object, e As MouseEventArgs) Handles GridView_Docs.MouseDown Dim view As GridView = sender Dim hi As GridHitInfo = view.CalcHitInfo(e.Location) GridCursorLocation = e.Location ' wenn in eine Group Row Doppelt geklickt wurde.. If hi.InGroupRow Then ' Ein/Ausklappen verhindern DXMouseEventArgs.GetMouseArgs(e).Handled = True GridViewItem_Clicked = "GROUP" 'Dim info = hi.Column.FieldName 'Dim info1 = hi.ToString Dim msg = "" ElseIf hi.InDataRow Then GridViewItem_Clicked = "ROW" Else GridViewItem_Clicked = Nothing End If End Sub 'Private Sub GridView_Docs_RowStyle(sender As Object, e As RowStyleEventArgs) Handles GridView_Docs.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 End Class