Ejemplo n.º 1
0
 public RegionInfo[] GetRegionInfos(bool nonDisabledOnly)
 {
     List<RegionInfo> Infos = new List<RegionInfo>();
     List<string> RetVal = nonDisabledOnly ?
         GD.Query("Disabled", 0, "simulator", "RegionInfo") :
         GD.Query("", "", "simulator", "RegionInfo");
     if (RetVal.Count == 0)
         return Infos.ToArray();
     RegionInfo replyData = new RegionInfo();
     for (int i = 0; i < RetVal.Count; i++)
     {
         replyData.UnpackRegionInfoData((OSDMap)OSDParser.DeserializeJson(RetVal[i]));
         if (replyData.ExternalHostName == "DEFAULT" || replyData.FindExternalAutomatically)
         {
             replyData.ExternalHostName = Aurora.Framework.Utilities.GetExternalIp();
         }
         else
             replyData.ExternalHostName = Util.ResolveEndPoint(replyData.ExternalHostName, replyData.InternalEndPoint.Port).Address.ToString();
         Infos.Add(replyData);
         replyData = new RegionInfo();
     }
     //Sort by startup number
     Infos.Sort(RegionInfoStartupSorter);
     return Infos.ToArray();
 }
    public bool PosTest2()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest2:Return the property TwoLetterISORegionName in RegionInfo object 2");
        try
        {
            RegionInfo regionInfo = new RegionInfo("zh-CN");
            string strTwoLetterName = regionInfo.TwoLetterISORegionName;
            if (strTwoLetterName != "CN")
            {
                TestLibrary.TestFramework.LogError("003", "the ExpectResult is CN but the ActualResult is " + strTwoLetterName);
                retVal = false;
            }
        }
		catch (ArgumentException)
		{
			TestLibrary.TestFramework.LogInformation("The East Asian Languages are not installed. Skipping test(s)");
			retVal = true;
		}
		catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
            retVal = false;
        }
        return retVal;
    }
Ejemplo n.º 3
0
    /// <summary>
    /// Binds the country dropdown list with countries retrieved
    /// from the .NET Framework.
    /// </summary>
    public void BindCountries()
    {
        StringDictionary dic = new StringDictionary();
        List<string> col = new List<string>();

        foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
        {
            RegionInfo ri = new RegionInfo(ci.Name);
            if (!dic.ContainsKey(ri.EnglishName))
                dic.Add(ri.EnglishName, ri.TwoLetterISORegionName.ToLowerInvariant());

            if (!col.Contains(ri.EnglishName))
                col.Add(ri.EnglishName);
        }

        // Add custom cultures
        if (!dic.ContainsValue("bd"))
        {
            dic.Add("Bangladesh", "bd");
            col.Add("Bangladesh");
        }

        col.Sort();

        ddlCountry.Items.Add(new ListItem("[Not specified]", ""));
        foreach (string key in col)
        {
            ddlCountry.Items.Add(new ListItem(key, dic[key]));
        }

        SetDefaultCountry();
    }
Ejemplo n.º 4
0
        private void CreateNewRegion(object sender, EventArgs e)
        {
            if (RName.Text == "")
            {
                MessageBox.Show("You must enter a region name!");
                return;
            }
            RegionInfo region = new RegionInfo();
            region.RegionName = RName.Text;
            region.RegionID = UUID.Random();
            region.RegionLocX = int.Parse(LocX.Text) * Constants.RegionSize;
            region.RegionLocY = int.Parse(LocY.Text) * Constants.RegionSize;
            
            IPAddress address = IPAddress.Parse("0.0.0.0");
            int port = port = Convert.ToInt32(Port.Text);
            region.InternalEndPoint = new IPEndPoint(address, port);

            string externalName = ExternalIP.Text;
            if (externalName == "DEFAULT")
            {
                externalName = Aurora.Framework.Utilities.GetExternalIp();
                region.FindExternalAutomatically = true;
            }
            else
                region.FindExternalAutomatically = false;
            region.ExternalHostName = externalName;

            region.RegionType = Type.Text;
            region.ObjectCapacity = int.Parse(ObjectCount.Text);
            int maturityLevel = 0;
            if (!int.TryParse(Maturity.Text, out maturityLevel))
            {
                if (Maturity.Text == "Adult")
                    maturityLevel = 2;
                else if (Maturity.Text == "Mature")
                    maturityLevel = 1;
                else //Leave it as PG by default if they do not select a valid option
                    maturityLevel = 0;
            }
            region.RegionSettings.Maturity = maturityLevel;
            region.Disabled = DisabledEdit.Checked;
            region.RegionSizeX = int.Parse(CRegionSizeX.Text);
            region.RegionSizeY = int.Parse(CRegionSizeY.Text);
            region.NumberStartup = int.Parse(CStartNum.Text);

            m_connector.UpdateRegionInfo(region);
            if (KillAfterRegionCreation)
            {
                System.Windows.Forms.Application.Exit();
                return;
            }
            else
            {
                IScene scene;
                m_log.Info("[LOADREGIONS]: Creating Region: " + region.RegionName + ")");
                SceneManager manager = m_OpenSimBase.ApplicationRegistry.RequestModuleInterface<SceneManager>();
                manager.CreateRegion(region, out scene);
            }
            RefreshCurrentRegions();
        }
Ejemplo n.º 5
0
    public bool PosTest1()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest1:Get the hash code of the RegionInfo object 1");
        try
        {
            RegionInfo regionInfo = new RegionInfo("zh-CN");
            int hashCode = regionInfo.GetHashCode();
            if (hashCode != regionInfo.Name.GetHashCode())
            {
                TestLibrary.TestFramework.LogError("001", "the ExpectResult is" + regionInfo.Name.GetHashCode() +"but the ActualResult is " + hashCode);
                retVal = false;
            }
        }
		catch (ArgumentException)
		{
			TestLibrary.TestFramework.LogInformation("The East Asian Languages are not installed. Skipping test(s)");
			retVal = true;
		}
		catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
            retVal = false;
        }
        return retVal;
    }
Ejemplo n.º 6
0
 public void UpdateRegionInfo(RegionInfo region, bool Disable)
 {
     List<object> Values = new List<object>();
     if (GetRegionInfo(region.RegionID) != null)
     {
         Values.Add(region.RegionName);
         Values.Add(region.RegionLocX);
         Values.Add(region.RegionLocY);
         Values.Add(region.InternalEndPoint.Address);
         Values.Add(region.InternalEndPoint.Port);
         if (region.FindExternalAutomatically)
         {
             Values.Add("DEFAULT");
         }
         else
         {
             Values.Add(region.ExternalHostName);
         }
         Values.Add(region.RegionType);
         Values.Add(region.ObjectCapacity);
         Values.Add(region.AccessLevel);
         Values.Add(Disable ? 1 : 0);
         Values.Add(region.AllowScriptCrossing ? 1 : 0);
         Values.Add(region.TrustBinariesFromForeignSims ? 1 : 0);
         Values.Add(region.SeeIntoThisSimFromNeighbor ? 1 : 0);
         Values.Add(region.AllowPhysicalPrims ? 1 : 0);
         GD.Update("simulator", Values.ToArray(), new string[]{"RegionName","RegionLocX",
         "RegionLocY","InternalIP","Port","ExternalIP","RegionType","MaxPrims","AccessLevel","Disabled"},
             new string[] { "RegionID" }, new object[] { region.RegionID });
     }
     else
     {
         Values.Add(region.RegionID);
         Values.Add(region.RegionName);
         Values.Add(region.RegionLocX);
         Values.Add(region.RegionLocY);
         Values.Add(region.InternalEndPoint.Address);
         Values.Add(region.InternalEndPoint.Port);
         if (region.FindExternalAutomatically)
         {
             Values.Add("DEFAULT");
         }
         else
         {
             Values.Add(region.ExternalHostName);
         }
         Values.Add(region.RegionType);
         Values.Add(region.ObjectCapacity);
         Values.Add(0);
         Values.Add(0);
         Values.Add(0);
         Values.Add(region.AccessLevel);
         Values.Add(Disable ? 1 : 0);
         Values.Add(region.AllowScriptCrossing ? 1 : 0);
         Values.Add(region.TrustBinariesFromForeignSims ? 1 : 0);
         Values.Add(region.SeeIntoThisSimFromNeighbor ? 1 : 0);
         Values.Add(region.AllowPhysicalPrims ? 1 : 0);
         GD.Insert("simulator", Values.ToArray());
     }
 }
