예제 #1
0
        /// <summary>
        /// Creates a <see cref="LogTableDefinition" /> for the specified <see cref="FrameworkDataLog" /> object.
        /// </summary>
        /// <param name="dataLog">The <see cref="FrameworkDataLog" /> object.</param>
        /// <returns>A <see cref="LogTableDefinition" /> for the specified <see cref="FrameworkDataLog" />.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="dataLog" /> is null.</exception>
        public static LogTableDefinition BuildTableDefinition(FrameworkDataLog dataLog)
        {
            if (dataLog == null)
            {
                throw new ArgumentNullException(nameof(dataLog));
            }

            LogTableDefinition definition = new LogTableDefinition(dataLog.TableName, dataLog.PrimaryKeyColumn);

            foreach (DataLogPropertyInfo dataLogProperty in GetDataLogProperties(dataLog))
            {
                // Special case for session ID
                if (dataLogProperty.Name == "SessionId" && dataLogProperty.PropertyType == typeof(string))
                {
                    definition.Add(new LogTableColumn(dataLogProperty.Name, "varchar(50)", false));
                }
                else
                {
                    // Primary key should be non-null; everything else is nullable
                    bool nullable = (dataLogProperty.Name != dataLog.PrimaryKeyColumn);
                    definition.Add(new LogTableColumn(dataLogProperty.PropertyInfo, dataLogProperty.MaxLength, nullable));
                }
            }
            return(definition);
        }
        /// <summary>
        /// Submits the specified <see cref="FrameworkDataLog" /> as a new log record.
        /// </summary>
        /// <param name="dataLog">The <see cref="FrameworkDataLog" />.</param>
        /// <returns><c>true</c> if submission was successful; an exception is thrown otherwise.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="dataLog" /> is null.</exception>
        /// <exception cref="DataLoggerMockException">An issue with the data log was detected.</exception>
        public bool Submit(FrameworkDataLog dataLog)
        {
            if (dataLog == null)
            {
                throw new ArgumentNullException(nameof(dataLog));
            }

            // Not implemented
            return(true);
        }
        /// <summary>
        /// Updates an existing log record using data from the specified <see cref="FrameworkDataLog" />.
        /// (This mock does not make an async call.)
        /// </summary>
        /// <param name="dataLog">The <see cref="FrameworkDataLog" />.</param>
        /// <exception cref="ArgumentNullException"><paramref name="dataLog" /> is null.</exception>
        /// <exception cref="DataLoggerMockException">An issue with the data log was detected.</exception>
        public void UpdateAsync(FrameworkDataLog dataLog)
        {
            if (dataLog == null)
            {
                throw new ArgumentNullException(nameof(dataLog));
            }

            // Not implemented
            return;
        }
예제 #4
0
        /// <summary>
        /// Asynchronously updates an existing log record using data from the specified <see cref="FrameworkDataLog" />.
        /// </summary>
        /// <param name="dataLog">The <see cref="FrameworkDataLog" />.</param>
        /// <exception cref="ArgumentNullException"><paramref name="dataLog" /> is null.</exception>
        public void UpdateAsync(FrameworkDataLog dataLog)
        {
            if (dataLog == null)
            {
                throw new ArgumentNullException(nameof(dataLog));
            }

            LogTableDefinition table  = DataLogTranslator.BuildTableDefinition(dataLog);
            LogTableRecord     record = DataLogTranslator.BuildUpdateRecord(dataLog);

            Task.Factory.StartNew(() => Update(table, record));
        }
예제 #5
0
        /// <summary>
        /// Updates an existing log record using data from the specified <see cref="FrameworkDataLog" />.
        /// </summary>
        /// <param name="dataLog">The <see cref="FrameworkDataLog" />.</param>
        /// <returns><c>true</c> if update was successful, <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="dataLog" /> is null.</exception>
        public bool Update(FrameworkDataLog dataLog)
        {
            if (dataLog == null)
            {
                throw new ArgumentNullException(nameof(dataLog));
            }

            LogTableDefinition table  = DataLogTranslator.BuildTableDefinition(dataLog);
            LogTableRecord     record = DataLogTranslator.BuildUpdateRecord(dataLog);

            return(Update(table, record));
        }
예제 #6
0
        private static LogTableRecord BuildRecord(FrameworkDataLog dataLog, bool insert)
        {
            if (dataLog == null)
            {
                throw new ArgumentNullException(nameof(dataLog));
            }

            LogTableRecord record = new LogTableRecord();

            foreach (DataLogPropertyInfo dataLogProperty in GetDataLogProperties(dataLog))
            {
                bool isPrimaryKey = dataLogProperty.Name.Equals(dataLog.PrimaryKeyColumn);
                if (insert || dataLogProperty.IncludeInUpdates || isPrimaryKey)
                {
                    record.Add(dataLogProperty.Name, GetPropertyValue(dataLogProperty, dataLog));
                }
            }
            return(record);
        }
 public void UpdateAsync(FrameworkDataLog dataLog)
 {
 }
 public void SubmitAsync(FrameworkDataLog dataLog)
 {
 }
 public bool Update(FrameworkDataLog dataLog) => true;
 // IDataLoggerInternal is implemented but does nothing
 public bool Submit(FrameworkDataLog dataLog) => true;
예제 #11
0
 /// <summary>
 /// Builds a <see cref="LogTableRecord" /> for an update operation from the specified <see cref="FrameworkDataLog" /> object.
 /// </summary>
 /// <param name="dataLog">The <see cref="FrameworkDataLog" /> object.</param>
 /// <returns>A <see cref="LogTableRecord" /> for an update operation from the specified <see cref="FrameworkDataLog" />.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="dataLog" /> is null.</exception>
 /// <exception cref="InvalidOperationException"><paramref name="dataLog" /> contains data that exceeds the maximum allowable length and cannot be truncated.</exception>
 public static LogTableRecord BuildUpdateRecord(FrameworkDataLog dataLog)
 {
     return(BuildRecord(dataLog, false));
 }
예제 #12
0
 /// <summary>
 /// Builds a <see cref="LogTableRecord" /> for an insert operation from the specified <see cref="FrameworkDataLog" /> object.
 /// </summary>
 /// <param name="dataLog">The <see cref="FrameworkDataLog" /> object.</param>
 /// <returns>A <see cref="LogTableRecord" /> for an insert operation from the specified <see cref="FrameworkDataLog" />.</returns>
 /// <exception cref="ArgumentNullException"><paramref name="dataLog" /> is null.</exception>
 /// <exception cref="InvalidOperationException"><paramref name="dataLog" /> contains data that exceeds the maximum allowable length and cannot be truncated.</exception>
 public static LogTableRecord BuildInsertRecord(FrameworkDataLog dataLog)
 {
     return(BuildRecord(dataLog, true));
 }