251029
This commit is contained in:
17
FATrace.WPLApp/Services/DataServices.cs
Normal file
17
FATrace.WPLApp/Services/DataServices.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据服务
|
||||
/// 产线PLC数据交互的服务
|
||||
/// </summary>
|
||||
public class DataServices
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
20
FATrace.WPLApp/Services/ILogService.cs
Normal file
20
FATrace.WPLApp/Services/ILogService.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// NLog服务
|
||||
/// </summary>
|
||||
public interface ILogService
|
||||
{
|
||||
void Debug(string msg);
|
||||
void Error(string msg);
|
||||
void Fatal(string msg);
|
||||
void Info(string msg);
|
||||
void Warn(string msg);
|
||||
}
|
||||
}
|
||||
14
FATrace.WPLApp/Services/IMapperProvider.cs
Normal file
14
FATrace.WPLApp/Services/IMapperProvider.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using AutoMapper;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
public interface IMapperProvider
|
||||
{
|
||||
IMapper GetMapper();
|
||||
}
|
||||
}
|
||||
82
FATrace.WPLApp/Services/LogService.cs
Normal file
82
FATrace.WPLApp/Services/LogService.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志服务
|
||||
/// </summary>
|
||||
public class LogService : ILogService
|
||||
{
|
||||
private static Logger Logger = LogManager.GetCurrentClassLogger(); //初始化日志类
|
||||
|
||||
/// <summary>
|
||||
/// 调试日志
|
||||
/// </summary>
|
||||
/// <param name="msg">日志内容</param>
|
||||
public void Debug(string msg)
|
||||
{
|
||||
Logger.Debug(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 信息日志
|
||||
/// </summary>
|
||||
/// <param name="msg">日志内容</param>
|
||||
/// <remarks>
|
||||
/// 适用大部分场景
|
||||
/// 1.记录日志文件
|
||||
/// </remarks>
|
||||
public void Info(string msg)
|
||||
{
|
||||
Logger.Info(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 错误日志
|
||||
/// </summary>
|
||||
/// <param name="msg">日志内容</param>
|
||||
/// <remarks>
|
||||
/// 适用异常,错误日志记录
|
||||
/// 1.记录日志文件
|
||||
/// </remarks>
|
||||
public void Error(string msg)
|
||||
{
|
||||
Logger.Error(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 严重致命错误日志
|
||||
/// </summary>
|
||||
/// <param name="msg">日志内容</param>
|
||||
/// <remarks>
|
||||
/// 1.记录日志文件
|
||||
/// 2.控制台输出
|
||||
/// </remarks>
|
||||
public void Fatal(string msg)
|
||||
{
|
||||
Logger.Fatal(msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 警告日志
|
||||
/// </summary>
|
||||
/// <param name="msg">日志内容</param>
|
||||
/// <remarks>
|
||||
/// 1.记录日志文件
|
||||
/// 2.发送日志邮件
|
||||
/// </remarks>
|
||||
public void Warn(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
Logger.Warn(msg);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
41
FATrace.WPLApp/Services/MapperProvidere.cs
Normal file
41
FATrace.WPLApp/Services/MapperProvidere.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using AutoMapper;
|
||||
using Prism.Ioc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置服务
|
||||
/// </summary>
|
||||
public class MapperProvidere : IMapperProvider
|
||||
{
|
||||
private readonly MapperConfiguration _Configuration;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="container"></param>
|
||||
public MapperProvidere(IContainerProvider container)
|
||||
{
|
||||
_Configuration = new MapperConfiguration(configure =>
|
||||
{
|
||||
//var assemblys = AppDomain.CurrentDomain.GetAssemblies();
|
||||
//configure.AddMaps(assemblys);
|
||||
|
||||
configure.ConstructServicesUsing(container.Resolve);
|
||||
|
||||
//扫描profile文件
|
||||
configure.AddMaps(AppDomain.CurrentDomain.GetAssemblies());
|
||||
});
|
||||
}
|
||||
|
||||
public IMapper GetMapper()
|
||||
{
|
||||
return _Configuration.CreateMapper();
|
||||
}
|
||||
}
|
||||
}
|
||||
165
FATrace.WPLApp/Services/NavigationServices.cs
Normal file
165
FATrace.WPLApp/Services/NavigationServices.cs
Normal file
@@ -0,0 +1,165 @@
|
||||
using FATrace.WPLApp.ModelDto;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 导航服务类
|
||||
/// </summary>
|
||||
public class NavigationServices
|
||||
{
|
||||
public NavigationServices()
|
||||
{
|
||||
NavItemDtos = new ObservableCollection<NavItemDto>()
|
||||
{
|
||||
// 看板导航项
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "Dashboard",
|
||||
CmdPar = "Dashboard",
|
||||
Icon = "\ued78",
|
||||
IsParent = false,
|
||||
},
|
||||
|
||||
// 工艺监控导航项(父级)
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "工艺监控",
|
||||
CmdPar = "",
|
||||
Icon = "\uea12",
|
||||
IsParent = true,
|
||||
ChildrenNavItemDtos = new ObservableCollection<NavItemDto>()
|
||||
{
|
||||
// 基础数据的子项
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "3D工艺流程",
|
||||
CmdPar = "3D工艺流程",
|
||||
Icon = "\uee12",
|
||||
IsParent = false,
|
||||
},
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "管道线路",
|
||||
CmdPar = "管道线路",
|
||||
Icon = "\ue650",
|
||||
IsParent = false,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
// 生产管理导航项(父级) - 新增测试导航
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "数据管理",
|
||||
CmdPar = "",
|
||||
Icon = "\ue62c",
|
||||
IsParent = true,
|
||||
ChildrenNavItemDtos = new ObservableCollection<NavItemDto>()
|
||||
{
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "报表数据",
|
||||
CmdPar = "报表数据",
|
||||
Icon = "\uec55",
|
||||
IsParent = false,
|
||||
},
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "原料使用查询",
|
||||
CmdPar = "原料使用查询",
|
||||
Icon = "\ue62c",
|
||||
IsParent = false,
|
||||
},
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "原料入库查询",
|
||||
CmdPar = "原料入库查询",
|
||||
Icon = "\uec55",
|
||||
IsParent = false,
|
||||
},
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "历史报警",
|
||||
CmdPar = "历史报警",
|
||||
Icon = "\uec60;",
|
||||
IsParent = false,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
// 系统设置导航项(父级)
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "系统",
|
||||
CmdPar = "",
|
||||
Icon = "\ue62b",
|
||||
IsParent = true,
|
||||
ChildrenNavItemDtos = new ObservableCollection<NavItemDto>()
|
||||
{
|
||||
// 系统设置的子项
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "日志信息",
|
||||
CmdPar = "日志信息",
|
||||
Icon = "\uec46",
|
||||
IsParent = false,
|
||||
},
|
||||
// 系统设置的子项
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "用户登录",
|
||||
CmdPar = "用户登录",
|
||||
Icon = "\ueb22",
|
||||
IsParent = false,
|
||||
},
|
||||
new NavItemDto()
|
||||
{
|
||||
Name = "使用手册",
|
||||
CmdPar = "使用手册",
|
||||
Icon = "\ue8c3",
|
||||
IsParent = false,
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
//// 生产管理导航项(父级) - 新增测试导航
|
||||
//new NavItemDto()
|
||||
//{
|
||||
// Name = "生产管理",
|
||||
// CmdPar = "",
|
||||
// Icon = "\ue650",
|
||||
// IsParent = true,
|
||||
// ChildrenNavItemDtos = new ObservableCollection<NavItemDto>()
|
||||
// {
|
||||
// new NavItemDto()
|
||||
// {
|
||||
// Name = "生产计划",
|
||||
// CmdPar = "生产计划",
|
||||
// Icon = "\ue650",
|
||||
// IsParent = false,
|
||||
// },
|
||||
// new NavItemDto()
|
||||
// {
|
||||
// Name = "工艺参数",
|
||||
// CmdPar = "工艺参数",
|
||||
// Icon = "\ue650",
|
||||
// IsParent = false,
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导航服务类集合数据
|
||||
/// </summary>
|
||||
public ObservableCollection<NavItemDto> NavItemDtos { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
88
FATrace.WPLApp/Services/SysRunService.cs
Normal file
88
FATrace.WPLApp/Services/SysRunService.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using FATrace.WPLApp.Models;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
public class SysRunService : BindableBase
|
||||
{
|
||||
public SysRunService(IEventAggregator eventAggregator)
|
||||
{
|
||||
// 创建一个定时器,设置间隔时间为2000毫秒(即2秒)
|
||||
CurTimer = new System.Timers.Timer(5000);
|
||||
CurTimer.AutoReset = true;
|
||||
// 设置Elapsed事件处理程序
|
||||
CurTimer.Elapsed += CurTimer_Elapsed;
|
||||
// 启动定时器
|
||||
CurTimer.Start();
|
||||
|
||||
}
|
||||
|
||||
private string? _CurUser;
|
||||
/// <summary>
|
||||
/// 当前的用户
|
||||
/// </summary>
|
||||
public string? CurUser
|
||||
{
|
||||
get { return _CurUser; }
|
||||
set
|
||||
{
|
||||
if (_CurUser != value)
|
||||
{
|
||||
_CurUser = value;
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
IsLogin = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsLogin = true;
|
||||
}
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsLogin;
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
public bool IsLogin
|
||||
{
|
||||
get { return _IsLogin; }
|
||||
set { _IsLogin = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行状态
|
||||
/// </summary>
|
||||
public SysRunState SysRunState { get; set; } = new SysRunState();
|
||||
|
||||
/// <summary>
|
||||
/// 定时器
|
||||
/// </summary>
|
||||
private System.Timers.Timer CurTimer { get; set; }
|
||||
|
||||
private DateTime _CurDateTime;
|
||||
/// <summary>
|
||||
/// 当前时间信息
|
||||
/// </summary>
|
||||
public DateTime CurDateTime
|
||||
{
|
||||
get { return _CurDateTime; }
|
||||
set { _CurDateTime = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private void CurTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
CurDateTime = DateTime.Now;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user