/// <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>
        /// Checks for the grid owner estate on initial startup.
        /// </summary>
        void CheckGridOwnerEstate()
        {
            // these should have already been checked but just make sure...
            if (m_estateConnector == null)
            {
                return;
            }

            if (m_estateConnector.RemoteCalls())
            {
                return;
            }

            // check for existing estate name in case of estate ID change
            var estates = m_estateConnector.GetEstateNames();

            if (estates.Count > 2)     // we have 2 system estates, 'System' & 'Mainland'
            {
                return;
            }

            // Create an estate for the grid owner
            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();

            if (accountService == null)
            {
                MainConsole.Instance.Warn("[EstateService]: Unable to determine grid owner for estate creation");
                return;
            }

            var  userAccts   = accountService.GetUserAccounts(null, "*");
            UUID gridOwnerId = UUID.Zero;

            foreach (var acct in userAccts)
            {
                if (!Utilities.IsSystemUser(acct.PrincipalID))
                {
                    gridOwnerId = acct.PrincipalID;                 // we should have only one non system user
                }
            }
            var gridOwnerAcct = accountService.GetUserAccount(null, gridOwnerId);

            MainConsole.Instance.InfoFormat("[EstateService]: The estate for '{0}' needs to be created.", gridOwnerAcct.Name);

            // get estate name
            var estateName = MainConsole.Instance.Prompt("Estate name", "Owner's Estate");

            if (estateName == "")
            {
                estateName = "Owner's Estate";
            }


            var ES = new EstateSettings();

            ES.EstateName  = estateName;
            ES.EstateOwner = gridOwnerId;

            ES.EstateID = (uint)m_estateConnector.CreateNewEstate(ES);
            if (ES.EstateID == 0)
            {
                MainConsole.Instance.Warn("There was an error in creating the owner's estate: " + ES.EstateName);
                //EstateName holds the error. See LocalEstateConnector for more info.
            }
            else
            {
                MainConsole.Instance.InfoFormat("[EstateService]: The estate '{0}' owned by '{1}' has been created.",
                                                ES.EstateName, gridOwnerAcct.Name);
            }
        }