private static void PerformPing() { string connectionString = AppSettings.GetString("AgentTemplateDbConnectionString"); int commandTimeoutSeconds = AppSettings.GetInt32("AgentTemplateDbCommandTimeoutSeconds", 30); DatabaseConnection dbc = new DatabaseConnection(connectionString, commandTimeoutSeconds); AssemblyName exe = Assembly.GetExecutingAssembly().GetName(); Console.WriteLine(exe.Name + ", Version=" + exe.Version); Console.WriteLine("Database Connection String: " + dbc.ConnectionString); Console.WriteLine("Ping:"); try { using (DatabaseRequest db = new DatabaseRequest(dbc, "PingGetDatabaseInfo")) { using (SqlDataReader reader = db.ExecuteSingleReader()) { if (reader.Read()) { Console.WriteLine(" Timestamp: " + reader.GetDateTime(0).ToString()); Console.WriteLine(" Server Instance: " + reader.GetString(1)); Console.WriteLine(" Version: " + reader.GetString(2)); Console.WriteLine(" Edition: " + reader.GetString(3)); Console.WriteLine(" Database: " + reader.GetString(4)); Console.WriteLine(" User: "******" <no data returned>"); } } } } catch (Exception ex) { Console.WriteLine("Ping failed." + Environment.NewLine + ex.ToString()); } }
private TaskResponse DoGetTask(GetTaskRequest request) { using (DatabaseRequest db = new DatabaseRequest(_Db, "AgentTemplateGetTask")) { if (request.TestMode != 0) { db.AddParameter("@TestMode", request.TestMode); } using (SqlDataReader reader = db.ExecuteSingleReader()) { if (!reader.Read()) { return(null); } TaskResponse response = new TaskResponse(); if (!reader.IsDBNull(0)) { response.Lock = reader.GetGuid(0); } return(response); } } }
private AgentPingResponse DoPing() { using (DatabaseRequest db = new DatabaseRequest(_Db, "PingGetDatabaseInfo")) { using (SqlDataReader reader = db.ExecuteSingleReader()) { AgentPingResponse response = new AgentPingResponse(); reader.Read(); if (!reader.IsDBNull(0)) { response.Timestamp = reader.GetDateTime(0); } if (!reader.IsDBNull(1)) { response.ServerInstance = reader.GetString(1); } if (!reader.IsDBNull(2)) { response.Version = reader.GetString(2); } if (!reader.IsDBNull(3)) { response.Edition = reader.GetString(3); } if (!reader.IsDBNull(4)) { response.Database = reader.GetString(4); } if (!reader.IsDBNull(5)) { response.User = reader.GetString(5); } return(response); } } }