@@ -0,0 +1,12 @@ | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public interface IMessage | |||
{ | |||
} | |||
} |
@@ -6,7 +6,7 @@ using System.Threading.Tasks; | |||
namespace BPASmart.Model | |||
{ | |||
public class PublishInfo | |||
public class PublishInfo : IMessage | |||
{ | |||
public List<PublishModel> PublishModels { get; set; } = new List<PublishModel>(); | |||
} | |||
@@ -5,10 +5,10 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.用户 | |||
namespace BPASmart.Model | |||
{ | |||
public class LocalUser | |||
{ | |||
public ObservableCollection<UserManager> UserManagers { get; set; } = new ObservableCollection<UserManager>(); | |||
public ObservableCollection<UserManager> UserManagers { get; set; } = new ObservableCollection<UserManager>(); | |||
} | |||
} |
@@ -4,7 +4,7 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.用户 | |||
namespace BPASmart.Model | |||
{ | |||
public class UserManager | |||
{ | |||
@@ -5,7 +5,7 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
namespace BPASmart.Model | |||
{ | |||
public class LocalMaterails | |||
{ | |||
@@ -6,11 +6,11 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
namespace BPASmart.Model | |||
{ | |||
public class LocalRecipes | |||
public class LocalRecipes | |||
{ | |||
public ObservableCollection<Recipes> locaRecipes { get; set; } = new ObservableCollection<Recipes>(); | |||
} | |||
} |
@@ -6,9 +6,9 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
namespace BPASmart.Model | |||
{ | |||
public class Order:ObservableObject | |||
public class Order : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 订单ID | |||
@@ -5,9 +5,9 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
namespace BPASmart.Model | |||
{ | |||
public class Property:ObservableObject | |||
public class Property : ObservableObject | |||
{ | |||
public string PropertyId { get { return _propertyId; } set { _propertyId = value; OnPropertyChanged(); } } | |||
private string _propertyId; | |||
@@ -6,9 +6,9 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
namespace BPASmart.Model | |||
{ | |||
public class RecipeMaterials:ObservableObject | |||
public class RecipeMaterials : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 原料ID | |||
@@ -18,7 +18,7 @@ namespace BPASmart.Model.配方 | |||
/// <summary> | |||
/// 物料名称 | |||
/// </summary> | |||
public string Name { get { return _name; } set { _name = value;OnPropertyChanged(); } } | |||
public string Name { get { return _name; } set { _name = value; OnPropertyChanged(); } } | |||
private string _name; | |||
/// <summary> | |||
/// 物料种类 | |||
@@ -33,7 +33,7 @@ namespace BPASmart.Model.配方 | |||
/// <summary> | |||
/// 原料位置 | |||
/// </summary> | |||
public string MaterialPosion { get { return _materialPosion; } set { _materialPosion = value;OnPropertyChanged(); } } | |||
public string MaterialPosion { get { return _materialPosion; } set { _materialPosion = value; OnPropertyChanged(); } } | |||
private string _materialPosion; | |||
/// <summary> | |||
@@ -43,7 +43,7 @@ namespace BPASmart.Model.配方 | |||
} | |||
public enum MaterialType | |||
{ | |||
{ | |||
无 = 0, | |||
干料 = 1, | |||
湿料 = 2, | |||
@@ -6,9 +6,9 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
namespace BPASmart.Model | |||
{ | |||
public class Recipes:ObservableObject | |||
public class Recipes : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 配方ID | |||
@@ -38,8 +38,8 @@ namespace BPASmart.Model.配方 | |||
/// </summary> | |||
public ObservableCollection<RecipeMaterials> recipeMaterials { get; set; } | |||
public ObservableCollection<TechnologyProcessModel> TechnologyProcessModels { get; set; } = new ObservableCollection<TechnologyProcessModel>(); | |||
public ObservableCollection<TechnologyProcessModel> TechnologyProcessModels { get; set; } = new ObservableCollection<TechnologyProcessModel>(); | |||
} | |||
@@ -5,15 +5,15 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
namespace BPASmart.Model.配方 | |||
namespace BPASmart.Model | |||
{ | |||
public class TechnologyProcessModel:ObservableObject | |||
public class TechnologyProcessModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 工艺步骤 | |||
/// </summary> | |||
public string Step { get { return _step; } set { _step = value; OnPropertyChanged(); } } | |||
public string Step { get { return _step; } set { _step = value; OnPropertyChanged(); } } | |||
private string _step; | |||
/// <summary> | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Collections.ObjectModel; | |||
@@ -18,7 +18,7 @@ namespace BPASmart.RecipeManagement.Globle | |||
/// <summary> | |||
/// 修改配方传值 | |||
/// </summary> | |||
public static Recipes ChangeRecipes = new Recipes(); | |||
public static Recipes ChangeRecipes = new Recipes(); | |||
/// <summary> | |||
/// | |||
@@ -28,6 +28,6 @@ namespace BPASmart.RecipeManagement.Globle | |||
/// <summary> | |||
/// 配方的工艺流程传值 | |||
/// </summary> | |||
public static Recipes recipeTechnologyProcess = new Recipes(); | |||
public static Recipes recipeTechnologyProcess = new Recipes(); | |||
} | |||
} |
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
@@ -9,10 +9,10 @@ using System.Linq; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class CreateOrderViewModel: ObservableObject | |||
public class CreateOrderViewModel : ObservableObject | |||
{ | |||
public ObservableCollection<Recipes> recipes { get; set; } = new ObservableCollection<Recipes>(); | |||
public ObservableCollection<Recipes> recipes { get; set; } = new ObservableCollection<Recipes>(); | |||
public ObservableCollection<string> recipesName { get; set; } = new ObservableCollection<string>(); | |||
@@ -24,8 +24,8 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
private void Delete(object o) | |||
{ | |||
if(o == null) return; | |||
if(o is string id) | |||
if (o == null) return; | |||
if (o is string id) | |||
{ | |||
var res = recipes.FirstOrDefault(x => x.ID == id); | |||
recipes.Remove(res); | |||
@@ -44,15 +44,15 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
}); | |||
ActionManage.GetInstance.Send("CloseCreateOrderView"); | |||
}); | |||
DeleteCommand = new RelayCommand<object>(Delete); | |||
AddRecipeCommand = new RelayCommand(() => | |||
{ | |||
recipes.Add(new Recipes() { ID = Guid.NewGuid().ToString() ,RecipeCount =1,}); | |||
recipes.Add(new Recipes() { ID = Guid.NewGuid().ToString(), RecipeCount = 1, }); | |||
}); | |||
foreach( var item in Json<LocalRecipes>.Data.locaRecipes ) | |||
foreach (var item in Json<LocalRecipes>.Data.locaRecipes) | |||
{ | |||
recipesName.Add(item.Name); | |||
} | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using System; | |||
@@ -9,7 +9,7 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class MainWindowViewModel: ObservableObject | |||
public class MainWindowViewModel : ObservableObject | |||
{ | |||
public MainWindowViewModel() | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmart.RecipeManagement.Globle; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
@@ -12,16 +12,16 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class MaterialConfigureViewModel:ObservableObject | |||
public class MaterialConfigureViewModel : ObservableObject | |||
{ | |||
public ObservableCollection<Property> currentProperty { get; set; } = new ObservableCollection<Property>(); | |||
public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } | |||
public string MaterialName { get { return _materialName; } set { _materialName = value; OnPropertyChanged(); } } | |||
private string _materialName; | |||
public ObservableCollection<MaterialType> MaterialTypes { get; set; } = new ObservableCollection<MaterialType>(); | |||
public MaterialType MaterialType { get{ return _materialType; } set { _materialType = value; OnPropertyChanged(); } } | |||
public MaterialType MaterialType { get { return _materialType; } set { _materialType = value; OnPropertyChanged(); } } | |||
private MaterialType _materialType = 0; | |||
public string MaterialPosion { get { return _materialPosion; } set { _materialPosion = value; OnPropertyChanged(); } } | |||
@@ -61,46 +61,46 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
MaterialName = GlobleData.ChangeMaterail.Name; | |||
MaterialType = GlobleData.ChangeMaterail.MaterialType; | |||
MaterialPosion = GlobleData.ChangeMaterail.MaterialPosion; | |||
foreach(var item in currentProperty) | |||
foreach (var item in currentProperty) | |||
{ | |||
var res = GlobleData.ChangeMaterail.PropertyCollections.FirstOrDefault(p => p.PropertyId == item.PropertyId); | |||
if (res != null) | |||
{ | |||
item.PropertyValue = res.PropertyValue; | |||
} | |||
} | |||
} | |||
foreach(MaterialType item in Enum.GetValues(typeof(MaterialType))) | |||
foreach (MaterialType item in Enum.GetValues(typeof(MaterialType))) | |||
{ | |||
MaterialTypes.Add(item); | |||
} | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
if(MaterialName == null) | |||
if (MaterialName == null) | |||
{ | |||
ErrorMessage = "原料名称不能为空"; | |||
return; | |||
} | |||
if(GlobleData.ChangeMaterail!=null)//编辑原料 | |||
{ | |||
var res = Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p=>p.ID == GlobleData.ChangeMaterail.ID); | |||
if (res != null) | |||
if (GlobleData.ChangeMaterail != null)//编辑原料 | |||
{ | |||
var res = Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p => p.ID == GlobleData.ChangeMaterail.ID); | |||
if (res != null) | |||
{ | |||
if (MaterialName != res.Name )//修改了原料名称 | |||
if (MaterialName != res.Name)//修改了原料名称 | |||
{ | |||
if (Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p => p.Name == MaterialName) != null) | |||
{ | |||
ErrorMessage = "原料名称已存在"; | |||
return ; | |||
return; | |||
} | |||
} | |||
if(MaterialPosion != res.MaterialPosion)//修改了原料位置 | |||
if (MaterialPosion != res.MaterialPosion)//修改了原料位置 | |||
{ | |||
if (Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p => p.MaterialPosion == MaterialPosion) != null) | |||
{ | |||
@@ -116,7 +116,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
} | |||
else //添加新原料 | |||
{ | |||
if(Json<LocalMaterails>.Data.locaMaterails != null) | |||
if (Json<LocalMaterails>.Data.locaMaterails != null) | |||
{ | |||
var res = Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p => p.Name == MaterialName); | |||
if (res != null) | |||
@@ -124,7 +124,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
ErrorMessage = "原料名称已存在"; | |||
return; | |||
} | |||
var item = Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p=>p.MaterialPosion == MaterialPosion); | |||
var item = Json<LocalMaterails>.Data.locaMaterails.FirstOrDefault(p => p.MaterialPosion == MaterialPosion); | |||
if (item != null) | |||
{ | |||
ErrorMessage = "原料位置重复"; | |||
@@ -134,7 +134,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
else | |||
{ | |||
AddMaterials(); | |||
} | |||
} | |||
} | |||
Json<LocalMaterails>.Save(); | |||
ActionManage.GetInstance.Send("CloseMaterialConfigureView"); | |||
@@ -5,7 +5,7 @@ using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using System.Collections.ObjectModel; | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
using BPASmart.RecipeManagement.View; | |||
using System.Windows.Controls; | |||
@@ -14,7 +14,7 @@ using BPASmartClient.Helper; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class MaterialManagerViewModel:ObservableObject | |||
public class MaterialManagerViewModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 原料集合 | |||
@@ -24,12 +24,12 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
public RelayCommand CreateMaterailCommand { get; set; } | |||
public RelayCommand<object> EditMaterailCommand { get; set; } | |||
public RelayCommand<object> DeleteMaterailCommand { get; set; } | |||
private void EditMaterail(object o) | |||
{ | |||
if(o == null) return; | |||
if(o is int item && item >= 0) | |||
if (o == null) return; | |||
if (o is int item && item >= 0) | |||
{ | |||
GlobleData.ChangeMaterail = new RecipeMaterials(); | |||
GlobleData.ChangeMaterail = MaterialList[item]; | |||
@@ -41,7 +41,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
private void DeleteMaterail(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is int item && item >= 0) | |||
if (o is int item && item >= 0) | |||
{ | |||
MaterialList.RemoveAt(item); | |||
Json<LocalMaterails>.Save(); | |||
@@ -50,7 +50,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
public MaterialManagerViewModel() | |||
{ | |||
CreateMaterailCommand = new RelayCommand(() => | |||
{ | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmart.RecipeManagement.View; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
@@ -11,7 +11,7 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class OrderManagerViewModel:ObservableObject | |||
public class OrderManagerViewModel : ObservableObject | |||
{ | |||
/// <summary> | |||
/// 订单集合 | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
@@ -11,7 +11,7 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class PowerManagerViewModel:ObservableObject | |||
public class PowerManagerViewModel : ObservableObject | |||
{ | |||
public ObservableCollection<string> UserName { get; set; } = new ObservableCollection<string>(); | |||
/// <summary> | |||
@@ -66,7 +66,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
UserMaterials.Clear(); | |||
foreach (RecipeMaterials item in AllMaterials) | |||
{ | |||
UserMaterials.Add(item); | |||
UserMaterials.Add(item); | |||
} | |||
} | |||
@@ -78,7 +78,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
UserRecipes.Add(item); | |||
} | |||
} | |||
} | |||
private void AddMaterial(object o) | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
@@ -11,7 +11,7 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class PropertySettingViewModel:ObservableObject | |||
public class PropertySettingViewModel : ObservableObject | |||
{ | |||
public ObservableCollection<Property> properties { get; set; } = Json<LocalMaterails>.Data.PorpertyCollections; | |||
@@ -31,7 +31,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
private void Delete(object o) | |||
{ | |||
if (o == null) return; | |||
if(o is string id) | |||
if (o is string id) | |||
{ | |||
var res = properties.FirstOrDefault(p => p.PropertyId == id); | |||
if (res != null) | |||
@@ -45,7 +45,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
if(PropertyName == null) | |||
if (PropertyName == null) | |||
{ | |||
ErrorName = "属性名称不能为空"; | |||
return; | |||
@@ -55,7 +55,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
ErrorName = "请添加属性说明"; | |||
return; | |||
} | |||
if(properties.FirstOrDefault(p=>p.PropertyName == PropertyName) != null) | |||
if (properties.FirstOrDefault(p => p.PropertyName == PropertyName) != null) | |||
{ | |||
ErrorName = "属性名重复"; | |||
return; | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmart.RecipeManagement.View; | |||
using BPASmartClient.Helper; | |||
using BPASmartClient.RecipeManagement.View; | |||
@@ -13,7 +13,7 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class RecipeManagerViewModel:ObservableObject | |||
public class RecipeManagerViewModel : ObservableObject | |||
{ | |||
public ObservableCollection<Recipes> RecipeList { get; set; } = Json<LocalRecipes>.Data.locaRecipes; | |||
@@ -26,7 +26,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
private void EditRecipe(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is int item && item >= 0) | |||
if (o is int item && item >= 0) | |||
{ | |||
Globle.GlobleData.ChangeRecipes = new Recipes(); | |||
Globle.GlobleData.ChangeRecipes = RecipeList[item]; | |||
@@ -48,16 +48,16 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
private void PecipeSetting(object o) | |||
{ | |||
if (o == null) return; | |||
if (o is string id ) | |||
if (o is string id) | |||
{ | |||
var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p=>p.ID == id); | |||
var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == id); | |||
if (res != null) | |||
{ | |||
Globle.GlobleData.recipeTechnologyProcess = null; | |||
Globle.GlobleData.recipeTechnologyProcess = res; | |||
TechnologyProcess technologyProcess = new TechnologyProcess(); | |||
technologyProcess.ShowDialog(); | |||
} | |||
} | |||
} | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
@@ -11,7 +11,7 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class RecipesConfigureViewModel:ObservableObject | |||
public class RecipesConfigureViewModel : ObservableObject | |||
{ | |||
public ObservableCollection<RecipeMaterials> recipeMaterials { get; set; } = new ObservableCollection<RecipeMaterials>(); | |||
@@ -26,7 +26,7 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
public string RecipeName { get { return _repiceName; } set { _repiceName = value; OnPropertyChanged(); } } | |||
private string _repiceName; | |||
public string ErrorMessage { get { return _errorMessage; } set { _errorMessage = value; OnPropertyChanged(); } } | |||
@@ -37,13 +37,13 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
public RelayCommand SaveCommand { get; set; } | |||
public RelayCommand<object> DeleteCommand { get; set; } | |||
private void Delete(object o) | |||
{ | |||
if (o == null) return; | |||
if(o is string id) | |||
if (o is string id) | |||
{ | |||
var res = recipeMaterials.FirstOrDefault(p=>p.ID == id); | |||
var res = recipeMaterials.FirstOrDefault(p => p.ID == id); | |||
if (res != null) recipeMaterials.Remove(res); | |||
} | |||
} | |||
@@ -60,17 +60,17 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
}); | |||
}); | |||
SaveCommand = new RelayCommand(() => | |||
{ | |||
if(RecipeName == null) | |||
if (RecipeName == null) | |||
{ | |||
ErrorMessage = "配方名称为空"; | |||
return; | |||
} | |||
if (Globle.GlobleData.ChangeRecipes!=null) | |||
if (Globle.GlobleData.ChangeRecipes != null) | |||
{ | |||
var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == Globle.GlobleData.ChangeRecipes.ID); | |||
res.recipeMaterials = recipeMaterials; | |||
@@ -84,9 +84,9 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
ErrorMessage = "配方名称已存在"; | |||
return; | |||
} | |||
Json<LocalRecipes>.Data.locaRecipes.Add(new Recipes | |||
{ | |||
ID = Guid.NewGuid().ToString() , | |||
Json<LocalRecipes>.Data.locaRecipes.Add(new Recipes | |||
{ | |||
ID = Guid.NewGuid().ToString(), | |||
Name = RecipeName, | |||
recipeMaterials = recipeMaterials | |||
}); | |||
@@ -104,12 +104,12 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
materialsName.Add(materail.Name); | |||
} | |||
} | |||
if(Globle.GlobleData.ChangeRecipes != null) | |||
if (Globle.GlobleData.ChangeRecipes != null) | |||
{ | |||
RecipeName = Globle.GlobleData.ChangeRecipes.Name.ToString(); | |||
recipeMaterials = Globle.GlobleData.ChangeRecipes.recipeMaterials; | |||
recipeMaterials = Globle.GlobleData.ChangeRecipes.recipeMaterials; | |||
} | |||
} | |||
} | |||
@@ -1,4 +1,4 @@ | |||
using BPASmart.Model.配方; | |||
using BPASmart.Model; | |||
using BPASmartClient.Helper; | |||
using Microsoft.Toolkit.Mvvm.ComponentModel; | |||
using Microsoft.Toolkit.Mvvm.Input; | |||
@@ -11,18 +11,18 @@ using System.Threading.Tasks; | |||
namespace BPASmart.RecipeManagement.ViewModel | |||
{ | |||
public class TechnologyProcessViewModel:ObservableObject | |||
public class TechnologyProcessViewModel : ObservableObject | |||
{ | |||
public static int currentItemId; | |||
public int Id { get { return _id; } set { _id = value; OnPropertyChanged(); } } | |||
private int _id = 0; | |||
public ObservableCollection<TechnologyProcessModel> technologyProcessModels { get; set; } = new ObservableCollection<TechnologyProcessModel>(); | |||
public ObservableCollection<TechnologyProcessModel> technologyProcessModels { get; set; } = new ObservableCollection<TechnologyProcessModel>(); | |||
public string currentRecipeName { get { return _currentRecipeName; } set { _currentRecipeName = value; OnPropertyChanged(); } } | |||
private string _currentRecipeName = string.Empty; | |||
public RelayCommand CloseWindowCommand { get; set; } | |||
@@ -36,11 +36,11 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
public TechnologyProcessViewModel() | |||
{ | |||
foreach(var item in Globle.GlobleData.recipeTechnologyProcess.recipeMaterials) | |||
foreach (var item in Globle.GlobleData.recipeTechnologyProcess.recipeMaterials) | |||
{ | |||
meterailItems.Add(item.Name); | |||
} | |||
ActionManage.GetInstance.Register(new Action<object>((obj) => | |||
{ | |||
if (obj != null) | |||
@@ -63,14 +63,14 @@ namespace BPASmart.RecipeManagement.ViewModel | |||
ConfirmCommand = new RelayCommand(() => | |||
{ | |||
var res = Json<LocalRecipes>.Data.locaRecipes.FirstOrDefault(p => p.ID == Globle.GlobleData.recipeTechnologyProcess.ID); | |||
if(res != null) | |||
if (res != null) | |||
{ | |||
res.TechnologyProcessModels.Clear(); | |||
res.TechnologyProcessModels = technologyProcessModels; | |||
} | |||
Json<LocalRecipes>.Save(); | |||
; | |||
; | |||
ActionManage.GetInstance.Send("CloseTechnologyProcessView"); | |||
}); | |||
@@ -10,6 +10,7 @@ | |||
<ItemGroup> | |||
<PackageReference Include="BPA.Communication" Version="1.0.19" /> | |||
<PackageReference Include="BPA.Helper" Version="1.0.15" /> | |||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.9" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
@@ -98,7 +98,18 @@ namespace BPASmart.Server | |||
{ | |||
while (msg.Count > 0) | |||
{ | |||
DeviceControl(); | |||
if (msg.TryDequeue(out string s)) | |||
{ | |||
var res = JsonConvert.DeserializeObject(s) as IMessage; | |||
if (res != null) | |||
{ | |||
if (res is PublishInfo _mPublishInfo) | |||
{ | |||
DeviceControl(_mPublishInfo); | |||
} | |||
} | |||
} | |||
} | |||
Thread.Sleep(100); | |||
}), "MQTT 消息监听"); | |||
@@ -109,14 +120,14 @@ namespace BPASmart.Server | |||
}); | |||
} | |||
private void DeviceControl() | |||
private void DeviceControl(PublishInfo publishInfo) | |||
{ | |||
if (msg.TryDequeue(out string s)) | |||
{ | |||
var res = JsonConvert.DeserializeObject<PublishInfo>(s); | |||
if (res != null) | |||
{ | |||
res.PublishModels.ForEach(item => | |||
//if (msg.TryDequeue(out string s)) | |||
//{ | |||
// var res = JsonConvert.DeserializeObject<PublishInfo>(s); | |||
// if (res != null) | |||
// { | |||
publishInfo.PublishModels.ForEach(item => | |||
{ | |||
if (CommunicationDevices.ContainsKey(item.DeviceName)) | |||
{ | |||
@@ -160,8 +171,8 @@ namespace BPASmart.Server | |||
} | |||
}); | |||
} | |||
} | |||
//} | |||
//} | |||
} | |||
private void SetValue(Array arrays, string DeviceName, ReadDataModel readDataModel, EDataType eDataType) | |||
@@ -0,0 +1,30 @@ | |||
using Microsoft.EntityFrameworkCore; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Linq; | |||
using System.Text; | |||
using System.Threading.Tasks; | |||
using BPASmart.Model; | |||
namespace BPASmart.Server | |||
{ | |||
public class SqliteHelper : DbContext | |||
{ | |||
string path | |||
{ | |||
get | |||
{ | |||
Directory.CreateDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"AccessFile\\DB")); | |||
return $"{AppDomain.CurrentDomain.BaseDirectory}AccessFile\\DB\\RecipeInfo.db"; | |||
} | |||
} | |||
//public DbSet<> | |||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | |||
{ | |||
optionsBuilder.UseSqlite($"FileName={path}"); | |||
} | |||
} | |||
} |