终端一体化运控平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

65 行
2.0 KiB

  1. using BPASmartClient.Helper;
  2. using BPASmartClient.Message;
  3. using FryPot_DosingSystem.Model;
  4. using Microsoft.Toolkit.Mvvm.ComponentModel;
  5. using Microsoft.Toolkit.Mvvm.Input;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace FryPot_DosingSystem.ViewModel
  13. {
  14. internal class RecipeSetDownViewModel : ObservableObject
  15. {
  16. /// <summary>
  17. /// 配方下发
  18. /// </summary>
  19. public RelayCommand<object> RecipeSetDownCommand { get; set; }
  20. /// <summary>
  21. /// 配方一键下发
  22. /// </summary>
  23. public RelayCommand AllRecipeSetDownCommand { get; set; }
  24. public ObservableCollection<NewRecipeModel> Recipes { get; set; } = new ObservableCollection<NewRecipeModel>();
  25. public RecipeSetDownViewModel()
  26. {
  27. Json<RecipeManage>.Read();
  28. Recipes = Json<RecipeManage>.Data.Recipes;
  29. RecipeSetDownCommand = new RelayCommand<object>((Id) =>
  30. {
  31. if (Id != null && Id is string strId)
  32. {
  33. var res = Recipes.FirstOrDefault(p => p.RecipeId == strId);
  34. if (res != null)
  35. {
  36. RecipeSetDown(new NewRecipeModel[] { res });
  37. }
  38. }
  39. });
  40. AllRecipeSetDownCommand = new RelayCommand(() =>
  41. {
  42. if (Recipes != null)
  43. {
  44. //foreach (var recipeModel in Recipes)
  45. //{
  46. // RecipeSetDown(recipeModel);
  47. //}
  48. RecipeSetDown(Recipes.ToArray());
  49. }
  50. });
  51. }
  52. /// <summary>
  53. /// 数据下发方法
  54. /// </summary>
  55. public void RecipeSetDown(NewRecipeModel[] recipes)
  56. {
  57. ActionManage.GetInstance.Send("RecipeSetDown", recipes);
  58. }
  59. }
  60. }