Dynamics 365的系统作业实体记录增长太快怎么回事?
摘要: 本人微信公众号:微软动态CRM专家罗勇 ,回复294或者20190111可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me 。
这个一般是工作流没有选中【自动删除已完成的工作流作业(以节省磁盘空间)】这个选项,或者是SDK插件步骤没有选中【Delete AsyncOperation if StatusCode = Successful】这个选项。特别是运行频繁的工作流,或者注册的频繁执行的异步执行的SDK插件步骤(如注册在实体上的Retrieve 或者 RetrieveMultiple 消息的插件步骤),如果没有设置对,会导致【系统作业】实体(实体逻辑名称asyncoperation)的记录增长的非常快,占用磁盘会非常大。
所以我开发了一个程序来检查是否有这样的插件步骤或者工作流,不多说了,上代码。
using Microsoft.Crm.Sdk.Messages; using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Client; using Microsoft.Xrm.Sdk.Query; using System; using System.Configuration; using System.Net; using System.ServiceModel.Description;namespace CheckWorkflowPluginStepAutoDelete {class Program{static void Main(string[] args){try{string inputKey;ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;IServiceManagement<IOrganizationService> orgServiceMgr = ServiceConfigurationFactory.CreateManagement<IOrganizationService>(new Uri(ConfigurationManager.AppSettings["orgUrl"]));AuthenticationCredentials orgAuCredentials = new AuthenticationCredentials();orgAuCredentials.ClientCredentials.UserName.UserName = ConfigurationManager.AppSettings["userName"];orgAuCredentials.ClientCredentials.UserName.Password = ConfigurationManager.AppSettings["passWord"];string needConfirm = ConfigurationManager.AppSettings["needConfirm"];using (var orgSvc = GetProxy<IOrganizationService, OrganizationServiceProxy>(orgServiceMgr, orgAuCredentials)){orgSvc.Timeout = new TimeSpan(8, 0, 0);WhoAmIRequest whoReq = new WhoAmIRequest();var whoRsp = orgSvc.Execute(whoReq) as WhoAmIResponse;var userEntity = orgSvc.Retrieve("systemuser", whoRsp.UserId, new Microsoft.Xrm.Sdk.Query.ColumnSet("fullname"));Console.WriteLine(string.Format("欢迎【{0}】登陆到【{1}】", userEntity.GetAttributeValue<string>("fullname"), ConfigurationManager.AppSettings["orgUrl"]));Console.WriteLine("本程序用于检查工作流/SDK插件步骤是否选中了【运行成功后自动删除日志】!");if (needConfirm == "Y"){Console.WriteLine("当前处于需要确认才会继续的模式,若要继续请输入Y然后回车确认!");inputKey = Console.ReadLine();if (inputKey.ToUpper() == "Y"){CheckSDKMessageProcessingStepAutoDelete(orgSvc);CheckWorkflowAutoDelete(orgSvc);}else{Console.WriteLine("你选择了取消运行!");}}else{CheckSDKMessageProcessingStepAutoDelete(orgSvc);CheckWorkflowAutoDelete(orgSvc);}}Console.Write("程序运行完成,按任意键退出." + DateTime.Now.ToString());Console.ReadLine();}catch (Exception ex){Console.WriteLine("程序运行出错:" + ex.Message + ex.StackTrace);Console.ReadLine();}}private static void CheckSDKMessageProcessingStepAutoDelete(OrganizationServiceProxy orgSvc){const string functionName = "检查SDK插件步骤是否选中了【运行成功后自动删除日志】";Console.WriteLine(string.Format("开始 {0} - {1}", functionName, DateTime.Now.ToString()));try{QueryExpression qe = new QueryExpression("sdkmessageprocessingstep");qe.ColumnSet = new ColumnSet("name");qe.NoLock = true;qe.Criteria.AddCondition(new ConditionExpression("mode", ConditionOperator.Equal, 1));qe.Criteria.AddCondition(new ConditionExpression("asyncautodelete", ConditionOperator.Equal, false));qe.Criteria.AddCondition(new ConditionExpression("iscustomizable", ConditionOperator.Equal, true));EntityCollection ec = orgSvc.RetrieveMultiple(qe);if (ec.Entities.Count == 0){Console.WriteLine("Perfect!所有SDK插件步骤都选中了成功后自动删除运行日志!");}else{Console.WriteLine("所有异步运行的SDK插件步骤没有选中【运行成功后自动删除日志】清单如下:");foreach (Entity ent in ec.Entities){Console.WriteLine(ent.GetAttributeValue<string>("name"));}}}catch (Exception ex){Console.WriteLine(string.Format("运行 {0} 出现异常:{1}", functionName, ex.Message + ex.StackTrace));}Console.WriteLine(string.Format("结束 {0} - {1}", functionName, DateTime.Now.ToString()));Console.WriteLine("================================================");}private static void CheckWorkflowAutoDelete(OrganizationServiceProxy orgSvc){const string functionName = "检查工作流是否选中了【运行成功后自动删除日志】";Console.WriteLine(string.Format("开始 {0} - {1}", functionName, DateTime.Now.ToString()));try{var fetchXml = @"<fetch version='1.0' mapping='logical' distinct='false' no-lock='true'><entity name='workflow'><attribute name='name' /><filter type='and'><condition attribute='type' operator='eq' value='1' /><condition attribute='category' operator='eq' value='0' /><condition attribute='statecode' operator='eq' value='1' /><condition attribute='asyncautodelete' operator='ne' value='1' /><condition attribute='mode' operator='eq' value='0' /></filter></entity> </fetch>";var workflowEntities = orgSvc.RetrieveMultiple(new FetchExpression(fetchXml));if (workflowEntities.Entities.Count == 0){Console.WriteLine("Perfect!所有工作流都选中了成功后自动删除运行日志!");}else{Console.WriteLine("所有异步运行的工作流没有选中【运行成功后自动删除日志】清单如下:");foreach (var item in workflowEntities.Entities){Console.WriteLine(item.GetAttributeValue<string>("name"));}}}catch (Exception ex){Console.WriteLine(string.Format("运行 {0} 出现异常:{1}", functionName, ex.Message + ex.StackTrace));}Console.WriteLine(string.Format("结束 {0} - {1}", functionName, DateTime.Now.ToString()));Console.WriteLine("================================================");}private static TProxy GetProxy<TService, TProxy>( IServiceManagement<TService> serviceManagement, AuthenticationCredentials authCredentials)where TService : classwhere TProxy : ServiceProxy<TService>{Type classType = typeof(TProxy);if (serviceManagement.AuthenticationType !=AuthenticationProviderType.ActiveDirectory){AuthenticationCredentials tokenCredentials =serviceManagement.Authenticate(authCredentials);return (TProxy)classType.GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(SecurityTokenResponse) }).Invoke(new object[] { serviceManagement, tokenCredentials.SecurityTokenResponse });}return (TProxy)classType.GetConstructor(new Type[] { typeof(IServiceManagement<TService>), typeof(ClientCredentials) }).Invoke(new object[] { serviceManagement, authCredentials.ClientCredentials });}} }
转载于:https://www.cnblogs.com/luoyong0201/p/Dynamics_365_System_Job_Auto_Deletion.html
Dynamics 365的系统作业实体记录增长太快怎么回事?相关推荐
- 中国博士生数量增长太快将会导致博士就业难
全国政协委员王大中说:"必须考虑社会需求.科研投入.导师力量.学校办学条件等 因素,要加强对博士生教育规模的宏观调控.""现在一些高校的博士生,还延续中小学生 培养方式, ...
- 多方面比较Salesforce与Microsoft Dynamics 365
这是Salesforce®和Microsoft Dynamics™365的基于事实的比较.对于那些为正在准备上CRM的公司来说,以下信息是一点提示. 此篇文章并不是要比较出来哪个产品更优秀,只是给CR ...
- 【转】Dynamics 365中开发和注册插件介绍
是微软Dynamics 365 & Power Platform方面的工程师罗勇,也是2015年7月到2018年6月连续三年Dynamics CRM/Business Solutions方面的 ...
- Dynamics 365 你所期待的子网格编辑终于来了
Dynamics 365的online版本已经在11月1号发布了,on-premises版也在没几天后发布,今天略看了一眼 what's new 一眼就看到了 editable grids,这个不用我 ...
- Dynamics 365 多租户?多实例?
Dynamics 365(在线)为您提供了隔离Dynamics 365数据和使用户访问权限的选项. 对于大多数公司而言,在订阅中增加和用多个实例可提供正确的功能组合和易管理性. 具备不同地理位置的企业 ...
- Dynamics 365 App for Outlook 与 Dynamics 365 for Outlook(已被弃用)
在最新的版本中Dynamics 365 for Outlook(Outlook 客户端)已被弃用 随 Dynamics CRM 2016(版本 8.0)引入的 Dynamics 365 App for ...
- Dynamics 365 for CRM: Sitemap站点图的可视化编辑功能
Dynamics 365 for CRM 提供了Sitemap站点图的可视化编辑功能 在之前的所有版本中,我们只能通过从系统中导出站点图的XML进行编辑后再导入(容易出错),或使用第三方的Sitema ...
- 此版本的应用程序不支持其项目类型 (.etp)_适用于Microsoft Dynamics 365商业中心的VPS和VJS版本1.8...
甘特图从1998年的第一个商用版本开始就致力于计划编制和项目管理方面控件的研究和开发,经过20多年的积累和沉淀,目前可为软件开发商和最终用户提供最顶级的计划编制和项目管理的控件产品,帮助用户快速的整合 ...
- 【转】Dynamics 365中的事件框架与事件执行管道(Event execution pipeline)
本文介绍了Microsoft Dynamics 365(以下简称D365)中的两个概念,事件框架(Event Framework)与事件执行管道(Event execution pipeline). ...
最新文章
- SAP LSMW Standard Batch (Direct) Input 方式制作的LSMW工具导入OPEN PO 单据时候’税码’字段的处理
- telnet给服务器发消息,Telnet按字符发送字符串
- html pie标签,css3pie怎么用?
- boost::posix_time模块用时间构造和计算的一些简单例子
- 【转】如何判断一个文本文件内容的编码格式 UTF-8 ? ANSI(GBK)
- termux php 出错,android上的终端——termux
- mui + php,GitHub - alphaphp/mui-kidApp: 基于 MUI 构建一个具有 90 +页面的APP应用
- 华为再发行30亿元超短期融资券
- 河南城镇化争植“智慧”基因
- 第十一篇 面向对象进阶
- 古典乐器网页设计成品 大学生音乐网站制作模板 大学生静态音乐HTML网页源码 dreamweaver网页作业 简单网页课程成品
- 计算机无法启动无法修复工具,windows资源保护无法启动修复服务的解决方法
- 蓝桥杯嵌入式STM32G431——第九届省赛真题电子定时器
- 笔记——STM32串口USART收发数据。
- SIP没有摘机消息可以通话吗
- 程序员面试笔试宝典学习记录(一)
- 《笑着离开惠普》读书笔记之员工成长之路
- IIS架设WebService服务端的基本错误:试图加载格式不正确的程序
- hive启动警告:Establishing SSL connection without server's identity verification is not recommended
- 学单片机有前景吗?单片机入门基础知识
热门文章
- 他回国后对学生说,玩会这12个游戏就能掌握python基础,其实不难
- 计算机视觉论文-2021-07-16
- PyTorch | torch.from_numpy使用方法 | torch.from_numpy如何使用?torch.from_numpy()例子 | 通过torch.from_numpy创建张量
- Python中的operator.itemgetter函数
- 微信开发者配置服务器信息,【开发】微信验证开发者接口配置信息,服务器没有正确响应Token....
- 使用 加载 顺序_SpringBoot系列教程之Bean加载顺序之错误使用姿势辟谣
- python的os模块使用_Python之os模块的常见用法
- dremwere怎样让多个图片并列排放_国标双壁波纹管直径200、300、400、500、600、800图片展示...
- python 财务分析-linux 复制移动命令详解
- 湖首大学计算机科学硕士申请,湖首大学王牌专业之一丨计算机科学专业