public virtual IHttpActionResult Get() { log.TraceFormat("Get::{0:S} requested", typeof(T).Name); if (Attribute.GetCustomAttributes(this.GetType(), typeof(Attributes.GetAllSupportedAttribute), false) == null) { return(ResponseMessage(new System.Net.Http.HttpResponseMessage(System.Net.HttpStatusCode.NotImplemented))); } try { using (SqlConnection conn = new SqlConnection(Startup.ConnectionString)) { conn.Open(); using (var trans = conn.BeginTransaction()) { var r = DatabaseItem <K> .GetAll <T>(conn, trans); trans.Commit(); log.TraceFormat("{0:S} Get returning {1:N0} items.", typeof(T).FullName, r.Count); return(Ok(r)); } } } catch (Core.Exceptions.TSQLNotFoundException) { return(BadRequest(string.Format("Get not supported by {0:S}", typeof(T).FullName))); } }
public void LoggingExtensions_Test1() { log.DebugFormat("Time now is {0:S}", DateTime.Now.ToString()); log.InfoFormat("Time now is {0:S}", DateTime.Now.ToString()); log.WarnFormat("Time now is {0:S}", DateTime.Now.ToString()); log.ErrorFormat("Time now is {0:S}", DateTime.Now.ToString()); log.FatalFormat("Time now is {0:S}", DateTime.Now.ToString()); log.TraceFormat("Time now is {0:S}", DateTime.Now.ToString()); log.VerboseFormat("Time now is {0:S}", DateTime.Now.ToString()); }
protected void PingThread() { while (true) { try { log.TraceFormat("{0:S} - Update server LKA", this.ToString()); using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { this.UpdateKeepAlive(conn, trans); trans.Commit(); } } Thread.Sleep(int.Parse(Configuration["SERVER_KEEPALIVE_SLEEP_MS"])); } catch (Exception exce) // catch all to keep the thread alive { log.ErrorFormat("Unhandled exception during PingThread: {0:S}", exce.ToString()); } } }
public virtual IHttpActionResult Get(string id, string type) { log.TraceFormat("Get::{0:S}({1:S}, {2:S}) requested", this.GetType().Name, id.ToString(), type.ToString()); return(this.GetSecondary(id, 255)); }