Module Module1
Sub Main()
'CSV読み込み
Dim dicBunrui As New Dictionary(Of String, List(Of SagyouFormat))
Dim dicDay As New Dictionary(Of String, List(Of SagyouFormat))
'SagyouFormat作成
'作成したSagyouFormatを辞書に分類
'作業時間報告用の文字列を作成
End Sub
'Private Function GetSagyouHoukokuString(
End Module
Class SagyouList
Enum ListType
None = -1
Day = 0
Bunrui = 1
End Enum
Private List As List(Of SagyouFormat)
Public SagyouListType As ListType = ListType.None
Sub New(list As List(Of SagyouFormat), type As SagyouList.ListType)
Me.List = list
Me.SagyouListType = type
End Sub
End Class
Class SagyouFormat
Public DayYmd As String = String.Empty
Public SagyouBunrui As String = String.Empty
Public SagyouName As String = String.Empty
Public IdNo As String = String.Empty
Public SagyouTime As TimeSpan = TimeSpan.Zero
Public ErrorFormat As Boolean = False
Public Sub New(args() As String)
If args.Count <> 9 Then
ErrorFormat = True
Return
End If
DayYmd = args(0).Replace("/", String.Empty)
SagyouBunrui = args(1).Trim
SagyouName = args(2).Trim
If String.IsNullOrEmpty(args(3).Trim) Then
IdNo = "000000-00"
Else
IdNo = args(3).Trim
End If
For i As Integer = 4 To 8
If Not Me.AddTime(args(i).Trim) Then
ErrorFormat = True
Return
End If
Next
End Sub
Private Function AddTime(timeFormat As String) As Boolean
timeFormat = timeFormat.Trim
If String.IsNullOrEmpty(timeFormat) Then
Return False
End If
'変換
Dim currentSpan As TimeSpan = Me.GetSpan(timeFormat)
If currentSpan = TimeSpan.Zero Then
Return False
End If
'加える
Me.SagyouTime = Me.SagyouTime + currentSpan
Return True
End Function
Private Function GetSpan(timeFormat As String) As TimeSpan
timeFormat = timeFormat.Trim
If String.IsNullOrEmpty(timeFormat) Then
Return TimeSpan.Zero
End If
If timeFormat.Contains(":") AndAlso timeFormat.Contains("-") Then
'「:」と「-」が含まれる形式(例.10:10-12:00)
Dim tmpString As String() = timeFormat.Split("-"c)
If tmpString.Count <> 2 Then
Return TimeSpan.Zero
End If
'tmpString(0)のh:mmの文字列をDateTimeに変換
'tmpString(1)のh:mmの文字列をDateTimeに変換
'Spanを求める
'Dim startTime As DateTime =
'Dim endTime As DateTime =
'Return endTime - startTime
ElseIf timeFormat.Contains("h") Then
'hが含まれる形式(例.1hとか、1h20m)
timeFormat = timeFormat.Replace("m", String.Empty)
Dim tmpString As String() = timeFormat.Split("h"c)
Dim hours As Integer = 0
Dim minuates As Integer = 0
hours = Integer.Parse(tmpString(0))
If tmpString.Count = 2 Then
minuates = Integer.Parse(tmpString(1))
End If
Return New TimeSpan(hours, minuates, 0)
ElseIf timeFormat.Contains("m") Then
'mが含まれる形式(例.20m)
Dim minuates As Integer = 0
timeFormat = timeFormat.Replace("m", String.Empty)
'todo 分が60を超えても問題ないか確認
minuates = Integer.Parse(timeFormat)
Return New TimeSpan(0, minuates, 0)
End If
Return TimeSpan.Zero
End Function
End Class
最終更新:2016年05月19日 05:14