初始化
This commit is contained in:
13
UseSQLQueryData/.config/dotnet-tools.json
Normal file
13
UseSQLQueryData/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"dotnet-ef": {
|
||||
"version": "9.0.7",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
}
|
||||
}
|
||||
}
|
||||
209
UseSQLQueryData/Controllers/BaoYiController.cs
Normal file
209
UseSQLQueryData/Controllers/BaoYiController.cs
Normal file
@@ -0,0 +1,209 @@
|
||||
using Common;
|
||||
using CommonEntity;
|
||||
using DAL.New_Models;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Microsoft.VisualBasic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace UseSQLQueryData.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class BaoYiController : ControllerBase
|
||||
{
|
||||
public static string TimerReportData = "TimerReportData";
|
||||
public RicsContext db { get; set; }
|
||||
public IMemoryCache _memorycache { get; set; }
|
||||
public BaoYiController(RicsContext context, IMemoryCache cache)
|
||||
{
|
||||
this.db = context;
|
||||
this._memorycache = cache;
|
||||
}
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> SaveRoomTypeModal()
|
||||
{
|
||||
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
using var reader = new StreamReader(Request.Body);
|
||||
string jsonString = await reader.ReadToEndAsync();
|
||||
|
||||
var userlist = Newtonsoft.Json.JsonConvert.DeserializeObject<List<BaoYiModel>>(jsonString);
|
||||
var QQQ = userlist.GroupBy(A => A.roomTypeID).Select(A => A.Key);
|
||||
|
||||
using var tran = this.db.Database.BeginTransaction();
|
||||
int roomTypeID = 0;
|
||||
foreach (var item in QQQ)
|
||||
{
|
||||
roomTypeID = item;
|
||||
await db.TbRoomTypeModals.Where(A => A.RoomTypeId == item).ExecuteDeleteAsync();
|
||||
}
|
||||
|
||||
var roomType = db.TbRoomTypes.Find(roomTypeID);
|
||||
|
||||
foreach (var item in userlist)
|
||||
{
|
||||
var id = item.id;
|
||||
var modalAddress = item.modalAddress; ;
|
||||
var outlet = item.outlet;
|
||||
var name = item.name;
|
||||
var englishName = item.englishName;
|
||||
var power = item.power;
|
||||
var twName = item.twName;
|
||||
var aliasName = item.aliasName;
|
||||
var type = item.type;
|
||||
var sort = item.sort;
|
||||
var color = item.color;
|
||||
|
||||
var OfflineDisplay = item.OfflineDisplay;
|
||||
|
||||
var LowPower = item.LowPower;
|
||||
//低电保存显示
|
||||
var LowPowerDisplay = item.LowPowerDisplay;
|
||||
|
||||
//是否声音报警
|
||||
var Beep = item.Beep;
|
||||
//是否异常判断
|
||||
var Abnormal = item.Abnormal;
|
||||
|
||||
var MultipleGroupID = item.MultipleGroupID;
|
||||
var MultipleTCLName = item.MultipleTCLName;
|
||||
var TCLDeviceName = item.TCLDeviceName;
|
||||
var WXActiveIndicator = item.WXActiveIndicator;
|
||||
var ActiveIndicator = item.ActiveIndicator;
|
||||
|
||||
var roomTypeModal = new TbRoomTypeModal();
|
||||
roomTypeModal.RoomType = roomType;
|
||||
roomTypeModal.ModalAddress = modalAddress;
|
||||
roomTypeModal.Outlet = outlet;
|
||||
roomTypeModal.Name = name;
|
||||
roomTypeModal.EnglishName = englishName;
|
||||
roomTypeModal.Twname = twName;
|
||||
roomTypeModal.AliasName = aliasName;
|
||||
roomTypeModal.Power = power;
|
||||
roomTypeModal.Default1 = false;
|
||||
roomTypeModal.Type = (int)type;
|
||||
roomTypeModal.Subtype = null;
|
||||
roomTypeModal.Sort = sort;
|
||||
roomTypeModal.Color = color;
|
||||
roomTypeModal.ActiveIndicator = ActiveIndicator;//新增时默认显示
|
||||
roomTypeModal.WxactiveIndicator = true;//只要显示,微信默认允许控制
|
||||
roomTypeModal.OfflineDisplay = OfflineDisplay;
|
||||
roomTypeModal.LowPowerDisplay = LowPowerDisplay;
|
||||
roomTypeModal.Beep = Beep;
|
||||
roomTypeModal.Abnormal = Abnormal;
|
||||
|
||||
|
||||
roomTypeModal.SourceType = 0;
|
||||
roomTypeModal.MultipleTclname = MultipleTCLName;
|
||||
roomTypeModal.TcldeviceName = TCLDeviceName;
|
||||
roomTypeModal.IsUploadBaoJing = item.IsUploadBaoJing;
|
||||
int a = 0;
|
||||
int.TryParse(MultipleGroupID, out a);
|
||||
roomTypeModal.MultipleGroupId = a;
|
||||
|
||||
|
||||
db.TbRoomTypeModals.Add(roomTypeModal);
|
||||
UpdateHostModals(roomTypeModal);
|
||||
}
|
||||
await db.SaveChangesAsync();
|
||||
await this.db.Database.CommitTransactionAsync();
|
||||
|
||||
var TBL = db.TbHosts.Where(A => A.RoomTypeId == roomTypeID).Select(A => A.Id);
|
||||
foreach (var item in TBL)
|
||||
{
|
||||
CSRedisCacheHelper.Del_Partition("TimerReportData_" + item, 3);
|
||||
}
|
||||
r.isok = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.message = ex.Message + "\r\n" + ex.StackTrace;
|
||||
r.isok = false;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
private void UpdateHostModals(TbRoomTypeModal roomTypeModal)
|
||||
{
|
||||
if (roomTypeModal.RoomType == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//List<Host> hosts = HostManager.LoadAll().Where(t => t.RoomType.ID == roomTypeModal.RoomType.ID).ToList();
|
||||
List<TbHost> hosts = db.TbHosts.Where(A => A.RoomType != null && A.RoomType.Id == roomTypeModal.RoomType.Id).ToList();
|
||||
foreach (TbHost host in hosts)//该房型下所有主机关联回路
|
||||
{
|
||||
//var hostModal = HostModalManager.GetByModalAddress(host.ID, roomTypeModal.ModalAddress);
|
||||
var hostModal = db.TbHostModals.FirstOrDefault(A => A.HostId == host.Id && A.RoomTypeModal.ModalAddress.Equals(roomTypeModal.ModalAddress));
|
||||
if (null == hostModal)
|
||||
{
|
||||
//HostModalManager.Save(new HostModal { HostID = host.ID, Modal = roomTypeModal, Status = 2, Time = 0, UpdateTime = DateTime.Now });
|
||||
var n = new TbHostModal() { HostId = host.Id, RoomTypeModal = roomTypeModal, Status = 2, Time = 0, UpdateTime = DateTime.Now };
|
||||
db.TbHostModals.Add(n);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public void CacheTest_Add()
|
||||
{
|
||||
_memorycache.Set("A", "aaaa", DateTimeOffset.Now.AddMinutes(10));
|
||||
}
|
||||
[HttpPost()]
|
||||
public string CacheTest()
|
||||
{
|
||||
_memorycache.TryGetValue("A", out string AAA);
|
||||
return AAA;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class BaoYiModel
|
||||
{
|
||||
public int id { get; set; }
|
||||
public int roomTypeID { get; set; }
|
||||
public string modalAddress { get; set; }
|
||||
public string outlet { get; set; }
|
||||
public string name { get; set; }
|
||||
public string englishName { get; set; }
|
||||
public int power { get; set; }
|
||||
public string twName { get; set; }
|
||||
public string aliasName { get; set; }
|
||||
public DeviceType type { get; set; }
|
||||
public int sort { get; set; }
|
||||
public string color { get; set; }
|
||||
|
||||
public int LowPower { get; set; }
|
||||
//离线保存显示
|
||||
public bool OfflineDisplay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否低电显示
|
||||
/// </summary>
|
||||
public bool LowPowerDisplay { get; set; }
|
||||
|
||||
public bool Beep { get; set; }
|
||||
/// <summary>
|
||||
/// 是否异常判断
|
||||
/// </summary>
|
||||
public virtual bool Abnormal { get; set; }
|
||||
|
||||
|
||||
|
||||
public bool WXActiveIndicator { get; set; }
|
||||
public bool ActiveIndicator { get; set; }
|
||||
public string? MultipleGroupID { get; set; }
|
||||
public string? MultipleTCLName { get; set; }
|
||||
public string? TCLDeviceName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否上传到宝镜
|
||||
/// </summary>
|
||||
public bool IsUploadBaoJing { get; set; }
|
||||
}
|
||||
}
|
||||
164
UseSQLQueryData/Controllers/HiWeiController.cs
Normal file
164
UseSQLQueryData/Controllers/HiWeiController.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
using RestSharp;
|
||||
|
||||
namespace UseSQLQueryData.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class HiWeiController : ControllerBase
|
||||
{
|
||||
|
||||
public static string HiWeiKey = "HiWei_";
|
||||
public static int ExpireTimer = 60 * 3;
|
||||
public string? HiWeiAppId { get; set; }
|
||||
public string? HiWeiAppSecret { get; set; }
|
||||
|
||||
public IConfiguration ConfigurationBuilder { get; set; }
|
||||
|
||||
|
||||
public static Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
public HiWeiController(IConfiguration config)
|
||||
{
|
||||
this.ConfigurationBuilder = config;
|
||||
HiWeiAppId = config["HiWeiAppId"];
|
||||
HiWeiAppSecret = config["HiWeiAppSecret"];
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
//public ReturnInfo HiWeiOAuthRequest(string response_type, string client_id, string client_secret, string redirect_uri)
|
||||
public ReturnInfo HiWeiOAuthRequest(string? response_type, string? client_id, string? client_secret, string? redirect_uri, string? code, string? refresh_token)
|
||||
{
|
||||
|
||||
ReturnInfo returninfo = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
//code wijsv8hf5izejkny 6c1014dab24c41369068d12e4f7e145c http://tvos.hw-iot.com.cn/voice-service/token/auth/SKG9ZSC3|
|
||||
logger.Error("Data:" + response_type + " " + client_id + " " + client_secret + " " + redirect_uri);
|
||||
Random r = new Random();
|
||||
int newcode = r.Next(1, 10000);
|
||||
string id = HiWeiAppId;
|
||||
string secret = HiWeiAppSecret;
|
||||
string Key = HiWeiKey + newcode;
|
||||
if (response_type.Equals("code") && client_id.Equals(id) && client_secret.Equals(secret))
|
||||
{
|
||||
var t1 = Guid.NewGuid().ToString();
|
||||
var t2 = Guid.NewGuid().ToString();
|
||||
|
||||
var t3 = Guid.NewGuid().ToString();
|
||||
var t4 = Guid.NewGuid().ToString();
|
||||
var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(t1 + "###" + t2));
|
||||
var reftoken = Convert.ToBase64String(Encoding.UTF8.GetBytes(t3 + "###" + t4));
|
||||
|
||||
HiWeiToken g = new HiWeiToken();
|
||||
g.access_token = token;
|
||||
g.refresh_token = reftoken;
|
||||
g.expires_in = new TimeSpan(20, 0, 0).TotalSeconds;
|
||||
|
||||
CSRedisCacheHelper.redis3.Set(Key, g, ExpireTimer);
|
||||
CSRedisCacheHelper.redis3.Set(refresh_token, g, ExpireTimer);
|
||||
|
||||
var client1 = new RestClient(redirect_uri);
|
||||
var request1 = new RestRequest("", Method.Get);
|
||||
request1.AddQueryParameter("code", newcode);
|
||||
|
||||
var QQQ = client1.Execute(request1);
|
||||
var content = QQQ.Content;
|
||||
logger.Error("返回的数据为:" + content);
|
||||
HttpStatusCode HHH = QQQ.StatusCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
returninfo.isok = false;
|
||||
returninfo.message = "没有授权";
|
||||
}
|
||||
Dictionary<string, int> codere = new Dictionary<string, int>();
|
||||
codere.Add("code", newcode);
|
||||
returninfo.isok = true;
|
||||
returninfo.response = codere;
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
returninfo.isok = false;
|
||||
returninfo.message = ex.Message;
|
||||
}
|
||||
return returninfo;
|
||||
}
|
||||
|
||||
[HttpGet()]
|
||||
public object mytoken(string code)
|
||||
{
|
||||
|
||||
return "aaaaa";
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public object gettoken([FromBody] Data data)
|
||||
{
|
||||
//ReturnInfo re = new ReturnInfo();
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
var ttt = System.Text.Json.JsonSerializer.Serialize(data);
|
||||
logger.Error("获取token:" + ttt);
|
||||
string grant_type = data.grant_type;
|
||||
string code = data.code;
|
||||
|
||||
if (grant_type.Equals("authorization_code"))
|
||||
{
|
||||
logger.Error("code: " + code);
|
||||
string Key = HiWeiKey + code;
|
||||
var hi = CSRedisCacheHelper.redis3.Get<HiWeiToken>(Key);
|
||||
|
||||
if (hi != null)
|
||||
{
|
||||
logger.Error("返回了");
|
||||
return hi;
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.Error("没有获取到");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (grant_type.Equals("refresh_token"))
|
||||
{
|
||||
var hi = CSRedisCacheHelper.redis3.Get<HiWeiToken>("11111232323");
|
||||
if (hi != null)
|
||||
{
|
||||
return hi;
|
||||
}
|
||||
else
|
||||
{
|
||||
return hi;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class Data
|
||||
{
|
||||
public string code { get; set; }
|
||||
public string grant_type { get; set; }
|
||||
public string client_secret { get; set; }
|
||||
public string client_id { get; set; }
|
||||
|
||||
}
|
||||
public class HiWeiToken
|
||||
{
|
||||
public string access_token { get; set; }
|
||||
public string refresh_token { get; set; }
|
||||
public double expires_in { get; set; }
|
||||
}
|
||||
}
|
||||
78
UseSQLQueryData/Controllers/IISController.cs
Normal file
78
UseSQLQueryData/Controllers/IISController.cs
Normal file
@@ -0,0 +1,78 @@
|
||||
using CliWrap;
|
||||
using CliWrap.Buffered;
|
||||
using Common;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Web.Administration;
|
||||
|
||||
namespace UseSQLQueryData.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class IISController : ControllerBase
|
||||
{
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> Recly()
|
||||
{
|
||||
var dt = DateTime.Now;
|
||||
var span = new TimeSpan(0, 1, 0);
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
if (dt - Program.Dt > span)
|
||||
{
|
||||
|
||||
string Key = "IISRecycle";
|
||||
CSRedisCacheHelper.redis3.Set(Key,1);
|
||||
//using (ServerManager serverManager = new ServerManager())
|
||||
//{
|
||||
// var pool = serverManager.ApplicationPools["DefaultAppPool"];
|
||||
// if (pool != null)
|
||||
// {
|
||||
// pool.Recycle();
|
||||
// r.isok = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// r.isok = false;
|
||||
// }
|
||||
//}
|
||||
|
||||
//Program.Dt = DateTime.Now;
|
||||
//var cmd = await Cli.Wrap("1.cmd")
|
||||
//.WithWorkingDirectory("D:\\BLW_Data\\cricsSQL")
|
||||
//.ExecuteBufferedAsync();
|
||||
|
||||
|
||||
//var result = await Cli.Wrap(@"C:\Windows\System32\inetsrv\appcmd.exe")
|
||||
// .WithArguments("recycle apppool /apppool.name:DefaultAppPool")
|
||||
// .ExecuteBufferedAsync();
|
||||
|
||||
//if (result.ExitCode == 0)
|
||||
//{
|
||||
// Console.WriteLine("应用程序池回收成功!");
|
||||
// Console.WriteLine(result.StandardOutput);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// Console.WriteLine($"回收失败,错误代码: {result.ExitCode}");
|
||||
// Console.WriteLine(result.StandardError);
|
||||
//}
|
||||
r.isok = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
r.isok = false;
|
||||
r.message = "1分钟之间只能回收一次";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.message = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
91
UseSQLQueryData/Controllers/MonitorController.cs
Normal file
91
UseSQLQueryData/Controllers/MonitorController.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using Common;
|
||||
using CommonEntity;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
|
||||
namespace UseSQLQueryData.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class MonitorController : ControllerBase
|
||||
{
|
||||
public static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
[HttpPost()]
|
||||
public ReturnInfo SetMonitor([FromBody] MonitorData lll)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
lll.DataList.RemoveAll(x => string.IsNullOrEmpty(x.IPAddress) || x.Port <= 0);
|
||||
var osa = lll.DataList.Select(x => { x.AddDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); return x; }).ToList();
|
||||
if (lll.Handler.Equals("add"))
|
||||
{
|
||||
var QQQ = CSRedisCacheHelper.Get<List<MonitorEndPoint>>("MonitorEndPointList");
|
||||
|
||||
foreach (var item in osa)
|
||||
{
|
||||
bool bbb= QQQ.Any(A=>A.IPAddress.Equals(item.IPAddress)&&A.Port==item.Port);
|
||||
if (bbb==false)
|
||||
{
|
||||
QQQ.Add(item);
|
||||
}
|
||||
}
|
||||
CSRedisCacheHelper.Forever<List<MonitorEndPoint>>("MonitorEndPointList",QQQ);
|
||||
}
|
||||
else if (lll.Handler.Equals("remove"))
|
||||
{
|
||||
var QQQ = CSRedisCacheHelper.Get<List<MonitorEndPoint>>("MonitorEndPointList");
|
||||
foreach (var item in lll.DataList)
|
||||
{
|
||||
QQQ.RemoveAll(A => A.IPAddress.Equals(item.IPAddress) && A.Port == item.Port);
|
||||
}
|
||||
|
||||
CSRedisCacheHelper.Forever<List<MonitorEndPoint>>("MonitorEndPointList", QQQ);
|
||||
}
|
||||
|
||||
r.isok = true;
|
||||
r.response = "sucess";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public ReturnInfo GetMonitorData()
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
var QQQ = CSRedisCacheHelper.Get<List<MonitorEndPoint>>("MonitorEndPointList");
|
||||
r.isok = true;
|
||||
r.response = QQQ;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex.Message);
|
||||
logger.Error(ex.StackTrace);
|
||||
r.isok = false;
|
||||
r.message = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
public class MonitorData
|
||||
{
|
||||
public string? Handler { get; set; }
|
||||
public List<MonitorEndPoint?> DataList { get; set; }
|
||||
}
|
||||
public class MonitorEndPoint
|
||||
{
|
||||
public string? IPAddress { get; set; }
|
||||
public int? Port { get; set; } = 0;
|
||||
public string? AddDateTime { get; set; }
|
||||
}
|
||||
}
|
||||
364
UseSQLQueryData/Controllers/ValuesController.cs
Normal file
364
UseSQLQueryData/Controllers/ValuesController.cs
Normal file
@@ -0,0 +1,364 @@
|
||||
using System.Data;
|
||||
using CliWrap;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.OutputCaching;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using NLog;
|
||||
using RestSharp;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace UseSQLQueryData.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[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 = "Data Source=DESKTOP-DUNS5K7;Initial Catalog=CRICS;User ID=sa;Password=123456;Trust Server Certificate=True";
|
||||
public static Logger logger = LogManager.GetCurrentClassLogger();
|
||||
[HttpGet()]
|
||||
[OutputCache()]
|
||||
public async Task<ReturnInfo> GetRoomCount()
|
||||
{
|
||||
ReturnInfo returnInfo = new ReturnInfo();
|
||||
//return returnInfo;
|
||||
try
|
||||
{
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
con.Open();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
string sql = @"select A.HotelID,B.Code,Count(A.HotelID) as TotalCount from tb_Hosts A
|
||||
left join tb_Sys_Hotels B
|
||||
on A.HotelID=B.ID
|
||||
where A.IsDeleted=0 and B.IsDeleted=0
|
||||
group by HotelID,B.Code
|
||||
ORDER BY HotelID;";
|
||||
sqlCommand.CommandText = sql;
|
||||
//SqlParameter ps1 = new SqlParameter("@HotelID", hotelid);
|
||||
//sqlCommand.Parameters.Add(ps1);
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
List<ChaXun> chaList = new List<ChaXun>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
var id = item["HotelID"].ToString();
|
||||
var totalcount = item["TotalCount"].ToString();
|
||||
var code = item["Code"].ToString();
|
||||
ChaXun cha = new ChaXun();
|
||||
cha.HotelID = id;
|
||||
cha.HotelCode = code;
|
||||
cha.TotalCount = totalcount;
|
||||
chaList.Add(cha);
|
||||
}
|
||||
}
|
||||
returnInfo.isok = true;
|
||||
returnInfo.response = chaList;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
returnInfo.isok = false;
|
||||
returnInfo.message = ex.Message;
|
||||
}
|
||||
return returnInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成主机标识号
|
||||
/// </summary>
|
||||
/// <param name="HotelID"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GenericHOSTNUMBER([FromForm] string HotelID, [FromForm] string HotelCode)
|
||||
{
|
||||
//2147 --099008
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
logger.Error("HotelID:" + HotelID + " HotelCode:" + HotelCode);
|
||||
ushort a = ushort.Parse(HotelCode);
|
||||
byte[] bbf = BitConverter.GetBytes(a);
|
||||
byte b1 = bbf[0];
|
||||
byte b2 = bbf[1];
|
||||
string nn1 = b1.ToString("000");
|
||||
string nn2 = b2.ToString("000");
|
||||
|
||||
string nn3 = nn1 + nn2;
|
||||
|
||||
using SqlConnection con = new SqlConnection("server=WIN-061EVIHKD86\\BLW;database=CRICS;uid=sa;pwd=pass@123$%^;TrustServerCertificate=True;");
|
||||
con.Open();
|
||||
SqlTransaction tran = con.BeginTransaction();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
sqlCommand.Transaction = tran;
|
||||
|
||||
string sql = string.Format("select ID,MAC from tb_Hosts where HotelID={0} and IsDeleted=0 and MAC is not NULL and MAC!='';", HotelID);
|
||||
sqlCommand.CommandText = sql;
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
var id = item["ID"].ToString();
|
||||
var mymac = item["MAC"].ToString();
|
||||
if (!string.IsNullOrEmpty(mymac))
|
||||
{
|
||||
|
||||
string[] NNN = mymac.Split('-');
|
||||
string n1 = NNN[4];
|
||||
string n2 = NNN[5];
|
||||
byte bbn1 = Convert.ToByte(n1, 16);
|
||||
byte bbn2 = Convert.ToByte(n2, 16);
|
||||
short MAC1 = Convert.ToInt16(bbn1);
|
||||
short MAC2 = Convert.ToInt16(bbn2);
|
||||
|
||||
string HOSTNUMBER = nn3 + MAC1.ToString("000") + MAC2.ToString("000");
|
||||
|
||||
string sql111 = string.Format(@"update tb_Hosts set HostNumber='{0}' where ID={1} and (HostNumber is NULL or HostNumber='');", HOSTNUMBER, id);
|
||||
sqlCommand.CommandText = sql111;
|
||||
await sqlCommand.ExecuteNonQueryAsync();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
tran.Commit();
|
||||
r.isok = true;
|
||||
r.response = "success";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error("出错了" + ex.Message);
|
||||
r.isok = false;
|
||||
r.message = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="HotelID"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> SendGetRCUInfoData(string HotelID)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<string> HttpRecv()
|
||||
{
|
||||
|
||||
using var reader = new StreamReader(Request.Body);
|
||||
var body = await reader.ReadToEndAsync();
|
||||
return body;
|
||||
}
|
||||
|
||||
|
||||
#region TFTP
|
||||
|
||||
public static string BaseUrl = "https://www.boonlive-rcu.com/";
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> GetTFTPInfo()
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
|
||||
using SqlConnection con = new SqlConnection(SqlConnectionString);
|
||||
await con.OpenAsync();
|
||||
using SqlCommand sqlCommand = con.CreateCommand();
|
||||
|
||||
string sql = @"select A.*,B.HostNumber,B.MAC from TFTP_set A left join tb_Hosts B on A.HostID=B.ID;";
|
||||
sqlCommand.CommandText = sql;
|
||||
SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand);
|
||||
DataSet dataSet = new DataSet();
|
||||
adapter.Fill(dataSet);
|
||||
|
||||
DataTable dt = dataSet.Tables[0];
|
||||
List<TFTPSet> chaList = new List<TFTPSet>();
|
||||
if (dt != null && dt.Rows.Count > 0)
|
||||
{
|
||||
foreach (DataRow item in dt.Rows)
|
||||
{
|
||||
var id = item["ID"].ToString();
|
||||
var HotelCode = item["HotelCode"].ToString();
|
||||
var HotelID = item["HotelID"].ToString();
|
||||
var RoomNumber = item["RoomNumber"].ToString();
|
||||
var HostID = item["HostID"].ToString();
|
||||
var HostNumber = item["HostNumber"].ToString();
|
||||
var MAC = item["MAC"].ToString();
|
||||
var TargetPort = item["TargetPort"].ToString();
|
||||
var TargetDomain = item["TargetDomain"].ToString();
|
||||
var LT = item["LastTime"].ToString();
|
||||
var IT = item["IsTrigger"].ToString();
|
||||
var CT = item["CreateTime"].ToString();
|
||||
TFTPSet cha = new TFTPSet();
|
||||
cha.hotelcode = HotelCode;
|
||||
cha.hotelid = HotelID;
|
||||
cha.hostnumber = HostNumber;
|
||||
cha.roomnumber = RoomNumber;
|
||||
cha.mac = MAC;
|
||||
cha.hostid = HostID;
|
||||
cha.domain = TargetDomain;
|
||||
cha.port = TargetPort;
|
||||
cha.lasttime = LT;
|
||||
cha.isenable = IT;
|
||||
cha.createtime = CT;
|
||||
chaList.Add(cha);
|
||||
}
|
||||
}
|
||||
|
||||
var U = chaList.GroupBy(A => new { A.hotelid, A.hotelcode });
|
||||
List<TFTP> tl = new List<TFTP>();
|
||||
foreach (var item in U)
|
||||
{
|
||||
TFTP t = new TFTP();
|
||||
t.hotelcode = item.Key.hotelcode;
|
||||
t.hotelid = item.Key.hotelid;
|
||||
t.TFTPRoomList = item.ToList();
|
||||
tl.Add(t);
|
||||
}
|
||||
|
||||
r.isok = true;
|
||||
r.response = tl;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
throw;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="listdata">[{"hotelcode":"","hostnumber":"","mac":""}]</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> TFTPReadSet([FromBody] List<Dictionary<string, string>> listdata)
|
||||
{
|
||||
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
var options = new RestClientOptions(BaseUrl);
|
||||
var client = new RestClient(options);
|
||||
|
||||
var request = new RestRequest("api/TFTPReadSet");
|
||||
request.AddJsonBody(listdata);
|
||||
RestResponse response = await client.PostAsync(request);
|
||||
string? str1 = response.Content;
|
||||
r.isok = true;
|
||||
r.response = str1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
[HttpPost()]
|
||||
public async Task<ReturnInfo> TFTPSet_Execute([FromBody] FTP_JSON body)
|
||||
{
|
||||
ReturnInfo r = new ReturnInfo();
|
||||
try
|
||||
{
|
||||
var options = new RestClientOptions(BaseUrl);
|
||||
var client = new RestClient(options);
|
||||
var request = new RestRequest("api/TFTPSet_Execute");
|
||||
request.AddJsonBody(body);
|
||||
RestResponse response = await client.PostAsync(request);
|
||||
string? str1 = response.Content;
|
||||
r.isok = true;
|
||||
r.response = str1;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
r.isok = false;
|
||||
r.response = ex.Message;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
public class TFTP
|
||||
{
|
||||
public string hotelcode { get; set; }
|
||||
public string hotelid { get; set; }
|
||||
public List<TFTPSet> TFTPRoomList { get; set; }
|
||||
|
||||
}
|
||||
public class TFTPSet
|
||||
{
|
||||
public string hotelcode { get; set; }
|
||||
public string hotelid { get; set; }
|
||||
public string hostid { get; set; }
|
||||
public string roomnumber { get; set; }
|
||||
public string hostnumber { get; set; }
|
||||
public string mac { get; set; }
|
||||
public string port { get; set; }
|
||||
public string domain { get; set; }
|
||||
/// <summary>
|
||||
/// 上传 几个小时的日志
|
||||
/// </summary>
|
||||
public string lasttime { get; set; }
|
||||
public string isenable { get; set; }
|
||||
public string createtime { get; set; }
|
||||
}
|
||||
|
||||
public class host_data
|
||||
{
|
||||
public string hostnumber { get; set; }
|
||||
public string mac { get; set; }
|
||||
}
|
||||
public class FTP_JSON
|
||||
{
|
||||
public List<host_data> host_data { get; set; }
|
||||
public bool isenable { get; set; }
|
||||
public string domain { get; set; }
|
||||
public UInt16 port { get; set; }
|
||||
public UInt16 lasttime { get; set; }
|
||||
}
|
||||
public class ChaXun
|
||||
{
|
||||
public string HotelID { get; set; }
|
||||
public string HotelCode { get; set; }
|
||||
public string TotalCount { get; set; }
|
||||
}
|
||||
public class ReturnInfo
|
||||
{
|
||||
public bool isok { set; get; } // 是否成功,true成功
|
||||
public string message { set; get; } // 传递接口信息,or报错信息
|
||||
public int status { set; get; } // 服务器报错信息,正确为200,错误404/500等
|
||||
public object response { set; get; } // 获取到的信息本体,若报错则为null
|
||||
}
|
||||
}
|
||||
33
UseSQLQueryData/Controllers/WeatherForecastController.cs
Normal file
33
UseSQLQueryData/Controllers/WeatherForecastController.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace UseSQLQueryData.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
public class WeatherForecastController : ControllerBase
|
||||
{
|
||||
private static readonly string[] Summaries = new[]
|
||||
{
|
||||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
|
||||
};
|
||||
|
||||
private readonly ILogger<WeatherForecastController> _logger;
|
||||
|
||||
public WeatherForecastController(ILogger<WeatherForecastController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IEnumerable<WeatherForecast> Get()
|
||||
{
|
||||
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
|
||||
{
|
||||
Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
|
||||
TemperatureC = Random.Shared.Next(-20, 55),
|
||||
Summary = Summaries[Random.Shared.Next(Summaries.Length)]
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
48
UseSQLQueryData/Program.cs
Normal file
48
UseSQLQueryData/Program.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using DAL.New_Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace UseSQLQueryData
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static DateTime Dt = DateTime.Now;
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
Dt =new DateTime(1970,1,1,0,0,0);
|
||||
builder.Services.AddDbContext<RicsContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"));
|
||||
});
|
||||
builder.Services.AddControllers();
|
||||
|
||||
builder.Services.AddMemoryCache();
|
||||
builder.Services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy(name: "KuaYu",
|
||||
policy =>
|
||||
{
|
||||
policy
|
||||
.AllowAnyOrigin()
|
||||
.AllowAnyHeader()
|
||||
.AllowAnyMethod();
|
||||
});
|
||||
});
|
||||
builder.Services.AddOutputCache();
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
|
||||
app.UseCors("KuaYu");
|
||||
app.UseAuthorization();
|
||||
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
app.Run();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?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>true</SelfContained>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<_PublishTargetUrl>E:\tian\BLS\BLWLogServer\UseSQLQueryData\bin\Release\net8.0\publish\</_PublishTargetUrl>
|
||||
<History>True|2025-11-07T05:33:31.0471634Z||;True|2025-11-07T13:31:20.5682483+08:00||;True|2025-11-07T13:22:03.2538784+08:00||;True|2025-11-07T13:21:05.5293446+08:00||;True|2025-11-07T11:53:38.2357672+08:00||;True|2025-11-07T11:20:07.6912037+08:00||;True|2025-11-07T10:56:32.1932199+08:00||;True|2025-11-04T16:21:24.6016597+08:00||;True|2025-11-04T16:08:01.8306281+08:00||;True|2025-11-04T14:53:10.2683542+08:00||;True|2025-11-04T09:01:06.9087853+08:00||;True|2025-09-22T10:39:12.0773121+08:00||;True|2025-09-02T10:55:14.4248175+08:00||;True|2025-09-02T10:51:03.2536348+08:00||;True|2025-09-02T10:45:14.7601363+08:00||;True|2025-09-02T10:02:13.3617335+08:00||;True|2025-09-02T09:53:06.2207119+08:00||;True|2025-09-02T09:46:46.8635672+08:00||;False|2025-09-02T09:46:12.6849116+08:00||;True|2025-09-02T09:42:10.1092326+08:00||;True|2025-09-02T09:41:32.2469206+08:00||;True|2025-09-02T09:33:49.6721005+08:00||;True|2025-09-02T09:26:54.2061225+08:00||;True|2025-09-02T09:20:53.2529651+08:00||;True|2025-09-02T09:08:54.8123555+08:00||;True|2025-09-02T08:56:42.6561083+08:00||;True|2025-08-30T09:02:40.4888590+08:00||;True|2025-08-27T13:55:28.5898320+08:00||;True|2025-08-27T11:45:16.5325354+08:00||;True|2025-08-27T11:45:09.9546456+08:00||;True|2025-08-27T11:41:14.2662113+08:00||;True|2025-08-27T11:40:50.0169860+08:00||;True|2025-08-26T16:46:44.1731402+08:00||;True|2025-08-26T15:12:48.0529751+08:00||;True|2025-08-26T15:08:56.6003382+08:00||;True|2025-08-26T15:03:36.2932504+08:00||;True|2025-08-26T14:38:49.7608591+08:00||;True|2025-08-26T14:35:54.6541443+08:00||;True|2025-08-26T14:32:43.0146924+08:00||;True|2025-08-26T14:28:09.5325849+08:00||;True|2025-08-26T14:17:45.1671612+08:00||;True|2025-08-26T14:09:23.7912496+08:00||;True|2025-08-26T14:06:17.3251591+08:00||;True|2025-08-26T13:59:36.1310592+08:00||;True|2025-08-26T13:51:08.0473014+08:00||;True|2025-08-26T13:47:55.0643049+08:00||;True|2025-08-26T13:47:37.6858888+08:00||;True|2025-08-26T13:36:06.7868682+08:00||;True|2025-08-26T11:34:32.1855844+08:00||;True|2025-08-26T10:40:47.7552748+08:00||;True|2025-08-26T10:39:02.0026958+08:00||;True|2025-08-26T10:37:33.1782340+08:00||;True|2025-08-26T10:32:18.1084637+08:00||;True|2025-08-26T10:26:52.1716197+08:00||;True|2025-08-26T10:25:57.7810952+08:00||;True|2025-08-26T09:50:19.7164627+08:00||;True|2025-08-26T09:48:02.2640537+08:00||;True|2025-08-26T09:43:19.1545028+08:00||;True|2025-08-26T09:29:41.9360936+08:00||;True|2025-08-22T10:50:57.1412310+08:00||;True|2025-08-22T10:50:44.6477231+08:00||;True|2025-08-22T10:34:01.4521338+08:00||;True|2025-08-22T10:27:24.7964715+08:00||;True|2025-08-22T09:50:46.1928064+08:00||;True|2025-08-21T15:53:35.3929761+08:00||;True|2025-08-21T14:01:43.3138433+08:00||;True|2025-08-13T10:19:46.7006037+08:00||;True|2025-08-07T15:07:37.6383093+08:00||;True|2025-08-07T15:06:54.7720609+08:00||;True|2025-08-07T15:05:26.4943382+08:00||;True|2025-08-07T14:55:04.3839590+08:00||;True|2025-08-07T14:52:33.1834214+08:00||;True|2025-07-30T15:46:31.1561876+08:00||;True|2025-07-30T15:43:39.1118948+08:00||;True|2025-07-30T15:39:31.8063859+08:00||;True|2025-07-30T15:37:14.3864707+08:00||;True|2025-07-30T15:20:55.9890753+08:00||;True|2025-07-30T15:18:50.3835509+08:00||;True|2025-07-30T15:18:37.7136553+08:00||;True|2025-07-30T15:14:32.9036975+08:00||;</History>
|
||||
<LastFailureDetails />
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
31
UseSQLQueryData/Properties/launchSettings.json
Normal file
31
UseSQLQueryData/Properties/launchSettings.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/launchsettings.json",
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:49723",
|
||||
"sslPort": 0
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"http": {
|
||||
"commandName": "Project",
|
||||
"dotnetRunMessages": true,
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"applicationUrl": "http://localhost:5108",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"launchUrl": "weatherforecast",
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
25
UseSQLQueryData/UseSQLQueryData.csproj
Normal file
25
UseSQLQueryData/UseSQLQueryData.csproj
Normal file
@@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CliWrap" Version="3.9.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.19" />
|
||||
<PackageReference Include="Microsoft.Data.SqlClient" Version="6.1.0" />
|
||||
<PackageReference Include="Microsoft.Web.Administration" Version="11.1.0" />
|
||||
<PackageReference Include="NLog" Version="6.0.3" />
|
||||
<PackageReference Include="NLog.Schema" Version="6.0.3" />
|
||||
<PackageReference Include="RestSharp" Version="112.1.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CommonEntity\CommonEntity.csproj" />
|
||||
<ProjectReference Include="..\CommonTools\CommonTools.csproj" />
|
||||
<ProjectReference Include="..\DAL\DAL.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
8
UseSQLQueryData/UseSQLQueryData.csproj.user
Normal file
8
UseSQLQueryData/UseSQLQueryData.csproj.user
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
|
||||
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
|
||||
<NameOfLastUsedPublishProfile>E:\tian\BLS\BLWLogServer\UseSQLQueryData\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
6
UseSQLQueryData/UseSQLQueryData.http
Normal file
6
UseSQLQueryData/UseSQLQueryData.http
Normal file
@@ -0,0 +1,6 @@
|
||||
@UseSQLQueryData_HostAddress = http://localhost:5108
|
||||
|
||||
GET {{UseSQLQueryData_HostAddress}}/weatherforecast/
|
||||
Accept: application/json
|
||||
|
||||
###
|
||||
13
UseSQLQueryData/WeatherForecast.cs
Normal file
13
UseSQLQueryData/WeatherForecast.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace UseSQLQueryData
|
||||
{
|
||||
public class WeatherForecast
|
||||
{
|
||||
public DateOnly Date { get; set; }
|
||||
|
||||
public int TemperatureC { get; set; }
|
||||
|
||||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
|
||||
|
||||
public string? Summary { get; set; }
|
||||
}
|
||||
}
|
||||
8
UseSQLQueryData/appsettings.Development.json
Normal file
8
UseSQLQueryData/appsettings.Development.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
}
|
||||
}
|
||||
15
UseSQLQueryData/appsettings.json
Normal file
15
UseSQLQueryData/appsettings.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Data Source=DESKTOP-DUNS5K7;Initial Catalog=RICS;User ID=sa;Password=123456;Trust Server Certificate=True"
|
||||
},
|
||||
"HiWeiAppId": "wijsv8hf5izejkny",
|
||||
"HiWeiAppSecret": "6c1014dab24c41369068d12e4f7e145c",
|
||||
"Logging": {
|
||||
"LogLevel": {
|
||||
"Default": "Information",
|
||||
"Microsoft.AspNetCore": "Warning"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*"
|
||||
}
|
||||
35
UseSQLQueryData/nlog.config
Normal file
35
UseSQLQueryData/nlog.config
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
|
||||
<!-- enable asp.net core layout renderers -->
|
||||
<targets>
|
||||
<!--项目日志保存文件路径说明fileName="${basedir}/保存目录,以年月日的格式创建/${shortdate}/${记录器名称}-${单级记录}-${shortdate}.txt"-->
|
||||
<target name="info_file" xsi:type="File"
|
||||
fileName="${basedir}/Logs/${shortdate}/info_${shortdate}.txt"
|
||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=ToString} ${newline} ${stacktrace} ${newline}"
|
||||
archiveFileName="${basedir}/archives/info_${shortdate}-{#####}.txt"
|
||||
archiveAboveSize="102400"
|
||||
archiveNumbering="Sequence"
|
||||
concurrentWrites="true"
|
||||
keepFileOpen="false" />
|
||||
<target name="error_file" xsi:type="File"
|
||||
fileName="${basedir}/Logs/${shortdate}/error_${shortdate}.txt"
|
||||
layout="${longdate}|${level:uppercase=true}|${logger}|${message}|${exception:format=ToString} ${newline} ${stacktrace} ${newline}"
|
||||
archiveFileName="${basedir}/archives/error_${shortdate}-{#####}.txt"
|
||||
archiveAboveSize="102400"
|
||||
archiveNumbering="Sequence"
|
||||
concurrentWrites="true"
|
||||
keepFileOpen="false" />
|
||||
</targets>
|
||||
|
||||
<!--规则配置,final - 最终规则匹配后不处理任何规则-->
|
||||
<!--规则配置,final - 最终规则匹配后不处理任何规则-->
|
||||
<!--定义使用哪个target输出-->
|
||||
<rules>
|
||||
<!-- 优先级从高到低依次为:OFF、FATAL、ERROR、WARN、INFO、DEBUG、TRACE、 ALL -->
|
||||
<!-- 将所有日志输出到文件 -->
|
||||
<logger name="*" minlevel="FATAL" maxlevel="FATAL" writeTo="info_file" />
|
||||
<logger name="*" minlevel="Error" writeTo="error_file" />
|
||||
</rules>
|
||||
</nlog>
|
||||
Reference in New Issue
Block a user