田工版本初次提交

This commit is contained in:
2025-12-11 14:13:27 +08:00
parent ab6e620f8e
commit fe7f5313bc
146 changed files with 86546 additions and 3 deletions

View File

@@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Dysmsapi.Model.V20170525;
namespace BLWWS_BLL
{
public static class AliyunSMSHelper
{
/// <summary>
/// 发送验证码
/// </summary>
/// <param name="recNum">接收号码,多个号码可以逗号分隔</param>
/// <param name="code">验证码</param>
public static void SendVerifySMS(string recNum, string code)
{
SendSMS(recNum, "{'code':'" + code + "'}");
}
/// <summary>
/// 发送验证码
/// </summary>
/// <param name="recNum">接收号码,多个号码可以逗号分隔</param>
/// <param name="paramString">短信模板中的变量数字需要转换为字符串个人用户每个变量长度必须小于15个字符。</param>
/// <returns></returns>
private static void SendSMS(string recNum, string paramString)
{
IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "LTAICuIny2zJSSjm", "uguZzmshKPtT0fW87E8sP1TXe7Kwc9");
//IAcsClient client = new DefaultAcsClient(profile);
//SingleSendSmsRequest request = new SingleSendSmsRequest();
DefaultProfile.AddEndpoint("cn-hangzhou", "cn-hangzhou", "Dysmsapi", "dysmsapi.aliyuncs.com");//短信API产品名称,短信API产品域名
IAcsClient acsClient = new DefaultAcsClient(profile);
SendSmsRequest request = new SendSmsRequest();
try
{
//request.SignName = "小威提示";//"管理控制台中配置的短信签名(状态必须是验证通过)"
//request.TemplateCode = "SMS_95095011";//"管理控制台中配置的审核通过的短信模板的模板CODE状态必须是验证通过"
//request.RecNum = recNum;
//request.ParamString = paramString;
//SingleSendSmsResponse httpResponse = client.GetAcsResponse(request);
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用批量上限为20个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
request.PhoneNumbers = recNum;
//必填:短信签名-可在短信控制台中找到
request.SignName = "小威提示";
//必填:短信模板-可在短信控制台中找到
request.TemplateCode = "SMS_95095011";
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
request.TemplateParam = paramString;// "{\"customer\":\"123\"}";
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
//request.OutId = "21212121211";
//请求失败这里会抛ClientException异常
//SendSmsResponse sendSmsResponse =
acsClient.GetAcsResponse(request);
//LogHelper.WriteLog(sendSmsResponse.Message);
}
catch (ServerException e)
{
LogHelper.WriteLog(e.ToString());
}
catch (ClientException e)
{
LogHelper.WriteLog(e.ToString());
}
}
}
}

1230
BLLCore/BLL.cs Normal file

File diff suppressed because it is too large Load Diff

33
BLLCore/BLLCore.csproj Normal file
View File

@@ -0,0 +1,33 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.8.807" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
<PackageReference Include="MySql.Data" Version="8.4.0" />
<PackageReference Include="NLog" Version="6.0.6" />
<PackageReference Include="Quartz" Version="3.15.1" />
<PackageReference Include="RestSharp" Version="113.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.210" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.22" />
</ItemGroup>
<ItemGroup>
<Reference Include="AipSdk">
<HintPath>..\dll\AipSdk.dll</HintPath>
</Reference>
<Reference Include="aliyun-net-sdk-core">
<HintPath>..\dll\aliyun-net-sdk-core.dll</HintPath>
</Reference>
<Reference Include="aliyun-net-sdk-dysmsapi">
<HintPath>..\dll\aliyun-net-sdk-dysmsapi.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using CSRedis;
namespace BLWWS_BLL.Common
{
/// <summary>
/// Redis缓存辅助类
/// </summary>
public class CSRedisCacheHelper
{
public static CSRedisClient redis;
public static CSRedisClient redis3;
public static CSRedisClient redis5;
private const string ip = "127.0.0.1";
private const string port = "6379";
static CSRedisCacheHelper()
{
var redisHostStr = string.Format("{0}:{1}", ip, port);
if (!string.IsNullOrEmpty(redisHostStr))
{
redis = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=1");
redis3 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=3");
//准备存储取电数据
redis5 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=5");
//string channel = "__keyevent@1__:expired";
//var QQQ = new ValueTuple<string, Action<CSRedisClient.SubscribeMessageEventArgs>>(channel, (msg) =>
// {
// if (channel.Equals(""))
// {
// }
// Console.WriteLine(msg.MessageId);
// Console.WriteLine(msg.Body);
// Console.WriteLine("11111111");
// });
//redis.Subscribe(QQQ);
}
}
/// <summary>
/// 添加缓存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
public static void Set<T>(string key, T value, int ExpireTime)
{
redis?.Set(key, value, ExpireTime * 60);
}
public static T Get<T>(string key)
{
return redis.Get<T>(key);
}
public static void Forever<T>(string key, T value)
{
redis.Set(key, value, -1);
}
public static void Del(string key)
{
redis.Del(key);
}
/// <summary>
/// 判断是否存在
/// </summary>
/// <param name="key"></param>
/// <param name="mac"></param>
/// <returns></returns>
public static bool Contains(string key, string mac)
{
bool result = redis.Exists(mac);
if (!result)
{
result = redis.Exists(key);
}
return result;
}
public static bool Contains(string key)
{
bool result = redis.Exists(key);
return result;
}
public static void Publish(string Topic, string Payload)
{
CSRedisCacheHelper.redis3.Publish(Topic, Payload);
}
}
}

59
BLLCore/EntityData.cs Normal file
View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public class StaticData
{
public static string PMSLogMonitor = "PMSLogMonitor";
}
public class CheckInYuanShidata
{
public string CommandType { get; set; }
public double Step { get; set; }
public string IP { get; set; }
public string RequestId { get; set; }
public JianJie JianJieData { get; set; }
public ZhiJie ZhiJieData { get; set; }
public DateTime CurrentTime { get; set; }
public string ReturnMsg { get; set; }
}
public class JianJie
{
public string OriginallData { get; set; }
}
public class ZhiJie
{
public CheckInData CheckInData { get; set; }
public CheckOutData CheckOutData { get; set; }
public RentData RentData { get; set; }
}
public class CheckInData
{
public string key { get; set; }
public string code { get; set; }
public string roomNumber { get; set; }
public DateTime checkInDate;
public string xmlString { get; set; }
public string phoneNumber { get; set; }
public string idNumber { get; set; }
}
public class CheckOutData
{
public string key { get; set; }
public string code { get; set; }
public string roomNumber { get; set; }
public DateTime checkOutDate { get; set; }
}
public class RentData
{
public string key { get; set; }
public string code { get; set; }
public string roomNumber { get; set; }
public DateTime rentDate { get; set; }
}
}

13
BLLCore/ExtraData.cs Normal file
View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public class ExtraData
{
public string OriginalData { get; set; }
public string RequestIP { get; set; }
}
}

121
BLLCore/GlobalCache.cs Normal file
View File

@@ -0,0 +1,121 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using BLWWS_BLL.Job;
using NLog;
using Quartz;
using Quartz.Impl;
using LogManager = NLog.LogManager;
namespace BLWWS_BLL
{
public class GlobalCache
{
public static ISchedulerFactory sf = null;
public static IScheduler sched = null;
public static ConcurrentQueue<string> GlobalCacheData = new ConcurrentQueue<string>();
public static System.Timers.Timer timer;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
public static void Init()
{
_logger.Error("初始化");
if (timer == null)
{
timer = new System.Timers.Timer();
timer.Interval = 500;
timer.Elapsed -= Timer_Elapsed;
timer.Elapsed += Timer_Elapsed;
timer.Start();
}
}
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
if (GlobalCache.GlobalCacheData.TryDequeue(out string data))
{
if (!string.IsNullOrEmpty(data))
{
string strResult = Tools.PostWebRequest(data, "");//调用人脸机接口
_logger.Error("人脸 后台:" + strResult);
}
}
}
catch (Exception ex)
{
_logger.Error("人脸 后台异常:" + ex.Message);
}
}
public static void Add(string jobData)
{
if (timer == null)
{
timer = new System.Timers.Timer();
timer.Interval = 500;
timer.Elapsed -= Timer_Elapsed;
timer.Elapsed += Timer_Elapsed;
timer.Start();
}
else
{
}
_logger.Error("后台来了任务");
GlobalCacheData.Enqueue(jobData);
//if (sf == null)
//{
// Init();
//}
//DateTimeOffset runTime = DateTimeOffset.UtcNow.AddSeconds(2);
//string JobName = "Job" + System.Guid.NewGuid().ToString("N");
//string TriggerName = "Trigger" + System.Guid.NewGuid().ToString("N");
//IJobDetail job = JobBuilder.Create<HttpJob>()
// .WithIdentity(JobName, "group1")
// .UsingJobData("JobData", jobData)
// .Build();
//// Trigger the job to run on the next round minute
//ITrigger trigger = TriggerBuilder.Create()
// .WithIdentity(TriggerName, "group1")
// .StartAt(runTime)
// .Build();
//GlobalCache.sched.ScheduleJob(job, trigger);
}
public static void TaskAdd(string jobData)
{
if (sched != null)
{
DateTimeOffset runTime = DateTimeOffset.UtcNow.AddSeconds(2);
string JobName = "Job" + System.Guid.NewGuid().ToString("N");
string TriggerName = "Trigger" + System.Guid.NewGuid().ToString("N");
IJobDetail job = JobBuilder.Create<HttpJob>()
.WithIdentity(JobName, "group1")
.UsingJobData("JobData", jobData)
.Build();
// Trigger the job to run on the next round minute
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(TriggerName, "group1")
.StartAt(runTime)
.Build();
GlobalCache.sched.ScheduleJob(job, trigger);
}
else
{
LogHelper.WriteLog("初始化");
}
}
}
}

