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(); }
/// <summary> /// Timer触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Tick(object sender, EventArgs e) { if (OnCountDown()) { //HourArea.Text = processCount.GetHour(); //MinuteArea.Text = processCount.GetMinute(); //SecondArea.Text = processCount.GetSecond(); ChcekInTimer = processCount.GetMinute() + "分" + processCount.GetSecond() + "秒"; ThreadPool.QueueUserWorkItem(m => { if (processCount.timerTotalSecond >= 20) { 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; } var minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60; processCount.ResetTotalSecond((int)minuteChangeSecond); } }); } else { if (VerifyView != null) { VerifyView.Close(); //MainWindowViewModel.CloseExitVerify(); } VerifyResultShow(true, CheckInVerifyResultState.TimeError); timer.Stop(); } }
/// <summary> /// Timer触发的事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void timer_Tick(object sender, EventArgs e) { if (OnCountDown()) { //Application.Current.Dispatcher.Invoke((Action)(() => //{ if (todayAttendanceRecords != null) { todayAttendanceRecords.ChcekInTimer = "(" + processCount.GetMinute() + "分" + processCount.GetSecond() + "秒" + ")"; } ThreadPool.QueueUserWorkItem(m => { if (processCount.timerTotalSecond >= 20) { 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; } var minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60; processCount.ResetTotalSecond((int)minuteChangeSecond); } }); //})); } else { todayAttendanceRecords.IsbtnVerify = false; todayAttendanceRecords.VerifyDescribe = "验证过期"; todayAttendanceRecords.VerifyState = 1; timer.Stop(); } }
//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(); }