Update 20250204
This commit is contained in:
62
API_NetFramework - Kopie (2)/Models/StaticParams.cs
Normal file
62
API_NetFramework - Kopie (2)/Models/StaticParams.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Configuration;
|
||||
using System.Configuration;
|
||||
using Database;
|
||||
using System.Net.Http;
|
||||
using System.ComponentModel;
|
||||
using SecuringWebApiUsingApiKey.Middleware;
|
||||
|
||||
namespace API_NetFramework.Models
|
||||
{
|
||||
public enum LogLevelType { Info, Warning, Trace, Debug, Error }
|
||||
public static class APILogging
|
||||
{
|
||||
|
||||
public static void initLogging()
|
||||
{
|
||||
if (Logging.Logging.IntLogLevel == "")
|
||||
{
|
||||
string connectionstring = StringCipher.Decrypt(ConfigurationManager.ConnectionStrings["EDOKAConnectionstring"].ConnectionString, "i%!k!7pab%bNLdA5hE4pkR4XaB%E^jB3d9tHuQ4pbF&BZjF7SB#WBWit5#HrbJiLrLVm");
|
||||
DB db = new DB(connectionstring);
|
||||
db.Get_Tabledata("Select * from nlog_parameter where id=3", false, true);
|
||||
Logging.Logging.IntLogLevel = db.dsdaten.Tables[0].Rows[0]["LogLevel"].ToString();
|
||||
Logging.Logging.IntUserID = db.dsdaten.Tables[0].Rows[0]["LogUserID"].ToString();
|
||||
db = null;
|
||||
}
|
||||
|
||||
}
|
||||
public static void Log(HttpRequestMessage request, string Message, LogLevelType logtype)
|
||||
{
|
||||
string userhost = "";
|
||||
if (request.Properties.ContainsKey("MS_HttpContext"))
|
||||
{
|
||||
userhost = ((HttpContextWrapper)request.Properties["MS_HttpContext"]).Request.UserHostAddress;
|
||||
}
|
||||
switch (logtype)
|
||||
{
|
||||
case LogLevelType.Info:
|
||||
Logging.Logging.Info(Message, request.RequestUri.ToString(), userhost);
|
||||
break;
|
||||
case LogLevelType.Warning:
|
||||
Logging.Logging.Warning(Message, request.RequestUri.ToString(), userhost);
|
||||
break;
|
||||
case LogLevelType.Trace:
|
||||
Logging.Logging.Trance(Message, request.RequestUri.ToString(), userhost);
|
||||
break;
|
||||
case LogLevelType.Debug:
|
||||
Logging.Logging.Debug(Message, request.RequestUri.ToString(), userhost);
|
||||
break;
|
||||
case LogLevelType.Error:
|
||||
Logging.Logging.Error(Message, request.RequestUri.ToString(), userhost);
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user