Ejemplo n.º 7
0
    public bool PosTest2()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest2:Return the property IsMetric in RegionInfo object 2");
        try
        {
            RegionInfo regionInfo = new RegionInfo("zh-CN");
            bool boolVal = regionInfo.IsMetric;
            if (!boolVal)
            {
                TestLibrary.TestFramework.LogError("003", "the ExpectResult is false but the ActualResult is " + boolVal.ToString());
                retVal = false;
            }
        }
		catch (ArgumentException)
		{
			TestLibrary.TestFramework.LogInformation("The East Asian Languages are not installed. Skipping test(s)");
			retVal = true;
		}
		catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
            retVal = false;
        }
        return retVal;
    }
        public RegionInfo GetSelectedRegionInfo()
        {
            string regionPath = String.Empty;
            string country = Request.Form["country"];
            string province = Request.Form["province"];
            string city = Request.Form["city"];
            string county = Request.Form["county"];

            int curRegionId=0;

            if (curRegionId==0 && !String.IsNullOrEmpty(county))
                int.TryParse(county,out curRegionId);
            if (curRegionId == 0 && !String.IsNullOrEmpty(city))
                int.TryParse(city, out curRegionId);
            if (curRegionId == 0 && !String.IsNullOrEmpty(province))
                int.TryParse(province, out curRegionId);
            if (curRegionId == 0 && !String.IsNullOrEmpty(country))
                int.TryParse(country, out curRegionId);

            RegionInfo result = null;
            if (curRegionId >0)
            {
                result = new RegionInfo(curRegionId);
            }
            return result;
        }
Ejemplo n.º 9
0
    public bool PosTest1()
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest1:Invoke the method ToString in RegionInfo object 1");
		try
		{
			RegionInfo regionInfo = new RegionInfo("zh-CN");
			string strVal = regionInfo.ToString();
			if (strVal != regionInfo.Name)
			{
				TestLibrary.TestFramework.LogError("001", "the ExpectResult is" + regionInfo.Name + "but the ActualResult is" + strVal);
				retVal = false;
			}
		}
		catch (ArgumentException)
		{
			TestLibrary.TestFramework.LogInformation("The East Asian Languages are not installed. Skipping test(s)");
			retVal = true;
		}
		catch (Exception e)
		{
			TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
			retVal = false;
		}
        return retVal;
    }
Ejemplo n.º 10
0
	public bool PosTest2() 
    {
        bool retVal = true;
        TestLibrary.TestFramework.BeginScenario("PosTest2:Return the CurrencySymbol property in RegionInfo object 2");
        try
        {
            RegionInfo regionInfo = new RegionInfo("zh-CN");
            string strCurrencySymbol = regionInfo.CurrencySymbol;
            if (strCurrencySymbol != (TestLibrary.Utilities.IsVistaOrLater ? "\u00A5" : "\uFFE5"))
            {
				TestLibrary.TestFramework.LogError("003", "the ExpectResult is "+ (TestLibrary.Utilities.IsVista ? "\u00A5" : "\uFFE5") + " but the ActualResult is " + strCurrencySymbol);
				retVal = false;
            }
        }
		catch (ArgumentException)
		{
			TestLibrary.TestFramework.LogInformation("The East Asian Languages are not installed. Skipping test(s)");
			retVal = true;
		}
		catch (Exception e)
        {
            TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
            retVal = false;
        }
        return retVal;
    }
Ejemplo n.º 11
0
        public BackendResponse TryFetchRegion(UUID id, out RegionInfo region)
        {
            List<RegionInfo> regions;
            BackendResponse response = TryFetchRegionsFromGridService(out regions);

            if (response == BackendResponse.Success)
            {
                for (int i = 0; i < regions.Count; i++)
                {
                    if (regions[i].ID == id)
                    {
                        region = regions[i];
                        return BackendResponse.Success;
                    }
                }
            }
            else
            {
                region = default(RegionInfo);
                return response;
            }

            region = default(RegionInfo);
            return response;
        }
Ejemplo n.º 12
0
 public void Equals(RegionInfo regionInfo1, object obj, bool expected)
 {
     Assert.Equal(expected, regionInfo1.Equals(obj));
     Assert.Equal(regionInfo1.GetHashCode(), regionInfo1.GetHashCode());
     if (obj is RegionInfo)
     {
         Assert.Equal(expected, regionInfo1.GetHashCode().Equals(obj.GetHashCode()));
     }
 }
 public void UpdateRegionInfo(RegionInfo region)
 {
     List<object> Values = new List<object>();
     Values.Add(region.RegionID);
     Values.Add(region.RegionName);
     Values.Add(OSDParser.SerializeJsonString(region.PackRegionInfoData(true)));
     Values.Add(region.Disabled ? 1 : 0);
     GD.Replace("simulator", new string[]{"RegionID","RegionName",
         "RegionInfo","Disabled"}, Values.ToArray());
 }
 public void MiscTest(int lcid, int geoId, string currencyEnglishName, string alternativeCurrencyEnglishName, string currencyNativeName, string threeLetterISORegionName, string threeLetterWindowsRegionName)
 {
     RegionInfo ri = new RegionInfo(lcid); // create it with lcid
     Assert.Equal(geoId, ri.GeoId);
     Assert.True(currencyEnglishName.Equals(ri.CurrencyEnglishName) || 
                 alternativeCurrencyEnglishName.Equals(ri.CurrencyEnglishName), "Wrong currency English Name");
     Assert.Equal(currencyNativeName, ri.CurrencyNativeName);
     Assert.Equal(threeLetterISORegionName, ri.ThreeLetterISORegionName);
     Assert.Equal(threeLetterWindowsRegionName, ri.ThreeLetterWindowsRegionName);
 }
Ejemplo n.º 15
0
//        private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);

        public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
            StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)
        {
            HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager);

            return
                new HGScene(
                    regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager,
                    m_moduleLoader, false, m_configSettings.PhysicalPrim,
                    m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version);
        }
