コード例 #1
0
ファイル: Net2NTP.cs プロジェクト: cxdcxd/RRS
        public ProcessResult Sync()
        {
            ProcessResult result = new ProcessResult();

            try
            {
                ntp_time = connection.GetUtc();
            }
            catch (Exception e)
            {
                result.Success = false;
                result.Message = e.Message;
            }

            return(result);
        }
コード例 #2
0
ファイル: NTPClient.cs プロジェクト: cxdcxd/RRS
 public void sync(string host_name)
 {
     try
     {
         var connection = new NtpConnection(host_name);
         stop_watch = new Stopwatch();
         stop_watch.Stop();
         var utcNow = connection.GetUtc();
         stop_watch.Start();
         time_offset = (long)(utcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;
         reportLog("NTP Sync successful", LogType.INFO, "NTPClient");
         reportLog("Current time is : " + get(), LogType.INFO, "NTPClient");
     }
     catch (Exception e)
     {
         string msg = e.Message;
         reportLog("Error in time sync : " + msg, LogType.ERROR, "NTPClient");
     }
 }