示例#1
0
        static void AnalyzeCategories
        (
            int year,
            int month
        )
        {
            string expression = string.Format
                                (
                CultureInfo.InvariantCulture,
                "RD={0:0000}{1:00}$",
                year,
                month
                                );

            int[]             found   = connection.Search(expression);
            List <MarcRecord> records = new BatchRecordReader
                                        (
                connection,
                connection.Database,
                500,
                true,
                found
                                        )
                                        .ReadAll(true);

            ReaderInfo[] readers = records.Select(ReaderInfo.Parse).ToArray();
            DictionaryCounterInt32 <string> counter = new DictionaryCounterInt32 <string>();

            foreach (ReaderInfo reader in readers)
            {
                string category = reader.Category;
                if (!string.IsNullOrEmpty(category))
                {
                    counter.Increment(category);
                }
            }

            CultureInfo        culture = CultureInfo.CurrentCulture;
            DateTimeFormatInfo format  = culture.DateTimeFormat;

            Console.Write("{0} {1}", format.GetAbbreviatedMonthName(month), year);
            foreach (string category in knownCategories)
            {
                Console.Write("\t{0}", counter.GetValue(category));
            }
            int others = 0;

            foreach (string key in counter.Keys)
            {
                if (!knownCategories.Contains(key))
                {
                    int value = counter[key];
                    others += value;
                }
            }

            Console.WriteLine("\t{0}", others);
        }
示例#2
0
        static List <int> AnalyzeAttendance
        (
            int year
        )
        {
            string expression = string.Format("RD={0}$", year.ToInvariantString());

            int[]             found   = connection.Search(expression);
            List <MarcRecord> records = new BatchRecordReader
                                        (
                connection,
                connection.Database,
                500,
                true,
                found
                                        )
                                        .ReadAll(true);

            ReaderInfo[] readers = records.Select(ReaderInfo.Parse).ToArray();
            foreach (ReaderInfo reader in readers)
            {
                ProcessReader(reader);
            }

            List <int> result = new List <int> {
                readers.Length
            };

            for (int attendance = 1; attendance < MaxAttendance; attendance++)
            {
                int count = readers.Count(r => r.Visits.Length >= attendance);
                result.Add(count);
            }

            return(result);
        }