Пример #1
0
        /// <summary>
        /// Fetches the tax service settings.
        /// </summary>
        /// <returns></returns>
        private static TaxServiceSettings FetchTaxServiceSettings()
        {
            DatabaseConfigurationProvider _databaseConfigurationProvider = new DatabaseConfigurationProvider();
            TaxServiceSettings            taxServiceSettings             =
                _databaseConfigurationProvider.FetchConfigurationByName(TaxServiceSettings.SECTION_NAME) as TaxServiceSettings;

            return(taxServiceSettings);
        }
Пример #2
0
        /// <summary>
        /// Sets the default tax provider.
        /// </summary>
        /// <param name="defaultTaxProvider">The default tax provider.</param>
        /// <returns></returns>
        public static int SetDefaultTaxProvider(string defaultTaxProvider, string userName)
        {
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(defaultTaxProvider, DEFAULT_TAX_PROVIDER);
            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            TaxServiceSettings            taxServiceSettings            =
                databaseConfigurationProvider.FetchConfigurationByName(TaxServiceSettings.SECTION_NAME) as TaxServiceSettings;

            taxServiceSettings.DefaultProvider = defaultTaxProvider;
            int id = databaseConfigurationProvider.SaveConfiguration(TaxServiceSettings.SECTION_NAME, taxServiceSettings, userName);

            return(id);
        }
Пример #3
0
        /// <summary>
        /// Saves the specified tax service settings.
        /// </summary>
        /// <param name="taxServiceSettings">The tax service settings.</param>
        /// <returns></returns>
        public static int Save(TaxServiceSettings taxServiceSettings, string userName)
        {
            Validator.ValidateObjectIsNotNull(taxServiceSettings, TAX_SERVICE_SETTINGS);
            Validator.ValidateObjectType(taxServiceSettings, typeof(TaxServiceSettings));
            //Set a default provider, regardless of whether or not the service uses one.
            if (taxServiceSettings.ProviderSettingsCollection.Count == 1)
            {
                taxServiceSettings.DefaultProvider = taxServiceSettings.ProviderSettingsCollection[0].Name;
            }
            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            int id = databaseConfigurationProvider.SaveConfiguration(TaxServiceSettings.SECTION_NAME, taxServiceSettings, userName);

            return(id);
        }
Пример #4
0
        /// <summary>
        /// Gets the default tax provider.
        /// </summary>
        /// <returns></returns>
        public static ITaxProvider GetDefaultTaxProvider()
        {
            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            TaxServiceSettings            taxServiceSettings            = databaseConfigurationProvider.FetchConfigurationByName(TaxServiceSettings.SECTION_NAME) as TaxServiceSettings;
            string defaultTaxProviderName = taxServiceSettings.DefaultProvider;

            if (String.IsNullOrEmpty(defaultTaxProviderName))
            {
                return(null);
            }
            ProviderSettings ps          = taxServiceSettings.ProviderSettingsCollection[defaultTaxProviderName];
            ITaxProvider     taxProvider = Activator.CreateInstance(Type.GetType(ps.Type), ps.Arguments) as ITaxProvider;

            Validator.ValidateObjectIsNotNull(taxProvider, TAX_PROVIDER);
            return(taxProvider);
        }
