選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

165 行
4.2KB

  1. <%
  2. Class PurpleEnvelopeReportHelper_Class
  3. Public Function FormatElectionLabel(ByVal rawValue)
  4. FormatElectionLabel = Trim(rawValue & "")
  5. If Len(FormatElectionLabel) = 0 Then Exit Function
  6. On Error Resume Next
  7. dim parsedDate : parsedDate = CDate(rawValue)
  8. If Err.Number = 0 Then
  9. FormatElectionLabel = MonthName(Month(parsedDate), True) & "-" & CStr(Year(parsedDate))
  10. Else
  11. Err.Clear
  12. End If
  13. On Error GoTo 0
  14. End Function
  15. Public Function SortPrecinctColorRows(ByVal rs)
  16. dim list : set list = new LinkedList_Class
  17. If rs.EOF Then
  18. set SortPrecinctColorRows = list
  19. Exit Function
  20. End If
  21. dim items()
  22. dim itemCount : itemCount = -1
  23. Do Until rs.EOF
  24. itemCount = itemCount + 1
  25. ReDim Preserve items(itemCount)
  26. dim row : set row = new PrecinctColorRow_ViewModel_Class
  27. row.PRECINCT = rs("PRECINCT")
  28. If IsNull(rs("ColorId")) Then
  29. row.ColorId = ""
  30. Else
  31. row.ColorId = rs("ColorId")
  32. End If
  33. Set items(itemCount) = row
  34. rs.MoveNext
  35. Loop
  36. SortPrecinctItems items
  37. dim i
  38. For i = 0 To UBound(items)
  39. list.Push items(i)
  40. Next
  41. set SortPrecinctColorRows = list
  42. End Function
  43. Public Function SortPrecinctBallotRangeRows(ByVal rs)
  44. dim list : set list = new LinkedList_Class
  45. If rs.EOF Then
  46. set SortPrecinctBallotRangeRows = list
  47. Exit Function
  48. End If
  49. dim items()
  50. dim itemCount : itemCount = -1
  51. Do Until rs.EOF
  52. itemCount = itemCount + 1
  53. ReDim Preserve items(itemCount)
  54. dim row : set row = new PrecinctBallotRangeRow_ViewModel_Class
  55. row.PRECINCT = rs("PRECINCT")
  56. row.LowBallotNumber = rs("LowBallotNumber")
  57. row.HighBallotNumber = rs("HighBallotNumber")
  58. Set items(itemCount) = row
  59. rs.MoveNext
  60. Loop
  61. SortPrecinctItems items
  62. dim i
  63. For i = 0 To UBound(items)
  64. list.Push items(i)
  65. Next
  66. set SortPrecinctBallotRangeRows = list
  67. End Function
  68. Private Sub SortPrecinctItems(ByRef items)
  69. If Not IsArray(items) Then Exit Sub
  70. dim i, j
  71. For i = 0 To UBound(items) - 1
  72. For j = i + 1 To UBound(items)
  73. If PrecinctSortsBefore(items(j).PRECINCT, items(i).PRECINCT) Then
  74. dim temp : set temp = items(i)
  75. Set items(i) = items(j)
  76. Set items(j) = temp
  77. End If
  78. Next
  79. Next
  80. End Sub
  81. Private Function PrecinctSortsBefore(ByVal leftPrecinct, ByVal rightPrecinct)
  82. dim leftType, leftNumber, leftSuffix, leftNormalized
  83. dim rightType, rightNumber, rightSuffix, rightNormalized
  84. ParsePrecinctSortParts leftPrecinct, leftType, leftNumber, leftSuffix, leftNormalized
  85. ParsePrecinctSortParts rightPrecinct, rightType, rightNumber, rightSuffix, rightNormalized
  86. If leftType <> rightType Then
  87. PrecinctSortsBefore = (leftType < rightType)
  88. Exit Function
  89. End If
  90. If leftType = 0 Then
  91. If leftNumber <> rightNumber Then
  92. PrecinctSortsBefore = (leftNumber < rightNumber)
  93. Exit Function
  94. End If
  95. If leftSuffix <> rightSuffix Then
  96. PrecinctSortsBefore = (leftSuffix < rightSuffix)
  97. Exit Function
  98. End If
  99. End If
  100. If leftNormalized <> rightNormalized Then
  101. PrecinctSortsBefore = (leftNormalized < rightNormalized)
  102. Else
  103. PrecinctSortsBefore = (UCase(Trim(leftPrecinct & "")) < UCase(Trim(rightPrecinct & "")))
  104. End If
  105. End Function
  106. Private Sub ParsePrecinctSortParts(ByVal precinct, ByRef precinctType, ByRef numericPart, ByRef suffixPart, ByRef normalizedText)
  107. dim rawPrecinct : rawPrecinct = Trim(precinct & "")
  108. dim leadingDigits : leadingDigits = ""
  109. dim i, currentChar
  110. For i = 1 To Len(rawPrecinct)
  111. currentChar = Mid(rawPrecinct, i, 1)
  112. If currentChar >= "0" And currentChar <= "9" Then
  113. leadingDigits = leadingDigits & currentChar
  114. Else
  115. Exit For
  116. End If
  117. Next
  118. If Len(leadingDigits) > 0 Then
  119. precinctType = 0
  120. numericPart = CLng(leadingDigits)
  121. suffixPart = UCase(Trim(Mid(rawPrecinct, Len(leadingDigits) + 1)))
  122. normalizedText = CStr(numericPart) & "|" & suffixPart
  123. Else
  124. precinctType = 1
  125. numericPart = 0
  126. suffixPart = UCase(rawPrecinct)
  127. normalizedText = suffixPart
  128. End If
  129. End Sub
  130. End Class
  131. dim PurpleEnvelopeReportHelper__Singleton
  132. Function PurpleEnvelopeReportHelper()
  133. If IsEmpty(PurpleEnvelopeReportHelper__Singleton) Then
  134. set PurpleEnvelopeReportHelper__Singleton = new PurpleEnvelopeReportHelper_Class
  135. End If
  136. set PurpleEnvelopeReportHelper = PurpleEnvelopeReportHelper__Singleton
  137. End Function
  138. %>

Powered by TurnKey Linux.