/// <summary>
        /// Updates the geoblock configuration using the module service
        /// </summary>
        /// <param name="updatedGeoblockConfiguration">The new geoblock configuration</param>
        public void UpdateGeoblockConfiguration(GeoblockConfiguration updatedGeoblockConfiguration)
        {
            PropertyBag config = new PropertyBag();

            config.Add(0, updatedGeoblockConfiguration.Enabled);
            config.Add(1, updatedGeoblockConfiguration.DenyAction);
            config.Add(2, updatedGeoblockConfiguration.GeoIpFilepath);
            config.Add(3, updatedGeoblockConfiguration.VerifyAll);
            config.Add(4, updatedGeoblockConfiguration.AllowedMode);

            ArrayList countries = new ArrayList();

            foreach (Country country in updatedGeoblockConfiguration.SelectedCountryCodes)
            {
                PropertyBag item = new PropertyBag();
                item.Add(0, country.CountryCode);
                countries.Add(item);
            }
            config.Add(5, countries);

            ArrayList exceptionRules = new ArrayList();

            foreach (ExceptionRule exceptionRule in updatedGeoblockConfiguration.ExceptionRules)
            {
                PropertyBag item = new PropertyBag();
                item.Add(0, exceptionRule.AllowedMode);
                item.Add(1, exceptionRule.IpAddress);
                item.Add(2, exceptionRule.Mask);
                exceptionRules.Add(item);
            }
            config.Add(6, exceptionRules);

            Invoke("UpdateGeoblockConfiguration", config);
        }
        /// <summary>
        /// Gets the geoblock configuration from the module service
        /// </summary>
        /// <returns>The geoblock configuration</returns>
        public GeoblockConfiguration GetGeoblockConfiguration()
        {
            PropertyBag config = (PropertyBag)Invoke("GetGeoblockConfiguration");

            GeoblockConfiguration result = new GeoblockConfiguration();

            result.Enabled       = (bool)config[0];
            result.DenyAction    = (string)config[1];
            result.GeoIpFilepath = (string)config[2];
            result.VerifyAll     = (bool)config[3];
            result.AllowedMode   = (bool)config[4];

            result.SelectedCountryCodes = new List <Country>();
            ArrayList countries = (ArrayList)config[5];

            foreach (PropertyBag item in countries)
            {
                result.SelectedCountryCodes.Add(new Country((string)item[0], null));
            }

            result.ExceptionRules = new List <ExceptionRule>();
            ArrayList exceptionRules = (ArrayList)config[6];

            foreach (PropertyBag item in exceptionRules)
            {
                result.ExceptionRules.Add(new ExceptionRule((bool)item[0], (string)item[1], (string)item[2]));
            }

            return(result);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Gets the configuration for this module
 /// </summary>
 public void GetConfiguration()
 {
     if (serviceProxy == null)
     {
         serviceProxy = (GeoblockModuleServiceProxy)CreateProxy(typeof(GeoblockModuleServiceProxy));
     }
     moduleConfiguration = serviceProxy.GetGeoblockConfiguration();
 }