示例#1
0
        static bool LogOffendingCustomReportSchedules(Group group, StringBuilder stringBuilder, List <CustomReportSchedule> reports, bool addEndOfLine)
        {
            if (reports == null || reports.Count < 1)
            {
                return(false);
            }

            // could have done Binary Search Tree, but need to implement since .NET doesn't have a standard implementation
            var reportsByTemplateNameTemplateIdScheduleDestination = new LinkedList <CustomReportSchedule>();
            var comparer = new CustomReportScheduleComparerForLogging();

            foreach (var report in reports)
            {
                InsertCustomReportScheduleForLogging(reportsByTemplateNameTemplateIdScheduleDestination, report, comparer);
            }
            stringBuilder.Append("Associated Custom Reports: ");
            var current = reportsByTemplateNameTemplateIdScheduleDestination.First;

            foreach (var report in reportsByTemplateNameTemplateIdScheduleDestination)
            {
                LogCustomReportSchedule(group, stringBuilder, report);
                stringBuilder.Append(current != reportsByTemplateNameTemplateIdScheduleDestination.Last ? "; " : ".");
                current = current.Next;
            }
            if (addEndOfLine)
            {
                stringBuilder.Append(Environment.NewLine);
            }

            return(true);
        }
示例#2
0
        static void InsertCustomReportScheduleForLogging(LinkedList <CustomReportSchedule> list, CustomReportSchedule valueToInsert, CustomReportScheduleComparerForLogging comparer)
        {
            if (list.Count == 0)
            {
                list.AddFirst(valueToInsert);
                return;
            }
            var currentInList = list.First;

            while (comparer.Compare(currentInList.Value, valueToInsert) < 0 && currentInList != list.Last)
            {
                currentInList = currentInList.Next;
            }
            if (comparer.Compare(currentInList.Value, valueToInsert) > 0)
            {
                list.AddBefore(currentInList, valueToInsert); //last was reached
            }
            else
            {
                list.AddAfter(currentInList, valueToInsert);
            }
        }