Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
示例#1
0
 partial void UpdateFileGroup(FileGroup instance);
示例#2
0
 partial void DeleteFileGroup(FileGroup instance);
        // Determines whether the timestamps in the file extend beyond user-defined thresholds.
        private static void ValidateFileTimestamps(string filePath, FileGroup fileGroup, SystemSettings systemSettings, FileInfoDataContext fileInfo)
        {
            DateTime now;
            double timeDifference;

            // Get the current time in XDA's time zone
            now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, systemSettings.XDATimeZoneInfo);

            // Determine whether past timestamp validation is disabled
            if (systemSettings.MinTimeOffset > 0.0D)
            {
                // Get the total number of hours between the current time and the start time of the data in the file
                timeDifference = now.Subtract(fileGroup.DataStartTime).TotalHours;

                // Determine whether the number of hours exceeds the threshold
                if (timeDifference > systemSettings.MinTimeOffset)
                    throw new FileSkippedException($"Skipped file \"{filePath}\" because data start time '{fileGroup.DataStartTime}' is too old.");
            }

            // Determine whether future timestamp validation is disabled
            if (systemSettings.MaxTimeOffset > 0.0D)
            {
                // Get the total number of hours between the current time and the end time of the data in the file
                timeDifference = fileGroup.DataEndTime.Subtract(now).TotalHours;

                // Determine whether the number of hours exceeds the threshold
                if (timeDifference > systemSettings.MaxTimeOffset)
                    throw new FileSkippedException($"Skipped file \"{filePath}\" because data end time '{fileGroup.DataEndTime}' is too far in the future.");
            }
        }
示例#4
0
 partial void InsertFileGroup(FileGroup instance);
            /// <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;
            }
        // Determines whether the duration of data in the file exceeds a user-defined threshold.
        private static void ValidateFileDuration(string filePath, double maxFileDuration, FileGroup fileGroup)
        {
            double timeDifference;

            // Determine whether file duration validation is disabled
            if (maxFileDuration <= 0.0D)
                return;

            // Determine the number of seconds between the start and end time of the data in the file
            timeDifference = fileGroup.DataEndTime.Subtract(fileGroup.DataStartTime).TotalSeconds;

            // Determine whether the file duration exceeds the maximum threshold
            if (timeDifference > maxFileDuration)
                throw new FileSkippedException($"Skipped file \"{filePath}\" because duration of the file ({timeDifference:0.##} seconds) is too long.");
        }
        private List<MeterDataSet> LoadMeterDataSets(DbAdapterContainer dbAdapterContainer, FileGroup fileGroup)
        {
            List<MeterDataSet> meterDataSets = new List<MeterDataSet>();

            MeterInfoDataContext meterInfo = dbAdapterContainer.GetAdapter<MeterInfoDataContext>();
            EventTableAdapter eventAdapter = dbAdapterContainer.GetAdapter<EventTableAdapter>();
            EventDataTableAdapter eventDataAdapter = dbAdapterContainer.GetAdapter<EventDataTableAdapter>();

            MeterData.EventDataTable eventTable = eventAdapter.GetDataByFileGroup(fileGroup.ID);

            MeterDataSet meterDataSet;
            DataGroup dataGroup;

            foreach (IGrouping<int, MeterData.EventRow> eventGroup in eventTable.GroupBy(evt => evt.MeterID))
            {
                meterDataSet = new MeterDataSet();
                meterDataSet.Meter = meterInfo.Meters.SingleOrDefault(meter => meter.ID == eventGroup.Key);

                foreach (MeterData.EventRow evt in eventGroup)
                {
                    dataGroup = new DataGroup();
                    dataGroup.FromData(meterDataSet.Meter, eventDataAdapter.GetTimeDomainData(evt.EventDataID));

                    foreach (DataSeries dataSeries in dataGroup.DataSeries)
                        meterDataSet.DataSeries.Add(dataSeries);
                }

                meterDataSets.Add(meterDataSet);
            }

            return meterDataSets;
        }
 partial void DeleteFileGroup(FileGroup instance);
 partial void UpdateFileGroup(FileGroup instance);
 partial void InsertFileGroup(FileGroup instance);
示例#11
0
        private static List<XElement> GetPathElements(FileGroup fileGroup)
        {
            List<XElement> pathElements = fileGroup.DataFiles
                .Select(dataFile => new XElement("path", dataFile.FilePath))
                .ToList();

            return pathElements;
        }