Пример #1
0
 public LightWeightSiteByYear(SiteByYear i_SiteByYear)
 {
     ID      = i_SiteByYear.Id;
     LayerID = i_SiteByYear.CurrentLayer.Id;
     SiteID  = i_SiteByYear.CurrentSite.Id;
     Crop    = new LightWeightCrop(i_SiteByYear.CurrentCrop);
 }
Пример #2
0
        public IHttpActionResult UpdateSiteByYear(SiteByYear i_SiteByYearToModofied)
        {
            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                IHttpActionResult response = Ok();
                bool ok = true;

                try
                {
                    m_SiteByYearHendler.UpdateRow(i_SiteByYearToModofied, context);
                }
                catch
                {
                    ok       = false;
                    response = StatusCode(System.Net.HttpStatusCode.ServiceUnavailable);
                }
                if (ok)
                {
                    List <ILightWeight> sitesByYearsToSend = m_SiteByYearHendler.GetAllTable(context) as List <ILightWeight>;
                    response = Ok(sitesByYearsToSend);
                }

                return(response);
            }
        }
Пример #3
0
        public IHttpActionResult GetSiteByYear(int i_SiteByYearID)
        {
            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                IHttpActionResult response         = NotFound();
                SiteByYear        siteByYearToSend = m_SiteByYearHendler.GetRowByID(i_SiteByYearID, context) as SiteByYear;

                if (siteByYearToSend != null)
                {
                    response = Ok(siteByYearToSend);
                }

                return(response);
            }
        }
Пример #4
0
        public IHttpActionResult UpdateSiteByYear(SiteByYear i_SiteByYearToModofied)
        {
            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                IHttpActionResult response = Ok();

                try
                {
                    m_SiteByYearHendler.UpdateRow(i_SiteByYearToModofied, context);
                }
                catch
                {
                    response = BadRequest("could not update...");
                }

                return(response);
            }
        }
Пример #5
0
        public IHttpActionResult PostSiteByYear(SiteByYear i_PostedSiteByYear)
        {
            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                IHttpActionResult response = Ok();

                try
                {
                    m_SiteByYearHendler.PostNewRow(i_PostedSiteByYear, context);
                }
                catch
                {
                    response = BadRequest("could not post...");
                }

                return(response);
            }
        }