Ejemplo n.º 16
0
        public RegionInfo[] LoadRegions()
        {
            string regionConfigPath = Path.Combine(Util.configDir(), "Regions");

            try
            {
                IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"];
                regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim();
            }
            catch (Exception)
            {
                // No INI setting recorded.
            }

            if (!Directory.Exists(regionConfigPath))
            {
                Directory.CreateDirectory(regionConfigPath);
            }

            string[] configFiles = Directory.GetFiles(regionConfigPath, "*.xml");
            string[] iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");

            if (configFiles.Length == 0 && iniFiles.Length == 0)
            {
                new RegionInfo("DEFAULT REGION CONFIG", Path.Combine(regionConfigPath, "Regions.ini"), false, m_configSource);
                iniFiles = Directory.GetFiles(regionConfigPath, "*.ini");
            }

            List<RegionInfo> regionInfos = new List<RegionInfo>();

            int i = 0;
            foreach (string file in iniFiles)
            {
                IConfigSource source = new IniConfigSource(file);

                foreach (IConfig config in source.Configs)
                {
                    //m_log.Info("[REGIONLOADERFILESYSTEM]: Creating RegionInfo for " + config.Name);
                    RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource, config.Name);
                    regionInfos.Add(regionInfo);
                    i++;
                }
            }

            foreach (string file in configFiles)
            {
                RegionInfo regionInfo = new RegionInfo("REGION CONFIG #" + (i + 1), file, false, m_configSource);
                regionInfos.Add(regionInfo);
                i++;
            }

            return regionInfos.ToArray();
        }
Ejemplo n.º 17
0
        public RegionInfo[] LoadRegions()
        {
            if (m_configSource == null)
            {
                m_log.Error("[WEBLOADER]: Unable to load configuration source!");
                return null;
            }
            else
            {
                IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"];
                string url = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim();
                if (url == String.Empty)
                {
                    m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty.");
                    return null;
                }
                else
                {
                    HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(url);
                    webRequest.Timeout = 45000; //30 Second Timeout
                    m_log.Debug("[WEBLOADER]: Sending Download Request...");
                    HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse();
                    m_log.Debug("[WEBLOADER]: Downloading Region Information From Remote Server...");
                    StreamReader reader = new StreamReader(webResponse.GetResponseStream());
                    string xmlSource = String.Empty;
                    string tempStr = reader.ReadLine();
                    while (tempStr != null)
                    {
                        xmlSource = xmlSource + tempStr;
                        tempStr = reader.ReadLine();
                    }
                    m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
                                xmlSource.Length);
                    XmlDocument xmlDoc = new XmlDocument();
                    xmlDoc.LoadXml(xmlSource);
                    if (xmlDoc.FirstChild.Name == "Regions")
                    {
                        RegionInfo[] regionInfos = new RegionInfo[xmlDoc.FirstChild.ChildNodes.Count];
                        int i;
                        for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
                        {
                            m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
                            regionInfos[i] =
                                new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i],false,m_configSource);
                        }

                        return regionInfos;
                    }
                    return null;
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        ///     Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="configSource"></param>
        /// <returns></returns>
        protected IScene SetupScene(RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager();
            List<IClientNetworkServer> clientServers = AuroraModuleLoader.PickupModules<IClientNetworkServer>();
            List<IClientNetworkServer> allClientServers = new List<IClientNetworkServer>();
            foreach (IClientNetworkServer clientServer in clientServers)
            {
                clientServer.Initialise(MainServer.Instance.Port, m_configSource, circuitManager);
                allClientServers.Add(clientServer);
            }

            AsyncScene scene = new AsyncScene();
            scene.AddModuleInterfaces(m_openSimBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, circuitManager, allClientServers);

            return scene;
        }
