public ImmigrationDataParser(TextAsset dat) { string[] lines = parseTextAsset(dat); var lineCount = 0; foreach (string line in lines) { if (lineCount != 0) { String[] splitLine = line.Split(','); var data = new MigrationData(); var isDateParsed = DateTime.TryParse(splitLine[0], out data.assessedDate); if (!isDateParsed) { continue; } data.fromCountry = splitLine[6]; data.travelPurpose = splitLine[9]; var isIntPared = int.TryParse(splitLine[10], out data.numberOfArrivals); if (!isIntPared) { continue; } parsedData.Add(data); } lineCount++; } Console.WriteLine(lineCount); }
public static void EnqueueMigration(int id, MigrationData data) { lock (MigrationLock) { MigrationQueue.Add(id, data); } }
private void AddMigration(string contextName, string version, MigrationData migration, string snapshot, bool createNew) { using (var context = this.contextService.Get <MigrationContext>()) { SnapshotData newSnapshot; if (createNew) { newSnapshot = new SnapshotData { Context = contextName }; context.Snapshots.Add(newSnapshot); } else { newSnapshot = context.Snapshots.Single(x => x.Context == contextName); } newSnapshot.Version = version; if (migration != null) { newSnapshot.Snapshot = snapshot; context.Migrations.Add(migration); } context.SaveChanges(); } }
/// <summary> /// Invoked when a sequence of migrations fails with an error /// </summary> /// <param name="exception">Exception which was encountered</param> /// <param name="from">Migration which was migrated from</param> /// <param name="currentVersion">Last successful migration which was applied</param> public void EndSequenceWithError(Exception exception, MigrationData from, MigrationData currentVersion) { Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Database is currently on version {0}: {1}", currentVersion.Version, currentVersion.FullName); Console.ForegroundColor = this.foregroundColor; }
/// <summary> /// Initializes a new instance of the <see cref="MainForm"/> class. /// </summary> public MainForm() { this.InitializeComponent(); this.migrationData = new MigrationData(); this.Size = new Size(this.Size.Width, this.Size.Height - 25); ////Todo: use tablessControl this.treeViewContentSelection.CheckBoxes = true; this.listViewMigrationContent.Scrollable = true; ColumnHeader header = new ColumnHeader(); header.Text = "Element"; header.Name = "col1"; header.Width = 400; this.listViewMigrationContent.Columns.Add(header); // disable all tabs other than the first one this.EnableTab(this.tabPageContentSelection, false); this.EnableTab(this.tabPageMigrationElements, true); //// set it true for testing this.EnableTab(this.tabPageMigrationPreparation, false); this.EnableTab(this.tabPageMigrationProgress, false); this.log = new Logger(this.listBoxMigrationLog, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)); this.log.AddMessage("Program started"); }
private bool migrate_CourtBankAccount(MigrationData item) { var data = item.Data.Split('|'); try { var model = new CourtBankAccount() { CourtId = item.CourtId, Iban = data[0], Label = data[1], MoneyGroupId = int.Parse(data[2]), IsActive = true, DateStart = DefaultDateFrom }; repo.Add(model); repo.SaveChanges(); model.OrderNumber = model.Id; repo.SaveChanges(); return(true); } catch (Exception ex) { var error = ex.Message; return(false); } }
private void MigrateContext(Type type) { SnapshotData snapshot; using (var context = this.contextService.Get <MigrationContext>()) { snapshot = context.Snapshots .AsNoTracking() .SingleOrDefault(x => x.Context == type.Name); } var assemblyVersion = type.Assembly.GetName().Version; if (snapshot == null || Version.Parse(snapshot.Version) < assemblyVersion) { var oldSnapshotCode = snapshot?.Snapshot ?? string.Empty; var oldVersion = Version.Parse(snapshot?.Version ?? DefaultMigrationDbContextService.EmptyVersion); var oldMigrationsAssembly = this.GenerateMigrationAssemblyName(type, oldVersion); this.LoadAssembly(oldMigrationsAssembly, oldSnapshotCode); var newVersion = type.Assembly.GetName().Version; var newMigrationName = this.GenerateMigrationName(type, newVersion); var scaffoldedMigration = this.CreateMigration(type, oldMigrationsAssembly, newMigrationName); MigrationData migration = null; if (scaffoldedMigration.SnapshotCode != oldSnapshotCode) { migration = this.ApplyMigration(type, newVersion, scaffoldedMigration); } this.AddMigration(type.Name, newVersion.ToString(), migration, scaffoldedMigration.SnapshotCode, snapshot == null); } }
public static PacketWriter LoginAccountSuccess(MapleAccount acc) { PacketWriter pw = new PacketWriter(); pw.WriteHeader(SendHeader.AccountLoginResponse); pw.WriteByte(0); pw.WriteByte(0); pw.WriteInt(0); pw.WriteInt(acc.Id); pw.WriteLong(0); pw.WriteShort(0); pw.WriteByte(0x95); pw.WriteMapleString(acc.Name); pw.WriteLong(0); pw.WriteShort(0); pw.WriteHexString("A0 2C D1 09 92 7C C5 01 0A 00 00 00 01 11 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 01 01 00 00 02 00 01 01 00 01 01 00 01 01 00 01 01 00 00 01 00 00 FF FF FF FF 01 01"); /*pw.WriteHexString("60 AC CC 1F 57 C7 01"); * pw.WriteInt(0x38); * pw.WriteBool(true); //? * pw.WriteByte(0xB); //featured job, shows up at the front, 0xA = Zero, 0xB = BeastTamer * pw.WriteBool(true); //Resistance * pw.WriteBool(true); //Explorer * pw.WriteBool(true); //Cygnus * pw.WriteBool(true); //Aran * pw.WriteBool(true); //Evan * pw.WriteBool(true); //Mercedes * pw.WriteBool(true); //Demon * pw.WriteBool(true); //Phantom * pw.WriteBool(true); //DualBlade * pw.WriteBool(true); //Mihile * pw.WriteBool(true); //Luminous * pw.WriteBool(true); //Kaiser * pw.WriteBool(true); //Angelic Buster * pw.WriteBool(true); //Cannonneer * pw.WriteBool(true); //Xenon * pw.WriteBool(false); //Zero * pw.WriteBool(true); //Jett * pw.WriteBool(true); //Hayato * pw.WriteBool(true); //Kanna * pw.WriteBool(true); //BeastTamer */ MigrationData migration = new MigrationData() { CharacterId = 0, ConnectionAuth = Functions.RandomLong(), AccountName = acc.Name }; acc.MigrationData = migration; pw.WriteLong(migration.ConnectionAuth); return(pw); }
private bool migrate_CourtGroup(MigrationData item) { var data = item.Data.Split('|'); var caseGroupTXT = data[1].ToLower(); int caseGroupId = 0; if (caseGroupTXT.Contains("аказа", StringComparison.InvariantCultureIgnoreCase)) { caseGroupId = NomenclatureConstants.CaseGroups.NakazatelnoDelo; } if (caseGroupTXT.Contains("ажданск", StringComparison.InvariantCultureIgnoreCase)) { caseGroupId = NomenclatureConstants.CaseGroups.GrajdanskoDelo; } if (caseGroupTXT.Contains("ирмен", StringComparison.InvariantCultureIgnoreCase)) { caseGroupId = NomenclatureConstants.CaseGroups.Company; } if (caseGroupTXT.Contains("ърговск", StringComparison.InvariantCultureIgnoreCase)) { caseGroupId = NomenclatureConstants.CaseGroups.Trade; } if (caseGroupTXT.Contains("министра", StringComparison.InvariantCultureIgnoreCase)) { caseGroupId = NomenclatureConstants.CaseGroups.Administrative; } try { if (caseGroupId == 0) { throw new Exception($"Невалидна група '{caseGroupTXT}'"); } var model = new CourtGroup() { CourtId = item.CourtId, Label = data[0], CaseGroupId = caseGroupId, Description = item.Code.Trim(), DateFrom = DefaultDateFrom }; repo.Add(model); repo.SaveChanges(); model.OrderNumber = model.Id; repo.SaveChanges(); return(true); } catch (Exception ex) { var error = ex.Message; return(false); } }
public static void Handle(MapleClient c, PacketReader pr) { //[00 00 00 00] [F2 07 00 00] 00 00 00 00 00 00 64 11 A0 D8 00 00 00 00 B8 54 00 00 38 9A FE 92 98 EB F3 B2 pr.Skip(4); //v143 int characterId = pr.ReadInt(); pr.Skip(18); long ConnectionAuth = pr.ReadLong(); MigrationData migration = Program.TryDequeueMigration(characterId, ConnectionAuth, c.Channel); if (migration != null || migration.Character == null) { MapleClient oldClient = Program.GetClientByCharacterId(migration.CharacterId); if (oldClient != null) { oldClient.SClient.Dispose(); } MapleAccount account = MapleAccount.GetAccountFromDatabase(migration.AccountName); MapleCharacter chr = migration.Character; account.Character = chr; c.Account = account; chr.Bind(c); account.MigrationData = migration; account.Character = chr; if (!migration.ToCashShop) { MapleMap map = Program.GetChannelServer(c.Channel).GetMap(chr.MapId); if (map != null) { chr.Map = map; MapleCharacter.EnterChannel(c); c.Account.Character.LoggedIn(); chr.Stats.Recalculate(chr); chr.Position = map.GetStartpoint(0).Position; map.AddCharacter(chr); } } else { CashShop.StartShowing(c); } } else { c.Disconnect("No migration data found."); } }
public void Release() { lock (ReleaseLock) { if (Character != null) { bool hasMigration = Program.MigrationExists(Character.Id); MapleCharacter.SaveToDatabase(Character); Character.Release(hasMigration); Character = null; } MigrationData = null; } }
/// <summary> /// Safely tries to dequeue a migration. /// </summary> public static MigrationData TryDequeueMigration(int id, long auth, byte channel) { lock (MigrationLock) { MigrationData connection = null; if (MigrationQueue.TryGetValue(id, out connection)) { if (connection.ConnectionAuth == auth && connection.ToChannel == channel) { MigrationQueue.Remove(id); return(connection); } } } return(null); }
private bool migrate_ArchiveIndexCode(MigrationData item) { var data = item.Data.Split('|'); try { var model = new CourtArchiveIndexCode() { DateFrom = DefaultDateFrom }; var index = repo.AllReadonly <CourtArchiveIndex>().Where(x => x.CourtId == item.CourtId && x.Description == item.ParentCode).FirstOrDefault(); int caseCodeId = getCaseCodeByCode(item.Code); if (index != null && caseCodeId > 0) { model.CourtArchiveIndexId = index.Id; model.CaseCodeId = caseCodeId; if (repo.AllReadonly <CourtArchiveIndexCode>() .Where(x => x.CourtArchiveIndexId == model.CourtArchiveIndexId && x.CaseCodeId == model.CaseCodeId).Any()) { item.Message = "Кода се повтаря."; return(true); } repo.Add(model); repo.SaveChanges(); return(true); } else { item.Message = $"Ненамерен индекс с ID = {item.ParentCode} или шифър {item.Code}"; return(false); } } catch (Exception ex) { item.Message = ex.Message; return(false); } }
private bool migrate_CourtGroupCode(MigrationData item) { try { int groupId = repo.AllReadonly <CourtGroup>().Where(x => x.CourtId == item.CourtId && x.Description == item.ParentCode.Trim()) .Select(x => x.Id).FirstOrDefault(); int caseCodeId = getCaseCodeByCode(item.Code); if (groupId == 0) { throw new Exception($"Ненамерена група с id={item.ParentCode}"); } if (caseCodeId == 0) { throw new Exception($"Ненамерен шифър с код={item.Code}"); } var model = new CourtGroupCode() { CourtGroupId = groupId, CaseCodeId = caseCodeId, DateFrom = DefaultDateFrom }; item.Message = null; if (repo.AllReadonly <CourtGroupCode>().Where(x => x.CourtGroupId == groupId && x.CaseCodeId == caseCodeId).Any()) { return(true); } else { repo.Add(model); repo.SaveChanges(); return(true); } } catch (Exception ex) { item.Message = ex.Message; return(false); } }
private bool migrate_LoadGroup(MigrationData item) { try { var data = item.Data.Split('$'); var groupModel = new LoadGroup() { Code = data[0], Label = data[1], DateStart = DefaultDateFrom, IsActive = true, Description = "migrated", LoadGroupLinks = new HashSet <LoadGroupLink>() }; var linkModel = new LoadGroupLink() { CourtTypeId = int.Parse(data[2]), CaseInstanceId = int.Parse(data[3]), LoadIndex = decimal.Parse(data[4].Replace(",", System.Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)), GroupCodes = new HashSet <LoadGroupLinkCode>() }; var codeModel = new LoadGroupLinkCode() { CaseCodeId = int.Parse(data[5]) }; linkModel.GroupCodes.Add(codeModel); groupModel.LoadGroupLinks.Add(linkModel); repo.Add(groupModel); repo.SaveChanges(); return(true); } catch (Exception ex) { item.Message = ex.Message; return(false); } }
private bool migrate_ArchiveCommitteeLawunit(MigrationData item) { var data = item.Data.Split('|'); try { var model = new CourtArchiveCommitteeLawUnit() { DateFrom = DefaultDateFrom }; var committee = repo.AllReadonly <CourtArchiveCommittee>().Where(x => x.CourtId == item.CourtId && x.Description == item.ParentCode).FirstOrDefault(); var uic = data[0]; var lawunit = repo.AllReadonly <CourtLawUnit>() .Include(x => x.LawUnit) .Where(x => x.CourtId == item.CourtId && x.LawUnit.Uic == uic && x.PeriodTypeId == NomenclatureConstants.PeriodTypes.Appoint) .Select(x => x.LawUnit).FirstOrDefault(); if ((committee == null) || (lawunit == null)) { item.Message = $"Ненамерена комисия {item.ParentCode} или лице {uic} {data[1]}"; return(false); } if (repo.AllReadonly <CourtArchiveCommitteeLawUnit>().Where(x => x.CourtArchiveCommitteeId == committee.Id && x.LawUnitId == lawunit.Id).Any()) { item.Message = $"Лицето {uic} {data[1]} вече съществува"; return(false); } model.CourtArchiveCommitteeId = committee.Id; model.LawUnitId = lawunit.Id; repo.Add(model); repo.SaveChanges(); return(true); } catch (Exception ex) { item.Message = ex.Message; return(false); } }
private MigrationData ApplyMigration(Type type, Version version, ScaffoldedMigration scaffoldedMigration) { var migration = new MigrationData { Context = type.Name, Version = version.ToString(), Migration = scaffoldedMigration.MigrationCode, Metadata = scaffoldedMigration.MetadataCode }; var migrationAssemblyName = this.GenerateMigrationAssemblyName(type, version); this.LoadAssembly(migrationAssemblyName, scaffoldedMigration.SnapshotCode, migration); using (var context = (DbContextBase)this.contextService.Get(type)) { context.Initialize(new DefaultInitializeDbContext(this.app, migrationAssemblyName, this.GenerateMigrationsHistoryTableName(type))); context.Database.Migrate(); } return(migration); }
private bool migrate_ArchiveCommittee(MigrationData item) { try { var model = new CourtArchiveCommittee() { CourtId = item.CourtId, Label = item.Data, Description = item.Code, DateStart = DefaultDateFrom }; repo.Add(model); repo.SaveChanges(); return(true); } catch (Exception ex) { var error = ex.Message; return(false); } }
private bool migrate_ArchiveIndex(MigrationData item) { var data = item.Data.Split('|'); try { var model = new CourtArchiveIndex() { CourtId = item.CourtId, Code = data[0], Label = data[1], StorageYears = int.Parse(data[2]), Description = item.Code, IsActive = true, DateStart = DefaultDateFrom }; var committee = repo.AllReadonly <CourtArchiveCommittee>().Where(x => x.CourtId == item.CourtId && x.Description == item.ParentCode).FirstOrDefault(); if (committee != null) { model.CourtArchiveCommitteeId = committee.Id; repo.Add(model); repo.SaveChanges(); return(true); } else { item.Message = $"Ненамерена комисия с ID = {item.ParentCode}"; return(false); } } catch (Exception ex) { var error = ex.Message; return(false); } }
private bool migrate_CourtHall(MigrationData item) { var data = item.Data.Split('|'); try { var model = new CourtHall() { CourtId = item.CourtId, Name = data[0], Location = data[1], DateFrom = DefaultDateFrom }; repo.Add(model); repo.SaveChanges(); return(true); } catch (Exception ex) { var error = ex.Message; return(false); } }
/// <summary> /// Invoked when an individual migration is started /// </summary> /// <param name="migration">Migration being started</param> /// <param name="direction">Direction of the migration</param> public void BeginMigration(MigrationData migration, MigrationDirection direction) { var term = direction == MigrationDirection.Up ? "migrating" : "reverting"; this.WriteHeader("{0}: {1} {2}", migration.Version, migration.FullName, term); }
/// <summary> /// Read all the manifest.xml files and generate a dictionary of uncensors to be used in config manager dropdown /// </summary> private static void PopulateUncensorLists() { BodyDictionary.Clear(); BodyConfigListFull.Clear(); PenisDictionary.Clear(); PenisConfigListFull.Clear(); BallsDictionary.Clear(); BallsConfigListFull.Clear(); //Add the default body options BodyConfigListFull["Random"] = "Random"; #if KK || EC BodyData DefaultMale = new BodyData(0, DefaultBodyMaleGUID, "Default Body M"); BodyDictionary[DefaultMale.BodyGUID] = DefaultMale; BodyConfigListFull[$"[{(DefaultMale.Sex == 0 ? "Male" : "Female")}] {DefaultMale.DisplayName}"] = DefaultMale.BodyGUID; #endif BodyData DefaultFemale = new BodyData(1, DefaultBodyFemaleGUID, "Default Body F"); BodyDictionary[DefaultFemale.BodyGUID] = DefaultFemale; BodyConfigListFull[$"[{(DefaultFemale.Sex == 0 ? "Male" : "Female")}] {DefaultFemale.DisplayName}"] = DefaultFemale.BodyGUID; //Add the default penis options PenisConfigListFull["Random"] = "Random"; PenisData DefaultPenis = new PenisData(DefaultPenisGUID, "Mosaic Penis"); PenisDictionary[DefaultPenis.PenisGUID] = DefaultPenis; PenisConfigListFull[DefaultPenis.DisplayName] = DefaultPenis.PenisGUID; //Add the default balls options BallsConfigListFull["Random"] = "Random"; BallsData DefaultBalls = new BallsData(DefaultBallsGUID, "Mosaic Balls"); BallsDictionary[DefaultBalls.BallsGUID] = DefaultBalls; BallsConfigListFull[DefaultBalls.DisplayName] = DefaultBalls.BallsGUID; var loadedManifests = Sideloader.Sideloader.Manifests; foreach (var manifest in loadedManifests.Values) { XDocument manifestDocument = manifest.manifestDocument; XElement uncensorSelectorElement = manifestDocument?.Root?.Element(PluginNameInternal); if (uncensorSelectorElement != null && uncensorSelectorElement.HasElements) { foreach (XElement uncensorElement in uncensorSelectorElement.Elements("body")) { BodyData bodyData = new BodyData(uncensorElement); if (bodyData.BodyGUID == null) { Logger.LogWarning("Body failed to load due to missing GUID."); continue; } if (bodyData.DisplayName == null) { Logger.LogWarning("Body failed to load due to missing display name."); continue; } if (bodyData.OOBase == Defaults.OOBase) { Logger.LogWarning("Body was not loaded because oo_base is the default."); continue; } BodyDictionary[bodyData.BodyGUID] = bodyData; BodyConfigListFull[$"[{(bodyData.Sex == 0 ? "Male" : "Female")}] {bodyData.DisplayName}"] = bodyData.BodyGUID; foreach (var part in bodyData.AdditionalParts) { AllAdditionalParts.Add(part); } } foreach (XElement uncensorElement in uncensorSelectorElement.Elements("penis")) { PenisData penisData = new PenisData(uncensorElement); if (penisData.PenisGUID == null) { Logger.LogWarning("Penis failed to load due to missing GUID."); continue; } if (penisData.DisplayName == null) { Logger.LogWarning("Penis failed to load due to missing display name."); continue; } if (penisData.File == null) { Logger.LogWarning("Penis failed to load due to missing file."); continue; } if (penisData.Asset == null) { Logger.LogWarning("Penis failed to load due to missing asset."); continue; } PenisDictionary[penisData.PenisGUID] = penisData; PenisConfigListFull[penisData.DisplayName] = penisData.PenisGUID; } foreach (XElement uncensorElement in uncensorSelectorElement.Elements("balls")) { BallsData ballsData = new BallsData(uncensorElement); if (ballsData.BallsGUID == null) { Logger.LogWarning("Balls failed to load due to missing GUID."); continue; } if (ballsData.DisplayName == null) { Logger.LogWarning("Balls failed to load due to missing display name."); continue; } if (ballsData.File == null) { Logger.LogWarning("Balls failed to load due to missing file."); continue; } if (ballsData.Asset == null) { Logger.LogWarning("Balls failed to load due to missing asset."); continue; } BallsDictionary[ballsData.BallsGUID] = ballsData; BallsConfigListFull[ballsData.DisplayName] = ballsData.BallsGUID; } foreach (XElement uncensorElement in uncensorSelectorElement.Elements("migration")) { MigrationData migrationData = new MigrationData(uncensorElement); if (migrationData.UncensorGUID == null) { Logger.LogWarning("Migration data failed to load due to missing Uncensor GUID."); continue; } if (migrationData.BodyGUID == null) { Logger.LogWarning("Migration data failed to load due to missing Body GUID."); continue; } MigrationDictionary[migrationData.UncensorGUID] = migrationData; } } } }
/// <summary> /// Invoked when a sequence of migrations is started /// </summary> /// <param name="from">Migration being migrated from</param> /// <param name="to">Migration being migrated to</param> public void BeginSequence(MigrationData from, MigrationData to) { this.foregroundColor = Console.ForegroundColor; this.WriteHeader("Migrating from {0}: {1} to {2}: {3}", from.Version, from.FullName, to.Version, to.FullName); }
/// <summary> /// Invoked when an individual migration is completed successfully /// </summary> /// <param name="migration">Migration which completed</param> /// <param name="direction">Direction of the migration</param> public void EndMigration(MigrationData migration, MigrationDirection direction) { Console.WriteLine(); }
/// <summary> /// Invoked when a sequence of migrations is started /// </summary> /// <param name="from">Migration being migrated from</param> /// <param name="to">Migration being migrated to</param> public void BeginSequence(MigrationData from, MigrationData to) { this.foregroundColor = Console.ForegroundColor; this.WriteHeader($"Migrating from {from.Version}: {from.FullName} to {to.Version}: {to.FullName}"); }
/// <summary> /// Invoked when an individual migration fails with an error /// </summary> /// <param name="exception">Exception which was encountered</param> /// <param name="migration">Migration which failed</param> /// <param name="direction">Direction of the migration</param> public void EndMigrationWithError(Exception exception, MigrationData migration, MigrationDirection direction) { this.WriteError("{0}: {1} ERROR {2}", migration.Version, migration.FullName, exception.Message); }
private bool migrate_Institution(MigrationData item) { var data = item.Data.Split('|'); try { int institutionTypeId = int.Parse(item.DataType.Substring(12)); var model = new Institution() { Person = null, InstitutionTypeId = institutionTypeId, UicTypeId = NomenclatureConstants.UicTypes.EGN, FirstName = data[0], MiddleName = data[1], FamilyName = data[2], Family2Name = data[3], Code = data[4] }; if (!string.IsNullOrEmpty(item.Code)) { model.Uic = item.Code; } if (!string.IsNullOrEmpty(model.Code)) { var savedInst = repo.AllReadonly <Institution>() .Where(x => x.Code == model.Code && x.InstitutionTypeId == model.InstitutionTypeId) .FirstOrDefault(); if (savedInst != null) { item.Message = $"{savedInst.Code} {savedInst.FullName} вече съществува"; return(false); } } if (!string.IsNullOrEmpty(model.Uic)) { var savedInst = repo.AllReadonly <Institution>() .Where(x => x.Uic == model.Uic && x.UicTypeId == model.UicTypeId && x.InstitutionTypeId == model.InstitutionTypeId) .FirstOrDefault(); if (savedInst != null) { item.Message = $"{savedInst.Uic} {savedInst.FullName} вече съществува"; return(false); } } switch (institutionTypeId) { case NomenclatureConstants.InstitutionTypes.Notary: model.DepartmentName = data[5].Trim(); break; default: break; } model.FullName = model.MakeFullName(); repo.Add(model); repo.SaveChanges(); return(true); } catch (Exception ex) { item.Message = ex.Message; return(false); } }
/// <summary> /// Invoked when an individual migration fails with an error /// </summary> /// <param name="exception">Exception which was encountered</param> /// <param name="migration">Migration which failed</param> /// <param name="direction">Direction of the migration</param> public void EndMigrationWithError(Exception exception, MigrationData migration, MigrationDirection direction) { this.WriteError($"{migration.Version}: {migration.FullName} ERROR {exception.Message}"); }
/// <summary> /// Invoked when a sequence of migrations is completed successfully /// </summary> /// <param name="from">Migration which was migrated from</param> /// <param name="to">Migration which was migrated to</param> public void EndSequence(MigrationData from, MigrationData to) { this.WriteHeader("Done"); }
private async Task <bool> migrate_CourtLawUnit(MigrationData item) { var data = item.Data.Split('|'); try { int lawUnitTypeId = int.Parse(item.DataType.Substring(8)); string email = string.Empty; var lawUnit = new LawUnit() { LawUnitTypeId = lawUnitTypeId, UicTypeId = NomenclatureConstants.UicTypes.EGN, Uic = data[1], FirstName = data[2]?.Trim(), MiddleName = data[3]?.Trim(), FamilyName = data[4]?.Trim(), Family2Name = data[5]?.Trim(), DateFrom = DefaultDateFrom, DateWrt = DateTime.Now }; lawUnit.FullName = lawUnit.MakeFullName(); if (!string.IsNullOrEmpty(lawUnit.Uic)) { lawUnit.Person.CopyFrom(lawUnit); } else { lawUnit.Person = null; } var lawUnitPeriods = new List <CourtLawUnit>(); var appointPeriod = new CourtLawUnit(); if (!NomenclatureConstants.LawUnitTypes.NoApointmentPersons.Contains(lawUnitTypeId)) { appointPeriod.CourtId = item.CourtId; appointPeriod.DateFrom = DefaultDateFrom; appointPeriod.PeriodTypeId = NomenclatureConstants.PeriodTypes.Appoint; lawUnitPeriods.Add(appointPeriod); } switch (lawUnitTypeId) { case NomenclatureConstants.LawUnitTypes.Judge: email = data[6].Trim(); try { if (!string.IsNullOrEmpty(data[7])) { var moveToCourt = int.Parse(data[7]); var moveFromDate = data[8]; var movePeriod = new CourtLawUnit() { CourtId = moveToCourt, DateFrom = moveFromDate.StrToDateFormat("dd.MM.yyyy"), PeriodTypeId = NomenclatureConstants.PeriodTypes.Move }; if (moveToCourt < 0) { //Ако е командирован в текущия съд, се разменят двата вида период appointPeriod.PeriodTypeId = NomenclatureConstants.PeriodTypes.Move; appointPeriod.DateFrom = movePeriod.DateFrom; movePeriod.CourtId = Math.Abs(movePeriod.CourtId); movePeriod.PeriodTypeId = NomenclatureConstants.PeriodTypes.Appoint; movePeriod.DateFrom = DefaultDateFrom; } lawUnitPeriods.Add(movePeriod); } } catch { } break; case NomenclatureConstants.LawUnitTypes.MessageDeliverer: email = data[6].Trim(); break; case NomenclatureConstants.LawUnitTypes.OtherEmployee: email = data[6].Trim(); lawUnit.Department = data[7]; break; case NomenclatureConstants.LawUnitTypes.Jury: //Кой съд и специалност ако има lawUnit.Department = data[6] + ":" + (data[7] ?? ""); break; case NomenclatureConstants.LawUnitTypes.Prosecutor: //Кой съд и специалност ако има lawUnit.Code = data[6] ?? ""; lawUnit.Department = data[7] ?? ""; if (string.IsNullOrEmpty(lawUnit.Code)) { item.Message = $"{lawUnit.FullName} няма код"; return(false); } if (repo.AllReadonly <LawUnit>().Where(x => x.Code == lawUnit.Code && x.LawUnitTypeId == lawUnitTypeId).Any()) { item.Message = $"{lawUnit.Code} {lawUnit.FullName} вече съществува"; return(false); } break; default: break; } lawUnit.Courts = lawUnitPeriods; if (!string.IsNullOrEmpty(lawUnit.Uic)) { var savedLU = repo.AllReadonly <LawUnit>() .Where(x => x.Uic == lawUnit.Uic && x.UicTypeId == lawUnit.UicTypeId) .FirstOrDefault(); if (savedLU != null) { item.Message = $"{savedLU.Uic} {savedLU.FullName} вече съществува"; return(false); } } //Лицата трябва да имат уникално ЕГН и уникален email if (NomenclatureConstants.LawUnitTypes.EissUserTypes.Contains(lawUnitTypeId)) { if (string.IsNullOrEmpty(lawUnit.Uic)) { item.Message = "Лицето няма ЕГН"; return(false); } long egn; if (!long.TryParse(lawUnit.Uic, out egn)) { item.Message = "Невалидно ЕГН"; return(false); } if (string.IsNullOrEmpty(email)) { item.Message = "Лицето няма електронна поща"; return(false); } if (repo.AllReadonly <ApplicationUser>().Where(x => x.NormalizedEmail == email.ToUpper()).Any()) { item.Message = "Съществуваща електронна поща"; return(false); } } repo.Add(lawUnit); repo.SaveChanges(); //Ако има електронна поща се създава и потребител if (!string.IsNullOrEmpty(email)) { var user = new ApplicationUser { UserName = email, Email = email, LawUnitId = lawUnit.Id, CourtId = item.CourtId, WorkNotificationToMail = true, IsActive = true }; IdentityResult res = null; res = await userManager.CreateAsync(user).ConfigureAwait(false); if (res.Succeeded) { return(true); } else { return(false); } } else { return(true); } } catch (Exception ex) { item.Message = ex.Message; return(false); } }
/// <summary> /// Invoked when an individual migration is started /// </summary> /// <param name="migration">Migration being started</param> /// <param name="direction">Direction of the migration</param> public void BeginMigration(MigrationData migration, MigrationDirection direction) { var term = direction == MigrationDirection.Up ? "migrating" : "reverting"; this.WriteHeader($"{migration.Version}: {migration.FullName} {term}"); }
public MigrationDataRecieved(MigrationData data) { Data = data; }
/// <summary> /// Read all the manifest.xml files and generate a dictionary of uncensors to be used in config manager dropdown /// </summary> private static void PopulateUncensorLists() { BodyDictionary.Clear(); BodyConfigListFull.Clear(); PenisDictionary.Clear(); PenisConfigListFull.Clear(); BallsDictionary.Clear(); BallsConfigListFull.Clear(); //Add the default body options BodyConfigListFull.Add("Random", "Random"); BodyData DefaultMale = new BodyData(0, "Default.Body.Male", "Default Body M"); BodyDictionary.Add(DefaultMale.BodyGUID, DefaultMale); BodyConfigListFull.Add($"[{(DefaultMale.Sex == 0 ? "Male" : "Female")}] {DefaultMale.DisplayName}", DefaultMale.BodyGUID); BodyData DefaultFemale = new BodyData(1, "Default.Body.Female", "Default Body F"); BodyDictionary.Add(DefaultFemale.BodyGUID, DefaultFemale); BodyConfigListFull.Add($"[{(DefaultFemale.Sex == 0 ? "Male" : "Female")}] {DefaultFemale.DisplayName}", DefaultFemale.BodyGUID); //Add the default penis options PenisConfigListFull.Add("Random", "Random"); PenisData DefaultPenis = new PenisData("Default.Penis", "Mosaic Penis"); PenisDictionary.Add(DefaultPenis.PenisGUID, DefaultPenis); PenisConfigListFull.Add(DefaultPenis.DisplayName, DefaultPenis.PenisGUID); //Add the default balls options BallsConfigListFull.Add("Random", "Random"); BallsData DefaultBalls = new BallsData("Default.Balls", "Mosaic Balls"); BallsDictionary.Add(DefaultBalls.BallsGUID, DefaultBalls); BallsConfigListFull.Add(DefaultBalls.DisplayName, DefaultBalls.BallsGUID); #if KK var loadedManifests = Sideloader.Sideloader.LoadedManifests; #elif EC var loadedManifests = Sideloader.LoadedManifests; #endif foreach (var manifest in loadedManifests) { XDocument manifestDocument = manifest.manifestDocument; XElement uncensorSelectorElement = manifestDocument?.Root?.Element(PluginNameInternal); if (uncensorSelectorElement != null && uncensorSelectorElement.HasElements) { foreach (XElement uncensorElement in uncensorSelectorElement.Elements("body")) { BodyData bodyData = new BodyData(uncensorElement); if (bodyData.BodyGUID == null) { Log(LogLevel.Warning, "Body failed to load due to missing GUID."); continue; } if (bodyData.DisplayName == null) { Log(LogLevel.Warning, "Body failed to load due to missing display name."); continue; } if (bodyData.OOBase == Defaults.OOBase) { Log(LogLevel.Warning, "Body was not loaded because oo_base is the default."); continue; } BodyDictionary.Add(bodyData.BodyGUID, bodyData); BodyConfigListFull.Add($"[{(bodyData.Sex == 0 ? "Male" : "Female")}] {bodyData.DisplayName}", bodyData.BodyGUID); foreach (var part in bodyData.AdditionalParts) { AllAdditionalParts.Add(part); } } foreach (XElement uncensorElement in uncensorSelectorElement.Elements("penis")) { PenisData penisData = new PenisData(uncensorElement); if (penisData.PenisGUID == null) { Log(LogLevel.Warning, "Penis failed to load due to missing GUID."); continue; } if (penisData.DisplayName == null) { Log(LogLevel.Warning, "Penis failed to load due to missing display name."); continue; } if (penisData.File == null) { Log(LogLevel.Warning, "Penis failed to load due to missing file."); continue; } if (penisData.Asset == null) { Log(LogLevel.Warning, "Penis failed to load due to missing asset."); continue; } PenisDictionary.Add(penisData.PenisGUID, penisData); PenisConfigListFull.Add(penisData.DisplayName, penisData.PenisGUID); } foreach (XElement uncensorElement in uncensorSelectorElement.Elements("balls")) { BallsData ballsData = new BallsData(uncensorElement); if (ballsData.BallsGUID == null) { Log(LogLevel.Warning, "Balls failed to load due to missing GUID."); continue; } if (ballsData.DisplayName == null) { Log(LogLevel.Warning, "Balls failed to load due to missing display name."); continue; } if (ballsData.File == null) { Log(LogLevel.Warning, "Balls failed to load due to missing file."); continue; } if (ballsData.Asset == null) { Log(LogLevel.Warning, "Balls failed to load due to missing asset."); continue; } BallsDictionary.Add(ballsData.BallsGUID, ballsData); BallsConfigListFull.Add(ballsData.DisplayName, ballsData.BallsGUID); } foreach (XElement uncensorElement in uncensorSelectorElement.Elements("migration")) { MigrationData migrationData = new MigrationData(uncensorElement); if (migrationData.UncensorGUID == null) { Log(LogLevel.Warning, "Migration data failed to load due to missing Uncensor GUID."); continue; } if (migrationData.BodyGUID == null) { Log(LogLevel.Warning, "Migration data failed to load due to missing Body GUID."); continue; } MigrationDictionary.Add(migrationData.UncensorGUID, migrationData); } } } }