Const TimeZoneParameterName As String = "TimeZone"
Const SD_BaseTypeParameterName As String = "StartDate_BaseType"
Const SD_BaseValueParameterName As String = "StartDate_BaseValue"
Const SD_OffsetTypeParameterName As String = "StartDate_OffsetType"
Const SD_OffsetValueParameterName As String = "StartDate_OffsetValue"
Const ED_BaseTypeParameterName As String = "EndDate_BaseType"
Const ED_BaseValueParameterName As String = "EndDate_BaseValue"
Const ED_OffsetTypeParameterName As String = "EndDate_OffsetType"
Const ED_OffsetValueParameterName As String = "EndDate_OffsetValue"
Const IsRelativeTimeSupported As Boolean = True
Const TimeTypeParameterName As String = "TimeType"
Const TimeWeekMapParameterName As String = "TimeWeekMap"
Const DataAggregationParameterName As String = "DataAggregation"
Dim LocTables As System.Collections.Generic.Dictionary(Of String, Microsoft.EnterpriseManagement.Reporting.XmlStringTable)
Dim ReportTimeZone As Microsoft.EnterpriseManagement.Reporting.TimeZoneCoreInformation
Dim ReportStartDate As DateTime
Dim ReportEndDate As DateTime
Dim ReportTime As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime
Dim ReportCulture As System.Globalization.CultureInfo
Dim ParameterProcessor As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor
Dim InitLock As New Object
Const TimeIntervalCount As Integer = 6
Const TimeIntervalParameterName As String = "TimeInterval"
Dim TimeIntervalTable(TimeIntervalCount - 1) As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Dim TimeIntervalParameterTable As System.Collections.Generic.List(Of String)
Dim SlaTable As System.Collections.Generic.Dictionary(Of SlaIdentity, System.Collections.Generic.Dictionary(Of Integer, SloValue))
Protected Overrides Sub OnInit()
LocTables = new System.Collections.Generic.Dictionary(Of String, Microsoft.EnterpriseManagement.Reporting.XmlStringTable)()
ReportTimeZone = Nothing
ReportStartDate = DateTime.MinValue
ReportEndDate = DateTime.MinValue
ReportTime = Nothing
ReportCulture = System.Globalization.CultureInfo.GetCultureInfo(Report.User("Language"))
ParameterProcessor = New Microsoft.EnterpriseManagement.Reporting.ParameterProcessor(ReportCulture)
SlaTable = New System.Collections.Generic.Dictionary(Of SlaIdentity, System.Collections.Generic.Dictionary(Of Integer, SloValue))()
End Sub
Public Function GetCallingManagementGroupId() As String
Return Microsoft.EnterpriseManagement.Reporting.ReportingConfiguration.ManagementGroupId
End Function
Public Function GetReportLocLanguageCode() As String
Return ReportCulture.ThreeLetterWindowsLanguageName
End Function
Public Function GetLocTable(Name As String) As Microsoft.EnterpriseManagement.Reporting.XmlStringTable
Dim LocTable As Microsoft.EnterpriseManagement.Reporting.XmlStringTable
If Not LocTables.TryGetValue(Name, LocTable) Then
LocTable = New Microsoft.EnterpriseManagement.Reporting.XmlStringTable(LocTableStringQuery, Report.Parameters(Name).Value)
LocTables.Add(Name, LocTable)
End If
Return LocTable
End Function
Public Function GetReportTimeZone() As Microsoft.EnterpriseManagement.Reporting.TimeZoneCoreInformation
SyncLock InitLock
If IsNothing(ReportTimeZone) Then ReportTimeZone = Microsoft.EnterpriseManagement.Reporting.TimeZoneCoreInformation.FromValueString(Report.Parameters(TimeZoneParameterName).Value)
Return ReportTimeZone
End SyncLock
End Function
Public Function ToDbDate(ByVal DateValue As DateTime) As DateTime
return GetReportTimeZone.ToUniversalTime(DateValue)
End Function
Public Function ToReportDate(ByVal DateValue As DateTime) As DateTime
return GetReportTimeZone.ToLocalTime(DateValue)
End Function
Public Function GetReportStartDate() As DateTime
SyncLock InitLock
If (ReportStartDate = DateTime.MinValue) Then
If (IsRelativeTimeSupported) Then
ReportStartDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(SD_BaseTypeParameterName).Value, Report.Parameters(SD_BaseValueParameterName).Value, Report.Parameters(SD_OffsetTypeParameterName).Value, Report.Parameters(SD_OffsetValueParameterName).Value, Report.Parameters(TimeTypeParameterName).Value)
Else
ReportStartDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(SD_BaseTypeParameterName).Value, Report.Parameters(SD_BaseValueParameterName).Value, Report.Parameters(SD_OffsetTypeParameterName).Value, Report.Parameters(SD_OffsetValueParameterName).Value)
End if
If (CInt(Report.Parameters(DataAggregationParameterName).Value) > 0) Then
ReportStartDate = ReportStartDate.Date
End If
End If
return ReportStartDate
End SyncLock
End Function
Public Function GetReportEndDate() As DateTime
SyncLock InitLock
If (ReportEndDate = DateTime.MinValue) Then
If (IsRelativeTimeSupported) Then
ReportEndDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(ED_BaseTypeParameterName).Value, Report.Parameters(ED_BaseValueParameterName).Value, Report.Parameters(ED_OffsetTypeParameterName).Value, Report.Parameters(ED_OffsetValueParameterName).Value, Report.Parameters(TimeTypeParameterName).Value)
If IsBusinessHours(GetReportTimeFilter()) Then ReportEndDate = ReportCulture.Calendar.AddDays(ReportEndDate, 1)
Else
ReportEndDate = ParameterProcessor.GetDateTime(ToReportDate(DateTime.UtcNow), Report.Parameters(ED_BaseTypeParameterName).Value, Report.Parameters(ED_BaseValueParameterName).Value, Report.Parameters(ED_OffsetTypeParameterName).Value, Report.Parameters(ED_OffsetValueParameterName).Value)
End if
If (CInt(Report.Parameters(DataAggregationParameterName).Value) > 0) Then
ReportEndDate = ReportEndDate.Date
End If
End If
return ReportEndDate
End SyncLock
End Function
Public Function GetReportTimeFilter() As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime
SyncLock InitLock
If IsNothing(ReportTime) Then
If (CInt(Report.Parameters(DataAggregationParameterName).Value) = 0)
ReportTime = New Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime(Report.Parameters(TimeTypeParameterName).Value, Report.Parameters(SD_BaseValueParameterName).Value, Report.Parameters(ED_BaseValueParameterName).Value, CStr(Join(Report.Parameters(TimeWeekMapParameterName).Value, ",")))
Else
ReportTime = New Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime(Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTimeType.Regular, Report.Parameters(SD_BaseValueParameterName).Value, Report.Parameters(ED_BaseValueParameterName).Value, CStr(Join(Report.Parameters(TimeWeekMapParameterName).Value, ",")))
End if
End If
return ReportTime
End SyncLock
End Function
Public Function IsBusinessHours(Value As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime) As Boolean
return (Not IsNothing(Value)) And (Value.TimeType = Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTimeType.Business)
End Function
Public Function FormatDateTime(Format As String, Value As DateTime) As String
return Value.ToString(Format, ReportCulture)
End Function
Public Function FormatNumber(Format As String, Value As Decimal) As String
return Value.ToString(Format, ReportCulture)
End Function
Public Function FormatString(Format As String, ParamArray Values() as Object) As String
return String.Format(ReportCulture, Format, Values)
End Function
Public Function NullFormatString(Format As String, Value as String) As String
return IIF(String.IsNullOrEmpty(Value), String.Empty, String.Format(ReportCulture, Format, Value))
End Function
Public Function FormatBusinessHours(Format As String, Value As Microsoft.EnterpriseManagement.Reporting.ParameterProcessor.RelativeTime) As String
Dim result As String
If IsBusinessHours(Value) Then
Dim firstDay As DayOfWeek
Dim days As System.Collections.Generic.List(Of String)
firstDay = ReportCulture.DateTimeFormat.FirstDayOfWeek
days = new System.Collections.Generic.List(Of String)()
For loopDay As DayOfWeek = DayOfWeek.Sunday To DayOfWeek.Saturday
Dim day As DayOfWeek
day = CType((CInt(loopDay) + CInt(firstDay)) Mod 7, DayOfWeek)
If value.WeekMap.Contains(day) Then days.Add(ReportCulture.DateTimeFormat.GetAbbreviatedDayName(day))
Next loopDay
result = FormatString(Format, DateTime.Today.Add(Value.StartTime).ToString(ReportCulture.DateTimeFormat.ShortTimePattern), DateTime.Today.Add(Value.EndTime).ToString(ReportCulture.DateTimeFormat.ShortTimePattern), String.Join(",", days.ToArray()))
Else
result = String.Empty
End if
return result
End Function
REM ---------------------------------
Public Enum DataAggregationType
Hourly = 0
Daily = 1
End Enum
Public Function GetDBDataAggregationTypeId(ByVal aggregation As DataAggregationType) As Integer
Select Case aggregation
Case DataAggregationType.Hourly
Return 20
Case DataAggregationType.Daily
Return 30
Case Else
Return 0
End Select
End Function
Public Function NormalizeDateValue(ByVal aggregation As DataAggregationType, ByVal Value As DateTime) As DateTime
Dim Result As DateTime = Value.Date.AddHours(Value.Hour)
If aggregation = DataAggregationType.Daily Then
Result = Result.AddHours(1)
End If
Return Result
End Function
REM ---------------------------------
Public Enum SloObjectiveType
Under = 0
Over = 1
End Enum
Public Class SloValue
Private CurrentValue As Double
Private RelatedValueTable() As Double = New Double() {}
Public ReadOnly Goal As Double
Public ReadOnly Objective As SloObjectiveType
Public Sub New(ByVal SloValue As Double, ByVal SloGoal As Double, ByVal SloObjective As SloObjectiveType)
CurrentValue = SloValue
Goal = SloGoal
Objective = SloObjective
End Sub
Public Sub New(ByVal SloValue As Double, ByVal SloGoal As Double, ByVal SloObjective As String)
CurrentValue = SloValue
Goal = SloGoal
Objective = [Enum].Parse(GetType(SloObjectiveType), SloObjective, True)
End Sub
Public ReadOnly Property Value() As Double
Get
Return CurrentValue
End Get
End Property
Public ReadOnly Property RelatedValues() As Double()
Get
Return RelatedValueTable
End Get
End Property
Public Function IsGoalMet() As Boolean
Return IIf(Objective = SloObjectiveType.Under, CurrentValue <= Goal, CurrentValue >= Goal)
End Function
Public Function IsRelatedGoalMet(ByVal Index As Integer) As Nullable(Of Boolean)
Dim RelatedValue As Double = RelatedValues(Index)
If Double.IsNaN(RelatedValue) Then
Return Nothing
Else
Return New Nullable(Of Boolean)(IIf(Objective = SloObjectiveType.Under, RelatedValue <= Goal, RelatedValue >= Goal))
End If
End Function
Public Sub CollectValue(ByVal NewValue As Double)
Select Case Objective
Case SloObjectiveType.Over
If (NewValue < CurrentValue) Then
CurrentValue = NewValue
End If
Case SloObjectiveType.Under
If (NewValue > CurrentValue) Then
CurrentValue = NewValue
End If
End Select
End Sub
Public Sub CollectRelatedValue(ByVal Index As Integer, ByVal NewValue As Double)
If Index >= RelatedValues.Length Then
ReDim Preserve RelatedValueTable(Index)
RelatedValues(Index) = Double.NaN
End If
If Not Double.IsNaN(NewValue) Then
If Double.IsNaN(RelatedValues(Index)) Then
RelatedValues(Index) = NewValue
Else
Select Case Objective
Case SloObjectiveType.Over
If (NewValue < RelatedValues(Index)) Then
RelatedValues(Index) = NewValue
End If
Case SloObjectiveType.Under
If (NewValue > RelatedValues(Index)) Then
RelatedValues(Index) = NewValue
End If
End Select
End If
End If
End Sub
End Class
REM ---------------------------------
Public Class SlaIdentity
Implements IEquatable(Of SlaIdentity)
Public ReadOnly Id As Integer
Public ReadOnly GroupId As Integer
Public ReadOnly ObjectId As Integer
Public Sub New(ByVal ManagementGroupId As Integer, ByVal SlaId As Integer, ByVal SlaObjectId As Integer)
Id = SlaId
GroupId = ManagementGroupId
ObjectId = SlaObjectId
End Sub
Public Overloads Function Equals(ByVal other As SlaIdentity) As Boolean Implements System.IEquatable(Of SlaIdentity).Equals
Return Id = other.Id And ObjectId = other.ObjectId And GroupId = other.GroupId
End Function
Public Overrides Function GetHashCode() As Integer
Return (GroupId << 25) Or (Id << 14) Or ObjectId
End Function
End Class
REM ---------------------------------
Public Function AddSloValue(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer, ByVal Value As Double, ByVal Goal As Double, ByVal Objective As String) As Double
Dim CurrentValue As SloValue = Nothing
Dim SloTable As System.Collections.Generic.Dictionary(Of Integer, SloValue) = Nothing
Dim SlaId As SlaIdentity = New SlaIdentity(ManagementGroup, Sla, SlaObject)
If Not SlaTable.TryGetValue(SlaId, SloTable) Then
SloTable = New System.Collections.Generic.Dictionary(Of Integer, SloValue)()
SlaTable.Add(SlaId, SloTable)
End If
If Not SloTable.TryGetValue(Slo, CurrentValue) Then
CurrentValue = New SloValue(Value, Goal, Objective)
SloTable.Add(Slo, CurrentValue)
Else
CurrentValue.CollectValue(Value)
End If
Return CurrentValue.Value
End Function
Public Function AddRelatedSloValue(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer, ByVal Value As Object, ByVal Index As Integer) As Double
Dim SloVal As SloValue = SlaTable(New SlaIdentity(ManagementGroup, Sla, SlaObject))(Slo)
SloVal.CollectRelatedValue(Index, IIf(IsNothing(Value), Double.NaN, CDbl(Value)))
Return SloVal.RelatedValues(Index)
End Function
Public Function GetSlo(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer) As SloValue
Dim SlaId As SlaIdentity = New SlaIdentity(ManagementGroup, Sla, SlaObject)
If SlaTable.ContainsKey(SlaId) Then
Dim Value As SloValue = Nothing
If SlaTable(SlaId).TryGetValue(Slo, Value) Then
Return Value
Else
Return Nothing
End If
Else
Return Nothing
End If
End Function
Public Function GetSloValue(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer) As Double
Dim Value As SloValue = GetSlo(ManagementGroup, Sla, SlaObject, Slo)
If IsNothing(Value) Then
Return Double.NaN
Else
Return Value.Value
End If
End Function
Public Function GetRelatedSloValue(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer, ByVal Index As Integer) As Double
Dim Value As SloValue = GetSlo(ManagementGroup, Sla, SlaObject, Slo)
If IsNothing(Value) Then
Return Double.NaN
Else
Return Value.RelatedValues(Index)
End If
End Function
Public Function GetSloCondition(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer) As Nullable(Of Boolean)
Dim Value As SloValue = GetSlo(ManagementGroup, Sla, SlaObject, Slo)
If IsNothing(Value) Then
Return Nothing
Else
Return Value.IsGoalMet()
End If
End Function
Public Function GetRelatedSloCondition(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer, ByVal Index As Integer) As Nullable(Of Boolean)
Dim Value As SloValue = GetSlo(ManagementGroup, Sla, SlaObject, Slo)
If IsNothing(Value) Then
Return Nothing
Else
Return Value.IsRelatedGoalMet(Index)
End If
End Function
Public Function GetSlaCondition(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer) As Nullable(Of Boolean)
Dim SlaId As SlaIdentity = New SlaIdentity(ManagementGroup, Sla, SlaObject)
Dim Result As Nullable(Of Boolean) = Nothing
If SlaTable.ContainsKey(SlaId) Then
For Each Value As SloValue In SlaTable(SlaId).Values
If (Not Value.IsGoalMet()) Then
Return False
Else
Result = True
End If
Next
End If
Return Result
End Function
Public Function GetRelatedSlaCondition(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Index As Integer) As Nullable(Of Boolean)
Dim SlaId As SlaIdentity = New SlaIdentity(ManagementGroup, Sla, SlaObject)
Dim Result As Nullable(Of Boolean) = Nothing
If SlaTable.ContainsKey(SlaId) Then
For Each Value As SloValue In SlaTable(SlaId).Values
If Not IsNothing(Value.IsRelatedGoalMet(Index)) Then
If (Not Value.IsRelatedGoalMet(Index).Value) Then
Return False
Else
Result = True
End If
End If
Next
End If
Return Result
End Function
Public Function GetMaxSloValue(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer) As Double
Dim Value As SloValue = GetSlo(ManagementGroup, Sla, SlaObject, Slo)
Dim Result As Double = Double.NaN
If Not IsNothing(Value) Then
Result = Value.Goal
If Value.Value > Result Then
Result = Value.Value
End If
For Each RelatedValue As Double In Value.RelatedValues
If RelatedValue > Result Then
Result = RelatedValue
End If
Next
End If
Return Result
End Function
Public Function GetMinSloValue(ByVal ManagementGroup As Integer, ByVal Sla As Integer, ByVal SlaObject As Integer, ByVal Slo As Integer) As Double
Dim Value As SloValue = GetSlo(ManagementGroup, Sla, SlaObject, Slo)
Dim Result As Double = 0
If Not IsNothing(Value) Then
If Value.Goal < Result Then
Result = Value.Goal
End If
If Value.Value < Result Then
Result = Value.Value
End If
For Each RelatedValue As Double In Value.RelatedValues
If RelatedValue < Result Then
Result = RelatedValue
End If
Next
End If
Return Result
End Function
REM ---------------------------------
Public Function GetTimeIntervalParameterTable() As System.Collections.Generic.IList(Of String)
If IsNothing(TimeIntervalParameterTable) Then
TimeIntervalParameterTable = New System.Collections.Generic.List(Of String)()
For Each Value As String In Report.Parameters(TimeIntervalParameterName).Value
If Not IsNothing(Value) Then
If Not String.IsNullOrEmpty(Value.Trim()) Then
TimeIntervalParameterTable.Add(Value)
End If
End If
Next
End If
Return TimeIntervalParameterTable
End Function
Public Function GetTimeInterval(ByVal Index As Integer) As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Dim Value As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval = Nothing
If (Index >= 0) And (Index < TimeIntervalCount) Then
Value = TimeIntervalTable(Index)
If IsNothing(Value) Then
If GetTimeIntervalParameterTable().Count > Index Then
Value = New Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval(GetReportEndDate(), GetTimeIntervalParameterTable()(Index), ReportCulture)
TimeIntervalTable(Index) = Value
End If
End If
End If
Return Value
End Function
Public Function GetTimeIntervalTitle(ByVal Index As Integer) As String
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Interval = GetTimeInterval(Index)
If IsNothing(Interval) Then
Return Nothing
Else
Return Interval.Title
End If
End Function
Public Function IsTimeIntervalContains(ByVal Index As Integer, ByVal Value As DateTime) As Boolean
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Interval = GetTimeInterval(Index)
If IsNothing(Interval) Then
Return False
Else
Return Interval.Contains(Value)
End If
End Function
Public Function IsTimeIntervalHidden(ByVal Index As Integer) As Boolean
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Interval = GetTimeInterval(Index)
Return IsNothing(Interval)
End Function
Public Function CalculateTimeIntervalValue(ByVal Index As Integer, ByVal aggregation As DataAggregationType, ByVal IntervalDate As DateTime, ByVal Value As Object) As Object
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Interval = GetTimeInterval(Index)
If IsNothing(Interval) Then
Return System.DBNull.Value
Else
If ((IntervalDate >= NormalizeDateValue(aggregation, Interval.StartDate)) and (IntervalDate < NormalizeDateValue(aggregation, Interval.EndDate))) Then
Return Value
Else
Return System.DBNull.Value
End If
End If
End Function
Public Function GetTimeIntervalParameterStartDate(ByVal Index As Integer) As DateTime
Dim Result As DateTime = GetTimeIntervalStartDate(Index)
If IsBusinessHours(GetReportTimeFilter()) Then
Result = Result.Date + GetReportTimeFilter().StartTime
End If
Return Result
End Function
Public Function GetTimeIntervalParameterEndDate(ByVal Index As Integer) As DateTime
Dim Result As DateTime = GetTimeIntervalEndDate(Index)
If IsBusinessHours(GetReportTimeFilter()) Then
Result = Result.Date.AddDays(-1) + GetReportTimeFilter().EndTime
End If
Return Result
End Function
Public Function GetTimeIntervalStartDate(ByVal Index As Integer) As Date
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Interval = GetTimeInterval(Index)
If IsNothing(Interval) Then
Return Nothing
Else
Return Interval.StartDate
End If
End Function
Public Function GetTimeIntervalEndDate(ByVal Index As Integer) As Date
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
Interval = GetTimeInterval(Index)
If IsNothing(Interval) Then
Return Nothing
Else
Return Interval.EndDate
End If
End Function
Public Function GetReportMinStartDate() As DateTime
Dim Index As Integer
Dim MinStartDate As DateTime = GetReportStartDate()
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
For Index = 0 To TimeIntervalCount - 1
Interval = GetTimeInterval(Index)
If (Not IsNothing(Interval)) Then
If (Interval.StartDate < MinStartDate) Then
MinStartDate = Interval.StartDate
End If
End If
Next
Return MinStartDate
End Function
Public Function GetReportMaxEndDate() As DateTime
Dim Index As Integer
Dim MaxEndDate As DateTime = GetReportEndDate()
Dim Interval As Microsoft.EnterpriseManagement.Reporting.ParameterTimeInterval
For Index = 0 To TimeIntervalCount - 1
Interval = GetTimeInterval(Index)
If (Not IsNothing(Interval)) Then
If (Interval.EndDate > MaxEndDate) Then
MaxEndDate = Interval.EndDate
End If
End If
Next
Return MaxEndDate
End Function
Public Function CalculateReportDurationValue(ByVal aggregation As DataAggregationType, ByVal IntervalDate As DateTime, ByVal Value As Object) As Object
If ((IntervalDate >= NormalizeDateValue(aggregation, GetReportStartDate())) and (IntervalDate < NormalizeDateValue(aggregation, GetReportEndDate()))) Then
Return Value
Else
Return System.DBNull.Value
End If
End Function
REM ---------------------------------
Public Enum SloValueType
Number = 0
Percent = 1
End Enum
Public Function FormatSloValue(ByVal Value As Object, ByVal ValueType As SloValueType) As String
If Double.IsNaN(Value) Then
Return String.Empty
Else
Select Case ValueType
Case SloValueType.Number
Return FormatNumber("G12", Value)
Case SloValueType.Percent
IF(Value Mod 100 = 0)
Return FormatNumber("P0", Value/100)
Else
Return FormatNumber("P2", Value/100)
End If
End Select
End If
End Function
Public Function GetSloImage(ByVal Value As Nullable(Of Boolean)) As String
If IsNothing(Value) Then
Return "Error"
Else
Return IIF(Value.Value, "Ok", "Error")
End If
End Function
Public Function GetSlaImage(ByVal Value As Nullable(Of Boolean)) As String
If IsNothing(Value) Then
Return "NoDataLarge.gif"
Else
Return IIF(Value.Value, "TrueLarge.gif", "FalseLarge.gif")
End If
End Function