// Determines the start time and end time of the given data and sets the properties on the given file group. private static void SetDataTimeRange(MeterDataSet meterDataSet, FileInfoDataContext fileInfo) { DateTime dataStartTime; DateTime dataEndTime; dataStartTime = meterDataSet.DataSeries .Concat(meterDataSet.Digitals) .Where(dataSeries => dataSeries.DataPoints.Any()) .Select(dataSeries => dataSeries.DataPoints.First().Time) .DefaultIfEmpty() .Min(); dataEndTime = meterDataSet.DataSeries .Concat(meterDataSet.Digitals) .Where(dataSeries => dataSeries.DataPoints.Any()) .Select(dataSeries => dataSeries.DataPoints.Last().Time) .DefaultIfEmpty() .Max(); if (dataStartTime != default(DateTime)) meterDataSet.FileGroup.DataStartTime = dataStartTime; if (dataEndTime != default(DateTime)) meterDataSet.FileGroup.DataEndTime = dataEndTime; fileInfo.SubmitChanges(); }
/// <summary> /// Gets the file group containing information about the file on /// the given file path, as well as the files related to it. /// </summary> /// <param name="dataContext">The data context used for database lookups.</param> /// <param name="xdaTimeZone">The time zone used by openXDA.</param> /// <returns></returns> public FileGroup GetFileGroup(FileInfoDataContext dataContext, TimeZoneInfo xdaTimeZone) { FileInfo fileInfo; FileGroup fileGroup; DataFile dataFile; fileGroup = new FileGroup(); fileGroup.ProcessingStartTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, xdaTimeZone); foreach (string file in GSF.IO.FilePath.GetFileList($"{m_filePathWithoutExtension}.*")) { fileInfo = new FileInfo(file); dataFile = new DataFile(); dataFile.FilePath = file; dataFile.FilePathHash = file.GetHashCode(); dataFile.FileSize = fileInfo.Length; dataFile.CreationTime = TimeZoneInfo.ConvertTimeFromUtc(fileInfo.CreationTimeUtc, xdaTimeZone); dataFile.LastWriteTime = TimeZoneInfo.ConvertTimeFromUtc(fileInfo.LastWriteTimeUtc, xdaTimeZone); dataFile.LastAccessTime = TimeZoneInfo.ConvertTimeFromUtc(fileInfo.LastAccessTimeUtc, xdaTimeZone); dataFile.FileGroup = fileGroup; } dataContext.FileGroups.InsertOnSubmit(fileGroup); dataContext.SubmitChanges(); return fileGroup; }