Exemplo n.º 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();
                }
            }
        }
		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();
				}
			}
		}