public void TableMergeTest() { NovanaTables.IntakeCommonDataTable DT = new NovanaTables.IntakeCommonDataTable(); NovanaTables.PejlingerDataTable DT2 = new NovanaTables.PejlingerDataTable(); NovanaTables.IntakeCommonRow dr = DT.NewIntakeCommonRow(); dr.NOVANAID = "boring 1"; dr.JUPKOTE = 10; DT.Rows.Add(dr); NovanaTables.PejlingerRow dr1 = DT2.NewPejlingerRow(); dr1.NOVANAID= "boring2"; DT2.Rows.Add(dr1); NovanaTables.PejlingerRow dr2 = DT2.NewPejlingerRow(); dr2.NOVANAID = "boring 1"; DT2.Rows.Add(dr2); int n = dr.Table.Columns.Count; DT.Merge(DT2); n = dr.Table.Columns.Count; dr["AKTDAGE"] = 2; }
public IEnumerable<JupiterIntake> AddDataForNovanaExtraction(IEnumerable<Plant> Plants, DateTime StartDate, DateTime EndDate) { NovanaTables.IntakeCommonDataTable DT2 = new NovanaTables.IntakeCommonDataTable(); NovanaTables.IndvindingerDataTable DT1 = new NovanaTables.IndvindingerDataTable(); NovanaTables.IndvindingerRow CurrentRow; List<JupiterIntake> _intakes = new List<JupiterIntake>(); //Make sure all the necessary data have been read. if (JXL.ReducedRead) JXL.ReadWells(false, false); //Loop the plants foreach (Plant P in Plants) { var anlaeg = JXL.DRWPLANT.FindByPLANTID(P.IDNumber); //Loop the wells foreach (IWell IW in P.PumpingWells) { var wellData=JXL.BOREHOLE.FindByBOREHOLENO(IW.ID); //Construct a JupiterWell JupiterWell Jw = new JupiterWell(IW); //Loop the intakes foreach (IIntake I in Jw.Intakes) { //If the plant does not use all intakes in a well we should not print it if (null!=P.PumpingIntakes.FirstOrDefault(var=> var.Intake.IDNumber.Equals(I.IDNumber) & var.Intake.well.ID.Equals(Jw.ID))) { var intakedata = wellData.GetINTAKERows().FirstOrDefault(var => var.INTAKENO == I.IDNumber); JupiterIntake CurrentIntake = I as JupiterIntake; CurrentIntake.Data = DT2.NewIntakeCommonRow(); //Read generic data AddCommonDataForNovana(CurrentIntake); DT2.Rows.Add(CurrentIntake.Data); CurrentRow = DT1.NewIndvindingerRow(); //Construct novana id string NovanaID = P.IDNumber + "_" + CurrentIntake.well.ID.Replace(" ", "") + "_" + CurrentIntake.IDNumber; CurrentRow.NOVANAID = NovanaID; CurrentIntake.Data["NOVANAID"] = NovanaID; CurrentRow.JUPDTMK = -999; FillPlantDataIntoDataRow(CurrentRow, anlaeg, P, StartDate, EndDate); //Aktiv periode var plantintake = anlaeg.GetDRWPLANTINTAKERows().FirstOrDefault(var => var.BOREHOLENO == Jw.ID & var.INTAKENO == I.IDNumber); NovanaTables.IntakeCommonRow TIC = CurrentIntake.Data as NovanaTables.IntakeCommonRow; CurrentRow.FRAAAR = 1000; int nextyear; if (!plantintake.IsSTARTDATENull()) { CurrentRow.INTSTDATE = plantintake.STARTDATE; CurrentRow.FRAAAR = Math.Max(CurrentRow.FRAAAR, GetFraAar(plantintake.STARTDATE)); } if (!wellData.IsDRILENDATENull()) CurrentRow.FRAAAR = Math.Max(CurrentRow.FRAAAR, GetFraAar(wellData.DRILENDATE)); if (!TIC.IsINTSTDATE2Null()) CurrentRow.FRAAAR = Math.Max(CurrentRow.FRAAAR, GetFraAar(TIC.INTSTDATE2)); CurrentRow.TILAAR = 9999; if (!plantintake.IsENDDATENull()) { CurrentRow.INTENDDATE = plantintake.ENDDATE; CurrentRow.TILAAR = Math.Min(CurrentRow.TILAAR, GetTilAar(plantintake.ENDDATE)); } if (!wellData.IsABANDONDATNull()) CurrentRow.TILAAR = Math.Min(CurrentRow.TILAAR, GetTilAar(wellData.ABANDONDAT)); if (!TIC.IsINTENDATE2Null()) CurrentRow.TILAAR = Math.Min(CurrentRow.TILAAR, GetTilAar(TIC.INTENDATE2)); //Do not include the intake if it is not active within the given period. if (CurrentRow.FRAAAR > EndDate.Year || CurrentRow.TILAAR < StartDate.Year) DT2.Rows.Remove(CurrentIntake.Data); else { DT1.Rows.Add(CurrentRow); _intakes.Add(CurrentIntake); } } } } } //Add a blank string to ensure length of column DT2.Rows[0]["Comment"] = " "; DT2.Rows[0]["OK_KOMMENT"] = " "; DT2.Merge(DT1); return _intakes; }
public void AddDataForNovanaPejl(IEnumerable<JupiterIntake> Intakes) { NovanaTables.PejlingerDataTable DT1 = new NovanaTables.PejlingerDataTable(); NovanaTables.PejlingerRow CurrentRow; NovanaTables.IntakeCommonDataTable DT2 = new NovanaTables.IntakeCommonDataTable(); foreach (JupiterIntake CurrentIntake in Intakes) { CurrentIntake.Data = DT2.NewIntakeCommonRow(); AddCommonDataForNovana(CurrentIntake); DT2.Rows.Add(CurrentIntake.Data); CurrentRow = DT1.NewPejlingerRow(); CurrentRow.NOVANAID = CurrentIntake.Data["NOVANAID"].ToString(); DT1.Rows.Add(CurrentRow); //Create statistics on water levels CurrentRow.ANTPEJ = CurrentIntake.Observations.Count; if (CurrentRow.ANTPEJ > 0) { CurrentRow.REFPOINT = CurrentIntake.RefPoint; CurrentRow.MINDATO = CurrentIntake.Observations.Min(x => x.Time); CurrentRow.MAXDATO = CurrentIntake.Observations.Max(x => x.Time); CurrentRow.AKTAAR = CurrentRow.MAXDATO.Year - CurrentRow.MINDATO.Year + 1; CurrentRow.AKTDAGE = CurrentRow.MAXDATO.Subtract(CurrentRow.MINDATO).Days + 1; CurrentRow.PEJPRAAR = CurrentRow.ANTPEJ / CurrentRow.AKTAAR; CurrentRow.MAXPEJ = CurrentIntake.Observations.Max(num => num.Value); CurrentRow.MINPEJ = CurrentIntake.Observations.Min(num => num.Value); CurrentRow.MEANPEJ = CurrentIntake.Observations.Average(num => num.Value); } } //Add a blank string to ensure length of column DT2.Rows[0]["Comment"] = " "; DT2.Rows[0]["OK_KOMMENT"] = " "; DT2.Merge(DT1); }