/// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try {
            if (mailSettings == null) {
              mailSettings = new MailSettings();
            }
            mailSettings.From = txtFrom.Text.Trim();
            mailSettings.Host = txtHost.Text.Trim();
            mailSettings.RequireAuthentication = chkRequireAuthentication.Checked;
            mailSettings.UserName = txtUserName.Text.Trim();
            mailSettings.Password = txtPassword.Text.Trim();
            int port = 25;
            bool isParsed = int.TryParse(txtPort.Text.Trim(), out port);
            mailSettings.Port = (isParsed) ? port : 25;
            mailSettings.RequireSsl = chkRequireSsl.Checked;

            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            int id = databaseConfigurationProvider.SaveConfiguration(MailSettings.SECTION_NAME, mailSettings, WebUtility.GetUserName());
            MessagingCache.RemoveMailSettings();
            if (id > 0) {
              Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblMailSettingsSaved"));
            }
            else {
              Master.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblMailSettingsNotSaved"));
            }
              }
              catch (Exception ex) {
            Logger.Error(typeof(mailconfiguration).Name + ".btnSave_Click", ex);
            Master.MessageCenter.DisplayCriticalMessage(ex.Message);
              }
        }
Esempio n. 2
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;
 }
 /// <summary>
 /// Saves the specified site settings.
 /// </summary>
 /// <param name="siteSettings">The site settings.</param>
 public void Save(SiteSettings siteSettings)
 {
     try {
     DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
     int id = databaseConfigurationProvider.SaveConfiguration(SiteSettings.SECTION_NAME, siteSettings, WebUtility.GetUserName());
     SiteSettingCache.RemoveSiteSettingsFromCache();
     if (id > 0) {
       MasterPage.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblSiteSettingsSaved"));
     }
     else {
       MasterPage.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblSiteSettingsNotSaved"));
     }
       }
       catch(Exception ex) {
     Logger.Error("Save", ex);
     MasterPage.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
        /// <summary>
        /// Handles the Click event of the btnSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try {
            mailSettings.Contact = txtEmail.Text.Trim();

            DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
            int id = databaseConfigurationProvider.SaveConfiguration(MailSettings.SECTION_NAME, mailSettings, WebUtility.GetUserName());
            SiteSettingCache.RemoveSiteSettingsFromCache();
            if (id > 0) {
              Master.MessageCenter.DisplaySuccessMessage(LocalizationUtility.GetText("lblMailSettingsSaved"));
            }
            else {
              Master.MessageCenter.DisplayFailureMessage(LocalizationUtility.GetText("lblMailSettingsNotSaved"));
            }
              }
              catch (Exception ex) {
            Logger.Error(typeof(mailconfiguration).Name + ".btnSave_Click", ex);
            Master.MessageCenter.DisplayCriticalMessage(ex.Message);
              }
        }
 /// <summary>
 /// Handles the Click event of the btnSave control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
 protected void btnSave_Click(object sender, EventArgs e)
 {
     try {
     PaymentServiceSettings paymentServiceSettings = new PaymentServiceSettings();
     ProviderSettings settings = new ProviderSettings();
     settings.Name = typeof(PayPalProPaymentProvider).Name;
     settings.Type = typeof(PayPalProPaymentProvider).AssemblyQualifiedName;
     settings.Parameters.Add("ApiUserName", "username");
     settings.Parameters.Add("ApiPassword", "password");
     settings.Parameters.Add("Signature", "signature");
     settings.Parameters.Add("IsLive", "false");
     paymentServiceSettings.ProviderSettingsCollection.Add(settings);
     DatabaseConfigurationProvider config = new DatabaseConfigurationProvider();
     config.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, WebUtility.GetUserName());
     SiteSettingCache.RemoveSiteSettingsFromCache();
       }
       catch (Exception ex) {
     Logger.Error(typeof(paymentserviceconfiguration).Name + ".Page_Load", ex);
     Master.MessageCenter.DisplayCriticalMessage(ex.Message);
       }
 }
 /// <summary>
 /// Fetches the shipping service settings.
 /// </summary>
 /// <returns></returns>
 private static ShippingServiceSettings FetchShippingServiceSettings()
 {
     DatabaseConfigurationProvider _databaseConfigurationProvider = new DatabaseConfigurationProvider();
       ShippingServiceSettings shippingServiceSettings =
     _databaseConfigurationProvider.FetchConfigurationByName(ShippingServiceSettings.SECTION_NAME) as ShippingServiceSettings;
       return shippingServiceSettings;
 }
 /// <summary>
 /// Sets the default shipping provider.
 /// </summary>
 /// <param name="defaultTaxProvider">The default tax provider.</param>
 /// <returns></returns>
 public static int SetDefaultShippingProvider(string defaultShippingProvider, string userName)
 {
     Validator.ValidateStringArgumentIsNotNullOrEmptyString(defaultShippingProvider, DEFAULT_SHIPPING_PROVIDER);
       DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
       ShippingServiceSettings shippingServiceSettings =
     databaseConfigurationProvider.FetchConfigurationByName(ShippingServiceSettings.SECTION_NAME) as ShippingServiceSettings;
       shippingServiceSettings.DefaultProvider = defaultShippingProvider;
       int id = databaseConfigurationProvider.SaveConfiguration(ShippingServiceSettings.SECTION_NAME, shippingServiceSettings, userName);
       return id;
 }
 /// <summary>
 /// Saves the specified shipping service settings.
 /// </summary>
 /// <param name="shippingServiceSettings">The shipping service settings.</param>
 /// <returns></returns>
 public static int Save(ShippingServiceSettings shippingServiceSettings, string userName)
 {
     Validator.ValidateObjectIsNotNull(shippingServiceSettings, SHIPPING_SERVICE_SETTINGS);
       Validator.ValidateObjectType(shippingServiceSettings, typeof(ShippingServiceSettings));
       //Set a default provider, regardless of whether or not the service uses one.
       if(shippingServiceSettings.ProviderSettingsCollection.Count == 1) {
     shippingServiceSettings.DefaultProvider = shippingServiceSettings.ProviderSettingsCollection[0].Name;
       }
       DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
       int id = databaseConfigurationProvider.SaveConfiguration(ShippingServiceSettings.SECTION_NAME, shippingServiceSettings, userName);
       return id;
 }
