public IHttpActionResult Get()
        {
            EstateService estateService = CreateEstateService();
            var           estates       = estateService.GetEstates();

            return(Ok(estates));
        }
        public IHttpActionResult Get(int id)
        {
            EstateService estateService = CreateEstateService();
            var           estate        = estateService.GetEstateById(id);

            return(Ok(estate));
        }
        private EstateService CreateEstateService()
        {
            var userId        = Guid.Parse(User.Identity.GetUserId());
            var estateService = new EstateService(userId);

            return(estateService);
        }
Beispiel #4
0
        public async Task <ActionResult> Index()
        {
            var service = new EstateService();
            var estates = await service.SearchAsync();

            ViewBag.Message = "Your application description page.";

            return(View(estates));
        }
        public async void UnassignEstateService(int estateId, int serviceId)
        {
            EstateService estateService = await FindByEstateIdAndServiceId(estateId, serviceId);

            if (estateService != null)
            {
                Remove(estateService);
            }
        }
Beispiel #6
0
        public async Task <ActionResult> Detail(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(nameof(id));
            }

            var service = new EstateService();
            var estates = await service.GetAsync(id);

            return(View(estates));
        }
        public async Task AssignEstateService(int estateId, int serviceId)
        {
            EstateService estateService = await FindByEstateIdAndServiceId(estateId, serviceId);

            if (estateService == null)
            {
                estateService = new EstateService {
                    ServiceId = serviceId, EstateId = estateId
                };
                await AddAsync(estateService);
            }
        }
