private void LoadData(AttendanceRecord attendanceRecord) { var errCode = 0; var errMsg = string.Empty; todayAttendanceRecords = attendanceRecord; if (todayAttendanceRecords == null) { return; } checkInDataTime = todayAttendanceRecords.PuncherDateTime; AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg); DateTime serverDateTime = DateTime.Now; if (serverResult != null) { serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime); } var diffMinute = serverDateTime - checkInDataTime; if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString()) { return; } if (diffMinute.Hours > 6) { return; } if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20 || !todayAttendanceRecords.IsbtnVerify) { return; } //设置定时器 timer?.Stop(); timer = null; timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 1); //时间间隔为一秒 timer.Tick += new EventHandler(timer_Tick); var minuteChangeSecond = 0d; if (diffMinute.TotalMinutes < 0) { minuteChangeSecond = (20 - 0.01) * 60; } else { minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60; } //处理倒计时的类 processCount = new ProcessCount((int)minuteChangeSecond); //Application.Current.Dispatcher.Invoke((Action)(() => //{ todayAttendanceRecords.ChcekInTimer = "(" + processCount.GetMinute() + "分" + processCount.GetSecond() + "秒" + ")"; //})); CountDown += new CountDownHandler(processCount.ProcessCountDown); //开启定时器 timer.Start(); }
private void ButtonBase3_OnClick(object sender, RoutedEventArgs e) { //处理倒计时的类 processCount = new ProcessCount(hour * 3600 + minute * 60 + second); CountDown += new CountDownHandler(processCount.ProcessCountDown); //开启定时器 timer.Start(); }
/// <summary> /// 窗口加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainWin_Loaded(object sender, RoutedEventArgs e)//////////////////////////////////////// { //设置定时器 timer = new DispatcherTimer(); timer.Interval = new TimeSpan(10000000); //时间间隔为一秒 timer.Tick += new EventHandler(timer_Tick); //转换成秒数 //Int32 hour = Convert.ToInt32(HourArea.Text); //Int32 minute = Convert.ToInt32(MinuteArea.Text); Int32 second = Convert.ToInt32(SecondArea.Text); //处理倒计时的类 processCount = new ProcessCount(second); CountDown += new CountDownHandler(processCount.ProcessCountDown); //开启定时器 timer.Start(); }
private void ButtonBase_OnClick(object sender, RoutedEventArgs e) { timer.IsEnabled = true; //转换成秒数 hour = Convert.ToInt32(HourArea.Text); minute = Convert.ToInt32(MinuteArea.Text); second = Convert.ToInt32(SecondArea.Text); //处理倒计时的类 processCount = new ProcessCount(hour * 3600 + minute * 60 + second); CountDown += new CountDownHandler(processCount.ProcessCountDown); //开启定时器 timer.Start(); }
public MainWindow() { InitializeComponent(); thislock = new object(); config = new double[ExternalFunctions.GetConfigSize()]; ExternalFunctions.GetConfig(config); WrongTime = new double[ExternalFunctions.GetMaxTimeSize()]; ExternalFunctions.GetMaxTime(WrongTime); m_GridCameraWindow.Children.Add(new CameraWindow()); ThreadStart ts = new ThreadStart(DisplayInfos); t = new Thread(ts); t.Start(); playbeep = new Thread(new ParameterizedThreadStart(_Beep)); playfiletune = new Thread(new ParameterizedThreadStart(_PlayTune)); countDownTimer = new DispatcherTimer(); countDownTimer.Interval = new TimeSpan(10000000); //时间间隔为一秒 countDownTimer.Tick += new EventHandler(timer_Tick); HourArea.Text = Default.SetTimeHour.ToString(); MinuteArea.Text = Default.SetTimeMinute.ToString(); SecondArea.Text = Default.SetTimeSecond.ToString(); Int32 hour = Convert.ToInt32(HourArea.Text); Int32 minute = Convert.ToInt32(MinuteArea.Text); Int32 second = Convert.ToInt32(SecondArea.Text); //处理倒计时的类 processCount = new ProcessCount(hour * 3600 + minute * 60 + second); CountDown += new CountDownHandler(processCount.ProcessCountDown); ExternalFunctions.ConfigDisable(4); }
//private bool CmdPing(string strIp) ////通过CMD中的ping命令去得电脑上网IP //{ // bool returnvalue = false; // Process p = new Process(); p.StartInfo.FileName = "cmd.exe";//设定程序名 // p.StartInfo.UseShellExecute = false; //关闭Shell的使用 // p.StartInfo.RedirectStandardInput = true;//重定向标准输入 // p.StartInfo.RedirectStandardOutput = true;//重定向标准输出 // p.StartInfo.RedirectStandardError = true;//重定向错误输出 // p.StartInfo.CreateNoWindow = true;//设置不显示窗口 // p.Start(); p.StandardInput.WriteLine("ping -n 2 -w 1 -S " + strIp + " " + "GuangWang"); // p.StandardInput.WriteLine("exit"); // string strRst = p.StandardOutput.ReadToEnd(); // if (strRst.IndexOf("(100% 丢失)") != -1 || strRst.IndexOf("(100% loss)") != -1) // { // returnvalue = false; // } // else // { // returnvalue = true; // } // p.Close(); // return returnvalue; //} /// <summary> /// 加载初始化数据 /// </summary> private void LoadData() { string _ComputName = System.Net.Dns.GetHostName(); listIp = NetworkHelper.GetPhysicsNetworkCardIP(); if (listIp.Count > 0) { hostIp = listIp[0]; } //System.Net.IPAddress[] _IPList = System.Net.Dns.GetHostAddresses(_ComputName); //for (int i = 0; i != _IPList.Length; i++) //{ // if (_IPList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) // { // hostIp = _IPList[i].ToString(); // MessageBoxWindow.Show(hostIp, GlobalVariable.WarnOrSuccess.Success); // break; // } //} var errCode = 0; var errMsg = string.Empty; AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg); DateTime serverDateTime = DateTime.Now; if (serverResult != null) { serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime); } var diffMinute = serverDateTime - checkInDataTime; if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString()) { return; } if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20) { return; } //设置定时器 timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 0, 1); //时间间隔为一秒 timer.Tick += new EventHandler(timer_Tick); var minuteChangeSecond = 0d; if (diffMinute.TotalMinutes < 0) { minuteChangeSecond = (20 - 0.01) * 60; } else { minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60; } //处理倒计时的类 processCount = new ProcessCount((int)minuteChangeSecond); ChcekInTimer = processCount.GetMinute() + "分" + processCount.GetSecond() + "秒"; CountDown += new CountDownHandler(processCount.ProcessCountDown); //开启定时器 timer.Start(); }