Ejemplo n.º 19
0
        public void Start(IScene scene)
        {
            m_scene = scene;

            m_regionInfo = m_scene.GetSceneModule<RegionInfo>();
            m_permissions = m_scene.GetSceneModule<LLPermissions>();

            m_udp = m_scene.GetSceneModule<LLUDP>();
            if (m_udp != null)
            {
                m_udp.AddPacketHandler(PacketType.UseCircuitCode, UseCircuitCodeHandler);
                m_udp.AddPacketHandler(PacketType.CompleteAgentMovement, CompleteAgentMovementHandler);
                m_udp.AddPacketHandler(PacketType.LogoutRequest, LogoutRequestHandler);
                m_udp.AddPacketHandler(PacketType.AgentThrottle, AgentThrottleHandler);
                m_udp.AddPacketHandler(PacketType.RegionHandshakeReply, RegionHandshakeReplyHandler);
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        ///     Create a scene and its initial base structures.
        /// </summary>
        /// <param name="regionInfo"></param>
        /// <param name="configSource"></param>
        /// <returns></returns>
        public IScene CreateScene(ISimulationDataStore dataStore, RegionInfo regionInfo)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager();
            List<IClientNetworkServer> clientServers = AuroraModuleLoader.PickupModules<IClientNetworkServer>();
            List<IClientNetworkServer> allClientServers = new List<IClientNetworkServer>();
            foreach (IClientNetworkServer clientServer in clientServers)
            {
                clientServer.Initialise((uint)regionInfo.RegionPort, m_configSource, circuitManager);
                allClientServers.Add(clientServer);
            }

            AsyncScene scene = new AsyncScene();
            scene.AddModuleInterfaces(m_openSimBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, dataStore, circuitManager, allClientServers);

            return scene;
        }
        public void CurrentRegion()
        {
            CultureInfo oldThreadCulture = CultureInfo.CurrentCulture;

            try
            {
                CultureInfo.CurrentCulture = new CultureInfo("en-US");

                RegionInfo ri = new RegionInfo(new RegionInfo(CultureInfo.CurrentCulture.Name).TwoLetterISORegionName);
                Assert.True(RegionInfo.CurrentRegion.Equals(ri) || RegionInfo.CurrentRegion.Equals(new RegionInfo(CultureInfo.CurrentCulture.Name)));
                Assert.Same(RegionInfo.CurrentRegion, RegionInfo.CurrentRegion);
            }
            finally
            {
                CultureInfo.CurrentCulture = oldThreadCulture;
            }
        }
Ejemplo n.º 22
0
    public SortedList CountryList()
    {
        SortedList slCountry = new SortedList();
        string Key = "";
        string Value = "";

        foreach (CultureInfo info in CultureInfo.GetCultures(CultureTypes.SpecificCultures))
        {
            RegionInfo info2 = new RegionInfo(info.LCID);
            if (!slCountry.Contains(info2.EnglishName))
            {
                Value = info2.TwoLetterISORegionName;
                Key = info2.EnglishName;
                slCountry.Add(Key, Value);
            }
        }
        return slCountry;
    }
	// Register a culture and region with the current thread.
#if !ECMA_COMPAT
	public static void Register(CultureInfo culture, CultureInfo uiCulture,
							    RegionInfo region)
			{
				if(culture == null)
				{
					throw new ArgumentNullException("culture");
				}
				if(uiCulture == null)
				{
					throw new ArgumentNullException("uiCulture");
				}
				if(region == null)
				{
					throw new ArgumentNullException("region");
				}
				CultureInfo.SetCurrentCulture(culture);
				CultureInfo.SetCurrentUICulture(uiCulture);
				RegionInfo.currentRegion = region;
			}
Ejemplo n.º 24
0
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Return the property ISOCurrencySymbol in RegionInfo object 1");
     try
     {
         RegionInfo regionInfo = new RegionInfo("en-US");
         string strISOCurrency = regionInfo.ISOCurrencySymbol;
         if (strISOCurrency != "USD")
         {
             TestLibrary.TestFramework.LogError("001", "the ExpectResult is USD but the ActualResult is (" + strISOCurrency +")");
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Ejemplo n.º 25
0
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Return the property Name in RegionInfo object 1");
     try
     {
         RegionInfo regionInfo = new RegionInfo("en-US");
         string strName = regionInfo.Name;
         if (strName != "US")
         {
             TestLibrary.TestFramework.LogError("001", "the ExpectResult is en-US but the ActualResult is " + strName);
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Ejemplo n.º 26
0
 public bool PosTest1()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest1:Return the property IsMetric in RegionInfo object 1");
     try
     {
         RegionInfo regionInfo = new RegionInfo("en-US");
         bool boolVal = regionInfo.IsMetric;
         if (boolVal)
         {
             TestLibrary.TestFramework.LogError("001", "the ExpectResult is false but the ActualResult is " + boolVal.ToString());
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("002", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Ejemplo n.º 27
0
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Get the hash code of the RegionInfo object 2");
     try
     {
         RegionInfo regionInfo = new RegionInfo("en-US");
         int hashCode = regionInfo.GetHashCode();
         if (hashCode != regionInfo.Name.GetHashCode())
         {
             TestLibrary.TestFramework.LogError("003", "the ExpectResult is" + regionInfo.Name.GetHashCode() +"but the ActualResult is " + hashCode);
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
Ejemplo n.º 28
0
        /// <summary>
        ///   Create a scene and its initial base structures.
        /// </summary>
        /// <param name = "regionInfo"></param>
        /// <param name = "proxyOffset"></param>
        /// <param name = "configSource"></param>
        /// <param name = "clientServer"> </param>
        /// <returns></returns>
        protected IScene SetupScene(RegionInfo regionInfo, IConfigSource configSource)
        {
            AgentCircuitManager circuitManager = new AgentCircuitManager();
            List<IClientNetworkServer> clientServers = AuroraModuleLoader.PickupModules<IClientNetworkServer>();
            List<IClientNetworkServer> allClientServers = new List<IClientNetworkServer>();
            foreach (IClientNetworkServer clientServer in clientServers)
            {
                foreach (int port in regionInfo.UDPPorts)
                {
                    IClientNetworkServer copy = clientServer.Copy();
                    copy.Initialise(port, m_configSource, circuitManager);
                    allClientServers.Add(copy);
                }
            }

            Scene scene = new Scene();
            scene.AddModuleInterfaces(m_openSimBase.ApplicationRegistry.GetInterfaces());
            scene.Initialize(regionInfo, circuitManager, allClientServers);

            return scene;
        }
Ejemplo n.º 29
0
 public bool PosTest2()
 {
     bool retVal = true;
     TestLibrary.TestFramework.BeginScenario("PosTest2:Invoke the method ToString in RegionInfo object 2");
     try
     {
         RegionInfo regionInfo = new RegionInfo("en-US");
         string strVal = regionInfo.ToString();
         if (strVal != regionInfo.Name)
         {
             TestLibrary.TestFramework.LogError("003", "the ExpectResult is" + regionInfo.Name + "but the ActualResult is" + strVal);
             retVal = false;
         }
     }
     catch (Exception e)
     {
         TestLibrary.TestFramework.LogError("004", "Unexpect exception:" + e);
         retVal = false;
     }
     return retVal;
 }
 public void UpdateRegionInfo(RegionInfo region)
 {
     RegionInfo oldRegion = GetRegionInfo(region.RegionID);
     if (oldRegion != null)
     {
         m_registry.RequestModuleInterface<ISimulationBase>().EventManager.FireGenericEventHandler("RegionInfoChanged", new[] 
         {
             oldRegion,
             region
         });
     }
     List<object> Values = new List<object>
                               {
                                   region.RegionID,
                                   region.RegionName.MySqlEscape(50),
                                   OSDParser.SerializeJsonString(region.PackRegionInfoData(true)),
                                   region.Disabled ? 1 : 0
                               };
     GD.Replace("simulator", new[]{"RegionID","RegionName",
         "RegionInfo","Disabled"}, Values.ToArray());
 }
Ejemplo n.º 31
0
        public async Task <ActionResult> CreatePayment()
        {
            var accessToken = await GetAccessToken();

            var currentUser = await _workContext.GetCurrentUser();

            var cart = await _cartService.GetCart(currentUser.Id);

            var regionInfo = new RegionInfo(CultureInfo.CurrentCulture.LCID);

            if (string.IsNullOrWhiteSpace(_setting.Value.ExperienceProfileId))
            {
                _setting.Value.ExperienceProfileId = await CreateExperienceProfile();

                var stripeProvider = await _paymentProviderRepository.Query().FirstOrDefaultAsync(x => x.Id == PaymentProviderHelper.PaypalExpressProviderId);

                stripeProvider.AdditionalSettings = JsonConvert.SerializeObject(_setting.Value);
                await _paymentProviderRepository.SaveChangesAsync();
            }

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
            var paymentCreateRequest = new PaymentCreateRequest
            {
                // experience_profile_id = _setting.Value.ExperienceProfileId,
                intent = "sale",
                payer  = new Payer
                {
                    payment_method = "paypal"
                },
                transactions = new Transaction[]
                {
                    new Transaction {
                        amount = new Amount
                        {
                            total    = cart.OrderTotal.ToString(),
                            currency = regionInfo.ISOCurrencySymbol,
                            details  = new Details
                            {
                                subtotal = cart.SubTotalWithDiscount.ToString(),
                                tax      = cart.TaxAmount.ToString(),
                                shipping = cart.ShippingAmount.ToString()
                            }
                        }
                    }
                },
                redirect_urls = new Redirect_Urls
                {
                    cancel_url = "http://localhost:49209/PaypalExpress/Cancel",
                    return_url = "http://localhost:49209/PaypalExpress/Success",
                }
            };

            var response = await httpClient.PostJsonAsync($"https://api{_setting.Value.EnvironmentUrlPart}.paypal.com/v1/payments/payment", paymentCreateRequest);

            var responseBody = await response.Content.ReadAsStringAsync();

            dynamic payment = JObject.Parse(responseBody);
            // Has to explicitly declare the type to be able to get the propery
            string paymentId = payment.id;

            return(Ok(new { PaymentId = paymentId, Debug = responseBody }));
        }
Ejemplo n.º 32
0
 public Squadron(string name, TemporalRole role, RegionInfo country, ICitation citation, IAudit audit) : base(name, role, country, DEFAULT_CONTROL_RANGE, DEFAULT_INFLUENCE_RANGE, citation, audit)
 {
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Creates and initializes a new instance of class Money, with the
 /// specified units and currency code from the region information.
 /// </summary>
 /// <remarks>
 /// The amount of money will be rounded to the number of decimal digits of the currency.
 /// If value is halfway between two numbers, the even number is returned; that is, 4.555
 /// is converted to 4.56, and 5.585 is converted to 5.58.
 /// </remarks>
 /// <param name="value">The amount of money, subject to rounding.</param>
 /// <param name="regionInfo">Region information for the currency</param>
 public Money(double value, RegionInfo regionInfo) : this(value, regionInfo.ISOCurrencySymbol)
 {
 }
Ejemplo n.º 34
0
        public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
        {
            //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);

            List <GridRegion> neighbours
                = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);

            m_log.DebugFormat(
                "[SCENE COMMUNICATION SERVICE]: Informing {0} neighbours that region {1} is up",
                neighbours.Count, m_scene.Name);

            foreach (GridRegion n in neighbours)
            {
                InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
                d.BeginInvoke(neighbourService, region, n.RegionHandle,
                              InformNeighborsThatRegionisUpCompleted,
                              d);
            }
        }
Ejemplo n.º 35
0
        /// <summary>
        /// Recursive SendGridInstantMessage over XMLRPC method.
        /// This is called from within a dedicated thread.
        /// The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from
        /// itself, prevRegionHandle will be the last region handle that we tried to send.
        /// If the handles are the same, we look up the user's location using the grid.
        /// If the handles are still the same, we end.  The send failed.
        /// </summary>
        /// <param name="prevRegionHandle">
        /// Pass in 0 the first time this method is called.  It will be called recursively with the last
        /// regionhandle tried
        /// </param>
        protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result,
                                                                    ulong prevRegionHandle, int tries)
        {
            UserAgentData upd         = null;
            bool          lookupAgent = false;
            UUID          toAgentID   = new UUID(im.toAgentID);

            if (tries > 5)
            {
                m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Retries exhausted - Unable to deliver an instant message to {0}", toAgentID.ToString());
                return;
            }

            if (m_DebugLevel >= 2)
            {
                m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} tries={1}", prevRegionHandle, tries);
            }

            lock (m_UserRegionMap)
            {
                if (m_UserRegionMap.ContainsKey(toAgentID))
                {
                    upd             = new UserAgentData();
                    upd.AgentOnline = true;
                    upd.Handle      = m_UserRegionMap[toAgentID];

                    // We need to compare the current regionhandle with the previous region handle
                    // or the recursive loop will never end because it will never try to lookup the agent again
                    if (prevRegionHandle == upd.Handle)
                    {
                        lookupAgent = true;
                        if (m_DebugLevel >= 2)
                        {
                            m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} tries={1} in region map, same region, requires lookup", prevRegionHandle, tries);
                        }
                    }
                    else
                    if (prevRegionHandle == 0)
                    {
                        if (m_DebugLevel >= 1)
                        {
                            m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} tries={1} in region map, using {2}, no lookup", prevRegionHandle, tries, upd.Handle);
                        }
                    }
                    else
                    {
                        if (m_DebugLevel >= 1)
                        {
                            m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} tries={1} in region map, different region, no lookup", prevRegionHandle, tries);
                        }
                    }
                }
                else
                {
                    lookupAgent = true;
                    if (m_DebugLevel >= 2)
                    {
                        m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} tries={1} not in region map, requires lookup", prevRegionHandle, tries);
                    }
                }
            }

            // Are we needing to look-up an agent?
            if (lookupAgent)
            {
                // Non-cached user agent lookup.
                upd = m_Scenes[0].CommsManager.UserService.GetUserAgent(toAgentID);

                if (upd != null)
                {
                    // check if we've tried this before..
                    // This is one way to end the recursive loop
                    //
                    if (upd.Handle == prevRegionHandle)
                    {
                        if (m_DebugLevel >= 1)
                        {
                            m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} still, tries={1}", upd.Handle, tries);
                        }
                        HandleUndeliveredMessage(im, result);
                        return;
                    }
                    else
                    {
                        if (m_DebugLevel >= 1)
                        {
                            m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} now, tries={1} lookup success", upd.Handle, tries);
                        }
                    }
                }
                else
                {
                    m_log.ErrorFormat("[GRID INSTANT MESSAGE]: Unable to deliver an instant message to {0} (user lookup failed).", toAgentID.ToString());
                    HandleUndeliveredMessage(im, result);
                    return;
                }
            }

            if (upd != null)
            {
                if (upd.AgentOnline)
                {
                    RegionInfo reginfo = m_Scenes[0].SceneGridService.RequestNeighbouringRegionInfo(upd.Handle);
                    if (reginfo != null)
                    {
                        if (m_DebugLevel >= 2)
                        {
                            m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} now, sending grid IM", upd.Handle);
                        }
                        Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
                        // Not actually used anymore, left in for compatibility
                        // Remove at next interface change
                        //
                        msgdata["region_handle"] = 0;
                        bool imresult = doIMSending(reginfo, msgdata);
                        if (imresult)
                        {
                            // IM delivery successful, so store the Agent's location in our local cache.
                            lock (m_UserRegionMap)
                            {
                                if (m_UserRegionMap.ContainsKey(toAgentID))
                                {
                                    m_UserRegionMap[toAgentID] = upd.Handle;
                                    if (m_DebugLevel >= 1)
                                    {
                                        m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} success, updating map", upd.Handle);
                                    }
                                }
                                else
                                {
                                    m_UserRegionMap.Add(toAgentID, upd.Handle);
                                    if (m_DebugLevel >= 1)
                                    {
                                        m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} success, adding to map", upd.Handle);
                                    }
                                }
                            }
                            result(true);
                        }
                        else
                        {
                            // try again, but lookup user this time.
                            // Warning, this must call the Async version
                            // of this method or we'll be making thousands of threads
                            // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
                            // The version that spawns the thread is SendGridInstantMessageViaXMLRPC

                            // This is recursive!!!!!
                            if (m_DebugLevel >= 2)
                            {
                                m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} failed, retrying recursively", upd.Handle);
                            }
                            SendGridInstantMessageViaXMLRPCAsync(im, result, upd.Handle, ++tries);
                        }
                    }
                    else
                    {
                        if (m_DebugLevel >= 2)
                        {
                            m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}, will retry", upd.Handle);
                        }
                        SendGridInstantMessageViaXMLRPCAsync(im, result, upd.Handle, ++tries);
                    }
                }
                else
                {
                    if (m_DebugLevel >= 1)
                    {
                        m_log.ErrorFormat("[GRID INSTANT MESSAGE]: region={0} user offline.", upd.Handle);
                    }
                    HandleUndeliveredMessage(im, result);
                }
            }
            else
            {
                if (m_DebugLevel >= 1)
                {
                    m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find user {0}", toAgentID);
                }
                HandleUndeliveredMessage(im, result);
            }
        }
