首次提交:添加src文件夹代码
This commit is contained in:
45
Cowain.Bake.BLL/Converter/CavityInfoIdConverter.cs
Normal file
45
Cowain.Bake.BLL/Converter/CavityInfoIdConverter.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Cowain.Bake.BLL.Converter
|
||||
{
|
||||
public class CavityInfoIdConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is int val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().CavityInfo.Where(x => x.Id == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().CavityInfo.Where(x => x.Name == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Id;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
30
Cowain.Bake.BLL/Converter/InvalidConvertor.cs
Normal file
30
Cowain.Bake.BLL/Converter/InvalidConvertor.cs
Normal file
@@ -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.Bake.Common.Enums;
|
||||
|
||||
namespace Cowain.Bake.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Cowain.Bake.BLL/Converter/LogTypeConverter.cs
Normal file
26
Cowain.Bake.BLL/Converter/LogTypeConverter.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Bake.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Cowain.Bake.BLL/Converter/PalletIdConverter.cs
Normal file
33
Cowain.Bake.BLL/Converter/PalletIdConverter.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Cowain.Bake.BLL.Converter
|
||||
{
|
||||
public class PalletIdConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is int val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().GetPalletInfoById(val);
|
||||
if (null == p)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.PalletCode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
33
Cowain.Bake.BLL/Converter/PalletVirtualIdConverter.cs
Normal file
33
Cowain.Bake.BLL/Converter/PalletVirtualIdConverter.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Cowain.Bake.BLL.Converter
|
||||
{
|
||||
public class PalletVirtualIdConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is int val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().GetPalletInfoByVirtualId(val);
|
||||
if (null == p)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.PalletCode;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Cowain.Bake.BLL/Converter/ProcessParamIdConvertor.cs
Normal file
32
Cowain.Bake.BLL/Converter/ProcessParamIdConvertor.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Cowain.Bake.BLL.Converter
|
||||
{
|
||||
public class ProcessParamIdConvertor : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is int val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().GetProcessParam(val);
|
||||
if (null == p)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.ProcessParamName;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
31
Cowain.Bake.BLL/Converter/RoleConvertor.cs
Normal file
31
Cowain.Bake.BLL/Converter/RoleConvertor.cs
Normal file
@@ -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.Bake.Common.Enums;
|
||||
|
||||
|
||||
namespace Cowain.Bake.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
Cowain.Bake.BLL/Converter/StationIdConverter.cs
Normal file
47
Cowain.Bake.BLL/Converter/StationIdConverter.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Cowain.Bake.BLL.Converter
|
||||
{
|
||||
public class StationIdConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
if (value is int val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().AllStation.Where(x => x.Id == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Desc;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().AllStation.Where(x => x.Name == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Id;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Cowain.Bake.BLL/Converter/TaskTypeConverter.cs
Normal file
45
Cowain.Bake.BLL/Converter/TaskTypeConverter.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Windows.Data;
|
||||
using Prism.Ioc;
|
||||
|
||||
namespace Cowain.Bake.BLL.Converter
|
||||
{
|
||||
public class TaskTypeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is int val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().TaskType.Where(x => x.Id == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return "手动任务";
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is string val)
|
||||
{
|
||||
var p = MyAppContainer.Current.Resolve<MemoryDataProvider>().TaskType.Where(x => x.Name == val).FirstOrDefault();
|
||||
if (null == p)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return p.Id;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
77
Cowain.Bake.BLL/Converter/VarValueConverter.cs
Normal file
77
Cowain.Bake.BLL/Converter/VarValueConverter.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using Cowain.Bake.Common.Models;
|
||||
using Cowain.Bake.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.Bake.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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user