// The following constructor has parameters for two of the three // properties. public resourceProviderTest(appDatabase TempDB) { this.userAccount = TempDB.userid; this.userPswd = TempDB.password; this.serverName = TempDB.serverName; this.testPassed = false; this.testFinished = false; }
public void loadPortalDBSiteData(appDatabase Database) { SqlDataAdapter siteInfoAdapter; DataTable siteInfoTable; string siteInfoQuery = ""; int siteInfoCount = 0; string [] siteparts; string serverName; try { SqlConnection siteInfoConnection = new SqlConnection("server=" + Database.serverName + ", 1433; database=" + Database.databaseName + "; user id=" + Database.userid + "; password="******"; Integrated Security=False"); siteInfoConnection.Open(); siteInfoQuery = "SELECT [Namespace],[Value] FROM [Microsoft.MgmtSvc.PortalConfigStore].[Config].[Settings] WHERE Name Like '%FQDN%'"; siteInfoAdapter = new SqlDataAdapter(siteInfoQuery, siteInfoConnection); siteInfoTable = new DataTable(); siteInfoCount = siteInfoAdapter.Fill(siteInfoTable); if (siteInfoCount != 0) { foreach (DataRow row in siteInfoTable.Rows) // Loop over the rows. { //parse out the site server name siteparts = row.ItemArray[1].ToString().Split(':'); serverName = siteparts[1].Replace("//", ""); switch (row.ItemArray[0].ToString()) { case "AdminSite": appSites.Add(new appSite(serverName, "MgmtSvc-AdminSite")); break; case "AuthSite": appSites.Add(new appSite(serverName, "MgmtSvc-AuthSite")); break; case "TenantSite": appSites.Add(new appSite(serverName, "MgmtSvc-TenantSite")); break; case "WindowsAuthSite": appSites.Add(new appSite(serverName, "MgmtSvc-WindowsAuthSite")); break; } } } else { Log.Information("No Portal Sites Information Found In The [Microsoft.MgmtSvc.PortalConfigStore].[Config].[Settings] DB Table."); Failed(); } siteInfoConnection.Close(); } catch (Exception e) { Log.Information(e.Message.ToString()); Failed(); } }
public string parseConnection(string connectionstr) { string datasource = ""; string catalog = ""; string user = ""; string password = ""; string [] connectionParts; string [] valueParts; appDatabase parseDB; //get the individual parts isolated connectionParts = connectionstr.Split(';'); foreach (string connectionPart in connectionParts) { //Log.Information(connectionPart); string tempParseString = connectionPart; valueParts = tempParseString.Split('='); valueParts[0] = valueParts[0].ToLower(); //I was changing the case of the value string at this point, and causing myself grief. Can't change the password case. if (valueParts[0].Contains("data source")) { valueParts[1] = valueParts[1].ToLower(); datasource = valueParts[1]; } if (valueParts[0].Contains("initial catalog")) { valueParts[1] = valueParts[1].ToLower(); catalog = valueParts[1]; //Log.Information(catalog); } if (valueParts[0].Contains("user id")) { user = valueParts[1]; } if (valueParts[0].Contains("password")) { password = valueParts[1]; } } parseDB = new appDatabase(datasource, catalog, user, password); appDatabases.Add(parseDB); connectionstr = "Connect String to " + catalog + " on server " + datasource + " found"; return(connectionstr); }
public void loadResourceProviderSiteDate(appDatabase Database) { SqlDataAdapter siteInfoAdapter; DataTable siteInfoTable; string siteInfoQuery = ""; int siteInfoCount = 0; string[] siteparts; string serverName; try { SqlConnection siteInfoConnection = new SqlConnection("server=" + Database.serverName + ", 1433; database=" + Database.databaseName + "; user id=" + Database.userid + "; password="******"; Integrated Security=False"); siteInfoConnection.Open(); siteInfoQuery = "SELECT [Name],[AdminForwardingAddress] FROM [Microsoft.MgmtSvc.Store].[mp].[ResourceProviders]"; siteInfoAdapter = new SqlDataAdapter(siteInfoQuery, siteInfoConnection); siteInfoTable = new DataTable(); siteInfoCount = siteInfoAdapter.Fill(siteInfoTable); if (siteInfoCount != 0) { foreach (DataRow row in siteInfoTable.Rows) // Loop over the rows. { //parse out the site server name siteparts = row.ItemArray[1].ToString().Split(':'); serverName = siteparts[1].TrimStart('/'); //it concerns me that the the complete site addresses are not in the AdminForwardingAddress, but it is the best information available. switch (row.ItemArray[0].ToString()) { case "monitoring": appSites.Add(new appSite(serverName, "MgmtSvc-Monitoring")); break; case "mysqlservers": appSites.Add(new appSite(serverName, "MgmtSvc-MySQL")); break; case "usageservice": appSites.Add(new appSite(serverName, "MgmtSvc-Usage")); break; case "marketplace": appSites.Add(new appSite(serverName, "MgmtSvc-WebAppGallery")); // break; case "sqlservers": appSites.Add(new appSite(serverName, "MgmtSvc-SQLServer")); break; case "CmpWapExtension": appSites.Add(new appSite(serverName, "MgmtSvc-CmpWapExtension")); break; } } } else { Log.Information("No Resource Provider Sites Information Found In The [Microsoft.MgmtSvc.Store].[mp].[ResourceProviders] DB Table."); Failed(); } siteInfoConnection.Close(); } catch (Exception e) { Log.Information(e.Message.ToString()); Failed(); } }