public static void FillBadRegistry(FirebirdFilePath dbFile) { List <NA_UCHETE> entities; using (Old2014_1Context ctxFB = new Old2014_1Context(dbFile.ConnectionString)) { entities = ctxFB.NA_UCHETE.ToList(); } using (BrandNewContext ctxg = new BrandNewContext()) { foreach (var entity in entities) { if (!ctxg.BadRegistry.Any(e => e.Name.Equals(entity.NAME))) { ctxg.BadRegistry.AddObject(new BadRegistry() { Name = entity.NAME }); } } ctxg.SaveChanges(); } }
public static void FillMilitaryDistrict(FirebirdFilePath dbFile) { List <V_OKRUG> entities; using (Old2014_1Context ctxFB = new Old2014_1Context(dbFile.ConnectionString)) { entities = ctxFB.V_OKRUG.ToList(); } using (BrandNewContext ctxg = new BrandNewContext()) { foreach (var entity in entities) { if (!ctxg.MilitaryDistrict.Any(e => e.Name.Equals(entity.NAME))) { ctxg.MilitaryDistrict.AddObject(new MilitaryDistrict() { Name = entity.NAME }); } } ctxg.SaveChanges(); } }
public static void FillSeason(FirebirdFilePath dbFile) { using (BrandNewContext ctxg = new BrandNewContext()) { if (!ctxg.Season.Any(e => e.Year == dbFile.Year && e.Number == dbFile.Number)) { ctxg.Season.AddObject(new Season() { Year = dbFile.Year, Number = dbFile.Number }); } ctxg.SaveChanges(); } }
public static void FillDepartment(FirebirdFilePath dbFile) { List <RVK> entities; using (Old2014_1Context ctxFB = new Old2014_1Context(dbFile.ConnectionString)) { entities = ctxFB.RVK.ToList(); } using (BrandNewContext ctxg = new BrandNewContext()) { Season season = ctxg.Season.FirstOrDefault(s => s.Number == dbFile.Number && s.Year == dbFile.Year); if (season == default(Season)) { season = new Season() { Number = dbFile.Number, Year = dbFile.Year }; } foreach (var entity in entities) { if (!ctxg.Department.Any(e => e.NameShort == entity.NAME && e.Season.Year == dbFile.Year && e.Season.Number == dbFile.Number)) { ctxg.Department.AddObject(new Department() { NameShort = entity.NAME, NameFull = entity.NAME_S, Season = season }); } } ctxg.SaveChanges(); } }
public static void FillChosenRecruit(FirebirdFilePath dbFile) { List <KN_P> entities; using (Old2014_1Context ctxFB = new Old2014_1Context(dbFile.ConnectionString)) { entities = ctxFB.KN_P.ToList(); } using (BrandNewContext ctxg = new BrandNewContext()) { foreach (var entity in entities) { DateTime birthDate; DateTime.TryParse(entity.D_ROD, out birthDate); #region debugshit /* * List<ChosenRecruit> a1 = new List<ChosenRecruit>(); * List<ChosenRecruit> a2 = new List<ChosenRecruit>(); * List<ChosenRecruit> a3 = new List<ChosenRecruit>(); * List<ChosenRecruit> a4 = new List<ChosenRecruit>(); * List<ChosenRecruit> a5 = new List<ChosenRecruit>(); * List<ChosenRecruit> a51 = new List<ChosenRecruit>(); * List<ChosenRecruit> a52 = new List<ChosenRecruit>(); * List<ChosenRecruit> a53 = new List<ChosenRecruit>(); * List<ChosenRecruit> a6 = new List<ChosenRecruit>(); * List<ChosenRecruit> a7 = new List<ChosenRecruit>(); * List<ChosenRecruit> a8 = new List<ChosenRecruit>(); * try * { * a1 = ctxg.ChosenRecruit.Where(e => e.LastName == entity.FAM).ToList(); * } * catch * { * } * try * { * a2 = a1.Where(e => e.FirstName == entity.IM).ToList(); * } * catch * { * } * try * { * a3 = a2.Where(e => e.MiddleName == entity.OTCH).ToList(); * } * catch * { * } * try * { * a4 = a3.Where(e => e.BirthDate.Value.Year == birthDate.Year).ToList(); * } * catch * { * } * try * { * a51 = a4.Where(e => e.Department_ID.HasValue).ToList(); * } * catch * { * } * try * { * a52 = a4.Where(e => string.IsNullOrEmpty(entity.RVK)).ToList(); * } * catch * { * } * //try * //{ * // a53 = a4.Where(e => e.Department.NameShort == entity.RVK).ToList(); * //} * //catch * //{ * //} * try * { * a5 = a4.Where(e => !e.Department_ID.HasValue && string.IsNullOrEmpty(entity.RVK) || * e.Department_ID.HasValue && e.Department.NameShort == entity.RVK).ToList(); * } * catch * { * } * try * { * a6 = a5.Where(e => e.Destination == entity.KUDA).ToList(); * } * catch * { * } * try * { * a7 = a6.Where(e => string.IsNullOrEmpty(e.Patron) && string.IsNullOrEmpty(entity.KTO) || e.Patron == entity.KTO).ToList(); * } * catch * { * } * try * { * a8 = a7.Where(e => e.Season.Year == dbFile.Year && e.Season.Number == dbFile.Number).ToList(); * } * catch (Exception) * { * } */ #endregion //if (!ctxg.ChosenRecruit.Any(e => e.Equals(entity, dbFile.Number, dbFile.Year))) if (!ctxg.ChosenRecruit.Any(e => (string.IsNullOrEmpty(e.LastName) && string.IsNullOrEmpty(entity.FAM) || e.LastName == entity.FAM) && (string.IsNullOrEmpty(e.FirstName) && string.IsNullOrEmpty(entity.IM) || e.FirstName == entity.IM) && (string.IsNullOrEmpty(e.MiddleName) && string.IsNullOrEmpty(entity.OTCH) || e.MiddleName == entity.OTCH) && (!e.BirthDate.HasValue && birthDate == null || e.BirthDate.Value.Year == birthDate.Year) && (!e.Department_ID.HasValue && string.IsNullOrEmpty(entity.RVK) || e.Department_ID.HasValue && e.Department.NameShort == entity.RVK) && (string.IsNullOrEmpty(e.Destination) && string.IsNullOrEmpty(entity.KUDA) || e.Destination == entity.KUDA) && (string.IsNullOrEmpty(e.Patron) && string.IsNullOrEmpty(entity.KTO) || e.Patron == entity.KTO) && e.Season.Year == dbFile.Year && e.Season.Number == dbFile.Number )) { Season season = ctxg.Season.FirstOrDefault(s => s.Number == dbFile.Number && s.Year == dbFile.Year); if (season == default(Season)) { season = new Season() { Number = dbFile.Number, Year = dbFile.Year }; } Department dept = ctxg.Department.FirstOrDefault(d => d.NameShort.Equals(entity.RVK) && d.Season.Year == dbFile.Year && d.Season.Number == dbFile.Number); if (dept == default(Department)) { //dept = new Department() { NameShort = entity.RVK }; } ctxg.ChosenRecruit.AddObject(new ChosenRecruit() { LastName = entity.FAM, FirstName = entity.IM, MiddleName = entity.OTCH, BirthDate = birthDate, Department = dept, Destination = entity.KUDA, Patron = entity.KTO, Season = season }); } //else //{ // var a = 0; //} } ctxg.SaveChanges(); } }