Пример #5
0
        /// <summary>
        /// Loads the providers.
        /// </summary>
        private void LoadProviders()
        {
            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            TaxServiceSettings            taxServiceSettings            =
                databaseConfigurationProvider.FetchConfigurationByName(TaxServiceSettings.SECTION_NAME) as TaxServiceSettings;
            ITaxProvider taxProvider = null;
            Type         type        = null;

            foreach (ProviderSettings providerSettings in taxServiceSettings.ProviderSettingsCollection)
            {
                //We only want to load the defaultProvider
                if (taxServiceSettings.DefaultProvider == providerSettings.Name)
                {
                    type        = Type.GetType(providerSettings.Type);
                    taxProvider = Activator.CreateInstance(type, providerSettings.Arguments) as ITaxProvider;
                    Validator.ValidateObjectIsNotNull(taxProvider, TAX_PROVIDER);
                    _taxProviderCollection.Add(taxProvider);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// Removes the tax provider.
        /// </summary>
        /// <param name="providerName">Name of the provider.</param>
        public static void RemoveTaxProvider(string providerName, string userName)
        {
            Validator.ValidateStringArgumentIsNotNullOrEmptyString(providerName, PROVIDER_NAME);
            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            TaxServiceSettings            taxServiceSettings            =
                databaseConfigurationProvider.FetchConfigurationByName(TaxServiceSettings.SECTION_NAME) as TaxServiceSettings;

            if (providerName == taxServiceSettings.DefaultProvider)
            {
                throw new InvalidOperationException(Strings.ResourceManager.GetString("UnableToDeleteDefaultProvider"));
            }
            ProviderSettings providerSettings = taxServiceSettings.ProviderSettingsCollection.Find(delegate(ProviderSettings theProviderSettings) {
                return(theProviderSettings.Name == providerName);
            });

            if (providerSettings != null)
            {
                taxServiceSettings.ProviderSettingsCollection.Remove(providerSettings);
                databaseConfigurationProvider.SaveConfiguration(TaxServiceSettings.SECTION_NAME, taxServiceSettings, userName);
            }
        }
 /// <summary>
 /// Saves the specified tax service settings.
 /// </summary>
 /// <param name="taxServiceSettings">The tax service settings.</param>
 public int Save(TaxServiceSettings taxServiceSettings, string userName)
 {
     int id = TaxService.Save(taxServiceSettings, userName);
       return id;
 }
Пример #8
0
 /// <summary>
 /// Saves the specified tax service settings.
 /// </summary>
 /// <param name="taxServiceSettings">The tax service settings.</param>
 /// <returns></returns>
 public static int Save(TaxServiceSettings taxServiceSettings, string userName)
 {
     Validator.ValidateObjectIsNotNull(taxServiceSettings, TAX_SERVICE_SETTINGS);
       Validator.ValidateObjectType(taxServiceSettings, typeof(TaxServiceSettings));
       //Set a default provider, regardless of whether or not the service uses one.
       if (taxServiceSettings.ProviderSettingsCollection.Count == 1) {
     taxServiceSettings.DefaultProvider = taxServiceSettings.ProviderSettingsCollection[0].Name;
       }
       DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
       int id = databaseConfigurationProvider.SaveConfiguration(TaxServiceSettings.SECTION_NAME, taxServiceSettings, userName);
       return id;
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
     SetVatConfigurationProperties();
     taxServiceSettings = TaxService.FetchConfiguredTaxProviders();
     if (taxServiceSettings != null) {
       foreach (ProviderSettings providerSettings in taxServiceSettings.ProviderSettingsCollection) {
     if (providerSettings.Name == typeof(VatTaxProvider).Name) {
       vatTaxConfigurationSettings = providerSettings;
     }
       }
       //if (vatTaxConfigurationSettings != null) {
       //  txtDefaultRate.Text = vatTaxConfigurationSettings.Parameters[VatTaxProvider.DEFAULT_RATE];
       //}
     }
     else {
       taxServiceSettings = new TaxServiceSettings();
     }
     view = Utility.GetParameter("view");
     switch (view) {
       case "c":
     pnlVatTaxConfiguration.Visible = true;
     pnlVatTaxData.Visible = false;
     break;
       case "d":
     LoadVatTaxRates();
     pnlVatTaxData.Visible = true;
     pnlVatTaxConfiguration.Visible = false;
     break;
       default:
     pnlVatTaxConfiguration.Visible = true;
     pnlVatTaxData.Visible = false;
     break;
     }
       }
       catch (Exception ex) {
     Logger.Error(typeof(vattaxconfiguration).Name + ".Page_Load", ex);
     base.MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
Пример #10
0
        /// <summary>
        /// Fetches the configured tax providers.
        /// </summary>
        /// <returns></returns>
        public static TaxServiceSettings FetchConfiguredTaxProviders()
        {
            TaxServiceSettings taxServiceSettings = FetchTaxServiceSettings();

            return(taxServiceSettings);
        }