private void SyncTime() { Eclock eclock = new Eclock(); string serialPort = eclock.GetPort(); string[] ports = SerialPort.GetPortNames(); string commPort = ""; foreach (var item in ports) { if (serialPort.Contains(item)) { commPort = item; } } if (!String.IsNullOrEmpty(commPort)) { eclock.SyncTime(commPort); } }
private void button1_Click(object sender, EventArgs e) { try { if (ActionType == "BANDED") { DataStartIndex = Convert.ToInt32(this.txtCount.Text); DataEndtIndex = Convert.ToInt32(this.txtto.Text); SyncBanded(); } else if (ActionType == "ENTRY") { DataStartIndex = Convert.ToInt32(this.txtCount.Text); DataEndtIndex = Convert.ToInt32(this.txtto.Text); SyncEntry(); } else if (ActionType == "UNLOCK") { UnLockEclock(); } else if (ActionType == "ENTRYDB") { SyncEntryInDatabase(); } else if (ActionType == "RESULTDB") { SyncResultInDatabase(); } else if (ActionType == "RESULTRACE") { SyncResult(ActionType); } else if (ActionType == "RESULTTRAINING") { SyncResult(ActionType); } else if (ActionType == "UPLOADPROGRAM") { string path = AppDomain.CurrentDomain.BaseDirectory + "ProgramLoader"; var process = Process.Start(path + "\\ConsoleApp1.exe"); process.WaitForExit(); var exitCode = process.ExitCode; this.Close(); } else if (ActionType == "RESET") { Eclock eclock = new Eclock(); string serialPort = eclock.GetPort(); string[] ports = SerialPort.GetPortNames(); string commPort = ""; foreach (var item in ports) { if (serialPort.Contains(item)) { commPort = item; } } if (commPort != "") { eclock.SyncTime(commPort); } this.Close(); } else if (ActionType == "CLOCK") { Eclock eclock = new Eclock(); string serialPort = eclock.GetPort(); string[] ports = SerialPort.GetPortNames(); string commPort = ""; foreach (var item in ports) { if (serialPort.Contains(item)) { commPort = item; } } if (commPort != "") { eclock.SyncTime(commPort); } this.Close(); } } catch (Exception ex) { Common.Logs(ex.Message); } }