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.

110 lines
3.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mesnac.Basic;
namespace Mesnac.Action.Feeding.Qingquan.BasicInfo
{
/// <summary>
/// 配方称量信息缓存类,在提前下传称量信息时缓存
/// </summary>
public class RecipeWeighCache
{
#region 单例实现
private static RecipeWeighCache _instance = null;
private RecipeWeighCache() { }
/// <summary>
/// 配方称量信息缓存实例
/// </summary>
public static RecipeWeighCache Instance
{
get
{
if (_instance == null)
{
_instance = new RecipeWeighCache();
}
return _instance;
}
}
#endregion
#region 属性定义
private bool _cacheFlag = false; //称量信息下传标志
private List<RecipeData.RecipeWeightInfo> _allWeightInfo = new List<RecipeData.RecipeWeightInfo>(); //称量信息
/// <summary>
/// 称量信息下传标志
/// </summary>
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<List<RecipeData.RecipeWeightInfo>>(this._allWeightInfo);
action.UpdateSysValue("RecipeWeightCache", xmlRecipeWeightCache);
action.UpdateSysValue("RecipeWeightCache_CacheFlag", this._cacheFlag.ToString());
}
}
}
/// <summary>
/// 称量信息
/// </summary>
public List<RecipeData.RecipeWeightInfo> AllWeightInfo
{
get
{
return this._allWeightInfo;
}
}
/// <summary>
/// 缓存称量信息
/// </summary>
/// <param name="allWeightInfo"></param>
public void CacheAllWeightInfo(List<RecipeData.RecipeWeightInfo> 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 称量信息解析
/// <summary>
/// 称量信息解析
/// </summary>
/// <returns></returns>
public string RecipeWeighResolve()
{
return RecipeWeightCommon.ParserRecipeWeighString(this._allWeightInfo);
}
#endregion
}
}