Beispiel #1
0
        private static LinkTableRow[] EnumerateLinkTable(JetDb db)
        {
            Stopwatch stopwatch = null;

            if (ShowDebugOutput)
            {
                ConsoleEx.WriteDebug($"Called: {nameof(NtdsAudit)}::{nameof(EnumerateLinkTable)}");
                stopwatch = new Stopwatch();
                stopwatch.Start();
            }

            using (var table = db.OpenJetDbTable(LINKTABLE))
            {
                // Get a dictionary mapping column names to column ids
                var columnDictionary = table.GetColumnDictionary();

                var linktable        = new List <LinkTableRow>();
                var deletedLinkCount = 0;

                // Loop over the table
                table.MoveBeforeFirst();
                while (table.TryMoveNext())
                {
                    var linkDelTimeColumn = new DateTimeColumnValue {
                        Columnid = columnDictionary["link_deltime"]
                    };
                    var linkDntColumn = new Int32ColumnValue {
                        Columnid = columnDictionary["link_DNT"]
                    };
                    var backlinkDnt = new Int32ColumnValue {
                        Columnid = columnDictionary["backlink_DNT"]
                    };
                    table.RetrieveColumns(linkDelTimeColumn, linkDntColumn, backlinkDnt);

                    // Ignore deleted links
                    if (linkDelTimeColumn.Error == JET_wrn.Success)
                    {
                        deletedLinkCount++;
                        continue;
                    }

                    linktable.Add(new LinkTableRow
                    {
                        LinkDnt     = linkDntColumn.Value.Value,
                        BacklinkDnt = backlinkDnt.Value.Value,
                    });
                }

                if (ShowDebugOutput)
                {
                    ConsoleEx.WriteDebug($"  Ignored {deletedLinkCount} deleted backlinks");
                    ConsoleEx.WriteDebug($"  Found {linktable.Count} backlinks");

                    stopwatch.Stop();
                    ConsoleEx.WriteDebug($"  Completed in {stopwatch.Elapsed}");
                }

                return(linktable.ToArray());
            }
        }
Beispiel #2
0
        public void TestDateTimeLength()
        {
            var value = new DateTimeColumnValue();

            foreach (DateTime i in new[] { DateTime.MinValue, DateTime.MaxValue, Any.DateTime, DateTime.Now, DateTime.UtcNow, DateTime.Today })
            {
                TestLengthForStruct(value, i, 8);
            }
        }
Beispiel #3
0
        public void TestDateTimeValueAsObject()
        {
            var value = new DateTimeColumnValue();

            foreach (DateTime i in new[] { DateTime.MinValue, DateTime.MaxValue, Any.DateTime, DateTime.Now, DateTime.UtcNow, DateTime.Today })
            {
                TestValueAsObjectForStruct(value, i);
            }
        }