This commit is contained in:
2020-02-13 17:19:45 +01:00
parent a6ac1e08f0
commit 73bfb00299
15 changed files with 2102 additions and 1164 deletions

View File

@@ -11,6 +11,8 @@ Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraEditors.Controls
Imports System.Threading
Imports System.ComponentModel
Imports System.IO
Imports System.Drawing.Imaging
Public Class frmMain
'Private _windreamPM As ClassPMWindream
@@ -34,6 +36,8 @@ Public Class frmMain
'Private _windream As New ClassWindream_allgemein
Private allgFunk As New ClassAllgemeineFunktionen
Private CurrNavBarGroup As NavBarGroup
Private Sub frmMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
Try
formopenClose = True
@@ -357,20 +361,25 @@ Public Class frmMain
End Sub
Sub Load_Profile_items()
Dim oStopWatch As New RefreshHelper.SW("Load_Profile_items")
Dim profileGroupOpen As Boolean = False
Try
Dim CurrGroup As NavBarGroup = NavBarControl1.Groups(1)
profileGroupOpen = CurrGroup.Expanded
If Not IsNothing(CurrNavBarGroup) Then
Try
profileGroupOpen = CurrNavBarGroup.Expanded
Try
CurrNavBarGroup.ItemLinks.Clear()
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info("CurrGroupClear - Error: " & ex.Message)
End Try
CurrGroup.ItemLinks.Clear()
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info("CurrGroupClear - Error: " & ex.Message)
End Try
End If
Try
If Load_Profiles_for_User() = False Then
@@ -408,15 +417,19 @@ Public Class frmMain
End If
End If
If Not IsNothing(CurrNavBarGroup) Then
CurrNavBarGroup.Expanded = profileGroupOpen
Else
NavBarControl1.Groups(1).Expanded = True
End If
CurrGroup.Expanded = profileGroupOpen
Catch ex As Exception
LOGGER.Error(ex)
LOGGER.Info("Load_Profile_items - Error: " & ex.Message)
'MsgBox("Unexpected Error in Load_Profile_items - Error: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
End Try
oStopWatch.Done()
End Sub
Private Sub navBar_LinkClicked(ByVal sender As Object, ByVal e As NavBarLinkEventArgs)
' Das aktuelle Layout speichern, bevor das neue geladen wird
@@ -463,8 +476,8 @@ Public Class frmMain
BindingNavigator1.Dock = DockStyle.Top
GridControl_Docs.Visible = True
GridControl_Docs.Dock = DockStyle.Fill
SplitContainerDashboard.Visible = False
SplitContainerDashboard.Dock = DockStyle.None
pnlDashboard.Visible = False
pnlDashboard.Dock = DockStyle.None
End If
End Sub
@@ -472,42 +485,43 @@ Public Class frmMain
Try
If GridControl_Docs.Visible = True Then
BindingNavigator1.Visible = False
BindingNavigator1.Dock = DockStyle.None
GridControl_Docs.Visible = False
GridControl_Docs.Dock = DockStyle.None
BindingNavigator1.Visible = False
GridControl_Docs.Dock = DockStyle.None
GridControl_Docs.Visible = False
Dim groupCount As Integer
Dim charts As List(Of ChartControl)
SplitContainerDashboard.Visible = True
pnlDashboard.Visible = 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 oGroupIndex As Integer = Groups.IndexOf(gRow)
Dim oGroupID As String = gRow.Item("GROUP_ID")
Dim groupCharts = DT_CHARTS.Select(String.Format("GROUP_ID = '{0}'", groupName))
Dim groupCharts = DT_CHARTS.Select(String.Format("GROUP_ID = '{0}'", oGroupID))
Dim chart As ChartControl
For Each cRow As DataRow In groupCharts
Dim type = cRow.Item("TYPE_CHART")
Dim title = cRow.Item("TITLE")
Dim oChartType = cRow.Item("TYPE_CHART")
Dim oChartTitle = 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 oChartValue = cRow.Item("VALUE")
Dim oChartArgument = cRow.Item("ARGUMENT")
Dim oSqlchart = cRow.Item("SQL_COMMAND")
oSqlchart = oSqlchart.Replace("@USER", USER_USERNAME)
Dim DATA_DT As DataTable = ClassDatabase.Return_Datatable(oSqlchart)
Dim series As Series = Create_Series(title, type)
Dim series As Series = Create_Series(oChartTitle, oChartType)
' Select Current Chart
chart = Select_Chart(groupIndex)
chart = charts.Item(groupIndex)
chart = Select_Chart(oGroupIndex)
chart = charts.Item(oGroupIndex)
Try
chart.Series.Clear()
Catch ex As Exception
@@ -518,8 +532,8 @@ Public Class frmMain
chart.DataSource = DATA_DT
' Set shown Columns for Chart
series.ArgumentDataMember = argument
series.ValueDataMembers.AddRange(New String() {value})
series.ArgumentDataMember = oChartArgument
series.ValueDataMembers.AddRange(New String() {oChartValue})
'set some options
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True
@@ -531,28 +545,28 @@ Public Class frmMain
Next 'End Groups
Else
' Create Charts
For Each row As DataRow In DT_CHARTS.Rows
For Each cRow As DataRow In DT_CHARTS.Rows
Dim chart As ChartControl
Dim chartIndex As Integer = DT_CHARTS.Rows.IndexOf(row)
Dim chartIndex As Integer = DT_CHARTS.Rows.IndexOf(cRow)
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")
Dim oChartType = cRow.Item("TYPE_CHART")
Dim oChartTitle = cRow.Item("TITLE")
Dim guid = cRow.Item("GUID")
Dim oChartValue = cRow.Item("VALUE")
Dim oChartArgument = cRow.Item("ARGUMENT")
Dim oSqlchart = cRow.Item("SQL_COMMAND")
sqlchart = clsPatterns.ReplaceInternalValues(sqlchart)
sqlchart = clsPatterns.ReplaceUserValues(sqlchart, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
oSqlchart = clsPatterns.ReplaceInternalValues(oSqlchart)
oSqlchart = clsPatterns.ReplaceUserValues(oSqlchart, USER_PRENAME, USER_SURNAME, USER_SHORTNAME, USER_LANGUAGE, USER_EMAIL, USER_ID, CURRENT_CLICKED_PROFILE_ID)
sqlchart = sqlchart.ToString.ToUpper.Replace("@USER_ID", USER_ID)
sqlchart = sqlchart.ToString.ToUpper.Replace("@USER", USER_USERNAME)
Dim DATA_DT As DataTable = ClassDatabase.Return_Datatable(sqlchart)
oSqlchart = oSqlchart.ToString.ToUpper.Replace("@USER_ID", USER_ID)
oSqlchart = oSqlchart.ToString.ToUpper.Replace("@USER", USER_USERNAME)
Dim DATA_DT As DataTable = ClassDatabase.Return_Datatable(oSqlchart)
' Create Series based on type
Dim series As Series = Create_Series(title, type)
Dim series As Series = Create_Series(oChartTitle, oChartType)
' Select Current Chart
chart = Select_Chart(chartIndex)
@@ -566,8 +580,8 @@ Public Class frmMain
chart.DataSource = DATA_DT
' Set shown Columns for Chart
series.ArgumentDataMember = argument
series.ValueDataMembers.AddRange(New String() {value})
series.ArgumentDataMember = oChartArgument
series.ValueDataMembers.AddRange(New String() {oChartValue})
'set some options
chart.Legend.Visibility = DevExpress.Utils.DefaultBoolean.True
@@ -638,7 +652,7 @@ Public Class frmMain
' Show SplitContainerBottom
SplitContainerDashboard.Panel2Collapsed = False
End Select
SplitContainerDashboard.Dock = DockStyle.Fill
pnlDashboard.Dock = DockStyle.Fill
End Sub
Sub Load_single_Profile()
@@ -839,20 +853,34 @@ Public Class frmMain
' LOGGER.Warn($"Unexpected Error in freefileforUser [{oUpdate}] - {ex.Message}")
' End Try
'End If
SaveGridLayout()
Load_Profile_items()
Decide_Load()
If USER_LANGUAGE <> "de-DE" Then
bsilastsync.Caption = "Last Client-Sync: " & Now.ToLongTimeString
Else
bsilastsync.Caption = "Letzte Synchronisation: " & Now.ToLongTimeString
'End If
If bwSync.IsBusy Then
Exit Sub
End If
Try
SaveGridLayout()
'bwSync.ReportProgress(10)
Load_Profile_items()
'bwSync.ReportProgress(60)
Dim oStopWatch As New RefreshHelper.SW("Decide_Load")
Decide_Load()
oStopWatch.Done()
'bwSync.ReportProgress(95)
If USER_LANGUAGE <> "de-DE" Then
bsilastsync.Caption = "Last Client-Sync: " & Now.ToLongTimeString
Else
bsilastsync.Caption = "Letzte Synchronisation: " & Now.ToLongTimeString
End If
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.LoadViewInfo()
If GridControl_Docs.Visible = True And formopenClose = False Then RefreshHelper.LoadViewInfo()
Handling_DEBUG_USER()
Handling_DEBUG_USER()
Catch ex As Exception
LOGGER.Error(ex)
End Try
'BarEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Always
'' call this method to start your asynchronous Task.
'bwSync.RunWorkerAsync()
End Sub
@@ -866,7 +894,7 @@ Public Class frmMain
Exit Sub
End If
If TimerRefresh.Enabled = True Then
TimerRefresh.Stop()
TimerRefresh.Enabled = False
End If
If GRID_LOAD_TYPE = "OVERVIEW" Then
Load_Grid_Overview()
@@ -887,7 +915,7 @@ Public Class frmMain
LOGGER.Info("Unexpected error in Decide_load: " & ex.Message)
End Try
If TimerRefresh.Enabled = False Then
TimerRefresh.Start()
TimerRefresh.Enabled = True
End If
End Sub
@@ -956,7 +984,7 @@ Public Class frmMain
omsgTitle = "Attention:"
End If
If TimerRefresh.Enabled Then
TimerRefresh.Stop()
TimerRefresh.Enabled = False
End If
' Dim th As System.Threading.Thread
If Not Application.OpenForms().OfType(Of frmValidator).Any Then
@@ -964,7 +992,6 @@ Public Class frmMain
Decide_Load()
TimerRefresh.Enabled = True
TimerRefresh.Start()
Dim iterateIndex As Integer = 0
Dim oNewDataTable As DataTable = CURR_DT_OVERVIEW.Copy
For Each row As DataRow In oNewDataTable.Rows
@@ -1291,7 +1318,7 @@ Public Class frmMain
RefreshHelper.LoadViewInfo()
End Sub
Sub Load_Grid_Overview()
SplitContainerDashboard.Visible = False
pnlDashboard.Visible = False
Layout_Single_Profile()
GRID_LOAD_TYPE = "OVERVIEW"
CURRENT_CLICKED_PROFILE_ID = 0
@@ -1312,12 +1339,12 @@ Public Class frmMain
Exit Sub
End If
Dim oStopWatch As New RefreshHelper.SW("Load_Profiles_for_User")
Load_Profiles_for_User()
ClassInit.InitBasics()
oStopWatch.Done()
'ClassInit.InitBasics()
oStopWatch = New RefreshHelper.SW("build CURR_DT_OVERVIEW")
Dim oSQLOverview = CURRENT_DT_CONFIG.Rows(0).Item("SQL_PROFILE_MAIN_VIEW")
If IsDBNull(oSQLOverview) Then
bsiMessage.Caption = "No GROUP-CONFIG (SQL_PROFILE_MAIN_VIEW) in Baseconfig"
Exit Sub
@@ -1336,7 +1363,7 @@ Public Class frmMain
' "WHERE T.PROFIL_ID = T1.PROFIL_ID " &
' "AND T1.ACTIVE = 1 And (UPPER(T1.USERNAME) = UPPER('{0}')) Order By T1.PRIORITY", USER_USERNAME)
CURR_DT_OVERVIEW = ClassDatabase.Return_Datatable(oSQLOverview)
oStopWatch.Done()
Dim DTGRID_GROUPS As DataTable
Try
@@ -1506,7 +1533,7 @@ Public Class frmMain
Private Sub NavBarItemDashboard_LinkClicked(sender As Object, e As NavBarLinkEventArgs) Handles NavBarItemDashboard.LinkClicked
If TimerRefresh.Enabled = True Then
TimerRefresh.Stop()
TimerRefresh.Enabled = False
End If
Layout_Dashboard()
End Sub
@@ -1667,7 +1694,7 @@ Public Class frmMain
End If
LOGGER.Debug($" RibbonControl1.ColorScheme [{RIBBON_COLOR_SCHEME}]")
Me.Text = ADDITIONAL_TITLE
CurrNavBarGroup = NavBarControl1.Groups(1)
End Sub
Sub Handling_DEBUG_USER()
If USER_DEBUG_LOG = True Then
@@ -1844,4 +1871,119 @@ Public Class frmMain
Private Sub bbtniMetadataFile_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles bbtniMetadataFile.ItemClick
frmDesignerLayout.Show()
End Sub
Private Sub bwSync_DoWork(sender As Object, e As DoWorkEventArgs) Handles bwSync.DoWork
End Sub
Private Sub bwSync_ProgressChanged(sender As Object, e As ProgressChangedEventArgs) Handles bwSync.ProgressChanged
BarEditItem1.EditValue = e.ProgressPercentage
End Sub
Private Sub bwSync_RunWorkerCompleted(sender As Object, e As RunWorkerCompletedEventArgs) Handles bwSync.RunWorkerCompleted
'BarEditItem1.Visibility = DevExpress.XtraBars.BarItemVisibility.Never
End Sub
Private Sub Panel1_Paint(sender As Object, e As PaintEventArgs) Handles Panel1.Paint
End Sub
Sub ExportChart2Pdf(pMyChart As ChartControl, pFilePath As String)
Try
pMyChart.OptionsPrint.ImageFormat = DevExpress.XtraCharts.Printing.PrintImageFormat.Metafile
pMyChart.ExportToPdf(pFilePath, New DevExpress.XtraPrinting.PdfExportOptions With {
.ConvertImagesToJpeg = False
})
' Exports to a stream as PDF.
Dim pdfStream As FileStream = New FileStream(pFilePath, FileMode.Create)
pMyChart.ExportToPdf(pdfStream)
' ...
pdfStream.Close()
Catch ex As Exception
LOGGER.Error(ex)
End Try
End Sub
Private Sub ToolStripButton1_Click(sender As Object, e As EventArgs) Handles ToolStripButton1.Click
SaveFileDialog1.Filter = "PDF Files (*.pdf*)|*.pdf"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportChart2Pdf(ChartTopLeft, SaveFileDialog1.FileName)
End If
End Sub
Private Sub ToolStripButton2_Click(sender As Object, e As EventArgs) Handles ToolStripButton2.Click
SaveFileDialog1.Filter = "PDF Files (*.pdf*)|*.pdf"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportChart2Pdf(ChartTopRight, SaveFileDialog1.FileName)
End If
End Sub
Private Sub ToolStripButton3_Click(sender As Object, e As EventArgs) Handles ToolStripButton3.Click
SaveFileDialog1.Filter = "PDF Files (*.pdf*)|*.pdf"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportChart2Pdf(ChartBottomLeft, SaveFileDialog1.FileName)
End If
End Sub
Private Sub ToolStripButton4_Click(sender As Object, e As EventArgs) Handles ToolStripButton4.Click
SaveFileDialog1.Filter = "PDF Files (*.pdf*)|*.pdf"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportChart2Pdf(ChartBottomRight, SaveFileDialog1.FileName)
End If
End Sub
Private Sub ToolStripButton5_Click(sender As Object, e As EventArgs) Handles ToolStripButton5.Click
SaveFileDialog1.Filter = "PNG Files(* .png *)|*.png"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportCharttoimage(ChartTopLeft, SaveFileDialog1.FileName)
End If
End Sub
Sub ExportCharttoimage(pMyChart As ChartControl, pFilePath As String)
Try
SaveChartImageToFile(pMyChart, ImageFormat.Png, pFilePath)
Dim image As Image = GetChartImage(pMyChart, ImageFormat.Png)
image.Save(pFilePath)
Catch ex As Exception
LOGGER.Error(ex)
End Try
End Sub
Private Sub SaveChartImageToFile(ByVal chart As ChartControl, ByVal format As ImageFormat, ByVal fileName As String)
' Create an image in the specified format from the chart
' and save it to the specified path.
chart.ExportToImage(fileName, format)
End Sub
Private Function GetChartImage(ByVal chart As ChartControl, ByVal format As ImageFormat) As Image
' Create an image.
Dim image As Image = Nothing
' Create an image of the chart.
Using s As New MemoryStream()
chart.ExportToImage(s, format)
image = System.Drawing.Image.FromStream(s)
End Using
' Return the image.
Return image
End Function
Private Sub ToolStripButton6_Click(sender As Object, e As EventArgs) Handles ToolStripButton6.Click
SaveFileDialog1.Filter = "PNG Files(* .png *)|*.png"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportCharttoimage(ChartTopRight, SaveFileDialog1.FileName)
End If
End Sub
Private Sub ToolStripButton7_Click(sender As Object, e As EventArgs) Handles ToolStripButton7.Click
SaveFileDialog1.Filter = "PNG Files(* .png *)|*.png"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportCharttoimage(ChartBottomLeft, SaveFileDialog1.FileName)
End If
End Sub
Private Sub ToolStripButton8_Click(sender As Object, e As EventArgs) Handles ToolStripButton8.Click
SaveFileDialog1.Filter = "PNG Files(* .png *)|*.png"
If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
ExportCharttoimage(ChartBottomRight, SaveFileDialog1.FileName)
End If
End Sub
End Class