/// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        /// <param name="eS">E s.</param>
        /// <param name="newEstateID">New estate I.</param>
        static void UpdateSystemEstates(IEstateConnector estateConnector, EstateSettings eS, int newEstateID)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = eS.EstateID;

            // get existing linked regions
            var regions = estateConnector.GetRegions((int)oldEstateID);

            // recreate the correct estate?
            if (oldEstateID != newEstateID)
            {
                estateConnector.DeleteEstate((int)oldEstateID);
                newEstateID = estateConnector.CreateNewEstate(eS);
                MainConsole.Instance.Info("System estate '" + eS.EstateName + "' is present but the ID was corrected.");
            }

            // re-link regions
            foreach (UUID regID in regions)
            {
                estateConnector.LinkRegion(regID, newEstateID);
            }
            if (regions.Count > 0)
            {
                MainConsole.Instance.InfoFormat("Relinked {0} regions", regions.Count);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 ///     Server side
 /// </summary>
 /// <param name="FunctionName"></param>
 /// <param name="parameters"></param>
 /// <returns></returns>
 protected object OnGenericEvent(string FunctionName, object parameters)
 {
     if (FunctionName == "EstateUpdated")
     {
         EstateSettings            es = (EstateSettings)parameters;
         IEstateConnector          estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector>();
         ISyncMessagePosterService asyncPoster     =
             m_registry.RequestModuleInterface <ISyncMessagePosterService>();
         IGridService gridService = m_registry.RequestModuleInterface <IGridService>();
         if (estateConnector != null)
         {
             List <UUID> regions = estateConnector.GetRegions((int)es.EstateID);
             if (regions != null)
             {
                 foreach (UUID region in regions)
                 {
                     //Send the message to update all regions that are in this estate, as a setting changed
                     if (gridService != null && asyncPoster != null)
                     {
                         GridRegion r = gridService.GetRegionByUUID(null, region);
                         if (r != null)
                         {
                             asyncPoster.Post(r.ServerURI,
                                              SyncMessageHelper.UpdateEstateInfo(es.EstateID, region));
                         }
                     }
                 }
             }
         }
     }
     return(null);
 }
        /// <summary>
        /// Deletes an estate.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        protected void DeleteEstateCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();

            string estateName = "";

            // check for passed estate name
            estateName = (cmd.Length < 3)
                ? MainConsole.Instance.Prompt("Estate name", estateName)
                : Util.CombineParams(cmd, 2);
            if (estateName == "")
            {
                return;
            }

            // verify that the estate does exist

            EstateSettings ES = estateConnector.GetEstateSettings(estateName);

            if (ES == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName);
                return;
            }

            // check for bogies...
            if (Utilities.IsSystemUser(ES.EstateOwner))
            {
                MainConsole.Instance.Info("[EstateService]: Tsk, tsk.  System estates should not be deleted!");
                return;
            }

            // check for linked regions
            var regions = estateConnector.GetRegions((int)ES.EstateID);

            if (regions.Count > 0)
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' has {1} associated regions. These must be unlinked before deletion!",
                                                estateName, regions.Count);
                return;
            }

            var okDelete = MainConsole.Instance.Prompt("Delete estate '" + estateName + "'. Are you sure? (yes/no)", "no").ToLower() == "yes";

            if (okDelete)
            {
                estateConnector.DeleteEstate((int)ES.EstateID);
                MainConsole.Instance.Warn(estateName + " has been deleted");
            }
            else
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' has not been deleted.", estateName);
            }
        }
        /// <summary>
        /// Shows details of all estates.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void ShowEstatesCommand(IScene scene, string [] cmd)
        {
            IEstateConnector    estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IUserAccountService accountService  = m_registry.RequestModuleInterface <IUserAccountService> ();

            string estateInfo;
            var    estates = estateConnector.GetEstateNames();

            // headings
            estateInfo  = string.Format("{0, -20}", "Estate");
            estateInfo += string.Format("{0, -20}", "Owner");
            estateInfo += string.Format("{0, -10}", "Regions");
            estateInfo += string.Format("{0, -10}", "Voice");
            estateInfo += string.Format("{0, -10}", "Price/M");
            estateInfo += string.Format("{0, -10}", "Public");
            estateInfo += string.Format("{0, -10}", "Tax Free");
            estateInfo += string.Format("{0, -10}", "Direct Tp");

            MainConsole.Instance.CleanInfo(estateInfo);
            MainConsole.Instance.CleanInfo("--------------------------------------------------------------------------------------------------");

            foreach (string estate in estates)
            {
                var            estateID = estateConnector.GetEstateID(estate);
                EstateSettings ES       = estateConnector.GetEstateIDSettings(estateID);

                if (ES != null)
                {
                    //var regInfo = scene.RegionInfo;
                    UserAccount EstateOwner = accountService.GetUserAccount(null, ES.EstateOwner);
                    var         regions     = estateConnector.GetRegions(estateID);

                    // todo ... change hardcoded field sizes to public constants
                    estateInfo  = string.Format("{0, -20}", ES.EstateName);
                    estateInfo += string.Format("{0, -20}", EstateOwner.Name);
                    estateInfo += string.Format("{0, -10}", regions.Count);
                    estateInfo += string.Format("{0, -10}", (ES.AllowVoice) ? "Yes" : "No");
                    estateInfo += string.Format("{0, -10}", ES.PricePerMeter);
                    estateInfo += string.Format("{0, -10}", (ES.PublicAccess) ? "Yes" : "No");
                    estateInfo += string.Format("{0, -10}", (ES.TaxFree) ? "Yes" : "No");
                    estateInfo += string.Format("{0, -10}", (ES.AllowDirectTeleport) ? "Yes" : "No");

                    MainConsole.Instance.CleanInfo(estateInfo);
                }
            }
            MainConsole.Instance.CleanInfo("\n");
        }
        /// <summary>
        /// Shows estate regions.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void ShowEstateRegionsCommand(IScene scene, string [] cmd)
        {
            IEstateConnector estateConnector = Framework.Utilities.DataManager.RequestPlugin <IEstateConnector> ();
            IGridService     gridService     = m_registry.RequestModuleInterface <IGridService> ();

            // check for passed estate name
            string estateName;

            if (cmd.Length < 4)
            {
                do
                {
                    estateName = MainConsole.Instance.Prompt("Estate name (? for list)", "");
                    if (estateName == "?")
                    {
                        var estates = estateConnector.GetEstateNames();
                        MainConsole.Instance.CleanInfo(" Available estates are : ");
                        foreach (string estate in estates)
                        {
                            MainConsole.Instance.CleanInfo("    " + estate);
                        }
                    }
                } while (estateName == "?");

                if (estateName == "")
                {
                    return;
                }
            }
            else
            {
                estateName = cmd [3];
            }

            // verify that the estate does exist
            EstateSettings ES = estateConnector.GetEstateSettings(estateName);

            if (ES == null)
            {
                MainConsole.Instance.ErrorFormat("[EstateService]: The estate '{0}' does not exist!", estateName);
                return;
            }

            var estateregions = estateConnector.GetRegions((int)ES.EstateID);

            int   estRegions = 0;
            float estateArea = 0;
            int   offLine    = 0;

            string regionInfo;

            regionInfo  = string.Format("{0, -20}", "Region");
            regionInfo += string.Format("{0, -12}", "Location");
            regionInfo += string.Format("{0, -14}", "Size");
            regionInfo += string.Format("{0, -12}", "Area");
            regionInfo += string.Format("{0, -26}", "Type");
            regionInfo += string.Format("{0, -10}", "Online");

            MainConsole.Instance.CleanInfo(regionInfo);

            MainConsole.Instance.CleanInfo(
                "----------------------------------------------------------------------------------------------------");

            foreach (UUID regionID in estateregions)
            {
                var region = gridService.GetRegionByUUID(null, regionID);
                if (region == null)     // deleted??
                {
                    continue;
                }

                estRegions++;
                estateArea = estateArea + region.RegionArea;


                if (!region.IsOnline)
                {
                    offLine++;
                }

                // TODO ... change hardcoded field sizes to public constants
                regionInfo  = string.Format("{0, -20}", region.RegionName);
                regionInfo += string.Format("{0, -12}", region.RegionLocX / Constants.RegionSize + "," + region.RegionLocY / Constants.RegionSize);
                regionInfo += string.Format("{0, -14}", region.RegionSizeX + "x" + region.RegionSizeY);
                regionInfo += string.Format("{0, -12}", region.RegionArea < 1000000 ? region.RegionArea + " m2" : (region.RegionArea / 1000000) + " km2");
                regionInfo += string.Format("{0, -26}", region.RegionType);
                regionInfo += string.Format("{0, -10}", region.IsOnline ? "yes" : "no");

                MainConsole.Instance.CleanInfo(regionInfo);
            }
            MainConsole.Instance.CleanInfo("");
            MainConsole.Instance.CleanInfo(
                "----------------------------------------------------------------------------------------------------");
            MainConsole.Instance.CleanInfo("Regions : " + estRegions + " regions with an area of " + (estateArea / 1000000) + " km2");
            MainConsole.Instance.CleanInfo("Offline : " + offLine);
            MainConsole.Instance.CleanInfo(string.Empty);
            MainConsole.Instance.CleanInfo(
                "----------------------------------------------------------------------------------------------------");
            MainConsole.Instance.CleanInfo("\n");
        }
        /// <summary>
        /// Correct the system estate ID and update any linked regions.
        /// </summary>
        /// <param name="estateConnector">Estate connector.</param>
        /// <param name="eS">E s.</param>
        /// <param name="newEstateID">New estate I.</param>
        static void UpdateSystemEstates (IEstateConnector estateConnector, EstateSettings eS, int newEstateID)
        {
            // this may be an ID correction or just an estate name change
            uint oldEstateID = eS.EstateID;

            // get existing linked regions
            var regions = estateConnector.GetRegions ((int)oldEstateID);

            // recreate the correct estate?
            if (oldEstateID != newEstateID) {
                estateConnector.DeleteEstate ((int)oldEstateID);
                newEstateID = estateConnector.CreateNewEstate (eS);
                MainConsole.Instance.Info ("System estate '" + eS.EstateName + "' is present but the ID was corrected.");
            }

            // re-link regions
            foreach (UUID regID in regions) {
                estateConnector.LinkRegion (regID, newEstateID);
            }
            if (regions.Count > 0)
                MainConsole.Instance.InfoFormat ("Relinked {0} regions", regions.Count);
        }