コード例 #1
0
        /// <summary>
        /// Summarizes sets of IndexInfo 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.IndexInfoSummary"/> that represents a summary of the data in that timespan</returns>
        public static IndexInfoSummary SummarizeWriteData(DateTime startDay, DateTime endDay)
        {
            DataTable table;

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

            IndexInfoSummary summary = new IndexInfoSummary();

            Action <DataTable> action = delegate(DataTable inputTable) {
                if (inputTable != null)
                {
                    int totalRows = inputTable.Rows.Count;
                    for (int i = 0; i < totalRows; i++)
                    {
                        DataRow row = inputTable.Rows[i];
                        try {
                            summary.AddIndexInfo(new IndexInfo(row["IndexDirectory"].ToString(), row["IndexName"].ToString(), int.Parse(row["TotalDocuments"].ToString()), Boolean.Parse(row["Optimized"].ToString()), DateTime.Parse(row["CreateTime"].ToString())));
                        }
                        catch (Exception) {
                        }
                    }
                }
            };

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

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

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

            return(summary);
        }
コード例 #2
0
        /// <summary>
        /// Summarizes sets of IndexInfo 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.IndexInfoSummary"/> that represents a summary of the data in that timespan</returns>
        public static IndexInfoSummary SummarizeWriteData(DateTime startDay, DateTime endDay)
        {
            DataTable table;
            if (startDay > endDay) throw new ArgumentOutOfRangeException("startDay", "startDay cannot be newer than endDay");

            IndexInfoSummary summary = new IndexInfoSummary();

            Action<DataTable> action = delegate(DataTable inputTable) {
                if (inputTable != null) {
                    int totalRows = inputTable.Rows.Count;
                    for (int i = 0; i < totalRows; i++) {
                        DataRow row = inputTable.Rows[i];
                        try {
                            summary.AddIndexInfo(new IndexInfo(row["IndexDirectory"].ToString(), row["IndexName"].ToString(), int.Parse(row["TotalDocuments"].ToString()), Boolean.Parse(row["Optimized"].ToString()), DateTime.Parse(row["CreateTime"].ToString())));
                        }
                        catch (Exception) {
                        }
                    }
                }
            };

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

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

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

            return summary;
        }