You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.4 KiB
C#

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SlnMesnac.Model.domain;
using SlnMesnac.Repository.service;
using SlnMesnac.WPF;
using SlnMesnac.WPF.Page;
using System;
using System.Collections.Generic;
using System.Text;
#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* (c) 2024 WenJY
* CLR4.0.30319.42000
* LAPTOP-E0N2L34V
* SlnMesnac.Model.dto
* 96940a51-66a8-4593-b68d-e4d7fdb16c9b
*
* WenJY
* wenjy@mesnac.com
* 2024-04-12 11:07:33
* V1.0.0
*
*
*--------------------------------------------------------------------
*
*
*
*
* V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.Model
{
/// <summary>
/// 配方管理封装对象
/// </summary>
public class RecipeManageCache
{
#region 单例实现
private static readonly RecipeManageCache lazy = new RecipeManageCache();
public static RecipeManageCache Instance
{
get
{
return lazy;
}
}
#endregion
#region 变量定义
private readonly ILogger<RecipeManageCache> _logger;
private readonly IBaseRecipeManageService? baseRecipeManageService;
public List<RecipeManage> recipeManageList = null;
#endregion
public RecipeManageCache()
{
baseRecipeManageService = App.ServiceProvider.GetService<IBaseRecipeManageService>();
recipeManageList = baseRecipeManageService.GetRecipeManageList();
}
/// <summary>
/// 更新配方
/// </summary>
/// <param name="recipeManage"></param>
public void UpdateRecipeManage(RecipeManage recipeManage)
{
try
{
baseRecipeManageService.UpdateRecipeManage(recipeManage);
//刷新缓存
recipeManageList = baseRecipeManageService.GetRecipeManageList();
}
catch (Exception ex)
{
_logger.LogError($"UpdateRecipeManage异常:{ex.Message}");
}
}
}
}