public IHttpActionResult CreateNomenclatureValue(int nomId, NomValueDO data) { NomValue nomValue = new NomValue(); nomValue.NomId = nomId; nomValue.Code = data.Code; nomValue.Name = data.Name; nomValue.NameAlt = data.NameAlt; nomValue.ParentValueId = data.ParentValueId; nomValue.IsActive = data.IsActive; nomValue.Order = data.Order; if (data.TextContent != null) { nomValue.TextContentString = data.TextContent.ToString(); } this.unitOfWork.DbContext.Set<NomValue>().Add(nomValue); this.unitOfWork.Save(); return Ok(nomValue); }
private void migrateOrganizationKinds(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("organizationKinds"); var results = conn.CreateStoreCommand(@"SELECT * FROM CAA_DOC.NM_SHORT_LISTS where domain = 'TYPE_ORG'") .Materialize(r => new NomValue { OldId = r.Field<object>("ID").ToString(), Code = r.Field<string>("CODE"), Name = r.Field<string>("MEANING"), NameAlt = r.Field<string>("MEANING_TRANS"), Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }) .ToList(); noms["organizationKinds"] = new Dictionary<string, NomValue>(); foreach (var row in results) { noms["organizationKinds"][row.OldId] = row; nom.NomValues.Add(row); } var organizationFmTypes = new List<Tuple<string, string>>() { { new Tuple<string,string>("АД" , "AD")}, { new Tuple<string,string>("ООД" , "OOD")} }; foreach (var type in organizationFmTypes) { NomValue row = new NomValue() { OldId = null, Code = type.Item2, Name = type.Item1, NameAlt = type.Item1, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["organizationKinds"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateGroundServiceOperatorActivityTypes(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("groundServiceOperatorActivityTypes"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "GAS" , new Tuple<string,string>("Наземно администриране и надзор" , "" )}, { "CS" , new Tuple<string,string>("Обслужване на пътници" , "" )}, { "BP" , new Tuple<string,string>("Обработка на багажи" , "" )}, { "CMP" , new Tuple<string,string>("Обработка на товари и поща" , "" )}, { "ACPS" , new Tuple<string,string>("Перонно обслужване на въздухоплавателни средства" , "" )}, { "ACS" , new Tuple<string,string>("Обслужване на въздухоплавателни средства" , "" )}, { "ACSFO" , new Tuple<string,string>("Обслужване на въздухоплавателни средства с горива и масла" , "" )}, { "ACTS" , new Tuple<string,string>("Техническо обслужване на въздухоплавателни средства" , "" )}, { "FOCA" , new Tuple<string,string>("Полетни операции и администриране на екипажите" , "" )}, { "GT" , new Tuple<string,string>("Наземен транспорт" , "" )}, { "BBS" , new Tuple<string,string>("Обслужване на бордния бюфет" , "" )} }; noms["groundServiceOperatorActivityTypes"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["groundServiceOperatorActivityTypes"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateEURegTypesFm(INomRepository repo, SqlConnection conn) { Nom nom = repo.GetNom("EURegTypesFm"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "EU" , new Tuple<string,string>("EU" , "EU" )}, { "EUR" , new Tuple<string,string>("EU - Restricted" , "EU - Restricted" )}, { "OD" , new Tuple<string,string>("Old Doc" , "Old Doc" )}, { "AN" , new Tuple<string,string>("Annex II" , "Annex II" )}, { "A2" , new Tuple<string,string>("Article-2" , "Article-2" )}, { "A1" , new Tuple<string,string>("Article-1" , "Article-1" )}, { "VLA" , new Tuple<string,string>("VLA" , "VLA" )}, { "AM" , new Tuple<string,string>("Amateur" , "Amateur" )}, { "EXP" , new Tuple<string,string>("EXP" , "EXP" )}, { "RU" , new Tuple<string,string>("RU" , "RU" )}, }; noms["EURegTypesFm"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["EURegTypesFm"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateEASATypesFm(INomRepository repo, SqlConnection conn) { Nom nom = repo.GetNom("EASATypesFm"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "BA" , new Tuple<string,string>("Balloon" , "Balloon" )}, { "CO" , new Tuple<string,string>("Commuter" , "Commuter" )}, { "EX" , new Tuple<string,string>("Experimental" , "Experimental" )}, { "GL" , new Tuple<string,string>("Glider" , "Glider" )}, { "GY" , new Tuple<string,string>("Gyroplane" , "Gyroplane" )}, { "LA" , new Tuple<string,string>("Large Aeroplane" , "Large Aeroplane" )}, { "MH" , new Tuple<string,string>("Motor-hanglider" , "Motor-hanglider" )}, { "PT" , new Tuple<string,string>("Paramotor-Trike" , "Paramotor-Trike" )}, { "RO" , new Tuple<string,string>("Rotorcraft" , "Rotorcraft" )}, { "SA" , new Tuple<string,string>("Small Aeroplane" , "Small Aeroplane" )}, { "SR" , new Tuple<string,string>("Small Rotorcraft" , "Small Rotorcraft" )}, { "VL" , new Tuple<string,string>("Very Light" , "Very Light" )}, { "VLA" , new Tuple<string,string>("Very Light Aeroplane" , "Very Light Aeroplane" )}, { "VLR" , new Tuple<string,string>("Very Light Rotorcraft" , "Very Light Rotorcraft" )} }; noms["EASATypesFm"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["EASATypesFm"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateEASACategoriesFm(INomRepository repo, SqlConnection conn) { Nom nom = repo.GetNom("EASACategoriesFm"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "AW" , new Tuple<string,string>("Aerial Work" , "Aerial Work" )}, { "COM" , new Tuple<string,string>("Commercial" , "Commercial" )}, { "COR" , new Tuple<string,string>("Corporate" , "Corporate" )}, { "PR" , new Tuple<string,string>("Private" , "Private" )}, { "VLA" , new Tuple<string,string>("VLA" , "VLA" )} }; noms["EASACategoriesFm"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["EASACategoriesFm"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private List<object> GetDocuments( PersonLicenceDO licence, NomValue licenceType, IEnumerable<PersonTrainingDO> includedTrainings, IEnumerable<PersonTrainingDO> includedExams, IEnumerable<PersonCheckDO> includedChecks) { if (licenceType.Code == "ATPA" || licenceType.Code == "CPA") { string[] documentRoleCodes; int[] documentRoleIds; bool hasRoles = LicenceDictionary.LicenceRole.TryGetValue(licenceType.Code, out documentRoleCodes); documentRoleIds = documentRoleCodes .Select(c => this.nomRepository.GetNomValues("documentRoles").Where(r => r.Code == c).SingleOrDefault().NomValueId) .ToArray(); if (!hasRoles) { return null; } NomValue theoreticalTrainingRole = this.nomRepository.GetNomValue("documentRoles", "theoreticalTraining"); NomValue theoreticalExamRole = this.nomRepository.GetNomValue("documentRoles", "exam"); NomValue simulatorRole = this.nomRepository.GetNomValue("documentRoles", "simulator"); NomValue flyingCheckRole = this.nomRepository.GetNomValue("documentRoles", "flyingCheck"); NomValue flyingTrainingRole = this.nomRepository.GetNomValue("documentRoles", "flyingTraining"); int validTrueId = this.nomRepository.GetNomValue("boolean", "yes").NomValueId; var theoreticalTrainings = Utils.GetTrainingsById(includedTrainings, theoreticalTrainingRole.NomValueId, documentRoleIds, this.nomRepository); var flyingTrainings = Utils.GetTrainingsById(includedTrainings, flyingTrainingRole.NomValueId, documentRoleIds, this.nomRepository); var exams = includedExams.Where(d => d.ValidId == validTrueId && documentRoleIds.Contains(d.DocumentRoleId.Value) && d.DocumentRoleId == theoreticalExamRole.NomValueId) .Select(t => new { DOC_TYPE = this.nomRepository.GetNomValue("documentTypes", t.DocumentTypeId.Value).Name.ToLower(), DOC_NO = t.DocumentNumber, DATE = t.DocumentDateValidFrom, DOC_PUBLISHER = t.DocumentPublisher }) .ToList<object>(); exams = Utils.FillBlankData(exams, 1); var simulators = Utils.FillBlankData(Utils.GetChecksById(includedChecks, simulatorRole.NomValueId, documentRoleIds, this.nomRepository), 1); var flyingChecks = Utils.FillBlankData(Utils.GetChecksById(includedChecks, flyingCheckRole.NomValueId, documentRoleIds, this.nomRepository), 1); var result = new List<object>() { new { DOC = new { DOC_ROLE = String.Format("{0}. {1}", number++, LicenceDictionary.DocumentTitle["TheoreticalTraining"]), SUB_DOC = Utils.FillBlankData(theoreticalTrainings, 1) } }, new { DOC = new { DOC_ROLE = String.Format("{0}. {1}", number++, LicenceDictionary.DocumentTitle["FlyingTraining"]), SUB_DOC = Utils.FillBlankData(flyingTrainings, 1) } }, new { DOC = new { DOC_ROLE = String.Format("{0}. {1}", number++, LicenceDictionary.DocumentTitle["TheoreticalExam"]), SUB_DOC = exams } }, new { DOC = new { DOC_ROLE = String.Format("{0}. {1}", number++, LicenceDictionary.DocumentTitle["FlyingCheck"]), SUB_DOC = flyingChecks } }, }; if (licenceType.Code == "ATPA") { result.Add(new { DOC = new { DOC_ROLE = String.Format("{0}. {1}", number++, LicenceDictionary.DocumentTitle["Simulator"]), SUB_DOC = simulators } }); } return result; } else { return new List<object>(); } }
private void migrateStaffTypes(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("staffTypes"); var aliases = new Dictionary<string, string>() { { "F", "flightCrew" }, { "T", "ovd"}, { "G", "to_vs"}, { "M", "to_suvd"} }; var results = conn.CreateStoreCommand(@"SELECT * FROM CAA_DOC.NM_STAFF_TYPE") .Materialize(r => new NomValue { OldId = r.Field<object>("ID").ToString(), Code = r.Field<string>("CODE"), Name = r.Field<string>("NAME"), NameAlt = r.Field<string>("NAME_TRANS"), ParentValueId = null, Alias = aliases[r.Field<string>("CODE")], TextContentString = JsonConvert.SerializeObject( new { codeCA = r.Field<string>("CA_CODE") }), IsActive = r.Field<string>("VALID_YN") == "Y" ? true : false }) .ToList(); noms["staffTypes"] = new Dictionary<string, NomValue>(); foreach (var row in results) { noms["staffTypes"][row.OldId] = row; nom.NomValues.Add(row); } Nom trainingStaffTypesNom = repo.GetNom("trainingStaffTypes"); var copiedResults = results.Select(v => new NomValue { OldId = v.OldId, Code = v.Code, Name = v.Name, NameAlt = v.NameAlt, ParentValueId = v.ParentValueId, Alias = v.Alias, TextContentString = v.TextContentString, IsActive = v.IsActive }); noms["trainingStaffTypes"] = new Dictionary<string, NomValue>(); foreach (var row in copiedResults) { noms["trainingStaffTypes"][row.OldId] = row; trainingStaffTypesNom.NomValues.Add(row); } NomValue generalDocument = new NomValue { NomValueId = 0, Name = "Общ документ", Alias = "general" }; noms["trainingStaffTypes"]["0"] = generalDocument; trainingStaffTypesNom.NomValues.Add(generalDocument); }
private void migrateAirportRelations(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("airportRelations"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "OW", new Tuple<string,string>("Собственик" , "Owner" )}, { "TN", new Tuple<string,string>("Наемател" , "Tenant" )}, { "OP", new Tuple<string,string>("Летищен оператор" , "Operator" )} }; noms["airportRelations"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["airportRelations"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateAirportOperatorActivityTypes(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("airportoperatorActivityTypes"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "OPINT" , new Tuple<string,string>("Летищен оператор на гражданско летище за обществено ползване за обслужване на международни превози" , "" )}, { "OPDOM" , new Tuple<string,string>("Летищен оператор на гражданско летище за обществено ползване за обслужване на вътрешни превози" , "" )}, { "OPOTH" , new Tuple<string,string>("Летищен оператор на гражданско летище за дейности, различни от вътрешни и международни превози" , "" )} }; noms["airportoperatorActivityTypes"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["airportoperatorActivityTypes"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateAircraftRadiotypes(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("aircraftRadioTypes"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "TRM" , new Tuple<string,string>("Предаватели" , "Transmitters" )}, { "ELT" , new Tuple<string,string>("Аварийни предаватели", "E L T" )}, { "TRS" , new Tuple<string,string>("Транспондер" , "Transponders" )}, { "WR" , new Tuple<string,string>("Метео радар" , "Weather radar" )}, { "TCAS", new Tuple<string,string>("ТКАС" , "TCAS" )}, { "DME" , new Tuple<string,string>("ДМЕ" , "DME" )}, { "RA" , new Tuple<string,string>("Висотомер" , "Radio Altimeter" )}, { "Otr" , new Tuple<string,string>("Друг" , "Other" )} }; noms["aircraftRadioTypes"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["aircraftRadioTypes"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private List<object> GetExams( IEnumerable<PersonTrainingDO> includedExams, IEnumerable<PersonCheckDO> includedChecks, NomValue practicalCheckRole) { var exams = includedExams .Select(t => new { CLASS = t.RatingTypes.Count() > 0 ? string.Join(", ", t.RatingTypes.Select(rt => this.nomRepository.GetNomValue("ratingTypes", rt).Code)) : "", DOC_NO = t.DocumentNumber, DATE = t.DocumentDateValidFrom }) .ToList<object>(); var checks = includedChecks.Where(d => d.DocumentRoleId == practicalCheckRole.NomValueId) .Select(t => new { CLASS = t.RatingTypes.Count() > 0 ? string.Join(", ", t.RatingTypes.Select(rt => this.nomRepository.GetNomValue("ratingTypes", rt).Code)) : "", DOC_NO = t.DocumentNumber, DATE = t.DocumentDateValidFrom }) .ToList<object>(); return Utils.FillBlankData(exams.Union(checks).ToList<object>(), 4); }
internal static List<object> GetRatingsDataByCode( IEnumerable<PartVersion<PersonRatingDO>> includedRatings, IEnumerable<PartVersion<PersonRatingEditionDO>> ratingEditions, NomValue authorizationGroup, INomRepository nomRepository) { List<object> ratings = new List<object>(); foreach (var edition in ratingEditions) { var rating = includedRatings.Where(r => r.Part.Index == edition.Content.RatingPartIndex).Single(); if (rating.Content.AuthorizationId.HasValue) { NomValue authorization = nomRepository.GetNomValue("authorizations", rating.Content.AuthorizationId.Value); if (authorization.ParentValueId != null && authorizationGroup.NomValueId == authorization.ParentValueId.Value && authorization.Code != "RTO") { ratings.Add(new { TYPE = string.Format( "{0} {1} {2}", rating.Content.RatingClassId.HasValue ? nomRepository.GetNomValue("ratingClasses", rating.Content.RatingClassId.Value).Name : string.Empty, rating.Content.RatingTypes.Count() > 0 ? string.Join(", ", nomRepository.GetNomValues("ratingTypes", rating.Content.RatingTypes.ToArray()).Select(rt => rt.Code)) : "", authorization == null ? string.Empty : authorization.Code).Trim(), AUTH_NOTES = string.Format("{0}", edition.Content.NotesAlt).Trim(), VALID_DATE = edition.Content.DocumentDateValidTo }); } } } return ratings; }
public void StartMigrating( //input constants Dictionary<string, Dictionary<string, NomValue>> noms, Dictionary<string, int> aircraftFmIdtoLotId, Func<int?, JObject> getPersonByApexId, Func<string, JObject> getPersonByFmOrgName, Func<string, JObject> getOrgByFmOrgName, //intput ConcurrentQueue<string> aircraftFmIds, //output ConcurrentDictionary<string, int> regMarkToLotId, //cancellation CancellationTokenSource cts, CancellationToken ct) { try { this.sqlConn.Open(); } catch (Exception) { cts.Cancel(); throw; } Dictionary<string, int> inspectorsFM = new Dictionary<string, int>() { {"Стар запис" , -1},//TODO {"А.Борисов" , 6203}, {"А.Станков" , 1149}, {"Б.Божинов" , -1},//TODO {"В.Василев" , -1}, {"В.Драганов" , 5464}, {"В.Дяков" , 3897}, {"В.Михайлов" , 2666}, {"В.Наньов" , 6023}, {"В.Пешев" , 2606}, {"В.Текнеджиев" , 2219}, {"Г.Илчов" , -1},//TODO {"Г.Андонов" , 4028}, {"Г.Андонов ARS 02" , 4028}, {"Е.Крайкова" , 7328}, {"И.Банковски" , 5466}, {"И.Иванов" , -1},//TODO {"И.Коев" , 5468}, {"И.Найденов" , -1},//TODO {"И.С.Иванов" , 3491}, {"Ив.Иванов" , 2590}, {"Ил.Иванов" , 1087}, {"К.Гълъбов" , 4162}, {"М.Илов" , 9184}, {"М.Митов" , -1},//TODO {"Н. Начев" , 1150}, {"Н.Василев" , 5463}, {"Н.Джамбов" , 2286}, {"Н.Начев" , 1150}, {"Н.Тотева" , 7737}, {"П.МЛАДЕНОВ" , -1},//TODO {"П.Юнашкова" , 2349}, {"С.Живков" , 2396}, {"С.Пенчев" , 803}, {"С.Тодоров" , 5465}, {"Т.Вълков" , 5467}, {"Ю.Иванчев" , -1}, {"В.Димитров" , -1} }; string aircraftFmId; while (aircraftFmIds.TryDequeue(out aircraftFmId)) { ct.ThrowIfCancellationRequested(); try { using (var dependencies = dependencyFactory()) { var unitOfWork = dependencies.Value.Item1; var lotRepository = dependencies.Value.Item2; var userRepository = dependencies.Value.Item3; var fileRepository = dependencies.Value.Item4; var applicationRepository = dependencies.Value.Item5; var personRepository = dependencies.Value.Item6; var organizationRepository = dependencies.Value.Item7; var lotEventDispatcher = dependencies.Value.Item9; var context = dependencies.Value.Item10; var lot = lotRepository.GetLotIndex(aircraftFmIdtoLotId[aircraftFmId], fullAccess: true); Func<string, bool, JObject> getInspectorImpl = (tRegUser, showErrorIfMissing) => { if (string.IsNullOrWhiteSpace(tRegUser)) { return null; } if (!inspectorsFM.ContainsKey(tRegUser)) { if (showErrorIfMissing) { Console.WriteLine("CANNOT FIND INSPECTOR {0}", tRegUser);//TODO } return null; } int personId = inspectorsFM[tRegUser]; if (personId == -1) { Console.WriteLine("INSPECTOR {0} IS NOT MAPPED TO PERSONID", tRegUser);//TODO return null; } return getPersonByApexId(personId); }; Func<string, JObject> getInspectorOrDefault = (tRegUser) => getInspectorImpl(tRegUser, false); Func<string, JObject> getInspectorOrOther = (tRegUser) => { JObject inspector = null; string other = null; if (!string.IsNullOrEmpty(tRegUser)) { JObject person = getInspectorOrDefault(tRegUser); if (person == null) { other = tRegUser; } else { inspector = person; } } return Utils.ToJObject( new { inspector, examiner = (JObject)null, other }); }; Func<string, JObject, PartVersion> addPartWithFiles = (path, content) => { var pv = lot.CreatePart(path, content.Get<JObject>("part"), context); fileRepository.AddFileReferences(pv.Part, content.GetItems<CaseDO>("files")); return pv; }; if (!aircraftFmIdtoLotId.ContainsKey(aircraftFmId)) { //TODO remove, those are the ones with duplicate MSN skipped earlier continue; } var aircraftCertNoiseFM = this.getAircraftCertNoiseFM(aircraftFmId, noms); if (aircraftCertNoiseFM != null) { addPartWithFiles("aircraftCertNoises/*", aircraftCertNoiseFM); } Dictionary<int, Tuple<string, NomValue>> registrations = new Dictionary<int, Tuple<string, NomValue>>(); var aircraftCertRegistrationsFM = this.getAircraftCertRegistrationsFM(aircraftFmId, noms, getInspectorOrOther, getPersonByFmOrgName, getOrgByFmOrgName); foreach (var aircraftCertRegistrationFM in aircraftCertRegistrationsFM) { var pv = addPartWithFiles("aircraftCertRegistrationsFM/*", aircraftCertRegistrationFM); int? certNumber = aircraftCertRegistrationFM.Get<int?>("part.certNumber"); int? actNumber = aircraftCertRegistrationFM.Get<int?>("part.actNumber"); string regMark = aircraftCertRegistrationFM.Get<string>("part.regMark"); var registration = new NomValue() { NomValueId = pv.Part.Index, Name = string.Format( regMark + (certNumber.HasValue ? string.Format("/рег.№ {0}", certNumber.ToString()) : string.Empty) + (actNumber.HasValue ? string.Format("/дел.№ {0}", actNumber.ToString()) : string.Empty)) }; if (!string.IsNullOrEmpty(regMark) && !regMarkToLotId.ContainsKey(regMark)) { regMarkToLotId.TryAdd(regMark, lot.LotId); } string registerCode = aircraftCertRegistrationFM.Get<string>("part.register.code"); int certId = aircraftCertRegistrationFM.Get<int>("part.__oldId"); if (!registrations.ContainsKey(certId)) { registrations.Add(certId, new Tuple<string, NomValue>(registerCode, registration)); } } var aircraftCertAirworthinessesFM = this.getAircraftCertAirworthinessFM(aircraftFmId, registrations, noms, getInspectorOrOther, getInspectorOrDefault); foreach (var aircraftCertAirworthinessFM in aircraftCertAirworthinessesFM) { addPartWithFiles("aircraftCertAirworthinessesFM/*", aircraftCertAirworthinessFM); } var aircraftDocumentDebtsFM = this.getAircraftDocumentDebtsFM(aircraftFmId, noms, getInspectorOrOther); foreach (var aircraftDocumentDebtFM in aircraftDocumentDebtsFM) { try { addPartWithFiles("aircraftDocumentDebtsFM/*", aircraftDocumentDebtFM); } catch (Exception e) { Console.WriteLine("ERROR CREATEPART AIRCRAFTDOCUMENTDEBTSFM {0}", e.Message);//TODO throw e; } } try { lot.Commit(context, lotEventDispatcher); } // ignore empty commit exceptions catch (InvalidOperationException) { } unitOfWork.Save(); Console.WriteLine("Migrated FM aircraftId: {0}", aircraftFmId); } } catch (Exception) { Console.WriteLine("Error in FM aircraftId: {0}", aircraftFmId); cts.Cancel(); throw; } } }
private void migratePersonCheckRatingValues(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("personCheckRatingValues"); var nomInfo = new Dictionary<string, Tuple<string, string, bool>>() { { "G", new Tuple<string,string, bool>("Добро" , "Good" , true)}, { "S", new Tuple<string,string, bool>("Задоволително" , "Satisfactory" , true)}, { "I", new Tuple<string,string, bool>("Недостатъчно" , "Insufficient" , true)}, { "U", new Tuple<string,string, bool>("Неприемливо" , "Unacceptable" , true)}, { "К", new Tuple<string,string, bool>("Компетентен" , "Competent" , true)}, { "Н", new Tuple<string,string, bool>("Некомпетентен" , "Incompetent" , true)}, { "C", new Tuple<string,string, bool>("C" , "C" , false)} }; noms["personCheckRatingValues"] = new Dictionary<string, NomValue>(); int order = 0; foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = ni.Value.Item3, ParentValueId = null, TextContentString = null, Order = order++ }; noms["personCheckRatingValues"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateAirportTypes(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("airportTypes"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "IA", new Tuple<string,string>("Международно летище" , "International airport" )}, { "MA", new Tuple<string,string>("Военно летище" , "Military airport" )}, { "AF", new Tuple<string,string>("Летателна площадка" , "Airfield" )} }; noms["airportTypes"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["airportTypes"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migratePersonRatingModels(INomRepository repo, OracleConnection conn) { Nom nom = repo.GetNom("personRatingModels"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "P", new Tuple<string,string>("Постоянно" , "Permanently" )}, { "T", new Tuple<string,string>("Временно" , "Temporarily" )} }; noms["personRatingModels"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["personRatingModels"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateCofATypesFm(INomRepository repo, SqlConnection conn) { Nom nom = repo.GetNom("CofATypesFm"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { { "E25", new Tuple<string,string>("EASA 25" , "EASA 25" )}, { "E24", new Tuple<string,string>("EASA 24" , "EASA 24" )}, { "BGF", new Tuple<string,string>("BG Form" , "BG Form" )}, { "TEC", new Tuple<string,string>("Tech Cert" , "Tech Cert" )}, { "EXP", new Tuple<string,string>("EXP" , "EXP" )}, { "EA" , new Tuple<string,string>("EASA" , "EASA" )}, { "OBF", new Tuple<string,string>("Old BG Form" , "Old BG Form" )} }; noms["CofATypesFm"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["CofATypesFm"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
private void migrateAircraftDebtTypesFm(INomRepository repo, SqlConnection conn) { Nom nom = repo.GetNom("aircraftDebtTypesFm"); var nomInfo = new Dictionary<string, Tuple<string, string>>() { {"PLE" , new Tuple<string,string>("ЗАЛОГ" , "Pledge" )}, {"DASS", new Tuple<string,string>("ЗАПОР" , "Distraint" )} }; noms["aircraftDebtTypesFm"] = new Dictionary<string, NomValue>(); foreach (var ni in nomInfo) { NomValue row = new NomValue() { OldId = null, Code = ni.Key, Name = ni.Value.Item1, NameAlt = ni.Value.Item2, Alias = null, IsActive = true, ParentValueId = null, TextContentString = null }; noms["aircraftDebtTypesFm"][Guid.NewGuid().ToString()] = row; nom.NomValues.Add(row); } }
public void UpdateLotCaseTypes(string set, GvaCaseType caseType, Lot lot, UserContext userContext) { Part updatedPart = null; if (set == "Person") { PersonDataDO personData = lot.Index.GetPart<PersonDataDO>("personData").Content; personData.CaseTypes.Add(caseType.GvaCaseTypeId); this.caseTypeRepository.AddCaseTypes(lot, personData.CaseTypes); updatedPart = lot.UpdatePart("personData", personData, userContext).Part; } else if (set == "Organization") { NomValue caseTypeNom = new NomValue() { NomValueId = caseType.GvaCaseTypeId, Name = caseType.Name, Alias = caseType.Alias }; OrganizationDataDO organizationData = lot.Index.GetPart<OrganizationDataDO>("organizationData").Content; organizationData.CaseTypes.Add(caseTypeNom); this.caseTypeRepository.AddCaseTypes(lot, organizationData.CaseTypes.Select(ct => ct.NomValueId)); updatedPart = lot.UpdatePart("organizationData", organizationData, userContext).Part; } lot.Commit(userContext, this.lotEventDispatcher); this.unitOfWork.Save(); this.lotRepository.ExecSpSetLotPartTokens(updatedPart.PartId); }