Пример #1
0
        /// <summary>
        /// 同步服务器时间
        /// </summary>
        public void SyncServerTime()
        {
            string sql = "SELECT GETDATE()";
            //object o = DataProvider.Instance.ExecuteScalar(Globals.DEF_ATTEND_SYSTEM_DB, sql);
            //DateTime dt = ConvertEx.ToDateTimeEx(o);
            //比较时间一致性
            //if (ConvertEx.ToCharYYYYMMDDHHMM(DateTime.Now) != ConvertEx.ToCharYYYYMMDDHHMM(dt))
            //    LocalTimeSync.SyncTime(dt);//同步服务器的时间

            object   o  = DataProvider.Instance.ExecuteScalar(Globals.DEF_MASTER_DB, sql);
            DateTime dt = (DateTime)ConvertEx.ToDateTime(o);

            //LocalTimeSync.SyncTime(dt);

            //比较时间一致性
            if (ConvertEx.ToCharYYYYMMDDHHMMSS(DateTime.Now) != ConvertEx.ToCharYYYYMMDDHHMMSS(dt))
            {
                LocalTimeSync.SyncTime(dt);//同步服务器的时间
            }
        }