Example #1
0
        protected override void Seed(SyncContext database)
        {
            #region USERS
            database.User.Add(new User
            {
                GUID       = "milantevsa1516",
                Name       = "Сергей",
                Surname    = "Милантьев",
                Midname    = "Андреевич",
                Gender     = true,
                Birthdate  = Convert.ToDateTime("1995-03-29"),
                Country    = "Россия",
                City       = "Саратов",
                Department = "ИнПИТ",
                Group      = "ИФСТ",
                Status     = "Обучающийся",
                Email      = "*****@*****.**",
                Phone      = "+79020447508",
                Role       = "Студент"
            });
            database.User.Add(new User
            {
                GUID       = "konyaevyy1517",
                Name       = "Юрий",
                Surname    = "Коняев-Гурченко",
                Midname    = "Юрьевич",
                Gender     = true,
                Birthdate  = Convert.ToDateTime("1997-10-05"),
                Country    = "Россия",
                City       = "Саратов",
                Department = "ИнПИТ",
                Group      = "ИФСТ",
                Status     = "Отпуск",
                Email      = "*****@*****.**",
                Phone      = "+79061508501",
                Role       = "Студент"
            });
            database.User.Add(new User
            {
                GUID       = "eremenkod1518",
                Name       = "Денис",
                Surname    = "Еременко",
                Midname    = "Сергеевич",
                Gender     = true,
                Birthdate  = Convert.ToDateTime("1997-01-08"),
                Country    = "Россия",
                City       = "Саратов",
                Department = "ИнПИТ",
                Group      = "ИФСТ",
                Status     = "Отчислен",
                Email      = "*****@*****.**",
                Phone      = "+79370220973",
                Role       = "Студент"
            });
            database.User.Add(new User
            {
                GUID       = "abor1519",
                Name       = "Андрей",
                Surname    = "Бороздюхин",
                Midname    = "Александрович",
                Gender     = true,
                Birthdate  = Convert.ToDateTime("1970-01-25"),
                Country    = "Россия",
                City       = "Саратов",
                Department = "ИнПИТ",
                Group      = "ИФСТ",
                Status     = "Отпуск",
                Email      = "*****@*****.**",
                Phone      = "+79030459403",
                Role       = "Преподаватель"
            });
            #endregion
            #region 1C SYNC
            string   path = AppDomain.CurrentDomain.BaseDirectory + "App_Code\\users.txt";
            string[] lines;
            if (File.Exists(path))
            {
                lines = File.ReadAllLines(path);
            }
            else
            {
                lines = File.ReadAllLines("D:\\users.txt");
            }
            int        count = 1;
            Random     random = new Random();
            DateTime   start = new DateTime(1995, 1, 1), end = new DateTime(1999, 1, 1);
            int        range      = (end - start).Days;
            Translator translator = new Translator();
            foreach (var line in lines)
            {
                string   surname = "", name = "", midname = "", gender = "";
                string[] items = line.Split(' ');

                switch (items.Length)
                {
                case 3:
                    surname = items[0];
                    name    = items[1];
                    gender  = items[2];
                    break;

                case 4:
                    surname = items[0];
                    name    = items[1];
                    midname = items[2];
                    gender  = items[3];
                    break;

                case 5:
                    surname = items[0];
                    name    = items[1];
                    midname = items[2] + " " + items[3];
                    gender  = items[4];
                    break;

                default:
                    break;
                }
                string phone = string.Empty;
                for (int i = 0; i < 10; i++)
                {
                    phone += random.Next(0, 9).ToString();
                }
                string guid = translator.Bind(surname.ToLower());
                database.User.Add(new User
                {
                    GUID       = guid + count.ToString(),
                    Name       = name,
                    Surname    = surname,
                    Midname    = midname,
                    Gender     = gender == "1" ? true : false,
                    Birthdate  = start.AddDays(random.Next(range)),
                    Country    = "Россия",
                    City       = "Саратов",
                    Department = "ИнПИТ",
                    Group      = "ИФСТ",
                    Status     = "Обучающийся",
                    Email      = $"{guid}@gmail.com",
                    Phone      = "+7" + phone,
                    Role       = "Студент"
                });
                ++count;
            }
            #endregion
        }
