using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mesnac.Basic;
namespace Mesnac.Action.Feeding.Qingquan.BasicInfo
{
///
/// 配方称量信息缓存类,在提前下传称量信息时缓存
///
public class RecipeWeighCache
{
#region 单例实现
private static RecipeWeighCache _instance = null;
private RecipeWeighCache() { }
///
/// 配方称量信息缓存实例
///
public static RecipeWeighCache Instance
{
get
{
if (_instance == null)
{
_instance = new RecipeWeighCache();
}
return _instance;
}
}
#endregion
#region 属性定义
private bool _cacheFlag = false; //称量信息下传标志
private List _allWeightInfo = new List(); //称量信息
///
/// 称量信息下传标志
///
public bool CacheFlag
{
get
{
return this._cacheFlag;
}
set
{
this._cacheFlag = value;
if (this._cacheFlag == false)
{
if (this._allWeightInfo != null)
{
this._allWeightInfo.Clear();
}
FeedingAction action = new FeedingAction();
string xmlRecipeWeightCache = SerializeHandler.SerializeObject>(this._allWeightInfo);
action.UpdateSysValue("RecipeWeightCache", xmlRecipeWeightCache);
action.UpdateSysValue("RecipeWeightCache_CacheFlag", this._cacheFlag.ToString());
}
}
}
///
/// 称量信息
///
public List AllWeightInfo
{
get
{
return this._allWeightInfo;
}
}
///
/// 缓存称量信息
///
///
public void CacheAllWeightInfo(List allWeightInfo)
{
this._cacheFlag = true;
if (allWeightInfo != null && allWeightInfo.Count > 0)
{
this._allWeightInfo = allWeightInfo;
}
else
{
this._allWeightInfo.Clear();
}
Mesnac.Communication.TcpService.Instance.NetSendMsg(this.RecipeWeighResolve()); //把称量信息发送至Socket客户端
}
#endregion
#region 称量信息解析
///
/// 称量信息解析
///
///
public string RecipeWeighResolve()
{
return RecipeWeightCommon.ParserRecipeWeighString(this._allWeightInfo);
}
#endregion
}
}