Ejemplo n.º 36
0
        public void CommitTaxes(Order order, HccRequestContext hccContext)
        {
            try
            {
                var memberShipService = Factory.CreateService <MembershipServices>(hccContext);
                var contactService    = Factory.CreateService <ContactService>(hccContext);
                var orderService      = Factory.CreateService <OrderService>(hccContext);

                // write down the business logic to commit taxes

                var docCode      = string.Empty;
                var customerCode = GetCustomerCode(order);
                var companyCode  = string.Empty;

                var currencyCode = "USD";
                var ri           = new RegionInfo(hccContext.CurrentStore.Settings.CurrencyCultureCode);

                if (ri != null)
                {
                    currencyCode = ri.ISOCurrencySymbol;
                }

                var             taxExemptUser      = false;
                var             taxExemptionNumber = string.Empty;
                CustomerAccount customer           = null;

                if (!string.IsNullOrEmpty(order.UserID))
                {
                    customer = memberShipService.Customers.Find(order.UserID);
                }
                else if (!string.IsNullOrEmpty(order.UserEmail))
                {
                    customer = memberShipService.Customers.FindByEmail(order.UserEmail).FirstOrDefault();
                }

                if (customer != null && customer.TaxExempt)
                {
                    taxExemptUser      = true;
                    taxExemptionNumber = customer.TaxExemptionNumber;
                }

                //The only difference here is that we are using a SalesInvoice instead of SalesOrder
                var     originationAddress = ConvertAddressToTaxProvider(contactService.Addresses.FindStoreContactAddress());
                Address destination;

                if (order.HasShippingItems)
                {
                    destination = order.ShippingAddress;
                }
                else
                {
                    destination = order.BillingAddress;
                }

                var destinationAddress = ConvertAddressToTaxProvider(destination);
                var applyVATRules      = hccContext.CurrentStore.Settings.ApplyVATRules;
                var lines = ConvertOrderLines(order, orderService, applyVATRules, hccContext.CurrentStore.Id);

                var hccAvaTax = MyTaxProviderGateWay(hccContext.CurrentStore);

                var result = hccAvaTax.GetTax(DocumentType.SalesInvoice, companyCode, order.bvin,
                                              originationAddress, destinationAddress, lines, order.TotalOrderDiscounts,
                                              customerCode, currencyCode,
                                              taxExemptUser, taxExemptionNumber, applyVATRules);

                if (result.Success)
                {
                    docCode = result.DocCode;
                }

                var totalTax = result.TotalTax;

                result = hccAvaTax.PostTax(companyCode, docCode, DocumentType.SalesInvoice, result.TotalAmount,
                                           result.TotalTax);

                if (result != null)
                {
                    if (result.Success)
                    {
                        order.CustomProperties.SetProperty("hcc", TaxProviderPropertyName, result.DocCode);
                        orderService.Orders.Update(order);
                    }
                    else
                    {
                        var note = "MyTaxProvider - Commit Tax Failed (POST):";

                        foreach (var m in result.Messages)
                        {
                            note += "\n" + m;
                        }

                        order.Notes.Add(new OrderNote
                        {
                            IsPublic = false,
                            Note     = note
                        });

                        orderService.Orders.Update(order);

                        EventLog.LogEvent("MyTaxProvider", note, EventLogSeverity.Error);
                    }
                }

                result = hccAvaTax.CommitTax(companyCode, docCode, DocumentType.SalesInvoice);
            }
            catch (Exception ex)
            {
                EventLog.LogEvent(ex);
            }
        }
