using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Mesnac.Action.Feeding.Qingquan.BasicInfo { /// /// 配方数据缓存类,每次下传配方、配方重传时进行缓存,方便存盘时使用 /// public class RecipeCache { #region 单例实现 private static RecipeCache _instance = null; private RecipeCache() { } /// /// 配方数据缓存实例 /// 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 _allWeightInfo = new List(); //称量信息 private List _allMixingInfo = new List(); //密炼信息 /// /// 配方主信息 /// public RecipeData.RecipeInfo RecipeInfo { get { return this._recipeInfo; } } /// /// 计划信息 /// public RecipeData.PptPlanInfo PlanInfo { get { return this._planInfo; } } /// /// 称量信息 /// public List AllWeightInfo { get { return this._allWeightInfo; } } /// /// 密炼信息 /// public List AllMixingInfo { get { return this._allMixingInfo; } } /// /// 缓存配方主信息 /// /// public void CacheRecipeInfo(RecipeData.RecipeInfo recipeInfo) { if (recipeInfo != null) { this._recipeInfo = recipeInfo; } else { if (this._recipeInfo == null) { this._recipeInfo = new RecipeData.RecipeInfo(); } } } /// /// 缓存计划信息 /// /// public void CachePlanInfo(RecipeData.PptPlanInfo planInfo) { if (planInfo != null) { this._planInfo = planInfo; } else { if (this._planInfo == null) { this._planInfo = new RecipeData.PptPlanInfo(); } } } /// /// 缓存称量信息 /// /// public void CacheAllWeightInfo(List 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客户端 } /// /// 缓存密炼信息 /// /// 要缓存的密炼信息 public void CacheAllMixingInfo(List allMixingInfo) { if (allMixingInfo != null && allMixingInfo.Count > 0) { this._allMixingInfo = allMixingInfo; } else { this._allMixingInfo.Clear(); } } #endregion #region 称量信息解析 /// /// 称量信息解析 /// /// public string RecipeWeighResolve() { return RecipeWeightCommon.ParserRecipeWeighString(this._allWeightInfo); } #endregion } }