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.

171 lines
4.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mesnac.Action.Feeding.Qingquan.BasicInfo
{
/// <summary>
/// 配方数据缓存类,每次下传配方、配方重传时进行缓存,方便存盘时使用
/// </summary>
public class RecipeCache
{
#region 单例实现
private static RecipeCache _instance = null;
private RecipeCache()
{
}
/// <summary>
/// 配方数据缓存实例
/// </summary>
public static RecipeCache Instance
{
get
{
if (_instance == null)
{
_instance = new RecipeCache();
}
return _instance;
}
}
#endregion
#region 属性定义
private RecipeData.RecipeInfo _recipeInfo = new RecipeData.RecipeInfo(); //配方主信息
private RecipeData.PptPlanInfo _planInfo = new RecipeData.PptPlanInfo(); //计划信息
private List<RecipeData.RecipeWeightInfo> _allWeightInfo = new List<RecipeData.RecipeWeightInfo>(); //称量信息
private List<RecipeData.RecipeMixingInfo> _allMixingInfo = new List<RecipeData.RecipeMixingInfo>(); //密炼信息
/// <summary>
/// 配方主信息
/// </summary>
public RecipeData.RecipeInfo RecipeInfo
{
get
{
return this._recipeInfo;
}
}
/// <summary>
/// 计划信息
/// </summary>
public RecipeData.PptPlanInfo PlanInfo
{
get
{
return this._planInfo;
}
}
/// <summary>
/// 称量信息
/// </summary>
public List<RecipeData.RecipeWeightInfo> AllWeightInfo
{
get
{
return this._allWeightInfo;
}
}
/// <summary>
/// 密炼信息
/// </summary>
public List<RecipeData.RecipeMixingInfo> AllMixingInfo
{
get
{
return this._allMixingInfo;
}
}
/// <summary>
/// 缓存配方主信息
/// </summary>
/// <param name="recipeInfo"></param>
public void CacheRecipeInfo(RecipeData.RecipeInfo recipeInfo)
{
if (recipeInfo != null)
{
this._recipeInfo = recipeInfo;
}
else
{
if (this._recipeInfo == null)
{
this._recipeInfo = new RecipeData.RecipeInfo();
}
}
}
/// <summary>
/// 缓存计划信息
/// </summary>
/// <param name="planInfo"></param>
public void CachePlanInfo(RecipeData.PptPlanInfo planInfo)
{
if (planInfo != null)
{
this._planInfo = planInfo;
}
else
{
if (this._planInfo == null)
{
this._planInfo = new RecipeData.PptPlanInfo();
}
}
}
/// <summary>
/// 缓存称量信息
/// </summary>
/// <param name="allWeightInfo"></param>
public void CacheAllWeightInfo(List<RecipeData.RecipeWeightInfo> allWeightInfo)
{
if (allWeightInfo != null && allWeightInfo.Count > 0)
{
this._allWeightInfo = allWeightInfo;
}
else
{
this._allWeightInfo.Clear();
ICSharpCode.Core.LoggingService.Warn("清空称量信息缓存.....");
}
Mesnac.Communication.TcpService.Instance.NetSendMsg(this.RecipeWeighResolve()); //把称量信息发送至Socket客户端
}
/// <summary>
/// 缓存密炼信息
/// </summary>
/// <param name="allMixingInfo">要缓存的密炼信息</param>
public void CacheAllMixingInfo(List<RecipeData.RecipeMixingInfo> allMixingInfo)
{
if (allMixingInfo != null && allMixingInfo.Count > 0)
{
this._allMixingInfo = allMixingInfo;
}
else
{
this._allMixingInfo.Clear();
}
}
#endregion
#region 称量信息解析
/// <summary>
/// 称量信息解析
/// </summary>
/// <returns></returns>
public string RecipeWeighResolve()
{
return RecipeWeightCommon.ParserRecipeWeighString(this._allWeightInfo);
}
#endregion
}
}