Fixed some export issues

This commit is contained in:
MikeMaximus
2018-02-02 10:28:17 -06:00
parent 93517f5236
commit 248efa8878
2 changed files with 30 additions and 8 deletions
+5 -5
View File
@@ -5,7 +5,7 @@ Public Class Session
Private sGame As String Private sGame As String
Private sStart As String Private sStart As String
Private sEnd As String Private sEnd As String
Private dHours As Double Private sHours As String
<XmlElement("Game")> <XmlElement("Game")>
Public Property GameName As String Public Property GameName As String
@@ -38,12 +38,12 @@ Public Class Session
End Property End Property
<XmlElement("Hours")> <XmlElement("Hours")>
Public Property Hours As Double Public Property Hours As String
Set(value As Double) Set(value As String)
dHours = value sHours = value
End Set End Set
Get Get
Return dHours Return sHours
End Get End Get
End Property End Property
End Class End Class
+25 -3
View File
@@ -1,6 +1,7 @@
Imports GBM.My.Resources Imports GBM.My.Resources
Imports System.IO Imports System.IO
Imports System.Xml.Serialization Imports System.Xml.Serialization
Imports System.Globalization
Public Class mgrSessions Public Class mgrSessions
@@ -133,12 +134,21 @@ Public Class mgrSessions
Dim oWriter As StreamWriter Dim oWriter As StreamWriter
Dim sHeader As String Dim sHeader As String
Dim sCurrentRow As String Dim sCurrentRow As String
Dim dDecimal As Decimal
Dim oBannedColumns As New List(Of DataGridViewColumn) Dim oBannedColumns As New List(Of DataGridViewColumn)
Dim oDecimalColumns As New List(Of DataGridViewColumn)
Dim oNfi As New NumberFormatInfo
'We want to force a specific decimal seperator when exporting CSV files due to certain regions using a comma.
oNfi.NumberDecimalSeparator = "."
Try Try
oWriter = New StreamWriter(sLocation) oWriter = New StreamWriter(sLocation)
'Ban Columns 'Set Decimal Columns
oDecimalColumns.Add(dg.Columns("Hours"))
'Set Ban Columns
oBannedColumns.Add(dg.Columns("MonitorID")) oBannedColumns.Add(dg.Columns("MonitorID"))
If bUnixTime Then If bUnixTime Then
@@ -167,11 +177,23 @@ Public Class mgrSessions
sCurrentRow = String.Empty sCurrentRow = String.Empty
For Each dgCell As DataGridViewCell In dgRow.Cells For Each dgCell As DataGridViewCell In dgRow.Cells
If Not oBannedColumns.Contains(dg.Columns(dgCell.ColumnIndex)) Then If Not oBannedColumns.Contains(dg.Columns(dgCell.ColumnIndex)) Then
sCurrentRow &= dgCell.Value.ToString & "," If oDecimalColumns.Contains(dg.Columns(dgCell.ColumnIndex)) Then
dDecimal = CDec(dgCell.Value)
sCurrentRow &= dDecimal.ToString(oNfi) & ","
Else
sCurrentRow &= dgCell.Value.ToString & ","
End If
End If End If
Next Next
sCurrentRow = sCurrentRow.TrimEnd(",") sCurrentRow = sCurrentRow.TrimEnd(",")
oWriter.WriteLine(sCurrentRow)
'Don't write a LF on the last row
If dg.Rows.Count = (dgRow.Index + 1) Then
oWriter.Write(sCurrentRow)
Else
oWriter.WriteLine(sCurrentRow)
End If
Next Next
'Finish up 'Finish up