35
BLLCore/HttpJob.cs Normal file
View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using BLWWS_BLL;
using Quartz;
namespace BLWWS_BLL.Job
{
public class HttpJob : IJob
{
public void Execute(IJobExecutionContext context)
{
try
{
var mmm = context.JobDetail.JobDataMap;
var nnn = mmm.GetString("JobData");
//string str = Tools.PostWebRequest(nnn, "");//调用人脸机接口
//LogHelper.WriteLog("后台人脸机的结果:" + str);
LogHelper.WriteLog("执行任务"+nnn);
}
catch (Exception ex)
{
//LogHelper.WriteLog("后台人脸机异常:" + ex.Message);
LogHelper.WriteLog("后台异常:" + ex.Message);
}
}
Task IJob.Execute(IJobExecutionContext context)
{
throw new NotImplementedException();
}
}
}

120
BLLCore/LogHelper.cs Normal file
View File

@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Web;
using NLog;
namespace BLWWS_BLL
{
/// <summary>
/// 日志辅助类
/// </summary>
public static class LogHelper
{
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
/// <summary>
/// 日志写入到批定的文件路径下
/// </summary>
/// <param name="msg"></param>
public static void WriteLog(string msg, string path = "")
{
_logger.Error(msg);
}
public static void WriteLogNew(string msg, string path = "")
{
_logger.Error(msg);
}
/// <summary>
/// 把数据写入指定的文件里
/// </summary>
/// <param name="path">文件路径(包括文件名称)</param>
/// <param name="msg">写入内容</param>
/// <param name="append">是否追加</param>
public static void WriteLog(string path, string msg, bool append)
{
string folder = Path.GetDirectoryName(path);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
StreamWriter sw = null;
try
{
sw = new StreamWriter(path, append, Encoding.Unicode);
sw.WriteLine(msg);
}
catch (Exception)
{
}
finally
{
if (sw != null)
{
sw.Close();
}
}
}
/// <summary>
/// 把数据写入指定的文件里
/// </summary>
/// <param name="path"></param>
/// <param name="msg"></param>
public static void WriteLog(string path, byte[] msg)
{
string folder = Path.GetDirectoryName(path);
if (!Directory.Exists(folder))
{
Directory.CreateDirectory(folder);
}
FileStream fs = null;
try
{
fs = new FileStream(path, FileMode.Append, FileAccess.Write);
fs.Write(msg, 0, msg.Length);
}
catch (Exception)
{
}
finally
{
if (fs != null)
{
fs.Close();
}
}
}
/// <summary>
/// 读取文件内容
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static string ReadLog(string path)
{
if (File.Exists(path))
{
StreamReader sr = null;
try
{
sr = new StreamReader(path);
return sr.ReadToEnd();
}
catch (Exception)
{
}
finally
{
if (sr != null)
{
sr.Close();
}
}
}
return "";
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using NLog;
namespace BLWWS_BLL
{
public static class LogHelperForService
{
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
//private static string ExePath = Application.StartupPath;
/// <summary>
/// 日志写入到批定的文件路径下
/// </summary>
/// <param name="msg"></param>
public static void WriteLog(string msg)
{
_logger.Error(msg);
}
/// <summary>
/// 把数据写入指定的文件里
/// </summary>
/// <param name="path">文件路径(包括文件名称)</param>
/// <param name="msg">写入内容</param>
/// <param name="append">是否追加</param>
public static void WriteLog(string path, string msg, bool append)
{
_logger.Error(msg);
}
}
}

18
BLLCore/MyMemoryCache.cs Normal file
View File

@@ -0,0 +1,18 @@
using Microsoft.Extensions.Caching.Memory;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLLCore
{
public class MyMemoryCache
{
public static MemoryCache Cache { get; } = new MemoryCache(
new MemoryCacheOptions
{
SizeLimit = 2048
});
}
}

20
BLLCore/PmsInterface.cs Normal file
View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public class PmsInterface
{
public int pmsId { get; set; }
public System.DateTime DateTime { get; set; }
public string pmsContent { get; set; }
public int hotelid { get; set; }
public Nullable<int> room { get; set; }
public string faceSN { get; set; }
public Nullable<int> issueresult { get; set; }
public Nullable<int> pmstype { get; set; }
public string messageid { get; set; }
}
}

4232
BLLCore/SqlHelper.cs Normal file

File diff suppressed because it is too large Load Diff

32
BLLCore/SqlSugarBase.cs Normal file
View File

@@ -0,0 +1,32 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public static class SqlSugarBase
{
public static SqlSugarClient GesmartDb()
{
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = "Server=blv-cloud-db.mysql.rds.aliyuncs.com;Database=Face;Uid=blv_rcu;Pwd=fnadiaJDIJ7546;charset=utf8;port=3307;",
DbType = SqlSugar.DbType.MySql,
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样我就不多解释了
});
//用来打印Sql方便调式
Db.Aop.OnLogExecuting = (sql, pars) =>
{
Db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value));
Debug.WriteLine(sql);
};
return Db;
}
}
}

160
BLLCore/Tools.cs Normal file
View File

@@ -0,0 +1,160 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
using System.Net;
using System.Text;
using System.IO;
using RestSharp;
namespace BLWWS_BLL
{
public static class Tools
{
/// <summary>
/// 验证指定的号码是否是手机号码
/// </summary>
/// <param name="number"></param>
/// <returns></returns>
public static bool IsMobileNumber(string number)
{
return System.Text.RegularExpressions.Regex.IsMatch(number, @"1[0-9]{10}");
}
/// <summary>
/// 获取验证码
/// </summary>
/// <param name="length">验证码长度</param>
/// <returns></returns>
public static string CreateValidateCode(int length)
{
int[] randMembers = new int[length];
int[] validateNums = new int[length];
System.Text.StringBuilder validateNumberStr = new System.Text.StringBuilder();
//生成起始序列值
int seekSeek = unchecked((int)DateTime.Now.Ticks);
Random seekRand = new Random(seekSeek);
int beginSeek = (int)seekRand.Next(0, Int32.MaxValue - length * 10000);
int[] seeks = new int[length];
for (int i = 0; i < length; i++)
{
beginSeek += 10000;
seeks[i] = beginSeek;
}
//生成随机数字
for (int i = 0; i < length; i++)
{
Random rand = new Random(seeks[i]);
int pownum = 1 * (int)Math.Pow(10, length);
randMembers[i] = rand.Next(pownum, Int32.MaxValue);
}
//抽取随机数字
for (int i = 0; i < length; i++)
{
string numStr = randMembers[i].ToString();
int numLength = numStr.Length;
Random rand = new Random();
int numPosition = rand.Next(0, numLength - 1);
validateNums[i] = Int32.Parse(numStr.Substring(numPosition, 1));
}
//生成验证码
for (int i = 0; i < length; i++)
{
validateNumberStr.Append(validateNums[i].ToString());
}
return validateNumberStr.ToString();
}
/// <summary>
/// post数据接口
/// </summary>
/// <param name="url"></param>
/// <param name="postData"></param>
/// <param name="method">post和put默认post</param>
/// <returns></returns>
public static string PostWebRequest(string url, string postData)
{
string result = string.Empty;
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.ContentType = "application/json";
req.Method = "POST";
//req.Timeout = 10000;//设置请求超时时间,单位为毫秒
byte[] data = Encoding.UTF8.GetBytes(postData);
req.ContentLength = data.Length;
using (Stream reqStream = req.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
}
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
using (Stream stream = resp.GetResponseStream())
{
using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
{
result = reader.ReadToEnd();//获取响应内容
}
}
return result;
}
public static string PostWebRequestNew(string url, string postData)
{
string content = "";
try
{
var client1 = new RestClient(url);
var request1 = new RestRequest("", Method.Post);
request1.AddJsonBody(postData);
var Response = client1.Execute(request1).Content;
content = Response;
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.Message);
}
return content;
}
public static string ByteToString(byte[] bytesData)
{
StringBuilder result = new StringBuilder();
foreach (byte r in bytesData)
{
result.Append(r.ToString("X2") + " ");
}
return result.ToString().Trim();
}
/// <summary>
/// 16进制 字符串 转换成 字节 数组
/// </summary>
/// <param name="hexString"></param>
/// <returns></returns>
public static byte[] HEXString2ByteArray(string hexString)
{
char[] hexCharacters = hexString.ToCharArray();
byte[] byteArray = new byte[hexCharacters.Length / 2];
for (int i = 0; i < byteArray.Length; i++)
{
string hexVal = string.Concat(hexCharacters[i * 2], hexCharacters[i * 2 + 1]);
byteArray[i] = Convert.ToByte(hexVal, 16);
}
return byteArray;
}
public static long GetCurrentTimeStamp(DateTime dt)
{
TimeSpan ts = dt - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Local);
long current_timestamp = Convert.ToInt64(ts.TotalSeconds);
return current_timestamp;
}
public static DateTime GetCurrentDateTime(long timestampMilliseconds)
{
DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local);
DateTime utcTime = epoch.AddSeconds(timestampMilliseconds);
return utcTime;
}
}
}

28
BLLCore/Uploadinfo.cs Normal file
View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public class Uploadinfo
{
public string key { get; set; }
public string code { get; set; }
public long checkInID { get; set; }
public int idType { get; set; }
public string idCard { get; set; }
public int sex { get; set; }
public string name { get; set; }
public string birthday { get; set; }
public string photoUrl { get; set; }
public string photo { get; set; }
}
}

22
BLLCore/pmsLog.cs Normal file
View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public class pmsLog
{
public int id { get; set; }
public int pmsid { get; set; }
public Nullable<int> step { get; set; }
public Nullable<int> app { get; set; }
public Nullable<System.DateTime> Creationtime { get; set; }
public string message { get; set; }
public string Data { get; set; }
public string HotelCode { get; set; }
public string roomid { get; set; }
public string Ip { get; set; }
}
}

View File

