增加日志
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using System.Data;
|
||||
using CliWrap;
|
||||
using DAL.New_Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.OutputCaching;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using NLog;
|
||||
using RestSharp;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
@@ -15,6 +18,252 @@ namespace UseSQLQueryData.Controllers
|
||||
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 = "Data Source=DESKTOP-DUNS5K7;Initial Catalog=RICS;User ID=sa;Password=123456;Trust Server Certificate=True";
|
||||
|
||||
public RicsContext db { get; set; }
|
||||
public IMemoryCache _memorycache { get; set; }
|
||||
public ValuesController(RicsContext context, IMemoryCache cache)
|
||||
{
|
||||
this.db = context;
|
||||
this._memorycache = cache;
|
||||
}
|
||||
public record hotelinfo
|
||||
{
|
||||
public string HotelID { get; set; }
|
||||
public string? HotelCode { get; set; }
|
||||
public string? HotelName { get; set; }
|
||||
}
|
||||
|
||||
public record hostinfo
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string HotelID { get; set; }
|
||||
public string RoomTypeID { get; set; }
|
||||
public string? RoomNumber { get; set; }
|
||||
public string? HostNumber { get; set; }
|
||||
public string? MAC { get; set; }
|
||||
}
|
||||
public record roomtype_info
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string HotelID { get; set; }
|
||||
public string? RoomTypeName { get; set; }
|
||||
}
|
||||
public record roomtype_modalinfo
|
||||
{
|
||||
public string ID { get; set; }
|
||||
public string RoomTypeID { get; set; }
|
||||
public string? ModalAddress { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取酒店列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[OutputCache()]
|
||||
public async Task<ReturnInfo> GetHotelList()
|
||||
{
|
||||
ReturnInfo returnInfo = new ReturnInfo();
|
||||
//return returnInfo;
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
string sql = @"select ID,Code,Name from tb_Sys_Hotels where IsDeleted=0;";
|
||||
sqlCommand.CommandText = sql;
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
List<hotelinfo> chaList = new List<hotelinfo>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
var id = item["ID"].ToString();
|
||||
var code = item["Code"].ToString();
|
||||
var Name = item["Name"].ToString();
|
||||
hotelinfo cha = new hotelinfo();
|
||||
cha.HotelID = id;
|
||||
cha.HotelCode = code;
|
||||
cha.HotelName = Name;
|
||||
chaList.Add(cha);
|
||||
}
|
||||
}
|
||||
returnInfo.isok = true;
|
||||
returnInfo.response = chaList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
returnInfo.isok = false;
|
||||
returnInfo.message = ex.Message;
|
||||
}
|
||||
return returnInfo;
|
||||
}
|
||||
|
||||
[OutputCache()]
|
||||
public async Task<ReturnInfo> GetHostList()
|
||||
{
|
||||
ReturnInfo returnInfo = new ReturnInfo();
|
||||
//return returnInfo;
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
string sql = @"select ID,HotelID,RoomTypeID,RoomNumber,HostNumber,MAC from tb_Hosts where IsDeleted=0;";
|
||||
sqlCommand.CommandText = sql;
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
List<hostinfo> chaList = new List<hostinfo>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
var id = item["ID"].ToString();
|
||||
var hid = item["HotelID"].ToString();
|
||||
var RoomTypeID = item["RoomTypeID"].ToString();
|
||||
var RoomNumber = item["RoomNumber"].ToString();
|
||||
var HostNumber = item["HostNumber"].ToString();
|
||||
var MAC = item["MAC"].ToString();
|
||||
hostinfo cha = new hostinfo();
|
||||
cha.ID = id;
|
||||
cha.HotelID = hid;
|
||||
cha.RoomTypeID = RoomTypeID;
|
||||
cha.RoomNumber = RoomNumber;
|
||||
cha.HostNumber = HostNumber;
|
||||
cha.MAC = MAC;
|
||||
chaList.Add(cha);
|
||||
}
|
||||
}
|
||||
returnInfo.isok = true;
|
||||
returnInfo.response = chaList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
returnInfo.isok = false;
|
||||
returnInfo.message = ex.Message;
|
||||
}
|
||||
return returnInfo;
|
||||
}
|
||||
|
||||
[OutputCache()]
|
||||
public async Task<ReturnInfo> GetRoomType_Info()
|
||||
{
|
||||
ReturnInfo returnInfo = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
string sql = @"select ID,HotelID,Name from tb_RoomType where IsDeleted=0;";
|
||||
sqlCommand.CommandText = sql;
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
List<roomtype_info> chaList = new List<roomtype_info>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
var id = item["ID"].ToString();
|
||||
var HotelID = item["HotelID"].ToString();
|
||||
var Name = item["Name"].ToString();
|
||||
roomtype_info cha = new roomtype_info();
|
||||
cha.HotelID = HotelID;
|
||||
cha.ID = id;
|
||||
cha.RoomTypeName = Name;
|
||||
chaList.Add(cha);
|
||||
}
|
||||
}
|
||||
returnInfo.isok = true;
|
||||
returnInfo.response = chaList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
returnInfo.isok = false;
|
||||
returnInfo.message = ex.Message;
|
||||
}
|
||||
return returnInfo;
|
||||
}
|
||||
|
||||
[OutputCache()]
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetRoomType_ModalInfo([FromBody] List<int> RoomTypeIDList)
|
||||
{
|
||||
ReturnInfo returnInfo = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
var parameters = string.Join(',', RoomTypeIDList);
|
||||
string sql = @$"select ID,RoomTypeID,ModalAddress,Type, Name from tb_RoomTypeModal WHERE RoomTypeID IN ({parameters});";
|
||||
//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);
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
sqlCommand.CommandText = sql;
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
List<roomtype_modalinfo> chaList = new List<roomtype_modalinfo>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
var id = item["ID"].ToString();
|
||||
var RoomTypeID = item["RoomTypeID"].ToString();
|
||||
var ModalAddress = item["ModalAddress"].ToString();
|
||||
var Type = item["Type"].ToString();
|
||||
var Name = item["Name"].ToString();
|
||||
roomtype_modalinfo cha = new roomtype_modalinfo();
|
||||
cha.ID = id;
|
||||
cha.RoomTypeID = RoomTypeID;
|
||||
cha.Name = Name;
|
||||
cha.ModalAddress = ModalAddress;
|
||||
cha.Type = Type;
|
||||
chaList.Add(cha);
|
||||
}
|
||||
}
|
||||
|
||||
//List<roomtype_modalinfo> chaList = new List<roomtype_modalinfo>();
|
||||
//foreach (var item in qqq)
|
||||
//{
|
||||
|
||||
// roomtype_modalinfo cha = new roomtype_modalinfo();
|
||||
// cha.ID = item.Id.ToString();
|
||||
// cha.RoomTypeID = item.RoomTypeId.ToString();
|
||||
// cha.Name = item.Name;
|
||||
// cha.ModalAddress = item.ModalAddress;
|
||||
// cha.Type = item.Type.ToString();
|
||||
// chaList.Add(cha);
|
||||
//}
|
||||
returnInfo.isok = true;
|
||||
returnInfo.response = chaList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
returnInfo.isok = false;
|
||||
returnInfo.message = ex.Message;
|
||||
}
|
||||
return returnInfo;
|
||||
}
|
||||
|
||||
//public static string SqlConnectionString = "Data Source=DESKTOP-DUNS5K7;Initial Catalog=CRICS;User ID=sa;Password=123456;Trust Server Certificate=True";
|
||||
public static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
[HttpGet()]
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<DeleteExistingFiles>false</DeleteExistingFiles>
|
||||
<ExcludeApp_Data>false</ExcludeApp_Data>
|
||||
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
|
||||
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
|
||||
<LastUsedPlatform>Any CPU</LastUsedPlatform>
|
||||
<PublishProvider>FileSystem</PublishProvider>
|
||||
<PublishUrl>bin\Release\net8.0\publish\</PublishUrl>
|
||||
<WebPublishMethod>FileSystem</WebPublishMethod>
|
||||
<_TargetId>Folder</_TargetId>
|
||||
<SiteUrlToLaunchAfterPublish />
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<ProjectGuid>10f5f2cb-a414-43db-a99a-68081f2800fc</ProjectGuid>
|
||||
<SelfContained>false</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- https://go.microsoft.com/fwlink/?LinkID=208121. -->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>E:\tian\chongxin\NewGit\Web_BLSKafka_Server_Prod\UseSQLQueryData\bin\Release\net8.0\publish\</_PublishTargetUrl>
|
||||
<History>True|2026-01-31T06:49:29.1275223Z||;True|2026-01-31T14:13:11.7242950+08:00||;True|2026-01-31T14:10:05.1267470+08:00||;True|2026-01-31T13:37:30.6761345+08:00||;True|2026-01-31T11:30:39.2792110+08:00||;True|2026-01-31T11:28:44.6978619+08:00||;True|2026-01-31T11:27:35.8243470+08:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -3,6 +3,6 @@
|
||||
<PropertyGroup>
|
||||
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
|
||||
<NameOfLastUsedPublishProfile>E:\tian\BLS\BLWLogServer\UseSQLQueryData\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
<NameOfLastUsedPublishProfile>E:\tian\chongxin\NewGit\Web_BLSKafka_Server_Prod\UseSQLQueryData\Properties\PublishProfiles\FolderProfile1.pubxml</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user