/// <summary>
    /// Opens a point shape
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void button2_Click(object sender, EventArgs e)
    {
        openFileDialog2.Filter = "Known file types (*.shp)|*.shp";
        this.openFileDialog2.ShowReadOnly = true;
        this.openFileDialog2.Title = "Select a shape file with data for wells or intakes";

        if (openFileDialog2.ShowDialog() == DialogResult.OK)
        {
            string FileName = openFileDialog2.FileName;

            ShapeReader SR = new ShapeReader(FileName);

            DataTable FullDataSet = SR.Data.Read();
            //Launch a data selector
            DataSelector DS = new DataSelector(FullDataSet);

            if (DS.ShowDialog() == DialogResult.OK)
            {
                if (ShpConfig == null)
                {
                    XmlSerializer x = new XmlSerializer(typeof(ShapeReaderConfiguration));
                    string InstallationPath = Path.GetDirectoryName(this.GetType().Assembly.Location);
                    string config = Path.Combine(InstallationPath, "ShapeReaderConfig.xml");
                    using (FileStream fs = new FileStream(config, FileMode.Open))
                    {
                        ShpConfig = (ShapeReaderConfiguration)x.Deserialize(fs);

                        if (CheckColumn(FullDataSet, ShpConfig.WellIDHeader, config))
                            if (CheckColumn(FullDataSet, ShpConfig.IntakeNumber, config))
                                if (CheckColumn(FullDataSet, ShpConfig.XHeader, config))
                                    if (CheckColumn(FullDataSet, ShpConfig.YHeader, config))
                                        if (CheckColumn(FullDataSet, ShpConfig.TOPHeader, config))
                                          if (CheckColumn(FullDataSet, ShpConfig.BOTTOMHeader, config))
                                          {
                                            Wells = new IWellCollection();
                                            if (FullDataSet.Columns.Contains(ShpConfig.PlantIDHeader))
                                            {
                                              DPlants = new IPlantCollection();
                                              HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells, DPlants);
                                            }
                                            else
                                              HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells);
                                            UpdateListsAndListboxes();
                                          }
                    }
                }
            }
            SR.Dispose();
        }
    }
