private void GetServerSettings(schema::DatasetBase ds, out string connectionString, out DbProviderFactory dbf) { EntityFactory ef = new EntityFactory(RegistryContext); Entity db = ef.LoadEntity(EntityType.Unknown, Jhu.Graywulf.Registry.AppSettings.FederationName, ds.Name); if (StringComparer.InvariantCultureIgnoreCase.Compare(ds.Name, MyDBDatabaseDefinition.Name) == 0) { // In case of myDB connectionString = ((schema::SqlServer.SqlServerDataset)SchemaManager.Datasets[MyDBDatabaseDefinition.Name]).ConnectionString; dbf = DbProviderFactories.GetFactory(ds.ProviderName); } else if (db is DatabaseDefinition) { // In case of a Graywulf database definition DatabaseDefinition dd = (DatabaseDefinition)db; dd.LoadDatabaseVersions(false); DatabaseVersion rs = dd.DatabaseVersions.Values.First(r => r.Name == "HOT"); // ***** TODO: this should come from the job settings... dd.LoadDatabaseInstances(false); List <DatabaseInstance> dis = new List <DatabaseInstance>(dd.DatabaseInstances.Values.Where(dii => dii.DatabaseVersionReference.Guid == rs.Guid)); // Pick a random server Random rnd = new Random(); DatabaseInstance di = dis[rnd.Next(dis.Count)]; connectionString = di.GetConnectionString().ConnectionString; dbf = System.Data.SqlClient.SqlClientFactory.Instance; } else if (db is RemoteDatabase) { RemoteDatabase rd = (RemoteDatabase)db; connectionString = ds.GetSpecializedConnectionString(rd.ConnectionString, rd.IntegratedSecurity, rd.Username, rd.Password, false); dbf = DbProviderFactories.GetFactory(ds.ProviderName); } else { throw new InvalidOperationException(); } }
protected void GenerateTable() { CheckBox[][] cb = new CheckBox[slices.Count][]; for (int i = 0; i < cb.Length; i++) { cb[i] = new CheckBox[serverInstances.Count]; } TableCell cell; // Add header (slices in columns) TableRow header = new TableRow(); for (int sli = 0; sli < slices.Count; sli++) { if (sli == 0) { header.Cells.Add(new TableCell()); // corner cell } cell = new TableCell(); cell.Text = slices[sli].Name; header.Cells.Add(cell); } MappingTable.Rows.Add(header); // Add rows (server instances in rows) for (int sii = 0; sii < serverInstances.Count; sii++) { TableRow tr = new TableRow(); cell = new TableCell(); cell.Text = String.Format("{0}.{1}", serverInstances[sii].Machine.Name, serverInstances[sii].Name); tr.Cells.Add(cell); for (int sli = 0; sli < slices.Count; sli++) { cell = new TableCell(); CheckBox c = cb[sli][sii] = new CheckBox(); c.ID = string.Format("cb_{0}_{1}", sli, sii); c.Enabled = true; c.Checked = true; cell.Controls.Add(c); tr.Cells.Add(cell); } MappingTable.Rows.Add(tr); } // Find already mapped instances item.LoadDatabaseInstances(false); foreach (DatabaseInstance di in item.DatabaseInstances.Values.Where(x => x.DatabaseVersionReference.Guid == databaseVersion.Guid)) { int i = slices.FindIndex(x => x.Guid == di.SliceReference.Guid); int j = serverInstances.FindIndex(x => x.Guid == di.ServerInstanceReference.Guid); //cb[i][j].Checked = false; //cb[i][j].Enabled = false; } }