增加很多功能
增加几个日志监控功能
This commit is contained in:
@@ -17,15 +17,18 @@ namespace UseSQLQueryData.Controllers
|
||||
[ApiController]
|
||||
public class ValuesController : ControllerBase
|
||||
{
|
||||
public static string SqlConnectionString = "server=WIN-061EVIHKD86\\BLW;database=CRICS;uid=sa;pwd=pass@123$%^;TrustServerCertificate=True;";
|
||||
public static string SqlConnectionString = "server=WIN-O4NK3EJNBT1\\SQLEXPRESS;database=RICS;uid=sa;pwd=WIN-O4NK3EJNBT1;TrustServerCertificate=True;";
|
||||
//public static string SqlConnectionString = "Data Source=DESKTOP-DUNS5K7;Initial Catalog=RICS;User ID=sa;Password=123456;Trust Server Certificate=True";
|
||||
|
||||
//public static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
public RicsContext db { get; set; }
|
||||
public IMemoryCache _memorycache { get; set; }
|
||||
public ValuesController(RicsContext context, IMemoryCache cache)
|
||||
public IConfiguration _configuration { get; set; }
|
||||
public ValuesController(RicsContext context, IMemoryCache cache, IConfiguration configuration)
|
||||
{
|
||||
this.db = context;
|
||||
this._memorycache = cache;
|
||||
_configuration = configuration;
|
||||
}
|
||||
public record hotelinfo
|
||||
{
|
||||
@@ -69,7 +72,8 @@ namespace UseSQLQueryData.Controllers
|
||||
//return returnInfo;
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
//using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
@@ -113,7 +117,8 @@ namespace UseSQLQueryData.Controllers
|
||||
//return returnInfo;
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
//using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
@@ -162,7 +167,8 @@ namespace UseSQLQueryData.Controllers
|
||||
ReturnInfo returnInfo = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
//using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
@@ -211,7 +217,8 @@ namespace UseSQLQueryData.Controllers
|
||||
//var sql = $"SELECT * FROM Products WHERE Id IN ({string.Join(",", parameters)})";
|
||||
//var qqq = await db.TbRoomTypeModals.Where(A => RoomTypeIDList.Contains<int>(A.RoomTypeId)).ToListAsync();
|
||||
//var qqq = await db.TbRoomTypeModals.Where(A=>A.RoomTypeId==1).ToListAsync();
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
//using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
@@ -274,7 +281,8 @@ namespace UseSQLQueryData.Controllers
|
||||
//return returnInfo;
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
//using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
@@ -340,7 +348,7 @@ namespace UseSQLQueryData.Controllers
|
||||
|
||||
string nn3 = nn1 + nn2;
|
||||
|
||||
using SqlConnection con = new SqlConnection("server=WIN-061EVIHKD86\\BLW;database=CRICS;uid=sa;pwd=pass@123$%^;TrustServerCertificate=True;");
|
||||
using SqlConnection con = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"));
|
||||
con.Open();
|
||||
SqlTransaction tran = con.BeginTransaction();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
@@ -436,7 +444,8 @@ namespace UseSQLQueryData.Controllers
|
||||
try
|
||||
{
|
||||
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
//using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
using SqlConnection con = new SqlConnection(this._configuration.GetConnectionString("DefaultConnection"));
|
||||
await con.OpenAsync();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user