Beispiel #1
0
        private IEnumerable <Sezam.Data.EF.User> ReadUsers()
        {
            int    count         = 0;
            int    inactiveCount = 0;
            string userFile      = Path.Combine(rootPath.FullName, "user.dat");

            using (BinaryReader r = new BinaryReader(File.Open(userFile, FileMode.Open)))
            {
                // int deletedCount = 0;
                while (r.PeekChar() != -1)
                {
                    var user = new Sezam.Data.EF.User(count > 0 ? count : 99999);
                    user.Read(r);

                    Console.WriteLine($"{user.Username,-16} {user.FullName,-28} {user.City,-16} {user.LastCall:dd MMM yyyy HH:mm}");

                    count++;
                    if (!user.LastCall.HasValue)
                    {
                        inactiveCount++;
                    }

                    yield return(user);
                }
            }
            Debug.WriteLine("Read {0} users, {1} inactive.", count, inactiveCount);
        }