public static void UpdateDataSet(this MSMO.LinkedServer linkedServer, Data.ApplicationDataSet.LinkedServersRow dataRow) { try { //dataRow.DateLastModified = linkedServer.DateLastModified; } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 7); // TODO(crhodes): // Wrap anything above that throws an exception that we want to ignore, // e.g. property not available because of SQL Edition. } }
private static void Update(MSMO.LinkedServer linkedServer, SQLInformation.Data.ApplicationDataSet.LinkedServersRow dataRow) { try { linkedServer.UpdateDataSet(dataRow); UpdateDatabaseWithSnapShot(dataRow, ""); } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 6); UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256)); } }
//public string OSVersion; //public string ProcessorUsage; //public string Processors; //public string Product; //public string ProductLevel; //public string RootDirectory; //public string ServiceAccount; //public string ServiceStartMode; //public string SqlCharSetName; //public string SqlDomainGroup; //public string SqlSortOrderName; //public string VersionString; /// <summary> /// Initializes a new instance of the Server class. /// </summary> public LinkedServer(SMO.LinkedServer linkedServer) { //AddinHelper.Common.WriteToDebugWindow(string.Format("SMOH.{0}({1})", "LinkedServer", linkedServer)); // NB. Not all properties are available depending on login credentials // Wrap in TC blocks. //try //{ // BackupDirectory = server.BackupDirectory; //} //catch(Exception) //{ // BackupDirectory = "<No Access>"; //} //try //{ // Catalog = server.Catalog; //} //catch (Exception) //{ // Catalog = "<No Access>"; //} //try //{ // Edition = server.Edition; //} //catch(Exception) //{ // Edition = "<No Access>"; //} //try //{ // MasterDBPath = server.MasterDBPath; //} //catch (Exception) //{ // MasterDBPath = "<No Access>"; //} //try //{ // MasterDBLogPath = server.MasterDBLogPath; //} //catch (Exception) //{ // MasterDBLogPath = "<No Access>"; //} Name = linkedServer.Name; //try //{ // OSVersion = server.OSVersion; //} //catch (Exception) //{ // OSVersion = "<No Access>"; //} //try //{ // Processors = server.Processors.ToString(); //} //catch (Exception) //{ // Processors = "<No Access>"; //} //try //{ // ProcessorUsage = server.ProcessorUsage.ToString(); //} //catch (Exception) //{ // ProcessorUsage = "<No Access>"; //} //try //{ // Product = server.Product; //} //catch (Exception) //{ // Product = "<No Access>"; //} //try //{ // ProductLevel = server.ProductLevel; //} //catch (Exception) //{ // ProductLevel = "<No Access>"; //} //try //{ // RootDirectory = server.RootDirectory; //} //catch (Exception) //{ // RootDirectory = "<No Access>"; //} //try //{ // ServiceAccount = server.ServiceAccount; //} //catch (Exception) //{ // ServiceAccount = "<No Access>"; //} //try //{ // switch (server.ServiceStartMode) // { // case SMO.ServiceStartMode.Auto: // ServiceStartMode = "Auto"; // break; // case SMO.ServiceStartMode.Boot: // ServiceStartMode = "Boot"; // break; // case SMO.ServiceStartMode.Disabled: // ServiceStartMode = "Disabled"; // break; // case SMO.ServiceStartMode.Manual: // ServiceStartMode = "Manual"; // break; // case SMO.ServiceStartMode.System: // ServiceStartMode = "System"; // break; // } //} //catch (Exception) //{ // ServiceStartMode = "<No Access>"; //} //try //{ // SqlCharSetName = server.SqlCharSetName; //} //catch (Exception) //{ // SqlCharSetName = "<No Access>"; //} //try //{ // SqlDomainGroup = server.SqlDomainGroup; //} //catch (Exception) //{ // SqlDomainGroup = "<No Access>"; //} //try //{ // SqlSortOrderName = server.SqlSortOrderName; //} //catch (Exception) //{ // SqlSortOrderName = "<No Access>"; //} //try //{ // VersionString = server.VersionString; //} //catch(Exception) //{ // VersionString = "<No Access>"; //} //Databases = new Dictionary<string, Database>(); //foreach (SMO.Database database in server.Databases) //{ // SMOHelper.Database db = new SMOHelper.Database(database); // Databases.Add(database.Name, db); //} //Logins = new Dictionary<string, Login>(); //foreach (SMO.Login login in server.Logins) //{ // SMOHelper.Login li = new SMOHelper.Login(login); // Logins.Add(login.Name, li); //} //ServerRoles = new Dictionary<string, ServerRole>(); //foreach (SMO.ServerRole role in server.Roles) //{ // SMOHelper.ServerRole serverRole = new SMOHelper.ServerRole(role); // ServerRoles.Add(role.Name, serverRole); //} }
private static SQLInformation.Data.ApplicationDataSet.LinkedServersRow Add(Guid instanceID, MSMO.LinkedServer linkedServer, string instanceName) { SQLInformation.Data.ApplicationDataSet.LinkedServersRow dataRow = null; try { dataRow = Common.ApplicationDataSet.LinkedServers.NewLinkedServersRow(); dataRow.ID = Guid.NewGuid(); dataRow.Name_LinkedServer = linkedServer.Name; dataRow.Instance_ID = instanceID; dataRow.Name_Instance = instanceName; dataRow.Catalog = linkedServer.Catalog; dataRow.DataAccess = linkedServer.DataAccess; dataRow.DataSource = linkedServer.DataSource; dataRow.DateLastModified = linkedServer.DateLastModified; dataRow.ID_LinkedServer = linkedServer.ID; dataRow.IsPromotionofDistributedTransactionsForRPCEnabled = linkedServer.IsPromotionofDistributedTransactionsForRPCEnabled; dataRow.Location = linkedServer.Location; dataRow.ProductName = linkedServer.ProductName; dataRow.ProviderName = linkedServer.ProviderName; dataRow.ProviderString = linkedServer.ProviderString; dataRow.Publisher = linkedServer.Publisher; dataRow.SnapShotDate = DateTime.Now; dataRow.SnapShotError = ""; Common.ApplicationDataSet.LinkedServers.AddLinkedServersRow(dataRow); Common.ApplicationDataSet.LinkedServersTA.Update(Common.ApplicationDataSet.LinkedServers); } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 5); // TODO(crhodes): // Wrap anything above that throws an exception that we want to ignore, // e.g. property not available because of SQL Edition. UpdateDatabaseWithSnapShot(dataRow, ex.ToString().Substring(0, 256)); } return(dataRow); }
private static SQLInformation.Data.ApplicationDataSet.LinkedServersRow GetInfoFromSMO(Guid instanceID, MSMO.LinkedServer linkedServer, string instanceName) { #if TRACE long startTicks = VNC.AppLog.Trace2("Enter", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 2); #endif SQLInformation.Data.ApplicationDataSet.LinkedServersRow dataRow = null; try { var dbs = from tb in Common.ApplicationDataSet.LinkedServers where tb.Instance_ID == instanceID select tb; var dbs2 = from db2 in dbs where db2.Name_LinkedServer == linkedServer.Name select db2; if (dbs2.Count() > 0) { dataRow = dbs2.First(); Update(linkedServer, dataRow); } else { dataRow = Add(instanceID, linkedServer, instanceName); } } catch (Exception ex) { VNC.AppLog.Error(ex, LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 3); } #if TRACE VNC.AppLog.Trace2("Exit", LOG_APPNAME, CLASS_BASE_ERRORNUMBER + 4, startTicks); #endif return(dataRow); }