@@ -0,0 +1,246 @@
# **宝来威 人脸提交接口优化说明文档**
**处理流程说明图例:**
```mermaid
flowchart TD
A[入驻流程开始]:::startEnd --> B[开房信息录入]
B --> C[调用PMS接口 获取CheckInID]
C --> D[照片截取]
D --> E[调用图片质量检测模块]:::critical
E --> F{图片质量分值合格}
F -- 否 --> D
F -- 是 --> G[调用UploadPhoto接口上传图片]
G --> H{返回成功}
H -- 否 --> I[提示人脸机不可用 向前台索取门卡开门]:::warning
H -- 是 --> J[入驻流程完成]:::startEnd
I --> J
classDef startEnd fill:#D8BFD8,stroke:#333,stroke-width:1px;
classDef critical fill:#FFC0CB,stroke:#333,stroke-width:1px;
classDef warning fill:#FFA500,stroke:#333,stroke-width:1px;
class E critical
```
# 一、UploadPhoto 修改说明
这部分将说明如何调用`faceidtest.exe`可执行文件进行人脸验证,并提人脸验证工具调用说明
**修改返回值 `Msg` 规则:**
- 有问题时返回对应错误信息
- 同时确认图片分辨率和人脸机在线状态
- 二者都满足时直接返回 `OK (200)`
新增返回值代码表:
| Code | Msg |
| ---- | ------------------ |
| 200 | 图片上传成功 |
| 301 | 图片分辨率过高 |
| 302 | 图片分辨率过低 |
| 403 | 人脸机离线或不可用 |
# 二、图片质量检测模块调用说明
这部分将说明如何调用`faceidtest.exe`可执行文件进行人脸验证并提供C#调用示例代码
**说明**本应用生成的quality值是一个相对参考值推荐值*** > 0.5**
## 📍 准备工作
1. **放置可执行文件**
确保`faceidtest.exe`位于项目的 `ValRel` 子目录中:
```cmake
Project_Root/
├── ValRel/
│ └── faceidtest.exe
├── Controllers/
└── ...
```
2. **NuGet 包依赖C#环境)**
安装以下依赖包:
```json
Install-Package CliWrap
```
## ⚙️ 执行流程概述
```mermaid
flowchart TD
A[接收图片路径] --> B{参数校验}
B -- 路径为空 --> C[返回400错误]
B -- 文件不存在 --> D[返回400错误]
B -- 参数有效 --> E[准备执行环境]
E --> F{exe文件校验}
F -- 不存在 --> G[返回500错误]
F -- 存在 --> H[执行外部进程]
H --> I[解析输出]
I --> J{验证结果}
J -- 成功 --> K[返回质量分数]
J -- 失败 --> L[返回错误]
```
## 📝 调用参数说明
| 参数 | 类型 | 必需 | 说明 |
| -------------- | ------ | ---- | --------------------------------- |
| localImagePath | string | 是 | 本地图片文件的**绝对路径** |
| exeArguments | string | 是 | 固定参数格式:`{图片路径} 80x v3` |
## 🧩 C# 完整调用示例
```c#
[HttpPost]
public async Task<IActionResult> FaceValidator(string localImagePath)
{
// 1. 参数基础校验
if (string.IsNullOrWhiteSpace(localImagePath))
{
return BadRequest("图片路径不能为空");
}
if (!File.Exists(localImagePath))
{
return BadRequest($"图片文件不存在: {localImagePath}");
}
// 2. 确定exe执行路径
var exePath = Path.Combine(_hostingEnvironment.ContentRootPath, "ValRel", "faceidtest.exe");
var exeDirectory = Path.GetDirectoryName(exePath);
if (!File.Exists(exePath))
{
_logger.LogError($"可执行文件缺失: {exePath}");
return StatusCode(500, "人脸验证程序未找到");
}
try
{
// 3. 配置输出捕获
var stdOutBuffer = new StringBuilder();
var stdErrBuffer = new StringBuilder();
var arguments = $"{localImagePath} 80x v3"; // 固定参数格式
// 4. 执行外部进程20秒超时
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(20));
// 核心执行方法
var result = await Cli.Wrap(exePath)
.WithArguments(arguments)
.WithWorkingDirectory(exeDirectory)
.WithValidation(CommandResultValidation.None)
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdOutBuffer))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stdErrBuffer))
.ExecuteAsync(cts.Token);
// 5. 处理输出结果
var fullOutput = $"{stdErrBuffer}{stdOutBuffer}";
string[] lines = fullOutput.Split(["\r\n", "\r", "\n"], StringSplitOptions.None);
var validationResult = "";
foreach (var line in lines)
{
if (line.Contains("quality:"))
{
validationResult = line.Split(':')[2].Trim();
break;
}
}
// 6. 构造返回数据
var baseUrl = "http://your-domain.com/upload/"; // 替换为实际地址
var imageUrl = baseUrl + Path.GetFileName(localImagePath);
if (double.TryParse(validationResult, out double qualityScore))
{
return Ok(new
{
Success = true,
Quality = qualityScore,
ImageUrl = imageUrl
});
}
return Ok(new
{
Success = false,
Message = "验证结果解析失败",
ImageUrl = imageUrl
});
}
catch (OperationCanceledException)
{
_logger.LogError("验证超时");
return StatusCode(504, "验证超时");
}
catch (Exception ex)
{
_logger.LogError(ex, "验证异常");
return StatusCode(500, $"系统错误: {ex.Message}");
}
}
```
## 🔍 关键功能说明
### 参数校验
- 空路径检查:确保传入有效的文件路径
- 文件存在性检查:验证图片实际存在于磁盘
### 安全执行
- **绝对路径构造**:使用`ContentRootPath`确保路径可靠性
- **工作目录设置**在exe所在目录执行避免路径问题
- **超时控制**20秒执行超时机制可根据需要调整
### 结果解析
1. 合并标准输出和错误流
2. 识别关键行:查找包含`quality:`的输出行
3. 提取质量分数:从`quality:value`格式的第三部分获取数值
## ⚠️ 重要注意事项
1. **输出格式依赖**
结果解析基于特定输出格式:
```c#
[输出行示例] <文件名>.jpg quality: 0.66
```
2. **权限要求**
应用需要以下权限:
- 读取`ValRel`目录的执行权限
- 访问图片文件的读权限
- 写入日志文件的权限
3. **URL构造**
替换示例中的`baseUrl`为实际图片服务地址:
```c#
var baseUrl = "http://your-actual-service.com/uploads/";
```
4. **超时调整**
根据实际硬件性能调整超时时间:
```c#
// 调整超时为30秒
new CancellationTokenSource(TimeSpan.FromSeconds(30))
```
5. **日志监控**
建议添加详细日志记录:
```c#
_logger.LogInformation($"启动人脸验证: {localImagePath}");
_logger.LogDebug($"完整输出: {fullOutput}");
```

View File

@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"dotnet-ef": {
"version": "10.0.0",
"commands": [
"dotnet-ef"
],
"rollForward": false
}
}
}

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Folder Include="pic\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="SoapCore" Version="1.2.1.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BLLCore\BLLCore.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.ServiceModel.Http" Version="8.*" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="8.*" />
<PackageReference Include="System.ServiceModel.Primitives" Version="8.*" />
</ItemGroup>
</Project>

6
BLWWSCore/BLWWSCore.http Normal file
View File

@@ -0,0 +1,6 @@
@BLWWSCore_HostAddress = http://localhost:5229
GET {{BLWWSCore_HostAddress}}/weatherforecast/
Accept: application/json
###

37
BLWWSCore/Common.cs Normal file
View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
namespace BLWWSCore
{
public class Common
{
public static string MD5Encrypt(string str)
{
MD5CryptoServiceProvider md5Hasher = new MD5CryptoServiceProvider();
byte[] hashedDataBytes;
hashedDataBytes = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(str));
StringBuilder tmp = new StringBuilder();
foreach (byte i in hashedDataBytes)
{
tmp.Append(i.ToString("x2"));
}
return tmp.ToString();
}
public static long GetCurrentTimeStamp(DateTime dt)
{
TimeSpan ts = dt - new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Local);
long current_timestamp = Convert.ToInt64(ts.TotalSeconds);
return current_timestamp;
}
public static DateTime GetCurrentDateTime(long timestampseconds)
{
DateTime epoch = new DateTime(1970, 1, 1, 8, 0, 0, DateTimeKind.Local);
DateTime utcTime = epoch.AddSeconds(timestampseconds);
return utcTime;
}
}
}

View File

@@ -0,0 +1,28 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.IO;
namespace BLWWSCore.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ValuesController : ControllerBase
{
private readonly IWebHostEnvironment _environment;
public ValuesController(IWebHostEnvironment environment)
{
_environment = environment;
}
[HttpGet()]
public void Index()
{
// 获取项目根目录
string contentRootPath = _environment.ContentRootPath;
// 组合完整路径
string directoryPath = Path.Combine(contentRootPath, "pic");
string filePath = Path.Combine(directoryPath, "1.txt");
System.IO.File.WriteAllText(filePath, "11111111111");
}
}
}

View File

@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace BLWWSCore.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();
}
}
}

77
BLWWSCore/HttpSendData.cs Normal file
View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Net;
using System.Web;
using Newtonsoft.Json;
using RestSharp;
namespace BLWWS
{
public class HttpSendData
{
//public static readonly string BaseURL = "http://www.higmkj.com:8056";
public static readonly string BaseURL = "";
private static readonly NLog.Logger _logger = NLog.LogManager.GetCurrentClassLogger();
private static string NewMethod(PMSDataBase data, string url)
{
//var a = Newtonsoft.Json.JsonConvert.SerializeObject(data);
var client123 = new RestClient(BaseURL);
var request123 = new RestRequest(url, Method.Post);
request123.AddHeader("Content-Type", "application/json");
_logger.Error("发送的数据为:" + data);
request123.AddJsonBody(data);
//request123.AddStringBody(data, DataFormat.Json);
var Response = client123.Execute(request123).Content;
return Response;
}
public static void SendData(PMSDataBase data)
{
NewMethod(data, "/order/checkIn");
}
public static void SendData_CheckOut(PMSDataBase data)
{
var a = Newtonsoft.Json.JsonConvert.SerializeObject(data);
_logger.Error("宝镜推送SendData_CheckOut数据:" + a);
//WebReference.WebService1 w = new WebReference.WebService1();
//var Response = w.HelloWorld("C24cAfK", a, "/order/checkOut");
string Response = NewMethod(data, "/order/checkOut");
_logger.Error("宝镜推送CheckOut:" + Response);
}
}
public class PMSDataBase
{
public string hotel_code { get; set; } = "";
public string time { get; set; } = "";
public string sign { get; set; } = "";
public string hotel_id { get; set; } = "";
public string order_no { get; set; } = "";
public string room_no { get; set; } = "";
public string check_out_original { get; set; }
}
public class PMSData : PMSDataBase
{
public string checkIn { get; set; }
public string checkOut { get; set; }
public ushort is_breakfast { get; set; }
public ushort breakfast { get; set; }
public string rateCode { get; set; }
public string amount { get; set; }
public string order_original { get; set; }
public List<Info> infos { get; set; }
}
public class Info
{
public string name { get; set; }
public string mobile { get; set; }
public int type { get; set; }
public string idcard { get; set; }
public int sex { get; set; }
public string address { get; set; }
}
}

