private void button3_Click(object sender, EventArgs e)
        {
            if (saveFileDialog1.ShowDialog() == DialogResult.OK)
            {
                IEnumerable <Plant>         plants  = listBoxAnlaeg.Items.Cast <Plant>();
                IEnumerable <JupiterIntake> intakes = JupiterReader.AddDataForNovanaExtraction(plants, dateTimeStartExt.Value, dateTimeEndExt.Value);
                HeadObservations.WriteShapeFromDataRow(saveFileDialog1.FileName, intakes);

                IEnumerable <Plant> PlantWithoutIntakes = plants.Where(var => var.PumpingIntakes.Count == 0);
                if (PlantWithoutIntakes.Count() > 0)
                {
                    if (DialogResult.Yes == MessageBox.Show("The list contains plants with no intakes attached. Should these be written to a new shape-file?", "Plants without intakes!", MessageBoxButtons.YesNo))
                    {
                        if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                        {
                            NovanaTables.IndvindingerDataTable dt = JupiterReader.FillPlantData(PlantWithoutIntakes, dateTimeStartExt.Value, dateTimeEndExt.Value);
                            ShapeWriter PSW = new ShapeWriter(saveFileDialog1.FileName);
                            PSW.WritePointShape(dt, dt.ANLUTMXColumn.ColumnName, dt.ANLUTMYColumn.ColumnName);
                            PSW.Dispose();
                        }
                    }
                }
            }
        }
Beispiel #2
0
        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;
        }
Beispiel #3
0
        public NovanaTables.IndvindingerDataTable FillPlantData(IEnumerable<Plant> plants, DateTime StartDate, DateTime EndDate)
        {
            NovanaTables.IndvindingerDataTable DT = new NovanaTables.IndvindingerDataTable();
              NovanaTables.IndvindingerRow CurrentRow;
              JupiterXL.DRWPLANTRow anlaeg;

              foreach (Plant P in plants)
              {
              anlaeg = JXL.DRWPLANT.FindByPLANTID(P.IDNumber);
              CurrentRow = DT.NewIndvindingerRow();
              FillPlantDataIntoDataRow(CurrentRow, anlaeg, P, StartDate, EndDate);
              CurrentRow.NOVANAID = P.IDNumber.ToString();
              DT.AddIndvindingerRow(CurrentRow);
              }
              return DT;
        }