Exemplo n.º 1
0
        public int FillInExtractionWithCount(IPlantCollection Plants)
        {
            JXL.ReadExtractionTables();

            Plant CurrentPlant;

            //Loop the extractions
            foreach (var Ext in JXL.WRRCATCHMENT)
            {
                if (Plants.TryGetValue(Ext.PLANTID, out CurrentPlant))
                {
                    if (!Ext.IsAMOUNTNull())
                    {
                        CurrentPlant.Extractions.AddSiValue(Ext.STARTDATE, Ext.ENDDATE, Ext.AMOUNT);
                    }
                    if (!Ext.IsSURFACEWATERVOLUMENull())
                    {
                        CurrentPlant.SurfaceWaterExtrations.AddSiValue(Ext.STARTDATE, Ext.ENDDATE, Ext.SURFACEWATERVOLUME);
                    }
                }
            }


            //In ribe amt extractions are in another table

            foreach (var IntExt in JXL.INTAKECATCHMENT)
            {
                if (Plants.TryGetValue(IntExt.DRWPLANTINTAKERow.PLANTID, out CurrentPlant))
                {
                    //It would be possible to store this on the intake instead of the plant.
                    //We are throwing away information!

                    if (!IntExt.IsVOLUMENull())
                    {
                        CurrentPlant.Extractions.AddSiValue(IntExt.STARTDATE, IntExt.ENDDATE, IntExt.VOLUME);
                        //if (IntExt.ENDDATE.Year != IntExt.STARTDATE.Year)
                        //  throw new Exception("Volume cover period longer than 1 year)");

                        //var E = CurrentPlant.Extractions.Items.FirstOrDefault(var => var.StartTime.Year == IntExt.ENDDATE.Year);
                        //if (E == null)
                        //  CurrentPlant.Extractions.AddSiValue (new TimeSeriesEntry(IntExt.ENDDATE, IntExt.VOLUME));
                        //else
                        //  E.Value += IntExt.VOLUME;
                    }
                }
            }
            int toreturn = JXL.INTAKECATCHMENT.Count + JXL.WRRCATCHMENT.Count;

            JXL.INTAKECATCHMENT.Dispose();
            JXL.WRRCATCHMENT.Dispose();
            return(toreturn);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Read Extractions.
        /// The boolean set dates indicates whether the dates read from the DRWPLANTINTAKE table should be used as Pumpingstart
        /// and pumpingstop.
        /// </summary>
        /// <param name="Plants"></param>
        /// <param name="Wells"></param>
        public IPlantCollection ReadPlants(IWellCollection Wells)
        {
            List <Plant>     Plants  = new List <Plant>();
            IPlantCollection DPlants = new IPlantCollection();

            JXL.ReadPlantData();

            IIntake CurrentIntake = null;
            Plant   CurrentPlant;

            List <Tuple <int, Plant> > SubPlants = new List <Tuple <int, Plant> >();


            foreach (var Anlaeg in JXL.DRWPLANT)
            {
                CurrentPlant = new Plant(Anlaeg.PLANTID);
                DPlants.Add(CurrentPlant);

                if (Anlaeg.IsPLANTNAMENull())
                {
                    CurrentPlant.Name = "<no name in database>";
                }
                else
                {
                    CurrentPlant.Name = Anlaeg.PLANTNAME;
                }

                CurrentPlant.Address = Anlaeg.PLANTADDRESS;

                CurrentPlant.PostalCode = Anlaeg.PLANTPOSTALCODE;

                if (!Anlaeg.IsSUPPLANTNull())
                {
                    CurrentPlant.SuperiorPlantNumber = Anlaeg.SUPPLANT;
                }

                CurrentPlant.NewCommuneNumber = Anlaeg.MUNICIPALITYNO2007;
                CurrentPlant.OldCommuneNumber = Anlaeg.MUNICIPALITYNO;


                var cmp = Anlaeg.GetDRWPLANTCOMPANYTYPERows().LastOrDefault();
                if (cmp != null)
                {
                    CurrentPlant.CompanyType = cmp.COMPANYTYPE;
                }

                if (!Anlaeg.IsPERMITDATENull())
                {
                    CurrentPlant.PermitDate = Anlaeg.PERMITDATE;
                }

                if (!Anlaeg.IsPERMITEXPIREDATENull())
                {
                    CurrentPlant.PermitExpiryDate = Anlaeg.PERMITEXPIREDATE;
                }

                if (Anlaeg.IsPERMITAMOUNTNull())
                {
                    CurrentPlant.Permit = 0;
                }
                else
                {
                    CurrentPlant.Permit = Anlaeg.PERMITAMOUNT;
                }

                if (!Anlaeg.IsSUPPLANTNull())
                {
                    SubPlants.Add(new Tuple <int, Plant>(Anlaeg.SUPPLANT, CurrentPlant));
                }

                if (!Anlaeg.IsXUTMNull())
                {
                    CurrentPlant.X = Anlaeg.XUTM;
                }

                if (!Anlaeg.IsYUTMNull())
                {
                    CurrentPlant.Y = Anlaeg.YUTM;
                }


                //Loop the intakes. Only add intakes from wells already in table
                foreach (var IntakeData in Anlaeg.GetDRWPLANTINTAKERows())
                {
                    if (Wells.Contains(IntakeData.BOREHOLENO))
                    {
                        JupiterWell jw = Wells[IntakeData.BOREHOLENO] as JupiterWell;
                        CurrentIntake = jw.Intakes.FirstOrDefault(var => var.IDNumber == IntakeData.INTAKENO);
                        if (CurrentIntake != null)
                        {
                            PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant);
                            CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake);

                            if (!IntakeData.IsSTARTDATENull())
                            {
                                CurrentPumpingIntake.StartNullable = IntakeData.STARTDATE;
                            }
                            else if (jw.StartDate.HasValue)
                            {
                                CurrentPumpingIntake.StartNullable = jw.StartDate;
                            }
                            else if (CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Count() != 0)
                            {
                                CurrentPumpingIntake.StartNullable = CurrentIntake.Screens.Where(var => var.StartDate.HasValue).Min(var => var.StartDate);
                            }

                            if (!IntakeData.IsENDDATENull())
                            {
                                CurrentPumpingIntake.EndNullable = IntakeData.ENDDATE;
                            }
                            else if (jw.EndDate.HasValue)
                            {
                                CurrentPumpingIntake.EndNullable = jw.EndDate;
                            }
                            else if (CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Count() != 0)
                            {
                                CurrentPumpingIntake.EndNullable = CurrentIntake.Screens.Where(var => var.EndDate.HasValue).Max(var => var.EndDate);
                            }
                        }
                    }
                }
            }
            //Now attach the subplants
            foreach (Tuple <int, Plant> KVP in SubPlants)
            {
                Plant Upper;
                if (DPlants.TryGetValue(KVP.Item1, out Upper))
                {
                    if (Upper == KVP.Item2)
                    {
                        string l = "what";
                    }
                    else
                    {
                        Upper.SubPlants.Add(KVP.Item2);
                        foreach (PumpingIntake PI in KVP.Item2.PumpingIntakes)
                        {
                            PumpingIntake d = Upper.PumpingIntakes.FirstOrDefault(var => var.Intake.well.ID == PI.Intake.well.ID);
                            //Remove pumping intakes from upper plant if they are attached to lower plants.
                            if (d != null)
                            {
                                Upper.PumpingIntakes.Remove(d);
                            }
                        }
                    }
                }
            }

            JXL.DRWPLANT.Dispose();
            JXL.DRWPLANTINTAKE.Dispose();
            return(DPlants);
        }