Пример #6
0
        public void StartFilter()
        {
            int        i;
            int        key;
            int        objecyID_Index    = r_DbfReader.IndexOfFieldName("OBJECTID");
            int        site_Name_Index   = r_DbfReader.IndexOfFieldName("Hel_Name");
            int        region_Name_Index = r_DbfReader.IndexOfFieldName("Ezor");
            int        site_Dunam_Index  = r_DbfReader.IndexOfFieldName("Dunam");
            Site       current_site;
            string     current_crop_name;
            Coordinate current_coordinate;
            SiteByYear current_site_by_year;
            Crop       current_crop;
            string     current_sug;
            Dictionary <int, Layer>   layers_dicitonary = new Dictionary <int, Layer>();
            Dictionary <string, Crop> crops_dictionary  = new Dictionary <string, Crop>();
            Dictionary <int, Dictionary <string, int> > site_by_year_indexes = new Dictionary <int, Dictionary <string, int> >();

            using (EntitiesNegev4 context = new EntitiesNegev4())
            {
                context.Configuration.AutoDetectChangesEnabled = false;

                initializeRepositories(context);

                for (i = 13; i < 18; i++)
                {
                    key = 2000 + i;

                    layers_dicitonary.Add(key, new Layer()
                    {
                        Id          = m_LayersId++,
                        Name        = key.ToString(),
                        Year        = key,
                        SiteByYears = new List <SiteByYear>()
                    });

                    site_by_year_indexes.Add(key, new Dictionary <string, int>());

                    site_by_year_indexes[key].Add("Gidul1", r_DbfReader.IndexOfFieldName("Gidul_I_" + i.ToString()));
                    site_by_year_indexes[key].Add("Gidul2", r_DbfReader.IndexOfFieldName("Gidul_II_" + (17 - i).ToString()));
                    site_by_year_indexes[key].Add("Sug1", r_DbfReader.IndexOfFieldName("Sug_I_" + i.ToString()));
                    site_by_year_indexes[key].Add("Sug2", r_DbfReader.IndexOfFieldName("Sug_II_" + i.ToString()));
                    site_by_year_indexes[key].Add("Details", r_DbfReader.IndexOfFieldName("Details_" + i.ToString()));
                }

                for (int recorde_index = 0; recorde_index < r_DbfReader.GetRecords(objecyID_Index).Length; recorde_index++, m_SiteID++)
                {
                    current_site = new Site()
                    {
                        Dunam       = int.Parse(r_DbfReader.GetField(recorde_index, site_Dunam_Index)),
                        Region      = r_DbfReader.GetField(recorde_index, region_Name_Index).Trim(),
                        Name        = r_DbfReader.GetField(recorde_index, site_Name_Index).Trim(),
                        Id          = m_SiteID,
                        Coordinates = new List <Coordinate>(),
                        SiteByYears = new List <SiteByYear>()
                    };

                    //adding

                    m_SiteRepository.AddRow(current_site);

                    for (i = 0; i < getShapeCoordinates(recorde_index)[0].Length; i++)
                    {
                        current_coordinate = new Coordinate()
                        {
                            ID   = m_CoordinateID,
                            X    = getShapeCoordinates(recorde_index)[0][i].X,
                            Y    = getShapeCoordinates(recorde_index)[0][i].Y,
                            Site = current_site
                        };

                        if (!isCoordinateExistsInSite(current_coordinate, current_site))
                        {
                            //adding
                            current_site.Coordinates.Add(current_coordinate);
                            m_CoordinateReository.AddRow(current_coordinate);
                            m_CoordinateID++;
                        }
                    }

                    for (int year = 2013; year < 2018; year++)
                    {
                        for (int j = 1; j <= 2; j++)
                        {
                            try
                            {
                                current_crop_name = r_DbfReader.GetField(recorde_index, site_by_year_indexes[year]["Gidul" + j.ToString()]).Trim();
                            }
                            catch (Exception ex)
                            {
                                current_crop_name = null;
                            }
                            if (!string.IsNullOrWhiteSpace(current_crop_name))
                            {
                                try
                                {
                                    current_sug = r_DbfReader.GetField(recorde_index, site_by_year_indexes[year]["Sug" + j.ToString()]).Trim();
                                }
                                catch (Exception ex)
                                {
                                    current_sug = null;
                                }
                                if (!string.IsNullOrWhiteSpace(current_sug))
                                {
                                    current_crop_name += " " + current_sug;
                                }

                                if (!crops_dictionary.ContainsKey(current_crop_name))
                                {
                                    current_crop = new Crop()
                                    {
                                        ID          = m_CropId++,
                                        Name        = current_crop_name,
                                        Description = "",
                                        Quantity    = 0,
                                        SiteByYears = new List <SiteByYear>()
                                    };
                                    crops_dictionary.Add(current_crop_name, current_crop);
                                }
                                else
                                {
                                    current_crop = crops_dictionary[current_crop_name];
                                }

                                current_site_by_year = new SiteByYear()
                                {
                                    Id           = m_SiteByYearID++,
                                    CurrentCrop  = current_crop,
                                    CurrentSite  = current_site,
                                    CurrentLayer = layers_dicitonary[year]
                                };

                                current_crop.SiteByYears.Add(current_site_by_year);
                                current_site.SiteByYears.Add(current_site_by_year);
                                layers_dicitonary[year].SiteByYears.Add(current_site_by_year);

                                //adding
                                m_siteByYearRepository.AddRow(current_site_by_year);
                            }
                        }
                    }
                }

                foreach (KeyValuePair <string, Crop> crop in crops_dictionary)
                {
                    //adding
                    m_CropRepository.AddRow(crop.Value);
                }

                foreach (KeyValuePair <int, Layer> layer in layers_dicitonary)
                {
                    //adding
                    m_LayerRepository.AddRow(layer.Value);
                }

                context.Configuration.AutoDetectChangesEnabled = true;
                m_CoordinateReository.Save();
            }
        }