Exemplo n.º 1
0
 public Executor(
     IServerList windowsServers,
     ISqlServerList sqlServers,
     ISqlServerVersionMap sqlServerVersionMap,
     IReportSink sink)
 {
     m_WindowsServers      = windowsServers;
     m_SqlServers          = sqlServers;
     m_SqlServerVersionMap = sqlServerVersionMap;
     m_Sink = sink;
 }
Exemplo n.º 2
0
        private static void RetrieveAndReportUpdates(IReportSink sink, ITargetServer targetServer)
        {
            var wmiNamespace = string.Format("\\\\{0}\\root\\CIMV2", targetServer.ServerName);
            var searcher     = new ManagementObjectSearcher(wmiNamespace, "select * from Win32_QuickFixEngineering");

            searcher.Options.UseAmendedQualifiers = true;
            searcher.Scope.Options.Locale         = "MS_" + CultureInfo.CurrentCulture.LCID.ToString("X");
            ManagementObjectCollection results = searcher.Get();

            foreach (ManagementObject item in results)
            {
                sink.WriteLine("{0, -14}\t{1, -12}\t{2}", item["HotFixID"].ToString(), item["InstalledOn"].ToString(),
                               item["Caption"].ToString());
            }
        }
        public void GatherAndReport(IReportSink sink)
        {
            sink.WriteLine();
            sink.WriteLine("------------------------ ------------------------------------------------------");
            sink.WriteLine("{0, -24} SqlServerVersionGatherer", DateTime.Now.ToUniversalTime().ToString());
            sink.WriteLine();

            foreach (ITargetSqlServer targetSqlServer in m_SqlServers)
            {
                using (var connection = new SqlConnection(targetSqlServer.ConnectionString))
                {
                    var command = connection.CreateCommand();
                    var adapter = new SqlDataAdapter(command);
                    var table   = new DataTable("MSVer");

                    command.CommandText = "xp_msver";
                    command.CommandType = CommandType.StoredProcedure;

                    try
                    {
                        connection.Open();

                        adapter.Fill(table);

                        var row     = table.Select("[NAME] = 'ProductVersion'");
                        var version = row[0][3].ToString();

                        if (m_VersionMap.ContainsKey(version))
                        {
                            sink.WriteLine("{0, -30}\t{1, -12}\t{2}", targetSqlServer.ServerName, version, m_VersionMap[version]);
                        }
                        else
                        {
                            sink.WriteLine("{0, -30}\t{1, -12}\tNOT FOUND IN MAP", targetSqlServer.ServerName, version);
                        }
                    }
                    catch (Exception e)
                    {
                        sink.WriteLine("EXCEPTION! > {0} ==> {1}", targetSqlServer.ServerName, e.Message);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public void GatherAndReport(IReportSink sink)
        {
            sink.WriteLine();
            sink.WriteLine("------------------------ ------------------------------------------------------");
            sink.WriteLine("{0, -24} WindowsServerUpdateGatherer", DateTime.Now.ToUniversalTime().ToString());
            sink.WriteLine();

            foreach (ITargetServer targetServer in m_Servers)
            {
                try
                {
                    sink.WriteLine();
                    sink.WriteLine(">>> {0}", targetServer.ServerName);

                    RetrieveAndReportUpdates(sink, targetServer);
                }
                catch (Exception e)
                {
                    sink.WriteLine("EXCEPTION! > {0} ==> {1}", targetServer.ServerName, e.Message);
                }
            }
        }