93
BLWWSCore/IdWorker.cs Normal file
View File

@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Common
{
public class IdWorker
{
//起始的时间戳
private static long START_STMP = 1480166465631L;
//每一部分占用的位数
private static int SEQUENCE_BIT = 12; //序列号占用的位数
private static int MACHINE_BIT = 5; //机器标识占用的位数
private static int DATACENTER_BIT = 5;//数据中心占用的位数
//每一部分的最大值
private static long MAX_DATACENTER_NUM = -1L ^ (-1L << DATACENTER_BIT);
private static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT);
private static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT);
//每一部分向左的位移
private static int MACHINE_LEFT = SEQUENCE_BIT;
private static int DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT;
private static int TIMESTMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT;
private long datacenterId = 1; //数据中心
private long machineId = 1; //机器标识
private long sequence = 0L; //序列号
private long lastStmp = -1L;//上一次时间戳
#region :
private static readonly Lazy<IdWorker> lazy = new Lazy<IdWorker>(() => new IdWorker());
public static IdWorker Singleton { get { return lazy.Value; } }
private IdWorker() { }
#endregion
public IdWorker(long cid, long mid)
{
if (cid > MAX_DATACENTER_NUM || cid < 0) throw new Exception($"中心Id应在(0,{MAX_DATACENTER_NUM})之间");
if (mid > MAX_MACHINE_NUM || mid < 0) throw new Exception($"机器Id应在(0,{MAX_MACHINE_NUM})之间");
datacenterId = cid;
machineId = mid;
}
/// <summary>
/// 产生下一个ID
/// </summary>
/// <returns></returns>
public long nextId()
{
long currStmp = getNewstmp();
if (currStmp < lastStmp) throw new Exception("时钟倒退Id生成失败");
if (currStmp == lastStmp)
{
//相同毫秒内,序列号自增
sequence = (sequence + 1) & MAX_SEQUENCE;
//同一毫秒的序列数已经达到最大
if (sequence == 0L) currStmp = getNextMill();
}
else
{
//不同毫秒内序列号置为0
sequence = 0L;
}
lastStmp = currStmp;
return (currStmp - START_STMP) << TIMESTMP_LEFT //时间戳部分
| datacenterId << DATACENTER_LEFT //数据中心部分
| machineId << MACHINE_LEFT //机器标识部分
| sequence; //序列号部分
}
private long getNextMill()
{
long mill = getNewstmp();
while (mill <= lastStmp)
{
mill = getNewstmp();
}
return mill;
}
private long getNewstmp()
{
return (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalMilliseconds;
}
}
}

42
BLWWSCore/Program.cs Normal file
View File

@@ -0,0 +1,42 @@
using BLWWSCore.SOAP;
using SoapCore;
namespace BLWWSCore
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddHttpContextAccessor();
// ע<><D7A2> SOAP <20><><EFBFBD><EFBFBD>
builder.Services.AddSoapCore();
builder.Services.AddScoped<IWebServices, BLWWebServices>();
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9> Mvc<76><63><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>
// services.AddMvc();
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.UseSoapEndpoint<IWebServices>("/blwws.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
endpoints.UseSoapEndpoint<Isyncstatus>("/syncstatus.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
});
app.MapControllers();
app.Run();
}
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:16613",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5229",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,102 @@
using System.ServiceModel;
namespace BLWWSCore.SOAP
{
[ServiceContract()]
public interface IWebServices
{
/// <summary>
/// 没有人脸机的接口
/// </summary>
/// <param name="key"></param>
/// <param name="code"></param>
/// <param name="roomNumber"></param>
/// <param name="checkInDate"></param>
/// <param name="xmlString"></param>
/// <param name="errorMsg"></param>
/// <param name="phoneNumber"></param>
/// <param name="idNumber"></param>
/// <returns></returns>
[OperationContract()]
public bool CheckIn(string key, string code, string roomNumber, DateTime checkInDate, string xmlString, ref string errorMsg, string phoneNumber = "", string idNumber = "");
/// <summary>
/// 有人脸机的接口
/// </summary>
/// <param name="key"></param>
/// <param name="code"></param>
/// <param name="roomNumber"></param>
/// <param name="checkInDate"></param>
/// <param name="xmlString"></param>
/// <param name="errorMsg"></param>
/// <param name="checkInID"></param>
/// <param name="phoneNumber"></param>
/// <param name="idNumber"></param>
/// <returns></returns>
public bool CheckIn2(string key, string code, string roomNumber, DateTime checkInDate, string xmlString, ref string errorMsg, ref long checkInID, string phoneNumber = "", string idNumber = "");
/// <summary>
/// 图片上传
/// </summary>
/// <param name="key"></param>
/// <param name="code"></param>
/// <param name="checkInID"></param>
/// <param name="idType"></param>
/// <param name="idCard"></param>
/// <param name="name"></param>
/// <param name="sex"></param>
/// <param name="birthday"></param>
/// <param name="photoUrl"></param>
/// <param name="photo"></param>
/// <param name="errorMsg"></param>
/// <returns></returns>
public bool UploadPhoto(string key, string code, long checkInID, int idType, string idCard, string name, int sex, string birthday, string photoUrl, byte[] photo, ref string errorMsg);
public bool ChangePhoneNumber(string key, string code, string roomNumber, string phoneNumber, string idNumber, ref string errorMsg);
public bool CheckOut(string key, string code, string roomNumber, DateTime checkOutDate, ref string errorMsg);
public bool RentRoom(string key, string code, string roomNumber, DateTime rentDate, ref string errorMsg);
/// <summary>
/// 推送数据到宝镜系统
/// </summary>
/// <param name="key"></param>
/// <param name="code"></param>
/// <param name="isable"></param>
public void PushBaoJing_IsEnable(string key, string code, bool isable);
/// <summary>
/// 判断是否推送数据到宝镜系统
/// 获取是否推送PMS数据到宝镜
/// </summary>
/// <param name="key"></param>
/// <param name="code"></param>
/// <returns></returns>
public int GetPushBaoJing_IsEnable(string key, string code);
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="Code"></param>
/// <param name="HotelName"></param>
/// <param name="HotelId"></param>
/// <returns></returns>
public int AddHotelInfo(string key, string Code, string HotelName, int HotelId);
}
}

View File

@@ -0,0 +1,55 @@
using System.Data;
using System.ServiceModel;
namespace BLWWSCore.SOAP
{
[ServiceContract()]
public interface Isyncstatus
{
[OperationContract()]
public DataSet GetRoomRecord(string code, string roomNumber, string tableName);
[OperationContract()]
public string GetRoomCustomerByHotelID(int hotelID, string roomNumber, ref string phoneNumber);
[OperationContract()]
public DataSet GetRoomCustomer(long checkInID);
[OperationContract()]
public DataSet GetHotelCode();
[OperationContract()]
public DataTable GetHotelByCode(string code);
[OperationContract()]
public DataSet GetCheckInOrOutRecord(string code);
[OperationContract()]
public DataSet GetDevices(string code);
[OperationContract()]
public int SaveDevice(long id, string hotelCode, string roomNumber);
[OperationContract()]
public int UpdateCheckInOrOutRecord(string code, Int64 id, int flag);
[OperationContract()]
public bool ValidateNumber(int hotelID, string roomNumber, string validateCode);
[OperationContract()]
public bool ValidateNumberByCode(string code, string roomNumber, string validateCode);
[OperationContract()]
public DataTable GetCodeAndRoomNumberByPhone(string phone);
[OperationContract()]
public bool UploadPhoto(int idType, string idCard, string name, int sex, string birthday, byte[] photo);
[OperationContract()]
public bool FaceMatch(byte[] photo, ref int idType, ref string idCard, ref string name, ref int sex, ref byte[] matchPhoto);
}
}

View File