Ejemplo n.º 2
0
        /// <summary>
        /// Opens a point shape
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            openFileDialog2.Filter            = "Known file types (*.shp)|*.shp";
            this.openFileDialog2.ShowReadOnly = true;
            this.openFileDialog2.Title        = "Select a shape file with data for wells or intakes";

            if (openFileDialog2.ShowDialog() == DialogResult.OK)
            {
                string FileName = openFileDialog2.FileName;

                ShapeReader SR = new ShapeReader(FileName);

                DataTable FullDataSet = SR.Data.Read();
                //Launch a data selector
                DataSelector DS = new DataSelector(FullDataSet);

                if (DS.ShowDialog() == DialogResult.OK)
                {
                    if (ShpConfig == null)
                    {
                        XmlSerializer x = new XmlSerializer(typeof(ShapeReaderConfiguration));
                        string        InstallationPath = Path.GetDirectoryName(this.GetType().Assembly.Location);
                        string        config           = Path.Combine(InstallationPath, "ShapeReaderConfig.xml");
                        using (FileStream fs = new FileStream(config, FileMode.Open))
                        {
                            ShpConfig = (ShapeReaderConfiguration)x.Deserialize(fs);

                            if (CheckColumn(FullDataSet, ShpConfig.WellIDHeader, config))
                            {
                                if (CheckColumn(FullDataSet, ShpConfig.IntakeNumber, config))
                                {
                                    if (CheckColumn(FullDataSet, ShpConfig.XHeader, config))
                                    {
                                        if (CheckColumn(FullDataSet, ShpConfig.YHeader, config))
                                        {
                                            if (CheckColumn(FullDataSet, ShpConfig.TOPHeader, config))
                                            {
                                                if (CheckColumn(FullDataSet, ShpConfig.BOTTOMHeader, config))
                                                {
                                                    Wells = new IWellCollection();
                                                    if (FullDataSet.Columns.Contains(ShpConfig.PlantIDHeader))
                                                    {
                                                        DPlants = new IPlantCollection();
                                                        HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells, DPlants);
                                                    }
                                                    else
                                                    {
                                                        HeadObservations.FillInFromNovanaShape(DS.SelectedRows, ShpConfig, Wells);
                                                    }
                                                    UpdateListsAndListboxes();
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                SR.Dispose();
            }
        }
Ejemplo n.º 3
0
      /// <summary>
      /// Creates wells from DataRows based on ShapeReaderConfiguration
      /// </summary>
      /// <param name="DS"></param>
      /// <param name="SRC"></param>
      public static void FillInFromNovanaShape(DataRow[] DS, ShapeReaderConfiguration SRC, IWellCollection Wells, IPlantCollection Plants)
      {
        bool ReadPumpActivity = false;
        bool ReadPlants = false;
        bool ReadLayer = false;
        if (DS.First().Table.Columns.Contains(SRC.FraAArHeader) & DS.First().Table.Columns.Contains(SRC.TilAArHeader))
          ReadPumpActivity = true;

        if (DS.First().Table.Columns.Contains(SRC.LayerHeader))
          ReadLayer = true;


        if (Plants != null)
          if (DS.First().Table.Columns.Contains(SRC.PlantIDHeader))
            ReadPlants = true;

        IWell CurrentWell;
        IIntake CurrentIntake;
        foreach (DataRow DR in DS)
        {
          string wellID = DR[SRC.WellIDHeader].ToString();
          //Find the well in the dictionary
          if (Wells.Contains(wellID))
          {
            CurrentWell = Wells[wellID];
          }
          else
          {
            //Add a new well if it was not found
            CurrentWell = new Well(wellID);
            CurrentWell.UsedForExtraction = true;
            Wells.Add(CurrentWell);
          }

          int intakeno = Convert.ToInt32(DR[SRC.IntakeNumber]);

          CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == intakeno);

          if (CurrentIntake == null)
            CurrentIntake = CurrentWell.AddNewIntake(intakeno);

          if (ReadLayer)
            if (!Convert.IsDBNull(DR[SRC.LayerHeader]))
              CurrentIntake.Layer = Convert.ToInt32(DR[SRC.LayerHeader]);

          if (ReadPlants)
          {
            Plant CurrentPlant;
            int PlantID = Convert.ToInt32(DR[SRC.PlantIDHeader]);
            if (!Plants.TryGetValue(PlantID, out CurrentPlant))
            {
              CurrentPlant = new Plant(PlantID);
              Plants.Add(CurrentPlant);
            }
            PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant);
            CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake);
            if (ReadPumpActivity)
            {
              CurrentPumpingIntake.Start = new DateTime(Convert.ToInt32(DR[SRC.FraAArHeader]), 1, 1);
              CurrentPumpingIntake.End = new DateTime(Convert.ToInt32(DR[SRC.TilAArHeader]), 12, 31);
            }
          }
          CurrentWell.X = Convert.ToDouble(DR[SRC.XHeader]);
          CurrentWell.Y = Convert.ToDouble(DR[SRC.YHeader]);
          CurrentWell.Terrain = Convert.ToDouble(DR[SRC.TerrainHeader]);
          Screen CurrentScreen = new Screen(CurrentIntake);
          CurrentScreen.BottomAsKote = Convert.ToDouble(DR[SRC.BOTTOMHeader]);
          CurrentScreen.TopAsKote = Convert.ToDouble(DR[SRC.TOPHeader]);
        }
      }
Ejemplo n.º 4
0
 /// <summary>
 /// Creates wells from DataRows based on ShapeReaderConfiguration
 /// </summary>
 /// <param name="DS"></param>
 /// <param name="SRC"></param>
 public static void FillInFromNovanaShape(DataRow[] DS, ShapeReaderConfiguration SRC, IWellCollection Wells)
 {
   FillInFromNovanaShape(DS, SRC, Wells, null);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates wells from DataRows based on ShapeReaderConfiguration
        /// </summary>
        /// <param name="DS"></param>
        /// <param name="SRC"></param>
        public static void FillInFromNovanaShape(DataRow[] DS, ShapeReaderConfiguration SRC, IWellCollection Wells, IPlantCollection Plants)
        {
            bool ReadPumpActivity = false;
            bool ReadPlants       = false;
            bool ReadLayer        = false;

            if (DS.First().Table.Columns.Contains(SRC.FraAArHeader) & DS.First().Table.Columns.Contains(SRC.TilAArHeader))
            {
                ReadPumpActivity = true;
            }

            if (DS.First().Table.Columns.Contains(SRC.LayerHeader))
            {
                ReadLayer = true;
            }


            if (Plants != null)
            {
                if (DS.First().Table.Columns.Contains(SRC.PlantIDHeader))
                {
                    ReadPlants = true;
                }
            }

            IWell   CurrentWell;
            IIntake CurrentIntake;

            foreach (DataRow DR in DS)
            {
                string wellID = DR[SRC.WellIDHeader].ToString();
                //Find the well in the dictionary
                if (Wells.Contains(wellID))
                {
                    CurrentWell = Wells[wellID];
                }
                else
                {
                    //Add a new well if it was not found
                    CurrentWell = new Well(wellID);
                    CurrentWell.UsedForExtraction = true;
                    Wells.Add(CurrentWell);
                }

                int intakeno = Convert.ToInt32(DR[SRC.IntakeNumber]);

                CurrentIntake = CurrentWell.Intakes.FirstOrDefault(var => var.IDNumber == intakeno);

                if (CurrentIntake == null)
                {
                    CurrentIntake = CurrentWell.AddNewIntake(intakeno);
                }

                if (ReadLayer)
                {
                    if (!Convert.IsDBNull(DR[SRC.LayerHeader]))
                    {
                        CurrentIntake.Layer = Convert.ToInt32(DR[SRC.LayerHeader]);
                    }
                }

                if (ReadPlants)
                {
                    Plant CurrentPlant;
                    int   PlantID = Convert.ToInt32(DR[SRC.PlantIDHeader]);
                    if (!Plants.TryGetValue(PlantID, out CurrentPlant))
                    {
                        CurrentPlant = new Plant(PlantID);
                        Plants.Add(CurrentPlant);
                    }
                    PumpingIntake CurrentPumpingIntake = new PumpingIntake(CurrentIntake, CurrentPlant);
                    CurrentPlant.PumpingIntakes.Add(CurrentPumpingIntake);
                    if (ReadPumpActivity)
                    {
                        CurrentPumpingIntake.Start = new DateTime(Convert.ToInt32(DR[SRC.FraAArHeader]), 1, 1);
                        CurrentPumpingIntake.End   = new DateTime(Convert.ToInt32(DR[SRC.TilAArHeader]), 12, 31);
                    }
                }
                CurrentWell.X       = Convert.ToDouble(DR[SRC.XHeader]);
                CurrentWell.Y       = Convert.ToDouble(DR[SRC.YHeader]);
                CurrentWell.Terrain = Convert.ToDouble(DR[SRC.TerrainHeader]);
                Screen CurrentScreen = new Screen(CurrentIntake);
                CurrentScreen.BottomAsKote = Convert.ToDouble(DR[SRC.BOTTOMHeader]);
                CurrentScreen.TopAsKote    = Convert.ToDouble(DR[SRC.TOPHeader]);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Creates wells from DataRows based on ShapeReaderConfiguration
 /// </summary>
 /// <param name="DS"></param>
 /// <param name="SRC"></param>
 public static void FillInFromNovanaShape(DataRow[] DS, ShapeReaderConfiguration SRC, IWellCollection Wells)
 {
     FillInFromNovanaShape(DS, SRC, Wells, null);
 }