Ejemplo n.º 37
0
 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
 {
 }
Ejemplo n.º 38
0
 /// <summary>
 /// GetPaperSize gets the RegionPaperSize for the RegionInfo
 /// </summary>
 /// <param name="regionInfo">The RegionInfo to get the RegionPaperSize for</param>
 /// <returns>The RegionPaperSize for the RegionInfo</returns>
 public static RegionPaperSize GetPaperSize(this RegionInfo regionInfo)
 {
     return(RegionExtensions.GetPaperSize(regionInfo.TwoLetterISORegionName));
 }
Ejemplo n.º 39
0
 /// <summary>
 /// GetDayOfWeek gets the first DayOfWeek for the RegionInfo
 /// </summary>
 /// <param name="regionInfo">The RegionInfo to get the first DayOfWeek for</param>
 /// <returns>The first DayOfWeek for the RegionInfo</returns>
 public static DayOfWeek GetDayOfWeek(this RegionInfo regionInfo)
 {
     return(RegionExtensions.GetFirstDayOfWeek(regionInfo.TwoLetterISORegionName));
 }
Ejemplo n.º 40
0
 /// <summary>
 /// GetMeasurementSystem gets the MeasurementSystem for the RegionInfo
 /// </summary>
 /// <param name="regionInfo">The RegionInfo to get the MeasurementSystem for</param>
 /// <returns>The MeasurementSystem for the RegionInfo</returns>
 public static RegionMeasurementSystem GetMeasurementSystem(this RegionInfo regionInfo)
 {
     return(RegionExtensions.GetMeasurementSystem(regionInfo.TwoLetterISORegionName));
 }
Ejemplo n.º 41
0
 /// <summary>
 /// GetRegionInformation gets the RegionInformation for the RegionInfo
 /// </summary>
 /// <param name="regionInfo">The RegionInfo to get the RegionInformation for</param>
 /// <returns>The RegionInformation for the RegionInfo</returns>
 public static RegionInformation GetRegionInformation(this RegionInfo regionInfo)
 {
     return(RegionExtensions.GetRegionInformation(regionInfo.TwoLetterISORegionName));
 }
Ejemplo n.º 42
0
 /// <summary>
 /// GetTelephoneCode gets the telephone code used by the RegionInfo
 /// </summary>
 /// <param name="regionInfo">The RegionInfo to get the telephone code for</param>
 /// <returns>The telephone code used by the RegionInfo</returns>
 /// <remarks>GetTelephoneCode gets only the first telephone code used by the region.
 /// There is only one telephone code when a region is a country/region. Only when a region
 /// is larger than a country/region (e.g. The World) will it have more than one telephone code.</remarks>
 public static string GetTelephoneCode(this RegionInfo regionInfo)
 {
     return(RegionExtensions.GetTelephoneCode(regionInfo.TwoLetterISORegionName));
 }
        /// <summary>
        /// Recursive SendGridInstantMessage over XMLRPC method.
        /// This is called from within a dedicated thread.
        /// The first time this is called, prevRegionHandle will be 0 Subsequent times this is called from
        /// itself, prevRegionHandle will be the last region handle that we tried to send.
        /// If the handles are the same, we look up the user's location using the grid.
        /// If the handles are still the same, we end.  The send failed.
        /// </summary>
        /// <param name="prevRegionHandle">
        /// Pass in 0 the first time this method is called.  It will be called recursively with the last
        /// regionhandle tried
        /// </param>
        protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, ulong prevRegionHandle)
        {
            UUID toAgentID = new UUID(im.toAgentID);

            UserAgentData upd = null;

            bool lookupAgent = false;

            lock (m_UserRegionMap)
            {
                if (m_UserRegionMap.ContainsKey(toAgentID))
                {
                    upd             = new UserAgentData();
                    upd.AgentOnline = true;
                    upd.Handle      = m_UserRegionMap[toAgentID];

                    // We need to compare the current regionhandle with the previous region handle
                    // or the recursive loop will never end because it will never try to lookup the agent again
                    if (prevRegionHandle == upd.Handle)
                    {
                        lookupAgent = true;
                    }
                }
                else
                {
                    lookupAgent = true;
                }
            }


            // Are we needing to look-up an agent?
            if (lookupAgent)
            {
                // Non-cached user agent lookup.
                upd = m_Scenes[0].CommsManager.UserService.GetAgentByUUID(toAgentID);

                if (upd != null)
                {
                    // check if we've tried this before..
                    // This is one way to end the recursive loop
                    //
                    if (upd.Handle == prevRegionHandle)
                    {
                        m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
                        HandleUndeliveredMessage(im, result);
                        return;
                    }
                }
                else
                {
                    m_log.Error("[GRID INSTANT MESSAGE]: Unable to deliver an instant message");
                    HandleUndeliveredMessage(im, result);
                    return;
                }
            }

            if (upd != null)
            {
                if (upd.AgentOnline)
                {
                    RegionInfo reginfo = m_Scenes[0].SceneGridService.RequestNeighbouringRegionInfo(upd.Handle);
                    if (reginfo != null)
                    {
                        Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im);
                        // Not actually used anymore, left in for compatibility
                        // Remove at next interface change
                        //
                        msgdata["region_handle"] = 0;
                        bool imresult = doIMSending(reginfo, msgdata);
                        if (imresult)
                        {
                            // IM delivery successful, so store the Agent's location in our local cache.
                            lock (m_UserRegionMap)
                            {
                                if (m_UserRegionMap.ContainsKey(toAgentID))
                                {
                                    m_UserRegionMap[toAgentID] = upd.Handle;
                                }
                                else
                                {
                                    m_UserRegionMap.Add(toAgentID, upd.Handle);
                                }
                            }
                            result(true);
                        }
                        else
                        {
                            // try again, but lookup user this time.
                            // Warning, this must call the Async version
                            // of this method or we'll be making thousands of threads
                            // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync
                            // The version that spawns the thread is SendGridInstantMessageViaXMLRPC

                            // This is recursive!!!!!
                            SendGridInstantMessageViaXMLRPCAsync(im, result,
                                                                 upd.Handle);
                        }
                    }
                    else
                    {
                        m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.Handle);
                        HandleUndeliveredMessage(im, result);
                    }
                }
                else
                {
                    HandleUndeliveredMessage(im, result);
                }
            }
            else
            {
                m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find user {0}", toAgentID);
                HandleUndeliveredMessage(im, result);
            }
        }
