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(, , );
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, ));
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 == )
{
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 == )
{
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 : class
where 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 });
}
}
}
Dynamics 365的系统作业实体记录增长太快怎么回事?的更多相关文章
- Dynamics 365使用Execute Multiple Request删除系统作业实体记录
摘要: 本人微信公众号:微软动态CRM专家罗勇 ,回复295或者20190112可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me ...
- Dynamics 365 CE中AsyncOperationBase表记录太多,影响系统性能怎么办?
微软动态CRM专家罗勇 ,回复311或者20190311可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 本文主要是根据微软官 ...
- Dynamics CRM 导出系统中实体的属性字段到EXCEL
我们在CRM中看元数据信息,可以通过SDK中的metadata browser的解决方案包,但该解决方案包只是在可视化上方便了,但如果我们需要在excel中整理系统的数据字典时这个解决方案包就派不上用 ...
- Temporary ASP.NET Files\root 空间增长太快
估计是虚拟目录有新的文件,造成项目重新被编译要么把新文件放到另一个目录,要么使用web application而不是web project
- Dynamics 365检查工作流、SDK插件步骤是否选中运行成功后自动删除系统作业记录
本人微信公众号:微软动态CRM专家罗勇 ,回复298或者20190120可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . 系统 ...
- 自定义适用于手机和平板电脑的 Dynamics 365(三):显示的实体
您可以启用 适用于手机的 Dynamics 365 和 适用于平板电脑的 Dynamics 365 的有限实体集. 若要查看是否启用了实体,或者要启用实体,请单击“设置”>“自定义”>“自 ...
- Dynamics 365 Online-使用Azure Logic App 与 Dynamics 365 集成
什么是Logic App? Azure Logic App 是微软发布的集成平台的产品,有助于生成,计划和自动完成工作流形式的流程,适合跨企业或组织集成,数据,系统和服务.与此同时,Logic App ...
- 无依赖简单易用的Dynamics 365公共视图克隆工具
本人微信公众号:微软动态CRM专家罗勇 ,回复279或者20180818可方便获取本文,同时可以在第一间得到我发布的最新博文信息,follow me!我的网站是 www.luoyong.me . Dy ...
- 自定义工作流活动报错:您无法登陆系统。原因可能是您的用户记录或您所属的业务部门在Microsoft Dynamics 365中已被禁用。
本人微信和易信公众号: 微软动态CRM专家罗勇 ,回复265或者20170926可方便获取本文,同时可以在第一间得到我发布的最新的博文信息,follow me!我的网站是 www.luoyong.me ...
随机推荐
- vue父子组件及非父子组件通信
1.父组件传递数据给子组件 父组件数据如何传递给子组件呢?可以通过props属性来实现 父组件: <parent> <child :child-msg="msg" ...
- 安装部署jumpserver3.0
1.安装依赖包yum -y install git readline-devel automake autoconf2.下载 jumpservergit clone https://github.co ...
- Python档案袋(异常与异常捕获 )
无异常捕获 程序遇到异常会中断 print( xxx ) print("---- 完 -----") 得到结果为: 有异常捕获 程序遇到异常会进入异常处理,并继续执行下面程序 tr ...
- [原创]利用Browser协议探测内网主机操作系统版本(无需端口无视防火墙)
利用Browser协议可获取机器IP.MAC.机器名.操作系统.域,如图 浏览 在SMB协议中,计算机为了访问网络资源,就需要了解网络上存在的资源列表(例如在Windows下使用网络邻居查看可以访问的 ...
- J2EE-tomcat的配置
修改web.xml文件里面的内容: 路径:D:\software\apache-tomcat-8.0.44\webapps\ROOT\WEB-INF\web.xml: 内容:<?xml ver ...
- java多线程(6)---ThreadLocal
ThreadLocal 什么是ThreadLocal? 顾名思义它是local variable(线程局部变量).它的功用非常简单,就是为每一个使用该变量的线程都提供一个变量值的副本,是每一个线程都可 ...
- oauth2.0通过JdbcClientDetailsService从数据库读取相应的配置
oauth2.0通过JdbcClientDetailsService从数据库读取相应的配置 在上一节我们讲述的配置是把授权码存储在redis中,把相应的请求的路径用使用in-memory存储 ,这个是 ...
- 并发编程(十六)——java7 深入并发包 ConcurrentHashMap 源码解析
以前写过介绍HashMap的文章,文中提到过HashMap在put的时候,插入的元素超过了容量(由负载因子决定)的范围就会触发扩容操作,就是rehash,这个会重新将原数组的内容重新hash到新的扩容 ...
- 使用ML.NET和Azure Function进行机器学习 - 第2部分
本文是<使用ML.NET和AzureFunction进行机器学习 - 第1部分>的续篇. 像机器一样识别鸢尾花 回顾第1部分,您将使用Visual Studio创建一个新的Azure Fu ...
- C#版(击败97.76%的提交) - Leetcode 557. 反转字符串中的单词 III - 题解
版权声明: 本文为博主Bravo Yeung(知乎UserName同名)的原创文章,欲转载请先私信获博主允许,转载时请附上网址 http://blog.csdn.net/lzuacm. Leetcod ...