public override global::System.Data.DataSet Clone() { ImportDataSet cln = ((ImportDataSet)(base.Clone())); cln.InitVars(); cln.SchemaSerializationMode = this.SchemaSerializationMode; return(cln); }
public static int?CreateNewClient(ImportData data) { try { ImportDataSet ds = new ImportDataSet(); ImportDataSetTableAdapters.ClientsTableAdapter tableAdapter = new ImportDataSetTableAdapters.ClientsTableAdapter(); string provinceId = "00"; // HACK Provincia hardcodeada string countryId = "es"; // HACK Pais hardcodeado var row = ds.Clients.NewClientsRow(); row.Code = ""; row.Name = data.ClientName; row.Cif = data.ClientCif; row.Address = data.Address; row.City = data.City; row.PostCode = data.PostCode; row.Province = provinceId; row.Country = countryId; row.Contact = data.Contact; row.Phone = data.Phone; row.Phone2 = data.Phone2; row.PhoneMobile = ""; row.Fax = ""; row.Email = data.Email; string[] gps = Geocode(data.Address, data.PostCode, data.City); row.Latitude = float.Parse(gps[0]); row.Longitude = float.Parse(gps[1]); ds.Clients.AddClientsRow(row); tableAdapter.Update(ds.Clients); int clientId = ds.Clients[0].Id; ds.Clients[0].Code = clientId.ToString().PadLeft(8, '0'); tableAdapter.Update(ds.Clients); CreateClientRelationship(data, clientId); return(clientId); } catch (Exception) { return(null); } /* * TODO Elementos que no se insertan * Province * Country * PhoneMobile * Fax */ }
public RelatedValues( ImportDataSet dsImport, LinksDataSet dsLinks ) { if ( dsImport == null ) throw new ArgumentNullException("dsImport"); if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( dsLinks.tblRelatedStructure.Count <= 0 ) throw new ArgumentException("There should NOT be zero rows in tblRelatedStructure."); if ( dsLinks.tblMarkerGen1.Count <= 0 ) throw new ArgumentException("There should NOT be zero rows in tblMarkerGen1."); if ( dsLinks.tblMarkerGen2.Count <= 0 ) throw new ArgumentException("There should NOT be zero rows in tblMarkerGen2."); if ( dsLinks.vewSurveyTimeMostRecent.Count <= 0 ) throw new ArgumentException("There should NOT be zero rows in vewSurveyTimeMostRecent."); if ( dsLinks.tblRelatedValues.Count != 0 ) throw new ArgumentException("There should be zero rows in tblRelatedValues."); _dsImport = dsImport; _dsLinks = dsLinks; }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs) { ImportDataSet ds = new ImportDataSet(); global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); global::System.Xml.Schema.XmlSchemaAny any = new global::System.Xml.Schema.XmlSchemaAny(); any.Namespace = ds.Namespace; sequence.Items.Add(any); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private static bool CreateClientRelationship(ImportData data, int clientId) { ImportDataSet ds = new ImportDataSet(); ImportDataSetTableAdapters.Operators_ClientsTableAdapter adapt = new ImportDataSetTableAdapters.Operators_ClientsTableAdapter(); var row = ds.Operators_Clients.NewOperators_ClientsRow(); row.OperatorId = data.OperatorId; row.ClientId = clientId; row.Code = data.ClientCode; ds.Operators_Clients.AddOperators_ClientsRow(row); return(adapt.Update(ds.Operators_Clients) > 0); }
public MarkerGen1( LinksDataSet dsLinks, ImportDataSet dsImport ) { if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( dsLinks.tblSubject.Count <= 0 ) throw new ArgumentException("There shouldn't be zero rows in tblSubject."); if ( dsLinks.tblRelatedStructure.Count <= 0 ) throw new ArgumentException("There shouldn't be zero rows in tblRelatedStructure."); if ( dsLinks.tblRosterGen1.Count <= 0 ) throw new ArgumentException("There shouldn't be zero rows in tblRosterGen1."); if ( dsLinks.tblParentsOfGen1Current.Count <= 0 ) throw new ArgumentException("There shouldn't be zero rows in tblParentsOfGen1Current."); if ( dsLinks.tblParentsOfGen1Retro.Count <= 0 ) throw new ArgumentException("There shouldn't be zero rows in tblParentsOfGen1Retro."); if ( dsImport.tblGeocodeSanitized.Count <= 0 ) throw new ArgumentException("There shouldn't be zero rows in tblGeocodeSanitized."); if ( dsLinks.tblMarkerGen1.Count != 0 ) throw new ArgumentException("There should be zero rows in tblMarkerGen1."); _dsLinks = dsLinks; _dsImport = dsImport; _itemIDsString = CommonCalculations.ConvertItemsToString(_items); }
public Response( ImportDataSet dsImport, LinksDataSet dsLinks ) { if ( dsImport == null ) throw new ArgumentNullException("dsImport"); if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( dsLinks.tblResponse.Count != 0 ) throw new InvalidOperationException("tblResponse must be empty before creating rows for it."); if ( dsImport.tblGen1Links.Count == 0 ) throw new InvalidOperationException("tblGen1Links must NOT be empty before reading responses from it."); if ( dsImport.tblGen2Links.Count == 0 ) throw new InvalidOperationException("tblGen2Links must NOT be empty before reading responses from it."); if ( dsImport.tblGen2LinksFromGen1.Count == 0 ) throw new InvalidOperationException("tblGen2LinksFromGen1 must NOT be empty before reading responses from it."); if ( dsImport.tblGen2ImplicitFather.Count == 0 ) throw new InvalidOperationException("tblGen2ImplicitFather must NOT be empty before reading responses from it."); if( dsImport.tblGen1Outcomes.Count == 0 ) throw new InvalidOperationException("tblGen1Outcomes must NOT be empty before reading responses from it."); if( dsImport.tblGen2OutcomesHeight.Count == 0 ) throw new InvalidOperationException("tblGen2OutcomesHeight must NOT be empty before reading responses from it."); if( dsImport.tblGen2OutcomesWeight.Count == 0 ) throw new InvalidOperationException("tblGen2OutcomesWeight must NOT be empty before reading responses from it."); if( dsImport.tblGen2OutcomesMath.Count == 0 ) throw new InvalidOperationException("tblGen2OutcomesMath must NOT be empty before reading responses from it."); _dsImport = dsImport; _dsLinks = dsLinks; }
public static string CreateSubject( ImportDataSet dsImport, LinksDataSet dsLinks ) { if ( dsImport == null ) throw new ArgumentNullException("dsImport"); if ( dsImport.tblGen1Links.Rows.Count != Constants.Gen1Count ) throw new ArgumentException("There should be exactly " + Constants.Gen1Count + " Gen1 subject rows, but instead there are " + dsImport.tblGen1Links.Rows.Count + "."); if ( dsImport.tblGen2Links.Rows.Count != Constants.Gen2Count ) throw new ArgumentException("There should be exactly " + Constants.Gen2Count + " Gen2 subject rows, but instead there are " + dsImport.tblGen2Links.Rows.Count + "."); if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( dsLinks.tblSubject.Count != 0 ) throw new InvalidOperationException("tblSubject must be empty before creating rows for it."); Stopwatch sw = new Stopwatch(); sw.Start(); Int32 subjectRecordsAddedCount = 0; foreach ( ImportDataSet.tblGen1LinksRow drGen1 in dsImport.tblGen1Links ) { LinksDataSet.tblSubjectRow drBare = dsLinks.tblSubject.NewtblSubjectRow(); drBare.SubjectID = (Int32)drGen1[Constants.Gen1SubjectIDColumn]; drBare.SubjectTag = drBare.SubjectID * 100;//For Gen1 subjects, append "00" at the end. drBare.ExtendedID = Convert.ToInt16(drGen1[Constants.Gen1ExtendedFamilyIDColumn]); drBare.Generation = (byte)Generation.Gen1; drBare.Gender = Convert.ToByte(drGen1[Constants.Gen1GenderColumn]); dsLinks.tblSubject.AddtblSubjectRow(drBare); subjectRecordsAddedCount += 1; } Trace.Assert(subjectRecordsAddedCount == Constants.Gen1Count, "The number of added Gen1 subjects should be correct."); foreach ( ImportDataSet.tblGen2LinksRow drGen2 in dsImport.tblGen2Links ) { LinksDataSet.tblSubjectRow drBare = dsLinks.tblSubject.NewtblSubjectRow(); drBare.SubjectID = drGen2.C0000100; drBare.SubjectTag = drBare.SubjectID; Int32 motherID = drGen2.C0000200; drBare.ExtendedID = RetrieveExtendedFamilyIDFromGenMotherID(dsImport, motherID); drBare.Generation = (byte)Generation.Gen2; Int32 genderTemp = drGen2.C0005400; if ( genderTemp == -3 ) genderTemp = (byte)Gender.InvalidSkipGen2; drBare.Gender = (byte)genderTemp; dsLinks.tblSubject.AddtblSubjectRow(drBare); subjectRecordsAddedCount += 1; } Trace.Assert(subjectRecordsAddedCount == Constants.Gen1Count+ Constants.Gen2Count, "The number of added Gen2 subjects should be correct."); sw.Stop(); Int32 expectedRowCount = dsImport.tblGen1Links.Rows.Count + dsImport.tblGen2Links.Rows.Count; Trace.Assert(expectedRowCount == subjectRecordsAddedCount, "The correct number of subjects should be added."); return string.Format("{0:N0} Subject records were enumerated.\nElapsed time: {1}", subjectRecordsAddedCount, sw.Elapsed.ToString()); }
public void Dispose() { if (m_XDbConnection == null) { return; } try { if (m_XDbConnection.State == ConnectionState.Open) { m_XDbConnection.Close(); } ImportDataSet.Clear(); ImportDataSet.Dispose(); ImportDataSet = null; } catch { } finally { m_XDbConnection = null; } }
public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs) { global::System.Xml.Schema.XmlSchemaComplexType type = new global::System.Xml.Schema.XmlSchemaComplexType(); global::System.Xml.Schema.XmlSchemaSequence sequence = new global::System.Xml.Schema.XmlSchemaSequence(); ImportDataSet ds = new ImportDataSet(); global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny(); any1.Namespace = "http://www.w3.org/2001/XMLSchema"; any1.MinOccurs = new decimal(0); any1.MaxOccurs = decimal.MaxValue; any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any1); global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny(); any2.Namespace = "urn:schemas-microsoft-com:xml-diffgram-v1"; any2.MinOccurs = new decimal(1); any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax; sequence.Items.Add(any2); global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute1.Name = "namespace"; attribute1.FixedValue = ds.Namespace; type.Attributes.Add(attribute1); global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute(); attribute2.Name = "tableTypeName"; attribute2.FixedValue = "TransactionsDataTable"; type.Attributes.Add(attribute2); type.Particle = sequence; global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable(); if (xs.Contains(dsSchema.TargetNamespace)) { global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream(); global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream(); try { global::System.Xml.Schema.XmlSchema schema = null; dsSchema.Write(s1); for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();) { schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current)); s2.SetLength(0); schema.Write(s2); if ((s1.Length == s2.Length)) { s1.Position = 0; s2.Position = 0; for (; ((s1.Position != s1.Length) && (s1.ReadByte() == s2.ReadByte()));) { ; } if ((s1.Position == s1.Length)) { return(type); } } } } finally { if ((s1 != null)) { s1.Close(); } if ((s2 != null)) { s2.Close(); } } } xs.Add(dsSchema); return(type); }
private static Int16 RetrieveExtendedFamilyIDFromGenMotherID( ImportDataSet dsImport, Int32 motherID ) { ImportDataSet.tblGen1LinksRow drGen1 = dsImport.tblGen1Links.FindByR0000100(motherID); Trace.Assert(drGen1 != null, "The retrieved mother's row should not be null for Gen1 subject '" + motherID + "'."); return (Int16)drGen1.R0000149; }
public RGen2Pass1( ImportDataSet dsImport, LinksDataSet dsLinks, LinksDataSet.tblRelatedStructureRow drLeft, LinksDataSet.tblRelatedStructureRow drRight ) { if ( dsImport == null ) throw new ArgumentNullException("dsImport"); if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( drLeft == null ) throw new ArgumentNullException("drLeft"); if ( drRight == null ) throw new ArgumentNullException("drRight"); if ( dsImport.tblLinks2004Gen2.Count == 0 ) throw new InvalidOperationException("tblLinks2004Gen2 must NOT be empty before assigning R values from it."); if ( dsLinks.tblMzManual.Count == 0 ) throw new InvalidOperationException("tblMzManual must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubject.Count == 0 ) throw new InvalidOperationException("tblSubject must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubjectDetails.Count == 0 ) throw new InvalidOperationException("tblSubjectDetails must NOT be empty before assigning R values from it."); if ( dsLinks.tblMarkerGen2.Count == 0 ) throw new InvalidOperationException("tblMarkerGen2 must NOT be empty before assigning R values from it."); _dsImport = dsImport; _dsLinks = dsLinks; _drLeft = drLeft; _drRight = drRight; _idRelatedLeft = _drLeft.ID; _idRelatedRight = _drRight.ID; _drBare1 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S1); _drBare2 = _dsLinks.tblSubject.FindBySubjectTag(drLeft.SubjectTag_S2); _drSubjectDetails1 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S1); _drSubjectDetails2 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S2); _extendedID = _drLeft.tblSubjectRowByFK_tblRelatedStructure_tblSubject_Subject1.ExtendedID; if ( _drSubjectDetails1.BirthOrderInNls <= _drSubjectDetails2.BirthOrderInNls ) {//This is the way it usually is. Recall twins were assigned tied birth orders _idRelatedOlderAboutYounger = _idRelatedLeft; _idRelatedYoungerAboutOlder = _idRelatedRight; } else if ( _drSubjectDetails1.BirthOrderInNls > _drSubjectDetails2.BirthOrderInNls ) { _idRelatedOlderAboutYounger = _idRelatedRight; _idRelatedYoungerAboutOlder = _idRelatedLeft; } _dtMarkersGen2 = MarkerGen2.PairRelevantMarkerRows(_idRelatedLeft, _idRelatedRight, _dsLinks, _extendedID); LinksDataSet.tblMzManualRow drMzManual = Retrieve.MzManualRecord(_drBare1, _drBare2, _dsLinks); if ( drMzManual == null ) { _multipleBirth = MultipleBirth.No; _isMZ = Tristate.No; } else { _multipleBirth = (MultipleBirth)drMzManual.MultipleBirthIfSameSex; _isMZ = (Tristate)drMzManual.IsMz; } MarkerEvidence babyDaddyDeathDate = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyDeathDate, _dtMarkersGen2); MarkerEvidence babyDaddyAlive = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyAlive, _dtMarkersGen2); MarkerEvidence babyDaddyInHH = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyInHH, _dtMarkersGen2); MarkerEvidence babyDaddyLeftHHDate = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyLeftHHDate, _dtMarkersGen2); MarkerEvidence babyDaddyDistanceFromHH = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyDistanceFromHH, _dtMarkersGen2); MarkerEvidence babyDaddyAsthma = MarkerGen2.RetrieveBiodadMarkerFromGen1(_idRelatedOlderAboutYounger, MarkerType.BabyDaddyAsthma, _dtMarkersGen2); _rImplicitPass1 = CalculateRImplicitPass1(babyDaddyDeathDate, babyDaddyAlive, babyDaddyInHH, babyDaddyLeftHHDate, babyDaddyDistanceFromHH, babyDaddyAsthma); //_rImplicit not set; _rImplicit2004 = RetrieveRImplicit2004(); _rExplicitOldestSibVersion = CalculateRExplicitOldestSibVersion(); _rExplicitYoungestSibVersion = CalculateRExplicitYoungestSibVersion(); _rExplicitPass1 = CalculateRExplicitPass1(_isMZ, _multipleBirth); //_rExplicit not set; _rPass1 = CalculateRPass1(); //_r not set; //_rPeek not set; }
private void ImportData(object o) { int doneCount = 0; int failedCount = 0; int successCount = 0; Action <int> reportProgress = null; if (o is BackgroundWorker) { reportProgress = (o as BackgroundWorker).ReportProgress; } else { reportProgress = x => { } }; while (true) { ImportDataSet currentSet = null; lock (_queueLock) { if (_importSetQueue.Count == 0) { if (null == _moveSetQueue) { _importSetQueue = null; break; } Thread.Sleep(100); } else { currentSet = _importSetQueue.Dequeue(); } } if (null != currentSet) { bool savedData = false; int lastAnemId = -1; foreach (var file in currentSet.Files) { FileInfo fileLocation; if (!currentSet.MovedToLocation.TryGetValue(file, out fileLocation)) { fileLocation = file.Path; } if (null != fileLocation) { var currentFile = file.Path == fileLocation ? file : DaqDataFileInfo.Create(fileLocation); try { var pushOk = _dataStore.Push( currentSet.Sensor.Name, GetPackedReadings(currentFile), _recordOverwrite); if (pushOk) { successCount++; savedData = true; lastAnemId = file.Nid; } else { failedCount++; } } catch { failedCount++; } } } if (savedData) { _dataStore.SetLatestSensorNameForHardwareId( currentSet.Sensor.Name, ((char)(lastAnemId + (byte)('A'))).ToString() ); } System.Diagnostics.Debug.WriteLine("Importing..." + currentSet.Files.Count); doneCount++; } lock (_queueLock) { ImportProgress = doneCount / (double)MaxQueue; reportProgress((int)(Progress * 100)); } } _message = null; if (failedCount > 0 || successCount == 0) { _message = "Data import failed."; } else { _message = "Data import completed successfully."; } lock (_queueLock) { ImportProgress = 1.0; reportProgress((int)(Progress * 100)); } } }
public void Dispose() { ImportDataSet.DisposeObject(); ImportErrorDataSet.DisposeObject(); }
private Int32 FromBioparentBirthState( Bioparent bioparent, LinksDataSet.tblRelatedStructureRow drRelated, ImportDataSet.tblGeocodeSanitizedDataTable dtGeocode ) { const Int16 year = ItemYears.Gen1BioparentBirthState; Int32 subjectSmaller = Math.Min(drRelated.SubjectTag_S1, drRelated.SubjectTag_S2); Int32 subjectLarger = Math.Max(drRelated.SubjectTag_S1, drRelated.SubjectTag_S2); ImportDataSet.tblGeocodeSanitizedRow drGeo = dtGeocode.FindBySubjectTag_S1SubjectTag_S2(subjectSmaller, subjectLarger); MarkerType markerType; MarkerEvidence mzEvidence = MarkerEvidence.Irrelevant; MarkerEvidence shareBiomom = MarkerEvidence.Irrelevant; MarkerEvidence shareBiodad = MarkerEvidence.Irrelevant; switch ( bioparent ) { case Bioparent.Mom: markerType = MarkerType.Gen1BiomomBirthState; if ( drGeo.BirthMotherStateMissing_1 || drGeo.BirthMotherStateMissing_2 ) shareBiomom = MarkerEvidence.Missing; else if ( drGeo.BirthMotherStateEqual ) shareBiomom = MarkerEvidence.Consistent; else if ( !drGeo.BirthMotherStateEqual ) shareBiomom = MarkerEvidence.Disconfirms; else throw new InvalidOperationException("The execution should not have gotten here."); mzEvidence = shareBiomom; break; case Bioparent.Dad: markerType = MarkerType.Gen1BiodadBirthState; if ( drGeo.BirthFatherStateMissing_1 || drGeo.BirthFatherStateMissing_2 ) shareBiodad = MarkerEvidence.Missing; else if ( drGeo.BirthFatherStateEqual ) shareBiodad = MarkerEvidence.Consistent; else if ( !drGeo.BirthFatherStateEqual ) shareBiodad = MarkerEvidence.Disconfirms; else throw new InvalidOperationException("The execution should not have gotten here."); mzEvidence = shareBiodad; break; default: throw new ArgumentOutOfRangeException("bioparent", bioparent, "The 'FromShareBioparent' function does not accommodate this bioparent value."); } AddMarkerRow(drRelated.ExtendedID, drRelated.ID, markerType, year, mzEvidence: mzEvidence, sameGenerationEvidence: MarkerEvidence.Irrelevant, biomomEvidence: shareBiomom, biodadEvidence: shareBiodad, biograndparentEvidence: MarkerEvidence.Ambiguous); const Int32 recordsAdded = 1; return recordsAdded; }
public void SaveTemp() { string fileName = FileUtil.GetRealFileName("importTemp.xml", FilePathPosition.Xml); ImportDataSet.WriteXml(fileName, XmlWriteMode.WriteSchema); }
public void Dispose() { ImportDataSet.DisposeObject(); ErrorTable.DisposeObject(); }
private float? _rPass1 = float.NaN; // float.NaN; #endregion Fields #region Constructors public RGen1Pass1( ImportDataSet dsImport, LinksDataSet dsLinks, LinksDataSet.tblRelatedStructureRow drLeft, LinksDataSet.tblRelatedStructureRow drRight ) { if ( dsImport == null ) throw new ArgumentNullException("dsImport"); if ( dsLinks == null ) throw new ArgumentNullException("dsLinks"); if ( drLeft == null ) throw new ArgumentNullException("drLeft"); if ( drRight == null ) throw new ArgumentNullException("drRight"); if ( dsImport.tblLinks2004Gen1.Count == 0 ) throw new InvalidOperationException("tblLinks2004Gen1 must NOT be empty before assigning R values from it."); if ( dsLinks.tblMzManual.Count == 0 ) throw new InvalidOperationException("tblMzManual must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubject.Count == 0 ) throw new InvalidOperationException("tblSubject must NOT be empty before assigning R values from it."); if ( dsLinks.tblRosterGen1.Count == 0 ) throw new InvalidOperationException("tblRosterGen1 must NOT be empty before assigning R values from it."); if ( dsLinks.tblMarkerGen1.Count == 0 ) throw new InvalidOperationException("tblMarkerGen2 must NOT be empty before assigning R values from it."); if ( dsLinks.tblSubjectDetails.Count == 0 ) throw new InvalidOperationException("tblSubjectDetails must NOT be empty before assigning R values from it."); _dsImport = dsImport; _dsLinks = dsLinks; _drLeft = drLeft; _drRight = drRight; _idRelatedLeft = _drLeft.ID; _idRelatedRight = _drRight.ID; _drSubjectDetails1 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S1); _drSubjectDetails2 = _dsLinks.tblSubjectDetails.FindBySubjectTag(drLeft.SubjectTag_S2); _extendedID = _drLeft.tblSubjectRowByFK_tblRelatedStructure_tblSubject_Subject1.ExtendedID; //LinksDataSet.tblRosterGen1Row drRoster = _dsLinks.tblRosterGen1.FindByRelatedID(drLeft.ID); //Tristate rosterShareBiomom = (Tristate)drRoster.ShareBiomom; //Tristate rosterShareBiodad = (Tristate)drRoster.ShareBiodad; //if ( drRoster.IsRNull() ) _rRoster = null; //else _rRoster = (float)drRoster.R; if ( _drSubjectDetails1.BirthOrderInNls <= _drSubjectDetails2.BirthOrderInNls ) {//This is the way it usually is. Remember that twins were assigned tied birth orders _idRelatedOlderAboutYounger = _idRelatedLeft; _idRelatedYoungerAboutOlder = _idRelatedRight; } else if ( _drSubjectDetails1.BirthOrderInNls > _drSubjectDetails2.BirthOrderInNls ) { _idRelatedOlderAboutYounger = _idRelatedRight; _idRelatedYoungerAboutOlder = _idRelatedLeft; } _dtMarkersGen1 = MarkerGen1.PairRelevantMarkerRows(_idRelatedLeft, _idRelatedRight, _dsLinks, _extendedID); LinksDataSet.tblMzManualRow drMz = Retrieve.MzManualRecord(_drLeft.SubjectTag_S1, _drLeft.SubjectTag_S2, _dsLinks); if ( drMz == null ) { _multipleBirth = MultipleBirth.No; _isMZ = Tristate.No; _isRelatedInMzManual = Tristate.DoNotKnow; } else { _multipleBirth = (MultipleBirth)drMz.MultipleBirthIfSameSex; _isMZ = (Tristate)drMz.IsMz; if ( drMz.IsRelatedNull() ) _isRelatedInMzManual = Tristate.DoNotKnow; else if ( drMz.Related ) _isRelatedInMzManual = Tristate.Yes; else _isRelatedInMzManual = Tristate.No; } MarkerEvidence explicitBiomomFromOlder = ReduceShareBioparentToOne(MarkerType.ShareBiomom, ItemYears.Gen1ShareBioparent.Length, _idRelatedOlderAboutYounger); MarkerEvidence explicitBiodadFromOlder = ReduceShareBioparentToOne(MarkerType.ShareBiodad, ItemYears.Gen1ShareBioparent.Length, _idRelatedOlderAboutYounger); MarkerEvidence explicitBiomomFromYounger = ReduceShareBioparentToOne(MarkerType.ShareBiomom, ItemYears.Gen1ShareBioparent.Length, _idRelatedYoungerAboutOlder); MarkerEvidence explicitBiodadFromYounger = ReduceShareBioparentToOne(MarkerType.ShareBiodad, ItemYears.Gen1ShareBioparent.Length, _idRelatedYoungerAboutOlder); MarkerEvidence biomomInHH1979 = MarkerGen1.RetrieveParentMarkerMultiYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiomomInHH, 1979, Bioparent.Mom, _dtMarkersGen1); MarkerEvidence biodadInHH1979 = MarkerGen1.RetrieveParentMarkerMultiYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiodadInHH, 1979, Bioparent.Dad, _dtMarkersGen1); MarkerEvidence biomomDeathAge = MarkerGen1.RetrieveParentMarkerSingleYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiomomDeathAge, Bioparent.Mom, _dtMarkersGen1); MarkerEvidence biodadDeathAge = MarkerGen1.RetrieveParentMarkerSingleYear(_idRelatedOlderAboutYounger, MarkerType.Gen1BiodadDeathAge, Bioparent.Dad, _dtMarkersGen1); _explicitShareBiomomPass1 = CommonFunctions.TranslateEvidenceToTristate(explicitBiomomFromOlder, explicitBiomomFromYounger); _explicitShareBiodadPass1 = CommonFunctions.TranslateEvidenceToTristate(explicitBiodadFromOlder, explicitBiodadFromYounger); _implicitShareBiomomPass1 = ImplicitShareBioparent(inHH1979: biomomInHH1979, deathAge: biomomDeathAge); _implicitShareBiodadPass1 = ImplicitShareBioparent(inHH1979: biodadInHH1979, deathAge: biodadDeathAge); _shareBiomomPass1 = CommonFunctions.TakePriority(_explicitShareBiomomPass1, _implicitShareBiomomPass1); _shareBiodadPass1 = CommonFunctions.TakePriority(_explicitShareBiodadPass1, _implicitShareBiodadPass1); _rExplicitOldestSibVersion = CalculateRExplicitSingleSibVersion(explicitBiomomFromOlder, explicitBiodadFromOlder); _rExplicitYoungestSibVersion = CalculateRExplicitSingleSibVersion(explicitBiomomFromYounger, explicitBiodadFromYounger); _rExplicitPass1 = CommonFunctions.TranslateToR(shareBiomom: _explicitShareBiomomPass1, shareBiodad: _explicitShareBiodadPass1, mustDecide: false); _rImplicitPass1 = CommonFunctions.TranslateToR(shareBiomom: _implicitShareBiomomPass1, shareBiodad: _implicitShareBiodadPass1, mustDecide: false); _rImplicit2004 = RetrieveRImplicit2004(); _rPass1 = CalculateRFull(shareBiomom: _shareBiomomPass1, shareBiodad: _shareBiodadPass1, multiple: _multipleBirth, isMZ: _isMZ, isRelatedInMZManual: _isRelatedInMzManual, idRelated: _idRelatedLeft, dtRoster: _dsLinks.tblRosterGen1); }