Commit 765538cf by zxw

修复文件编码为utf8

parent 6bed92a5
......@@ -54,9 +54,9 @@ namespace JmpMsgService
{
onRefresh += SendRefresh;
onReciveMsg += OnMessageReceived;
//启动Ws服务
//启动Ws服务
wsServer = new WebSocketServer("ws://0.0.0.0:8090");
Console.WriteLine("消息服务 启动成功");
Console.WriteLine("消息服务 启动成功");
wsServer.Start(socket =>
{
socket.OnOpen = () =>
......@@ -80,13 +80,13 @@ namespace JmpMsgService
CheckDelete();
await Task.Delay(int.Parse(checkTime) * 60 * 1000); //单位:分钟
await Task.Delay(int.Parse(checkTime) * 60 * 1000); //单位:分钟
}
}
catch (Exception ex)
{
_logger.LogError("消息服务 ExecuteAsync:" + ex.ToString());
_logger.LogError("消息服务 ExecuteAsync:" + ex.ToString());
}
}
public override Task StopAsync(CancellationToken cancellationToken)
......@@ -98,7 +98,7 @@ namespace JmpMsgService
}
private void CheckMessage()
{
//启动轮询
//启动轮询
DateTime CheckTime = DateTime.Now.Date;
checkTime = Configuration.GetConnectionString("CheckTime");
......@@ -125,7 +125,7 @@ namespace JmpMsgService
};
Expression<Func<VScrapView, bool>> expression = p => p.WarrantyTime != null;
//var userInfo1 = _unitOfWork.CommonJpUserRepository.GetList(p=>p.Id!=null);
var scrapList = _unitOfWork.ScrapViewRepository.GetList(expression, p => p.WarrantyTime, false, parameScrap);//超期数据
var scrapList = _unitOfWork.ScrapViewRepository.GetList(expression, p => p.WarrantyTime, false, parameScrap);//超期数据
var orgList = scrapList.ToList().GroupBy(p => p.OrgId);
List<string> orgs = new List<string>();
foreach (var item in orgList)
......@@ -136,7 +136,7 @@ namespace JmpMsgService
var userInfo = _unitOfWork.CommonJpUserRepository.GetList(userExpression, null, false, parame).ToList();
var borrowList = _unitOfWork.BorrowReturnApplyRepository.GetList(p => p.ExpectedReturnTime != null && p.CommonJpBorrowReturns.FirstOrDefault().CurrentState.Equals(1) && p.ExpectedReturnTime <= DateTime.Now.Date, null, false, parameBorrow).ToList();
var historyMessage = _unitOfWork.MessageRepository.GetList(p => (p.MessageType.Equals("rebackWaring") || p.MessageType.Equals("scrapWaring")) && !string.IsNullOrEmpty(p.OrderId)).ToList();
var borrowTranList = _unitOfWork.TransferApplyRepository.GetList(p => p.ExpectedReturnTime != null && p.CommonJpTransfers.FirstOrDefault().CurrentState.Equals(1) && p.ExpectedReturnTime > DateTime.Now.Date, null, false, parameTr).ToList();//跨库借用单
var borrowTranList = _unitOfWork.TransferApplyRepository.GetList(p => p.ExpectedReturnTime != null && p.CommonJpTransfers.FirstOrDefault().CurrentState.Equals(1) && p.ExpectedReturnTime > DateTime.Now.Date, null, false, parameTr).ToList();//跨库借用单
var borrowCurrentList = _unitOfWork.EquipmentInventoryRepository.GetList(p => p.CurrentState.Equals(14)&&p.InventoryState!="loss", null, false, parameInventory).ToList();
List<CommonJpMessage> messges = new List<CommonJpMessage>();
foreach (var item in borrowTranList)
......@@ -153,7 +153,7 @@ namespace JmpMsgService
message.MessageInfo = item.Order;
message.SendTime = DateTime.Now;
message.PcNumber = Guid.NewGuid().ToString();
message.OrderType = "跨仓库归还提醒";
message.OrderType = "跨仓库归还提醒";
message.OrderId = item.Order;
messges.Add(message);
onRefresh?.Invoke(message.SendName);
......@@ -183,7 +183,7 @@ namespace JmpMsgService
message.MessageInfo = borrowState.Id;
message.SendTime = DateTime.Now;
message.PcNumber = Guid.NewGuid().ToString();
message.OrderType = "本仓库归还提醒";
message.OrderType = "本仓库归还提醒";
message.OrderId = borrowState.EquipmentCodeNavigation?.Name + "-" + borrowState.EquipmentSizecodeNavigation?.SizeName;
messges.Add(message);
onRefresh?.Invoke(message.SendName);
......@@ -192,11 +192,11 @@ namespace JmpMsgService
}
}
foreach (var item in scrapList)//添加报废消息到消息数据表
foreach (var item in scrapList)//添加报废消息到消息数据表
{
string id = item.Id;
string orgId = item.OrgId;
var sendUser = userInfo.Where(p => p.OrganizationId.Equals(item.OrgId));//当前存的管理员
var sendUser = userInfo.Where(p => p.OrganizationId.Equals(item.OrgId));//当前存的管理员
string pcNum = Guid.NewGuid().ToString();
if (item.WarrantyTime.Value.AddMonths(-1) <= DateTime.Now)
{
......@@ -212,7 +212,7 @@ namespace JmpMsgService
message.MessageInfo = item.Id;
message.SendTime = DateTime.Now;
message.PcNumber = pcNum;
message.OrderType = "报废提醒";
message.OrderType = "报废提醒";
message.OrderId = item.EquName + "-" + item.SizeName;
messges.Add(message);
onRefresh?.Invoke(message.SendName);
......@@ -222,7 +222,7 @@ namespace JmpMsgService
}
}
foreach (var item in borrowList)//添加归还消息到消息数据表
foreach (var item in borrowList)//添加归还消息到消息数据表
{
......@@ -236,7 +236,7 @@ namespace JmpMsgService
message.MessageInfo = item.OrderCode;
message.SendTime = DateTime.Now;
message.PcNumber = Guid.NewGuid().ToString();
message.OrderType = "归还提醒";
message.OrderType = "归还提醒";
message.OrderId = item.OrderCode;
messges.Add(message);
onRefresh?.Invoke(message.SendName);
......@@ -247,7 +247,7 @@ namespace JmpMsgService
bool result = _unitOfWork.MessageRepository.Insert(messges, true);
//_logger.LogDebug("Worker running at: {time},Result:{result}", DateTimeOffset.Now, result);
Task.Delay(int.Parse(checkTime) * 60 * 1000); //单位:分钟
Task.Delay(int.Parse(checkTime) * 60 * 1000); //单位:分钟
}
......@@ -256,8 +256,8 @@ namespace JmpMsgService
try
{
clearConfig = new CfgNotice();
//启动后读取一次数据库的配置信息
var cfg = _unitOfWork.CommonJpLogCfgRepository.Get(p => p.Id != null);//全局配置信息
//启动后读取一次数据库的配置信息
var cfg = _unitOfWork.CommonJpLogCfgRepository.Get(p => p.Id != null);//全局配置信息
clearConfig.id = cfg.Id;
clearConfig.updateCicle = cfg.UpdateCicle;
clearConfig.lastTime = DateTime.Now;
......@@ -267,12 +267,12 @@ namespace JmpMsgService
ClearCache();
clearConfig.lastTime = DateTime.Now;
Task.Delay(int.Parse(checkTime) * 60 * 1000); //单位:分钟
Task.Delay(int.Parse(checkTime) * 60 * 1000); //单位:分钟
}
catch (Exception ex)
{
_logger.LogError("消息服务 WaitData:" + ex.ToString());
_logger.LogError("消息服务 WaitData:" + ex.ToString());
}
}
private void RefreshCfg(string json)
......@@ -306,7 +306,7 @@ namespace JmpMsgService
if (client_info.IsAvailable)
{
client_info.Send("refresh");
Console.WriteLine($"发送至:{s.Key}");
Console.WriteLine($"发送至:{s.Key}");
}
}
});
......@@ -343,16 +343,16 @@ namespace JmpMsgService
DirectoryInfo cabPic = new DirectoryInfo(_cabinetPath);
DirectoryInfo logFile = new DirectoryInfo(_logPath);
//遍历文件夹
//遍历文件夹
if (Directory.Exists(channelPic.ToString()))
{
foreach (DirectoryInfo NextFolder in channelPic.GetDirectories())//遍历通道
foreach (DirectoryInfo NextFolder in channelPic.GetDirectories())//遍历通道
{
DirectoryInfo NewTheFolder = new DirectoryInfo(NextFolder.FullName);
foreach (DirectoryInfo NextNewFolder in NewTheFolder.GetDirectories())//遍历仓库
foreach (DirectoryInfo NextNewFolder in NewTheFolder.GetDirectories())//遍历仓库
{
DirectoryInfo NewDataFolder = new DirectoryInfo(NextNewFolder.FullName);
foreach (DirectoryInfo item in NewDataFolder.GetDirectories())//遍历仓库下的日期文件夹
foreach (DirectoryInfo item in NewDataFolder.GetDirectories())//遍历仓库下的日期文件夹
{
if (item.CreationTime.AddDays(clearConfig.updateCicle) < DateTime.Now.Date)
{
......@@ -371,10 +371,10 @@ namespace JmpMsgService
}
if (Directory.Exists(cabPic.ToString()))
{
foreach (DirectoryInfo NextFolder in cabPic.GetDirectories())//遍历单警柜日志文件夹
foreach (DirectoryInfo NextFolder in cabPic.GetDirectories())//遍历单警柜日志文件夹
{
DirectoryInfo NewTheFolder = new DirectoryInfo(NextFolder.FullName);
foreach (DirectoryInfo NextNewFolder in NewTheFolder.GetDirectories())//遍历主柜
foreach (DirectoryInfo NextNewFolder in NewTheFolder.GetDirectories())//遍历主柜
{
......@@ -390,10 +390,10 @@ namespace JmpMsgService
}
if (Directory.Exists(logFile.ToString()))
{
foreach (DirectoryInfo NextFolder in logFile.GetDirectories())//遍历日志文件夹
foreach (DirectoryInfo NextFolder in logFile.GetDirectories())//遍历日志文件夹
{
DirectoryInfo NewTheFolder = new DirectoryInfo(NextFolder.FullName);
foreach (FileInfo item in NewTheFolder.GetFiles())//遍历日志文件夹下的其他文件夹
foreach (FileInfo item in NewTheFolder.GetFiles())//遍历日志文件夹下的其他文件夹
{
if (item.CreationTime.AddDays(clearConfig.updateCicle) < DateTime.Now.Date)
{
......@@ -409,19 +409,19 @@ namespace JmpMsgService
try
{
var cmdInfo = JsonConvert.DeserializeObject<CmdInfo>(msg);
if (cmdInfo == null) { _logger.LogInformation("无效的JSON字符串"); }
if (cmdInfo == null) { _logger.LogInformation("无效的JSON字符串"); }
else
{
switch (cmdInfo.cmdType)
{
case CmdType.刷新消息:
case CmdType.刷新消息:
if (!dict_client_role.ContainsKey(client)&&!client.Contains("127.0.0.1"))
{
dict_client_role.Add(client, cmdInfo.cmdPara);
}
onRefresh?.Invoke(cmdInfo.cmdPara);
break;
case CmdType.缓存删除:
case CmdType.缓存删除:
RefreshCfg(cmdInfo.cmdPara);
break;
default: break;
......
......@@ -24,7 +24,7 @@ namespace JunmpPoliceStation
var process = Process.GetProcessesByName("JunmpPoliceStation");
if (process.Length > 1)
{
Console.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}] - 已有另一个进程正在运行中...");
Console.WriteLine($"[{DateTime.Now.ToString("yyyy-MM-dd HH:mm")}] - 已有另一个进程正在运行中...");
Console.ReadKey();
}
else
......
......@@ -63,13 +63,13 @@ namespace JunmpPoliceStation
GlobalContext.UseNoticeService(new Uri(msg_uri));
if (GlobalContext.ServerNum <= 0 || GlobalContext.ServerNum > 15)
{
throw new Exception("服务器编号不正确,应是1-15之间的数字,请检查JSON配置ServerNum字段。");
throw new Exception("服务器编号不正确,应是1-15之间的数字,请检查JSON配置ServerNum字段。");
}
else
{
services.AddSession();
services.AddTransient(typeof(UnitOfWork));//注入工作单元
//配置跨域处理,允许所有来源
services.AddTransient(typeof(UnitOfWork));//注入工作单元
//配置跨域处理,允许所有来源
services.AddCors(options =>
{
options.AddPolicy("cors",
......@@ -101,19 +101,19 @@ namespace JunmpPoliceStation
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0);
services.AddMvc().AddWebApiConventions();
services.AddMvc().AddControllersAsServices();
//配置Swagger
//注册Swagger生成器,定义一个Swagger 文档
//配置Swagger
//注册Swagger生成器,定义一个Swagger 文档
services.AddSwaggerGen(c =>
{
c.DocumentFilter<SwaggerIgnoreFilter>();
c.SwaggerDoc("v1", new OpenApiInfo
{
Version = "v1",
Title = "警用仓库管理平台接口",
Description = "仓库API"
Title = "警用仓库管理平台接口",
Description = "仓库API"
});
// 为 Swagger 设置xml文档注释路径
// 为 Swagger 设置xml文档注释路径
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
c.IncludeXmlComments(xmlPath);
......@@ -130,7 +130,7 @@ namespace JunmpPoliceStation
.AddNacosConfig(Configuration)
.AddNacosAspNetCore(Configuration);
//启动MQTT
//启动MQTT
//var mqtt = new MQTTServer(connection);
//mqtt.StartMqttServer(Configuration);
//services.AddSingleton(mqtt);
......@@ -145,9 +145,9 @@ namespace JunmpPoliceStation
services.AddSingleton<MQTTServer>();
services.AddHangfire(configuration => configuration
.UseMemoryStorage());//使用内存
services.AddHangfireServer();//添加hangfire服务
services.AddScoped<CronJob>();//注册执行类
.UseMemoryStorage());//使用内存
services.AddHangfireServer();//添加hangfire服务
services.AddScoped<CronJob>();//注册执行类
services.Configure<ForwardedHeadersOptions>(options =>
{
......@@ -181,9 +181,9 @@ namespace JunmpPoliceStation
app.UseSession();
//启用中间件服务生成Swagger作为JSON终结点
//启用中间件服务生成Swagger作为JSON终结点
app.UseSwagger();
//启用中间件服务对swagger-ui,指定Swagger JSON终结点
//启用中间件服务对swagger-ui,指定Swagger JSON终结点
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
......@@ -195,8 +195,8 @@ namespace JunmpPoliceStation
//app.UseAuthorization();
app.UseRouting();
//允许所有跨域,cors是在ConfigureServices方法中配置的跨域策略名称
//注意:UseCors必须放在UseRouting和UseEndpoints之间
//允许所有跨域,cors是在ConfigureServices方法中配置的跨域策略名称
//注意:UseCors必须放在UseRouting和UseEndpoints之间
app.UseCors("cors");
app.UseAuthentication();
app.UseEndpoints(endpoints =>
......@@ -223,7 +223,7 @@ namespace JunmpPoliceStation
// template: "{controller=Home}/{action=Index}/{id?}");
//});
//注册nacos服务
//注册nacos服务
//_namingClient.RegisterInstanceAsync(new RegisterInstanceRequest()
//{
// ServiceName = "JunmpPoliceStation12",
......@@ -245,7 +245,7 @@ namespace JunmpPoliceStation
public class Setting
{
/// <summary>
/// 数据库连接字符串
/// 数据库连接字符串
/// </summary>
public string MySqlConnection { get; set; }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论