@@ -0,0 +1,267 @@
using BLWWS_BLL;
using System.Data;
namespace BLWWSCore.SOAP
{
public class syncstatus:Isyncstatus
{
/// <summary>
/// 获取客户记录
/// </summary>
/// <param name="code"></param>
/// <param name="roomNumber"></param>
/// <returns></returns>
public DataSet GetRoomRecord(string code, string roomNumber, string tableName)
{
try
{
return BLL.GetRoomRecords(code, roomNumber, tableName);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return null;
}
/// <summary>
/// 根据酒店ID房号获取当前入住人信息
/// </summary>
/// <param name="hotelID">酒店ID</param>
/// <param name="roomNumber">房号</param>
/// <returns></returns>
public string GetRoomCustomerByHotelID(int hotelID, string roomNumber, ref string phoneNumber)
{
try
{
return BLL.GetRoomCustomer(hotelID, roomNumber, ref phoneNumber);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return "";
}
/// <summary>
/// 获取入住人信息
/// </summary>
/// <param name="checkInID"></param>
/// <returns></returns>
public DataSet GetRoomCustomer(long checkInID)
{
try
{
return BLL.GetRoomCustomer(checkInID);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return null;
}
/// <summary>
/// 获取酒店编码
/// </summary>
/// <returns></returns>
public DataSet GetHotelCode()
{
try
{
return BLL.GetHotelCode();
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return null;
}
/// <summary>
/// 获取酒店编码
/// </summary>
/// <returns></returns>
public DataTable GetHotelByCode(string code)
{
try
{
return BLL.GetHotelCode(code);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return null;
}
/// <summary>
/// 定时获取酒店新的开房/退房/待租记录
/// </summary>
/// <param name="code">酒店编码</param>
/// <returns></returns>
public DataSet GetCheckInOrOutRecord(string code)
{
try
{
return BLL.GetCheckInOrOutRecord(code);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return null;
}
/// <summary>
/// 获取人脸机设备信息
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public DataSet GetDevices(string code)
{
try
{
return BLL.GetDevices(code);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return null;
}
/// <summary>
/// 人脸机绑定房号
/// </summary>
/// <param name="id"></param>
/// <param name="hotelCode"></param>
/// <param name="roomNumber"></param>
/// <returns></returns>
public int SaveDevice(long id, string hotelCode, string roomNumber)
{
try
{
return BLL.SaveDevice(id, hotelCode, roomNumber);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return 0;
}
/// <summary>
/// 更新已同步的新开房/退房/待租状态
/// </summary>
/// <param name="code">酒店编码</param>
/// <param name="id">记录ID</param>
/// <param name="flag">0开房1退房2待租</param>
/// <returns></returns>
public int UpdateCheckInOrOutRecord(string code, Int64 id, int flag)
{
try
{
return BLL.UpdateCheckInOrOutRecord(code, id, flag);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return 0;
}
/// <summary>
/// 判断验证码是否正确
/// </summary>
/// <param name="hotelID">酒店ID</param>
/// <param name="roomNumber">房号</param>
/// <param name="validateCode">用户输入验证码</param>
/// <returns></returns>
public bool ValidateNumber(int hotelID, string roomNumber, string validateCode)
{
try
{
return BLL.ValidateNumber(hotelID, roomNumber, validateCode);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return false;
}
/// <summary>
/// 判断验证码是否正确
/// </summary>
/// <param name="code">酒店编码</param>
/// <param name="roomNumber">房号</param>
/// <param name="validateCode">用户输入验证码</param>
/// <returns></returns>
public bool ValidateNumberByCode(string code, string roomNumber, string validateCode)
{
try
{
return BLL.ValidateNumberByCode(code, roomNumber, validateCode);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return false;
}
/// <summary>
/// 根据手机号获取当前入住记录信息
/// </summary>
/// <param name="phone"></param>
/// <returns></returns>
public DataTable GetCodeAndRoomNumberByPhone(string phone)
{
try
{
return BLL.GetCodeAndRoomNumberByPhone(phone);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return null;
}
/// <summary>
/// 上传/变更图像及信息
/// </summary>
/// <param name="idType">证件类型0身份证1护照</param>
/// <param name="idCard">证件号码</param>
/// <param name="name">姓名</param>
/// <param name="sex">性别0女1男</param>
/// <param name="photo">图像</param>
/// <returns></returns>
public bool UploadPhoto(int idType, string idCard, string name, int sex, string birthday, byte[] photo)
{
try
{
if (BLL.UploadPhoto(idType, idCard, name, sex, birthday, photo) > 0)
{
return true;
}
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return false;
}
/// <summary>
/// 人脸识别
/// </summary>
/// <param name="photo"></param>
/// <param name="idType"></param>
/// <param name="idCard"></param>
/// <param name="name"></param>
/// <param name="sex"></param>
/// <param name="matchPhoto"></param>
/// <returns></returns>
public bool FaceMatch(byte[] photo, ref int idType, ref string idCard, ref string name, ref int sex, ref byte[] matchPhoto)
{
try
{
return BLL.FaceMatch(photo, ref idType, ref idCard, ref name, ref sex, ref matchPhoto);
}
catch (Exception ex)
{
LogHelper.WriteLog(ex.ToString());
}
return false;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BLWWSCore
{
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; }
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,22 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"connectionStrings": {
"connectionString": "Server=(localdb)\\mssqllocaldb;Database=BLWWSCoreDB;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"key": "blw_ws@2015",
"BaoJing_BaseUrl": "https://f.blv-oa.com:8099/rcu_pms_api/v1",
"face_url": "http://face.blv-oa.com/Interface",
"face_url_new": "http://face.blv-oa.com",
"BaoJing_username": "boonlive",
"BaoJing_password": "blv-rcu@2025.com",
"ImageMaxHeight": "2000",
"ImageMaxWidth": "2400",
"ImageMinHeight": "320",
"ImageMinWidth": "480"
}

35
BLWWSCore/nlog.config Normal file
View 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>

View File

@@ -376,7 +376,7 @@ namespace BLWWS_BLL
int result = 0;
if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
string sql = "update tb_RoomCheck set CheckOutDate='" + checkOutDate.ToString("yyyy-MM-dd HH:mm:ss") + "' where Code='" + code + "' and RoomNumber='" + roomNumber + "' and isnull(CheckOutDate,'')=''";
string sql = "update tb_RoomCheck set CheckOutDate='" + checkOutDate.ToString("yyyy-MM-dd HH:mm:ss") + "',SyncCheckOut=0 where Code='" + code + "' and RoomNumber='" + roomNumber + "' and isnull(CheckOutDate,'')=''";
result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionString, CommandType.Text, sql);
if (result > 0 && !string.IsNullOrEmpty(_face_url))
{
@@ -437,7 +437,7 @@ namespace BLWWS_BLL
"','" + roomNumber +
"','" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") +
"'," + 0 +
"," + 1 +
"," + 0 +
"," + 0 +
")";
result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionString, CommandType.Text, sql);

View File

@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using CSRedis;
namespace BLWWS_BLL.Common
{
/// <summary>
/// Redis缓存辅助类
/// </summary>
public class CSRedisCacheHelper
{
public static CSRedisClient redis;
public static CSRedisClient redis3;
public static CSRedisClient redis5;
private const string ip = "127.0.0.1";
private const string port = "6379";
static CSRedisCacheHelper()
{
var redisHostStr = string.Format("{0}:{1}", ip, port);
if (!string.IsNullOrEmpty(redisHostStr))
{
redis = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=1");
redis3 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=3");
//准备存储取电数据
redis5 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=5");
//string channel = "__keyevent@1__:expired";
//var QQQ = new ValueTuple<string, Action<CSRedisClient.SubscribeMessageEventArgs>>(channel, (msg) =>
// {
// if (channel.Equals(""))
// {
// }
// Console.WriteLine(msg.MessageId);
// Console.WriteLine(msg.Body);
// Console.WriteLine("11111111");
// });
//redis.Subscribe(QQQ);
}
}
/// <summary>
/// 添加缓存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
public static void Set<T>(string key, T value, int ExpireTime)
{
redis?.Set(key, value, ExpireTime * 60);
}
public static T Get<T>(string key)
{
return redis.Get<T>(key);
}
public static void Forever<T>(string key, T value)
{
redis.Set(key, value, -1);
}
public static void Del(string key)
{
redis.Del(key);
}
/// <summary>
/// 判断是否存在
/// </summary>
/// <param name="key"></param>
/// <param name="mac"></param>
/// <returns></returns>
public static bool Contains(string key, string mac)
{
bool result = redis.Exists(mac);
if (!result)
{
result = redis.Exists(key);
}
return result;
}
public static bool Contains(string key)
{
bool result = redis.Exists(key);
return result;
}
public static void Publish(string Topic, string Payload)
{
CSRedisCacheHelper.redis3.Publish(Topic, Payload);
}
}
}

59
BLWWS_BLL/EntityData.cs Normal file
View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public class StaticData
{
public static string PMSLogMonitor = "PMSLogMonitor";
}
public class CheckInYuanShidata
{
public string CommandType { get; set; }
public double Step { get; set; }
public string IP { get; set; }
public string RequestId { get; set; }
public JianJie JianJieData { get; set; }
public ZhiJie ZhiJieData { get; set; }
public DateTime CurrentTime { get; set; }
public string ReturnMsg { get; set; }
}
public class JianJie
{
public string OriginallData { get; set; }
}
public class ZhiJie
{
public CheckInData CheckInData { get; set; }
public CheckOutData CheckOutData { get; set; }
public RentData RentData { get; set; }
}
public class CheckInData
{
public string key { get; set; }
public string code { get; set; }
public string roomNumber { get; set; }
public DateTime checkInDate;
public string xmlString { get; set; }
public string phoneNumber { get; set; }
public string idNumber { get; set; }
}
public class CheckOutData
{
public string key { get; set; }
public string code { get; set; }
public string roomNumber { get; set; }
public DateTime checkOutDate { get; set; }
}
public class RentData
{
public string key { get; set; }
public string code { get; set; }
public string roomNumber { get; set; }
public DateTime rentDate { get; set; }
}
}

13
BLWWS_BLL/ExtraData.cs Normal file
View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLWWS_BLL
{
public class ExtraData
{
public string OriginalData { get; set; }
public string RequestIP { get; set; }
}
}

View File

@@ -27,6 +27,26 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HttpsTran", "HttpsTran\Http
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PMSLogProduce", "PMSLogProduce\PMSLogProduce.csproj", "{90D966FB-EA52-4991-B85B-111D1054E4B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySOAP", "MySOAP\MySOAP.csproj", "{12840676-C050-4345-AAE2-A84DE0138F2B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp9", "ConsoleApp9\ConsoleApp9.csproj", "{5D410E7B-AA45-4CC1-986A-FC018815A9F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp10", "ConsoleApp10\ConsoleApp10.csproj", "{106433B9-D144-4F0F-8DA8-DDF3D9696BD7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NetCore版本", "NetCore版本", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BLWWSCore", "BLWWSCore\BLWWSCore.csproj", "{F24D5475-BF8B-4785-AAE6-B32501F9B689}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BLLCore", "BLLCore\BLLCore.csproj", "{6E912CC5-B679-43ED-9A87-84D48430F434}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication1", "WebApplication1\WebApplication1.csproj", "{55868375-1BEE-4923-BE1B-594D57936418}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "修复CRICS", "修复CRICS", "{0923A02F-DE6B-42B6-A83A-669AFAD553F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CRICS_SSL", "CRICS_SSL\CRICS_SSL.csproj", "{7C910648-300D-48F6-8429-FE70505CFD22}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApplication2", "WebApplication2\WebApplication2.csproj", "{8E7F6C16-E25D-4767-9496-109C8AE2D9E5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -69,10 +89,48 @@ Global
{90D966FB-EA52-4991-B85B-111D1054E4B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{90D966FB-EA52-4991-B85B-111D1054E4B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{90D966FB-EA52-4991-B85B-111D1054E4B2}.Release|Any CPU.Build.0 = Release|Any CPU
{12840676-C050-4345-AAE2-A84DE0138F2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12840676-C050-4345-AAE2-A84DE0138F2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12840676-C050-4345-AAE2-A84DE0138F2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{12840676-C050-4345-AAE2-A84DE0138F2B}.Release|Any CPU.Build.0 = Release|Any CPU
{5D410E7B-AA45-4CC1-986A-FC018815A9F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5D410E7B-AA45-4CC1-986A-FC018815A9F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5D410E7B-AA45-4CC1-986A-FC018815A9F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5D410E7B-AA45-4CC1-986A-FC018815A9F7}.Release|Any CPU.Build.0 = Release|Any CPU
{106433B9-D144-4F0F-8DA8-DDF3D9696BD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{106433B9-D144-4F0F-8DA8-DDF3D9696BD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{106433B9-D144-4F0F-8DA8-DDF3D9696BD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{106433B9-D144-4F0F-8DA8-DDF3D9696BD7}.Release|Any CPU.Build.0 = Release|Any CPU
{F24D5475-BF8B-4785-AAE6-B32501F9B689}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F24D5475-BF8B-4785-AAE6-B32501F9B689}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F24D5475-BF8B-4785-AAE6-B32501F9B689}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F24D5475-BF8B-4785-AAE6-B32501F9B689}.Release|Any CPU.Build.0 = Release|Any CPU
{6E912CC5-B679-43ED-9A87-84D48430F434}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6E912CC5-B679-43ED-9A87-84D48430F434}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6E912CC5-B679-43ED-9A87-84D48430F434}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6E912CC5-B679-43ED-9A87-84D48430F434}.Release|Any CPU.Build.0 = Release|Any CPU
{55868375-1BEE-4923-BE1B-594D57936418}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55868375-1BEE-4923-BE1B-594D57936418}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55868375-1BEE-4923-BE1B-594D57936418}.Release|Any CPU.ActiveCfg = Release|Any CPU
{55868375-1BEE-4923-BE1B-594D57936418}.Release|Any CPU.Build.0 = Release|Any CPU
{7C910648-300D-48F6-8429-FE70505CFD22}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C910648-300D-48F6-8429-FE70505CFD22}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7C910648-300D-48F6-8429-FE70505CFD22}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7C910648-300D-48F6-8429-FE70505CFD22}.Release|Any CPU.Build.0 = Release|Any CPU
{8E7F6C16-E25D-4767-9496-109C8AE2D9E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E7F6C16-E25D-4767-9496-109C8AE2D9E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E7F6C16-E25D-4767-9496-109C8AE2D9E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E7F6C16-E25D-4767-9496-109C8AE2D9E5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{F24D5475-BF8B-4785-AAE6-B32501F9B689} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{6E912CC5-B679-43ED-9A87-84D48430F434} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
{7C910648-300D-48F6-8429-FE70505CFD22} = {0923A02F-DE6B-42B6-A83A-669AFAD553F3}
{8E7F6C16-E25D-4767-9496-109C8AE2D9E5} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A569AA4F-F1B7-4B26-BB35-02D271DBC68D}
EndGlobalSection

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CSRedisCore" Version="3.8.807" />
<PackageReference Include="RestSharp" Version="113.0.0" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,296 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using CSRedis;
namespace Common
{
/// <summary>
/// Redis缓存辅助类
/// </summary>
public class CSRedisCacheHelper
{
public static CSRedisClient redis;
public static CSRedisClient redis1;
public static CSRedisClient redis2;
public static CSRedisClient redis3;
public static CSRedisClient redis4;
public static CSRedisClient redis5;
private static int SessionExpireMinutes = 6;
private static int MonitorLogExpireMinutes = 30;
//过期时间60个小时
private static int DeviceStatusExpireMinutes = 60;
public static string HeartBeatPrefix = "HeartBeatMonitor";
static CSRedisCacheHelper()
{
var redisHostStr = "127.0.0.1:6379";
if (!string.IsNullOrEmpty(redisHostStr))
{
redis = new CSRedisClient(redisHostStr);//+ ",password=,defaultDatabase=0,poolsize=500,ssl=false,writeBuffer=10240,prefix=");
redis1 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=1");
redis2 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=2");
redis3 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=3");
redis4 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=4");
redis5 = new CSRedisClient(redisHostStr + ",password=,defaultDatabase=5");
}
}
/// <summary>
/// 添加缓存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
public static void Set<T>(string key, T value)
{
redis.Set(key, value, SessionExpireMinutes * 60);
}
public static T Get<T>(string key)
{
return redis.Get<T>(key);
}
public static void Del(string[] key)
{
redis.Del(key.ToArray());
}
public static void Del_Partition(string key, int SliceNo = 2)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.Del(key);
}
public static T ForeverGet<T>(string key)
{
return redis1.Get<T>(key);
}
public static void Forever<T>(string key, T value)
{
redis1.Set(key, value, MonitorLogExpireMinutes * 24 * 60 * 60);
}
public static T Get_Partition<T>(string key, int SliceNo = 2)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
return client.Get<T>(key);
}
public static void Set_Partition<T>(string key, T value, int SliceNo = 2)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.Set(key, value, DeviceStatusExpireMinutes * 60 * 60);
}
/// <summary>
/// 设置过期时间
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="ExpireTime_Minutes"></param>
/// <param name="SliceNo"></param>
public static void Set_PartitionWithTime<T>(string key, T value, int ExpireTime_Minutes, int SliceNo = 2)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.Set(key, value, ExpireTime_Minutes * 60);
}
public static void Set_PartitionWithForever<T>(string key, T value, int SliceNo = 2)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.Set(key, value, -1);
}
public static void Del_Partition(string[] key, int SliceNo = 2)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.Del(key);
}
public static bool Contains_Partition(string key, int SliceNo = 2)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
bool result = client.Exists(key);
return result;
}
private static CSRedisClient WhitchRedisSlice(int SliceNo)
{
CSRedisClient client = null;
if (SliceNo == 1)
{
client = redis1;
}
else if (SliceNo == 2)
{
client = redis2;
}
else if (SliceNo == 3)
{
client = redis3;
}
else if (SliceNo == 4)
{
client = redis4;
}
else if (SliceNo == 5)
{
client = redis5;
}
else
{
client = redis;
}
return client;
}
public static long GetForever_ExpireMinutes<T>(string key)
{
return redis.Ttl(key);
}
/// <summary>
/// 获取
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static T Get<T>(string key, string mac)
{
T obj = redis.Get<T>(mac);
if (obj == null)
{
return redis.Get<T>(key);
}
return obj;
}
/// <summary>
/// 判断是否存在
/// </summary>
/// <param name="key"></param>
/// <param name="mac"></param>
/// <returns></returns>
public static bool Contains(string key, string mac)
{
bool result = redis.Exists(mac);
if (!result)
{
result = redis.Exists(key);
}
return result;
}
public static bool Contains(string key)
{
bool result = redis.Exists(key);
return result;
}
public static void Publish(string Topic, string Payload)
{
CSRedisCacheHelper.redis3.Publish(Topic, Payload);
}
/// <summary>
/// 添加Hash缓存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <param name="value"></param>
public static void HMSet(int SliceNo, string key, params object[] value)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.HMSet(key, value);
}
public static void HMSet(int SliceNo, int ExpireTime_M, string key, params object[] value)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.HMSet(key, value);
client.Expire(key, new TimeSpan(0, ExpireTime_M, 0));
}
/// <summary>
/// 获取Hash缓存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static T[] HMGet<T>(int SliceNo, string key, string KeyV)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
return client.HMGet<T>(key, KeyV);
}
public static Dictionary<string, string> HMGetAll(int SliceNo, string key)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
return client.HGetAll(key);
}
/// <summary>
/// 获取 某个hash值的数量
/// </summary>
/// <param name="key"></param>
/// <returns></returns>
public static int GetHMCount(string key)
{
return redis5.HGetAll(key).Count;
}
/// <summary>
/// 删除Hash缓存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static long HDelAll<T>(int SliceNo, string key)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
return client.HDel(key);
}
public static long HDel(int SliceNo, string key, string key1)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
return client.HDel(key, key1);
}
public static void ListAdd(int SliceNo, string key, params object[] obj)
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
client.LPush(key, obj);
}
public static int MaxLen = 500000;
public static void StreamAdd(int SliceNo, string key, string Value)
{
try
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
// 添加简单消息
client.XAdd(key, MaxLen, "*", new ValueTuple<string, string>("__data", Value));
}
catch (Exception)
{
}
}
public static void StreamConsume(int SliceNo, string key, string group = "UDPData", string consumer = "Crics1")
{
CSRedisClient client = WhitchRedisSlice(SliceNo);
var data = redis.XReadGroup(group, consumer, 100, 10, new ValueTuple<string, string>(key, ">"));
if (data != null)
{
//检查pending表的长度
//消费确认前pending 应该等于2
var pending = redis.XPending(key, group);
foreach (var item in data)
{
var idarray = item.Item2;
foreach (var SerializeNo in idarray)
{
var id1 = SerializeNo.Item1;
redis.XAck(key, group, id1);
redis.XDel(key, id1);
}
}
}
}
}
}

