예제 #1
0
        /// <summary>
        /// Summarizes sets of ReadInfo instances that were created during the specified datetime range.
        /// </summary>
        /// <param name="startDay">The start day.</param>
        /// <param name="endDay">The end day.</param>
        /// <returns>A <see cref="IndexLibrary.Analysis.ReaderInfoSummary"/> that represents a summary of the data in that timespan</returns>
        public static ReaderInfoSummary SummarizeReadData(DateTime startDay, DateTime endDay)
        {
            DataTable table;

            if (startDay > endDay)
            {
                throw new ArgumentOutOfRangeException("startDay", "startDay cannot be newer than endDay");
            }

            ReaderInfoSummary summary = new ReaderInfoSummary();

            Action <DataTable> action = delegate(DataTable inputTable) {
                if (inputTable != null && inputTable.Columns.Contains("IndexName") && inputTable.Columns.Contains("TotalDocumentsRetrieved") && inputTable.Columns.Contains("TotalDocsInIndex") && inputTable.Columns.Contains("BuiltFiltersForAllData") && inputTable.Columns.Contains("Optimized") && inputTable.Columns.Contains("CreateTime"))
                {
                    int count = inputTable.Rows.Count;
                    for (int i = 0; i < count; i++)
                    {
                        DataRow row = inputTable.Rows[i];
                        try {
                            summary.AddReadInfo(new ReadInfo(row["IndexName"].ToString(), int.Parse(row["TotalDocumentsRetrieved"].ToString()), int.Parse(row["TotalDocsInIndex"].ToString()), bool.Parse(row["BuiltFiltersForAllData"].ToString()), bool.Parse(row["Optimized"].ToString()), DateTime.Parse(row["CreateTime"].ToString())));
                        }
                        catch (Exception) {
                        }
                    }
                }
            };

            if (startDay.Date < endDay.Date)
            {
                table = ReadDay(startDay, TableName.ReadAnalysis, true);
                action(table);
                startDay = startDay.Date.AddDays(1.0);
            }

            while (startDay < endDay)
            {
                table = ReadDay(startDay, TableName.ReadAnalysis, true);
                action(table);
                startDay = startDay.AddDays(1.0);
            }

            if (startDay.Date == endDay.Date)
            {
                table = ReadDay(endDay, TableName.ReadAnalysis, false);
                action(table);
                endDay = new DateTime(endDay.Year, endDay.Month, endDay.Day, 23, 59, 59);
            }

            return(summary);
        }
예제 #2
0
        /// <summary>
        /// Summarizes sets of ReadInfo instances that were created during the specified datetime range.
        /// </summary>
        /// <param name="startDay">The start day.</param>
        /// <param name="endDay">The end day.</param>
        /// <returns>A <see cref="IndexLibrary.Analysis.ReaderInfoSummary"/> that represents a summary of the data in that timespan</returns>
        public static ReaderInfoSummary SummarizeReadData(DateTime startDay, DateTime endDay)
        {
            DataTable table;
            if (startDay > endDay) throw new ArgumentOutOfRangeException("startDay", "startDay cannot be newer than endDay");

            ReaderInfoSummary summary = new ReaderInfoSummary();

            Action<DataTable> action = delegate(DataTable inputTable) {
                if (inputTable != null && inputTable.Columns.Contains("IndexName") && inputTable.Columns.Contains("TotalDocumentsRetrieved") && inputTable.Columns.Contains("TotalDocsInIndex") && inputTable.Columns.Contains("BuiltFiltersForAllData") && inputTable.Columns.Contains("Optimized") && inputTable.Columns.Contains("CreateTime")) {
                    int count = inputTable.Rows.Count;
                    for (int i = 0; i < count; i++) {
                        DataRow row = inputTable.Rows[i];
                        try {
                            summary.AddReadInfo(new ReadInfo(row["IndexName"].ToString(), int.Parse(row["TotalDocumentsRetrieved"].ToString()), int.Parse(row["TotalDocsInIndex"].ToString()), bool.Parse(row["BuiltFiltersForAllData"].ToString()), bool.Parse(row["Optimized"].ToString()), DateTime.Parse(row["CreateTime"].ToString())));
                        }
                        catch (Exception) {
                        }
                    }
                }
            };

            if (startDay.Date < endDay.Date) {
                table = ReadDay(startDay, TableName.ReadAnalysis, true);
                action(table);
                startDay = startDay.Date.AddDays(1.0);
            }

            while (startDay < endDay) {
                table = ReadDay(startDay, TableName.ReadAnalysis, true);
                action(table);
                startDay = startDay.AddDays(1.0);
            }

            if (startDay.Date == endDay.Date) {
                table = ReadDay(endDay, TableName.ReadAnalysis, false);
                action(table);
                endDay = new DateTime(endDay.Year, endDay.Month, endDay.Day, 23, 59, 59);
            }

            return summary;
        }