Beispiel #8
0
 public void UpdateEnvironmentSettings()
 {
     Terrain.LowerLimit = (float)RegionSettings.TerrainLowerLimit;
     Terrain.RaiseLimit = (float)RegionSettings.TerrainRaiseLimit;
     if (RegionSettings.UseEstateSun)
     {
         uint       estateID;
         EstateInfo estate;
         if (EstateService.RegionMap.TryGetValue(ID, out estateID) &&
             EstateService.TryGetValue(estateID, out estate))
         {
             Environment.FixedSunPosition = estate.SunPosition;
             Environment.IsSunFixed       = (estate.Flags & RegionOptionFlags.SunFixed) != 0;
         }
     }
     else
     {
         Environment.FixedSunPosition = RegionSettings.SunPosition;
         Environment.IsSunFixed       = RegionSettings.IsSunFixed;
     }
 }
        public override void TriggerEstateUpdate()
        {
            uint       estateID;
            EstateInfo estateInfo;

            try /* we need a fail protection here */
            {
                if (EstateService.RegionMap.TryGetValue(ID, out estateID) &&
                    EstateService.TryGetValue(estateID, out estateInfo))
                {
                    lock (m_EstateDataUpdateLock)
                    {
                        m_EstateData = estateInfo;
                    }
                }
            }
            catch (Exception e)
            {
                m_Log.WarnFormat("Exception when accessing EstateService: {0}: {1}\n{2}",
                                 e.GetType().FullName,
                                 e.Message,
                                 e.StackTrace);
            }

            foreach (IAgent agent in Agents)
            {
                var viewerAgent = agent as ViewerAgent;
                if (viewerAgent != null)
                {
                    SendRegionInfo(viewerAgent);

                    ParcelInfo pInfo;
                    if (Parcels.TryGetValue(viewerAgent.GlobalPosition, out pInfo))
                    {
                        viewerAgent.SendUpdatedParcelInfo(pInfo, ID);
                    }
                }
            }
            UpdateEnvironmentSettings();
        }
        protected SceneImplementation(
            SceneImplementationFactory sceneParams,
            RegionInfo ri)
            : base(ri.Size.X, ri.Size.Y)
        {
            SceneCapabilities.Add("ProductInfoRequest", new ProductInfoRequestCapability(this));
            m_Scenes     = sceneParams.Scenes;
            m_HttpServer = sceneParams.HttpServer;
            if (sceneParams.AssetService == null)
            {
                throw new ArgumentNullException("persistentAssetService");
            }
            if (sceneParams.GridService == null)
            {
                throw new ArgumentNullException("gridService");
            }
            if (ri == null)
            {
                throw new ArgumentNullException(nameof(ri));
            }
            if (sceneParams.AvatarNameServices == null)
            {
                throw new ArgumentNullException("avatarNameServices");
            }
            if (sceneParams.SimulationDataStorage == null)
            {
                throw new ArgumentNullException("simulationDataStorage");
            }
            if (sceneParams.EstateService == null)
            {
                throw new ArgumentNullException("estateService");
            }
            if (sceneParams.m_CapabilitiesConfig == null)
            {
                throw new ArgumentNullException("capabilitiesConfig");
            }
            if (sceneParams.RegionStorage == null)
            {
                throw new ArgumentNullException("regionStorage");
            }

            #region Setup services
            m_ChatService           = sceneParams.ChatFactory.Instantiate(ri.ID);
            RegionStorage           = sceneParams.RegionStorage;
            GroupsNameService       = sceneParams.GroupsNameService;
            GroupsService           = sceneParams.GroupsService;
            m_NeighborService       = sceneParams.NeighborService;
            m_SimulationDataStorage = sceneParams.SimulationDataStorage;
            PersistentAssetService  = sceneParams.AssetService;
            TemporaryAssetService   = sceneParams.AssetCacheService;
            GridService             = sceneParams.GridService;
            ExperienceService       = sceneParams.ExperienceService;
            ExperienceNameService   = sceneParams.ExperienceNameService;
            EstateService           = sceneParams.EstateService;
            /* next line is there to break the circular dependencies */
            TryGetScene = m_Scenes.TryGetValue;

            UserAgentServicePlugins.AddRange(sceneParams.UserAgentServicePlugins);
            AssetServicePlugins.AddRange(sceneParams.AssetServicePlugins);
            InventoryServicePlugins.AddRange(sceneParams.InventoryServicePlugins);

            #endregion

            #region Setup Region Data
            ID                        = ri.ID;
            GatekeeperURI             = ri.GridURI;
            Access                    = ri.Access;
            ID                        = ri.ID;
            Name                      = ri.Name;
            Owner                     = ri.Owner;
            GridPosition              = ri.Location;
            ProductName               = ri.ProductName;
            RegionPort                = ri.ServerPort;
            m_ExternalHostNameService = sceneParams.ExternalHostNameService;
            #endregion

            /* load estate flags cache */
            uint       estateID;
            EstateInfo estate;
            if (EstateService.RegionMap.TryGetValue(ID, out estateID) &&
                EstateService.TryGetValue(estateID, out estate))
            {
                m_EstateData = estate;
            }
            else
            {
                throw new ArgumentException("Could not load estate data");
            }

            m_RestartObject    = new RestartObject(m_Scenes, this, sceneParams, sceneParams.RegionStorage);
            m_IMService        = sceneParams.IMService;
            m_UDPServer        = new UDPCircuitsManager(new IPAddress(0), (int)ri.ServerPort, sceneParams.IMService, m_ChatService, this, sceneParams.PortControlServices);
            CapabilitiesConfig = sceneParams.m_CapabilitiesConfig;
            foreach (AvatarNameServiceInterface avNameService in sceneParams.AvatarNameServices)
            {
                AvatarNameServices.Add(avNameService);
            }

            Terrain     = new TerrainController(this);
            Environment = new EnvironmentController(this, sceneParams.WindModelFactory);

            if (sceneParams.PathfindingServiceFactory != null)
            {
                PathfindingService = sceneParams.PathfindingServiceFactory.Instantiate(this);
            }

            m_IMRouter = sceneParams.IMRouter;
            m_IMRouter.SceneIM.Add(IMSend);
            OnRemove += RemoveScene;
            m_UDPServer.Start();

            ScriptThreadPool = sceneParams.ScriptWorkerThreadPoolFactory.InstantiateThreadPool(ID);
        }
        public async Task NotReturnPrivateEstates()
        {
            var options = new DbContextOptionsBuilder <EstateSystemDbContext>()
                          .UseInMemoryDatabase(databaseName: "NotReturnPrivateEstates")
                          .Options;

            var estates = new Estate[]
            {
                new Estate()
                {
                    Id            = "ID01",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = false,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID02",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = false,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID03",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = false,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID04",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = true,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID05",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = true,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                }
            };

            using (var context = new EstateSystemDbContext(options))
            {
                await context.Estates.AddRangeAsync(estates);

                await context.SaveChangesAsync();

                var estateService = new EstateService(context);
                estateService.PageSize = 3;

                var resultDTo = await estateService.GetPublicEstatesAsync(1);

                var resultEstates = resultDTo.Estates.ToArray();

                Assert.True(resultEstates.Length == 2);
                Assert.Equal("ID04", resultEstates[0].Id);
                Assert.Equal("ID05", resultEstates[1].Id);
            }
        }
        public async Task Send_Correct_Pagination_View_Model()
        {
            var options = new DbContextOptionsBuilder <EstateSystemDbContext>()
                          .UseInMemoryDatabase(databaseName: "Can_Send_Pagination_View_Model")
                          .Options;

            var estates = new Estate[]
            {
                new Estate()
                {
                    Id            = "ID01",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = true,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID02",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = true,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID03",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = true,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID04",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = true,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                },
                new Estate()
                {
                    Id            = "ID05",
                    Capacity      = 2,
                    City          = "GO",
                    Country       = "Bulgaria",
                    Description   = "Normal House",
                    IsPublic      = true,
                    RentingPrice  = 100,
                    SellingPrice  = 100000,
                    Street        = "Who knows",
                    Size          = 2000,
                    StreetAddress = 66,
                    IsSellable    = false,
                    IsDeleted     = false
                }
            };

            using (var context = new EstateSystemDbContext(options))
            {
                await context.Estates.AddRangeAsync(estates);

                await context.SaveChangesAsync();

                var estateService = new EstateService(context);
                estateService.PageSize = 3;

                var resultDTo = await estateService.GetPublicEstatesAsync(2);

                var pageInfo = resultDTo.PagingInfo;

                Assert.Equal(2, pageInfo.CurrentPage);
                Assert.Equal(3, pageInfo.ItemsPerPage);
                Assert.Equal(5, pageInfo.TotalItems);
                Assert.Equal(2, pageInfo.TotalPages);
            }
        }
Beispiel #13
0
        public void DetermineInitialAgentLocation(IAgent agent, TeleportFlags teleportFlags, Vector3 destinationLocation, Vector3 destinationLookAt, bool sameParcelOverride = false)
        {
            UGUI agentOwner = agent.Owner;

            if (destinationLocation.X < 0 || destinationLocation.X >= SizeX)
            {
                destinationLocation.X = SizeX / 2f;
            }
            if (destinationLocation.Y < 0 || destinationLocation.Y >= SizeY)
            {
                destinationLocation.Y = SizeY / 2f;
            }

            if (teleportFlags.IsLogin())
            {
#if DEBUG
                m_Log.DebugFormat("Setting initial location to a suitable default");
#endif
                destinationLocation = new Vector3(SizeX / 2f, SizeY / 2f, 0);
            }

            ParcelInfo p = Parcels[destinationLocation];
            EstateInfo estateInfo;

            if ((!p.Owner.EqualsGrid(agentOwner) &&
                 !IsEstateManager(agentOwner) &&
                 !Owner.EqualsGrid(agentOwner) &&
                 !IsPossibleGod(agentOwner) &&
                 !sameParcelOverride) ||
                !EnableLandingOverride)
            {
                bool foundTelehub = false;

                estateInfo = CheckEstateRights(agent);

                #region Telehub logic
                if (RegionSettings.TelehubObject != UUID.Zero && (estateInfo.Flags & RegionSettings.AsFlags & RegionOptionFlags.AllowDirectTeleport) == 0)
                {
                    IObject obj;
                    if (Objects.TryGetValue(RegionSettings.TelehubObject, out obj))
                    {
                        var relativeSpawns = SpawnPoints;
                        var absoluteSpawns = new List <Vector3>();
                        switch (SpawnPointRouting)
                        {
                        case "random":
                        {
                            var rand = new Random();
                            while (relativeSpawns.Count > 0)
                            {
                                absoluteSpawns.Add(relativeSpawns[rand.Next(relativeSpawns.Count - 1).Clamp(0, relativeSpawns.Count - 1)] * obj.GlobalRotation + obj.GlobalPosition);
                            }
                        }
                        break;

                        case "emptiest":
                        {
                            var agentLocations = new List <Vector3>();
                            foreach (var retAgent in RootAgents)
                            {
                                agentLocations.Add(retAgent.GlobalPosition);
                            }

                            while (relativeSpawns.Count > 0)
                            {
                                int     emptiestindex         = -1;
                                double  emptiestdistindicator = 0;
                                Vector3 emptiest = Vector3.Zero;

                                for (int i = 0; i < relativeSpawns.Count; ++i)
                                {
                                    double  distindicator = 0;
                                    Vector3 absSpawnV     = relativeSpawns[i] * obj.GlobalRotation + obj.GlobalPosition;
                                    foreach (Vector3 agLocation in agentLocations)
                                    {
                                        distindicator += (agLocation - absSpawnV).LengthSquared;
                                    }
                                    if (emptiestindex < 0 || distindicator < emptiestdistindicator)
                                    {
                                        emptiestdistindicator = distindicator;
                                        emptiest      = absSpawnV;
                                        emptiestindex = i;
                                    }
                                }
                                relativeSpawns.RemoveAt(emptiestindex);
                                absoluteSpawns.Add(emptiest);
                            }
                        }
                        break;

                        case "sequence":
                            foreach (Vector3 v in relativeSpawns)
                            {
                                absoluteSpawns.Add(v * obj.GlobalRotation + obj.GlobalPosition);
                            }
                            break;

                        case "closest":
                        default:
                        {
                            while (relativeSpawns.Count > 0)
                            {
                                int     closestindex = -1;
                                double  distance     = 0;
                                Vector3 closest      = Vector3.Zero;
                                for (int i = 0; i < relativeSpawns.Count; ++i)
                                {
                                    Vector3 v       = relativeSpawns[i] * obj.GlobalRotation + obj.GlobalPosition;
                                    double  newDist = (v - destinationLocation).LengthSquared;
                                    if (closestindex < 0 || distance > newDist)
                                    {
                                        distance     = newDist;
                                        closestindex = i;
                                        closest      = v;
                                    }
                                }
                                relativeSpawns.RemoveAt(closestindex);
                                absoluteSpawns.Add(closest);
                            }
                        }
                        break;
                        }

                        foreach (var spawn in absoluteSpawns)
                        {
                            ParcelInfo spawnParcel;
                            if (Parcels.TryGetValue(spawn, out spawnParcel) &&
                                (spawnParcel.PassPrice != 0 /* skip parcels with pass price here */ ||
                                 CheckParcelAccessRights(agent, spawnParcel)))
                            {
                                /* found a viable spawn here */
                                p = spawnParcel;
                                destinationLocation = spawn;
                                foundTelehub        = true;
                            }
                        }
                    }
                }
                #endregion

                if (!CheckParcelAccessRights(agent, p) && !foundTelehub)
                {
                    p = FindNonBlockedParcel(agent, destinationLocation);
                }

                /* do not block parcel owner, estate manager or estate owner when landing override is enabled */

                if (!foundTelehub)
                {
                    switch (p.LandingType)
                    {
                    case TeleportLandingType.Blocked:
                        /* let's find another parcel */
                        p = FindNonBlockedParcel(agent, destinationLocation);
                        break;

                    case TeleportLandingType.LandingPoint:
                        destinationLocation = p.LandingPosition;
                        destinationLookAt   = p.LandingLookAt;
                        break;

                    case TeleportLandingType.Anywhere:
                    default:
                        break;
                    }
                }
            }

            if (!EstateService.ContainsKey(EstateService.RegionMap[ID]))
            {
                throw new ParcelAccessDeniedException(this.GetLanguageString(agent.CurrentCulture, "EstateDataNotAvailable", "Estate data not available."));
            }

            if (destinationLocation.X < 0 || destinationLocation.X >= SizeX)
            {
                destinationLocation.X = SizeX / 2f;
            }
            if (destinationLocation.Y < 0 || destinationLocation.Y >= SizeY)
            {
                destinationLocation.Y = SizeY / 2f;
            }

            agent.Rotation = destinationLookAt.AgentLookAtToQuaternion();

            double t0_0 = Terrain[(uint)Math.Floor(destinationLocation.X), (uint)Math.Floor(destinationLocation.Y)];
            double t0_1 = Terrain[(uint)Math.Floor(destinationLocation.X), (uint)Math.Ceiling(destinationLocation.Y)];
            double t1_0 = Terrain[(uint)Math.Ceiling(destinationLocation.X), (uint)Math.Floor(destinationLocation.Y)];
            double t1_1 = Terrain[(uint)Math.Ceiling(destinationLocation.X), (uint)Math.Ceiling(destinationLocation.Y)];
            double t_x  = agent.Position.X - Math.Floor(destinationLocation.X);
            double t_y  = agent.Position.Y - Math.Floor(destinationLocation.Y);

            double t0 = t0_0.Lerp(t0_1, t_y);
            double t1 = t1_0.Lerp(t1_1, t_y);

            destinationLocation.Z = t0.Lerp(t1, t_x) + 1;

            agent.Position = destinationLocation;
        }
 public void Remove(EstateService estateService)
 {
     _context.EstateServices.Remove(estateService);
 }
 public async Task AddAsync(EstateService estateService)
 {
     await _context.EstateServices.AddAsync(estateService);
 }
Beispiel #16
0
        // GET api/values
        public IEnumerable <EstateModel> Get()
        {
            EstateService service = new EstateService();

            return(service.GetEstates());
        }