133
CRICS_SSL/Program.cs Normal file
View File

@@ -0,0 +1,133 @@
using Common;
using Newtonsoft.Json;
using RestSharp;
using System.Net;
namespace CRICS_SSL
{
public class XuanZhuResponse
{
/// <summary>
/// 酒店编码
/// </summary>
public string code { get; set; }
/// <summary>
/// 房号
/// </summary>
public string roomNumber { get; set; }
/// <summary>
/// 回路地址
/// </summary>
public string address { get; set; }
/// <summary>
/// 回路名称
/// </summary>
public string name { get; set; }
/// <summary>
/// 状态
/// </summary>
public int status { get; set; }
/// <summary>
/// 异常类型
/// </summary>
public int faultType { get; set; }
/// <summary>
/// 异常值
/// </summary>
public int faultData { get; set; }
/// <summary>
/// 亮度
/// </summary>
public int brightness { get; set; }
/// <summary>
/// 当前温度
/// </summary>
public int currentTemp { get; set; }
/// <summary>
/// 设定温度
/// </summary>
public int settingTemp { get; set; }
/// <summary>
/// 风速
/// </summary>
public int fanSpeed { get; set; }
/// <summary>
/// 模式
/// </summary>
public int mode { get; set; }
/// <summary>
/// 阀门
/// </summary>
public int valve { get; set; }
}
public class Program
{
static void Main(string[] args)
{
Task.Factory.StartNew(() =>
{
while (true)
{
StreamConsume("UDPData", "Crics1", "task1");
}
}, TaskCreationOptions.LongRunning);
SendHttpData<string>("", "");
Console.WriteLine("Hello, World!");
Console.ReadLine();
}
public static string SendHttpData<T>(string Url, T obj)
{
var client1 = new RestClient("https://f-xcx.blv-oa.com/rcu/report");
var request1 = new RestRequest("", Method.Post);
string jjj = """
{"code":"1085","roomNumber":"8099","address":"009001004","name":"PM2.5浓度","status":1,"faultType":0,"faultData":0,"brightness":45,"currentTemp":0,"settingTemp":0,"fanSpeed":0,"mode":0,"valve":0}
""";
request1.AddJsonBody(jjj);
var QQQ = client1.Execute(request1);
HttpStatusCode HHH = QQQ.StatusCode;
if (HHH == HttpStatusCode.OK)
{
}
return "";
}
public static string UDPAllDataKey = "BaoYi_ReportData";
public static void StreamConsume(string group = "BaoYiData", string consumer = "BaoYiCRICS1", string task_key = "task1")
{
try
{
var redis = CSRedisCacheHelper.redis1;
var data = redis.XReadGroup(group, consumer, 500, 10, new ValueTuple<string, string>(UDPAllDataKey, ">"));
if (data != null)
{
//var pending = redis.XPending(UDPAllDataKey, group);
foreach (var item in data)
{
var idarray = item.Item2;
string nsa = string.Concat(task_key, "#", idarray.Count().ToString());
CSRedisCacheHelper.Publish("udp_package_consumer", nsa);
foreach (var SerializeNo in idarray)
{
var id1 = SerializeNo.Item1;
var str = SerializeNo.Item2[1];
var GGG = JsonConvert.DeserializeObject<XuanZhuResponse>(str);
redis.XAck(UDPAllDataKey, group, id1);
redis.XDel(UDPAllDataKey, id1);
//ProcessData(GGG);
SendHttpData("", "");
}
}
}
}
catch (Exception ex)
{
}
}
}
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="RestSharp" Version="113.0.0" />
</ItemGroup>
</Project>

77
ConsoleApp10/Program.cs Normal file
View File

@@ -0,0 +1,77 @@
using Newtonsoft.Json;
using RestSharp;
namespace ConsoleApp10
{
public class Root
{
public int code { get; set; }
public string message { get; set; }
public Data data { get; set; }
}
public class Data
{
public Table table { get; set; }
}
public class Table
{
public string table_id { get; set; }
public string name { get; set; }
public string alias { get; set; }
public string space_id { get; set; }
public string created_on { get; set; }
public List<dynamic> fields { get; set; }
}
//public class Field
//{
// public string? field_id { get; set; }
// public string? name { get; set; }
// public string? alias { get; set; }
// public string? field_type { get; set; }
// public string? data_type { get; set; }
// public object? from_relation_field { get; set; }
// public bool? required { get; set; }
// public string? description { get; set; }
// public object? config { get; set; }
//}
internal class Program
{
private static readonly string baseUrl = "https://api.huoban.com/";
private static readonly string API_Key = "FIQBLpReK6nAJ0CzYOxmNgKtEpa0cApctanSZyGW";
private static readonly string Space_Id = "4000000007643308";
private static readonly string Table_Id = "2100000061683453";
static void Main(string[] args)
{
// 创建 REST 客户端
var options = new RestClientOptions(baseUrl);
var client = new RestClient(options);
// 创建请求
var request = new RestRequest($"openapi/v1/table/{Table_Id}", Method.Post);
// 添加授权头
request.AddHeader("Open-Authorization", $"Bearer {API_Key}");
request.AddHeader("Content-Type", "application/json");
// 执行请求
var response = client.Execute(request);
Root USA = JsonConvert.DeserializeObject<Root>(response.Content);
var llls = USA.data.table.fields;
foreach (dynamic item in llls)
{
Console.WriteLine(item.name);
Console.WriteLine(item.field_id);
}
Console.ReadLine();
Console.WriteLine("Hello, World!");
Console.WriteLine("Hello, World!");
}
}
}

View File

@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json">
<HintPath>C:\Program Files\IIS\Microsoft Web Deploy V3\Newtonsoft.Json.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

1848
ConsoleApp9/Program.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -40,7 +40,7 @@ namespace HttpsTran
var D = (SecurityProtocolType)3072;
var E = (SecurityProtocolType)12288;
ServicePointManager.SecurityProtocol = A | B | C | D | E;
BaseURL = "https://localhost:7009/";
//BaseURL = "https://localhost:7009/";
var client123 = new RestClient(BaseURL);
//var request123 = new RestRequest("/order/checkOut", Method.POST);
var request123 = new RestRequest(url, Method.Post);

View File

@@ -0,0 +1,29 @@
namespace MySOAP
{
public class CalculatorService : ICalculatorService
{
public double Add(double a, double b)
{
return a + b;
}
public double Subtract(double a, double b)
{
return a - b;
}
public double Multiply(double a, double b)
{
return a * b;
}
public double Divide(double a, double b)
{
if (b == 0)
{
throw new DivideByZeroException();
}
return a / b;
}
}
}

View File

@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace MySOAP.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();
}
}
}

