Exemplo n.º 1
0
        public void SetSystemDateAndTimeNTP(string server, string utc)
        {
            if (deviceioClient == null)
            {
                return;
            }
            try
            {
                deviceio.TimeZone timeZone = new deviceio.TimeZone()
                {
                    TZ = utc
                };

                deviceio.NetworkHost[] ntp = new deviceio.NetworkHost[]
                {
                    new deviceio.NetworkHost()
                    {
                        Type = deviceio.NetworkHostType.IPv4, IPv4Address = server
                    }
                };

                DateTime          time          = DateTime.Now;
                deviceio.DateTime curDeviceTime = new deviceio.DateTime()
                {
                    Date = new deviceio.Date()
                    {
                        Year  = time.Date.Year,
                        Month = time.Date.Month,
                        Day   = time.Date.Day,
                    }
                    ,
                    Time = new deviceio.Time()
                    {
                        Hour   = time.Hour,
                        Minute = time.Minute,
                        Second = time.Second
                    }
                };

                deviceioClient.SetNTP(false, ntp);
                deviceioClient.SetSystemDateAndTime(deviceio.SetDateTimeType.NTP, false, timeZone, curDeviceTime);
            }
            catch (Exception ex)
            {
                Logger.Write(ex);
            }
        }
Exemplo n.º 2
0
        public void SetSystemDateAndTimeNTP(string server, string utc)
        {
            if (deviceioClient == null) return;
            try
            {
                deviceio.TimeZone timeZone = new deviceio.TimeZone() { TZ = utc };

                deviceio.NetworkHost[] ntp = new deviceio.NetworkHost[]
                {
                    new deviceio.NetworkHost()
                    {
                        Type = deviceio.NetworkHostType.IPv4, IPv4Address = server
                    }
                };

                DateTime time = DateTime.Now;
                deviceio.DateTime curDeviceTime = new deviceio.DateTime()
                {
                    Date = new deviceio.Date()
                    {
                        Year = time.Date.Year,
                        Month = time.Date.Month,
                        Day = time.Date.Day,
                    }
                    ,
                    Time = new deviceio.Time()
                    {
                        Hour = time.Hour,
                        Minute = time.Minute,
                        Second = time.Second
                    }
                };

                deviceioClient.SetNTP(false, ntp);
                deviceioClient.SetSystemDateAndTime(deviceio.SetDateTimeType.NTP, false, timeZone, curDeviceTime);

            }
            catch (Exception ex)
            {
                Logger.Write(ex);
            }
        }