缓存清理(Python实现)
参考社区知识:【二开案例.单据插件.缓存清理】,用Python实现,供参考
import clr clr.AddReference("mscorlib") clr.AddReference('System') clr.AddReference('System.Data') clr.AddReference('Kingdee.BOS') clr.AddReference('Kingdee.BOS.Core') clr.AddReference('Kingdee.BOS.App.Core') clr.AddReference('Kingdee.BOS.App') clr.AddReference('Kingdee.BOS.DataEntity') clr.AddReference('Kingdee.BOS.ServiceHelper') clr.AddReference('Kingdee.BOS.Contracts') clr.AddReference('Kingdee.K3.Core') from System import * from System.Data import * from System.Collections import * from System.Collections.Generic import * from System import StringComparison from Kingdee.BOS.Log import Logger from Kingdee.BOS import * from Kingdee.BOS.Util import * from Kingdee.BOS.App.Core import * from Kingdee.BOS.App.Data import * from Kingdee.BOS.Core.Bill.PlugIn import * from Kingdee.BOS.Core.Const import * from Kingdee.BOS.ServiceHelper import * from Kingdee.BOS.Core.DynamicForm.PlugIn.Args import * def BarItemClick(e): if e.BarItemKey.Equals("tbButton_1", StringComparison.OrdinalIgnoreCase): formIds = List[object]() formIds.Add("BD_MATERIAL") ClearCacheByFormIds(this.Context, formIds) this.View.ShowMessage("物料的缓存已被清空!") if e.BarItemKey.Equals("tbButton_2", StringComparison.OrdinalIgnoreCase): materialIds = List[String]() materialIds.Add("139886") materialIds.Add("139892") ClearCacheByPrimaryKeys(this.Context, "BD_MATERIAL", materialIds) this.View.ShowMessage("物料【XXX】的缓存已被清空!") def ClearCacheByFormIds(ctx, formIds): if formIds == None or len(formIds) == 0: return False area = ctx.GetAreaCacheKey() for formId in formIds: metadata = FormMetaDataCache.GetCachedFormMetaData(ctx, formId) if metadata != None: CacheUtil.ClearCache(area, metadata.BusinessInfo.GetEntity(0).TableName) CacheUtil.ClearCache(ctx.DBId + formId, CacheRegionConst.BOS_QuickBaseDataCache) return True def ClearCacheByPrimaryKeys(ctx, formId, keys): if keys == None or len(keys) == 0: return False metadata = FormMetaDataCache.GetCachedFormMetaData(ctx, formId) if metadata == None: return False cacheManager = DataEntityCacheManager(ctx, metadata.BusinessInfo.GetDynamicObjectType()) cacheManager.RemoveCacheByPrimaryKeys(keys) CacheUtil.ClearCache(ctx.DBId + formId, CacheRegionConst.BOS_QuickBaseDataCache) return True
一、注意:
1、实际测试,在不同账套环境出现:清理缓存(整个基础资料的缓存全清)- ClearCacheByFormIds(Context ctx, List<string> formIds) 这个方法没有效果,即根据基础资料FormId清除对应缓存没有生效。
2、通过id来清除基础资料,即:ClearCacheByPrimaryKeys(Context ctx, string formId, List<string> keys) 正常生效。
二、参考
【二开案例.表单插件.缓存清理(按区段清理)】
缓存清理(Python实现)
参考社区知识:【二开案例.单据插件.缓存清理】,用Python实现,供参考import clrclr.AddReference("mscorlib")clr.AddReference('Syst...
点击下载文档
本文2024-09-23 02:52:29发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-155260.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章