View File

@@ -0,0 +1,20 @@
using System.ServiceModel;
namespace MySOAP
{
[ServiceContract]
public interface ICalculatorService
{
[OperationContract]
double Add(double a, double b);
[OperationContract]
double Subtract(double a, double b);
[OperationContract]
double Multiply(double a, double b);
[OperationContract]
double Divide(double a, double b);
}
}

13
MySOAP/MySOAP.csproj Normal file
View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SoapCore" Version="1.2.1.11" />
</ItemGroup>
</Project>

6
MySOAP/MySOAP.http Normal file
View File

@@ -0,0 +1,6 @@
@MySOAP_HostAddress = http://localhost:5220
GET {{MySOAP_HostAddress}}/weatherforecast/
Accept: application/json
###

24
MySOAP/MySOAP.sln Normal file
View File

@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MySOAP", "MySOAP.csproj", "{BEBB9268-7AC5-F9EE-BCD7-F75423334851}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEBB9268-7AC5-F9EE-BCD7-F75423334851}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {88A70167-6316-4A1A-B72E-7B242BFE720E}
EndGlobalSection
EndGlobal

35
MySOAP/Program.cs Normal file
View File

@@ -0,0 +1,35 @@
using SoapCore;
namespace MySOAP
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
// <20><><EFBFBD>ӷ<EFBFBD><D3B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
builder.Services.AddSoapCore();
builder.Services.AddSingleton<ICalculatorService, CalculatorService>();
builder.Services.AddControllers();
builder.Services.AddMvc();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseRouting();
app.UseAuthorization();
_ = app.UseEndpoints(endpoints =>
{
endpoints.UseSoapEndpoint<ICalculatorService>("/Service.asmx", new SoapEncoderOptions(), SoapSerializer.XmlSerializer);
});
app.MapControllers();
app.Run();
}
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:21282",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5220",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

13
MySOAP/WeatherForecast.cs Normal file
View File

@@ -0,0 +1,13 @@
namespace MySOAP
{
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; }
}
}

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

9
MySOAP/appsettings.json Normal file
View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,33 @@
using Microsoft.AspNetCore.Mvc;
namespace WebApplication1.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();
}
}
}

View File

@@ -0,0 +1,25 @@
namespace WebApplication1
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseAuthorization();
app.MapControllers();
app.Run();
}
}
}

View File

@@ -0,0 +1,31 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:50138",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "weatherforecast",
"applicationUrl": "http://localhost:5029",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "weatherforecast",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,13 @@
namespace WebApplication1
{
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; }
}
}

View File

@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>

View File

@@ -0,0 +1,6 @@
@WebApplication1_HostAddress = http://localhost:5029
GET {{WebApplication1_HostAddress}}/weatherforecast/
Accept: application/json
###

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

View File

@@ -0,0 +1,32 @@
using Microsoft.AspNetCore.Mvc;
using System.Diagnostics;
using WebApplication2.Models;
namespace WebApplication2.Controllers
{
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
public HomeController(ILogger<HomeController> logger)
{
_logger = logger;
}
public IActionResult Index()
{
return View();
}
public IActionResult Privacy()
{
return View();
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error()
{
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
}
}
}

View File

