예제 #1
0
        /// <summary>
        /// Creates a <see cref="ArchiveDetails"/> from a specific <see cref="ArchiveTableSummary{TKey,TValue}"/>
        /// </summary>
        public static ArchiveDetails Create <TKey, TValue>(ArchiveTableSummary <TKey, TValue> table)
            where TKey : SnapTypeBase <TKey>, new()
            where TValue : SnapTypeBase <TValue>, new()
        {
            ArchiveDetails details = new ArchiveDetails
            {
                Id       = table.FileId,
                FileName = table.SortedTreeTable.BaseFile.FilePath,
                IsEmpty  = table.IsEmpty,
                FileSize = table.SortedTreeTable.BaseFile.ArchiveSize,
                FirstKey = table.FirstKey.ToString(),
                LastKey  = table.LastKey.ToString()
            };

#if SQLCLR
            details.StartTime = DateTime.MinValue;
            details.EndTime   = DateTime.MaxValue;
#else
            try
            {
                // Attempt to get timestamp range for archive file
                dynamic firstKey = table.FirstKey;
                dynamic lastKey  = table.LastKey;
                details.StartTime = firstKey.TimestampAsDate;
                details.EndTime   = lastKey.TimestampAsDate;
            }
            catch
            {
                // TKey implementation does not contain a TimestampAsDate property
                details.StartTime = DateTime.MinValue;
                details.EndTime   = DateTime.MaxValue;
            }
#endif
            return(details);
        }
        /// <summary>
        /// Gets a complete list of all archive files
        /// </summary>
        public override List <ArchiveDetails> GetAllAttachedFiles()
        {
            var rv = new List <ArchiveDetails>();

            lock (m_syncRoot)
            {
                foreach (var file in m_fileSummaries.Values)
                {
                    rv.Add(ArchiveDetails.Create(file));
                }
                return(rv);
            }
        }