/// <summary> /// 從緩存中讀取資源表 /// </summary> /// <param name="strTargetType"></param> /// <returns></returns> private DataTable GetWXResourcesFromCache(string strTargetType) { var pt = m_sdk == null ? 0 : m_sdk.WXType; m_CacheConfig = new WXResourceCacheConfig(strTargetType); object obj = this.GetCache(m_CacheConfig); if (obj == null) { //初始化数据访问DA m_DA = new WXResourceDA(); DataTable dt = m_DA.GetWXResources(strTargetType, pt); m_CacheConfig.CacheContent = dt; this.InsertCache(m_CacheConfig, this.CacheRemovedCallback); return(dt); } else { if (obj is DataTable && (obj as DataTable).Rows.Count == 0) { //初始化数据访问DA m_DA = new WXResourceDA(); DataTable dt = m_DA.GetWXResources(strTargetType, pt); m_CacheConfig.CacheContent = dt; this.InsertCache(m_CacheConfig, this.CacheRemovedCallback); return(dt); } else { return(obj as DataTable); } } }
/// <summary> /// 保存微信资源至DB /// </summary> /// <param name="strTargetType"></param> /// <param name="strValue"></param> /// <param name="media_ID"></param> private int SaveWXResource(int?lcid, string lcName, string lcClassify, string strTargetType, string strValue, string media_ID, int iSourceType) { m_CacheConfig = new WXResourceCacheConfig(strTargetType); //初始化数据访问DA m_DA = CastleAOPUtil.NewPxyByClass <WXResourceDA>(new DataWritingInterceptor(this.RemoveCache, this.m_CacheConfig)); if (lcid == 0) { lcid = null; } //保存资源——暂时不能分类及命名 lcid = m_DA.SaveResource(lcid, lcName, lcClassify, media_ID, strTargetType, strValue, DateTime.Now, iSourceType, m_sdk == null ? 0 : m_sdk.WXType); if (lcid == null) { EGExceptionOperator.ThrowX <Exception>("微信资源DataBase保存错误", EGActionCode.未知错误); } return(lcid.Value); }
/// <summary> /// 刪除資源 /// </summary> /// <param name="strTargetType"></param> /// <param name="lcid"></param> public void DeleteResource(string strTargetType, int lcid) { if (string.IsNullOrEmpty(strTargetType) || lcid < 1) { return; } m_CacheConfig = new WXResourceCacheConfig(strTargetType); //初始化数据访问DA m_DA = CastleAOPUtil.NewPxyByClass <WXResourceDA>(new DataWritingInterceptor(this.RemoveCache, this.m_CacheConfig)); int iRes = m_DA.DeleteResource(lcid); if (lcid == null) { EGExceptionOperator.ThrowX <Exception>("微信资源刪除错误", EGActionCode.未知错误); } }