@@ -0,0 +1,88 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using System.IO.Compression;
namespace WebApplication2.Controllers
{
[Route("api/[controller]/[action]")]
[ApiController]
public class ValuesController : ControllerBase
{
public IWebHostEnvironment _environment;
private readonly IContentTypeProvider _contentTypeProvider;
public ValuesController(IWebHostEnvironment e)
{
this._environment = e;
_contentTypeProvider = new FileExtensionContentTypeProvider();
}
[HttpGet()]
public async Task<IActionResult> DownloadImage(string imageName)
{
try
{
// 安全检查:防止路径遍历攻击
if (imageName.Contains("..") || imageName.Contains("/") || imageName.Contains("\\"))
{
return BadRequest("无效的文件名");
}
// 构建完整文件路径
var imagePath = Path.Combine(_environment.ContentRootPath, "images", imageName);
// 检查文件是否存在
if (!System.IO.File.Exists(imagePath))
{
return NotFound("图片不存在");
}
// 获取文件内容类型
if (!_contentTypeProvider.TryGetContentType(imageName, out var contentType))
{
contentType = "application/octet-stream";
}
// 读取文件并返回
//var fileBytes = await System.IO.File.ReadAllBytesAsync(imagePath);
var validFiles = new List<(string FileName, string FilePath)>();
validFiles.Add((imageName, imagePath));
var memoryStream = new MemoryStream();
// 创建zip归档
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
{
foreach (var (fileName, filePath) in validFiles)
{
try
{
// 在zip中创建条目
var entry = archive.CreateEntry(fileName, CompressionLevel.Optimal);
// 写入文件内容
using var entryStream = entry.Open();
using var fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read);
await fileStream.CopyToAsync(entryStream);
}
catch (Exception ex)
{
}
}
}
memoryStream.Seek(0, SeekOrigin.Begin);
// 返回zip文件
return File(memoryStream, "application/zip", "1.zip");
//// 重置流位置
//return File(fileBytes, contentType, imageName);
}
catch (Exception ex)
{
return StatusCode(500, $"下载失败: {ex.Message}");
}
}
}
}

View File

@@ -0,0 +1,9 @@
namespace WebApplication2.Models
{
public class ErrorViewModel
{
public string? RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}

View File

@@ -0,0 +1,32 @@
namespace WebApplication2
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
var app = builder.Build();
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
app.Run();
}
}
}

View File

@@ -0,0 +1,29 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:3770",
"sslPort": 0
}
},
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:5088",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}

View File

@@ -0,0 +1,8 @@
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://learn.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
</div>

View File

@@ -0,0 +1,6 @@
@{
ViewData["Title"] = "Privacy Policy";
}
<h1>@ViewData["Title"]</h1>
<p>Use this page to detail your site's privacy policy.</p>

View File

@@ -0,0 +1,25 @@
@model ErrorViewModel
@{
ViewData["Title"] = "Error";
}
<h1 class="text-danger">Error.</h1>
<h2 class="text-danger">An error occurred while processing your request.</h2>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<h3>Development Mode</h3>
<p>
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
</p>
<p>
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
It can result in displaying sensitive information from exceptions to end users.
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
and restarting the app.
</p>

View File

@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>@ViewData["Title"] - WebApplication2</title>
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/WebApplication2.styles.css" asp-append-version="true" />
</head>
<body>
<header>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container-fluid">
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">WebApplication2</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-between">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</li>
</ul>
</div>
</div>
</nav>
</header>
<div class="container">
<main role="main" class="pb-3">
@RenderBody()
</main>
</div>
<footer class="border-top footer text-muted">
<div class="container">
&copy; 2025 - WebApplication2 - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
</div>
</footer>
<script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false)
</body>
</html>

View File

@@ -0,0 +1,48 @@
/* Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
for details on configuring this project to bundle and minify static web assets. */
a.navbar-brand {
white-space: normal;
text-align: center;
word-break: break-all;
}
a {
color: #0077cc;
}
.btn-primary {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
color: #fff;
background-color: #1b6ec2;
border-color: #1861ac;
}
.border-top {
border-top: 1px solid #e5e5e5;
}
.border-bottom {
border-bottom: 1px solid #e5e5e5;
}
.box-shadow {
box-shadow: 0 .25rem .75rem rgba(0, 0, 0, .05);
}
button.accept-policy {
font-size: 1rem;
line-height: inherit;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
white-space: nowrap;
line-height: 60px;
}

View File

@@ -0,0 +1,2 @@
<script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

View File

@@ -0,0 +1,3 @@
@using WebApplication2
@using WebApplication2.Models
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

View File

@@ -0,0 +1,3 @@
@{
Layout = "_Layout";
}

View File

@@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Content Update="wwwroot\images\thumb-1920-49262.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,8 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
}
}

View File

@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 KiB

View File

@@ -0,0 +1,22 @@
html {
font-size: 14px;
}
@media (min-width: 768px) {
html {
font-size: 16px;
}
}
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}
html {
position: relative;
min-height: 100%;
}
body {
margin-bottom: 60px;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 KiB

View File

@@ -0,0 +1,4 @@
// Please see documentation at https://learn.microsoft.com/aspnet/core/client-side/bundling-and-minification
// for details on configuring this project to bundle and minify static web assets.
// Write your JavaScript code.

View File

@@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2011-2021 Twitter, Inc.
Copyright (c) 2011-2021 The Bootstrap Authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,427 @@
/*!
* Bootstrap Reboot v5.1.0 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors
* Copyright 2011-2021 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
@media (prefers-reduced-motion: no-preference) {
:root {
scroll-behavior: smooth;
}
}
body {
margin: 0;
font-family: var(--bs-body-font-family);
font-size: var(--bs-body-font-size);
font-weight: var(--bs-body-font-weight);
line-height: var(--bs-body-line-height);
color: var(--bs-body-color);
text-align: var(--bs-body-text-align);
background-color: var(--bs-body-bg);
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
hr {
margin: 1rem 0;
color: inherit;
background-color: currentColor;
border: 0;
opacity: 0.25;
}
hr:not([size]) {
height: 1px;
}
h6, h5, h4, h3, h2, h1 {
margin-top: 0;
margin-bottom: 0.5rem;
font-weight: 500;
line-height: 1.2;
}
h1 {
font-size: calc(1.375rem + 1.5vw);
}
@media (min-width: 1200px) {
h1 {
font-size: 2.5rem;
}
}
h2 {
font-size: calc(1.325rem + 0.9vw);
}
@media (min-width: 1200px) {
h2 {
font-size: 2rem;
}
}
h3 {
font-size: calc(1.3rem + 0.6vw);
}
@media (min-width: 1200px) {
h3 {
font-size: 1.75rem;
}
}
h4 {
font-size: calc(1.275rem + 0.3vw);
}
@media (min-width: 1200px) {
h4 {
font-size: 1.5rem;
}
}
h5 {
font-size: 1.25rem;
}
h6 {
font-size: 1rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-bs-original-title] {
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul {
padding-left: 2rem;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: 0.5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 0.875em;
}
mark {
padding: 0.2em;
background-color: #fcf8e3;
}
sub,
sup {
position: relative;
font-size: 0.75em;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -0.25em;
}
sup {
top: -0.5em;
}
a {
color: #0d6efd;
text-decoration: underline;
}
a:hover {
color: #0a58ca;
}
a:not([href]):not([class]), a:not([href]):not([class]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
direction: ltr /* rtl:ignore */;
unicode-bidi: bidi-override;
}
pre {
display: block;
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
font-size: 0.875em;
}
pre code {
font-size: inherit;
color: inherit;
word-break: normal;
}
code {
font-size: 0.875em;
color: #d63384;
word-wrap: break-word;
}
a > code {
color: inherit;
}
kbd {
padding: 0.2rem 0.4rem;
font-size: 0.875em;
color: #fff;
background-color: #212529;
border-radius: 0.2rem;
}
kbd kbd {
padding: 0;
font-size: 1em;
font-weight: 700;
}
figure {
margin: 0 0 1rem;
}
img,
svg {
vertical-align: middle;
}
table {
caption-side: bottom;
border-collapse: collapse;
}
caption {
padding-top: 0.5rem;
padding-bottom: 0.5rem;
color: #6c757d;
text-align: left;
}
th {
text-align: inherit;
text-align: -webkit-match-parent;
}
thead,
tbody,
tfoot,
tr,
td,
th {
border-color: inherit;
border-style: solid;
border-width: 0;
}
label {
display: inline-block;
}
button {
border-radius: 0;
}
button:focus:not(:focus-visible) {
outline: 0;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
select {
text-transform: none;
}
[role=button] {
cursor: pointer;
}
select {
word-wrap: normal;
}
select:disabled {
opacity: 1;
}
[list]::-webkit-calendar-picker-indicator {
display: none;
}
button,
[type=button],
[type=reset],
[type=submit] {
-webkit-appearance: button;
}
button:not(:disabled),
[type=button]:not(:disabled),
[type=reset]:not(:disabled),
[type=submit]:not(:disabled) {
cursor: pointer;
}
::-moz-focus-inner {
padding: 0;
border-style: none;
}
textarea {
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
float: left;
width: 100%;
padding: 0;
margin-bottom: 0.5rem;
font-size: calc(1.275rem + 0.3vw);
line-height: inherit;
}
@media (min-width: 1200px) {
legend {
font-size: 1.5rem;
}
}
legend + * {
clear: left;
}
::-webkit-datetime-edit-fields-wrapper,
::-webkit-datetime-edit-text,
::-webkit-datetime-edit-minute,
::-webkit-datetime-edit-hour-field,
::-webkit-datetime-edit-day-field,
::-webkit-datetime-edit-month-field,
::-webkit-datetime-edit-year-field {
padding: 0;
}
::-webkit-inner-spin-button {
height: auto;
}
[type=search] {
outline-offset: -2px;
-webkit-appearance: textfield;
}
/* rtl:raw:
[type="tel"],
[type="url"],
[type="email"],
[type="number"] {
direction: ltr;
}
*/
::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-color-swatch-wrapper {
padding: 0;
}
::file-selector-button {
font: inherit;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
iframe {
border: 0;
}
summary {
display: list-item;
cursor: pointer;
}
progress {
vertical-align: baseline;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More