Exemple #1
0
        public override void SaveProviderRepositoryInfo(string providerFactoryKey, ProviderRepositoryInfo providerRepositoryInfo)
        {
            using (ProviderDataContext dc = ProviderFactory.GetInstance <DataContextFactory>(ProviderRepositoryFactory.Instance.Providers[this.Parameters["dataContextProviderRepositoryName"]]).GetProviders <DataContextProviderBase>()[this.Parameters["dataContextProviderName"]].DataContext as ProviderDataContext)
            {
                dc.ExecuteCommand(String.Format("DELETE FROM ProviderParameters WHERE FKProviders IN (SELECT Id FROM Providers WHERE Key = '{0}')", providerFactoryKey));
                dc.ExecuteCommand(String.Format("DELETE FROM Providers WHERE Key = '{0}'", providerFactoryKey));

                foreach (ProviderSettings provider in providerRepositoryInfo.ProviderSettings)
                {
                    var newProvider = new ProviderValueObject();
                    newProvider.Key       = providerFactoryKey;
                    newProvider.Name      = provider.Name;
                    newProvider.Type      = provider.Type;
                    newProvider.IsDefault = (providerRepositoryInfo.DefaultProviderName == provider.Name);

                    dc.Providers.InsertOnSubmit(newProvider);
                    dc.SubmitChanges();

                    foreach (var item in provider.Parameters.Keys)
                    {
                        if (item.ToString().ToUpper() != "NAME" && item.ToString().ToUpper() != "TYPE")
                        {
                            var newParameter = new ProviderParameterValueObject();
                            newParameter.FKProviders = newProvider.Id;
                            newParameter.Name        = item.ToString();
                            newParameter.Value       = provider.Parameters[item.ToString()];

                            dc.ProviderParameters.InsertOnSubmit(newParameter);
                        }
                    }
                    dc.SubmitChanges();
                }
            }
        }
Exemple #2
0
        private string GetDefaultProviderName(string providerKey)
        {
            string providerName = string.Empty;

            using (ProviderDataContext dc = ProviderFactory.GetInstance <DataContextFactory>(ProviderRepositoryFactory.Instance.Providers[this.Parameters["dataContextProviderRepositoryName"]]).GetProviders <DataContextProviderBase>()[this.Parameters["dataContextProviderName"]].DataContext as ProviderDataContext)
            {
                ProviderValueObject result = dc.Providers.Where(p => p.IsDefault).SingleOrDefault();
                if (result != null)
                {
                    providerName = result.Name;
                }
            }

            return(providerName);
        }
		public override void SaveProviderRepositoryInfo (string providerFactoryKey, ProviderRepositoryInfo providerRepositoryInfo)
		{
			using (ProviderDataContext dc = ProviderFactory.GetInstance<DataContextFactory>(ProviderRepositoryFactory.Instance.Providers[this.Parameters["dataContextProviderRepositoryName"]]).GetProviders<DataContextProviderBase>()[this.Parameters["dataContextProviderName"]].DataContext as ProviderDataContext)
			{
                dc.ExecuteCommand(String.Format("DELETE FROM ProviderParameters WHERE FKProviders IN (SELECT Id FROM Providers WHERE Key = '{0}')", providerFactoryKey));
                dc.ExecuteCommand(String.Format("DELETE FROM Providers WHERE Key = '{0}'", providerFactoryKey));
				
				foreach (ProviderSettings provider in providerRepositoryInfo.ProviderSettings) {
					
					var newProvider = new ProviderValueObject();
					newProvider.Key = providerFactoryKey;
					newProvider.Name = provider.Name;
					newProvider.Type = provider.Type;
					newProvider.IsDefault = (providerRepositoryInfo.DefaultProviderName == provider.Name);
					
					dc.Providers.InsertOnSubmit(newProvider);
                    dc.SubmitChanges();

					foreach (var item in provider.Parameters.Keys) {
						if (item.ToString().ToUpper() != "NAME" && item.ToString().ToUpper() != "TYPE") {
							var newParameter = new ProviderParameterValueObject();
							newParameter.FKProviders = newProvider.Id;
							newParameter.Name = item.ToString();
							newParameter.Value = provider.Parameters[item.ToString()];
							
							dc.ProviderParameters.InsertOnSubmit(newParameter);
						}
						
					}
                    dc.SubmitChanges();
				}
			}
		}