public ApplicationNomDO(GvaApplication application) { this.ApplicationId = application.GvaApplicationId; if (application.GvaAppLotPartId != null) { var appContent = application.GvaViewApplication; if (!string.IsNullOrEmpty(appContent.OldDocumentNumber)) { this.ApplicationName = string.Format("{0} {1}/{2:dd.MM.yyyy}", appContent.ApplicationType.Code, appContent.OldDocumentNumber, appContent.DocumentDate); this.ApplicationDate = appContent.DocumentDate; } else { this.ApplicationName = string.Format("{0} {1}", appContent.ApplicationType.Code, application.Doc.RegUri); this.ApplicationDate = application.Doc.RegDate; } } else { this.ApplicationName = application.Doc.RegUri; this.ApplicationDate = application.Doc.RegDate; } }
public ApplicationDO(GvaApplication application, string lotSetAlias) : base(application) { this.DocId = application.DocId; this.LotId = application.LotId; this.PartIndex = application.GvaAppLotPart != null ? (int?)application.GvaAppLotPart.Index : null; this.LotSetAlias = lotSetAlias.ToLowerInvariant(); this.ApplicationType = application.GvaViewApplication != null ? application.GvaViewApplication.ApplicationType : null; this.AppDocCase = new List<ApplicationDocRelationDO>(); this.AppFilesNotInCase = new List<ApplicationLotFileDO>(); }
public void StartMigrating( //input constants Dictionary<string, Dictionary<string, NomValue>> noms, Dictionary<int, int> personIdToLotId, Func<int?, JObject> getAircraftByApexId, Func<int?, JObject> getPersonByApexId, Func<int?, JObject> getOrgByApexId, Dictionary<int, string> blobIdsToFileKeys, //intput ConcurrentQueue<int> personIds, //cancellation CancellationTokenSource cts, CancellationToken ct) { try { this.oracleConn.Open(); } catch (Exception) { cts.Cancel(); throw; } int personId; while (personIds.TryDequeue(out personId)) { ct.ThrowIfCancellationRequested(); try { using (var dependencies = this.dependencyFactory()) { var unitOfWork = dependencies.Value.Item1; var lotRepository = dependencies.Value.Item2; var fileRepository = dependencies.Value.Item3; var applicationRepository = dependencies.Value.Item4; var lotEventDispatcher = dependencies.Value.Item5; var context = dependencies.Value.Item6; var lot = lotRepository.GetLotIndex(personIdToLotId[personId], fullAccess: true); Func<string, JObject, PartVersion<JObject>> addPartWithFiles = (path, content) => { var pv = lot.CreatePart(path, content.Get<JObject>("part"), context); fileRepository.AddFileReferences(pv.Part, content.GetItems<CaseDO>("files")); return pv; }; Dictionary<int, string> appApexIdToStaffTypeCode = getPersonApplicationsStaffTypeCodes(personId); Dictionary<int, Tuple<GvaApplication, ApplicationNomDO>> applications = new Dictionary<int, Tuple<GvaApplication, ApplicationNomDO>>(); var personDocumentApplications = this.getPersonDocumentApplications(personId, noms, appApexIdToStaffTypeCode, blobIdsToFileKeys); foreach (var docApplication in personDocumentApplications) { var pv = addPartWithFiles("personDocumentApplications/*", docApplication); GvaApplication application = new GvaApplication() { Lot = lot, GvaAppLotPart = pv.Part }; applicationRepository.AddGvaApplication(application); string typeCode = docApplication.Get<string>("part.applicationType.code"); string oldDocumentNumber = docApplication.Get<string>("part.oldDocumentNumber"); DateTime? documentDate = docApplication.Get<DateTime?>("part.documentDate"); ApplicationNomDO applicationNom = new ApplicationNomDO() { ApplicationId = 0, ApplicationName = string.Format("{0} {1}/{2:dd.MM.yyyy}", typeCode, oldDocumentNumber, documentDate), ApplicationDate = documentDate }; applications.Add( docApplication.Get<int>("part.__oldId"), Tuple.Create(application, applicationNom)); } unitOfWork.Save(); Dictionary<int, JObject> nomApplications = new Dictionary<int, JObject>(); foreach (var app in applications) { var gvaApp = app.Value.Item1; var appNomDO = app.Value.Item2; appNomDO.ApplicationId = gvaApp.GvaApplicationId; nomApplications.Add( app.Key, Utils.ToJObject(appNomDO)); IList<GvaApplicationStage> appStages = CommonUtils.GetApplicationStages(this.oracleConn, personIdToLotId, appNomDO.ApplicationId, app.Key); foreach (GvaApplicationStage stage in appStages) { unitOfWork.DbContext.Set<GvaApplicationStage>().Add(stage); } } var personDocuments = this.getPersonDocuments(personId, nomApplications, noms, appApexIdToStaffTypeCode, blobIdsToFileKeys); Dictionary<int, int> trainingOldIdToPartIndex = new Dictionary<int, int>(); Dictionary<int, int> langCertOldIdToPartIndex = new Dictionary<int, int>(); Dictionary<int, int> examOldIdToPartIndex = new Dictionary<int, int>(); Dictionary<int, int> checkOldIdToPartIndex = new Dictionary<int, int>(); foreach (var personDocument in personDocuments) { if ((new string[] { "3", "4", "5" }).Contains(personDocument.Get<string>("part.__DOCUMENT_TYPE_CODE")) && personDocument.Get<string>("part.__DOCUMENT_ROLE_CODE") == "2") { Utils.Pluck(personDocument.Get<JObject>("part"), new string[] { "__oldId", "__migrTable", "documentType", "documentNumber", "documentDateValidFrom", "documentDateValidTo", "documentPublisher", "valid", "notes" }); addPartWithFiles("personDocumentIds/*", personDocument); } else if (!(new string[] { "3", "4", "5" }).Contains(personDocument.Get<string>("part.__DOCUMENT_TYPE_CODE")) && personDocument.Get<string>("part.__DOCUMENT_ROLE_CATEGORY_CODE") == "T") { Utils.Pluck(personDocument.Get<JObject>("part"), new string[] { "__oldId", "__migrTable", "documentNumber", "documentPersonNumber", "documentDateValidFrom", "documentDateValidTo", "documentPublisher", "ratingTypes", "aircraftTypeGroup", "ratingClass", "authorization", "licenceType", "locationIndicator", "sector", "personCheckRatingValue", "documentType", "documentRole", "valid", "notes" }); var pv = addPartWithFiles("personDocumentChecks/*", personDocument); checkOldIdToPartIndex.Add(personDocument.Get<int>("part.__oldId"), pv.Part.Index); } else if (!(new string[] { "3", "4", "5" }).Contains(personDocument.Get<string>("part.__DOCUMENT_TYPE_CODE")) && personDocument.Get<string>("part.__DOCUMENT_ROLE_CATEGORY_CODE") == "O" && (personDocument.Get<string>("part.__DOCUMENT_ROLE_CODE") == "ENG" || personDocument.Get<string>("part.__DOCUMENT_ROLE_CODE") == "BG")) { Utils.Pluck(personDocument.Get<JObject>("part"), new string[] { "__oldId", "__migrTable", "documentNumber", "documentPersonNumber", "documentDateValidFrom", "documentDateValidTo", "documentPublisher", "ratingTypes", "aircraftTypeGroup", "ratingClass", "authorization", "licenceType", "locationIndicator", "sector", "langLevel", "langLevelEntries", "documentType", "documentRole", "valid", "notes", }); var pv = addPartWithFiles("personDocumentLangCertificates/*", personDocument); langCertOldIdToPartIndex.Add(personDocument.Get<int>("part.__oldId"), pv.Part.Index); } else if (!(new string[] { "3", "4", "5" }).Contains(personDocument.Get<string>("part.__DOCUMENT_TYPE_CODE")) && personDocument.Get<string>("part.__DOCUMENT_ROLE_CATEGORY_CODE") == "O" && personDocument.Get<string>("part.__DOCUMENT_ROLE_CODE") == "6") { Utils.Pluck(personDocument.Get<JObject>("part"), new string[] { "__oldId", "__migrTable", "documentNumber", "documentPersonNumber", "documentDateValidFrom", "documentDateValidTo", "documentPublisher", "documentType", "documentRole", "valid", "notes", }); var pv = addPartWithFiles("personDocumentTrainings/*", personDocument); examOldIdToPartIndex.Add(personDocument.Get<int>("part.__oldId"), pv.Part.Index); } else if (!(new string[] { "3", "4", "5" }).Contains(personDocument.Get<string>("part.__DOCUMENT_TYPE_CODE")) && personDocument.Get<string>("part.__DOCUMENT_ROLE_CATEGORY_CODE") == "O") { Utils.Pluck(personDocument.Get<JObject>("part"), new string[] { "__oldId", "__migrTable", "documentNumber", "documentPersonNumber", "documentDateValidFrom", "documentDateValidTo", "documentPublisher", "ratingTypes", "aircraftTypeGroup", "ratingClass", "authorization", "licenceType", "locationIndicator", "sector", "documentType", "documentRole", "valid", "notes", }); var pv = addPartWithFiles("personDocumentTrainings/*", personDocument); trainingOldIdToPartIndex.Add(personDocument.Get<int>("part.__oldId"), pv.Part.Index); } else { Utils.Pluck(personDocument.Get<JObject>("part"), new string[] { "__oldId", "__migrTable", "documentNumber", "documentPersonNumber", "documentDateValidFrom", "documentDateValidTo", "documentPublisher ", "documentType", "documentRole", "valid", "notes", }); addPartWithFiles("personDocumentOthers/*", personDocument); } } var personAddresses = this.getPersonAddresses(personId, noms); foreach (var address in personAddresses) { addPartWithFiles("personAddresses/*", address); } var personDocumentEducations = this.getPersonDocumentEducations(personId, nomApplications, noms, appApexIdToStaffTypeCode, blobIdsToFileKeys); foreach (var docEducation in personDocumentEducations) { addPartWithFiles("personDocumentEducations/*", docEducation); } var personDocumentEmployments = this.getPersonDocumentEmployments(personId, noms, getOrgByApexId, blobIdsToFileKeys); Dictionary<int, PartVersion<JObject>> employmentsByOldId = new Dictionary<int, PartVersion<JObject>>(); foreach (var docEmployment in personDocumentEmployments) { var pv = addPartWithFiles("personDocumentEmployments/*", docEmployment); employmentsByOldId.Add(docEmployment.Get<int>("part.__oldId"), pv); } var personDocumentMedicals = this.getPersonDocumentMedicals(personId, nomApplications, noms, appApexIdToStaffTypeCode, blobIdsToFileKeys); Dictionary<int, int> medicalOldIdToPartIndex = new Dictionary<int, int>(); foreach (var docMedical in personDocumentMedicals) { var pv = addPartWithFiles("personDocumentMedicals/*", docMedical); medicalOldIdToPartIndex.Add(docMedical.Get<int>("part.__oldId"), pv.Part.Index); } var personFlyingExperiences = this.getPersonFlyingExperiences(personId, noms, getOrgByApexId, getAircraftByApexId); foreach (var flyingExperience in personFlyingExperiences) { addPartWithFiles("personFlyingExperiences/*", flyingExperience); } var personStatuses = this.getPersonStatuses(personId, noms); foreach (var personStatus in personStatuses) { addPartWithFiles("personStatuses/*", personStatus); } var personRatingEditions = this.getPersonRatingEditions(personId, getPersonByApexId, noms, nomApplications); var personRatings = this.getPersonRatings(personId, noms); Dictionary<int, JObject> ratingEditionOldIdToPartIndex = new Dictionary<int, JObject>(); foreach (var personRating in personRatings) { var ratingPartVersion = addPartWithFiles("ratings/*", personRating); int nextIndex = 0; foreach (var edition in personRatingEditions[personRating.Get<int>("part.__oldId")]) { var editionPart = edition["part"] as JObject; editionPart.Add("ratingPartIndex", ratingPartVersion.Part.Index); editionPart.Add("index", nextIndex); nextIndex++; var editionPartVersion = addPartWithFiles("ratingEditions/*", edition); ratingEditionOldIdToPartIndex.Add(edition.Get<int>("part.__oldId"), new JObject() { new JProperty("ind", ratingPartVersion.Part.Index), new JProperty("index", editionPartVersion.Part.Index) }); } } var personLicenceEditions = this.getPersonLicenceEditions(personId, getPersonByApexId, nomApplications, noms, ratingEditionOldIdToPartIndex, medicalOldIdToPartIndex, trainingOldIdToPartIndex, langCertOldIdToPartIndex, examOldIdToPartIndex, checkOldIdToPartIndex); var personLicences = this.getPersonLicences(personId, getPersonByApexId, noms, employmentsByOldId); Dictionary<int, int> licenceOldIdToPartIndex = new Dictionary<int, int>(); foreach (var personLicence in personLicences) { var licencePartVersion = addPartWithFiles("licences/*", personLicence); int nextIndex = 0; foreach (var edition in personLicenceEditions[personLicence.Get<int>("part.__oldId")]) { var editionPart = edition["part"] as JObject; editionPart.Add("licencePartIndex", licencePartVersion.Part.Index); editionPart.Add("index", nextIndex); nextIndex++; var editionPartVersion = addPartWithFiles("licenceEditions/*", edition); } licenceOldIdToPartIndex.Add(personLicence.Get<int>("part.__oldId"), licencePartVersion.Part.Index); } //replace included licence ids with part indexes foreach (var personLicence in personLicences) { foreach (var edition in personLicenceEditions[personLicence.Get<int>("part.__oldId")]) { var editionPart = edition["part"] as JObject; editionPart.Property("includedLicences").Value = new JArray(edition.GetItems<int>("includedLicences").Select(l => licenceOldIdToPartIndex[l]).ToArray()); } } var examSystPart = this.GetQualificationStates(personId, noms); if(examSystPart != null) { addPartWithFiles("personExamSystData", examSystPart); } try { lot.Commit(context, lotEventDispatcher); } //swallow the Cannot commit without modifications exception catch (InvalidOperationException) { } unitOfWork.Save(); Console.WriteLine("Migrated personId: {0}", personId); } } catch (Exception) { Console.WriteLine("Error in personId: {0}", personId); cts.Cancel(); throw; } } }
public void StartMigrating( //input constants Dictionary<string, Dictionary<string, NomValue>> noms, Dictionary<int, int> personIdToLotId, Dictionary<int, int> orgApexIdToLotId, Func<int?, JObject> getAircraftByApexId, Func<int?, JObject> getPersonByApexId, Dictionary<int, string> blobIdsToFileKeys, //intput ConcurrentQueue<int> organizationIds, //cancellation CancellationTokenSource cts, CancellationToken ct) { try { this.oracleConn.Open(); } catch (Exception) { cts.Cancel(); throw; } int organizationId; while (organizationIds.TryDequeue(out organizationId)) { ct.ThrowIfCancellationRequested(); try { using (var dependencies = this.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 aircraftRepository = dependencies.Value.Item7; var lotEventDispatcher = dependencies.Value.Item8; var caseTypeRepository = dependencies.Value.Item9; var context = dependencies.Value.Item10; var lot = lotRepository.GetLotIndex(orgApexIdToLotId[organizationId], fullAccess: true); bool isApprovedOrg = this.getIsApprovedOrg(organizationId); 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; }; Dictionary<int, Tuple<GvaApplication, ApplicationNomDO>> applications = new Dictionary<int, Tuple<GvaApplication, ApplicationNomDO>>(); var organizationDocumentApplications = this.getOrganizationDocumentApplications(organizationId, noms, blobIdsToFileKeys, isApprovedOrg); foreach (var organizationDocumentApplication in organizationDocumentApplications) { var pv = addPartWithFiles("organizationDocumentApplications/*", organizationDocumentApplication); GvaApplication application = new GvaApplication() { Lot = lot, GvaAppLotPart = pv.Part }; applicationRepository.AddGvaApplication(application); string typeCode = organizationDocumentApplication.Get<string>("part.applicationType.code"); string oldDocumentNumber = organizationDocumentApplication.Get<string>("part.oldDocumentNumber"); DateTime? documentDate = organizationDocumentApplication.Get<DateTime?>("part.documentDate"); ApplicationNomDO applicationNom = new ApplicationNomDO() { ApplicationId = 0, ApplicationName = string.Format("{0} {1}/{2:dd.MM.yyyy}", typeCode, oldDocumentNumber, documentDate), ApplicationDate = documentDate }; applications.Add( organizationDocumentApplication.Get<int>("part.__oldId"), Tuple.Create(application, applicationNom)); } unitOfWork.Save(); Dictionary<int, JObject> nomApplications = new Dictionary<int, JObject>(); foreach (var app in applications) { var gvaApp = app.Value.Item1; var appNomDO = app.Value.Item2; appNomDO.ApplicationId = gvaApp.GvaApplicationId; nomApplications.Add( app.Key, Utils.ToJObject(appNomDO)); IList<GvaApplicationStage> appStages = CommonUtils.GetApplicationStages(this.oracleConn, personIdToLotId, appNomDO.ApplicationId, app.Key); foreach (GvaApplicationStage stage in appStages) { unitOfWork.DbContext.Set<GvaApplicationStage>().Add(stage); } } Dictionary<int, int> inspectionPartIndexes = new Dictionary<int, int>(); var organizationInspections = this.getOrganizationInspections(organizationId, nomApplications, getPersonByApexId, blobIdsToFileKeys, noms); foreach (var organizationInspection in organizationInspections) { var pv = addPartWithFiles("organizationInspections/*", organizationInspection); inspectionPartIndexes.Add(organizationInspection.Get<int>("part.__oldId"), pv.Part.Index); } var organizationAddresses = this.getOrganizationAddress(organizationId, noms); foreach (var organizationAddress in organizationAddresses) { addPartWithFiles("organizationAddresses/*", organizationAddress); } Dictionary<int, PartVersion> organizationDocuments = new Dictionary<int, PartVersion>(); var organizationDocumentOthers = this.getOrganizationDocumentOthers(organizationId, nomApplications, noms, blobIdsToFileKeys, isApprovedOrg); foreach (var organizationDocumentOther in organizationDocumentOthers) { var pv = addPartWithFiles("organizationDocumentOthers/*", organizationDocumentOther); organizationDocuments.Add(organizationDocumentOther["part"]["__oldId"].Value<int>(), pv); } var organizationApprovalAmendments = this.getOrganizationApprovalAmendments(organizationId, noms, organizationDocuments, getPersonByApexId, nomApplications, isApprovedOrg); var organizationApprovals = this.getOrganizationApproval(organizationId, noms, isApprovedOrg); foreach (var organizationApproval in organizationApprovals) { var approvalPartVersion = addPartWithFiles("approvals/*", organizationApproval); int nextIndex = 0; foreach (var amendment in organizationApprovalAmendments[organizationApproval.Get<int>("part.__oldId")] .OrderBy(a => a.Get<int>("part.changeNum"))) { var amendmentPart = amendment["part"] as JObject; amendmentPart.Add("approvalPartIndex", approvalPartVersion.Part.Index); amendmentPart.Add("index", nextIndex); nextIndex++; var amendmentPartVersion = addPartWithFiles("approvalAmendments/*", amendment); } } var organizationRecommendations = this.getOrganizationRecommendation(organizationId, getPersonByApexId, nomApplications, noms, inspectionPartIndexes); foreach (var organizationRecommendation in organizationRecommendations) { addPartWithFiles("organizationRecommendations/*", organizationRecommendation); } var organizationManagementStaffs = this.getOrganizationManagementStaff(organizationId, nomApplications, noms, getPersonByApexId, isApprovedOrg); foreach (var organizationManagementStaff in organizationManagementStaffs) { addPartWithFiles("organizationStaffManagement/*", organizationManagementStaff); } var organizationAwExaminers = this.getOrganizationAwExaminers(organizationId, noms, getPersonByApexId); foreach (var organizationAwExaminer in organizationAwExaminers) { if (organizationAwExaminer.Get<int?>("part.person.nomValueId") == null) { Console.WriteLine("CANNOT FIND PERSON FOR organizationStaffExaminer WITH oldId " + organizationAwExaminer.Get<int>("part.__oldId")); continue; } addPartWithFiles("organizationAwExaminers/*", organizationAwExaminer); } try { lot.Commit(context, lotEventDispatcher); } //swallow the Cannot commit without modifications exception catch (InvalidOperationException) { } unitOfWork.Save(); Console.WriteLine("Migrated organizationId: {0}", organizationId); } } catch (Exception) { Console.WriteLine("Error in organizationId: {0}", organizationId); cts.Cancel(); throw; } } }
public void StartMigrating( //input constants Dictionary<string, Dictionary<string, NomValue>> noms, Dictionary<int, int> personIdToLotId, Dictionary<int, int> aircraftApexIdtoLotId, Func<int?, JObject> getPersonByApexId, Func<int?, JObject> getOrgByApexId, Dictionary<int, string> blobIdsToFileKeys, //intput ConcurrentQueue<int> aircraftApexIds, //cancellation CancellationTokenSource cts, CancellationToken ct) { try { this.oracleConn.Open(); } catch (Exception) { cts.Cancel(); throw; } int aircraftApexId; while (aircraftApexIds.TryDequeue(out aircraftApexId)) { 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; int lotId; if (!aircraftApexIdtoLotId.TryGetValue(aircraftApexId, out lotId)) { continue; } var lot = lotRepository.GetLotIndex(lotId, fullAccess: true); 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; }; Dictionary<int, Tuple<GvaApplication, ApplicationNomDO>> applications = new Dictionary<int, Tuple<GvaApplication, ApplicationNomDO>>(); var aircraftDocumentApplications = this.getAircraftDocumentApplications(aircraftApexId, noms, blobIdsToFileKeys); foreach (var aircraftDocumentApplication in aircraftDocumentApplications) { var pv = addPartWithFiles("aircraftDocumentApplications/*", aircraftDocumentApplication); GvaApplication application = new GvaApplication() { Lot = lot, GvaAppLotPart = pv.Part }; applicationRepository.AddGvaApplication(application); string typeCode = aircraftDocumentApplication.Get<string>("part.applicationType.code"); string oldDocumentNumber = aircraftDocumentApplication.Get<string>("part.oldDocumentNumber"); DateTime? documentDate = aircraftDocumentApplication.Get<DateTime?>("part.documentDate"); ApplicationNomDO applicationNom = new ApplicationNomDO() { ApplicationId = 0, ApplicationName = string.Format("{0} {1}/{2:dd.MM.yyyy}", typeCode, oldDocumentNumber, documentDate), ApplicationDate = documentDate }; applications.Add( aircraftDocumentApplication.Get<int>("part.__oldId"), Tuple.Create(application, applicationNom)); } unitOfWork.Save(); Dictionary<int, JObject> nomApplications = new Dictionary<int, JObject>(); foreach (var app in applications) { var gvaApp = app.Value.Item1; var appNomDO = app.Value.Item2; appNomDO.ApplicationId = gvaApp.GvaApplicationId; nomApplications.Add( app.Key, Utils.ToJObject(appNomDO)); IList<GvaApplicationStage> appStages = CommonUtils.GetApplicationStages(this.oracleConn, personIdToLotId, appNomDO.ApplicationId, app.Key); foreach (GvaApplicationStage stage in appStages) { unitOfWork.DbContext.Set<GvaApplicationStage>().Add(stage); } } var aircraftDocumentOccurrences = this.getAircraftDocumentOccurrences(aircraftApexId, nomApplications, noms, blobIdsToFileKeys); foreach (var aircraftDocumentOccurrence in aircraftDocumentOccurrences) { addPartWithFiles("documentOccurrences/*", aircraftDocumentOccurrence); } var aircraftDocumentOwners = this.getAircraftDocumentOwners(aircraftApexId, nomApplications, getPersonByApexId, getOrgByApexId, noms, blobIdsToFileKeys); foreach (var aircraftDocumentOwner in aircraftDocumentOwners) { var pv = addPartWithFiles("aircraftDocumentOwners/*", aircraftDocumentOwner); } var aircraftDocumentOthers = this.getAircraftDocumentOthers(aircraftApexId, nomApplications, noms, blobIdsToFileKeys); foreach (var aircraftDocumentOther in aircraftDocumentOthers) { addPartWithFiles("aircraftDocumentOthers/*", aircraftDocumentOther); } Dictionary<int, int> inspections = new Dictionary<int, int>(); var aircraftInspections = this.getAircraftInspections(aircraftApexId, nomApplications, getPersonByApexId, blobIdsToFileKeys, noms); foreach (var aircraftInspection in aircraftInspections) { var pv = addPartWithFiles("inspections/*", aircraftInspection); inspections.Add(aircraftInspection.Get<int>("part.__oldId"), pv.Part.Index); } var aircraftCertSmods = this.getAircraftCertSmods(aircraftApexId, nomApplications, noms); foreach (var aircraftCertSmod in aircraftCertSmods) { addPartWithFiles("aircraftCertSmods/*", aircraftCertSmod); } try { lot.Commit(context, lotEventDispatcher); } // ignore empty commit exceptions catch (InvalidOperationException) { } unitOfWork.Save(); Console.WriteLine("Migrated APEX aircraftId: {0}", aircraftApexId); } } catch (Exception) { Console.WriteLine("Error in APEX aircraftId: {0}", aircraftApexId); cts.Cancel(); throw; } } }
public IHttpActionResult PostLinkApplication(ApplicationLinkDO applicationLinkDO) { using (var transaction = this.unitOfWork.BeginTransaction()) { GvaApplication application = new GvaApplication() { LotId = applicationLinkDO.LotId, DocId = applicationLinkDO.DocId }; applicationRepository.AddGvaApplication(application); this.unitOfWork.Save(); transaction.Commit(); return Ok(new { applicationId = application.GvaApplicationId, docId = application.DocId, }); } }