Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
            /// <summary>
            /// Adds an archive file to the list with the given state information.
            /// </summary>
            /// <param name="sortedTree">archive table to add</param>
            public override void Add(SortedTreeTable <TKey, TValue> sortedTree)
            {
                if (m_disposed)
                {
                    throw new ObjectDisposedException(GetType().FullName);
                }

                ArchiveTableSummary <TKey, TValue> summary = new ArchiveTableSummary <TKey, TValue>(sortedTree);

                m_list.m_fileSummaries.Add(sortedTree.ArchiveId, summary);
            }
 /// <summary>
 /// Gets if the specified file is being.
 /// MUST be called from a synchronized context.
 /// </summary>
 /// <param name="sortedTree"></param>
 /// <returns></returns>
 bool InternalIsFileBeingUsed(SortedTreeTable <TKey, TValue> sortedTree)
 {
     foreach (var snapshot in m_allSnapshots)
     {
         ArchiveTableSummary <TKey, TValue>[] tables = snapshot.Tables;
         if (tables != null)
         {
             for (int x = 0; x < tables.Length; x++)
             {
                 ArchiveTableSummary <TKey, TValue> summary = tables[x];
                 if (summary != null && summary.SortedTreeTable == sortedTree)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }