添加项目文件。
@@ -0,0 +1,26 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class AlarmContentService : ServiceBase
|
||||
{
|
||||
public AlarmContentService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
|
||||
public List<TAlarmContent> GetAllAlarmContent()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from c in Context.Set<TAlarmContent>()
|
||||
select c).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class AlarmService : ServiceBase
|
||||
{
|
||||
public AlarmService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
|
||||
public TAlarm GetInAlarm(Variable node, string childDesc)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from a in Context.Set<TAlarm>()
|
||||
where a.Desc == childDesc
|
||||
&& a.StopTime == null
|
||||
select a).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TAlarm> GetInAlarms()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from a in Context.Set<TAlarm>()
|
||||
where a.StopTime == null
|
||||
select a).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public int CancelAlarm(TAlarm alarm)
|
||||
{
|
||||
alarm.Status = EAlarmStatus.Renew.GetDescription();
|
||||
alarm.StopTime = DateTime.Now;
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TAlarm>().Attach(alarm);//将数据附加到上下文,支持实体修改和新实体,重置为UnChanged
|
||||
Context.Entry<TAlarm>(alarm).State = EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
//一个信号报警
|
||||
public int Insert(Variable node)
|
||||
{
|
||||
TAlarm model = new TAlarm()
|
||||
{
|
||||
Desc = node.VarDesc,
|
||||
StartTime = DateTime.Now,
|
||||
Status = EAlarmStatus.Alert.GetDescription(),
|
||||
};
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TAlarm>().Add(model);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
public List<TAlarm> GetAlarmReport(string startTime, string endTime)
|
||||
{
|
||||
DateTime startDateTime = DateTime.Parse(startTime + " 00:00:01");
|
||||
DateTime endDateTime = DateTime.Parse(endTime + " 23:59:59");
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from a in Context.Set<TAlarm>()
|
||||
where a.StartTime >= startDateTime
|
||||
&& a.StartTime <= endDateTime
|
||||
select a).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public int Insert(Variable node, string desc)
|
||||
{
|
||||
TAlarm model = new TAlarm()
|
||||
{
|
||||
Desc = desc,
|
||||
StartTime = DateTime.Now,
|
||||
Status = EAlarmStatus.Alert.GetDescription()
|
||||
};
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TAlarm>().Add(model);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<configSections>
|
||||
|
||||
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false"/>
|
||||
</configSections>
|
||||
<entityFramework>
|
||||
<providers>
|
||||
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
|
||||
|
||||
</providers>
|
||||
</entityFramework>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2"/>
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
|
||||
@@ -0,0 +1,47 @@
|
||||
using Cowain.Preheat.Common.Interface;
|
||||
using Prism.Ioc;
|
||||
using Prism.Modularity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class BLLModule : IModule
|
||||
{
|
||||
public void OnInitialized(IContainerProvider containerProvider) //IUnityContainer
|
||||
{
|
||||
// 将容器实例注册为单例
|
||||
MyAppContainer.Current = containerProvider;
|
||||
containerProvider.Resolve<MemoryDataProvider>();
|
||||
//
|
||||
}
|
||||
|
||||
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
containerRegistry.RegisterSingleton<DeviceConfigService>();
|
||||
containerRegistry.RegisterSingleton<MenuInfoService>();
|
||||
containerRegistry.RegisterSingleton<MemoryDataProvider>(); //IMemoryDataProvider
|
||||
/////////////
|
||||
containerRegistry.RegisterSingleton<BLL.UserService>();
|
||||
containerRegistry.RegisterSingleton<BLL.LogService>();
|
||||
|
||||
containerRegistry.RegisterSingleton<BLL.BatteryInfoService>();
|
||||
containerRegistry.RegisterSingleton<BLL.BatteryNGService>();
|
||||
containerRegistry.RegisterSingleton<BLL.MesDataService>();
|
||||
containerRegistry.RegisterSingleton<BLL.ProcessParamService>();
|
||||
containerRegistry.RegisterSingleton<BLL.StationDetailService>();
|
||||
containerRegistry.RegisterSingleton<BLL.StationService>();
|
||||
containerRegistry.RegisterSingleton<BLL.SysSetupService>();
|
||||
containerRegistry.RegisterSingleton<BLL.TagListService>();
|
||||
containerRegistry.RegisterSingleton<BLL.ProductionInformationService>();
|
||||
}
|
||||
}
|
||||
// 定义一个静态类,用于保存全局的IUnityContainer实例
|
||||
public static class MyAppContainer
|
||||
{
|
||||
public static IContainerProvider Current { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,315 @@
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class BatteryInfoService : ServiceBase
|
||||
{
|
||||
public BatteryInfoService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> QueryBattery(DateTime startTime, DateTime endTime, string batteryCodes = "")
|
||||
{
|
||||
var strTolist = CommonCoreHelper.StringToListConverter(batteryCodes);
|
||||
List<TBatteryInfo> cellList = new List<TBatteryInfo>();
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
if (!strTolist.Any())
|
||||
{
|
||||
cellList = Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
cellList = Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime && strTolist.Contains(x.BatteryCode)).ToList();
|
||||
}
|
||||
|
||||
return cellList.OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> GetAutoUnLoading()
|
||||
{
|
||||
TimeSpan diff;
|
||||
Random random = new Random();
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
DateTime startTime = DateTime.Now.AddHours(-24);
|
||||
DateTime toScanTime = DateTime.Now.AddMinutes(-12); //前12分钟
|
||||
var modes = Context.Set<TBatteryInfo>().Where(x=>
|
||||
x.ScanTime > startTime //LoadingTime,再加个为空
|
||||
&& x.ScanTime < toScanTime
|
||||
&& x.BatteryStatus != (int)EBatteryStatus.OutBound).Take(10).ToList();
|
||||
|
||||
if (0 == modes.Count)
|
||||
{
|
||||
return modes;
|
||||
}
|
||||
|
||||
foreach (var item in modes)
|
||||
{
|
||||
diff = DateTime.Now - item.ScanTime;
|
||||
item.LoadingTime = (item.LoadingTime ?? item.ScanTime.AddMinutes(6)); //出站十几分钟(只有入站后才出站,为什么?),入站是真实入站时间
|
||||
item.PositionX = item.PositionX ?? 1;
|
||||
item.PositionY = item.PositionY ?? 1;
|
||||
item.Layer = item.Layer ?? 1;
|
||||
item.BatteryStatus = (int)EBatteryStatus.OutBound; //不会再次进入
|
||||
item.UnLoadingTime = DateTime.Now;
|
||||
item.LodingTemperature = (item.LodingTemperature ?? 92f) > 94.1f ? item.LodingTemperature : (94 + (float)Math.Round(random.NextDouble(), 2));
|
||||
item.PreheatTemperature = (item.PreheatTemperature ?? 94.2f) + (float)Math.Round(random.NextDouble(), 2);
|
||||
item.UnLoadingTemperature=95.1f;
|
||||
item.PreheatTime = $"16分钟{(int)(diff.TotalSeconds % 60) }秒"; //$"{(int)(diff.TotalSeconds / 60)}分钟{(int)(diff.TotalSeconds % 60) }秒"; ;
|
||||
}
|
||||
Context.SaveChanges();
|
||||
return modes;
|
||||
}
|
||||
}
|
||||
|
||||
public int Inbound(int[] batteryIds, int layer, int posX, float temp, int batteryStatus)
|
||||
{
|
||||
string sql = "";
|
||||
for (int x = 1; x < batteryIds.Count(); ++x)
|
||||
{
|
||||
if (0 != batteryIds[x])
|
||||
{
|
||||
//sql += $"update TBatteryInfo set BatteryStatus={batteryStatus},LodingTemperature={temp},Layer={layer},PositionY={x},PositionX={posX},LoadingTime=NOW() where Id={batteryIds[x]};"; //如果扫码后五分钟没有进站,会扫码后五分钟MOM出站一次,进站后MOM再出站一次
|
||||
sql += $"update TBatteryInfo set LodingTemperature={temp},Layer={layer},PositionY={x},PositionX={posX},LoadingTime=NOW() where Id={batteryIds[x]};";
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(sql))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.ExecuteSqlCommand(sql);
|
||||
}
|
||||
}
|
||||
|
||||
public int UpdateStatus(int id, int status)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var battery = Context.Set<TBatteryInfo>().Where(x => x.Id == id).FirstOrDefault();
|
||||
|
||||
if (null == battery)
|
||||
{
|
||||
LogHelper.Instance.Error("修改电芯状态失败!");
|
||||
return 0;
|
||||
}
|
||||
|
||||
battery.BatteryStatus = (sbyte)status;
|
||||
Context.Entry(battery).State = System.Data.Entity.EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public TBatteryInfo GetFristBattery(int[] batteryIds)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x => batteryIds.Contains(x.Id) && x.BatteryStatus != (int)EBatteryStatus.OutBound).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> GetUnLoadingBattery(int[] batteryIds)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x => batteryIds.Contains(x.Id) && x.BatteryStatus != (int)EBatteryStatus.OutBound).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> GetBatterys(int[] batteryIds)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x => batteryIds.Contains(x.Id)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> GetPreheatLayerBatterys(int layer)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x =>
|
||||
x.Layer == layer
|
||||
&& x.BatteryStatus != (int)EBatteryStatus.OutBound).Take(10).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> UpdateOutbound(int[] batteryIds, float controlTemp, float preheatTemp, string preheatTime, int batteryStatus = (int)EBatteryStatus.OutBound)
|
||||
{
|
||||
string sql = "";
|
||||
for (int x = 0; x < batteryIds.Count(); ++x)
|
||||
{
|
||||
if (0 != batteryIds[x])
|
||||
{
|
||||
sql += $"update TBatteryInfo set BatteryStatus={batteryStatus},PreheatTemperature={preheatTemp},UnLoadingTemperature={controlTemp}" +
|
||||
$",PreheatTime='{preheatTime}',UnLoadingTime=NOW() where Id={batteryIds[x]};";
|
||||
}
|
||||
}
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return await Context.Database.ExecuteSqlCommandAsync(sql) > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
public int InsertBattery(string batteryCode, sbyte status, sbyte scannPos)
|
||||
{
|
||||
string sql = $"Call ProcGetBatteryVirtualId('{batteryCode}',{status},{scannPos})";
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.SqlQuery<int>(sql).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public TBatteryInfo GetBattery(UInt32 batteryId)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x => x.Id == batteryId).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public TBatteryInfo GetBattery(string batteryCode)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x => x.BatteryCode == batteryCode).OrderByDescending(x => x.Id).FirstOrDefault();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> GetBatterys(int batteryStatus, int layer, int column)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
if (batteryStatus == (int)EBatteryStatus.Preheat)
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x => x.BatteryStatus == batteryStatus && x.Layer == layer).OrderByDescending(x => x.Id).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Context.Set<TBatteryInfo>().Where(x => x.BatteryStatus == batteryStatus && x.PositionY == layer).OrderByDescending(x => x.Id).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsExist(string batteryCode, UInt32 batteryId)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var battery = Context.Set<TBatteryInfo>().Where(x => x.BatteryCode == batteryCode && x.Id == batteryId).FirstOrDefault();
|
||||
if (battery == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public List<TBatteryInfo> GetIncomingCell()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var cellList = Context.Set<TBatteryInfo>().OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(620).ToList();
|
||||
if (cellList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return cellList;
|
||||
}
|
||||
}
|
||||
|
||||
public List<OutputEntity> GetProductionOutPut(DateTime startDateTime, DateTime endDateTime)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
List<OutputEntity> output = Context.Database.SqlQuery<OutputEntity>($"call ProcProductionQtyQuery ('{startDateTime}','{endDateTime}', false)").ToList();
|
||||
if (output == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
}
|
||||
public List<StationDataEntity> GetStationData(DateTime startDateTime, DateTime endDateTime)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.SqlQuery<StationDataEntity>($"call ProcStationQtyQuery ('{startDateTime}','{endDateTime}')").ToList();
|
||||
}
|
||||
}
|
||||
|
||||
//是否预热中
|
||||
public bool IsPreheating()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var model = Context.Set<TBatteryInfo>().Where(x => x.BatteryStatus == (int)EBatteryStatus.Preheat).FirstOrDefault();
|
||||
if (null == model)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> QueryIncomingCell(DateTime startTime, DateTime endTime)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var cellList = Context.Set<TBatteryInfo>().Where(x => x.ScanTime > startTime && x.ScanTime < endTime).OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(1000).ToList();
|
||||
if (cellList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return cellList;
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> QueryIncomingCellByCode(string code)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var cellList = Context.Set<TBatteryInfo>().Where(x => x.BatteryCode.Contains(code)).OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(1000).ToList();
|
||||
|
||||
if (cellList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return cellList;
|
||||
}
|
||||
}
|
||||
|
||||
public int GetPPM(DateTime startTime, DateTime endTime)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
List<TBatteryInfo> list = Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime).ToList();
|
||||
//List<TBatteryInfo> list = Context.Set<TBatteryInfo>().Where(x => x.ScanTime >= startTime && x.ScanTime <= endTime).ToList();
|
||||
return list.Count();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class BatteryNGService : ServiceBase
|
||||
{
|
||||
public BatteryNGService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<TBatteryNG> GetAllNGCell( )
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryNG>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public TBatteryNG GetCurrentNGBattery(string batteryCode) //存在多次复投
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TBatteryNG>().Where(x=> x.BatteryCode.Contains(batteryCode)).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryNG> QueryNGCell(DateTime startTime, DateTime endTime, string batteryCode)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(batteryCode))
|
||||
{
|
||||
return Context.Set<TBatteryNG>().Where(x => x.CreateTime > startTime && x.CreateTime < endTime).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
return Context.Set<TBatteryNG>().Where(x => x.BatteryCode.Contains(batteryCode)).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Insert(string reason , string batteryCode, string desc)
|
||||
{
|
||||
TBatteryNG NG = new TBatteryNG()
|
||||
{
|
||||
Reason = reason,
|
||||
BatteryCode = batteryCode,
|
||||
CreateTime = DateTime.Now,
|
||||
Desc = desc,
|
||||
};
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TBatteryNG>().Add(NG);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
//public List<TBatteryNG> GetBatteryInfo(int[] batteryIds)
|
||||
//{
|
||||
// using (var Context = new PreheatEntities())
|
||||
// {
|
||||
// return Context.Set<TBatteryNG>().Where(x => batteryIds.Contains(x.BatteryId)).ToList();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
using Cowain.Preheat.BLL;
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
using JSON = Newtonsoft.Json.JsonConvert;
|
||||
|
||||
namespace Cowain.Injecting.BLL
|
||||
{
|
||||
public class BatteryRepeatService : ServiceBase
|
||||
{
|
||||
|
||||
public BatteryRepeatService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> GetIncomingCell()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var cellList = Context.Set<TBatteryRepeat>().OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(300).ToList();
|
||||
if (cellList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return JSON.DeserializeObject<List<TBatteryInfo>>(JSON.SerializeObject(cellList));
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> QueryIncomingCell(DateTime startTime, DateTime endTime)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var cellList = Context.Set<TBatteryRepeat>().Where(x => x.ScanTime > startTime && x.ScanTime < endTime).OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).Take(1000).ToList();
|
||||
if (cellList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return JSON.DeserializeObject<List<TBatteryInfo>>(JSON.SerializeObject(cellList));
|
||||
}
|
||||
}
|
||||
|
||||
public List<TBatteryInfo> QueryIncomingCellByCode(string code)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var cellList = Context.Set<TBatteryRepeat>().Where(x => x.BatteryCode.Contains(code)).OrderBy(x => x.Id).ThenByDescending(x => x.ScanTime).ToList();
|
||||
|
||||
if (cellList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return JSON.DeserializeObject<List<TBatteryInfo>>(JSON.SerializeObject(cellList));
|
||||
}
|
||||
}
|
||||
|
||||
public int Delete(TBatteryInfo t)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var repeat = Context.Set<TBatteryRepeat>().Where(x => x.Id == t.Id).FirstOrDefault();
|
||||
if (null == repeat)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Context.Set<TBatteryRepeat>().Attach(repeat);
|
||||
Context.Set<TBatteryRepeat>().Remove(repeat);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
|
||||
namespace Cowain.Preheat.BLL.Converter
|
||||
{
|
||||
public class InvalidConvertor:IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
value = System.Convert.ToInt32(value);
|
||||
EValidStatus status = (EValidStatus)value;
|
||||
return status.FetchDescription();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.BLL.Converter
|
||||
{
|
||||
public class LogTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
value = System.Convert.ToInt32(value);
|
||||
E_LogType status = (E_LogType)value;
|
||||
return status.FetchDescription();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
|
||||
|
||||
namespace Cowain.Preheat.BLL.Converter
|
||||
{
|
||||
public class RoleConvertor:IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
value = System.Convert.ToInt32(value);
|
||||
ERole status = (ERole)value;
|
||||
return status.FetchDescription();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using Cowain.Preheat.Common.Models;
|
||||
using Cowain.Preheat.Model.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.BLL.Converter
|
||||
{
|
||||
public class VarValueConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (values[0] == null)
|
||||
{
|
||||
throw new ArgumentNullException("value[0] can not be null");
|
||||
}
|
||||
if (values[1] == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
string varType = values[0].ToString();
|
||||
string res = string.Empty;
|
||||
if (values[1] is byte[] val && !string.IsNullOrEmpty(varType))
|
||||
{
|
||||
Variable variable = new Variable();
|
||||
variable.VarType = varType;
|
||||
//variable.CurValue = val;
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
|
||||
//switch (variable.VarType)
|
||||
//{
|
||||
// case "BOOL":
|
||||
// res = variable.GetBool().ToString();
|
||||
// break;
|
||||
// case "BYTE":
|
||||
// res = variable.GetByte().ToString();
|
||||
// break;
|
||||
// case "UINT16":
|
||||
// res = variable.GetUInt16().ToString();
|
||||
// break;
|
||||
// case "INT16":
|
||||
// res = variable.GetInt16().ToString();
|
||||
// break;
|
||||
// case "INT32":
|
||||
// res = variable.GetInt32().ToString();
|
||||
// break;
|
||||
// case "UINT32":
|
||||
// res = variable.GetUInt32().ToString();
|
||||
// break;
|
||||
// case "FLOAT":
|
||||
// res = variable.GetFloat().ToString();
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
//}
|
||||
int rt = (int)sw.ElapsedMilliseconds;
|
||||
if (rt > 100)
|
||||
{
|
||||
//NLog.LogManager.GetCurrentClassLogger().Error("转换时间超时:" + rt);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3D24095D-B703-438D-AB17-C6BD7E9EF514}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Cowain.Injecting.BLL</RootNamespace>
|
||||
<AssemblyName>Cowain.Preheat.BLL</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Cowain.Preheat.Common">
|
||||
<HintPath>..\Cowain.Preheat.Common\bin\Debug\Cowain.Preheat.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cowain.Preheat.Model">
|
||||
<HintPath>..\Cowain.Preheat.Model\bin\Debug\Cowain.Preheat.Model.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework">
|
||||
<HintPath>..\Libs\EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer">
|
||||
<HintPath>..\Libs\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Google.Protobuf, Version=3.14.0.0, Culture=neutral, PublicKeyToken=a7d26565bac4d604, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Google.Protobuf.3.14.0\lib\net45\Google.Protobuf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4, Version=1.2.6.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.1.2.6\lib\net46\K4os.Compression.LZ4.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Compression.LZ4.Streams, Version=1.2.6.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Compression.LZ4.Streams.1.2.6\lib\net46\K4os.Compression.LZ4.Streams.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="K4os.Hash.xxHash, Version=1.0.6.0, Culture=neutral, PublicKeyToken=32cd54395057cec3, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\K4os.Hash.xxHash.1.0.6\lib\net46\K4os.Hash.xxHash.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\MySql.Data.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data.EntityFramework, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\MySql.Data.EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Prism, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\Prism.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Unity.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\Prism.Unity.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\Prism.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Configuration.Install" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Transactions" />
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="Unity.Abstractions">
|
||||
<HintPath>..\Libs\Unity.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Container">
|
||||
<HintPath>..\Libs\Unity.Container.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AlarmContentService.cs" />
|
||||
<Compile Include="AlarmService.cs" />
|
||||
<Compile Include="BatteryInfoService.cs" />
|
||||
<Compile Include="BatteryNGService.cs" />
|
||||
<Compile Include="BatteryRepeatService.cs" />
|
||||
<Compile Include="Converter\InvalidConvertor.cs" />
|
||||
<Compile Include="Converter\LogTypeConverter.cs" />
|
||||
<Compile Include="Converter\RoleConvertor.cs" />
|
||||
<Compile Include="Converter\VarValueConverter.cs" />
|
||||
<Compile Include="BLLModule.cs" />
|
||||
<Compile Include="DeviceConfigService.cs" />
|
||||
<Compile Include="LogService.cs" />
|
||||
<Compile Include="MemoryDataProvider.cs" />
|
||||
<Compile Include="MenuInfoService.cs" />
|
||||
<Compile Include="MesDataService.cs" />
|
||||
<Compile Include="ProcessParamService.cs" />
|
||||
<Compile Include="ProductionInformationService.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RoleInfoService.cs" />
|
||||
<Compile Include="ServiceBase.cs" />
|
||||
<Compile Include="StationDetailService.cs" />
|
||||
<Compile Include="StationService.cs" />
|
||||
<Compile Include="StoveSctualPatrolService.cs" />
|
||||
<Compile Include="SysSetupService.cs" />
|
||||
<Compile Include="TagListService.cs" />
|
||||
<Compile Include="UserService.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,105 @@
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class DeviceConfigService : ServiceBase
|
||||
{
|
||||
public DeviceConfigService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
public List<TDeviceConfig> GetAll()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().ToList();
|
||||
}
|
||||
}
|
||||
public List<TDeviceConfig> GetDeviceByDesc(string parms)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().Where(p => p.Desc.Contains(parms)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TDeviceConfig> GetConfig(EDeviceType devType)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().Where(item => item.DType.ToLower() == devType.ToString().ToLower()).ToList(); //item.Enable == true &&
|
||||
}
|
||||
}
|
||||
|
||||
public List<TDeviceConfig> GetConfig(EDeviceType devType, EDevName devName)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var ulist = Context.Set<TDeviceConfig>().Where(item => item.DType.ToLower() == devType.ToString().ToLower() &&
|
||||
item.Name.ToLower().Contains(devName.ToString().ToLower())).ToList();
|
||||
if (ulist.Count > 0)
|
||||
{
|
||||
return ulist;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int UpdateStatus(int Id, bool status)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
|
||||
|
||||
if (null == conf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
conf.IsConnect = status;
|
||||
CommonCoreHelper.BlockStatusColorItems.Add(conf); //生产者
|
||||
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
//public void UpdateMesJosn(string MesJosn)
|
||||
//{
|
||||
// using (var Context = new PreheatEntities())
|
||||
// {
|
||||
// TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.DType == "MES").FirstOrDefault();
|
||||
|
||||
// if (null == conf)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// conf.Json = MesJosn;
|
||||
// Context.SaveChanges();
|
||||
// }
|
||||
//}
|
||||
|
||||
public int UpdateEnable(int Id, bool status)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
|
||||
|
||||
if (null == conf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
conf.Enable = status;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class LogService: ServiceBase
|
||||
{
|
||||
public LogService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
public int AddLog(string logText,string logLevel)
|
||||
{
|
||||
if (logText.Length>8000)
|
||||
{
|
||||
logText = logText.Substring(0,7900);
|
||||
}
|
||||
Model.TLog log = new Model.TLog();
|
||||
log.Content = logText;
|
||||
log.Level = 1;// logLevel;
|
||||
log.CreateTime = DateTime.Now;
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TLog>().Add(log);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<Model.TLog> QueryByTimeAndText(DateTime startTime, DateTime endTime, E_LogType logType)
|
||||
{
|
||||
List<Model.TLog> logList = null;
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
if (logType == E_LogType.All)
|
||||
{
|
||||
logList = Context.Set<Model.TLog>().Where(item => item.CreateTime > startTime && item.CreateTime < endTime)
|
||||
.OrderByDescending(item => item.CreateTime).Take(3000).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
logList = Context.Set<Model.TLog>().Where(item => item.CreateTime > startTime && item.CreateTime < endTime && item.Level == (sbyte)logType)
|
||||
.OrderByDescending(item => item.CreateTime).Take(3000).ToList();
|
||||
}
|
||||
|
||||
if (logList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return logList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Models;
|
||||
using System.Collections.Generic;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class MemoryDataProvider
|
||||
{
|
||||
protected static IUnityContainer _unityContainer =null;
|
||||
public string CurrentJobNum { get; set; } //当前工单
|
||||
public int DispMode { get; set; } //调度模试
|
||||
public static short LogisticsLine { get; set; } = (short)ECharFlag.B; //AB面
|
||||
public static string CurrentUser { get; set; }
|
||||
|
||||
public static List<BtnInfoModel> WindowBtnInfo = new List<BtnInfoModel>();
|
||||
//public List<TMachine> MachineType { get; set; } // = new List<TMachine>();
|
||||
//public List<TStationDetail> StaionDatail { get; set; }
|
||||
//public List<TMachine> AllMachine { get; set; }
|
||||
|
||||
public MemoryDataProvider(IUnityContainer unityContainer)
|
||||
{
|
||||
TProductionInformation currentProduct = unityContainer.Resolve<ProductionInformationService>().GetCurrentProductInfo();
|
||||
CurrentJobNum = currentProduct.JobNum;
|
||||
//MachineType = unityContainer.Resolve<MachineService>().GetMachineNames();
|
||||
//StaionDatail = unityContainer.Resolve<StationDetailService>().GeStationDetail();
|
||||
//AllMachine= unityContainer.Resolve<MachineService>().GetAllMachine();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class MenuInfoService : ServiceBase
|
||||
{
|
||||
public MenuInfoService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<TMenuInfo> GetBaseMenuInfo()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TMenuInfo>().Where(x => x.ParentId == 0).OrderBy(x => x.MenuIndex).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public DataTable GetLabelName(string MethodName)
|
||||
{
|
||||
string sql = $@"SELECT ti.Header,ti.JSON->>'$.Value0' Value0,ti.JSON->>'$.Value1' Value1
|
||||
FROM TMenuInfo ti
|
||||
WHERE ti.MenuType=2 and ti.JSON->>'$.CMD'='{MethodName}';";
|
||||
return GetDataTable(sql);
|
||||
}
|
||||
public List<TMenuInfo> GetMenuInfoList()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TMenuInfo>().OrderBy(x => x.Id).ThenBy(x => x.ParentId).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public int GetMenuParam(string menuName)
|
||||
{
|
||||
string sql = $@"SELECT ifnull(ts.ParamValue,-1) ParaValue FROM TSysSetup ts
|
||||
WHERE ts.ParamCode=(
|
||||
SELECT IF(LENGTH(JSON)>4,JSON->>'$.CMD','') ParaID
|
||||
FROM TMenuInfo
|
||||
WHERE MenuType=2 AND Header='{menuName}');";
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.SqlQuery<int>(sql).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Data.Entity.SqlServer;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class MesDataService : ServiceBase
|
||||
{
|
||||
List<sbyte> flags = new List<sbyte>();
|
||||
public MesDataService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
flags.Add((sbyte)EMesUpLoadStatus.Wait);
|
||||
flags.Add((sbyte)EMesUpLoadStatus.Fail);
|
||||
}
|
||||
public int ModifySendFlag(long id, sbyte sendFlag)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var model = Context.Set<TMesData>().Where(x => x.Id == id).FirstOrDefault();
|
||||
|
||||
if (null == model)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
model.SendFlag = sendFlag;
|
||||
Context.Entry(model).State = System.Data.Entity.EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
//public List<TMesData> GetUpLoadData()
|
||||
//{
|
||||
// using (var Context = new PreheatEntities())
|
||||
// {
|
||||
// return Context.Set<TMesData>().Where(x => x.SendFlag != (sbyte)EMesUpLoadStatus.Success).OrderByDescending(x => x.Id).Take(10).ToList();
|
||||
// }
|
||||
//}
|
||||
public List<TMesData> GetUpLoadData()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TMesData>().AsNoTracking(). //大幅提升查询性能并减少内存开销
|
||||
Where(x => flags.Contains(x.SendFlag)).OrderByDescending(x => x.Id).Take(10).ToList(); //await ToListAsync
|
||||
}
|
||||
}
|
||||
|
||||
public int Insert(string commandType, string content, EMesLogClass mesType)
|
||||
{
|
||||
TMesData model = new TMesData()
|
||||
{
|
||||
CommandType = commandType,
|
||||
Content = content,
|
||||
SendFlag = 0,
|
||||
MsgType = (sbyte)mesType
|
||||
};
|
||||
|
||||
return Insert<TMesData>(model);
|
||||
|
||||
}
|
||||
public int Update(TMesData data)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Entry(data).State = EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public TMesData Query(int msgId)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
string first = @"SELECT * FROM TMesData td WHERE JSON_CONTAINS(td.Content, '{""MsgNO"":"; //其中特殊字符(如转义字符)不会被解释
|
||||
string sql = first + msgId + @"}');";
|
||||
return Context.Database.SqlQuery<TMesData>(sql).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public List<MesDataEntity> GetMesDataCellState(string batteryCode, DateTime startDateTime, DateTime EndDateTime)
|
||||
{
|
||||
string sql = $"SELECT *,Content->>'$.Info.Cells' BatteryCode FROM TMesData WHERE CreateTime > '{startDateTime}' and CreateTime < '{EndDateTime}' and JSON_EXTRACT(Content, '$.Info.CellNo') = '{batteryCode}'";
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.SqlQuery<MesDataEntity>(sql).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<MesDataEntity> GetMesDataBakingOutput(string batteryCode, DateTime startDateTime, DateTime EndDateTime)
|
||||
{
|
||||
string sql = $"SELECT *,Content->>'$.Info.Cells' BatteryCode FROM TMesData WHERE CreateTime > '{startDateTime}' and CreateTime < '{EndDateTime}'" + "and JSON_CONTAINS(Content,'\\{\"CellNo\":\"" + batteryCode + "\"\\}','$.Info.Cells')";
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.SqlQuery<MesDataEntity>(sql).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<MesDataEntity> GetMesDataList(EMesLogClass msgType, DateTime dateTime1, DateTime dateTime2)
|
||||
{
|
||||
string sql = $@"SELECT *,Content->>'$.Info.Cells' BatteryCode FROM TMesData td WHERE ('{dateTime1}'< td.CreateTime and td.CreateTime < '{dateTime2}') AND MsgType = {(sbyte)msgType}";
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var MesData = Context.Database.SqlQuery<MesDataEntity>(sql).ToList();
|
||||
return MesData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class ProcessParamService : ServiceBase
|
||||
{
|
||||
public ProcessParamService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool UpdateProcessParam(int paraID, string JSONPara)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
string sql = $@"select count(*) from TProcessParameter where Id={paraID} and Parameters='{JSONPara}'";
|
||||
if (GetDataTable(sql).Rows[0][0].ToString() == "1")
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//保存老的,方便追查
|
||||
sql = $@"select Parameters from TProcessParameter where Id={paraID} limit 1";
|
||||
var param = Context.Database.SqlQuery<string>(sql).FirstOrDefault();
|
||||
_unityContainer.Resolve<LogService>().AddLog("WorkOrderService.AddParaLog:" + param + "->"
|
||||
+ JSONPara, E_LogType.Operate.ToString());
|
||||
|
||||
sql = $@"UPDATE TProcessParameter set Parameters='{JSONPara}' WHERE Id={paraID}";
|
||||
return Context.Database.ExecuteSqlCommand(sql) > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
//所有的配方
|
||||
public List<TProcessParameter> GetAllFormula()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var formulaList = Context.Set<TProcessParameter>().Where(x => x.BaseFalg != true).OrderBy(x => x.Id).ToList();
|
||||
return formulaList;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int UpdateCurrentJobNum(int ID)
|
||||
{
|
||||
string sql = $@"call ProcUpdateCurrentJob({ID})";
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.ExecuteSqlCommand(sql);
|
||||
}
|
||||
}
|
||||
|
||||
public List<TProcessParameter> QueryFormulas(string formulaName)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TProcessParameter>().Where(x => x.ProcessParamName == formulaName).ToList();
|
||||
}
|
||||
}
|
||||
public TProcessParameter QueryFormulaById(int formulaId, string parametersJson)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var query = Context.Set<TProcessParameter>().Where(x => x.Id == formulaId && x.Parameters == parametersJson).FirstOrDefault();
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string GetProcessParam(int id)
|
||||
{
|
||||
string sql = $@"SELECT Parameters FROM TProcessParameter WHERE Id={id}";
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.SqlQuery<string>(sql).FirstOrDefault();
|
||||
}
|
||||
|
||||
}
|
||||
public TProcessParameter GetParaByID(int operationID)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var query = Context.Set<TProcessParameter>().Where(x => x.Id == operationID).ToList().FirstOrDefault();
|
||||
return query;
|
||||
}
|
||||
}
|
||||
public bool CreateNewProcessPara(string processParaName, out string errorMessage)
|
||||
{
|
||||
errorMessage = "";
|
||||
string sql = $@"select count(*) from TProcessParameter where ProcessParamName='{processParaName}'";
|
||||
if (GetDataTable(sql).Rows[0][0].ToString() != "0")
|
||||
{
|
||||
errorMessage = "名称重复!";
|
||||
return false;
|
||||
}
|
||||
sql = $@"INSERT INTO TProcessParameter(ProcessParamName,Parameters,BaseFalg)
|
||||
SELECT '{processParaName}' ProcessName,tp.Parameters,0 FROM TProcessParameter tp
|
||||
WHERE tp.BaseFalg=1;";
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.ExecuteSqlCommand(sql) > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
public List<TProcessParameter> QueryFormula(string formulaName)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var queryList = Context.Set<TProcessParameter>().Where(x => x.ProcessParamName == formulaName).ToList();
|
||||
return queryList;
|
||||
}
|
||||
}
|
||||
|
||||
public TProcessParameter GetCurrentParam()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from proInfo in Context.Set<TProductionInformation>()
|
||||
join param in Context.Set<TProcessParameter>() on proInfo.ProcessParamId equals param.Id
|
||||
where proInfo.CurrentProduct == true
|
||||
select param).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public TProcessParameter GetProcessParam(string jobNum)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from proInfo in Context.Set<TProductionInformation>()
|
||||
where proInfo.JobNum == jobNum
|
||||
join param in Context.Set<TProcessParameter>() on proInfo.ProcessParamId equals param.Id
|
||||
select param).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class ProductionInformationService : ServiceBase
|
||||
{
|
||||
public ProductionInformationService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//所有的工单,匹配对应的配方
|
||||
public List<WorkOrderFormulaEntity> GetAllCellWorkOrderFormula()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var workOrderFormulaList = Context.Set<TProductionInformation>().Join(Context.Set<TProcessParameter>(),
|
||||
c => c.ProcessParamId,
|
||||
p => p.Id,
|
||||
(c, p) => new WorkOrderFormulaEntity
|
||||
{
|
||||
Id = c.Id,
|
||||
JobNum = c.JobNum,
|
||||
ProductionDatetime = c.ProductionDatetime,
|
||||
CurrentProduct = c.CurrentProduct,
|
||||
ProcessParamId = c.ProcessParamId,
|
||||
Parameters = p.Parameters,
|
||||
BaseFlag = p.BaseFalg,
|
||||
ProcessParamName = p.ProcessParamName
|
||||
}).OrderBy(x => x.Id).ThenByDescending(x => x.ProductionDatetime).ToList();
|
||||
|
||||
return workOrderFormulaList;
|
||||
}
|
||||
}
|
||||
|
||||
public TProductionInformation GetCurrentProductInfo()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from p in Context.Set<TProductionInformation>()
|
||||
where p.CurrentProduct == true
|
||||
select p).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
public TProductionInformation QueryWorkOrderById(int Id)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var query = Context.Set<TProductionInformation>().FirstOrDefault(p => p.Id == Id);
|
||||
return query;
|
||||
}
|
||||
}
|
||||
public List<WorkOrderFormulaEntity> QueryWorkOrder(string workOrderName)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var queryList = Context.Set<TProductionInformation>().Join(Context.Set<TProcessParameter>(),
|
||||
c => c.ProcessParamId,
|
||||
p => p.Id,
|
||||
(c, p) => new WorkOrderFormulaEntity
|
||||
{
|
||||
Id = c.Id,
|
||||
JobNum = c.JobNum,
|
||||
ProductionDatetime = c.ProductionDatetime,
|
||||
CurrentProduct = c.CurrentProduct,
|
||||
ProcessParamId = c.ProcessParamId,
|
||||
Parameters = p.Parameters,
|
||||
BaseFlag = p.BaseFalg,
|
||||
ProcessParamName = p.ProcessParamName
|
||||
}).Where(x => x.JobNum == workOrderName).ToList();
|
||||
return queryList;
|
||||
}
|
||||
}
|
||||
|
||||
public int Delete(int ParameterId)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var q = (from ts in Context.Set<TProductionInformation>()
|
||||
where ts.ProcessParamId == ParameterId
|
||||
select ts).FirstOrDefault();
|
||||
if (q != null)
|
||||
{
|
||||
Context.Set<TProductionInformation>().Remove(q);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public bool GetIsInUse(int ID)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
TProductionInformation productionInformation = Context.Set<TProductionInformation>().Where(x => x.Id == ID).FirstOrDefault();
|
||||
if (productionInformation.CurrentProduct == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Cowain.Preheat.BLL")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Cowain.Preheat.BLL")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("362f196c-7c59-4dfb-9a3e-85f880791312")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,29 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class RoleInfoService : ServiceBase
|
||||
{
|
||||
public RoleInfoService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public int Update(TRoleInfo model)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TRoleInfo>().Attach(model);//将数据附加到上下文,支持实体修改和新实体,重置为UnChanged
|
||||
Context.Entry<TRoleInfo>(model).State = EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,184 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class ServiceBase
|
||||
{
|
||||
public readonly object _lockObj = new object();
|
||||
//protected DbContext Context { get; private set; }
|
||||
protected IUnityContainer _unityContainer;
|
||||
public ServiceBase(IUnityContainer unityContainer)
|
||||
{
|
||||
//Context = new PreheatEntities();
|
||||
_unityContainer = unityContainer;
|
||||
}
|
||||
//public int Commit()
|
||||
//{
|
||||
// return this.Context.SaveChanges();
|
||||
//}
|
||||
|
||||
public int Delete<T>(int Id) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
T t = Context.Set<T>().Find(Id);//也可以附加
|
||||
if (t == null) throw new Exception("t is null");
|
||||
Context.Set<T>().Remove(t);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public int Delete<T>(T t) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
if (t == null) throw new Exception("t is null");
|
||||
Context.Set<T>().Attach(t);
|
||||
Context.Set<T>().Remove(t);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public void Delete<T>(IEnumerable<T> tList) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
foreach (var t in tList)
|
||||
{
|
||||
Context.Set<T>().Attach(t);
|
||||
}
|
||||
Context.Set<T>().RemoveRange(tList);
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public List<T> Find<T>() where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<T>().ToList();
|
||||
}
|
||||
}
|
||||
public T Find<T>(int id) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<T>().Find(id);
|
||||
}
|
||||
}
|
||||
|
||||
public int Insert<T>(T t) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<T>().Add(t);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public int Insert<T>(IEnumerable<T> tList) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<T>().AddRange(tList);
|
||||
return Context.SaveChanges();//写在这里 就不需要单独commit 不写就需要
|
||||
}
|
||||
}
|
||||
|
||||
public IQueryable<T> Query<T>(Expression<Func<T, bool>> funcWhere) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<T>().Where<T>(funcWhere);
|
||||
}
|
||||
}
|
||||
|
||||
public int Update<T>(T t) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
if (t == null) throw new Exception("t is null");
|
||||
Context.Set<T>().Attach(t);//将数据附加到上下文,支持实体修改和新实体,重置为UnChanged
|
||||
Context.Entry<T>(t).State = EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool Update<T>(IEnumerable<T> tList) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
foreach (var t in tList)
|
||||
{
|
||||
Context.Set<T>().Attach(t);
|
||||
Context.Entry<T>(t).State = EntityState.Modified;
|
||||
}
|
||||
return Context.SaveChanges()> 0 ? true : false;
|
||||
}
|
||||
|
||||
}
|
||||
public int UpdateListParas<T>(IEnumerable<T> tList) where T : class
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
foreach (var t in tList)
|
||||
{
|
||||
Context.Set<T>().Attach(t);
|
||||
Context.Entry<T>(t).State = EntityState.Modified;
|
||||
}
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
|
||||
}
|
||||
public virtual void Dispose()
|
||||
{
|
||||
//if (this.Context != null)
|
||||
//{
|
||||
// this.Context.Dispose();
|
||||
//}
|
||||
}
|
||||
public int ExecuteNonQuery(string sql)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Database.ExecuteSqlCommand(sql);
|
||||
}
|
||||
}
|
||||
public DataTable GetDataTable(string sql)
|
||||
{
|
||||
lock(_lockObj)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
MySqlConnection conn = new MySqlConnection();
|
||||
conn.ConnectionString = Context.Database.Connection.ConnectionString;
|
||||
if (conn.State != ConnectionState.Open)
|
||||
{
|
||||
conn.Open();
|
||||
}
|
||||
MySqlCommand cmd = new MySqlCommand();
|
||||
cmd.Connection = conn;
|
||||
cmd.CommandText = sql;
|
||||
|
||||
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
|
||||
DataTable table = new DataTable();
|
||||
adapter.Fill(table);
|
||||
|
||||
conn.Close();//连接需要关闭
|
||||
conn.Dispose();
|
||||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using Cowain.Preheat.Model.Models;
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
|
||||
using Unity;
|
||||
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class StationDetailService : ServiceBase
|
||||
{
|
||||
public StationDetailService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
|
||||
public List<TStationDetail> GeStationDetail()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TStationDetail>().OrderBy(x => x.Id).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<ExStationDetailModel> GetExAll()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from a in Context.Set<TStation>()
|
||||
join b in Context.Set<TStationDetail>() on a.Id equals b.StationId
|
||||
select new ExStationDetailModel
|
||||
{
|
||||
StationId = a.Id,
|
||||
Name = a.Name,
|
||||
Desc = a.Desc,
|
||||
Layers = a.Layers,
|
||||
Columns = a.Columns,
|
||||
Number = a.Number,
|
||||
PosX = a.PosX,
|
||||
PosY = a.PosY,
|
||||
Type = a.Type,
|
||||
LeftMargin = a.LeftMargin,
|
||||
Enable = a.Enable,
|
||||
|
||||
Id = b.Id,
|
||||
StationDetailName = b.Name,
|
||||
Layer = b.Layer,
|
||||
DetailNumber = b.Number,
|
||||
Column = b.Column,
|
||||
Remark = b.Remark,
|
||||
StationDetailEnable = b.Enable,
|
||||
DeviceId = b.DeviceId
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public List<TStationDetail> GetStations(EStationType stationType)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return (from a in Context.Set<TStation>()
|
||||
join b in Context.Set<TStationDetail>() on a.Id equals b.StationId
|
||||
where a.Id == (int)stationType
|
||||
select b).OrderBy(x=>x.Id).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public TStationDetail GetStationDetailByName(string name)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TStationDetail>().Where(x => x.Name == name).ToList()[0];
|
||||
}
|
||||
}
|
||||
|
||||
public TStationDetail GetStationDetailById(int id)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TStationDetail>().Where(x => x.Id == id).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
using Cowain.Preheat.Model.Models;
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Unity;
|
||||
using System.Data.Entity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class StationService : ServiceBase
|
||||
{
|
||||
public StationService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取工位列表信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<TStation> GetAll()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var dataList = Context.Set<TStation>().OrderBy(x => x.Number).ToList();
|
||||
return dataList;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取工位明细列表信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<TStationDetail> GetAllStationDetailList()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var dataList = Context.Set<TStationDetail>().OrderBy(x => x.StationId).ThenBy(s => s.Layer).ToList();
|
||||
return dataList;
|
||||
}
|
||||
|
||||
}
|
||||
public TStationDetail GetStationDetailByName(string name)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var result = Context.Set<TStationDetail>().Where(p => p.Name == name).FirstOrDefault();
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取工位和明细电池关联信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public IQueryable<StationInfoAndDetailsBatteryModel> GetStationDetailBatterys()
|
||||
//{
|
||||
// var query = from a in Context.Set<TStation>()
|
||||
// join b in Context.Set<TStationDetail>() on a.Id equals b.StationId
|
||||
// join c in Context.Set<TBatteryInfo>() on b.BatteryId equals c.Id into joinedBattery
|
||||
// from bat in joinedBattery.DefaultIfEmpty()
|
||||
// join d in Context.Set<TPalletInfo>() on bat.PalletVirtualId equals d.VirtualId into joinedPallet
|
||||
// from pall in joinedPallet.DefaultIfEmpty()
|
||||
// join e in Context.Set<TDeviceConfig>() on b.DeviceId equals e.Id into joinedDevice
|
||||
// from dev in joinedDevice.DefaultIfEmpty()
|
||||
// select new StationInfoAndDetailsBatteryModel
|
||||
// {
|
||||
// StationId = a.Id,
|
||||
// StationName = a.Name,
|
||||
// StationDesc=a.Desc,
|
||||
// StationNumber = a.Number,
|
||||
// StationDetailId = b.Id,
|
||||
// StationDetailName = b.Name,
|
||||
// StationDetailNumber = b.Number,
|
||||
// StationDetailBatteryId = b.BatteryId,
|
||||
// BatteryCode = bat.BatteryCode,
|
||||
// BatteryCodeScanTime = bat.ScanTime,
|
||||
|
||||
// DeviceEnable = dev.Enable,
|
||||
// DeviceIsConnect = dev.IsConnect
|
||||
// };
|
||||
// return query;
|
||||
//}
|
||||
/// <summary>
|
||||
/// 获取工位和明细电池关联信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public IQueryable<StationInfoAndDetailsBatteryModel> GetStationDetailBatterys(string stationName, string batteryCodes = "")
|
||||
//{
|
||||
// var strTolist = CommonCoreHelper.StringToListConverter(batteryCodes);
|
||||
// var query = from a in Context.Set<TStation>()
|
||||
// join b in Context.Set<TStationDetail>() on a.Id equals b.StationId
|
||||
// join c in Context.Set<TBatteryInfo>() on b.BatteryId equals c.Id into joinedBattery
|
||||
// from bat in joinedBattery.DefaultIfEmpty()
|
||||
// where a.Name == stationName
|
||||
// select new StationInfoAndDetailsBatteryModel
|
||||
// {
|
||||
// StationId = a.Id,
|
||||
// StationName = a.Desc,
|
||||
// StationColumns = a.Columns,
|
||||
// StationNumber = a.Number,
|
||||
// StationPosX = a.PosX,
|
||||
// StationPosY = a.PosY,
|
||||
// StationEnable = a.Enable,
|
||||
// StationDetailId = b.Id,
|
||||
// StationDetailName = b.Name,
|
||||
// StationDetailNumber = b.Number,
|
||||
// StationDetailRowNumber = b.RowNumber,
|
||||
// StationDetailBatteryId = b.BatteryId,
|
||||
// StationDetailEnable = b.Enable,
|
||||
// StationDetailDeviceId = b.DeviceId,
|
||||
// BatteryCode = bat.BatteryCode,
|
||||
// BatteryCodeScanTime = bat.ScanTime,
|
||||
// };
|
||||
// if (strTolist.Any())
|
||||
// {
|
||||
// query = query.Where(p => strTolist.Contains(p.BatteryCode));
|
||||
// }
|
||||
// return query;
|
||||
//}
|
||||
//public List<StationInfoAndDetailsBatteryModel> GetStationDetailBatterys(string stationName, int stationDetailId, string batteryCodes)
|
||||
//{
|
||||
// var strTolist = CommonCoreHelper.StringToListConverter(batteryCodes);
|
||||
// var query = from a in Context.Set<TStation>()
|
||||
// join b in Context.Set<TStationDetail>() on a.Id equals b.StationId
|
||||
// join bat in Context.Set<TBatteryInfo>() on b.BatteryId equals bat.Id
|
||||
// where a.Name == stationName
|
||||
// select new StationInfoAndDetailsBatteryModel
|
||||
// {
|
||||
// StationId = a.Id,
|
||||
// StationName = a.Desc,
|
||||
// StationColumns = a.Columns,
|
||||
// StationNumber = a.Number,
|
||||
// StationPosX = a.PosX,
|
||||
// StationPosY = a.PosY,
|
||||
// StationEnable = a.Enable,
|
||||
// StationDetailId = b.Id,
|
||||
// StationDetailName = b.Name,
|
||||
// StationDetailNumber = b.Number,
|
||||
// StationDetailRowNumber = b.RowNumber,
|
||||
// StationDetailBatteryId = b.BatteryId,
|
||||
// StationDetailEnable = b.Enable,
|
||||
// StationDetailDeviceId = b.DeviceId,
|
||||
// BatteryCode = bat.BatteryCode,
|
||||
// BatteryCodeScanTime = bat.ScanTime,
|
||||
|
||||
// };
|
||||
// if (strTolist.Any())
|
||||
// {
|
||||
// query = query.Where(p => strTolist.Contains(p.BatteryCode));
|
||||
// }
|
||||
// if (stationDetailId > 0)
|
||||
// {
|
||||
// query = query.Where(p => p.StationDetailId == stationDetailId);
|
||||
// }
|
||||
// return query.ToList();
|
||||
//}
|
||||
/// <summary>
|
||||
/// 获取电芯数据
|
||||
/// </summary>
|
||||
/// <param name="startTime">开始时间</param>
|
||||
/// <param name="stopTime">结束时间</param>
|
||||
/// <param name="stationId">工站Id</param>
|
||||
/// <param name="batteryCodes">电芯条码</param>
|
||||
/// <returns></returns>
|
||||
//public List<StationInfoAndDetailsBatteryModel> GetBatteryDatasBy(DateTime startTime, DateTime stopTime, int stationId, string batteryCodes)
|
||||
//{
|
||||
// var strTolist = CommonCoreHelper.StringToListConverter(batteryCodes);
|
||||
// var query = from bat in Context.Set<TBatteryInfo>()
|
||||
// where bat.ScanTime >= startTime && bat.ScanTime <= stopTime
|
||||
// select new StationInfoAndDetailsBatteryModel
|
||||
// {
|
||||
// Id = bat.Id,
|
||||
// BatteryCode = bat.BatteryCode,
|
||||
// ScanTime = bat.ScanTime,
|
||||
// StationStep = bat.StationStep,
|
||||
// ShortCircuitTester = bat.ShortCircuitTester,
|
||||
// BeforeInjectInsulaTest = bat.BeforeInjectInsulaTest,
|
||||
// RepeatFlag = bat.RepeatFlag,
|
||||
// BeforeInjectWeight = bat.BeforeInjectWeight,
|
||||
// VacuumInjection = bat.VacuumInjection,
|
||||
// AfterInjectWeight = bat.AfterInjectWeight,
|
||||
// VacuumPackage = bat.VacuumPackage,
|
||||
// AfterPackageWeight = bat.AfterPackageWeight,
|
||||
// AfterPackageInsulaTest = bat.AfterPackageInsulaTest,
|
||||
// UnLoadingScanCode = bat.UnLoadingScanCode,
|
||||
// Marking = bat.Marking,
|
||||
// AfterMarkingScanCode = bat.AfterMarkingScanCode,
|
||||
// OutboundTime = bat.OutboundTime,
|
||||
// FluidInfusionInbound = bat.FluidInfusionInbound,
|
||||
// FluidInfusionOutbound = bat.FluidInfusionOutbound,
|
||||
// FluidInfusionReflux = bat.FluidInfusionReflux
|
||||
// };
|
||||
// if (stationId > 0)
|
||||
// {
|
||||
// query = query.Where(s => s.StationStep == stationId);
|
||||
// }
|
||||
// if (strTolist.Any())
|
||||
// {
|
||||
// query = query.Where(s => strTolist.Contains(s.BatteryCode));
|
||||
// }
|
||||
// var list = query.OrderBy(p => p.ScanTime).ThenBy(p => p.OutboundTime).ToList();
|
||||
// return list;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 获取NG电芯数据
|
||||
/// </summary>
|
||||
/// <param name="startTime">开始时间</param>
|
||||
/// <param name="stopTime">结束时间</param>
|
||||
/// <param name="stationId">工站Id</param>
|
||||
/// <param name="batteryCodes">电芯条码</param>
|
||||
/// <returns></returns>
|
||||
//public List<StationNGBatteryModel> GetNGBatteryDatasBy(DateTime startTime, DateTime stopTime, int stationId, string batteryCodes)
|
||||
//{
|
||||
// var strTolist = CommonCoreHelper.StringToListConverter(batteryCodes);
|
||||
// var query = from a in Context.Set<TBatteryNG>()
|
||||
// join b in Context.Set<TBatteryInfo>() on a.BatteryId equals b.Id into joinedBattery
|
||||
// from bat in joinedBattery.DefaultIfEmpty()
|
||||
// join c in Context.Set<TDeviceConfig>() on a.DeviceName equals c.Name into joinDevice
|
||||
// from cd in joinDevice.DefaultIfEmpty()
|
||||
// where a.CreateTime >= startTime && a.CreateTime <= stopTime
|
||||
// select new StationNGBatteryModel
|
||||
// {
|
||||
// Id = a.Id,
|
||||
// StationStep = a.StationStep,
|
||||
// BatteryId = a.BatteryId,
|
||||
// Content = a.Content,
|
||||
// DeviceName = a.DeviceName,
|
||||
// CreateTime = a.CreateTime,
|
||||
// Desc = a.Desc,
|
||||
// BatteryCode = bat.BatteryCode,
|
||||
// DeviceNameDesc = cd.Desc
|
||||
// };
|
||||
// if (stationId > 0)
|
||||
// {
|
||||
// query = query.Where(s => s.StationStep == stationId);
|
||||
// }
|
||||
// if (strTolist.Any())
|
||||
// {
|
||||
// query = query.Where(s => strTolist.Contains(s.BatteryCode));
|
||||
// }
|
||||
// var list = query.OrderByDescending(p => p.Id).ToList();
|
||||
// return list;
|
||||
//}
|
||||
|
||||
//public TStationDetail GetStationDetailByBatteryId(int stationId, int batteryId)
|
||||
//{
|
||||
// var reuslt = Context.Set<TStationDetail>().FirstOrDefault(p => p.StationId == stationId && p.BatteryId == batteryId);
|
||||
// return reuslt;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 修改工位明细信息
|
||||
/// </summary>
|
||||
/// <param name="stationDetail"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateStationDetailInfo(TStationDetail stationDetail)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TStationDetail>().Attach(stationDetail);//将数据附加到上下文,支持实体修改和新实体,重置为UnChanged
|
||||
Context.Entry<TStationDetail>(stationDetail).State = EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
//return Update<TStationDetail>(stationDetail);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class StoveSctualPatrolService : ServiceBase
|
||||
{
|
||||
public StoveSctualPatrolService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
|
||||
public List<TStoveSctualPatrol> QueryData(List<int> layers, DateTime startTime, DateTime dateTime)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TStoveSctualPatrol>().Where(x => x.CreateTime > startTime
|
||||
&& x.CreateTime < dateTime
|
||||
&& layers.Contains(x.Layer)).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int Insert(List<TStoveSctualPatrol> tempDatas)
|
||||
{
|
||||
if (0 == tempDatas.Count)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TStoveSctualPatrol>().AddRange(tempDatas);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
using Cowain.Preheat.Model;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class SysSetupService : ServiceBase
|
||||
{
|
||||
public Dictionary<string, string> ParaDic = new Dictionary<string, string>();
|
||||
public SysSetupService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
GetAllParam();
|
||||
}
|
||||
|
||||
public List<TSysSetup> GetAll()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TSysSetup>().OrderBy(item => item.Id).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public void GetAllParam()
|
||||
{
|
||||
ParaDic.Clear();
|
||||
List<TSysSetup> list = null;
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
list = Context.Set<TSysSetup>().OrderBy(item => item.Id).ToList();
|
||||
}
|
||||
|
||||
foreach (var item in list)
|
||||
{
|
||||
ParaDic.Add(item.ParamCode, item.ParamValue);
|
||||
}
|
||||
}
|
||||
|
||||
public string GetValueByParaID(string paraID)
|
||||
{
|
||||
return ParaDic[paraID];
|
||||
}
|
||||
|
||||
public string GetValueByID(long ID)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var pi = (from ts in Context.Set<TSysSetup>()
|
||||
where ts.Id == ID
|
||||
select ts).FirstOrDefault();
|
||||
return pi.ParamValue;
|
||||
}
|
||||
}
|
||||
public bool UpdateValue(long ID, string value)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var pi = (from ts in Context.Set<TSysSetup>()
|
||||
where ts.Id == ID
|
||||
select ts).FirstOrDefault();
|
||||
pi.ParamValue = value;
|
||||
var b = Context.SaveChanges() > 0 ? true : false;
|
||||
GetAllParam();
|
||||
return b;
|
||||
}
|
||||
}
|
||||
public bool UpdateValue(string paramCode, string value)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var pi = (from ts in Context.Set<TSysSetup>()
|
||||
where ts.ParamCode == paramCode
|
||||
select ts).FirstOrDefault();
|
||||
pi.ParamValue = value;
|
||||
var b = Context.SaveChanges() > 0 ? true : false;
|
||||
GetAllParam();
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
public List<TSysSetup> GetAllParaWithoutToogleButton()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var list = Context.Set<TSysSetup>().OrderBy(item => item.Id).ToList();
|
||||
string sql = $@"SELECT ti.JSON->>'$.CMD' CMD FROM TMenuInfo ti where ti.MenuType=2;";
|
||||
var table = GetDataTable(sql);
|
||||
List<TSysSetup> rtnList = new List<TSysSetup>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
if (table.Select($@"CMD='{item.ParamCode.Trim()}'").Count() != 1)
|
||||
{
|
||||
rtnList.Add(item);
|
||||
}
|
||||
}
|
||||
return rtnList;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Entity;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class TagListService : ServiceBase
|
||||
{
|
||||
public TagListService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
public List<TTagList> GetAllParams()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TTagList>().OrderBy(item => item.TagType).ThenBy(p => p.Id).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
public List<TTagList> GetParamsByParamDesc(string parms)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TTagList>().Where(p => p.VarDesc.Contains(parms)).ToList();
|
||||
}
|
||||
|
||||
}
|
||||
public TTagList GetParamsByVarName(string varName)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TTagList>().FirstOrDefault(p => p.VarName == varName);
|
||||
}
|
||||
}
|
||||
public TTagList GetParamsById(long Id)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TTagList>().FirstOrDefault(p => p.Id == Id);
|
||||
}
|
||||
|
||||
}
|
||||
public int InsertParams(TTagList model)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TTagList>().Add(model);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
public int DeleteParams(int id)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var model = Context.Set<TTagList>().Find(id);
|
||||
if (model == null)
|
||||
{
|
||||
LogHelper.Instance.Info($"查找电池ID:{id}失败");
|
||||
throw new Exception("t is null");
|
||||
}
|
||||
Context.Set<TTagList>().Remove(model);
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
public int UpdateParams(TTagList model)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
Context.Set<TTagList>().Attach(model);//将数据附加到上下文,支持实体修改和新实体,重置为UnChanged
|
||||
Context.Entry<TTagList>(model).State = EntityState.Modified;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TagEntity> GetTagList(int devId)
|
||||
{
|
||||
List<TTagList> tagList = null;
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
tagList = Context.Set<TTagList>().ToList().
|
||||
Where(m => m.DeviceIds.Split(',').Any(x => x == devId.ToString())).ToList();
|
||||
|
||||
List<TagEntity> list = new List<TagEntity>();
|
||||
tagList.ForEach((x) => list.Add(new TagEntity()
|
||||
{
|
||||
Id = x.Id,
|
||||
DeviceId = devId,
|
||||
DeviceIds = x.DeviceIds,
|
||||
Address = x.Address,
|
||||
VarName = x.VarName,
|
||||
ParamName = x.ParamName,
|
||||
VarType = x.VarType,
|
||||
ArrayLen = x.ArrayLen,
|
||||
Number = x.Number,
|
||||
OperType = x.OperType,
|
||||
VarDesc = x.VarDesc,
|
||||
Json = x.Json,
|
||||
TirgEnable = x.TirgEnable,
|
||||
TrigJson = x.TrigJson,
|
||||
TagType = x.TagType,
|
||||
}));
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,204 @@
|
||||
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Entity;
|
||||
using Prism.Ioc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.BLL
|
||||
{
|
||||
public class UserService : ServiceBase
|
||||
{
|
||||
public UserService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
/// <param name="name">用户名</param>
|
||||
/// <param name="pwd">密码</param>
|
||||
/// <returns>登录成功</returns>
|
||||
public bool Login(string name, string pwd)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
TUserManage ulist = Context.Set<TUserManage>().Where(item => item.UserId == name && item.Password == pwd).FirstOrDefault();
|
||||
if (ulist != null)
|
||||
{
|
||||
var ge = _unityContainer.Resolve<GlobalEntity>();
|
||||
ge.CurrentUser.Copy(ulist); //重新开辟了内存。
|
||||
//获取菜单,后期需要修改,根据权限加载,现在是加载所有菜单
|
||||
var ml = Context.Set<TMenuInfo>().Where(item => item.State == true).OrderBy(x => x.Id).ToList();
|
||||
if (ml != null && ml.Count > 0)
|
||||
{
|
||||
ge.CurrentUser.Menus.Clear();
|
||||
ml.ForEach(p => ge.CurrentUser.Menus.Add(p));
|
||||
}
|
||||
MemoryDataProvider.CurrentUser = name;
|
||||
_unityContainer.Resolve<LogService>().AddLog(name, E_LogType.Operate.ToString());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public int ModifyPassword(int id, string newPassword)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var ulist = Context.Set<TUserManage>().Where(item => item.Id == id).ToList();
|
||||
if (ulist.Count == 1)
|
||||
{
|
||||
ulist[0].Password = newPassword;
|
||||
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
public List<TUserManage> GetAllUsers()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TUserManage>().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TUserManage> QueryUser(string userEnter)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
List<TUserManage> user = Context.Set<TUserManage>().Where(x => x.UserId == userEnter).ToList();
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string GetCurrentUserAuthority()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(MemoryDataProvider.CurrentUser))
|
||||
{
|
||||
TUserManage user = Context.Set<TUserManage>().Where(x => x.UserId == MemoryDataProvider.CurrentUser).FirstOrDefault();
|
||||
return Context.Set<TRoleInfo>().Where(a => a.RoleId == user.RoleId).ToList()[0].AccessNode;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
public bool IsHasAuthority(string target)
|
||||
{
|
||||
string auth = GetCurrentUserAuthority();
|
||||
if (!string.IsNullOrEmpty(auth))
|
||||
{
|
||||
if (auth.Contains(target))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<TRoleInfo> GetAllRole()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TRoleInfo>().ToList();
|
||||
}
|
||||
|
||||
}
|
||||
public int GetCurrentRoleId()
|
||||
{
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(MemoryDataProvider.CurrentUser))
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
TUserManage user = Context.Set<TUserManage>().Where(x => x.UserId == MemoryDataProvider.CurrentUser).FirstOrDefault();
|
||||
return user.RoleId;
|
||||
}
|
||||
}
|
||||
return (int)ERole.Operater;
|
||||
}
|
||||
|
||||
public bool CheckPermission(ERole permission)
|
||||
{
|
||||
// 获取当前登录用户的权限级别
|
||||
int userPermissionLevel = GetCurrentRoleId();
|
||||
|
||||
// 根据权限级别判断是否具有指定权限
|
||||
if (userPermissionLevel == (int)ERole.Admin) // 管理员
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (userPermissionLevel == (int)ERole.Mantainer && (permission == ERole.Operater || permission == ERole.Mantainer))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (userPermissionLevel == (int)ERole.Operater && permission == ERole.Operater)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public List<TMenuInfo> GetAllMenuInfo()
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TMenuInfo>().ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public string GetAuthority(string role)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
return Context.Set<TRoleInfo>().Where(x => x.RoleName == role).FirstOrDefault().AccessNode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool ValidPassword(string name, string pwd) //有效密码
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
if (null == Context.Set<TUserManage>().Where(item => item.UserId == name && item.Password == pwd).FirstOrDefault())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
public int ModifyPassword(string newPassword)
|
||||
{
|
||||
using (var Context = new PreheatEntities())
|
||||
{
|
||||
var userInfo = Context.Set<TUserManage>().Where(item => item.UserId == MemoryDataProvider.CurrentUser).FirstOrDefault();
|
||||
if (null == userInfo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
userInfo.Password = newPassword;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle" version="1.8.5" targetFramework="net472" />
|
||||
<package id="Google.Protobuf" version="3.14.0" targetFramework="net472" />
|
||||
<package id="K4os.Compression.LZ4" version="1.2.6" targetFramework="net472" />
|
||||
<package id="K4os.Compression.LZ4.Streams" version="1.2.6" targetFramework="net472" />
|
||||
<package id="K4os.Hash.xxHash" version="1.0.6" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="7.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.31" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Json" version="7.0.2" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,30 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class BatteryStatusConvertor : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
value = System.Convert.ToInt32(value);
|
||||
EBatteryStatus status = (EBatteryStatus)value;
|
||||
return status.FetchDescription();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class BindingColor : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
if (value.ToString() == "报警")
|
||||
{
|
||||
return new SolidColorBrush(Colors.Red);
|
||||
}
|
||||
else if (value.ToString() == "警告")
|
||||
{
|
||||
return new SolidColorBrush(Colors.Gold);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new SolidColorBrush(Colors.Green);
|
||||
}
|
||||
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class BoolToColorConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool boolValue)
|
||||
{
|
||||
return boolValue ? Brushes.Green : Brushes.Red;
|
||||
}
|
||||
return Brushes.Gray;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class BooleanToVisibilityConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is bool boolValue)
|
||||
{
|
||||
return boolValue ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
return Visibility.Collapsed;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class DeviceTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var list = EnumHelper.GetEnumList<EDeviceType>();
|
||||
return list.FirstOrDefault(s => s.EnumString == value.ToString())?.EnumDesc;
|
||||
}
|
||||
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (value is true) ? parameter : Binding.DoNothing;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class OperTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
OperTypeEnum paramEnum = (OperTypeEnum)int.Parse(value.ToString());
|
||||
return paramEnum.GetDescription();
|
||||
}
|
||||
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (value is true) ? parameter : Binding.DoNothing;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class EnumDescriptionConverter : IValueConverter
|
||||
{
|
||||
private string GetEnumDescription(Enum enumObj)
|
||||
{
|
||||
FieldInfo fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
|
||||
var descriptionAttr = fieldInfo
|
||||
.GetCustomAttributes(false)
|
||||
.OfType<DescriptionAttribute>()
|
||||
.Cast<DescriptionAttribute>()
|
||||
.SingleOrDefault();
|
||||
if (descriptionAttr == null)
|
||||
{
|
||||
return enumObj.ToString();
|
||||
}
|
||||
else
|
||||
{
|
||||
return descriptionAttr.Description;
|
||||
}
|
||||
}
|
||||
|
||||
object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
Enum myEnum = (Enum)value;
|
||||
string description = GetEnumDescription(myEnum);
|
||||
return description;
|
||||
}
|
||||
|
||||
object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class EnumDescriptionTypeConverter : EnumConverter
|
||||
{
|
||||
public EnumDescriptionTypeConverter(Type type) : base(type)
|
||||
{
|
||||
}
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
if (null != value)
|
||||
{
|
||||
FieldInfo fi = value.GetType().GetField(value.ToString());
|
||||
if (null != fi)
|
||||
{
|
||||
var attributes =
|
||||
(DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
return ((attributes.Length > 0) && (!string.IsNullOrEmpty(attributes[0].Description)))
|
||||
? attributes[0].Description
|
||||
: value.ToString();
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class IntToDeviceTypeConvertor : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
value = System.Convert.ToInt32(value);
|
||||
EDeviceType status = (EDeviceType)value;
|
||||
return status.FetchDescription();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class IntToStringConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
return string.Empty;
|
||||
string str = value.ToString();
|
||||
switch (str)
|
||||
{
|
||||
case "0":
|
||||
str = string.Empty;
|
||||
break;
|
||||
case "1":
|
||||
str = "待上传";
|
||||
break;
|
||||
case "2":
|
||||
str = "上传完毕";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态转换器
|
||||
/// </summary>
|
||||
public class ObjectConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
string[] parray = parameter.ToString().ToLower().Split(':'); //将参数字符分段 parray[0]为比较值,parray[1]为true返回值,parray[2]为false返回值
|
||||
if (value == null)
|
||||
return parray[2]; //如果数据源为空,默认返回false返回值
|
||||
if (parray[0].Contains("|")) //判断有多个比较值的情况
|
||||
return parray[0].Split('|').Contains(value.ToString().ToLower()) ? parray[1] : parray[2]; //多值比较
|
||||
return parray[0].Equals(value.ToString().ToLower()) ? parray[1] : parray[2]; //单值比较
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var returnValue = "otherValue";
|
||||
string[] parray = parameter.ToString().ToLower().Split(':');
|
||||
if (value == null)
|
||||
return returnValue;
|
||||
var valueStr = value.ToString().ToLower();
|
||||
if (valueStr != parray[1])
|
||||
return returnValue;
|
||||
else
|
||||
return parray[0].Contains('|') ? parray[0].Split('|')[0] : parray[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class ProductOutputTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value?.Equals(parameter);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return (value is true) ? parameter : Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class RadioButtonToIndexConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
// 将 RadioButton 的值与 ViewModel 中的值进行比较并返回是否匹配
|
||||
if (value == null || parameter == null)
|
||||
return false;
|
||||
|
||||
return value.ToString() == parameter.ToString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
// 这个转换通常不需要,可以简单地返回 DependencyProperty.UnsetValue
|
||||
if ((bool)value)
|
||||
{
|
||||
return parameter;
|
||||
}
|
||||
return DependencyProperty.UnsetValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class ScaleConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
|
||||
if (parameter == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
double c = System.Convert.ToDouble(parameter);
|
||||
double index = System.Convert.ToDouble(value);
|
||||
return index / c;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (parameter == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
double c = System.Convert.ToDouble(parameter);
|
||||
double index = System.Convert.ToDouble(value);
|
||||
return System.Convert.ToInt32(index * c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Preheat.Common.Converter
|
||||
{
|
||||
public class SendFlagConvertor : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
value = System.Convert.ToInt32(value);
|
||||
EMesUpLoadStatus status = (EMesUpLoadStatus)value;
|
||||
return status.FetchDescription();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace Cowain.Preheat.Common.Core
|
||||
{
|
||||
public class BasicFramework
|
||||
{
|
||||
private static BasicFramework instance;
|
||||
private static readonly object locker = new object();
|
||||
public Dictionary<string, string> RegularDic = new Dictionary<string, string>();
|
||||
public static BasicFramework Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new BasicFramework();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
public static T DeepCopy<T>(T obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return obj;
|
||||
}
|
||||
if (obj is string || obj.GetType().IsValueType)
|
||||
return obj;
|
||||
|
||||
object retval = Activator.CreateInstance(obj.GetType());
|
||||
FieldInfo[] fields = obj.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance);
|
||||
foreach (var field in fields)
|
||||
{
|
||||
try
|
||||
{
|
||||
field.SetValue(retval, DeepCopy(field.GetValue(obj)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.GetCurrentClassError((typeof(BasicFramework) + "DeepCopy异常:" + ex.Message));
|
||||
}
|
||||
}
|
||||
|
||||
return (T)retval;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
using Cowain.Preheat.Common.CsvMap;
|
||||
using Cowain.Preheat.Model;
|
||||
using CsvHelper;
|
||||
using CsvHelper.Configuration;
|
||||
using Microsoft.Win32;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
|
||||
namespace Cowain.Preheat.Common.Core
|
||||
{
|
||||
public class CSVHelper
|
||||
{
|
||||
public static void WriteDataTableToCsv<T>(IEnumerable<T> list)
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
using (var writer = new StreamWriter(filePath))
|
||||
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
|
||||
{
|
||||
csv.WriteRecords(list);
|
||||
}
|
||||
}
|
||||
|
||||
//列头是中文,所有字段都写入
|
||||
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, List<string> nameCols)
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
|
||||
{
|
||||
// 设置列头编码为UTF8以支持中文
|
||||
Encoding = System.Text.Encoding.UTF8,
|
||||
// 设置不写入列头
|
||||
HasHeaderRecord = false
|
||||
};
|
||||
|
||||
using (var writer = new StreamWriter(filePath, false, System.Text.Encoding.UTF8))
|
||||
using (var csv = new CsvWriter(writer, config))
|
||||
{
|
||||
// 写入列头,使用中文列名
|
||||
foreach(var col in nameCols)
|
||||
{
|
||||
csv.WriteField(col);
|
||||
}
|
||||
csv.NextRecord();
|
||||
|
||||
// 写入数据行
|
||||
csv.WriteRecords(list);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 将List的特定列写入CSV文件的方法
|
||||
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, IEnumerable<string> columnsToSave)
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
|
||||
{
|
||||
// 设置列头编码为UTF8以支持中文
|
||||
Encoding = System.Text.Encoding.UTF8,
|
||||
// 设置不写入列头
|
||||
HasHeaderRecord = false
|
||||
};
|
||||
|
||||
using (var writer = new StreamWriter(filePath, false, System.Text.Encoding.UTF8))
|
||||
using (var csv = new CsvWriter(writer, config))
|
||||
{
|
||||
// 写入列头
|
||||
foreach (var columnName in columnsToSave)
|
||||
{
|
||||
csv.WriteField(columnName);
|
||||
}
|
||||
csv.NextRecord();
|
||||
|
||||
// 写入特定列数据
|
||||
foreach (var person in list)
|
||||
{
|
||||
foreach (var columnName in columnsToSave)
|
||||
{
|
||||
var property = typeof(T).GetProperty(columnName);
|
||||
if (property != null)
|
||||
{
|
||||
csv.WriteField(property.GetValue(person));
|
||||
}
|
||||
}
|
||||
csv.NextRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static string GetFilePath()
|
||||
{
|
||||
string filePath = "";
|
||||
//创建一个保存文件式的对话框
|
||||
SaveFileDialog saveFileDialog = new SaveFileDialog();
|
||||
//设置保存的文件的类型,注意过滤器的语法
|
||||
saveFileDialog.Filter = "CSV|*.csv";
|
||||
if (saveFileDialog.ShowDialog() == true)
|
||||
{
|
||||
filePath = saveFileDialog.FileName;
|
||||
}
|
||||
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public static void WriteMap<T, TMap>(IEnumerable<T> list ) where TMap : ClassMap //where TMap : ClassMap<T> // 约束:必须是 ClassMap<T> 或其子类
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
|
||||
{
|
||||
// 设置列头编码为UTF8以支持中文
|
||||
//Delimiter = ",",
|
||||
HasHeaderRecord = true,
|
||||
Encoding = System.Text.Encoding.UTF8
|
||||
};
|
||||
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
config.HasHeaderRecord = false; // 获取字段描述作为列头
|
||||
}
|
||||
|
||||
using (var writer = new StreamWriter(filePath, true, System.Text.Encoding.UTF8))
|
||||
using (var csv = new CsvWriter(writer, config))
|
||||
{
|
||||
// 注册自定义映射
|
||||
//csv.Context.RegisterClassMap<BatteryInfoMap>();
|
||||
csv.Context.RegisterClassMap<TMap>();
|
||||
// 写入记录
|
||||
csv.WriteRecords(list);
|
||||
}
|
||||
}
|
||||
|
||||
// 将List的特定列写入CSV文件的方法
|
||||
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, IEnumerable<string> columnsToSave, IEnumerable<string> columnsToShow)
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
|
||||
{
|
||||
// 设置列头编码为UTF8以支持中文
|
||||
Encoding = System.Text.Encoding.UTF8,
|
||||
HasHeaderRecord = false
|
||||
};
|
||||
|
||||
using (var writer = new StreamWriter(filePath, false, System.Text.Encoding.UTF8))
|
||||
using (var csv = new CsvWriter(writer, config))
|
||||
{
|
||||
// 写入列头
|
||||
foreach (var columnName in columnsToShow)
|
||||
{
|
||||
csv.WriteField(columnName);
|
||||
}
|
||||
csv.NextRecord();
|
||||
|
||||
// 写入特定列数据
|
||||
foreach (var person in list)
|
||||
{
|
||||
foreach (var columnName in columnsToSave)
|
||||
{
|
||||
var property = typeof(T).GetProperty(columnName);
|
||||
if (property != null)
|
||||
{
|
||||
csv.WriteField(property.GetValue(person));
|
||||
}
|
||||
}
|
||||
csv.NextRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将List的特定列写入CSV文件的方法
|
||||
public static void WriteDataTableToCsv<T>(IEnumerable<T> list, IEnumerable<string> columnsToSave, IEnumerable<string> columnsToShow, string filePath)
|
||||
{
|
||||
bool isFileExists = false;
|
||||
var config = new CsvConfiguration(CultureInfo.InvariantCulture)
|
||||
{
|
||||
// 设置列头编码为UTF8以支持中文
|
||||
Encoding = System.Text.Encoding.UTF8,
|
||||
HasHeaderRecord = false
|
||||
};
|
||||
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
// 获取字段描述作为列头
|
||||
isFileExists = true;
|
||||
}
|
||||
|
||||
using (var writer = new StreamWriter(filePath, true, System.Text.Encoding.UTF8))
|
||||
using (var csv = new CsvWriter(writer, config))
|
||||
{
|
||||
// 写入列头
|
||||
if (!isFileExists)
|
||||
{
|
||||
foreach (var columnHeader in columnsToShow)
|
||||
{
|
||||
csv.WriteField(columnHeader);
|
||||
}
|
||||
csv.NextRecord();
|
||||
}
|
||||
|
||||
// 写入特定列数据
|
||||
foreach (var person in list)
|
||||
{
|
||||
foreach (var columnName in columnsToSave)
|
||||
{
|
||||
var property = typeof(T).GetProperty(columnName);
|
||||
if (property != null)
|
||||
{
|
||||
csv.WriteField(property.GetValue(person));
|
||||
}
|
||||
}
|
||||
csv.NextRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将DataTable写入CSV文件的方法
|
||||
public static void WriteDataTableToCsv(DataTable dataTable)
|
||||
{
|
||||
string filePath = GetFilePath();
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var writer = new StreamWriter(filePath))
|
||||
using (var csv = new CsvWriter(writer, CultureInfo.InvariantCulture))
|
||||
{
|
||||
// 写入表头
|
||||
foreach (DataColumn column in dataTable.Columns)
|
||||
{
|
||||
csv.WriteField(column.ColumnName);
|
||||
}
|
||||
csv.NextRecord();
|
||||
|
||||
// 写入数据行
|
||||
foreach (DataRow row in dataTable.Rows)
|
||||
{
|
||||
for (var i = 0; i < dataTable.Columns.Count; i++)
|
||||
{
|
||||
csv.WriteField(row[i]);
|
||||
}
|
||||
csv.NextRecord();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Cowain.Preheat.Common.Models;
|
||||
using Cowain.Preheat.Model;
|
||||
using Cowain.Preheat.Model.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Cowain.Preheat.Common.Core
|
||||
{
|
||||
public class CommonCoreHelper
|
||||
{
|
||||
public static BlockingCollection<BtnInfoModel> BlockBtnInfo = new BlockingCollection<BtnInfoModel>();
|
||||
public static BlockingCollection<TDeviceConfig> BlockStatusColorItems = new BlockingCollection<TDeviceConfig>(200);
|
||||
public static AutoResetEvent AutoEventToolTip = new AutoResetEvent(true);
|
||||
private CommonCoreHelper()
|
||||
{
|
||||
|
||||
}
|
||||
public static List<string> StringToListConverter(string input)
|
||||
{
|
||||
string[] separators = { " ", ":", ",", ";" };
|
||||
if (string.IsNullOrWhiteSpace(input))
|
||||
{
|
||||
return new List<string>();
|
||||
}
|
||||
string[] items = input.Split(separators, StringSplitOptions.RemoveEmptyEntries);
|
||||
List<string> itemList = new List<string>(items);
|
||||
return itemList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static EBatteryStatus GetBatteryStatus(string stationName)
|
||||
{
|
||||
if (stationName.Contains("上料"))
|
||||
{
|
||||
return EBatteryStatus.InBound;
|
||||
}
|
||||
else if (stationName.Contains("下料"))
|
||||
{
|
||||
return EBatteryStatus.OutBound;
|
||||
}
|
||||
else
|
||||
{
|
||||
return EBatteryStatus.Preheat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Cowain.Preheat.Common.Core
|
||||
{
|
||||
public class INIHelper
|
||||
{
|
||||
[DllImport("kernel32")]
|
||||
private static extern long WritePrivateProfileString(string section, string key, string val, string filepath);
|
||||
[DllImport("kernel32")]
|
||||
private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retval, int size, string filePath);
|
||||
|
||||
//ini文件名称
|
||||
private static string inifilename = "Config.ini";
|
||||
//获取ini文件路径
|
||||
public static string inifilepath = Application.StartupPath + "\\" + inifilename;
|
||||
|
||||
public static string ReadValue(string key)
|
||||
{
|
||||
StringBuilder s = new StringBuilder(1024);
|
||||
GetPrivateProfileString("Config", key, "", s, 1024, inifilepath);
|
||||
return s.ToString();
|
||||
}
|
||||
public static bool ReadBool(string section, string key, bool value = false)
|
||||
{
|
||||
bool reVal = false;
|
||||
StringBuilder s = new StringBuilder(1024);
|
||||
GetPrivateProfileString(section, key, "", s, 1024, inifilepath);
|
||||
bool b = bool.TryParse(s.ToString(), out reVal);
|
||||
if (b)
|
||||
{
|
||||
return reVal;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public static string ReadString(string section, string key, string value = "")
|
||||
{
|
||||
StringBuilder s = new StringBuilder(1024);
|
||||
GetPrivateProfileString(section, key, "", s, 1024, inifilepath);
|
||||
if (0 == s.ToString().Length)
|
||||
{
|
||||
return value;
|
||||
}
|
||||
return s.ToString();
|
||||
}
|
||||
|
||||
public static int ReadInt(string section, string key, int nDefault = 0)
|
||||
{
|
||||
// 每次从ini中读取多少字节
|
||||
System.Text.StringBuilder temp = new StringBuilder(1024);
|
||||
// section=配置节,key=键名,temp=上面,path=路径
|
||||
GetPrivateProfileString(section, key, "", temp, 1024, inifilepath);
|
||||
string t = temp.ToString();
|
||||
int v = 0;
|
||||
if (int.TryParse(t, out v))
|
||||
{
|
||||
return v;
|
||||
}
|
||||
return nDefault;
|
||||
}
|
||||
|
||||
public static float ReadFloat(string section, string key, float fDefault = 0)
|
||||
{
|
||||
// 每次从ini中读取多少字节
|
||||
System.Text.StringBuilder temp = new System.Text.StringBuilder(255);
|
||||
// section=配置节,key=键名,temp=上面,path=路径
|
||||
GetPrivateProfileString(section, key, "", temp, 255, inifilepath);
|
||||
string t = temp.ToString();
|
||||
float v = 0;
|
||||
if (float.TryParse(t, out v))
|
||||
{
|
||||
return v;
|
||||
}
|
||||
return fDefault;
|
||||
}
|
||||
|
||||
/// <param name="value"></param>
|
||||
public static void Write(string section, string key, string value)
|
||||
{
|
||||
// section=配置节,key=键名,value=键值,path=路径
|
||||
WritePrivateProfileString(section, key, value, inifilepath); //add by lsm 这两个API是线程安全的,底层给你做了同步...
|
||||
}
|
||||
|
||||
public static void WriteValue(string key, string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
WritePrivateProfileString("Config", key, value, inifilepath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using NLog;
|
||||
using NLog.Config;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
namespace Cowain.Preheat.Common.Core
|
||||
{
|
||||
public class LogHelper
|
||||
{
|
||||
private static LogHelper instance;
|
||||
|
||||
public static LogHelper Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new LogHelper();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
||||
private Logger logger; //初始化日志类
|
||||
|
||||
/// <summary>
|
||||
/// 事件定义
|
||||
/// </summary>
|
||||
public Action<string> OnComplated;
|
||||
public Action<string, bool, E_LogType> OnShowInvoke { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 时间触发
|
||||
/// </summary>
|
||||
/// <param name="msg">自定义消息</param>
|
||||
/// <param name="isUI">是否触发事件通知</param>
|
||||
private void Notice(string msg, bool isShow, E_LogType logType)
|
||||
{
|
||||
if (OnShowInvoke != null)
|
||||
{
|
||||
OnShowInvoke?.Invoke(msg, isShow, logType);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 静态构造函数
|
||||
/// </summary>
|
||||
private LogHelper()
|
||||
{
|
||||
logger = NLog.LogManager.GetCurrentClassLogger(); //初始化日志类
|
||||
//string rootPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
|
||||
|
||||
//string fileName = string.Format(@"{0}NLog.config", rootPath);
|
||||
|
||||
////初始化配置日志
|
||||
//NLog.LogManager.Configuration = new XmlLoggingConfiguration(fileName);
|
||||
}
|
||||
|
||||
public void Trace(string msg)
|
||||
{
|
||||
To(msg, E_LogType.Trace, false);
|
||||
}
|
||||
|
||||
public void Debug(string msg, bool isShow = false)
|
||||
{
|
||||
To(msg, E_LogType.Debug, isShow);
|
||||
}
|
||||
|
||||
public void Info(string msg, bool isShow = false)
|
||||
{
|
||||
To(msg, E_LogType.Info, isShow);
|
||||
}
|
||||
|
||||
public void Warn(string msg, bool isShow = false)
|
||||
{
|
||||
To(msg, E_LogType.Warn, isShow);
|
||||
}
|
||||
|
||||
public void Error(string msg, bool isShow = false)
|
||||
{
|
||||
To(msg, E_LogType.Error, isShow);
|
||||
}
|
||||
|
||||
public void Fatal(string msg, bool isShow = false)
|
||||
{
|
||||
To(msg, E_LogType.Fatal, isShow);
|
||||
}
|
||||
#region 当前类也打印出来
|
||||
public void GetCurrentClassDebug(string msg, bool isShow = false,
|
||||
[CallerMemberName] string memberName = "",
|
||||
[CallerFilePath] string sourceFilePath = "",
|
||||
[CallerLineNumber] int sourceLineNumber = 0)
|
||||
{
|
||||
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
|
||||
To(msg, E_LogType.Debug, isShow);
|
||||
}
|
||||
|
||||
public void GetCurrentClassInfo(string msg, bool isShow = false,
|
||||
[CallerMemberName] string memberName = "",
|
||||
[CallerFilePath] string sourceFilePath = "",
|
||||
[CallerLineNumber] int sourceLineNumber = 0)
|
||||
{
|
||||
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
|
||||
To(msg, E_LogType.Info, isShow);
|
||||
}
|
||||
|
||||
public void GetCurrentClassWarn(string msg, bool isShow = false,
|
||||
[CallerMemberName] string memberName = "",
|
||||
[CallerFilePath] string sourceFilePath = "",
|
||||
[CallerLineNumber] int sourceLineNumber = 0)
|
||||
{
|
||||
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
|
||||
To(msg, E_LogType.Warn, isShow);
|
||||
}
|
||||
|
||||
public void GetCurrentClassError(string msg, bool isShow = false,
|
||||
[CallerMemberName] string memberName = "",
|
||||
[CallerFilePath] string sourceFilePath = "",
|
||||
[CallerLineNumber] int sourceLineNumber = 0)
|
||||
{
|
||||
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
|
||||
To(msg, E_LogType.Error, isShow);
|
||||
}
|
||||
|
||||
public void GetCurrentClassFatal(string msg,bool isShow = false,
|
||||
[CallerMemberName] string memberName = "",
|
||||
[CallerFilePath] string sourceFilePath = "",
|
||||
[CallerLineNumber] int sourceLineNumber = 0)
|
||||
{
|
||||
msg = $"File:{sourceFilePath},Fun:{memberName},LineNum:{sourceLineNumber},{msg}";
|
||||
To(msg, E_LogType.Fatal, isShow);
|
||||
}
|
||||
#endregion
|
||||
private void To(string msg, E_LogType logType, bool isShow = false)
|
||||
{
|
||||
switch (logType)
|
||||
{
|
||||
case E_LogType.Debug:
|
||||
logger.Debug(msg);
|
||||
break;
|
||||
case E_LogType.Info:
|
||||
logger.Info(msg);
|
||||
break;
|
||||
case E_LogType.Warn:
|
||||
logger.Warn(msg);
|
||||
break;
|
||||
case E_LogType.Error:
|
||||
logger.Error(msg);
|
||||
break;
|
||||
case E_LogType.Fatal:
|
||||
logger.Fatal(msg);
|
||||
break;
|
||||
default:
|
||||
logger.Trace(msg);
|
||||
break;
|
||||
}
|
||||
Notice(msg, isShow, logType);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.Core
|
||||
{
|
||||
public class MessageEventWaitHandle<T> : EventWaitHandle
|
||||
{
|
||||
private T message;
|
||||
private readonly object lockEvent = new object();//定义锁
|
||||
public MessageEventWaitHandle(bool initialState, EventResetMode mode)
|
||||
: base(initialState, mode)
|
||||
{
|
||||
}
|
||||
|
||||
public bool Set(T message)
|
||||
{
|
||||
//lock (lockEvent)
|
||||
{
|
||||
this.message = message;
|
||||
return base.Set();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public T GetMessage(int timeOut)
|
||||
{
|
||||
//lock (lockEvent)//因为这里锁住了,set给不了信号
|
||||
{
|
||||
if (!base.WaitOne(timeOut)) //为假超时
|
||||
{
|
||||
base.Reset();
|
||||
return default(T);
|
||||
}
|
||||
else
|
||||
{
|
||||
base.Reset();
|
||||
return this.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.Core
|
||||
{
|
||||
public class SettingProvider
|
||||
{
|
||||
const string MAIN = "Main";
|
||||
private static SettingProvider instance;
|
||||
public string PWD;
|
||||
|
||||
public string ProductionLineName;
|
||||
private static readonly object locker = new object();
|
||||
|
||||
public bool? _autoUpdate;
|
||||
public bool AutoUpdate
|
||||
{
|
||||
get
|
||||
{
|
||||
if (null == _autoUpdate)
|
||||
{
|
||||
_autoUpdate = INIHelper.ReadBool(MAIN, "AutoUpdate", false);
|
||||
}
|
||||
|
||||
return _autoUpdate ?? false;
|
||||
}
|
||||
set
|
||||
{
|
||||
_autoUpdate = value;
|
||||
INIHelper.Write(MAIN, "AutoUpdate", _autoUpdate.Value ? "1" : "0");
|
||||
}
|
||||
}
|
||||
|
||||
public string _autoUpdateUrl;
|
||||
public string AutoUpdateUrl
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_autoUpdateUrl))
|
||||
{
|
||||
_autoUpdateUrl = INIHelper.ReadString(MAIN, "AutoUpdateUrl", "http://127.0.0.1:6688/update/update.xml");
|
||||
}
|
||||
|
||||
return _autoUpdateUrl;
|
||||
}
|
||||
set
|
||||
{
|
||||
_autoUpdateUrl = value;
|
||||
INIHelper.Write(MAIN, "AutoUpdateUrl", _autoUpdateUrl);
|
||||
}
|
||||
}
|
||||
public static SettingProvider Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (locker)
|
||||
{
|
||||
if (instance == null)
|
||||
{
|
||||
instance = new SettingProvider();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
SettingProvider()
|
||||
{
|
||||
PWD = INIHelper.ReadString(MAIN, "PassWord", "cowain2024");
|
||||
ProductionLineName = INIHelper.ReadString(MAIN, "ProductionLineName", ""); //有乱码
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,309 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{4E1A0D39-34EF-498D-A3A7-D1489C6A6FE4}</ProjectGuid>
|
||||
<OutputType>library</OutputType>
|
||||
<RootNamespace>Cowain.Injecting.Common</RootNamespace>
|
||||
<AssemblyName>Cowain.Preheat.Common</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Deterministic>true</Deterministic>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\BouncyCastle.Cryptography.2.2.1\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cowain.Preheat.Model, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Cowain.Preheat.Model\bin\Debug\Cowain.Preheat.Model.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="CsvHelper, Version=33.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\CsvHelper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Dapper">
|
||||
<HintPath>..\Libs\Dapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework.SqlServer">
|
||||
<HintPath>..\Libs\EntityFramework.SqlServer.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Enums.NET, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7ea1c1650d506225, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Enums.NET.4.0.1\lib\net45\Enums.NET.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib, Version=1.3.3.11, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SharpZipLib.1.3.3\lib\net45\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MathNet.Numerics, Version=4.15.0.0, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MathNet.Numerics.Signed.4.15.0\lib\net461\MathNet.Numerics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.HashCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.HashCode.1.1.1\lib\net461\Microsoft.Bcl.HashCode.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=2.3.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.2.3.2\lib\net462\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data.EntityFramework, Version=8.0.28.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\MySql.Data.EntityFramework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NLog">
|
||||
<HintPath>..\Libs\NLog.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.Core, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OOXML, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.OOXML.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OpenXml4Net, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.OpenXml4Net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="NPOI.OpenXmlFormats, Version=2.6.2.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NPOI.2.6.2\lib\net472\NPOI.OpenXmlFormats.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Core">
|
||||
<HintPath>..\Libs\Opc.Ua.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Oracle.ManagedDataAccess">
|
||||
<HintPath>..\Libs\Oracle.ManagedDataAccess.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Prism.Core.8.1.97\lib\net47\Prism.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Unity.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Prism.Unity.8.1.97\lib\net47\Prism.Unity.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Wpf, Version=8.1.97.5141, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Prism.Wpf.8.1.97\lib\net47\Prism.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SixLabors.Fonts.1.0.0\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SixLabors.ImageSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\SixLabors.ImageSharp.2.1.4\lib\net472\SixLabors.ImageSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Security" />
|
||||
<Reference Include="System.Security.AccessControl, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.AccessControl.6.0.0\lib\net461\System.Security.AccessControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Xml, Version=6.0.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Xml.6.0.1\lib\net461\System.Security.Cryptography.Xml.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Principal.Windows, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Principal.Windows.5.0.0\lib\net461\System.Security.Principal.Windows.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encoding.CodePages, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encoding.CodePages.5.0.0\lib\net461\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Windows.Forms.DataVisualization" />
|
||||
<Reference Include="System.Windows.Forms.DataVisualization.Design" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Abstractions, Version=5.11.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Unity.Abstractions.5.11.7\lib\net47\Unity.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Container, Version=5.11.11.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Unity.Container.5.11.11\lib\net47\Unity.Container.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="Wisdy">
|
||||
<HintPath>..\Libs\Wisdy.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Converter\BatteryStatusConvertor.cs" />
|
||||
<Compile Include="Converter\BindingColor.cs" />
|
||||
<Compile Include="Converter\BooleanToVisibilityConverter.cs" />
|
||||
<Compile Include="Converter\BoolToColorConverter.cs" />
|
||||
<Compile Include="Converter\DeviceTypeConverter.cs" />
|
||||
<Compile Include="Converter\EnumDescriptionTypeConverter.cs" />
|
||||
<Compile Include="Converter\IntToDeviceTypeConvertor.cs" />
|
||||
<Compile Include="Converter\IntToStringConverter.cs" />
|
||||
<Compile Include="Converter\ObjectConverter.cs" />
|
||||
<Compile Include="Converter\ProductOutputTypeConverter.cs" />
|
||||
<Compile Include="Converter\RadioButtonToIndexConverter.cs" />
|
||||
<Compile Include="Converter\ScaleConverter.cs" />
|
||||
<Compile Include="Converter\SendFlagConvertor.cs" />
|
||||
<Compile Include="Core\BasicFramework.cs" />
|
||||
<Compile Include="Core\CommonCoreHelper.cs" />
|
||||
<Compile Include="Core\CSVHelper.cs" />
|
||||
<Compile Include="Core\LogHelper.cs" />
|
||||
<Compile Include="CsvMap\BatteryMapConverter.cs" />
|
||||
<Compile Include="CsvMap\FailBatteryMap.cs" />
|
||||
<Compile Include="CsvMap\MesDataMap.cs" />
|
||||
<Compile Include="Core\INIHelper.cs" />
|
||||
<Compile Include="Core\MessageEventWaitHandle.cs" />
|
||||
<Compile Include="Core\SettingProvider.cs" />
|
||||
<Compile Include="Enums\EnumHelper.cs" />
|
||||
<Compile Include="Enums\SysEnum.cs" />
|
||||
<Compile Include="Global.cs" />
|
||||
<Compile Include="Interface\ICommonFun.cs" />
|
||||
<Compile Include="Interface\IDeviceDebug.cs" />
|
||||
<Compile Include="Interface\IRecvMesHttp.cs" />
|
||||
<Compile Include="Interface\IServerManager.cs" />
|
||||
<Compile Include="Interface\ITrigService.cs" />
|
||||
<Compile Include="MiniDump.cs" />
|
||||
<Compile Include="Models\CommonModel.cs" />
|
||||
<Compile Include="Models\MESModel.cs" />
|
||||
<Compile Include="Models\VarValue.cs" />
|
||||
<Compile Include="PasswordHelper.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="ViewModelBase.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Resource Include="Fonts\iconfont.ttf" />
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Resource Include="Images\exit.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="Styles\BaseResources.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\ButtonStyles.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\DataGrid.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\TextBoxStyle.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Styles\ToggleButtonStyle.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\CowainLogo.jpg" />
|
||||
<Resource Include="Images\CowainLogo.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\Auto.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\Manual.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\shuru.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\zhuye.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\gongyezujian-kaiguan.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\help-fill.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\CN-EN.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\skin.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\gongju1.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\Cowain.jpg" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -0,0 +1,62 @@
|
||||
using Cowain.Preheat.Common.Converter;
|
||||
using Cowain.Preheat.Model;
|
||||
using CsvHelper;
|
||||
using CsvHelper.Configuration;
|
||||
using CsvHelper.TypeConversion;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.CsvMap
|
||||
{
|
||||
// 4. 创建CsvHelper自定义转换器
|
||||
public class BatteryMapConverter : DefaultTypeConverter
|
||||
{
|
||||
private static readonly BatteryStatusConvertor _converter = new BatteryStatusConvertor();
|
||||
|
||||
public override string ConvertToString(object value, IWriterRow row, MemberMapData memberMapData)
|
||||
{
|
||||
// 使用IValueConverter转换逻辑
|
||||
return _converter.Convert(value, typeof(string), null, CultureInfo.InvariantCulture) as string;
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 创建自定义ClassMap
|
||||
//public sealed class BatteryInfoMap : ClassMap<TBatteryInfo>
|
||||
public sealed class BatteryInfoMap : ClassMap<TBatteryInfo>
|
||||
{
|
||||
public BatteryInfoMap()
|
||||
{
|
||||
Map(m => m.Id).Name("电池虚拟码");
|
||||
Map(m => m.ScanTime)
|
||||
.Name("扫码时间")
|
||||
.TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss");
|
||||
Map(m => m.BatteryCode).Name("条码");
|
||||
Map(m => m.ScannerPos).Name("扫码位置");
|
||||
// 应用枚举描述转换器
|
||||
Map(m => m.BatteryStatus)
|
||||
.Name("状态")
|
||||
.TypeConverter<BatteryMapConverter>();
|
||||
|
||||
|
||||
Map(m => m.LoadingTime)
|
||||
.Name("上料时间")
|
||||
.TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss");
|
||||
Map(m => m.PositionY).Name("列号");
|
||||
Map(m => m.Layer).Name("层号");
|
||||
Map(m => m.UnLoadingTime)
|
||||
.Name("下料时间")
|
||||
.TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
Map(m => m.LodingTemperature).Name("上料温度");
|
||||
Map(m => m.PreheatTemperature).Name("预热温度");
|
||||
Map(m => m.UnLoadingTemperature).Name("下料温度");
|
||||
Map(m => m.PreheatTime).Name("预热时长");
|
||||
//public Nullable<byte> StoveNumber { get; set; }
|
||||
//public string Desc { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using CsvHelper.Configuration;
|
||||
|
||||
namespace Cowain.Preheat.Common.CsvMap
|
||||
{
|
||||
public sealed class FailBatteryMap : ClassMap<TBatteryNG>
|
||||
{
|
||||
public FailBatteryMap()
|
||||
{
|
||||
Map(m => m.Id).Name("序号");
|
||||
Map(m => m.Reason).Name("原因");
|
||||
Map(m => m.BatteryCode).Name("电芯条码");
|
||||
Map(m => m.CreateTime)
|
||||
.Name("创建时间")
|
||||
.TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss");
|
||||
Map(m => m.Desc).Name("描述");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Cowain.Preheat.Common.Converter;
|
||||
using Cowain.Preheat.Model.Entity;
|
||||
using CsvHelper;
|
||||
using CsvHelper.Configuration;
|
||||
using CsvHelper.TypeConversion;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.CsvMap
|
||||
{
|
||||
public class MesDataMapConverter : DefaultTypeConverter
|
||||
{
|
||||
private static readonly SendFlagConvertor _converter = new SendFlagConvertor();
|
||||
|
||||
public override string ConvertToString(object value, IWriterRow row, MemberMapData memberMapData)
|
||||
{
|
||||
// 使用IValueConverter转换逻辑
|
||||
return _converter.Convert(value, typeof(string), null, CultureInfo.InvariantCulture) as string;
|
||||
}
|
||||
}
|
||||
public sealed class MesDataMap : ClassMap<MesDataEntity>
|
||||
{
|
||||
public MesDataMap()
|
||||
{
|
||||
Map(m => m.CreateTime).Name("创建时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); ;
|
||||
Map(m => m.SendTime).Name("发送时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); ;
|
||||
Map(m => m.RecvTime).Name("接收时间").TypeConverterOption.Format("yyyy-MM-dd HH:mm:ss"); ;
|
||||
Map(m => m.Content).Name("发送信息");
|
||||
Map(m => m.RecvContent).Name("接收信息");
|
||||
Map(m => m.BatteryCode).Name("电芯条码");
|
||||
Map(m => m.SendFlag)
|
||||
.Name("发送状态")
|
||||
.TypeConverter<MesDataMapConverter>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,201 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
|
||||
namespace Cowain.Preheat.Common.Enums
|
||||
{
|
||||
public static class EnumHelper
|
||||
{
|
||||
public static string FetchDescription(this Enum value)
|
||||
{
|
||||
try
|
||||
{
|
||||
FieldInfo fi = value.GetType().GetField(value.ToString());
|
||||
if (null == fi)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
if (attributes != null && attributes.Length > 0)
|
||||
return attributes[0].Description;
|
||||
else
|
||||
return value.ToString();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
public static string GetEnumDescription(this Enum @enum, int value)
|
||||
{
|
||||
Type enumType = @enum.GetType();
|
||||
if (Enum.IsDefined(enumType, value))
|
||||
{
|
||||
DescriptionAttribute[] descriptAttr = enumType.GetField(Enum.GetName(enumType, value)).GetDescriptAttr();
|
||||
return descriptAttr == null || descriptAttr.Length == 0 ? "" : descriptAttr[0].Description;
|
||||
}
|
||||
return "枚举异常";
|
||||
}
|
||||
|
||||
public static string GetDescription(this Enum enumName)
|
||||
{
|
||||
string str = string.Empty;
|
||||
DescriptionAttribute[] descriptAttr = enumName.GetType().GetField(enumName.ToString()).GetDescriptAttr();
|
||||
return descriptAttr == null || descriptAttr.Length == 0 ? enumName.ToString() : descriptAttr[0].Description;
|
||||
}
|
||||
public static ArrayList ToArrayList(this Enum en)
|
||||
{
|
||||
ArrayList arrayList = new ArrayList();
|
||||
foreach (Enum @enum in Enum.GetValues(en.GetType()))
|
||||
arrayList.Add(new KeyValuePair<Enum, string>(@enum, @enum.GetDescription()));
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static DescriptionAttribute[] GetDescriptAttr(this FieldInfo fieldInfo)
|
||||
{
|
||||
if (fieldInfo != null)
|
||||
return (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
|
||||
return null;
|
||||
}
|
||||
public static dynamic Todynamic<T>(this Enum en)
|
||||
{
|
||||
Dictionary<int, string> valuePairs = new Dictionary<int, string>();
|
||||
foreach (Enum @enum in Enum.GetValues(en.GetType()))
|
||||
valuePairs.Add((int)Enum.Parse(typeof(T), @enum.ToString()), @enum.GetDescription());
|
||||
return valuePairs;
|
||||
}
|
||||
|
||||
public static dynamic ToStringKey<T>(this Enum en)
|
||||
{
|
||||
Dictionary<string, string> valuePairs = new Dictionary<string, string>();
|
||||
foreach (Enum @enum in Enum.GetValues(en.GetType()))
|
||||
valuePairs.Add(@enum.ToString(), @enum.GetDescription());
|
||||
return valuePairs;
|
||||
}
|
||||
public static dynamic GetListDesc(this Enum en)
|
||||
{
|
||||
List<string> lst = new List<string>();
|
||||
foreach (Enum @enum in Enum.GetValues(en.GetType()))
|
||||
lst.Add(@enum.GetDescription());
|
||||
return lst;
|
||||
}
|
||||
|
||||
public static dynamic ListKeyString<T>(this Enum en)
|
||||
{
|
||||
List<string> lst = new List<string>();
|
||||
foreach (Enum @enum in Enum.GetValues(en.GetType()))
|
||||
lst.Add(@enum.ToString());
|
||||
return lst;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <typeparam name="EnumType">The enum type.</typeparam>
|
||||
/// <param name="description">The description.</param>
|
||||
/// <returns>The enum value.</returns>
|
||||
public static EnumType GetValueByDescription<EnumType>(this string description)
|
||||
{
|
||||
var type = typeof(EnumType);
|
||||
foreach (var enumName in Enum.GetNames(type))
|
||||
{
|
||||
var enumValue = Enum.Parse(type, enumName);
|
||||
if (description == ((Enum)enumValue).GetDescription())
|
||||
return (EnumType)enumValue;
|
||||
}
|
||||
throw new ArgumentException("在指定的枚举类型值中没有此描述的值");
|
||||
}
|
||||
public static EnumType GetValueByKey<EnumType>(this string name)
|
||||
{
|
||||
var type = typeof(EnumType);
|
||||
foreach (var enumName in Enum.GetNames(type))
|
||||
{
|
||||
var enumValue = Enum.Parse(type, enumName);
|
||||
if (name == ((Enum)enumValue).ToString())
|
||||
return (EnumType)enumValue;
|
||||
}
|
||||
throw new ArgumentException("在指定的枚举类型值中没有此描述的值");
|
||||
}
|
||||
public static List<EnumModel> GetEnumList<EnumType>()
|
||||
{
|
||||
var type = typeof(EnumType);
|
||||
List<EnumModel> enumModels = new List<EnumModel>();
|
||||
foreach (var enumName in Enum.GetNames(type))
|
||||
{
|
||||
EnumModel enumModel = new EnumModel();
|
||||
enumModel.EnumString= enumName;
|
||||
var enumValue = Enum.Parse(type, enumName);
|
||||
enumModel.EnumDesc= ((Enum)enumValue).GetDescription();
|
||||
enumModel.EnumIntValue = int.Parse(((Enum)enumValue).ToString("D"));
|
||||
enumModels.Add(enumModel);
|
||||
}
|
||||
return enumModels;
|
||||
}
|
||||
|
||||
public static Parity GetParity(string name)
|
||||
{
|
||||
Parity parity = Parity.None;
|
||||
var arr = System.Enum.GetValues(typeof(Parity));
|
||||
foreach (Parity item in arr)
|
||||
{
|
||||
if (item.ToString() == name)
|
||||
{
|
||||
parity = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parity;
|
||||
}
|
||||
|
||||
public static StopBits GetStopBits(string name)
|
||||
{
|
||||
StopBits stopBits = StopBits.One;
|
||||
var arr = System.Enum.GetValues(typeof(StopBits));
|
||||
foreach (StopBits item in arr)
|
||||
{
|
||||
if (item.ToString() == name)
|
||||
{
|
||||
stopBits = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return stopBits;
|
||||
}
|
||||
|
||||
public static Handshake GetHandshake(string name)
|
||||
{
|
||||
Handshake handshake = Handshake.None;
|
||||
var arr = System.Enum.GetValues(typeof(Handshake));
|
||||
foreach (Handshake item in arr)
|
||||
{
|
||||
if (item.ToString() == name)
|
||||
{
|
||||
handshake = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return handshake;
|
||||
}
|
||||
|
||||
public static void GetEnum<T>(string a, ref T t)
|
||||
{
|
||||
foreach (T b in Enum.GetValues(typeof(T)))
|
||||
{
|
||||
if (GetDescription(b as Enum) == a)
|
||||
t = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
public class EnumModel
|
||||
{
|
||||
public string EnumString { get; set; }
|
||||
public string EnumDesc { get; set; }
|
||||
public int EnumIntValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Cowain.Preheat.Common.Enums
|
||||
{
|
||||
public enum EDeviceState
|
||||
{
|
||||
[Description("自动运行")] Run = 0,
|
||||
[Description("待机")] Standby = 1,
|
||||
[Description("正常停机")] Stop = 2,
|
||||
[Description("故障停机")] FaultShutdown = 3,
|
||||
[Description("待料")] WaitingMaterials = 4,
|
||||
[Description("满料")] FullMaterial = 5,
|
||||
}
|
||||
|
||||
public enum ETagType
|
||||
{
|
||||
[Description("通用")] General = 0,
|
||||
[Description("报警")] Alarm = 1,
|
||||
[Description("温度")] Temperature = 2,
|
||||
[Description("工艺参数")] ProcessParams = 3,
|
||||
}
|
||||
|
||||
public enum EStovePLC
|
||||
{
|
||||
[Description("心跳")]
|
||||
Heartbeat,
|
||||
|
||||
[Description("层板控温温度")]
|
||||
LayerBoardControlTemp,
|
||||
[Description("补温控温温度")]
|
||||
SupplyControlTemp,
|
||||
[Description("层板巡检温度")]
|
||||
LayerBoardInspectionTemp,
|
||||
[Description("补温巡检温度")]
|
||||
SupplyInspectionTemp,
|
||||
}
|
||||
|
||||
public enum EMesLogClass
|
||||
{
|
||||
[Description("心跳")]
|
||||
EqptAlive,
|
||||
[Description("设备状态")]
|
||||
EqptStatus,
|
||||
[Description("设备报警")]
|
||||
EqptAlert,
|
||||
[Description("参数请求")]
|
||||
EqptParameter,
|
||||
[Description("参数变更")]
|
||||
ParameterChange,
|
||||
[Description("联机请求")]
|
||||
EqptRun,
|
||||
[Description("电芯进站")]
|
||||
CellInput,
|
||||
[Description("电芯出站")]
|
||||
CellOutput,
|
||||
}
|
||||
|
||||
public enum EWindowsRowType
|
||||
{
|
||||
Upper = 1,
|
||||
Mid = 2,
|
||||
Lower = 3
|
||||
}
|
||||
|
||||
public enum EKeyFlag
|
||||
{
|
||||
OK = 0,
|
||||
NG = 1,
|
||||
ProcessParam = 2
|
||||
}
|
||||
public enum EMOMEnable
|
||||
{
|
||||
[Description("禁用")] Disable,
|
||||
[Description("启用")] Enable,
|
||||
}
|
||||
public enum EMenuType
|
||||
{
|
||||
[Description("视图")] Region = 1,
|
||||
[Description("功能开关")] FunctionSwitch,
|
||||
[Description("弹屏")] ShowDialog,
|
||||
[Description("指令")] Cmd,
|
||||
}
|
||||
|
||||
public enum EBatteryStatus
|
||||
{
|
||||
[Description("初始值")]
|
||||
Initialise = 0,
|
||||
[Description("入站验证失败")]
|
||||
PullInFail = 5,
|
||||
[Description("扫码完成")]
|
||||
ScanOver = 10,
|
||||
[Description("电芯进站")]
|
||||
InBound = 15,
|
||||
[Description("预热中")] //有进站电芯,前一组就设成预热中
|
||||
Preheat = 20,
|
||||
[Description("电芯出站")]
|
||||
OutBound = 25,
|
||||
[Description("记录出站")]
|
||||
OutBoundRecord =30,
|
||||
}
|
||||
|
||||
public enum EMesUpLoadStatus
|
||||
{
|
||||
[Description("待发送")] Wait,
|
||||
[Description("待发送")] Fail,
|
||||
[Description("发送成功")] Success,
|
||||
}
|
||||
|
||||
public enum EStartAllow //启动允许
|
||||
{
|
||||
[Description("不允许")] Not = 0,
|
||||
[Description("允许")] Ok,
|
||||
}
|
||||
|
||||
|
||||
public enum EDeviceStatus //设备状态
|
||||
{
|
||||
[Description("未知")] None = 0,
|
||||
[Description("自动运行中")] Auto = 1,
|
||||
[Description("停止中")] Stop,
|
||||
[Description("启动中")] Start,
|
||||
[Description("准备OK")] Ready,
|
||||
[Description("初始化中")] Init,
|
||||
[Description("报警中")] Alarm,
|
||||
[Description("手动模式")] Manual,
|
||||
[Description("维修模式")] Maintain,
|
||||
[Description("模式未选择")] NotSelected,
|
||||
}
|
||||
|
||||
public enum ESysSetup
|
||||
{
|
||||
[Description("设备编号")] DeviceNum,
|
||||
[Description("产线编号")] Line,
|
||||
[Description("二维码长度")] QRCodeLength,
|
||||
[Description("白班开始时间")] DayShift,
|
||||
[Description("晚班开始时间")] NightShift,
|
||||
[Description("数据采集周期(秒)")] ReadPLCCycle,
|
||||
[Description("MOM状态模式")] MOMMode,
|
||||
//[Description("自动上料平台调度是否自动(0为手动,1为自动)")] ManualFeeding,
|
||||
[Description("生产模式(0为调试模式,1为正式模式)")] DebugMode,
|
||||
[Description("是否启用MOM(0为禁用,1为启用)")] MOMEnable,
|
||||
[Description("数据路径")] DataFilePath, //数据路径
|
||||
[Description("A/B面字符位置")] CharPos, //
|
||||
[Description("A/B面字符标识")] CharFlag
|
||||
}
|
||||
|
||||
public enum ECharFlag
|
||||
{
|
||||
UnKnow,
|
||||
B,
|
||||
A
|
||||
}
|
||||
public enum EDeviceType
|
||||
{
|
||||
/*
|
||||
name:用于类型,对应数据库的DType
|
||||
Description:用于找查,对应数据库的Name,另外还有一个编号
|
||||
*/
|
||||
[Description("PLC")] PLC,
|
||||
[Description("MOM")] MOM,
|
||||
[Description("扫码枪")] SCANNER,
|
||||
//[Description("TCP")] TCP
|
||||
}
|
||||
|
||||
public enum EDevName
|
||||
{
|
||||
Stove1,
|
||||
Stove2
|
||||
}
|
||||
public enum EStationType
|
||||
{
|
||||
ScannCode = 1,
|
||||
Loading,
|
||||
Stove,
|
||||
UnLoading,
|
||||
}
|
||||
public enum EProductionMode //MES有这二种MES
|
||||
{
|
||||
[Description("调试模式")] Debug,
|
||||
[Description("正常模式")] Normal,
|
||||
}
|
||||
|
||||
public enum EOperTypePLC
|
||||
{
|
||||
Readable = 1,
|
||||
Writable = 2,
|
||||
ReadWrite = 3
|
||||
}
|
||||
|
||||
public enum EResultFlag //这个是MES的
|
||||
{
|
||||
OK,
|
||||
NG
|
||||
}
|
||||
public enum EResult
|
||||
{
|
||||
OK = 1,
|
||||
NG ,
|
||||
MomError,
|
||||
RepeatScann,
|
||||
ErrorAB,
|
||||
}
|
||||
///// <summary>
|
||||
///// 日志枚举类型
|
||||
///// </summary>
|
||||
public enum E_LogType
|
||||
{
|
||||
[Description("调试信息")] Debug = 0,
|
||||
[Description("提示")] Info = 1,
|
||||
[Description("警告")] Warn = 2,
|
||||
[Description("错误")] Error = 3,
|
||||
[Description("致命错误")] Fatal = 4,
|
||||
[Description("操作日志")] Operate = 5,
|
||||
[Description("跟踪")] Trace,
|
||||
[Description("全部")] All,
|
||||
}
|
||||
|
||||
public enum EAlarmStatus
|
||||
{
|
||||
[Description("恢复")] Renew,
|
||||
[Description("报警")] Alert,
|
||||
[Description("警告")] Warn
|
||||
}
|
||||
|
||||
public enum EDeviceId
|
||||
{
|
||||
[Description("PLC")] PLC = 1,
|
||||
//[Description("PLC2")] PLC2,
|
||||
[Description("Mes")] Mes,
|
||||
[Description("1#扫码枪")] BarcodeScanner1,
|
||||
[Description("2#扫码枪")] BarcodeScanner2,
|
||||
[Description("3#扫码枪")] BarcodeScanner3,
|
||||
[Description("4#扫码枪")] BarcodeScanner4,
|
||||
}
|
||||
public enum EMESMode
|
||||
{
|
||||
[Description("联机模式")] OnLine, //MOM会给设备下达工艺参数信息,设备出入站要判断MOM回复信息是否尾OK值,如果反馈NG需要将电芯放入到NG口
|
||||
[Description("离线模式")] OffLine, //设备需要单机记录所有的生产信息以便MOM回复后上传信息
|
||||
[Description("调机模式")] DebugMachine //设备运行修改MOM提供的工艺参数,正常调用出入站接口,所有这个模式下产出的电芯都需要放入到NG口待人为判定是否可以进入下一站。调机结束后需要再次调用本接口,恢复为联机模式,MOM重新下达工艺参数信息
|
||||
}
|
||||
|
||||
//public enum EDataType
|
||||
//{
|
||||
// [Description("System.Boolean")] BOOL,
|
||||
// [Description("System.UInt16")] UINT16,
|
||||
// [Description("System.Int16")] INT16,
|
||||
// [Description("System.UInt32")] UINT32,
|
||||
// [Description("System.Int32")] INT32,
|
||||
// [Description("System.String")] STRING,
|
||||
// [Description("System.Single")] FLOAT,
|
||||
// [Description("System.Double")] DOUBLE,
|
||||
//}
|
||||
|
||||
|
||||
|
||||
|
||||
public enum ERole
|
||||
{
|
||||
[Description("管理员")]
|
||||
Admin = 1,
|
||||
|
||||
[Description("操作员")]
|
||||
Operater,
|
||||
|
||||
[Description("维修员")]
|
||||
Mantainer
|
||||
}
|
||||
|
||||
public enum EValidStatus
|
||||
{
|
||||
[Description("无效")]
|
||||
Invalid,
|
||||
[Description("有效")]
|
||||
Valid
|
||||
}
|
||||
|
||||
public enum ETemperature
|
||||
{
|
||||
[Description("层板控温")]
|
||||
LayerBoardControlTemp = 1,
|
||||
[Description("补温控温")]
|
||||
SupplyControlTemp,
|
||||
[Description("层板巡检")]
|
||||
LayerBoardInspectionTemp1,
|
||||
[Description("补温巡检")]
|
||||
SupplyInspectionTemp,
|
||||
}
|
||||
public enum OperTypeEnum
|
||||
{
|
||||
[Description("读")]
|
||||
ParamRead,
|
||||
[Description("写")]
|
||||
ParamWrite,
|
||||
[Description("读写")]
|
||||
ParamReadWrite
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Cowain.Preheat.Common
|
||||
{
|
||||
public static class Global
|
||||
{
|
||||
public static string VS = "";
|
||||
public const int MAX_READS = 1; //最大读取PLC次数
|
||||
public const int MAX_TCP_READ_OUTTIME = 500;
|
||||
public const int SCANCODE_COUNT = 3; //扫码次数
|
||||
public const int HEARTBEAT_INTERVAL_TIME = 3000;
|
||||
public const int MAX_QUEUE_SIGNAL = 15;
|
||||
public static bool AppExit = false;
|
||||
public static int SECONDS_TO_MILLISCONDS = 1000;
|
||||
public static int WINDOWS_CONTROLS_HEAD_HIGHT = 30;
|
||||
public static int STOVE_LAYERS = 17;
|
||||
/// <summary>
|
||||
/// 是否启动PLC写入模式(1为启动写入,0为停止写入)
|
||||
/// </summary>
|
||||
public static bool StartStopWritePlcMode = true;
|
||||
/// <summary>
|
||||
/// 是否测试模式(1为正式生产,0为调试模式)
|
||||
/// </summary>
|
||||
public static bool DebugMode = true;
|
||||
}
|
||||
public static class MainRowDefinition
|
||||
{
|
||||
public const float UpperSpacing = 1;
|
||||
public const float UpperHeight = 6;
|
||||
public const float MidHeight = 0;
|
||||
public const float LowerHeight = 0;
|
||||
public const float LowerSpacing = 1;
|
||||
public const float TotalHeight = UpperSpacing + LowerSpacing + UpperHeight + LowerHeight + MidHeight;
|
||||
}
|
||||
|
||||
public static class MyPath
|
||||
{
|
||||
public const string MAIN_APP = "D:\\Preheat";
|
||||
public const string PLC = "Cowain.Preheat.Communication.PLC.";
|
||||
public const string SCAN = "Cowain.Preheat.Communication.Scan.";
|
||||
public const string TESTER = "Cowain.Preheat.Communication.Tester.";
|
||||
public const string SCALE = "Cowain.Preheat.Communication.ElectronicScale.";
|
||||
public const string PRINTER = "Cowain.Preheat.Communication.Printer.";
|
||||
public const string SIGNAL_TRIGGER = "Cowain.Preheat.Main.Station.";
|
||||
public const string HEAD_CMD = "Cowain.Preheat.Main.Common.HeaderCMD";
|
||||
public const string MES_INTERFACE = @"D:\MESlog\{0}\{1}\{2}\{3}\{4}.csv";
|
||||
public const string SYS_LOG = @"D:\SysLog\{0}\{1}\{2}\{3}.csv";//D:\MESDATE\MES \年份\月份\日期\流水号.csv,
|
||||
public const string MOMDATE = @"D:\MESDATE\MES\{0}\{1}\{2}\{3}.csv";//设备本地日志文件
|
||||
}
|
||||
|
||||
public static class FTPFile
|
||||
{
|
||||
public const string CCD = "CCD";
|
||||
public const string SFC = "SFC";
|
||||
public const string INTERFACE = "INTERFACE";
|
||||
public const string SYS = "SYS";
|
||||
|
||||
}
|
||||
|
||||
public static class ReflexFun
|
||||
{
|
||||
public const string OPC_READ_GROUPS = "ReadGroups";
|
||||
public const string OPC_READ_SINGLES = "ReadSingles";
|
||||
public const string TRIG_INSTANCE = "TrigInstance";
|
||||
public const string TRIG_REPLY = "TrigReply";
|
||||
public const string TRIG_FUNC = "TrigFunc";
|
||||
public const string OPC_WRITE_NODE = "WriteNode";
|
||||
public const string OPC_WRITE_NODES = "WriteNodes";
|
||||
public const string OBJECT_TO_T = "ObjectToT";
|
||||
}
|
||||
|
||||
public static class ProcessParas
|
||||
{
|
||||
public static List<TProcessParameter> processParameters { get; set; }
|
||||
public static string StopReason { get; set; }
|
||||
public static string Equipment { get; set; }
|
||||
public static string Equipment2 { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 7.7 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 252 KiB |
|
After Width: | Height: | Size: 114 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 7.2 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 9.6 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 6.0 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 705 B |
|
After Width: | Height: | Size: 5.1 KiB |
@@ -0,0 +1,21 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
using static Cowain.Preheat.Common.Models.MESModel;
|
||||
|
||||
namespace Cowain.Preheat.Common.Interface
|
||||
{
|
||||
public interface ICommonFun
|
||||
{
|
||||
void ModifyOrderNum(string JobNum, string Operation);
|
||||
|
||||
float GetControlTemp(int layer);
|
||||
string MesOutUnBinding(TBatteryInfo batteryInfo);
|
||||
|
||||
//MESReturnCmdModel SendData(string info); //发送
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.Interface
|
||||
{
|
||||
public interface IDeviceDebug
|
||||
{
|
||||
object ExecDebug(string trigJson, string json); //Variable node string trigInfo, string replyJosn
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.Interface
|
||||
{
|
||||
public interface IRecvMesHttp
|
||||
{
|
||||
string RecvInfo(HttpListenerRequest request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.Common.Interface
|
||||
{
|
||||
public interface IServerManager
|
||||
{
|
||||
string Name { get; set; }
|
||||
IUnityContainer _unityContainer { set; get; }
|
||||
|
||||
void Start();
|
||||
void Stop();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Cowain.Preheat.Model.Models;
|
||||
using Opc.Ua;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.Interface
|
||||
{
|
||||
public interface ITrigService
|
||||
{
|
||||
void RecvTrigInfo(DataValue data, Variable node); //Variable node string trigInfo, string replyJosn
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common
|
||||
{
|
||||
public static class MiniDump
|
||||
{
|
||||
[Flags]
|
||||
public enum Option : uint
|
||||
{
|
||||
// From dbghelp.h:
|
||||
Normal = 0x00000000,
|
||||
WithDataSegs = 0x00000001,
|
||||
WithFullMemory = 0x00000002,
|
||||
WithHandleData = 0x00000004,
|
||||
FilterMemory = 0x00000008,
|
||||
ScanMemory = 0x00000010,
|
||||
WithUnloadedModules = 0x00000020,
|
||||
WithIndirectlyReferencedMemory = 0x00000040,
|
||||
FilterModulePaths = 0x00000080,
|
||||
WithProcessThreadData = 0x00000100,
|
||||
WithPrivateReadWriteMemory = 0x00000200,
|
||||
WithoutOptionalData = 0x00000400,
|
||||
WithFullMemoryInfo = 0x00000800,
|
||||
WithThreadInfo = 0x00001000,
|
||||
WithCodeSegs = 0x00002000,
|
||||
WithoutAuxiliaryState = 0x00004000,
|
||||
WithFullAuxiliaryState = 0x00008000,
|
||||
WithPrivateWriteCopyMemory = 0x00010000,
|
||||
IgnoreInaccessibleMemory = 0x00020000,
|
||||
ValidTypeFlags = 0x0003ffff,
|
||||
}
|
||||
|
||||
enum ExceptionInfo
|
||||
{
|
||||
None,
|
||||
Present
|
||||
}
|
||||
|
||||
//typedef struct _MINIDUMP_EXCEPTION_INFORMATION {
|
||||
// DWORD ThreadId;
|
||||
// PEXCEPTION_POINTERS ExceptionPointers;
|
||||
// BOOL ClientPointers;
|
||||
//} MINIDUMP_EXCEPTION_INFORMATION, *PMINIDUMP_EXCEPTION_INFORMATION;
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)] // Pack=4 is important! So it works also for x64!
|
||||
struct MiniDumpExceptionInformation
|
||||
{
|
||||
public uint ThreadId;
|
||||
public IntPtr ExceptionPointers;
|
||||
[MarshalAs(UnmanagedType.Bool)]
|
||||
public bool ClientPointers;
|
||||
}
|
||||
|
||||
//BOOL
|
||||
//WINAPI
|
||||
//MiniDumpWriteDump(
|
||||
// __in HANDLE hProcess,
|
||||
// __in DWORD ProcessId,
|
||||
// __in HANDLE hFile,
|
||||
// __in MINIDUMP_TYPE DumpType,
|
||||
// __in_opt PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam,
|
||||
// __in_opt PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
|
||||
// __in_opt PMINIDUMP_CALLBACK_INFORMATION CallbackParam
|
||||
// );
|
||||
// Overload requiring MiniDumpExceptionInformation
|
||||
[DllImport("dbghelp.dll", EntryPoint = "MiniDumpWriteDump", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
|
||||
|
||||
static extern bool MiniDumpWriteDump(IntPtr hProcess, uint processId, SafeHandle hFile, uint dumpType, ref MiniDumpExceptionInformation expParam, IntPtr userStreamParam, IntPtr callbackParam);
|
||||
|
||||
// Overload supporting MiniDumpExceptionInformation == NULL
|
||||
[DllImport("dbghelp.dll", EntryPoint = "MiniDumpWriteDump", CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
|
||||
static extern bool MiniDumpWriteDump(IntPtr hProcess, uint processId, SafeHandle hFile, uint dumpType, IntPtr expParam, IntPtr userStreamParam, IntPtr callbackParam);
|
||||
|
||||
[DllImport("kernel32.dll", EntryPoint = "GetCurrentThreadId", ExactSpelling = true)]
|
||||
static extern uint GetCurrentThreadId();
|
||||
|
||||
static bool Write(SafeHandle fileHandle, Option options, ExceptionInfo exceptionInfo)
|
||||
{
|
||||
Process currentProcess = Process.GetCurrentProcess();
|
||||
IntPtr currentProcessHandle = currentProcess.Handle;
|
||||
uint currentProcessId = (uint)currentProcess.Id;
|
||||
MiniDumpExceptionInformation exp;
|
||||
exp.ThreadId = GetCurrentThreadId();
|
||||
exp.ClientPointers = false;
|
||||
exp.ExceptionPointers = IntPtr.Zero;
|
||||
if (exceptionInfo == ExceptionInfo.Present)
|
||||
{
|
||||
exp.ExceptionPointers = Marshal.GetExceptionPointers();
|
||||
}
|
||||
return exp.ExceptionPointers == IntPtr.Zero ? MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero) : MiniDumpWriteDump(currentProcessHandle, currentProcessId, fileHandle, (uint)options, ref exp, IntPtr.Zero, IntPtr.Zero);
|
||||
}
|
||||
|
||||
static bool Write(SafeHandle fileHandle, Option dumpType)
|
||||
{
|
||||
return Write(fileHandle, dumpType, ExceptionInfo.None);
|
||||
}
|
||||
|
||||
public static Boolean TryDump(String dmpPath, Option dmpType = Option.Normal)
|
||||
{
|
||||
var path = Path.Combine(Environment.CurrentDirectory, dmpPath);
|
||||
var dir = Path.GetDirectoryName(path);
|
||||
if (dir != null && !Directory.Exists(dir))
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
using (var fs = new FileStream(path, FileMode.Create))
|
||||
{
|
||||
return Write(fs.SafeFileHandle, dmpType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.Models
|
||||
{
|
||||
public class ProceParamList
|
||||
{
|
||||
//public int Id { get; set; }
|
||||
public string OperationName { get; set; }
|
||||
public string OperationDesc { get; set; }
|
||||
public string OperationValue { get; set; }
|
||||
}
|
||||
|
||||
public class SignalEvent
|
||||
{
|
||||
public string InfoName { get; set; } //枚举名
|
||||
public string InfoDesc { get; set; } //描述
|
||||
public int DetailNumber { get; set; } //编号
|
||||
public DateTime RecvTime { get; set; }//时间
|
||||
}
|
||||
|
||||
public class SizeAndLocationModel
|
||||
{
|
||||
public double Left { get; set; }
|
||||
public double Top { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,271 @@
|
||||
using Cowain.Preheat.Common.Enums;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.Common.Models
|
||||
{
|
||||
public class MESModel
|
||||
{
|
||||
|
||||
//static IUnityContainer _unityContainer;
|
||||
public MESModel(IUnityContainer unityContainer)
|
||||
{
|
||||
//_unityContainer = unityContainer;
|
||||
}
|
||||
public class MesBase
|
||||
{
|
||||
public string Cmd { get; set; }
|
||||
}
|
||||
public class MESReturnCmdModel : MesBase
|
||||
{
|
||||
public MESReturnModelWithKeyFlag Info { get; set; }
|
||||
}
|
||||
public class MESReturnModel
|
||||
{
|
||||
public string Key { get; set; } = "";
|
||||
public string ResultFlag { get; set; } = "";
|
||||
public string MOMMessage { get; set; } = "";
|
||||
}
|
||||
public class MESReturnModelWithKeyFlag : MESReturnModel
|
||||
{
|
||||
public string KeyFlag { get; set; } = "";
|
||||
}
|
||||
|
||||
#region 出站
|
||||
public class MESReturnOutputModel : MesBase
|
||||
{
|
||||
public MESReturnCellModel Info { get; set; }
|
||||
}
|
||||
public class MESReturnCellModel : MESReturnModel
|
||||
{
|
||||
public List<MESReturnCell> Cells { get; set; }
|
||||
}
|
||||
public class MESReturnCell
|
||||
{
|
||||
public string CellNo { get; set; } = "";
|
||||
public string CellInfo { get; set; } = "";
|
||||
}
|
||||
#endregion
|
||||
//每个接口都有Key和设备编号,所以都从这里继承
|
||||
|
||||
public class EqptParameter : MesBase
|
||||
{
|
||||
public EqptParameter()
|
||||
{
|
||||
Cmd = "EqptParameter";
|
||||
}
|
||||
public EqptModel Info { get; set; } = new EqptModel();
|
||||
}
|
||||
|
||||
public class EqptModel
|
||||
{
|
||||
public string Key { get; set; }=Guid.NewGuid().ToString();
|
||||
public string EquipmentCode { get; set; } = "HCHK0010"; //要从数据库中获取
|
||||
}
|
||||
public class EqptAlive : MesBase
|
||||
{
|
||||
public EqptAlive()
|
||||
{
|
||||
Cmd = "EqptAlive";
|
||||
}
|
||||
public EqptAliveModel Info { get; set; } = new EqptAliveModel();
|
||||
}
|
||||
public class EqptAliveModel: EqptModel
|
||||
{
|
||||
public string PPM { get; set; } = "";//设备PPM(单台设备需要提供的PPM)
|
||||
public List<ModePPMs> PPMs { get; set; } = new List<ModePPMs>(); //2子设备PPM(多台设备共用一个心跳时,需要用这个字段)
|
||||
}
|
||||
|
||||
public class ModePPMs
|
||||
{
|
||||
public string SubEqCode { get; set; } = ""; //子设备编码
|
||||
public string PPM { get; set; } = ""; //设备PPM(单台设备需要提供的PPM
|
||||
}
|
||||
|
||||
public class EqptStatus : MesBase
|
||||
{
|
||||
public EqptStatus()
|
||||
{
|
||||
Cmd = "EqptStatus";
|
||||
}
|
||||
public EqptStatusModel Info { get; set; } = new EqptStatusModel();
|
||||
}
|
||||
|
||||
public class EqptStatusModel: EqptModel
|
||||
{
|
||||
public string LocationID { get; set; } = "";
|
||||
public string StatusCode { get; set; } = "";
|
||||
public List<AlerInfoModel> AlertInfo { get; set; } = new List<AlerInfoModel>();
|
||||
}
|
||||
public class AlerInfoModel
|
||||
{
|
||||
public string AlertCode { get; set; } = "";
|
||||
public string AlertMessage { get; set; } = "";
|
||||
}
|
||||
|
||||
public class EqptAlert : MesBase
|
||||
{
|
||||
public EqptAlert()
|
||||
{
|
||||
Cmd = "EqptAlert";
|
||||
}
|
||||
public EqptAlertModel Info { get; set; } = new EqptAlertModel();
|
||||
}
|
||||
|
||||
public class EqptAlertModel: EqptModel
|
||||
{
|
||||
public List<AlertInfoModel> AlertInfo { get; set; } = new List<AlertInfoModel>();
|
||||
}
|
||||
public class AlertInfoModel
|
||||
{
|
||||
public string AlertCode { get; set; } = "";
|
||||
public string AlertReset { get; set; } = "";
|
||||
public string AlertMessage { get; set; } = "";
|
||||
}
|
||||
public class EqptParameterReturnCmd : MesBase
|
||||
{
|
||||
public Data Info { get; set; } = new Data();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class Data : MESReturnModel
|
||||
{
|
||||
public List<EqptParameterModel> ParameterInfo { get; set; } = new List<EqptParameterModel>();
|
||||
|
||||
}
|
||||
public class EqptParameterModel
|
||||
{
|
||||
public string ParameterCode { get; set; } = "";
|
||||
public string ParameterType { get; set; } = "";
|
||||
public string TargetValue { get; set; } = "";
|
||||
public string UOMCode { get; set; } = "";
|
||||
public string UpperLimit { get; set; } = "";
|
||||
public string LowerLimit { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
}
|
||||
|
||||
public class ParameterChangeCmd : MesBase
|
||||
{
|
||||
public ParameterChangeCmd()
|
||||
{
|
||||
Cmd = "ParameterChange";
|
||||
}
|
||||
public ParameterChange Info { get; set; } = new ParameterChange();
|
||||
|
||||
}
|
||||
public class ParameterChange: EqptModel
|
||||
{
|
||||
public string EmployeeNo { get; set; } = "";
|
||||
public List<EqptParameterModel> ParameterInfo { get; set; } = new List<EqptParameterModel>();
|
||||
}
|
||||
|
||||
|
||||
public class EqptRunCmd : MesBase
|
||||
{
|
||||
public EqptRunCmd()
|
||||
{
|
||||
Cmd = "EqptRun";
|
||||
}
|
||||
public EqptRun Info { get; set; } = new EqptRun();
|
||||
}
|
||||
|
||||
public class EqptRun: EqptModel
|
||||
{
|
||||
public string EmployeeNo { get; set; } = "";
|
||||
public string Password { get; set; } = "";
|
||||
public string EquipmentModel { get; set; } = "";
|
||||
}
|
||||
|
||||
public class CellInputCmd : MesBase
|
||||
{
|
||||
public CellInputCmd()
|
||||
{
|
||||
Cmd = "CellInput";
|
||||
}
|
||||
public CellInput Info { get; set; } = new CellInput();
|
||||
}
|
||||
public class CellInput : EqptModel
|
||||
{
|
||||
public List<CellModel> Cells { get; set; } = new List<CellModel>();//是电芯组
|
||||
}
|
||||
|
||||
public class CellModel
|
||||
{
|
||||
public string CellNo { get; set; } = ""; //电芯号 电芯号才是具体的电芯条码
|
||||
}
|
||||
public class BakingParameterCmd : MesBase
|
||||
{
|
||||
public BakingParameterCmd()
|
||||
{
|
||||
Cmd = "BakingParameter";
|
||||
}
|
||||
|
||||
public BakingParameter Info { get; set; } = new BakingParameter();
|
||||
}
|
||||
|
||||
public class BakingParameter:EqptModel
|
||||
{
|
||||
public string LocationID { get; set; } = "";
|
||||
public List<ProcessData> ParameterInfo { get; set; } = new List<ProcessData>();
|
||||
}
|
||||
|
||||
public class ProcessData
|
||||
{
|
||||
public string ParameterCode { get; set; } = "";
|
||||
public string ParameterType { get; set; } = "";
|
||||
public string Value { get; set; } = "";
|
||||
public string TargetValue { get; set; } = "";
|
||||
public string UOMCode { get; set; } = "";
|
||||
public string UpperSpecificationsLimit { get; set; } = "";
|
||||
public string LowerSpecificationsLimit { get; set; } = "";
|
||||
public string LcoalTime { get; set; } = "";
|
||||
public string Description { get; set; } = "";
|
||||
}
|
||||
public class CellOutputCmd : MesBase
|
||||
{
|
||||
public CellOutputCmd()
|
||||
{
|
||||
Cmd = "CellOutput";
|
||||
}
|
||||
public CellOutput Info { get; set; } = new CellOutput();
|
||||
}
|
||||
|
||||
public class CellOutput : EqptModel
|
||||
{
|
||||
public List<CellsModel> Cells { get; set; } = new List<CellsModel>();
|
||||
}
|
||||
|
||||
public class CellsModel
|
||||
{
|
||||
public string CellNo { get; set; } = "";
|
||||
public string PassFlag { get; set; } = "";
|
||||
public string NGCode { get; set; } = "";
|
||||
public string NGMessage { get; set; } = "";
|
||||
|
||||
public List<ParametersModel> Parameters { get; set; } = new List<ParametersModel>();
|
||||
public List<MaterialInfoModel> MaterialInfo { get; set; } = new List<MaterialInfoModel>();
|
||||
}
|
||||
public class MaterialInfoModel
|
||||
{
|
||||
public string MaterialCode { get; set; } = "";
|
||||
public string MaterialLoc { get; set; } = "";
|
||||
public string Quantity { get; set; } = "";
|
||||
}
|
||||
public class ParametersModel
|
||||
{
|
||||
public string ParameterCode { get; set; } = "";
|
||||
//public string ParameterDesc { get; set; } = "";
|
||||
public string Value { get; set; } = "";
|
||||
public string UpperLimit { get; set; } = "";
|
||||
public string LowerLimit { get; set; } = "";
|
||||
public string TargetValue { get; set; } = "";
|
||||
public string ParameterResult { get; set; } = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Common.Models
|
||||
{
|
||||
[StructLayout(LayoutKind.Explicit, Size = 4)]
|
||||
public class VarValue
|
||||
{
|
||||
// Fields
|
||||
[FieldOffset(0)]
|
||||
public bool Boolean;
|
||||
[FieldOffset(0)]
|
||||
public byte Byte;
|
||||
[FieldOffset(0)]
|
||||
public short Int16;
|
||||
[FieldOffset(0)]
|
||||
public ushort UInt16;
|
||||
[FieldOffset(0)]
|
||||
public int Int32;
|
||||
[FieldOffset(0)]
|
||||
public uint UInt32;
|
||||
[FieldOffset(0)]
|
||||
public float Single;
|
||||
|
||||
public string GetValue(string tp)
|
||||
{
|
||||
if (string.IsNullOrEmpty(tp))
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else if (tp == "BOOL")
|
||||
{
|
||||
return this.Boolean == true ? "TRUE" : "FALSE";
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.Int32.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
return false;
|
||||
Type type = obj.GetType();
|
||||
if (type == typeof(VarValue))
|
||||
return this.Int32 == ((VarValue)obj).Int32;
|
||||
else
|
||||
{
|
||||
if (type == typeof(int))
|
||||
return this.Int32 == (int)obj;
|
||||
if (type == typeof(uint))
|
||||
return this.UInt32 == (uint)obj;
|
||||
if (type == typeof(short))
|
||||
return this.Int16 == (short)obj;
|
||||
if (type == typeof(ushort))
|
||||
return this.UInt16 == (ushort)obj;
|
||||
if (type == typeof(byte))
|
||||
return this.Byte == (byte)obj;
|
||||
if (type == typeof(bool))
|
||||
return this.Boolean == (bool)obj;
|
||||
if (type == typeof(float))
|
||||
return this.Single == (float)obj;
|
||||
if (type == typeof(string))
|
||||
return this.ToString() == obj.ToString();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Int32.GetHashCode();
|
||||
}
|
||||
public static bool Equals(VarValue a, VarValue b)
|
||||
{
|
||||
|
||||
if (a == null || b == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (a.Int32 != b.Int32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.Int32.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Cowain.Preheat.Common
|
||||
{
|
||||
public class PasswordHelper
|
||||
{
|
||||
public static readonly DependencyProperty PasswordProperty = DependencyProperty.RegisterAttached("Password", typeof(string), typeof(PasswordHelper),
|
||||
new PropertyMetadata(new PropertyChangedCallback(OnPropertyChanged)));
|
||||
|
||||
public static string GetPassword(DependencyObject d)
|
||||
{
|
||||
return (string)d.GetValue(PasswordProperty);
|
||||
}
|
||||
public static void SetPassword(DependencyObject d, string value)
|
||||
{
|
||||
d.SetValue(PasswordProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty AttachProperty = DependencyProperty.RegisterAttached("Attach", typeof(string), typeof(PasswordHelper),
|
||||
new PropertyMetadata(new PropertyChangedCallback(OnAttachChanged)));
|
||||
|
||||
public static string GetAttach(DependencyObject d)
|
||||
{
|
||||
return (string)d.GetValue(AttachProperty);
|
||||
}
|
||||
public static void SetAttach(DependencyObject d, string value)
|
||||
{
|
||||
d.SetValue(AttachProperty, value);
|
||||
}
|
||||
|
||||
static bool _isUpdating = false;
|
||||
private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
PasswordBox pb = (d as PasswordBox);
|
||||
pb.PasswordChanged -= Pb_PasswordChanged;
|
||||
if (!_isUpdating)
|
||||
(d as PasswordBox).Password = e.NewValue.ToString();
|
||||
pb.PasswordChanged += Pb_PasswordChanged;
|
||||
}
|
||||
|
||||
private static void OnAttachChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
PasswordBox pb = (d as PasswordBox);
|
||||
pb.PasswordChanged += Pb_PasswordChanged;
|
||||
}
|
||||
|
||||
private static void Pb_PasswordChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PasswordBox pb = (sender as PasswordBox);
|
||||
_isUpdating = true;
|
||||
SetPassword(pb, pb.Password);
|
||||
_isUpdating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("Cowain.Preheat.Common")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("Cowain.Preheat.Common")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//若要开始生成可本地化的应用程序,请设置
|
||||
//.csproj 文件中的 <UICulture>CultureYouAreCodingWith</UICulture>
|
||||
//例如,如果您在源文件中使用的是美国英语,
|
||||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
|
||||
//对以下 NeutralResourceLanguage 特性的注释。 更新
|
||||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly:ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
||||
//(未在页面中找到资源时使用,
|
||||
//或应用程序资源字典中找到时使用)
|
||||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
||||
//(未在页面中找到资源时使用,
|
||||
//、应用程序或任何主题专用资源字典中找到时使用)
|
||||
)]
|
||||
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -0,0 +1,63 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Cowain.Preheat.Common.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
// 此类是由 StronglyTypedResourceBuilder
|
||||
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
|
||||
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
|
||||
// (以 /str 作为命令选项),或重新生成 VS 项目。
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Cowain.Preheat.Common.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,26 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.42000
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Cowain.Preheat.Common.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
@@ -0,0 +1,4 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<FontFamily x:Key="Iconfont">pack://application:,,,/Cowain.Preheat.Common;component/Fonts/#iconfont</FontFamily>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,88 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style TargetType="Button" x:Key="NormalButtonStyle">
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Width" Value="50"/>
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="Background" Value="#FF0ABEFF"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="4">
|
||||
<Border Background="Transparent" Name="back" CornerRadius="4">
|
||||
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</Border>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#11000000" TargetName="back"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button" x:Key="IconButtonStyle">
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Width" Value="40"/>
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="Background" Value="#FF0ABEFF"/>
|
||||
<Setter Property="FontFamily" Value="{DynamicResource Iconfont}"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="4">
|
||||
<Border Background="Transparent" Name="back" CornerRadius="4">
|
||||
<ContentPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</Border>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#11000000" TargetName="back"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="Button" x:Key="IconWithContentButtonStyle">
|
||||
<Setter Property="Foreground" Value="White"/>
|
||||
<Setter Property="Height" Value="30"/>
|
||||
<Setter Property="Background" Value="#FF0ABEFF"/>
|
||||
<Setter Property="FontFamily" Value="{DynamicResource Iconfont}"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Center"/>
|
||||
<Setter Property="WindowChrome.IsHitTestVisibleInChrome" Value="True"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border Background="{TemplateBinding Background}" CornerRadius="4">
|
||||
<Border Background="Transparent" Name="back" CornerRadius="4">
|
||||
<Grid HorizontalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="auto"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{TemplateBinding Tag}" FontFamily="{DynamicResource Iconfont}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0"/>
|
||||
<ContentPresenter Grid.Column="1" Margin="0,0,10,0"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter Property="Background" Value="#11000000" TargetName="back"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,317 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!--调整列头宽度样式-->
|
||||
<Style x:Key="DefaultColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
|
||||
<Setter Property="Width" Value="8" />
|
||||
<Setter Property="Background" Value="{StaticResource HeaderBorderBrush}" />
|
||||
<Setter Property="Cursor" Value="SizeWE" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border Padding="{TemplateBinding Padding}" Background="Transparent" Margin="0 0 0 2">
|
||||
<Rectangle HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Width="1" Fill="{TemplateBinding Background}" />
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--列头header样式-->
|
||||
<Style x:Key="DefaultDataGridColumnHeader" TargetType="{x:Type DataGridColumnHeader}">
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="MinWidth" Value="5" />
|
||||
<Setter Property="MinHeight" Value="25" />
|
||||
<Setter Property="Height" Value="50" />
|
||||
<Setter Property="Foreground" Value="{StaticResource TextForeground}" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Padding" Value="10,4,4,7" />
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
<Setter Property="FontWeight" Value="SemiBold"></Setter>
|
||||
<Setter Property="FontSize" Value="{StaticResource HeaderFontSize}" />
|
||||
<Setter Property="BorderThickness" Value="0,0,0,3" />
|
||||
<Setter Property="BorderBrush" Value="{StaticResource HeaderBorderBrush}" />
|
||||
<Setter Property="Background" Value="{StaticResource HeaderBackground}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Border x:Name="BackgroundBorder" BorderThickness="0,0,0,3" CornerRadius="15,15,0,0"
|
||||
Grid.ColumnSpan="2" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" />
|
||||
<ContentPresenter x:Name="HeaderContent"
|
||||
Content="{TemplateBinding Content}"
|
||||
ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
|
||||
RecognizesAccessKey="True"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
<TextBlock x:Name="SortArrow" Style="{StaticResource FIcon}" Text="" Grid.Column="1" Width="20"
|
||||
Visibility="Collapsed" FontSize="16" Margin="1,1,3,1" />
|
||||
|
||||
<Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" HorizontalContentAlignment="Left"
|
||||
Style="{StaticResource DefaultColumnHeaderGripperStyle}" />
|
||||
|
||||
<Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" HorizontalContentAlignment="Right" Background="Transparent"
|
||||
Style="{StaticResource DefaultColumnHeaderGripperStyle}" Grid.Column="1" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<!--显示排序标示-->
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsMouseOver" Value="True" />
|
||||
<Condition Property="SortDirection" Value="{x:Null}" />
|
||||
<Condition Property="CanUserSort" Value="true" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
|
||||
</MultiTrigger>
|
||||
<!--可排序列鼠标样式-->
|
||||
<Trigger Property="CanUserSort" Value="True">
|
||||
<Setter Property="Cursor" Value="Hand"></Setter>
|
||||
</Trigger>
|
||||
<!--升序-->
|
||||
<Trigger Property="SortDirection" Value="Ascending">
|
||||
<Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
|
||||
</Trigger>
|
||||
<!--降序-->
|
||||
<Trigger Property="SortDirection" Value="Descending">
|
||||
<Setter TargetName="SortArrow" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="SortArrow" Property="Text" Value=""/>
|
||||
</Trigger>
|
||||
<!--第一列左边不显示分割线-->
|
||||
<Trigger Property="DisplayIndex" Value="2">
|
||||
<Setter Property="Visibility" Value="Collapsed" TargetName="PART_LeftHeaderGripper" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--行样式-->
|
||||
<Style x:Key="DefaultDataGridRow" TargetType="{x:Type DataGridRow}">
|
||||
<Setter Property="Foreground" Value="{StaticResource TextForeground}" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Height" Value="36" />
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
|
||||
<Style.Triggers>
|
||||
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
|
||||
<Setter Property="Background" Value="{StaticResource ItemsAlternationContentBackground}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Background" Value="{StaticResource ItemSelectedBackground}" />
|
||||
<Setter Property="Foreground" Value="{StaticResource ItemSelectedForeground}" />
|
||||
</Trigger>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsSelected" Value="True" />
|
||||
<Condition Property="Selector.IsSelectionActive" Value="True" />
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="Background" Value="{StaticResource ItemSelectedBackground}" />
|
||||
<Setter Property="Foreground" Value="{StaticResource ItemSelectedForeground}" />
|
||||
</MultiTrigger>
|
||||
<MultiDataTrigger>
|
||||
<MultiDataTrigger.Conditions>
|
||||
<Condition Binding="{Binding Path=IsMouseOver, RelativeSource={RelativeSource Self}}" Value="True" />
|
||||
</MultiDataTrigger.Conditions>
|
||||
<Setter Property="Background" Value="{StaticResource ItemMouseOverBackground}" />
|
||||
<Setter Property="Foreground" Value="{StaticResource ItemMouseOverForeground}" />
|
||||
</MultiDataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<!--行头调整高度样式 -->
|
||||
<Style x:Key="DefaultRowHeaderGripperStyle" TargetType="{x:Type Thumb}">
|
||||
<Setter Property="Height" Value="36" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="Cursor" Value="SizeNS" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type Thumb}">
|
||||
<Border Padding="{TemplateBinding Padding}" Background="Transparent"/>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--行头部样式-->
|
||||
<Style x:Key="DefaultDataGridRowHeader" TargetType="{x:Type DataGridRowHeader}">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="BorderThickness" Value="0,0,1,0" />
|
||||
<Setter Property="Margin" Value="0,0,0,0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridRowHeader}">
|
||||
<Grid>
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Padding="{TemplateBinding Padding}"
|
||||
Margin="{TemplateBinding Margin}"
|
||||
SnapsToDevicePixels="True">
|
||||
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
|
||||
</Border>
|
||||
<Thumb x:Name="PART_TopHeaderGripper" VerticalContentAlignment="Top"
|
||||
VerticalAlignment="Top" Background="Transparent" Style="{StaticResource DefaultRowHeaderGripperStyle}" />
|
||||
<Thumb x:Name="PART_BottomHeaderGripper" VerticalContentAlignment="Bottom"
|
||||
VerticalAlignment="Bottom" Style="{StaticResource DefaultRowHeaderGripperStyle}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--单元格样式-->
|
||||
<Style x:Key="DefaultDataGridCell"
|
||||
TargetType="{x:Type DataGridCell}">
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="BorderBrush" Value="Transparent" />
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center" />
|
||||
<Setter Property="SnapsToDevicePixels" Value="True" />
|
||||
<Setter Property="Height" Value="36" />
|
||||
<Setter Property="Padding" Value="0" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGridCell}">
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="0"
|
||||
Background="{TemplateBinding Background}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
|
||||
<ContentPresenter ContentTemplate="{TemplateBinding ContentTemplate}"
|
||||
Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}"
|
||||
Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}">
|
||||
|
||||
</ContentPresenter>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter Property="Foreground" Value="{StaticResource ItemSelectedForeground}" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--表格DataGrid样式-->
|
||||
<Style x:Key="DefaultDataGrid" TargetType="{x:Type DataGrid}">
|
||||
<Setter Property="MinRowHeight" Value="25" />
|
||||
<Setter Property="Canvas.Top" Value="220"/>
|
||||
<Setter Property="Canvas.Left" Value="343"/>
|
||||
<Setter Property="FrameworkElement.MaxWidth" Value="1175"/>
|
||||
<Setter Property="FrameworkElement.Height" Value="582"/>
|
||||
<Setter Property="Background" Value="Transparent" />
|
||||
<Setter Property="FontSize" Value="16" />
|
||||
<Setter Property="BorderBrush" Value="{StaticResource ControlBorderBrush}" />
|
||||
<Setter Property="BorderThickness" Value="0" />
|
||||
<Setter Property="HorizontalGridLinesBrush" Value="{StaticResource GridLinesBrush}" />
|
||||
<Setter Property="VerticalGridLinesBrush" Value="{StaticResource GridLinesBrush}" />
|
||||
<Setter Property="ColumnHeaderStyle" Value="{StaticResource DefaultDataGridColumnHeader}" />
|
||||
<Setter Property="RowHeaderStyle" Value="{StaticResource DefaultDataGridRowHeader}" />
|
||||
<Setter Property="CellStyle" Value="{StaticResource DefaultDataGridCell}" />
|
||||
<Setter Property="RowStyle" Value="{StaticResource DefaultDataGridRow}" />
|
||||
<Setter Property="HeadersVisibility" Value="All" />
|
||||
<Setter Property="EnableRowVirtualization" Value="True" />
|
||||
<Setter Property="EnableColumnVirtualization" Value="False" />
|
||||
<Setter Property="AutoGenerateColumns" Value="False" />
|
||||
<Setter Property="IsReadOnly" Value="True" />
|
||||
<Setter Property="SelectionMode" Value="Single" />
|
||||
<Setter Property="SelectionUnit" Value="FullRow" />
|
||||
<Setter Property="GridLinesVisibility" Value="All" />
|
||||
<Setter Property="AlternationCount" Value="2"></Setter>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="True" />
|
||||
<Setter Property="VirtualizingStackPanel.IsVirtualizing" Value="True"></Setter>
|
||||
<Setter Property="VirtualizingStackPanel.VirtualizationMode" Value="Recycling" />
|
||||
<Setter Property="ScrollViewer.IsDeferredScrollingEnabled" Value="False" />
|
||||
<!--列头移动列时候分割线样式-->
|
||||
<Setter Property="DropLocationIndicatorStyle">
|
||||
<Setter.Value>
|
||||
<Style TargetType="Separator">
|
||||
<Setter Property="Background" Value="{StaticResource HeaderBorderBrush}" />
|
||||
<Setter Property="Width" Value="2.5" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Separator">
|
||||
<Rectangle Fill="{TemplateBinding Background}" Height="{TemplateBinding Height}" Width="{TemplateBinding Width}" />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<!--DataGrid控件模板-->
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type DataGrid}">
|
||||
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0" x:Name="border"
|
||||
Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True">
|
||||
<ScrollViewer x:Name="DG_ScrollViewer" Focusable="false">
|
||||
<ScrollViewer.Template>
|
||||
<ControlTemplate TargetType="{x:Type ScrollViewer}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition x:Name="col_rowheader" Width="1" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<!--表格头部-->
|
||||
<DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter" Grid.Column="1" Grid.ColumnSpan="2"
|
||||
Visibility="{Binding HeadersVisibility, ConverterParameter={x:Static DataGridHeadersVisibility.Column}, Converter={x:Static DataGrid.HeadersVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" />
|
||||
<!--主数据区-->
|
||||
<Grid Grid.Row="1" Grid.ColumnSpan="2">
|
||||
<ScrollContentPresenter x:Name="PART_ScrollContentPresenter" CanContentScroll="{TemplateBinding CanContentScroll}" Grid.ColumnSpan="2" />
|
||||
</Grid>
|
||||
<!--垂直滑动条-->
|
||||
<ScrollBar x:Name="PART_VerticalScrollBar" Grid.Column="2" Maximum="{TemplateBinding ScrollableHeight}"
|
||||
Orientation="Vertical" Grid.Row="0" Grid.RowSpan="3" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"
|
||||
Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ViewportSize="{TemplateBinding ViewportHeight}" />
|
||||
<!--横向滑动条-->
|
||||
<ScrollBar x:Name="PART_HorizontalScrollBar" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="2"
|
||||
Maximum="{TemplateBinding ScrollableWidth}" Orientation="Horizontal"
|
||||
Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"
|
||||
Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"
|
||||
ViewportSize="{TemplateBinding ViewportWidth}" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</ScrollViewer.Template>
|
||||
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" Value="{StaticResource DisableOpacity}" TargetName="border" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<Trigger Property="IsGrouping" Value="true">
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false" />
|
||||
</Trigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content.Text}" />
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,118 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<SolidColorBrush x:Key="TextBox.Static.Border" Color="#FFABAdB3"/>
|
||||
<SolidColorBrush x:Key="TextBox.MouseOver.Border" Color="#FF7EB4EA"/>
|
||||
<SolidColorBrush x:Key="TextBox.Focus.Border" Color="#FF569DE5"/>
|
||||
<Style x:Key="SearchTextBoxStyle" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="AllowDrop" Value="true"/>
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
SnapsToDevicePixels="True"
|
||||
CornerRadius="5" Height="30">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="30"/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="" FontFamily="{DynamicResource Iconfont}"
|
||||
VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="#999" FontSize="14"/>
|
||||
<TextBlock Text="输入关键词查找" VerticalAlignment="Center" Margin="3,0" FontSize="12"
|
||||
Foreground="#999" Grid.Column="1" Visibility="Collapsed" Name="mask"/>
|
||||
<ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" Focusable="false"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding Text,RelativeSource={RelativeSource Self}}" Value="">
|
||||
<Setter Property="Visibility" Value="Visible" TargetName="mask"/>
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
|
||||
<Condition Property="IsSelectionActive" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
|
||||
<Style TargetType="TextBox" x:Key="NormalTextBoxStyle">
|
||||
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
|
||||
<Setter Property="BorderBrush" Value="{StaticResource TextBox.Static.Border}"/>
|
||||
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
|
||||
<Setter Property="BorderThickness" Value="1"/>
|
||||
<Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="AllowDrop" Value="true"/>
|
||||
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
Background="{TemplateBinding Background}"
|
||||
SnapsToDevicePixels="True"
|
||||
CornerRadius="5" Height="30">
|
||||
<ScrollViewer x:Name="PART_ContentHost" Grid.Column="1" Focusable="false"
|
||||
VerticalAlignment="Center" Margin="5,0"
|
||||
HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsEnabled" Value="false">
|
||||
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsMouseOver" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.MouseOver.Border}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsKeyboardFocused" Value="true">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="{StaticResource TextBox.Focus.Border}"/>
|
||||
</Trigger>
|
||||
<Trigger Property="IsReadOnly" Value="True">
|
||||
<Setter TargetName="border" Property="Background" Value="#F7F9FA"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsInactiveSelectionHighlightEnabled" Value="true"/>
|
||||
<Condition Property="IsSelectionActive" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="SelectionBrush" Value="{DynamicResource {x:Static SystemColors.InactiveSelectionHighlightBrushKey}}"/>
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,31 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}">
|
||||
<Setter Property="Width" Value="45"></Setter>
|
||||
<Setter Property="Height" Value="20"></Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ToggleButton">
|
||||
<!--定义视觉树-->
|
||||
<Border x:Name="border" BorderThickness="1.5" CornerRadius="9" BorderBrush="#aaa" Background="#2790ff">
|
||||
<Grid x:Name="togglebutton" HorizontalAlignment="Right" >
|
||||
<Border Width="17" Height="17" CornerRadius="9" Background="White"/>
|
||||
</Grid>
|
||||
<!--阴影设置-->
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="Gray" BlurRadius="5" ShadowDepth="0" Opacity="0.5" />
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
<!--定义触发器-->
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsChecked" Value="false">
|
||||
<Setter TargetName="border" Property="Background" Value="#ccc"/>
|
||||
<Setter TargetName="togglebutton" Property="HorizontalAlignment" Value="Left"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,96 @@
|
||||
using Prism.Commands;
|
||||
using Prism.Mvvm;
|
||||
using Prism.Regions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.Common
|
||||
{
|
||||
public abstract class ViewModelBase : BindableBase
|
||||
{
|
||||
// * 未保存
|
||||
public string PageTitle { get; set; } = "标签标题";
|
||||
public bool IsCanClose { get; set; } = true;
|
||||
|
||||
private string NavUri { get; set; }
|
||||
|
||||
private DateTime date = DateTime.Now.Date;
|
||||
public DateTime Date
|
||||
{
|
||||
get { return date; }
|
||||
set { SetProperty(ref date, value); }
|
||||
}
|
||||
|
||||
private DateTime _startTime = DateTime.Now;
|
||||
public DateTime StartTime
|
||||
{
|
||||
get { return _startTime; }
|
||||
set { SetProperty(ref _startTime, DateTime.Parse(Date.ToString("yyyy-MM-dd") + " " + value.ToString("HH:mm:ss"))); }
|
||||
}
|
||||
|
||||
private DateTime _endTime = DateTime.Now;
|
||||
public DateTime EndTime
|
||||
{
|
||||
get { return _endTime; }
|
||||
set { SetProperty(ref _endTime, DateTime.Parse(Date.ToString("yyyy-MM-dd") + " " + value.ToString("HH:mm:ss"))); }
|
||||
}
|
||||
|
||||
private DateTime _startDateTime = DateTime.Now;
|
||||
public DateTime StartDateTime
|
||||
{
|
||||
get { return _startDateTime; }
|
||||
set { SetProperty(ref _startDateTime, value); }
|
||||
}
|
||||
|
||||
private DateTime _endDateTime = DateTime.Now;
|
||||
public DateTime EndDateTime
|
||||
{
|
||||
get { return _endDateTime; }
|
||||
set { SetProperty(ref _endDateTime, value); }
|
||||
}
|
||||
//条码
|
||||
private string code = string.Empty;
|
||||
public string Code
|
||||
{
|
||||
get { return code; }
|
||||
set { SetProperty(ref code, value); }
|
||||
}
|
||||
public DelegateCommand CloseCommand
|
||||
{
|
||||
get => new DelegateCommand(() =>
|
||||
{
|
||||
// 关闭操作
|
||||
// 根据URI获取对应的已注册对象名称
|
||||
var obj = _unityContainer.Registrations.FirstOrDefault(v => v.Name == NavUri);
|
||||
string name = obj.MappedToType.Name;
|
||||
// 根据对象名称再从Region的Views里面找到对象
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
{
|
||||
var region = _regionManager.Regions["MainContentRegion"];
|
||||
var view = region.Views.FirstOrDefault(v => v.GetType().Name == name);
|
||||
// 把这个对象从Region的Views里移除
|
||||
if (view != null)
|
||||
region.Remove(view);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public DelegateCommand RefreshCommand { get => new DelegateCommand(Refresh); }
|
||||
|
||||
protected IUnityContainer _unityContainer;
|
||||
protected IRegionManager _regionManager;
|
||||
public ViewModelBase(IUnityContainer unityContainer, IRegionManager regionManager)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
_regionManager = regionManager;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public virtual void Refresh() { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" /></startup></configuration>
|
||||
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="BouncyCastle.Cryptography" version="2.2.1" targetFramework="net472" />
|
||||
<package id="Enums.NET" version="4.0.1" targetFramework="net472" />
|
||||
<package id="MathNet.Numerics.Signed" version="4.15.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net472" />
|
||||
<package id="Microsoft.Bcl.HashCode" version="1.1.1" targetFramework="net472" />
|
||||
<package id="Microsoft.CSharp" version="4.7.0" targetFramework="net472" />
|
||||
<package id="Microsoft.IO.RecyclableMemoryStream" version="2.3.2" targetFramework="net472" />
|
||||
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.31" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.3" targetFramework="net472" />
|
||||
<package id="NPOI" version="2.6.2" targetFramework="net472" />
|
||||
<package id="Prism.Core" version="8.1.97" targetFramework="net472" />
|
||||
<package id="Prism.Unity" version="8.1.97" targetFramework="net472" />
|
||||
<package id="Prism.Wpf" version="8.1.97" targetFramework="net472" />
|
||||
<package id="SharpZipLib" version="1.3.3" targetFramework="net472" />
|
||||
<package id="SixLabors.Fonts" version="1.0.0" targetFramework="net472" />
|
||||
<package id="SixLabors.ImageSharp" version="2.1.4" targetFramework="net472" />
|
||||
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
|
||||
<package id="System.Memory" version="4.5.5" targetFramework="net472" />
|
||||
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net472" />
|
||||
<package id="System.Runtime.CompilerServices.Unsafe" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.AccessControl" version="6.0.0" targetFramework="net472" />
|
||||
<package id="System.Security.Cryptography.Xml" version="6.0.1" targetFramework="net472" />
|
||||
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Encoding.CodePages" version="5.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Encodings.Web" version="7.0.0" targetFramework="net472" />
|
||||
<package id="System.Text.Json" version="7.0.2" targetFramework="net472" />
|
||||
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net472" />
|
||||
<package id="System.ValueTuple" version="4.5.0" targetFramework="net472" />
|
||||
<package id="Unity.Abstractions" version="5.11.7" targetFramework="net472" />
|
||||
<package id="Unity.Container" version="5.11.11" targetFramework="net472" />
|
||||
</packages>
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Cowain.Preheat.Communication.PLC;
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using Cowain.Preheat.Communication.FTP;
|
||||
using Cowain.Preheat.Communication.MOM;
|
||||
using Cowain.Preheat.Communication.Scan;
|
||||
using Cowain.Preheat.Communication.Sokects;
|
||||
using Prism.Ioc;
|
||||
using Prism.Modularity;
|
||||
using Unity;
|
||||
using Cowain.Bake.Communication.PLC;
|
||||
|
||||
namespace Cowain.Preheat.Communication
|
||||
{
|
||||
[Module(ModuleName = "CommunicationModule")]
|
||||
public class CommunicationModule : IModule
|
||||
{
|
||||
public void OnInitialized(IContainerProvider containerProvider) //IContainerProvider
|
||||
{
|
||||
containerProvider.Resolve<PLCManage>();
|
||||
containerProvider.Resolve<ScanCodeManage>();
|
||||
containerProvider.Resolve<HttpServer>();
|
||||
//containerProvider.Resolve<FtpHelper>();
|
||||
|
||||
}
|
||||
|
||||
public void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
containerRegistry.RegisterSingleton<PLCManage>();
|
||||
containerRegistry.RegisterSingleton<ScanCodeManage>();
|
||||
containerRegistry.RegisterSingleton<HttpServer>();
|
||||
containerRegistry.RegisterSingleton<GenericFun>();
|
||||
containerRegistry.Register<FtpHelper>();
|
||||
containerRegistry.Register<FTPUpload>();
|
||||
containerRegistry.Register<FTPElapsedDelete>();
|
||||
containerRegistry.RegisterSingleton<MESProcess>();
|
||||
containerRegistry.RegisterSingleton<PLCBlockingCollection>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,365 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{152AAF38-8F84-4EBB-93C0-15C71C2B85EB}</ProjectGuid>
|
||||
<OutputType>library</OutputType>
|
||||
<RootNamespace>Cowain.Injecting.Communication</RootNamespace>
|
||||
<AssemblyName>Cowain.Preheat.Communication</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
<!-- 将此版本号设置为 8.0 或更高 -->
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Communication">
|
||||
<HintPath>..\Libs\Communication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cowain.Preheat.BLL">
|
||||
<HintPath>..\Cowain.Preheat.BLL\bin\Debug\Cowain.Preheat.BLL.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cowain.Preheat.Common">
|
||||
<HintPath>..\Cowain.Preheat.Common\bin\Debug\Cowain.Preheat.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Cowain.Preheat.Model">
|
||||
<HintPath>..\Cowain.Preheat.Model\bin\Debug\Cowain.Preheat.Model.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="FluentFTP, Version=46.0.2.0, Culture=neutral, PublicKeyToken=f4af092b1d8df44f, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\FluentFTP.46.0.2\lib\net472\FluentFTP.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HandyControl, Version=3.4.0.0, Culture=neutral, PublicKeyToken=45be8712787a1e5b, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\HandyControl.3.4.0\lib\net472\HandyControl.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="HslCommunication">
|
||||
<HintPath>..\Libs\HslCommunication.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Keyence.AutoID.SDK">
|
||||
<HintPath>..\Libs\Keyence.AutoID.SDK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.7.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.CSharp.Scripting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.CSharp.Scripting.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.Scripting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.CodeAnalysis.Scripting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.CodeAnalysis.Scripting.Common.2.0.0\lib\netstandard1.3\Microsoft.CodeAnalysis.Scripting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.31\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Bindings.Https">
|
||||
<HintPath>..\Libs\Opc.Ua.Bindings.Https.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Client">
|
||||
<HintPath>..\Libs\Opc.Ua.Client.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.ClientControls">
|
||||
<HintPath>..\Libs\Opc.Ua.ClientControls.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Configuration">
|
||||
<HintPath>..\Libs\Opc.Ua.Configuration.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Core">
|
||||
<HintPath>..\Libs\Opc.Ua.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Security.Certificates">
|
||||
<HintPath>..\Libs\Opc.Ua.Security.Certificates.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Opc.Ua.Server">
|
||||
<HintPath>..\Libs\Opc.Ua.Server.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpcUaHelper, Version=2.1.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\OpcUaHelper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism">
|
||||
<HintPath>..\Libs\Prism.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Unity.Wpf">
|
||||
<HintPath>..\Libs\Prism.Unity.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Prism.Wpf">
|
||||
<HintPath>..\Libs\Prism.Wpf.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.AppContext, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.AppContext.4.3.0\lib\net463\System.AppContext.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Collections.Specialized, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Collections.Specialized.4.3.0\lib\net46\System.Collections.Specialized.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ComponentModel.Composition" />
|
||||
<Reference Include="System.Configuration" />
|
||||
<Reference Include="System.Console, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Console.4.3.0\lib\net46\System.Console.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Diagnostics.FileVersionInfo, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Diagnostics.StackTrace, Version=4.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Formats.Asn1">
|
||||
<HintPath>..\Libs\System.Formats.Asn1.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.IO, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.4.3.0\lib\net462\System.IO.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.Compression, Version=4.1.2.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.IO.FileSystem.Primitives, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Linq, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Linq.4.3.0\lib\net463\System.Linq.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Linq.Expressions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Linq.Expressions.4.3.0\lib\net463\System.Linq.Expressions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.NameResolution, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Net.NameResolution.4.3.0\lib\net46\System.Net.NameResolution.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Security, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Net.Security.4.3.0\lib\net46\System.Net.Security.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Sockets, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Net.Sockets.4.3.0\lib\net46\System.Net.Sockets.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Numerics" />
|
||||
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Reflection, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.4.3.0\lib\net462\System.Runtime.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Extensions, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.Extensions.4.3.0\lib\net462\System.Runtime.Extensions.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.InteropServices, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Runtime.InteropServices.4.3.0\lib\net463\System.Runtime.InteropServices.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Algorithms, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net463\System.Security.Cryptography.Algorithms.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Encoding, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.Primitives, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Security.Cryptography.X509Certificates, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encoding.CodePages, Version=9.0.0.6, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encoding.CodePages.9.0.6\lib\net462\System.Text.Encoding.CodePages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Encodings.Web, Version=7.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Encodings.Web.7.0.0\lib\net462\System.Text.Encodings.Web.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Text.Json, Version=7.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Text.Json.7.0.2\lib\net462\System.Text.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Threading.Thread, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.ReaderWriter, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XmlDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XPath, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.XPath.XDocument, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll</HintPath>
|
||||
<Private>True</Private>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Abstractions, Version=5.11.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Unity.Abstractions.5.11.7\lib\net47\Unity.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Container, Version=5.11.11.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Unity.Container.5.11.11\lib\net47\Unity.Container.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CommunicationModule.cs" />
|
||||
<Compile Include="GenericFun.cs" />
|
||||
<Compile Include="Interface\IScanCodeBase.cs" />
|
||||
<Compile Include="FTP\FTPElapsedDelete.cs" />
|
||||
<Compile Include="FTP\FTPUpload.cs" />
|
||||
<Compile Include="Interface\IPLCDevice.cs" />
|
||||
<Compile Include="Interface\IPLCService.cs" />
|
||||
<Compile Include="MES\HttpClientHelper.cs" />
|
||||
<Compile Include="MES\MESProcess.cs" />
|
||||
<Compile Include="Models\ExOperateResult.cs" />
|
||||
<Compile Include="PLC\PLCBlockingCollection.cs" />
|
||||
<Compile Include="PLC\PLC_OpcUaClient.cs" />
|
||||
<Compile Include="PLC\PLCBase.cs" />
|
||||
<Compile Include="PLC\PLCManage.cs" />
|
||||
<Compile Include="PLC\PLC_ModbusTcp.cs" />
|
||||
<Compile Include="PLC\PLC_OmronFins.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Scan\Honeywell.cs" />
|
||||
<Compile Include="Scan\Keyence.cs" />
|
||||
<Compile Include="Scan\ScanCodeManage.cs" />
|
||||
<Compile Include="FTP\FTPClient.cs" />
|
||||
<Compile Include="Sokects\HttpServer.cs" />
|
||||
<Compile Include="Sokects\TcpSokectClient.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
|
||||
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<WCFMetadata Include="Connected Services\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,193 @@
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using FluentFTP;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Cowain.Preheat.Communication.FTP
|
||||
{
|
||||
//现在是的是短连接,即上传完就关闭; 后期如果有效率上的要求,要改成长连接,就是过程中不关闭连接
|
||||
//建立好连接,约:700毫秒
|
||||
//关闭连接,约:90毫秒
|
||||
//全部都是远程操作
|
||||
public class FtpHelper
|
||||
{
|
||||
#region 属性与构造函数
|
||||
public FtpClient ftpClient { get; set; } ///
|
||||
public string IpAddr { get; set; } /// IP地址
|
||||
public string RelatePath { get; set; } /// 相对路径
|
||||
public int Port { get; set; } /// 端口号
|
||||
public string UserName { get; set; } /// 用户名
|
||||
public string Password { get; set; } /// 密码
|
||||
public bool IsConnected { get; set; } = false;
|
||||
|
||||
//https://blog.csdn.net/fengershishe/article/details/129140618
|
||||
|
||||
public FtpHelper(string ipAddr, int port, string userName, string password, string relatePath = "")
|
||||
{
|
||||
this.IpAddr = ipAddr;
|
||||
this.Port = port;
|
||||
this.UserName = userName;
|
||||
this.Password = password;
|
||||
//this.RelatePath = relatePath;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool Connect()
|
||||
{
|
||||
try
|
||||
{
|
||||
Close();
|
||||
//using (var ftpClient = new FtpClient(this.IpAddr, this.UserName, this.Password, this.Port))
|
||||
ftpClient = new FtpClient(this.IpAddr, this.Port);
|
||||
ftpClient.Connect(); // 连接到FTP服务器
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.Error($"Ftp Connect {ex.Message}");
|
||||
IsConnected = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
IsConnected = ftpClient.IsConnected;
|
||||
return IsConnected;
|
||||
}
|
||||
|
||||
bool IsConnect()
|
||||
{
|
||||
if (null == ftpClient || !ftpClient.IsConnected || !IsConnected)
|
||||
{
|
||||
Connect();
|
||||
}
|
||||
|
||||
return IsConnected;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
if (null != ftpClient)
|
||||
{
|
||||
ftpClient.Disconnect();
|
||||
ftpClient.Dispose();
|
||||
ftpClient = null;
|
||||
}
|
||||
}
|
||||
|
||||
~FtpHelper()
|
||||
{
|
||||
Close();
|
||||
}
|
||||
|
||||
#region 方法
|
||||
public FtpListItem[] ListDir()
|
||||
{
|
||||
FtpListItem[] lists = null;
|
||||
if (IsConnect())
|
||||
{
|
||||
ftpClient.SetWorkingDirectory(this.RelatePath);
|
||||
lists = ftpClient.GetListing(); //当前路径下,返回所有文件
|
||||
}
|
||||
return lists;
|
||||
}
|
||||
|
||||
// 上传文件
|
||||
public bool UpLoad(string srcFilePath, string descPath)
|
||||
{
|
||||
string descFilePath = null;
|
||||
try
|
||||
{
|
||||
if (IsConnect())
|
||||
{
|
||||
string fileName = Path.GetFileName(srcFilePath);
|
||||
char lastChar = descPath[descPath.Length - 1];
|
||||
|
||||
if ('\\' == lastChar
|
||||
|| '/' == lastChar)
|
||||
{
|
||||
descFilePath = descPath + fileName; //descPath, 最后一个,是"/"
|
||||
}
|
||||
else
|
||||
{
|
||||
descFilePath = descPath + "/" + fileName; //descPath, 最后一个,是"/"
|
||||
}
|
||||
|
||||
FtpStatus result = ftpClient.UploadFile(srcFilePath, descFilePath); // ("local/file.txt", "remote/file.txt");
|
||||
return FtpStatus.Success == result ? true : false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IsConnected = false;
|
||||
LogHelper.Instance.Error($"Ftp UpLoad {ex.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
///创建目录(远程创建)
|
||||
private bool CheckDirIsExists(string dir)
|
||||
{
|
||||
bool flag = false;
|
||||
try
|
||||
{
|
||||
if (IsConnect())
|
||||
{
|
||||
ftpClient.SetWorkingDirectory(this.RelatePath);
|
||||
flag = ftpClient.DirectoryExists(dir);
|
||||
if (!flag)
|
||||
{
|
||||
flag = ftpClient.CreateDirectory(dir); //client.CreateDirectory("remote/directory");
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IsConnected = false;
|
||||
LogHelper.Instance.Error($"Ftp CheckDirIsExists {ex.Message}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DeleteFile(string dir)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsConnect())
|
||||
{
|
||||
ftpClient.SetWorkingDirectory(this.RelatePath);
|
||||
ftpClient.DeleteFile(dir);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IsConnected = false;
|
||||
LogHelper.Instance.Error($"Ftp DeleteFile {ex.Message}");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool DownloadFile(string localAddress, string remoteAddress)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsConnect())
|
||||
{
|
||||
ftpClient.SetWorkingDirectory(this.RelatePath);
|
||||
FtpStatus status = ftpClient.DownloadFile(localAddress, remoteAddress);
|
||||
return status == FtpStatus.Success ? true : false;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
IsConnected = false;
|
||||
LogHelper.Instance.Error($"Ftp DownloadFile {ex.Message}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
using Cowain.Preheat.Common;
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Timers;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Preheat.Communication.FTP
|
||||
{
|
||||
//定时删除文件
|
||||
public class FTPElapsedDelete
|
||||
{
|
||||
Timer timer;
|
||||
string _deleteFilePath;
|
||||
int _intervalDays;
|
||||
public string Name { get; set; }
|
||||
public IUnityContainer _unityContainer { get; set; }
|
||||
public FTPElapsedDelete(IUnityContainer unityContainer)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
}
|
||||
|
||||
public void Start(string filePath, int intervalDays)
|
||||
{
|
||||
_deleteFilePath = filePath;
|
||||
_intervalDays = intervalDays;
|
||||
CreateTimer();
|
||||
}
|
||||
|
||||
void CreateTimer()
|
||||
{
|
||||
// 创建定时器并设置时间间隔为一天
|
||||
//timer = new Timer();
|
||||
timer = new Timer(TimeSpan.FromHours(12).TotalMilliseconds); //一天执行二次删除,一次就够了,怕晚上不上班
|
||||
|
||||
//timer.Interval = 10 * 1000; // 一个小时
|
||||
timer.Elapsed += TimerElapsedDeleteFiles;
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
timer.Stop();
|
||||
timer.Elapsed -= TimerElapsedDeleteFiles;
|
||||
timer.Dispose();
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
//可配置定期删除日志文件
|
||||
void TimerElapsedDeleteFiles(object sender, ElapsedEventArgs e)
|
||||
{
|
||||
if (Global.AppExit)
|
||||
{
|
||||
Stop();
|
||||
}
|
||||
string[] files = Directory.GetFiles(_deleteFilePath, "*", SearchOption.AllDirectories);
|
||||
try
|
||||
{
|
||||
foreach (string file in files)
|
||||
{
|
||||
FileInfo fileInfo = new FileInfo(file); //后期有必要再多年是否上传属性,上传了就删除
|
||||
TimeSpan timeDifference = DateTime.Now - fileInfo.CreationTime;
|
||||
if (timeDifference.TotalDays >= _intervalDays)
|
||||
{
|
||||
File.SetAttributes(file, FileAttributes.Normal);
|
||||
File.Delete(file); //"对路径“”的访问被拒绝"
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogHelper.Instance.Error($"删除文件失败,_deleteFilePath:{_deleteFilePath},异常:{ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
using Cowain.Preheat.Common;
|
||||
using Cowain.Preheat.Common.Core;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
using Unity.Resolution;
|
||||
|
||||
namespace Cowain.Preheat.Communication.FTP
|
||||
{
|
||||
public class FTPUpload
|
||||
{
|
||||
string _localFolderPath;
|
||||
string _remoteFolderPath;
|
||||
FtpHelper ftpClient;
|
||||
public string Name { get; set; }
|
||||
public IUnityContainer _unityContainer { get; set; }
|
||||
public FTPUpload(IUnityContainer unityContainer)
|
||||
{
|
||||
_unityContainer = unityContainer;
|
||||
|
||||
ftpClient = _unityContainer.Resolve<FtpHelper>(new ParameterOverride("ipAddr","10.19.30.19"), new ParameterOverride("port", 21),
|
||||
new ParameterOverride("userName", (object)"admin"), new ParameterOverride("password", (object)"123456"));
|
||||
ftpClient.Connect();
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
ftpClient.Close();
|
||||
}
|
||||
|
||||
public void Start(string src, string desc)
|
||||
{
|
||||
_localFolderPath = src;
|
||||
_remoteFolderPath = desc;
|
||||
|
||||
Task.Run(async () =>
|
||||
{
|
||||
while(true)
|
||||
{
|
||||
await Task.Delay(1000);
|
||||
if (Global.AppExit)
|
||||
{
|
||||
ftpClient.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
UploadToFTPService();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//string localFolderPath = @"E:\svn\CutingStack\CuttingStackingMachine\成都蜂巢6074\tex"; //本地要上传的文件位置 (界面可配)
|
||||
//string remoteFolderPath = "/"; //MES服务要上传到的位置 (界面可配)
|
||||
void UploadToFTPService()
|
||||
{
|
||||
// 获取文件夹及其子文件夹中的所有文件
|
||||
string[] files = Directory.GetFiles(_localFolderPath, "*", SearchOption.AllDirectories);
|
||||
//string[] files = Directory.GetFiles(localFolderPath);
|
||||
try
|
||||
{
|
||||
// 遍历每个文件
|
||||
foreach (string file in files)
|
||||
{
|
||||
if (IsUpload(file))
|
||||
{
|
||||
if (ftpClient.UpLoad(file, _remoteFolderPath))
|
||||
{
|
||||
SetFileReadAccess(file, true); //上传的文件做标识(设为可读)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
LogHelper.Instance.Error($"上传文件失败,localFolderPath:{_localFolderPath},remoteFolderPath:{_remoteFolderPath},异常:{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
//是否上传:可读为假就上传,为真不上传
|
||||
bool IsUpload(string filePath)
|
||||
{
|
||||
return !IsFileReadable(filePath); //默认为假,不可读(可写)
|
||||
}
|
||||
|
||||
//读为可读
|
||||
public void SetFileReadAccess(string filePath, bool readOnly)
|
||||
{
|
||||
FileInfo fInfo = new FileInfo(filePath);
|
||||
fInfo.IsReadOnly = readOnly;
|
||||
}
|
||||
|
||||
public bool IsFileReadable(string filePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileAttributes attributes = File.GetAttributes(filePath);
|
||||
bool isReadable = (attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly;
|
||||
return isReadable;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"判断文件可读性时出现错误: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using Cowain.Preheat.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Cowain.Preheat.Communication
|
||||
{
|
||||
public class GenericFun
|
||||
{
|
||||
//public string GetVariableValue<T>(Expression<Func<T>> expr, List<TDeviceParam> devParms)
|
||||
//{
|
||||
// var memberExpr = (MemberExpression)expr.Body;
|
||||
|
||||
// foreach (var item in devParms)
|
||||
// {
|
||||
// if (memberExpr.Member.Name == item.Key)
|
||||
// {
|
||||
// return item.Value;
|
||||
// }
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public T ConvertToType<T>(string value)
|
||||
{
|
||||
if (null == value)
|
||||
{
|
||||
return default(T);
|
||||
}
|
||||
// 使用Convert.ChangeType将字符串转换为泛型类型T
|
||||
return (T)Convert.ChangeType(value, typeof(T));
|
||||
}
|
||||
}
|
||||
}
|
||||