| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using Muchinfo.PC.Common.Helpers;
- using Muchinfo.MTPClient.Infrastructure.Enums;
- using System;
- using System.Data;
- namespace Muchinfo.MTPClient.Infrastructure.Cache
- {
- /// <summary>
- /// 缓存数据表类
- /// </summary>
- public class CacheTable : DataTable
- {
- /// <summary>
- /// 缓存数据时间的键
- /// </summary>
- private const string CacheTimeName = "CacheTime";
- /// <summary>
- /// 缓存数据权限的键
- /// </summary>
- private const string PremissionName = "Premission";
- private CacheType _type;
- /// <summary>
- /// 获取或设置缓存表类型
- /// </summary>
- public CacheType Type
- {
- get { return this._type; }
- }
- private DateTime _cacheTime;
- /// <summary>
- /// 获取或设置最后请求缓存数据的时间
- /// </summary>
- public DateTime CacheTime
- {
- get
- {
- return this._cacheTime;
- }
- set
- {
- this._cacheTime = value;
- string cacheTime = value.ToString(FormatHelper.DateTimeFormat2);
- if (this.ExtendedProperties.Contains(CacheTable.CacheTimeName))
- {
- ExtendedProperties[CacheTable.CacheTimeName] = cacheTime;
- }
- else
- {
- ExtendedProperties.Add(CacheTable.CacheTimeName, cacheTime);
- }
- }
- }
- private string m_Premission;
- /// <summary>
- /// 获取或设置请求缓存使用的权限
- /// </summary>
- public string Premission
- {
- get
- {
- return m_Premission;
- }
- set
- {
- m_Premission = value;
- if (this.ExtendedProperties.Contains(CacheTable.PremissionName))
- {
- ExtendedProperties[CacheTable.PremissionName] = value;
- }
- else
- {
- ExtendedProperties.Add(CacheTable.PremissionName, value);
- }
- }
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="CacheTable"/> class.
- /// </summary>
- /// <param name="type">缓存数据类型</param>
- public CacheTable(CacheType type)
- {
- this._type = type;
- this.TableName = type.ToString();
- }
- internal void InitExtentProperties()
- {
- this._type = (CacheType)Enum.Parse(typeof(CacheType), TableName);
- if (this.ExtendedProperties.Contains(CacheTable.CacheTimeName))
- {
- DateTime.TryParse(string.Empty + ExtendedProperties[CacheTable.CacheTimeName], out _cacheTime);
- }
- if (this.ExtendedProperties.Contains(CacheTable.PremissionName))
- {
- this.m_Premission = string.Empty + ExtendedProperties[CacheTable.PremissionName];
- }
- }
- }
- }
|