UpdateRestaurantOsm() public method

public UpdateRestaurantOsm ( RestaurantOsm restaurant ) : void
restaurant Spontaneous.DataModel.RestaurantOsm
return void
Exemplo n.º 1
0
        /// <summary>
        /// Should add new restaurant if not exists or add new data to existing restaurant
        /// </summary>
        /// <param name="osmRestId">
        /// Id of RestaurantOSM
        /// </param>
        /// <param name="similarRestId">
        /// Id of existing similar restaurant in main DB
        /// </param>
        public void UpdateDbFromRestaurantOsmData(ObjectId osmRestId, ObjectId similarRestId)
        {
            try
            {
                string osmRestIdStr = osmRestId != null && osmRestId.ToString().IndexOf("000") < 0 ? osmRestId.ToString() : "";
                string similarRestIdStr = similarRestId != null && similarRestId.ToString().IndexOf("000") < 0 ? similarRestId.ToString() : "";
                log.InfoFormat("[UpdateDbFromRestaurantOsmData] osmRestId={0}, similarRestId={1}.", osmRestIdStr, similarRestIdStr);
                OpenStreetMapServices osmServices = new OpenStreetMapServices();

                RestaurantOsm tempOsmRest = osmServices.GetRestaurantOsmById(osmRestId.ToString());
                RestaurantBasicData existRest = GetRestaurantBasicById(similarRestIdStr);
                if (existRest != null)
                {
                    if (tempOsmRest.ReferenceId.ToString() != existRest.Id.ToString())
                    {
                        tempOsmRest.ReferenceId = existRest.Id;
                        osmServices.UpdateRestaurantOsm(tempOsmRest);
                    }
                    RestaurantBasicData tempBasicRest = tempOsmRest.RestaurantOsmToRestaurantBasicData(existRest);
                    if (tempBasicRest != null) // Some properties was updated
                    {
                        tempBasicRest.Source = "OpenStreetMap";
                        UpdateRestaurant(tempBasicRest);
                    }
                }
                else
                {
                    AddNewRestaurantFromOsmRest(tempOsmRest);
                }
            }
            catch (Exception e)
            {
                log.ErrorFormat("[UpdateDbFromRestaurantOsmData] Exception={0}", e);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add conver RestaurantOsm to RestaurantBasicData and Add new rest to DB
 /// </summary>
 /// <param name="osmRestId">
 /// RetaurantOsm
 /// </param>
 public void AddNewRestaurantFromOsmRest(RestaurantOsm osmRest)
 {
     try
     {
         string osmRestId = osmRest.Id.ToString();
         log.InfoFormat("[AddNewRestaurantFromOsmRest] osmRest.Id={0}.", osmRestId);
         OpenStreetMapServices osmServices = new OpenStreetMapServices();
         RestaurantBasicData tempRest = osmRest.RestaurantOsmToRestaurantBasicData();
         if (tempRest != null)
         {
             tempRest.Source = "OpenStreetMap";
             string newRestId = AddRestaurantBasicToDB(tempRest);
             if (newRestId != null)
             {
                 osmRest.ReferenceId = ObjectId.Parse(newRestId);
                 osmServices.UpdateRestaurantOsm(osmRest);
             }
         }
     }
     catch (Exception e)
     {
         log.ErrorFormat("[AddNewRestaurantFromOsmRest] Exception={0}.", e);
     }
 }