using System;
using System.Data;
using System.Collections;
using System.Text;
using BP.En;
using BP.Pub;
using BP.Sys;
namespace BP.DA
{
public class CacheFrmTemplate
{
#region 缓存ht
private static Hashtable _hts;
#endregion
#region 对实体的操作.
///
/// 放入表单
///
/// 表单ID
/// 表单模版
public static void Put(string frmID, DataSet ds)
{
string json = BP.Tools.Json.ToJson(ds);
lock (lockObj)
{
if (_hts == null)
_hts = new Hashtable();
if (_hts.ContainsKey(frmID) == false)
_hts.Add(frmID, json);
else
_hts[frmID] = json;
}
}
///
/// 移除
///
/// 表单ID
public static void Remove(string frmID)
{
lock (lockObj)
{
if (_hts == null)
_hts = new Hashtable();
_hts.Remove(frmID);
}
}
private static object lockObj = new object();
///
/// 获得表单DataSet模式的模版数据
///
/// 表单ID
/// 表单模版
public static DataSet GetFrmDataSetModel(string frmID)
{
lock (lockObj)
{
if (_hts == null)
_hts = new Hashtable();
if (_hts.ContainsKey(frmID) == true)
{
string json = _hts[frmID] as string;
DataSet ds = BP.Tools.Json.ToDataSet(json);
return ds;
}
return null;
}
}
///
/// 获得表单json模式的模版数据
///
/// 表单ID
/// json
public static string GetFrmJsonModel(string frmID)
{
lock (lockObj)
{
if (_hts == null)
_hts = new Hashtable();
if (_hts.ContainsKey(frmID) == true)
{
string json = _hts[frmID] as string;
return json;
}
return null;
}
}
#endregion 对实体的操作.
}
}