예제 #1
0
        /// <summary>
        /// Converts the supplied list of <see cref="ExceptionEvent"/> objects into a list of <see cref="DbExceptionEvent"/> objects.
        /// </summary>
        /// <param name="conditions">The list of <see cref="ExceptionEvent"/> objects to be converted.</param>
        /// <returns></returns>
        public static List <DbExceptionEvent> GetDbExceptionEvents(IList <ExceptionEvent> exceptionEvents)
        {
            DateTime recordCreationTimeUtc = DateTime.UtcNow;
            var      dbExceptionEvents     = new List <DbExceptionEvent>();

            foreach (var exceptionEvent in exceptionEvents)
            {
                DbExceptionEvent dbExceptionEvent = GetDbExceptionEvent(exceptionEvent);
                dbExceptionEvent.RecordCreationTimeUtc = recordCreationTimeUtc;
                dbExceptionEvents.Add(dbExceptionEvent);
            }
            return(dbExceptionEvents);
        }
예제 #2
0
        /// <summary>
        /// Converts the supplied <see cref="ExceptionEvent"/> into a <see cref="DbExceptionEvent"/>.
        /// </summary>
        /// <param name="">The <see cref="ExceptionEvent"/> to be converted.</param>
        /// <returns></returns>
        public static DbExceptionEvent GetDbExceptionEvent(ExceptionEvent exceptionEvent)
        {
            Device device = exceptionEvent.Device;
            Driver driver = exceptionEvent.Driver;
            Rule   rule   = exceptionEvent.Rule;

            DbExceptionEvent dbExceptionEvent = new DbExceptionEvent
            {
                GeotabId   = exceptionEvent.Id.ToString(),
                ActiveFrom = exceptionEvent.ActiveFrom,
                ActiveTo   = exceptionEvent.ActiveTo,
                DeviceId   = device.Id.ToString(),
                Distance   = exceptionEvent.Distance,
                DriverId   = driver.Id.ToString(),
                Duration   = exceptionEvent.Duration,
                RuleId     = rule.Id.ToString(),
                Version    = exceptionEvent.Version
            };

            return(dbExceptionEvent);
        }