e603793dc0
-modifica a generazione pdf
629 lines
34 KiB
VB.net
629 lines
34 KiB
VB.net
Imports EgtBEAMWALL.Core
|
|
Imports EgtBEAMWALL.Core.ConstGen
|
|
Imports EgtUILib
|
|
Imports MigraDoc.DocumentObjectModel
|
|
Imports MigraDoc.DocumentObjectModel.Shapes
|
|
Imports MigraDoc.DocumentObjectModel.Tables
|
|
|
|
Module PDFHelper
|
|
|
|
Friend Enum ListTypes As Integer
|
|
PART = 1
|
|
MACHGROUP = 2
|
|
RAWPART = 3
|
|
MACHGROUPTOT = 4
|
|
PART_LIST = 5
|
|
PART_TOT = 6
|
|
End Enum
|
|
|
|
Public Function CreateStatReport(ActivePage As Pages, bPreview As Boolean) As Document
|
|
' creo nuovo documento MigraDoc
|
|
Dim document As New Document()
|
|
|
|
If ActivePage = Pages.VIEW Then
|
|
document.Info.Title = ProjectManagerVM.CurrProd.sProdId & " - " & ProjectManagerVM.CurrProd.BTLFileName_Msg & " - Statistics"
|
|
ElseIf ActivePage = Pages.MACHINING Then
|
|
document.Info.Title = ProjectManagerVM.CurrProd.sProdId & " - " & ProjectManagerVM.CurrProd.ListName_Msg & " - Statistics"
|
|
End If
|
|
|
|
document.Info.Subject = "Production statistics of the project"
|
|
document.Info.Author = "Optimizer"
|
|
DefineStyles(document)
|
|
'Logo
|
|
Dim section As Section = document.AddSection()
|
|
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
|
|
Dim sImageLogo As String = Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\Logo landscape.png"
|
|
If Not System.IO.File.Exists(sImageLogo) Then
|
|
sImageLogo = Map.refMainWindowVM.MainWindowM.sResourcesRoot & "\notfound.png"
|
|
End If
|
|
DefineLogo(section, sImageLogo)
|
|
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
Dim paragraph As Paragraph = section.AddParagraph(Map.refMainWindowVM.Title, "Heading1")
|
|
paragraph.Format.SpaceBefore = Unit.FromCentimeter(4.0)
|
|
paragraph.Format.Alignment = ParagraphAlignment.Center
|
|
|
|
CreateAssembledImage(document, section, bPreview)
|
|
|
|
If ActivePage = Pages.VIEW Then
|
|
DefinePartTotals(document, section, bPreview)
|
|
DefineItemList(document, ListTypes.PART, bPreview)
|
|
ElseIf ActivePage = Pages.MACHINING Then
|
|
DefineMachGroupTotals(document, section, bPreview)
|
|
DefineItemList(document, ListTypes.MACHGROUP, bPreview)
|
|
DefineItemList(document, ListTypes.RAWPART, bPreview)
|
|
CreateRawPartPages(document, bPreview)
|
|
End If
|
|
|
|
Return document
|
|
End Function
|
|
|
|
#Region "DEFINEPARTTOTALS"
|
|
|
|
Public Sub DefinePartTotals(document As Document, section As Section, bPreview As Boolean)
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
Dim paragraph As Paragraph = section.AddParagraph(EgtMsg(61734) & "s", "Heading2")
|
|
paragraph.Format.SpaceBefore = Unit.FromCentimeter(3.5)
|
|
|
|
Dim sPartTot As ExpanderPDF = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61734)) ' Recupero lista Part Totals
|
|
|
|
Dim Items As New List(Of (ExpanderElement As ExpanderElement, Message As String, Value As String)) From {
|
|
(GetExpanderElement(sPartTot, 61716), Statistic_Messages.BTLTotParts_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotParts, "127")),
|
|
(GetExpanderElement(sPartTot, 61717), Statistic_Messages.BTLTotVolume_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotVolume, "9.156")),
|
|
(GetExpanderElement(sPartTot, 61718), Statistic_Messages.BTLTotTime_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLTotTime, "00:01:55")),
|
|
(GetExpanderElement(sPartTot, 61720), Statistic_Messages.BTLRemainingTime_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sBTLRemainingTime, "00:01:55"))
|
|
}
|
|
|
|
For Each Item As (ExpanderElement As ExpanderElement, Message As String, Value As String) In Items
|
|
If Not IsNothing(Item.ExpanderElement) AndAlso Item.ExpanderElement.bParameter_IsChecked Then
|
|
section.AddParagraph(Item.Message & Item.Value)
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' DefinePartTotals
|
|
|
|
#Region "DEFINEMACHGROUPTOTALS"
|
|
|
|
Public Sub DefineMachGroupTotals(ByVal document As Document, section As Section, bPreview As Boolean)
|
|
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
|
|
' cambio orientamento a orizzontale
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
Dim paragraph As Paragraph = section.AddParagraph(EgtMsg(61729), "Heading2")
|
|
paragraph.Format.SpaceBefore = Unit.FromMillimeter(3.5)
|
|
|
|
Dim sMachGroup As ExpanderPDF = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61729)) ' Recupero lista Machgroup Totals
|
|
|
|
Dim Items As New List(Of (ExpanderElement As ExpanderElement, Message As String, Value As String)) From {
|
|
(GetExpanderElement(sMachGroup, 61721), Statistic_Messages.TotMachGroups_Msg, If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotMachGroups, "11")),
|
|
(GetExpanderElement(sMachGroup, 61717), Statistic_Messages.BTLTotVolume_Msg, If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotVolume, "3.168")),
|
|
(GetExpanderElement(sMachGroup, 61719), Statistic_Messages.BTLTotEstimatedTime_Msg, If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotEstimatedTime, "00:22:30")),
|
|
(GetExpanderElement(sMachGroup, 61718), Statistic_Messages.BTLTotTime_Msg, If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sTotTime, "00:09:23")),
|
|
(GetExpanderElement(sMachGroup, 61720), Statistic_Messages.BTLRemainingTime_Msg, If(Not bPreview, Map.refProjectVM.MachGroupPanelVM.sRemainingTime, "00:09:23")),
|
|
(GetExpanderElement(sMachGroup, 61722), Statistic_Messages.TotCNTParts_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotCNTParts, "127")),
|
|
(GetExpanderElement(sMachGroup, 61723), Statistic_Messages.TotADDEDParts_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotADDEDParts, "0")),
|
|
(GetExpanderElement(sMachGroup, 61724), Statistic_Messages.TotINPRODParts_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotINPRODParts, "69")),
|
|
(GetExpanderElement(sMachGroup, 61725), Statistic_Messages.TotDONEParts_Msg, If(Not bPreview, Map.refProjectVM.BTLStructureVM.sTotDONEParts, "5"))
|
|
}
|
|
|
|
For Each Item As (ExpanderElement As ExpanderElement, Message As String, Value As String) In Items
|
|
If Not IsNothing(Item.ExpanderElement) AndAlso Item.ExpanderElement.bParameter_IsChecked Then
|
|
section.AddParagraph(Item.Message & Item.Value)
|
|
End If
|
|
Next
|
|
End Sub
|
|
|
|
#End Region ' DefineMachGroupTotals
|
|
|
|
#Region "GETEXPANDERELEMENT"
|
|
|
|
Private Function GetExpanderElement(sPartTot As ExpanderPDF, MsgId As Integer) As ExpanderElement
|
|
Return sPartTot.ExpanderElementList.FirstOrDefault(Function(x As ExpanderElement) x.sNameParameter = EgtMsg(MsgId))
|
|
End Function
|
|
|
|
#End Region ' GetExpanderElement
|
|
|
|
#Region "DEFINEITEMLIST"
|
|
|
|
Public Sub DefineItemList(ByVal document As Document, nListType As ListTypes, bPreview As Boolean)
|
|
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = True
|
|
'Recupero la lista delle colonne delle tabelle
|
|
Dim sMachGroupList As ExpanderTable = Nothing
|
|
If nListType = ListTypes.MACHGROUP Then
|
|
sMachGroupList = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61730)).ExpanderElementList.FirstOrDefault() ' Lista Tabella MachGroup List
|
|
ElseIf nListType = ListTypes.RAWPART Then
|
|
sMachGroupList = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61732)).ExpanderElementList.FirstOrDefault() ' Lista Tabella Raw Part List
|
|
ElseIf nListType = ListTypes.PART Then
|
|
sMachGroupList = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61733)).ExpanderElementList.FirstOrDefault() ' Lista Tabella Part List
|
|
End If
|
|
Dim sName As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_NAME) ' Recupero colonna 'colName' con relativo checkbox
|
|
Dim sW As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_W) ' Recupero colonna 'colW' con relativo checkbox
|
|
Dim sH As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_H) ' Recupero colonna 'colH' con relativo checkbox
|
|
Dim sL As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_L) ' Recupero colonna 'colL' con relativo checkbox
|
|
Dim sMaterial As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_MATERIAL) ' Recupero colonna 'colMaterial' con relativo checkbox
|
|
Dim sUsage As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_USAGE) ' Recupero colonna 'colUsage' con relativo checkbox
|
|
Dim sWaste As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_WASTE) ' Recupero colonna 'colWaste' con relativo checkbox
|
|
Dim sUTime As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_UNITTIME) ' Recupero colonna 'colUnitTime' con relativo checkbox
|
|
Dim sQty As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_QTY) ' Recupero colonna 'colQuantity' con relativo checkbox
|
|
Dim sPDN As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_PDN) ' Recupero colonna 'colPDN' con relativo checkbox
|
|
Dim sDesc As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_DESC) ' Recupero colonna 'colDescription' con relativo checkbox
|
|
Dim sCNT As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_CNT) ' Recupero colonna 'colCNT' con relativo checkbox
|
|
Dim sAdded As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_ADDED) ' Recupero colonna 'colAdded' con relativo checkbox
|
|
Dim sDone As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_DONE) ' Recupero colonna 'colDone' con relativo checkbox
|
|
Dim sUVolume As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_UNITVOLUME) ' Recupero colonna 'colUnitVolume' con relativo checkbox
|
|
Dim sTVolume As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_TOTVOLUME) ' Recupero colonna 'colTotVolume' con relativo checkbox
|
|
Dim sTTime As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_TOTTIME) ' Recupero colonna 'colTotTime' con relativo checkbox
|
|
Dim sINProd As EgwWPFBaseLib.ColumnLayout = sMachGroupList.RawPartColumns.FirstOrDefault(Function(x) x.Key = COL_INPROD) ' Recupero colonna 'colInProd' con relativo checkbox
|
|
Dim section As Section = document.LastSection()
|
|
DefineItem(document, nListType, bPreview, sMachGroupList, sName, sW, sH, sL, sMaterial, sUsage, sWaste, sUTime, sQty, sPDN, sDesc, sCNT, sAdded, sDone, sUVolume, sTVolume, sTTime, sINProd, section)
|
|
End Sub
|
|
|
|
Private Sub DefineItem(document As Document, nListType As ListTypes, bPreview As Boolean, sMachGroupList As ExpanderTable, sName As EgwWPFBaseLib.ColumnLayout, sW As EgwWPFBaseLib.ColumnLayout, sH As EgwWPFBaseLib.ColumnLayout, sL As EgwWPFBaseLib.ColumnLayout, sMaterial As EgwWPFBaseLib.ColumnLayout, sUsage As EgwWPFBaseLib.ColumnLayout, sWaste As EgwWPFBaseLib.ColumnLayout, sUTime As EgwWPFBaseLib.ColumnLayout, sQty As EgwWPFBaseLib.ColumnLayout, sPDN As EgwWPFBaseLib.ColumnLayout, sDesc As EgwWPFBaseLib.ColumnLayout, sCNT As EgwWPFBaseLib.ColumnLayout, sAdded As EgwWPFBaseLib.ColumnLayout, sDone As EgwWPFBaseLib.ColumnLayout, sUVolume As EgwWPFBaseLib.ColumnLayout, sTVolume As EgwWPFBaseLib.ColumnLayout, sTTime As EgwWPFBaseLib.ColumnLayout, sINProd As EgwWPFBaseLib.ColumnLayout, section As Section)
|
|
Select Case nListType
|
|
Case ListTypes.PART : section.AddParagraph(EgtMsg(61733), "Heading2")
|
|
Case ListTypes.MACHGROUP : section.AddParagraph(EgtMsg(61730), "Heading2")
|
|
Case ListTypes.RAWPART : section.AddParagraph(EgtMsg(61732), "Heading2")
|
|
End Select
|
|
|
|
Dim Items As IList(Of Object) = GetItemList(nListType, bPreview)
|
|
If Not bPreview AndAlso (IsNothing(Items) OrElse Items.Count = 0) Then Return
|
|
|
|
Dim ActiveColumns As New List(Of Integer)
|
|
|
|
For Index As Integer = 0 To sMachGroupList.RawPartColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(Index).Key
|
|
|
|
If ColumnIsEnabled(colName, sPDN, sName, sW, sH, sL, sMaterial, sUsage, sWaste, sUTime, sQty, sDesc, sCNT, sAdded, sDone, sUVolume, sTVolume, sTTime, sINProd) Then
|
|
ActiveColumns.Add(Index)
|
|
End If
|
|
Next
|
|
|
|
If ActiveColumns.Count = 0 Then Return
|
|
|
|
Dim table As New Table()
|
|
table.Borders.Width = 0.75
|
|
|
|
For Each colIndex As Integer In ActiveColumns
|
|
Dim width As Unit = GetColumnWidth(sMachGroupList.RawPartColumns(colIndex).Key, nListType)
|
|
table.AddColumn(width)
|
|
Next
|
|
|
|
Dim header As Row = table.AddRow()
|
|
header.HeadingFormat = True
|
|
header.Shading.Color = Colors.Aqua
|
|
|
|
For j As Integer = 0 To ActiveColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(ActiveColumns(j)).Key
|
|
header.Cells(j).AddParagraph(GetHeaderText(colName))
|
|
Next
|
|
|
|
If bPreview Then
|
|
Dim row As Row = table.AddRow()
|
|
For j As Integer = 0 To ActiveColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(ActiveColumns(j)).Key
|
|
row.Cells(j).AddParagraph(GetCellValue(colName, Nothing, nListType, bPreview))
|
|
Next
|
|
Else
|
|
For Each item As Object In Items
|
|
Dim row As Row = table.AddRow()
|
|
|
|
For j As Integer = 0 To ActiveColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(ActiveColumns(j)).Key
|
|
row.Cells(j).AddParagraph(GetCellValue(colName, item, nListType, bPreview))
|
|
Next
|
|
Next
|
|
End If
|
|
|
|
If table.Columns.Count > 0 AndAlso table.Rows.Count > 0 Then document.LastSection.Add(table)
|
|
End Sub
|
|
|
|
Private Function ColumnIsEnabled(colName As String, sPDN As EgwWPFBaseLib.ColumnLayout, sName As EgwWPFBaseLib.ColumnLayout, sW As EgwWPFBaseLib.ColumnLayout, sH As EgwWPFBaseLib.ColumnLayout, sL As EgwWPFBaseLib.ColumnLayout, sMaterial As EgwWPFBaseLib.ColumnLayout, sUsage As EgwWPFBaseLib.ColumnLayout, sWaste As EgwWPFBaseLib.ColumnLayout, sUTime As EgwWPFBaseLib.ColumnLayout, sQty As EgwWPFBaseLib.ColumnLayout, sDesc As EgwWPFBaseLib.ColumnLayout, sCNT As EgwWPFBaseLib.ColumnLayout, sAdded As EgwWPFBaseLib.ColumnLayout, sDone As EgwWPFBaseLib.ColumnLayout, sUVolume As EgwWPFBaseLib.ColumnLayout, sTVolume As EgwWPFBaseLib.ColumnLayout, sTTime As EgwWPFBaseLib.ColumnLayout, sINProd As EgwWPFBaseLib.ColumnLayout) As Boolean
|
|
Select Case colName
|
|
Case COL_PDN : Return sPDN.IsVisible
|
|
Case COL_NAME, COL_DESC : Return Not IsNothing(sName) AndAlso sName.IsVisible Or Not IsNothing(sDesc) AndAlso sDesc.IsVisible
|
|
Case COL_W : Return sW.IsVisible
|
|
Case COL_H : Return sH.IsVisible
|
|
Case COL_L : Return sL.IsVisible
|
|
Case COL_MATERIAL : Return sMaterial.IsVisible
|
|
Case COL_USAGE : Return sUsage.IsVisible
|
|
Case COL_WASTE : Return sWaste.IsVisible
|
|
Case COL_UNITTIME : Return sUTime.IsVisible
|
|
Case COL_QTY : Return sQty.IsVisible
|
|
Case COL_CNT : Return sCNT.IsVisible
|
|
Case COL_ADDED : Return sAdded.IsVisible
|
|
Case COL_DONE : Return sDone.IsVisible
|
|
Case COL_UNITVOLUME : Return sUVolume.IsVisible
|
|
Case COL_TOTVOLUME : Return sTVolume.IsVisible
|
|
Case COL_TOTTIME : Return sTTime.IsVisible
|
|
Case COL_INPROD : Return sINProd.IsVisible
|
|
Case COL_ID : Return True
|
|
Case Else : Return False
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetColumnWidth(colName As String, nListType As ListTypes) As Unit
|
|
Select Case colName
|
|
Case COL_PDN : Return Unit.FromCentimeter(1)
|
|
Case COL_ID : Return Unit.FromCentimeter(1.5)
|
|
Case COL_W, COL_H : Return If(nListType = ListTypes.PART, Unit.FromCentimeter(1), Unit.FromCentimeter(2))
|
|
Case COL_L : Return If(nListType = ListTypes.PART, Unit.FromCentimeter(1.6), Unit.FromCentimeter(2))
|
|
Case COL_NAME, COL_DESC : Return Unit.FromCentimeter(4)
|
|
Case COL_MATERIAL : Return Unit.FromCentimeter(2)
|
|
Case COL_CNT : Return Unit.FromCentimeter(1.6)
|
|
Case COL_ADDED : Return Unit.FromCentimeter(1.5)
|
|
Case COL_INPROD : Return Unit.FromCentimeter(2.5)
|
|
Case COL_DONE : Return Unit.FromCentimeter(1.5)
|
|
Case COL_USAGE, COL_WASTE : Return Unit.FromCentimeter(2)
|
|
Case COL_UNITVOLUME : Return If(nListType = ListTypes.PART, Unit.FromCentimeter(1.5), Unit.FromCentimeter(2))
|
|
Case COL_TOTVOLUME : Return Unit.FromCentimeter(1.5)
|
|
Case COL_UNITTIME : Return Unit.FromCentimeter(2.2)
|
|
Case COL_TOTTIME : Return Unit.FromCentimeter(2)
|
|
Case COL_QTY : Return Unit.FromCentimeter(2)
|
|
Case Else : Return Unit.FromCentimeter(2)
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetHeaderText(colName As String) As String
|
|
Select Case colName
|
|
Case COL_PDN : Return Statistic_Messages.PDN_Msg
|
|
Case COL_ID : Return Map.refStatisticsVM.ID_Msg
|
|
Case COL_W : Return Statistic_Messages.W_Msg
|
|
Case COL_H : Return Statistic_Messages.H_Msg
|
|
Case COL_L : Return Statistic_Messages.L_Msg
|
|
Case COL_NAME, COL_DESC : Return Statistic_Messages.NAM_Msg
|
|
Case COL_MATERIAL : Return Statistic_Messages.MAT_Msg
|
|
Case COL_CNT : Return Statistic_Messages.CNT_Msg
|
|
Case COL_ADDED : Return Statistic_Messages.ADDED_Msg
|
|
Case COL_INPROD : Return Statistic_Messages.INPROD_Msg
|
|
Case COL_DONE : Return Statistic_Messages.DONE_Msg
|
|
Case COL_USAGE : Return Statistic_Messages.Used_Msg
|
|
Case COL_WASTE : Return Statistic_Messages.Waste_Msg
|
|
Case COL_UNITVOLUME : Return Statistic_Messages.UNIT_VOLUME_Msg
|
|
Case COL_TOTVOLUME : Return Statistic_Messages.TOT_VOLUME_Msg
|
|
Case COL_UNITTIME : Return Statistic_Messages.UNIT_TIME_Msg
|
|
Case COL_TOTTIME : Return Statistic_Messages.TOT_TIME_Msg
|
|
Case COL_QTY : Return Statistic_Messages.QTY_Msg
|
|
Case Else : Return ""
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetItemList(nListType As ListTypes, bPreview As Boolean) As IList(Of Object)
|
|
If bPreview Then Return New List(Of Object)()
|
|
|
|
Select Case nListType
|
|
Case ListTypes.PART
|
|
Return Map.refProjectVM.BTLStructureVM.BTLPartVMList.Cast(Of Object)().ToList()
|
|
Case ListTypes.MACHGROUP
|
|
Return Map.refProjectVM.MachGroupPanelVM.MachGroupVMList.Cast(Of Object)().ToList()
|
|
Case ListTypes.RAWPART
|
|
Map.refStatisticsVM.LoadRawPart()
|
|
Return Map.refStatisticsVM.RawPartList.Cast(Of Object)().ToList()
|
|
Case Else
|
|
Return New List(Of Object)()
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetCellValue(colName As String, item As Object, nListType As ListTypes, bPreview As Boolean) As String
|
|
Select Case nListType
|
|
Case ListTypes.PART
|
|
Dim Part As BTLPartVM = CType(item, BTLPartVM)
|
|
|
|
Select Case colName
|
|
Case COL_PDN : Return If(bPreview, "1", Part.nPDN)
|
|
Case COL_W : Return If(bPreview, "200", Part.sW)
|
|
Case COL_H : Return If(bPreview, "360", Part.sH)
|
|
Case COL_L : Return If(bPreview, "6672.6", Part.sL)
|
|
Case COL_NAME, COL_DESC : Return If(bPreview, "saetta", Part.sNAM)
|
|
Case COL_MATERIAL : Return If(bPreview, "Abete", Part.sMATERIAL)
|
|
Case COL_CNT : Return If(bPreview, "1", Part.sCNT)
|
|
Case COL_ADDED : Return If(bPreview, "0", Part.sADDED)
|
|
Case COL_INPROD : Return If(bPreview, "0", Part.nINPROD)
|
|
Case COL_DONE : Return If(bPreview, "0", Part.nDONE)
|
|
Case COL_UNITVOLUME : Return If(bPreview, "0.48", Part.sUnitVolume)
|
|
Case COL_TOTVOLUME : Return If(bPreview, "0.48", Part.sTotVolume)
|
|
Case COL_UNITTIME : Return If(bPreview, "00:00:00", Part.sUnitTime)
|
|
Case COL_TOTTIME : Return If(bPreview, "00:00:00", Part.sTotTime)
|
|
End Select
|
|
Case ListTypes.MACHGROUP
|
|
Dim Machgroup As MyMachGroupVM = CType(item, MyMachGroupVM)
|
|
|
|
Select Case colName
|
|
Case COL_ID : Return Machgroup.Id
|
|
Case COL_W : Return If(bPreview, "120", Machgroup.dW)
|
|
Case COL_H : Return If(bPreview, "160", Machgroup.dH)
|
|
Case COL_L : Return If(bPreview, "15000", Machgroup.dL)
|
|
Case COL_NAME, COL_DESC : Return If(bPreview, "1", Machgroup.nName)
|
|
Case COL_MATERIAL : Return If(bPreview, "Abete", Machgroup.sMATERIAL)
|
|
Case COL_USAGE : Return If(bPreview, "99.719", Machgroup.sUsage)
|
|
Case COL_WASTE : Return If(bPreview, "0.5", Machgroup.sWaste)
|
|
Case COL_UNITVOLUME : Return If(bPreview, "0.48", Machgroup.dUnitVolume)
|
|
Case COL_UNITTIME : Return If(bPreview, "00:13:07", Machgroup.sUnitTime)
|
|
End Select
|
|
Case ListTypes.RAWPART
|
|
Dim RawPart As SParam = CType(item, SParam)
|
|
|
|
Select Case colName
|
|
Case COL_W : Return If(bPreview, "120", RawPart.sW)
|
|
Case COL_H : Return If(bPreview, "160", RawPart.sH)
|
|
Case COL_L : Return If(bPreview, "15000", RawPart.sL)
|
|
Case COL_MATERIAL : Return If(bPreview, "Abete", RawPart.sMaterial)
|
|
Case COL_QTY : Return If(bPreview, "11", RawPart.nQuantity)
|
|
End Select
|
|
End Select
|
|
|
|
Return ""
|
|
End Function
|
|
|
|
#End Region ' DefineItemList
|
|
|
|
#Region "CREATERAWPARTPAGES"
|
|
|
|
Public Sub CreateRawPartPages(ByVal document As Document, bPreview As Boolean)
|
|
document.DefaultPageSetup.DifferentFirstPageHeaderFooter = False
|
|
Dim section As Section = document.AddSection()
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
|
|
'Recupero la lista delle colonne delle tabelle
|
|
Dim sMachGroupList As ExpanderTable = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61731)).ExpanderElementList.FirstOrDefault() ' Lista Tabella Raw Part
|
|
|
|
Dim sPDN As EgwWPFBaseLib.ColumnLayout = GetColumns(sMachGroupList.RawPartColumns, COL_PDN)
|
|
Dim sW As EgwWPFBaseLib.ColumnLayout = GetColumns(sMachGroupList.RawPartColumns, COL_W)
|
|
Dim sH As EgwWPFBaseLib.ColumnLayout = GetColumns(sMachGroupList.RawPartColumns, COL_H)
|
|
Dim sL As EgwWPFBaseLib.ColumnLayout = GetColumns(sMachGroupList.RawPartColumns, COL_L)
|
|
Dim sDesc As EgwWPFBaseLib.ColumnLayout = GetColumns(sMachGroupList.RawPartColumns, COL_DESC)
|
|
Dim sMaterial As EgwWPFBaseLib.ColumnLayout = GetColumns(sMachGroupList.RawPartColumns, COL_MATERIAL)
|
|
|
|
Dim paragraph As Paragraph = section.AddParagraph(EgtMsg(62590), "Heading2")
|
|
paragraph.Format.SpaceAfter = Unit.FromMillimeter(3.0)
|
|
|
|
' Controllo se bPreview è true mostra il PDF di preview se no il PDF completo
|
|
If bPreview Then
|
|
CreateRawPartPage(section, sMachGroupList, sPDN, sW, sH, sL, sDesc, sMaterial, Nothing, bPreview)
|
|
Else
|
|
For Each RawPart As MyMachGroupVM In Map.refProjectVM.MachGroupPanelVM.MachGroupVMList
|
|
CreateRawPartPage(section, sMachGroupList, sPDN, sW, sH, sL, sDesc, sMaterial, RawPart, bPreview)
|
|
Next
|
|
End If
|
|
End Sub
|
|
|
|
Private Function GetColumns(RawPartColumns As IEnumerable(Of EgwWPFBaseLib.ColumnLayout), key As String) As EgwWPFBaseLib.ColumnLayout
|
|
Return RawPartColumns.FirstOrDefault(Function(x) x.Key = key)
|
|
End Function
|
|
|
|
Private Sub CreateRawPartPage(section As Section, sMachGroupList As ExpanderTable, sPDN As EgwWPFBaseLib.ColumnLayout, sW As EgwWPFBaseLib.ColumnLayout, sH As EgwWPFBaseLib.ColumnLayout, sL As EgwWPFBaseLib.ColumnLayout, sDesc As EgwWPFBaseLib.ColumnLayout, sMaterial As EgwWPFBaseLib.ColumnLayout, RawPart As MyMachGroupVM, bPreview As Boolean)
|
|
Dim Items As IList(Of Object)
|
|
Dim paragraph As Paragraph = Nothing
|
|
|
|
If IsNothing(RawPart) Then
|
|
Items = New List(Of Object)()
|
|
If sMachGroupList.bSection_IsChecked Then
|
|
paragraph = section.AddParagraph(EgtMsg(62589) & 1, "Heading3")
|
|
End If
|
|
Else
|
|
Items = RawPart.PartVMList.Cast(Of Object)().ToList()
|
|
If sMachGroupList.bSection_IsChecked Then
|
|
paragraph = section.AddParagraph(EgtMsg(62589) & RawPart.Name, "Heading3")
|
|
End If
|
|
End If
|
|
|
|
paragraph.Format.SpaceAfter = Unit.FromMillimeter(1.0)
|
|
|
|
If Not bPreview AndAlso Items.Count = 0 Then Return
|
|
|
|
Dim ActiveColumns As New List(Of Integer)
|
|
|
|
For i As Integer = 0 To sMachGroupList.RawPartColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(i).Key
|
|
|
|
If ColumnRawPartIsEnabled(colName, sPDN, Nothing, sW, sH, sL, sMaterial, Nothing, Nothing, Nothing, Nothing, sDesc, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing, Nothing) Then
|
|
ActiveColumns.Add(i)
|
|
End If
|
|
Next
|
|
|
|
If ActiveColumns.Count = 0 Then Return
|
|
|
|
Dim table As New Table()
|
|
table.Borders.Width = 0.75
|
|
|
|
For Each colIndex As Integer In ActiveColumns
|
|
Dim width As Unit = GetRawPartColumnWidth(sMachGroupList.RawPartColumns(colIndex).Key)
|
|
table.AddColumn(width)
|
|
Next
|
|
|
|
Dim header As Row = table.AddRow()
|
|
header.HeadingFormat = True
|
|
header.Shading.Color = Colors.Aqua
|
|
|
|
For j As Integer = 0 To ActiveColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(ActiveColumns(j)).Key
|
|
header.Cells(j).AddParagraph(GetRawPartHeader(colName))
|
|
Next
|
|
|
|
If bPreview Then
|
|
Dim row As Row = table.AddRow()
|
|
For j As Integer = 0 To ActiveColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(ActiveColumns(j)).Key
|
|
row.Cells(j).AddParagraph(GetRawPartValue(colName, Nothing, bPreview))
|
|
Next
|
|
Else
|
|
For Each obj As Object In Items
|
|
Dim p As PartVM = CType(obj, PartVM)
|
|
Dim row As Row = table.AddRow()
|
|
|
|
For j As Integer = 0 To ActiveColumns.Count - 1
|
|
Dim colName As String = sMachGroupList.RawPartColumns(ActiveColumns(j)).Key
|
|
row.Cells(j).AddParagraph(GetRawPartValue(colName, p, bPreview))
|
|
Next
|
|
Next
|
|
End If
|
|
|
|
If table.Columns.Count > 0 AndAlso table.Rows.Count > 0 Then
|
|
section.Add(table)
|
|
section.AddParagraph().Format.SpaceAfter = Unit.FromMillimeter(3.0)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
Private Function ColumnRawPartIsEnabled(colName As String, sPDN As EgwWPFBaseLib.ColumnLayout, sName As EgwWPFBaseLib.ColumnLayout, sW As EgwWPFBaseLib.ColumnLayout, sH As EgwWPFBaseLib.ColumnLayout, sL As EgwWPFBaseLib.ColumnLayout, sMaterial As EgwWPFBaseLib.ColumnLayout, sUsage As EgwWPFBaseLib.ColumnLayout, sWaste As EgwWPFBaseLib.ColumnLayout, sUTime As EgwWPFBaseLib.ColumnLayout, sQty As EgwWPFBaseLib.ColumnLayout, sDesc As EgwWPFBaseLib.ColumnLayout, sCNT As EgwWPFBaseLib.ColumnLayout, sAdded As EgwWPFBaseLib.ColumnLayout, sDone As EgwWPFBaseLib.ColumnLayout, sUVolume As EgwWPFBaseLib.ColumnLayout, sTVolume As EgwWPFBaseLib.ColumnLayout, sTTime As EgwWPFBaseLib.ColumnLayout, sINProd As EgwWPFBaseLib.ColumnLayout) As Boolean
|
|
Select Case colName
|
|
Case COL_PDN : Return sPDN.IsVisible
|
|
Case COL_W : Return sW.IsVisible
|
|
Case COL_H : Return sH.IsVisible
|
|
Case COL_L : Return sL.IsVisible
|
|
Case COL_DESC : Return sDesc.IsVisible
|
|
Case COL_MATERIAL : Return sMaterial.IsVisible
|
|
Case COL_NAME : Return True
|
|
Case Else : Return False
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetRawPartColumnWidth(colName As String) As Unit
|
|
Select Case colName
|
|
Case COL_PDN : Return Unit.FromCentimeter(1.5)
|
|
Case COL_W, COL_H, COL_L : Return Unit.FromCentimeter(2)
|
|
Case COL_DESC, COL_NAME : Return Unit.FromCentimeter(4)
|
|
Case COL_MATERIAL : Return Unit.FromCentimeter(2)
|
|
Case Else : Return Unit.FromCentimeter(2)
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetRawPartHeader(colName As String) As String
|
|
Select Case colName
|
|
Case COL_PDN : Return Statistic_Messages.PDN_Msg
|
|
Case COL_W : Return Statistic_Messages.W_Msg
|
|
Case COL_H : Return Statistic_Messages.H_Msg
|
|
Case COL_L : Return Statistic_Messages.L_Msg
|
|
Case COL_DESC, COL_NAME : Return Statistic_Messages.NAM_Msg
|
|
Case COL_MATERIAL : Return Statistic_Messages.MAT_Msg
|
|
Case Else : Return ""
|
|
End Select
|
|
End Function
|
|
|
|
Private Function GetRawPartValue(colName As String, p As PartVM, bPreview As Boolean) As String
|
|
Select Case colName
|
|
Case COL_PDN : Return If(bPreview, "55", p.nPDN)
|
|
Case COL_W : Return If(bPreview, "120", p.sW)
|
|
Case COL_H : Return If(bPreview, "160", p.sH)
|
|
Case COL_L : Return If(bPreview, "185.9", p.sL)
|
|
Case COL_DESC, COL_NAME : Return If(bPreview, EgtMsg(63033), p.sNAM)
|
|
Case COL_MATERIAL : Return If(bPreview, "GL24h", p.sMATERIAL)
|
|
Case Else : Return ""
|
|
End Select
|
|
End Function
|
|
|
|
Private Sub CreateAssembledImage(ByVal document As Document, section As Section, bPreview As Boolean)
|
|
Dim pgSetup As PageSetup = document.DefaultPageSetup.Clone()
|
|
pgSetup.Orientation = Orientation.Landscape
|
|
section.PageSetup = pgSetup
|
|
Dim paragraph As Paragraph = section.AddParagraph()
|
|
Dim sMachGroupList As ExpanderTable = Map.refPDFEditorVM.ExpanderList.FirstOrDefault(Function(x) x.sNameCategory = EgtMsg(61731)).ExpanderElementList.FirstOrDefault()
|
|
Dim sImagePath As String = String.Empty
|
|
Core.ViewPanelVM.BWSetView(If(Core.ViewPanelVM.Type = BWType.BEAM, VT.FRONT, VT.TOP), False)
|
|
Dim basePath = Map.refMainWindowVM.MainWindowM.sTempDir
|
|
Dim realImage = $"{basePath}\ImageAssembled.png"
|
|
Dim previewImage = $"{basePath}\ImageTest.png"
|
|
sImagePath = If(bPreview, previewImage, realImage)
|
|
' Setto il nuovo contesto
|
|
EgtSetCurrentContext(Map.refSceneShowBuldingVM.SceneShowBulding.GetCtx())
|
|
EgtGetImage(SM.SHADING, New Color3d(255, 255, 255), New Color3d(255, 255, 255), 2500, 1000, sImagePath)
|
|
' Ritorno al contesto corrente
|
|
EgtSetCurrentContext(Map.refSceneHostVM.MainScene.GetCtx())
|
|
' aggiungo immagine
|
|
If sMachGroupList.bImage_IsChecked Then
|
|
Dim Image As Image = section.AddImage(sImagePath)
|
|
Image.LockAspectRatio = True
|
|
Image.Width = Unit.FromMillimeter(275)
|
|
Image.RelativeHorizontal = RelativeHorizontal.Page
|
|
Image.RelativeVertical = RelativeVertical.Paragraph
|
|
Image.Left = ShapePosition.Center
|
|
End If
|
|
End Sub
|
|
|
|
#End Region ' CreateRawPartPages
|
|
|
|
#Region "LOGO"
|
|
|
|
Public Sub DefineLogo(section As Section, sImageLogo As String)
|
|
Dim Image As MigraDoc.DocumentObjectModel.Shapes.Image = section.Headers.FirstPage.AddImage(sImageLogo)
|
|
Image.Width = Unit.FromMillimeter(40)
|
|
Image.Height = Unit.FromMillimeter(40)
|
|
Image.LockAspectRatio = True
|
|
Image.RelativeVertical = RelativeVertical.Line
|
|
Image.Top = ShapePosition.Top
|
|
Image.Left = ShapePosition.Right
|
|
Image.WrapFormat.Style = WrapStyle.Through
|
|
Image.RelativeHorizontal = RelativeHorizontal.Margin
|
|
End Sub
|
|
|
|
#End Region ' Logo
|
|
|
|
#Region "STYLE"
|
|
|
|
''' <summary>
|
|
''' Defines the styles used in the document.
|
|
''' </summary>
|
|
Public Sub DefineStyles(ByVal document As Document)
|
|
' recupera lo stile predefinito Normal.
|
|
Dim style As Style = document.Styles("Normal")
|
|
' Because all styles are derived from Normal, the next line changes the
|
|
' font of the whole document. Or, more exactly, it changes the font of
|
|
' all styles and paragraphs that do not redefine the font.
|
|
style.Font.Name = "Arial"
|
|
|
|
' Heading1 to Heading9 are predefined styles with an outline level. An outline level
|
|
' other than OutlineLevel.BodyText automatically creates the outline (or bookmarks)
|
|
' in PDF.
|
|
|
|
style = document.Styles("Heading1")
|
|
style.Font.Name = "Tahoma"
|
|
style.Font.Size = 14
|
|
style.Font.Bold = True
|
|
style.Font.Color = Colors.DarkBlue
|
|
style.ParagraphFormat.PageBreakBefore = True
|
|
style.ParagraphFormat.SpaceAfter = 6
|
|
|
|
style = document.Styles("Heading2")
|
|
style.Font.Size = 12
|
|
style.Font.Bold = True
|
|
style.ParagraphFormat.PageBreakBefore = False
|
|
style.ParagraphFormat.SpaceBefore = 6
|
|
style.ParagraphFormat.SpaceAfter = 6
|
|
|
|
style = document.Styles("Heading3")
|
|
style.Font.Size = 10
|
|
style.Font.Bold = True
|
|
style.Font.Italic = True
|
|
style.ParagraphFormat.SpaceBefore = 6
|
|
style.ParagraphFormat.SpaceAfter = 3
|
|
|
|
style = document.Styles(StyleNames.Header)
|
|
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right)
|
|
|
|
style = document.Styles(StyleNames.Footer)
|
|
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center)
|
|
|
|
' Create a new style called TextBox based on style Normal
|
|
style = document.Styles.AddStyle("TextBox", "Normal")
|
|
style.ParagraphFormat.Alignment = ParagraphAlignment.Justify
|
|
style.ParagraphFormat.Borders.Width = 2.5
|
|
style.ParagraphFormat.Borders.Distance = "3pt"
|
|
style.ParagraphFormat.Shading.Color = Colors.SkyBlue
|
|
|
|
' Create a new style called TOC based on style Normal
|
|
style = document.Styles.AddStyle("TOC", "Normal")
|
|
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right, TabLeader.Dots)
|
|
style.ParagraphFormat.Font.Color = Colors.Blue
|
|
End Sub
|
|
|
|
#End Region ' Style
|
|
|
|
End Module
|