1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.1 KiB
C#

using HighWayIot.Log4net;
using HighWayIot.Repository.service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace HighWayIot.Winform.UserControlPages
{
public partial class MonitorMainPage : UserControl
{
LogHelper logHelper = LogHelper.Instance;
SysShiftTimeService shiftTimeService = SysShiftTimeService.Instance;
public MonitorMainPage()
{
InitializeComponent();
DateTimeRefresh();
}
/// <summary>
/// TImer事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void DataRefresh_Tick(object sender, EventArgs e)
{
if(DateTime.Now.Second == 0)
{
DateTimeRefresh();
}
}
/// <summary>
/// 白夜班时间,现在时间控件刷新
/// </summary>
private void DateTimeRefresh()
{
var timeList = shiftTimeService.GetShiftInfos();
var morningShift = timeList.Where(x => x.ShiftName == "早").FirstOrDefault();
var midShift = timeList.Where(x => x.ShiftName == "中").FirstOrDefault();
var nightShift = timeList.Where(x => x.ShiftName == "夜").FirstOrDefault();
if(morningShift == null || midShift == null || nightShift == null)
{
logHelper.Error("检查班次数据库是否早中夜班配置齐全!");
return;
}
string dayString = morningShift.ShiftStartTime.Substring(0, 5) + "-" + midShift.ShiftEndTime.Substring(0, 5);
string nightString = nightShift.ShiftStartTime.Substring(0, 5) + "-" + nightShift.ShiftEndTime.Substring(0, 5);
DayTimeLabel.Text = dayString;
NightTimeLabel.Text = nightString;
NowDateProductNumLabel.Text = DateTime.Now.ToString("MM 月 dd 日 产量");
}
}
}