Ejemplo n.º 44
0
        public static Money None => new Money(0, default(string)); // None, Empty, Void

        /// <summary>
        /// Gets a value representing zero money in the specified region.
        /// </summary>
        public static Money Zero(RegionInfo regionInfo) => new Money(0, regionInfo);
Ejemplo n.º 45
0
        public RegionInfo[] LoadRegions()
        {
            if (m_configSource == null)
            {
                m_log.Error("[WEBLOADER]: Unable to load configuration source!");
                return(null);
            }
            else
            {
                IConfig startupConfig   = (IConfig)m_configSource.Configs["Startup"];
                string  url             = startupConfig.GetString("regionload_webserver_url", String.Empty).Trim();
                bool    allowRegionless = startupConfig.GetBoolean("allow_regionless", false);

                if (url == String.Empty)
                {
                    m_log.Error("[WEBLOADER]: Unable to load webserver URL - URL was empty.");
                    return(null);
                }
                else
                {
                    RegionInfo[]   regionInfos = new RegionInfo[] {};
                    int            regionCount = 0;
                    HttpWebRequest webRequest  = (HttpWebRequest)WebRequest.Create(url);
                    webRequest.Timeout = 30000; //30 Second Timeout
                    m_log.DebugFormat("[WEBLOADER]: Sending download request to {0}", url);

                    try
                    {
                        string xmlSource = String.Empty;

                        using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
                        {
                            m_log.Debug("[WEBLOADER]: Downloading region information...");

                            using (Stream s = webResponse.GetResponseStream())
                            {
                                using (StreamReader reader = new StreamReader(s))
                                {
                                    string tempStr = reader.ReadLine();
                                    while (tempStr != null)
                                    {
                                        xmlSource = xmlSource + tempStr;
                                        tempStr   = reader.ReadLine();
                                    }
                                }
                            }
                        }

                        m_log.Debug("[WEBLOADER]: Done downloading region information from server. Total Bytes: " +
                                    xmlSource.Length);
                        XmlDocument xmlDoc = new XmlDocument();
                        xmlDoc.LoadXml(xmlSource);
                        if (xmlDoc.FirstChild.Name == "Nini")
                        {
                            regionCount = xmlDoc.FirstChild.ChildNodes.Count;

                            if (regionCount > 0)
                            {
                                regionInfos = new RegionInfo[regionCount];
                                int i;
                                for (i = 0; i < xmlDoc.FirstChild.ChildNodes.Count; i++)
                                {
                                    m_log.Debug(xmlDoc.FirstChild.ChildNodes[i].OuterXml);
                                    regionInfos[i] =
                                        new RegionInfo("REGION CONFIG #" + (i + 1), xmlDoc.FirstChild.ChildNodes[i], false, m_configSource);
                                }
                            }
                        }
                    }
                    catch (WebException ex)
                    {
                        using (HttpWebResponse response = (HttpWebResponse)ex.Response)
                        {
                            if (response.StatusCode == HttpStatusCode.NotFound)
                            {
                                if (!allowRegionless)
                                {
                                    throw ex;
                                }
                            }
                            else
                            {
                                throw ex;
                            }
                        }
                    }

                    if (regionCount > 0 | allowRegionless)
                    {
                        return(regionInfos);
                    }
                    else
                    {
                        m_log.Error("[WEBLOADER]: No region configs were available.");
                        return(null);
                    }
                }
            }
        }