Esempio n. 9
0
 /// <summary>
 /// Loads this instance.
 /// </summary>
 /// <returns></returns>
 public static SiteSettings Load()
 {
     try {
     DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
     SiteSettings siteSettings = databaseConfigurationProvider.FetchConfigurationByName(SiteSettings.SECTION_NAME) as SiteSettings;
     return siteSettings;
       }
       catch(Exception ex) {
     throw new Exception("Please make sure that you setup the Database, and the Connection String in the connectionString.config file.");
       }
 }
Esempio n. 10
0
 /// <summary>
 /// Fetches the payment service settings.
 /// </summary>
 /// <returns></returns>
 private static PaymentServiceSettings FetchPaymentServiceSettings()
 {
     DatabaseConfigurationProvider _databaseConfigurationProvider = new DatabaseConfigurationProvider();
       PaymentServiceSettings paymentServiceSettings =
     _databaseConfigurationProvider.FetchConfigurationByName(PaymentServiceSettings.SECTION_NAME) as PaymentServiceSettings;
       return paymentServiceSettings;
 }
Esempio n. 11
0
 /// <summary>
 /// Loads this instance.
 /// </summary>
 /// <returns></returns>
 public static MailSettings Load()
 {
     DatabaseConfigurationProvider databaseConfigurationprovider = new DatabaseConfigurationProvider();
       MailSettings mailSettings = databaseConfigurationprovider.FetchConfigurationByName(MailSettings.SECTION_NAME) as MailSettings;
       return mailSettings;
 }
Esempio n. 12
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);
     }
       }
 }
Esempio n. 13
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;
 }
Esempio n. 14
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;
 }
Esempio n. 15
0
 /// <summary>
 /// Loads the providers.
 /// </summary>
 private void LoadProviders()
 {
     DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
       ShippingServiceSettings shippingServiceSettings =
     databaseConfigurationProvider.FetchConfigurationByName(ShippingServiceSettings.SECTION_NAME) as ShippingServiceSettings;
       IShippingProvider shippingProvider = null;
       Type type = null;
       foreach (ProviderSettings providerSettings in shippingServiceSettings.ProviderSettingsCollection) {
     type = Type.GetType(providerSettings.Type);
     shippingProvider = Activator.CreateInstance(type, providerSettings.Arguments) as IShippingProvider;
     Validator.ValidateObjectIsNotNull(shippingProvider, SHIPPING_PROVIDER);
     _shippingProviderCollection.Add(shippingProvider);
       }
 }
Esempio n. 16
0
 /// <summary>
 /// Removes the shipping provider.
 /// </summary>
 /// <param name="providerName">Name of the provider.</param>
 public static void RemoveShippingProvider(string providerName, string userName)
 {
     Validator.ValidateStringArgumentIsNotNullOrEmptyString(providerName, PROVIDER_NAME);
       DatabaseConfigurationProvider databaseConfigurationProvider = new DatabaseConfigurationProvider();
       ShippingServiceSettings shippingServiceSettings =
     databaseConfigurationProvider.FetchConfigurationByName(ShippingServiceSettings.SECTION_NAME) as ShippingServiceSettings;
       if(providerName == shippingServiceSettings.DefaultProvider) {
     throw new InvalidOperationException(Strings.ResourceManager.GetString("UnableToDeleteDefaultProvider"));
       }
       ProviderSettings providerSettings = shippingServiceSettings.ProviderSettingsCollection.Find(delegate(ProviderSettings theProviderSettings) {return theProviderSettings.Name == providerName;});
       if(providerSettings != null) {
     shippingServiceSettings.ProviderSettingsCollection.Remove(providerSettings);
     databaseConfigurationProvider.SaveConfiguration(ShippingServiceSettings.SECTION_NAME, shippingServiceSettings, userName);
       }
 }
Esempio n. 17
0
 /// <summary>
 /// Sets the default payment provider.
 /// </summary>
 /// <param name="defaultPaymentProvider">The default payment provider.</param>
 /// <returns></returns>
 public static int SetDefaultPaymentProvider(string defaultPaymentProvider, string userName)
 {
     Validator.ValidateStringArgumentIsNotNullOrEmptyString(defaultPaymentProvider, DEFAULT_PAYMENT_PROVIDER);
       DatabaseConfigurationProvider _databaseConfigurationProvider = new DatabaseConfigurationProvider();
       PaymentServiceSettings paymentServiceSettings =
       _databaseConfigurationProvider.FetchConfigurationByName(PaymentServiceSettings.SECTION_NAME) as PaymentServiceSettings;
       paymentServiceSettings.DefaultProvider = defaultPaymentProvider;
       int id = _databaseConfigurationProvider.SaveConfiguration(PaymentServiceSettings.SECTION_NAME, paymentServiceSettings, userName);
       return id;
 }