Example #2
0
 protected override void Seed(Context database)
 {
     #region TYPES
     Domain.Core.Type type1 = new Domain.Core.Type {
         Description = "Пропускает через ворота",
         Status      = "Пропускной"
     };
     Domain.Core.Type type2 = new Domain.Core.Type {
         Description = "Отмечает посещаемость",
         Status      = "Лекционный"
     };
     Domain.Core.Type type3 = new Domain.Core.Type {
         Description = "Собирает статистику",
         Status      = "Статистический"
     };
     database.Type.Add(type1);
     database.Type.Add(type2);
     database.Type.Add(type3);
     #endregion
     #region MODES
     Mode mode1 = new Mode {
         Description = "Отмечает событие входа в объект",
         Status      = "Вход"
     };
     Mode mode2 = new Mode {
         Description = "Отмечает событие выхода из объекта",
         Status      = "Выход"
     };
     Mode mode3 = new Mode {
         Description = "Собирает статистические данные передвижений субъекта",
         Status      = "Статистика"
     };
     Mode mode4 = new Mode
     {
         Description = "Отмечает событие входа в аудиторию",
         Status      = "Вход в аудиторию"
     };
     Mode mode5 = new Mode
     {
         Description = "Отмечает событие выхода в аудитории",
         Status      = "Выход в аудитории"
     };
     #endregion
     #region ADMISSIONS
     Admission admission1 = new Admission {
         Role        = "Сотрудник",
         Description = "Вход в лабораторию"
     };
     Admission admission2 = new Admission {
         Role        = "Студент",
         Description = "Вход в 1-й корпус"
     };
     Admission admission3 = new Admission
     {
         Role        = "Преподаватель",
         Description = "Вход в 1-й корпус"
     };
     database.Admission.Add(admission1);
     database.Admission.Add(admission2);
     database.Admission.Add(admission3);
     database.SaveChanges();
     #endregion
     #region GUESTS
     int guestNumber = 15;
     while (guestNumber > 0)
     {
         database.Identity.Add(new Identity
         {
             GUID    = "GUEST_" + guestNumber.ToString(),
             Picture = "cat.jpg"
         });
         --guestNumber;
     }
     database.SaveChanges();
     #endregion
     #region USERS
     database.Identity.Add(new Identity
     {
         GUID    = "milantevsa1516",
         Picture = "milantevsa1516.jpg"
     });
     database.Identity.Add(new Identity
     {
         GUID    = "konyaevyy1517",
         Picture = "konyaevyy1517.jpg"
     });
     database.Identity.Add(new Identity
     {
         GUID    = "eremenkod1518",
         Picture = "eremenkod1518.jpg"
     });
     database.Identity.Add(new Identity
     {
         GUID    = "abor1519",
         Picture = "abor1519.jpg"
     });
     #endregion
     #region GUID BINDING
     string   path = AppDomain.CurrentDomain.BaseDirectory + "App_Code\\users.txt";
     string[] lines;
     if (File.Exists(path))
     {
         lines = File.ReadAllLines(path);
     }
     else
     {
         lines = File.ReadAllLines("D:\\users.txt");
     }
     int        count      = 1;
     Translator translator = new Translator();
     foreach (var line in lines)
     {
         string[] items = line.Split(' ');
         string   guid  = translator.Bind(items[0].ToLower());
         database.Identity.Add(new Identity
         {
             GUID = guid + count.ToString()
         });
         ++count;
     }
     #endregion
     #region CHECKPOINTS
     database.Checkpoint.Add(new Checkpoint
     {
         IP          = "192.168.0.1",
         Campus      = 1,
         Row         = 4,
         Section     = 1,
         Classroom   = 425,
         Description = "В лекционной аудитории",
         Status      = "Отметка",
         Type        = type2
     });
     database.Checkpoint.Add(new Checkpoint
     {
         IP          = "192.168.0.15",
         Campus      = 1,
         Row         = 4,
         Section     = 3,
         Description = "На углу на 4 этаже",
         Status      = "Пропуск",
         Type        = type1
     });
     database.SaveChanges();
     #endregion
     #region ACTIVITIES
     database.Activity.Add(new Activity
     {
         IdentityGUID = "milantev_sa#1516",
         CheckpointIP = "192.168.0.15",
         Date         = DateTime.Now,
         Mode         = mode1,
         Status       = true
     });
     database.Activity.Add(new Activity
     {
         IdentityGUID = "milantev_sa#1516",
         CheckpointIP = "192.168.0.1",
         Date         = DateTime.Now,
         Mode         = mode3,
         Status       = true
     });
     database.Activity.Add(new Activity
     {
         IdentityGUID = "milantev_sa#1516",
         CheckpointIP = "192.168.0.15",
         Date         = DateTime.Now,
         Mode         = mode2,
         Status       = true
     });
     #endregion
     #region ADMISSIONS TO CHECKPOINTS
     database.CheckpointAdmission.Add(new CheckpointAdmission {
         CheckpointID = 1,
         AdmissionID  = 1
     });
     database.CheckpointAdmission.Add(new CheckpointAdmission {
         CheckpointID = 2,
         AdmissionID  = 1
     });
     database.CheckpointAdmission.Add(new CheckpointAdmission {
         CheckpointID = 2,
         AdmissionID  = 2
     });
     database.CheckpointAdmission.Add(new CheckpointAdmission
     {
         CheckpointID = 1,
         AdmissionID  = 3
     });
     database.CheckpointAdmission.Add(new CheckpointAdmission
     {
         CheckpointID = 2,
         AdmissionID  = 3
     });
     database.SaveChanges();
     database.Mode.Add(mode4);
     database.Mode.Add(mode5);
     database.SaveChanges();
     #endregion
 }