Ejemplo n.º 46
0
        public override byte[] Handle(string path, Stream request,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            byte[] result = new byte[0];

            UUID   regionID;
            string action;
            ulong  regionHandle;

            if (RestHandlerUtils.GetParams(path, out regionID, out regionHandle, out action))
            {
                m_log.InfoFormat("[RegionPostHandler]: Invalid parameters for neighbour message {0}", path);
                httpResponse.StatusCode        = (int)HttpStatusCode.BadRequest;
                httpResponse.StatusDescription = "Invalid parameters for neighbour message " + path;

                return(result);
            }

            if (m_AuthenticationService != null)
            {
                // Authentication
                string authority = string.Empty;
                string authToken = string.Empty;
                if (!RestHandlerUtils.GetAuthentication(httpRequest, out authority, out authToken))
                {
                    m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message {0}", path);
                    httpResponse.StatusCode = (int)HttpStatusCode.Unauthorized;
                    return(result);
                }
                // TODO: Rethink this
                //if (!m_AuthenticationService.VerifyKey(regionID, authToken))
                //{
                //    m_log.InfoFormat("[RegionPostHandler]: Authentication failed for neighbour message {0}", path);
                //    httpResponse.StatusCode = (int)HttpStatusCode.Forbidden;
                //    return result;
                //}
                m_log.DebugFormat("[RegionPostHandler]: Authentication succeeded for {0}", regionID);
            }

            OSDMap args = Util.GetOSDMap(request, (int)httpRequest.ContentLength);

            if (args == null)
            {
                httpResponse.StatusCode        = (int)HttpStatusCode.BadRequest;
                httpResponse.StatusDescription = "Unable to retrieve data";
                m_log.DebugFormat("[RegionPostHandler]: Unable to retrieve data for post {0}", path);
                return(result);
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;

            if (args["destination_handle"] != null)
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            RegionInfo aRegion = new RegionInfo();

            try
            {
                aRegion.UnpackRegionInfoData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[RegionPostHandler]: exception on unpacking region info {0}", ex.Message);
                httpResponse.StatusCode        = (int)HttpStatusCode.BadRequest;
                httpResponse.StatusDescription = "Problems with data deserialization";
                return(result);
            }

            // Finally!
            GridRegion thisRegion = m_NeighbourService.HelloNeighbour(regionhandle, aRegion);

            OSDMap resp = new OSDMap(1);

            if (thisRegion != null)
            {
                resp["success"] = OSD.FromBoolean(true);
            }
            else
            {
                resp["success"] = OSD.FromBoolean(false);
            }

            httpResponse.StatusCode = (int)HttpStatusCode.OK;

            return(Util.UTF8.GetBytes(OSDParser.SerializeJsonString(resp)));
        }
Ejemplo n.º 47
0
 public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
 {
 }
Ejemplo n.º 48
0
 public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
 {
 }
Ejemplo n.º 49
0
        public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
        {
            //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
            if (neighbourService == null)
            {
                m_log.ErrorFormat("{0} No neighbour service provided for region {1} to inform neigbhours of status", LogHeader, m_scene.Name);
                return;
            }

            List <GridRegion> neighbours
                = m_scene.GridService.GetNeighbours(m_scene.RegionInfo.ScopeID, m_scene.RegionInfo.RegionID);

            List <ulong> onlineNeighbours = new List <ulong>();

            foreach (GridRegion n in neighbours)
            {
                //m_log.DebugFormat(
                //   "{0}: Region flags for {1} as seen by {2} are {3}",
                //    LogHeader, n.RegionName, m_scene.Name, regionFlags != null ? regionFlags.ToString() : "not present");

                // Robust services before 2015-01-14 do not return the regionFlags information.  In this case, we could
                // make a separate RegionFlags call but this would involve a network call for each neighbour.
                if (n.RegionFlags != null)
                {
                    if ((n.RegionFlags & OpenSim.Framework.RegionFlags.RegionOnline) != 0)
                    {
                        onlineNeighbours.Add(n.RegionHandle);
                    }
                }
                else
                {
                    onlineNeighbours.Add(n.RegionHandle);
                }
            }

            if (onlineNeighbours.Count > 0)
            {
                Util.FireAndForget(o =>
                {
                    foreach (ulong regionhandle in onlineNeighbours)
                    {
                        Util.RegionHandleToRegionLoc(regionhandle, out uint rx, out uint ry);
                        GridRegion neighbour = neighbourService.HelloNeighbour(regionhandle, region);
                        if (neighbour != null)
                        {
                            m_log.DebugFormat("{0} Region {1} successfully informed neighbour {2} at {3}-{4} that it is up",
                                              LogHeader, m_scene.Name, neighbour.RegionName, rx, ry);

                            m_scene.EventManager.TriggerOnRegionUp(neighbour);
                        }
                        else
                        {
                            m_log.WarnFormat("{0} Region {1} failed to inform neighbour at {2}-{3} that it is up.",
                                             LogHeader, m_scene.Name, rx, ry);
                        }
                    }
                });
            }
        }
Ejemplo n.º 50
0
 /// <summary>
 /// GetHour gets the RegionHour for the RegionInfo
 /// </summary>
 /// <param name="regionInfo">The RegionInfo to get the RegionHour for</param>
 /// <returns>The RegionHour for the RegionInfo</returns>
 public static RegionHour GetHour(this RegionInfo regionInfo)
 {
     return(RegionExtensions.GetHour(regionInfo.TwoLetterISORegionName));
 }
Ejemplo n.º 51
0
 public void MoveAgentIntoRegion(RegionInfo regInfo, OpenMetaverse.Vector3 pos, OpenMetaverse.Vector3 look)
 {
 }
Ejemplo n.º 52
0
 public void SendParcelInfo(RegionInfo info, LandData land, OpenMetaverse.UUID parcelID, uint x, uint y)
 {
 }
Ejemplo n.º 53
0
 public void SetScene(Scene s)
 {
     m_scene      = s;
     m_regionInfo = s.RegionInfo;
 }
Ejemplo n.º 54
0
        /// <summary>
        /// Asynchronous call to information neighbouring regions that this region is up
        /// </summary>
        /// <param name="region"></param>
        /// <param name="regionhandle"></param>
        private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
        {
            uint x = 0, y = 0;

            Utils.LongToUInts(regionhandle, out x, out y);

            GridRegion neighbour = null;

            if (neighbourService != null)
            {
                neighbour = neighbourService.HelloNeighbour(regionhandle, region);
            }
            else
            {
                m_log.DebugFormat(
                    "[SCENE COMMUNICATION SERVICE]: No neighbour service provided for region {0} to inform neigbhours of status",
                    m_scene.Name);
            }

            if (neighbour != null)
            {
                m_log.DebugFormat(
                    "[SCENE COMMUNICATION SERVICE]: Region {0} successfully informed neighbour {1} at {2}-{3} that it is up",
                    m_scene.Name, neighbour.RegionName, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));

                m_scene.EventManager.TriggerOnRegionUp(neighbour);
            }
            else
            {
                m_log.WarnFormat(
                    "[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
                    m_scene.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
            }
        }
Ejemplo n.º 55
0
        /// <summary>
        /// All cultures for a region.
        /// </summary>
        /// <param name="region"></param>
        /// <returns></returns>
        public static List <CultureInfo> RegionCultures(this RegionInfo region)
        {
            List <CultureInfo> cultures = System.Threading.Thread.CurrentThread.CurrentUICulture.GetCultures();

            return((from CultureInfo c in cultures where c.EnglishName == region.EnglishName select c).ToList());
        }
 protected static int CompareByName(RegionInfo region1, RegionInfo region2)
 {
     return(string.Compare(region1.DisplayName, region2.DisplayName));
 }
Ejemplo n.º 57
0
 public abstract SceneInterface Instantiate(RegionInfo ri);
Ejemplo n.º 58
0
        private void LoadStore(int storeId, int regionId)
        {
            ViewData["storeId"] = storeId;

            List <SelectListItem> storeRankList = new List <SelectListItem>();

            storeRankList.Add(new SelectListItem()
            {
                Text = "选择店铺等级", Value = "-1"
            });
            foreach (StoreRankInfo storeRankInfo in AdminStoreRanks.GetStoreRankList())
            {
                storeRankList.Add(new SelectListItem()
                {
                    Text = storeRankInfo.Title, Value = storeRankInfo.StoreRid.ToString()
                });
            }
            ViewData["storeRankList"] = storeRankList;


            List <SelectListItem> storeIndustryList = new List <SelectListItem>();

            storeIndustryList.Add(new SelectListItem()
            {
                Text = "选择店铺行业", Value = "-1"
            });
            foreach (StoreIndustryInfo storeIndustryInfo in AdminStoreIndustries.GetStoreIndustryList())
            {
                storeIndustryList.Add(new SelectListItem()
                {
                    Text = storeIndustryInfo.Title, Value = storeIndustryInfo.StoreIid.ToString()
                });
            }
            ViewData["storeIndustryList"] = storeIndustryList;

            List <SelectListItem> themeList = new List <SelectListItem>();
            DirectoryInfo         dir       = new DirectoryInfo(IOHelper.GetMapPath("/themes"));

            foreach (DirectoryInfo themeDir in dir.GetDirectories())
            {
                themeList.Add(new SelectListItem()
                {
                    Text = themeDir.Name, Value = themeDir.Name
                });
            }
            ViewData["themeList"] = themeList;

            RegionInfo regionInfo = Regions.GetRegionById(regionId);

            if (regionInfo != null)
            {
                ViewData["provinceId"] = regionInfo.ProvinceId;
                ViewData["cityId"]     = regionInfo.CityId;
                ViewData["countyId"]   = regionInfo.RegionId;
            }
            else
            {
                ViewData["provinceId"] = -1;
                ViewData["cityId"]     = -1;
                ViewData["countyId"]   = -1;
            }

            ViewData["allowImgType"] = BMAConfig.UploadConfig.UploadImgType.Replace(".", "");
            ViewData["maxImgSize"]   = BMAConfig.UploadConfig.UploadImgSize;
            ViewData["referer"]      = MallUtils.GetMallAdminRefererCookie();
        }
Ejemplo n.º 59
0
 /// <summary>
 /// GetPostcodeRegex gets the postal code regular expression for the RegionInfo
 /// </summary>
 /// <param name="regionInfo">The RegionInfo to get the postal code regular expression for</param>
 /// <returns>The postal code regular expression for the RegionInfo</returns>
 public static string GetPostcodeRegex(this RegionInfo regionInfo)
 {
     return(RegionExtensions.GetPostcodeRegex(regionInfo.TwoLetterISORegionName));
 }
Ejemplo n.º 60
0
 /// <summary>
 /// Creates and initializes a new instance of class Money, with the
 /// specified units and currency code from the region information.
 /// </summary>
 /// <remarks>
 /// Parameter <see cref="Units"/> should be specified in the fractional currency part.
 /// For example, USD 2.45 as 245, or JPY 5 as 5, or JOD 11.427 as 11427.
 /// </remarks>
 /// <param name="units">The amount of money in the fractional part of the currency, for example cents for USD.</param>
 /// <param name="regionInfo">Region information for the currency</param>
 public Money(long units, RegionInfo regionInfo) : this(units, regionInfo.ISOCurrencySymbol)
 {
 }