本文整理汇总了C#中Availability.Add方法的典型用法代码示例。如果您正苦于以下问题:C# Availability.Add方法的具体用法?C# Availability.Add怎么用?C# Availability.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Availability
的用法示例。
在下文中一共展示了Availability.Add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnGenerate_Click
private void btnGenerate_Click(object sender, RoutedEventArgs e)
{
ReportTable = null;
avReport = null;
dgReportGrid.DataContext = null;
dgReportGrid.Visibility = Visibility.Visible;
if (cmbReportSelector.SelectedIndex == 0)
{
ReportTable = dataAccess.GetReportData(dpFrom.SelectedDate.Value, dpTo.SelectedDate.Value);
dgReportGrid.DataContext = ReportTable;
}
else if (cmbReportSelector.SelectedIndex == 1)
{
avReport = new AvailabilityReport();
int[] lineids = {1,2,3,4,5,6,7,8,9,10};
foreach (Shift s in shifts)
{
if (s.Name != "GEN_SHIFT")
{
String date = String.Empty;
foreach (Session se in s.Sessions)
{
DateTime f = new DateTime(dpFrom.SelectedDate.Value.Year,
dpFrom.SelectedDate.Value.Month,
dpFrom.SelectedDate.Value.Day,
TimeSpan.Parse(se.StartTime).Hours,
TimeSpan.Parse(se.StartTime).Minutes,
TimeSpan.Parse(se.StartTime).Seconds
);
DateTime t = new DateTime(dpTo.SelectedDate.Value.Year,
dpTo.SelectedDate.Value.Month,
dpTo.SelectedDate.Value.Day,
TimeSpan.Parse(se.EndTime).Hours,
TimeSpan.Parse(se.EndTime).Minutes,
TimeSpan.Parse(se.EndTime).Seconds
);
if (s.Name == "THIRD SHIFT" && se.Name != "FIRST HOUR")
{
t = t.AddDays(1);
date = t.ToShortDateString();
}
else
date = f.ToShortDateString();
foreach(int n in lineids)
{
DataTable dt = dataAccess.GetHourlyReportData(n, f, t);
if (dt.Rows.Count == 0) continue;
Availability av = new Availability();
for (int j = 0; j < dt.Rows.Count; j++)
{
IssueDetails issueDetail = new IssueDetails();
issueDetail.Line = (int)dt.Rows[j]["LINE"];
issueDetail.Station = (int)dt.Rows[j]["STATION"];
issueDetail.Tolerance = (int)dt.Rows[j]["Tolerance"];
issueDetail.Raised = (TimeSpan)dt.Rows[j]["Raised"];
if (dt.Rows[j]["Resolved"] == DBNull.Value)
issueDetail.Resolved = TimeSpan.Parse(se.EndTime);
else
{
issueDetail.Resolved = (TimeSpan)dt.Rows[j]["Resolved"];
if (issueDetail.Resolved > TimeSpan.Parse(se.EndTime))
{
issueDetail.Resolved = TimeSpan.Parse(se.EndTime);
}
}
TimeSpan ToleranceLimit = new TimeSpan(0, issueDetail.Tolerance, 0);
if (issueDetail.Resolved - issueDetail.Raised > ToleranceLimit)
{
av.Add(issueDetail);
}
}
avReport.Add(new AvailabilityRecord((string)dt.Rows[0]["LINENAME"],
date, f.ToShortTimeString() + "-" + t.ToShortTimeString(),
av.getAvailability( f.TimeOfDay, t.TimeOfDay).ToString()));
}
}
}
}
dgReportGrid.AutoGenerateColumns = true;
dgReportGrid.DataContext = avReport;
}
}