Esempio n. 1
0
        /// <summary>
        /// Fixup the currentTime and cachedUntil time to match the user's clock.
        /// This should ONLY be called when the xml is first received from CCP
        /// </summary>
        /// <param name="millisecondsDrift"></param>
        public void SynchronizeWithLocalClock(double millisecondsDrift)
        {
            // Convert the drift between webserver time and local time
            // to a timespan. It is possible for millisecondsDrift to
            // be erroniously outside of the range of an int thus we
            // need to catch an overflow exception and reset to 0.
            TimeSpan drift;

            try
            {
                drift = new TimeSpan(0, 0, 0, 0, Convert.ToInt32(millisecondsDrift));
            }
            catch (OverflowException)
            {
                drift = new TimeSpan(0, 0, 0, 0);
            }

            // Now fix the server time to align with local time
            if (CurrentTime != DateTime.MinValue)
            {
                CurrentTime -= drift;
            }
            if (CachedUntil != DateTime.MinValue)
            {
                CachedUntil -= drift;
            }

            // Fix the TQ start/end times first
            ISynchronizableWithLocalClock synchronizable = ((Object)Result) as ISynchronizableWithLocalClock;

            if (synchronizable != null)
            {
                synchronizable.SynchronizeWithLocalClock(drift);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Fixup the result time to match the user's clock.
        /// This should ONLY be called when the xml is first received from CCP.
        /// </summary>
        /// <param name="millisecondsDrift"></param>
        public void SynchronizeWithLocalClock(double millisecondsDrift)
        {
            // Convert the drift between webserver time and local time
            // to a timespan. It is possible for millisecondsDrift to
            // be erroniously outside of the range of an int thus we
            // need to catch an overflow exception and reset to 0.
            TimeSpan drift;

            try
            {
                drift = new TimeSpan(0, 0, 0, 0, Convert.ToInt32(millisecondsDrift));
            }
            catch (OverflowException)
            {
                drift = new TimeSpan(0, 0, 0, 0);
            }

            // Fix the start/end times for the results implementing synchronization
            ISynchronizableWithLocalClock synchronizable = Result as ISynchronizableWithLocalClock;

            synchronizable?.SynchronizeWithLocalClock(drift);
        }