Case Helper
using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query; /// <summary>
/// 案例
/// </summary>
public class IncidentHelper
{
public static readonly string entityName = "incident";
public Guid incidentId = Guid.Empty;
public IOrganizationService service; /// <summary>
/// 创建案例
/// </summary>
public void Create()
{
Entity en = new Entity() { LogicalName = entityName };
en["name"] = "案例测试";
incidentId = service.Create(en);
} /// <summary>
/// 计算在案例上花费的总时间
/// </summary>
public void CalculateTotalTimeIncident()
{
CalculateTotalTimeIncidentRequest request = new CalculateTotalTimeIncidentRequest();
request.IncidentId = incidentId;
CalculateTotalTimeIncidentResponse response = (CalculateTotalTimeIncidentResponse)service.Execute(request);
long time = response.TotalTime;
} /// <summary>
/// 将案例的状态设置为“已结束”
/// </summary>
/// <param name="status">结束的状态</param>
public void CloseIncident(int status)
{
CloseIncidentRequest request = new CloseIncidentRequest();
request.IncidentResolution = new Entity() { LogicalName = entityName, Id = incidentId };
request.Status = new OptionSetValue(status);
CloseIncidentResponse response = (CloseIncidentResponse)service.Execute(request);
} /// <summary>
/// 验证是否可随时结束案例
/// </summary>
/// <param name="state">Active,Resolved,Canceled</param>
/// <param name="status">InProgress:1,OnHold:2,WaitingforDetails:3,Researching:4</param>
/// <param name="status">ProblemSolved:5,InformationProvided:1000,Canceled:6</param>
public void IsValidStateTransition(string state, int status)
{
IsValidStateTransitionRequest request = new IsValidStateTransitionRequest();
request.Entity = new EntityReference() { LogicalName = entityName, Id = incidentId };
request.NewState = state;
request.NewStatus = status;
IsValidStateTransitionResponse response = (IsValidStateTransitionResponse)service.Execute(request);
bool isValid = response.IsValid;
} /// <summary>
/// 删除指定安全主体(用户或团队)对案例的所有访问权限
/// </summary>
/// <param name="revokee">用户或团队引用</param>
public void RevokeAccess(EntityReference revokee)
{
RevokeAccessRequest request = new RevokeAccessRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = incidentId };
request.Revokee = revokee;
RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);
} /// <summary> ///
/// 删除案例 ///
/// </summary>
public void Delete() { service.Delete(entityName, incidentId); }
}
Case Helper的更多相关文章
- Delphi -- Compiler helper for initializing/finalizing variable
it CompilerhelperForInitializingFinalizingVariable; interface { Compiler helper for initializing/fin ...
- IEHelper - Internet Explorer Helper Class
http://www.codeproject.com/Articles/4411/IEHelper-Internet-Explorer-Helper-Class Discussions (81) IE ...
- NPOI使用教程附Helper
1 NPOI简介 1.1 NPOI是什么 NPOI是POI的.NET版本,POI是一套用Java写成的库,我们在开发中经常用到导入导出表格.文档的情况,NPOI能够帮助我们在没有安装微软Office的 ...
- 高盛昂赛 算法题先写corner case
[方法] 字写大点,先注释框架 链表:指针走就行了,最多是两个同时一起走. 两个链表求交点 //corner case if (headA == null || headB == null) { re ...
- Creating Your Own PHP Helper Functions In Laravel
By Hamza Ali LAST UPDATED AUG 26, 2018 12,669 104 Laravel provides us with many built-in helper fun ...
- 784. Letter Case Permutation 字符串中字母的大小写组合
[抄题]: Given a string S, we can transform every letter individually to be lowercase or uppercase to c ...
- handlebars Helper用法
handlebars Helper用法: http://www.cnblogs.com/iyangyuan/archive/2013/12/12/3471357.html 逻辑运算符在handle ...
- Attacking JavaScript Engines: A case study of JavaScriptCore and CVE-2016-4622(转)
转:http://phrack.org/papers/attacking_javascript_engines.html Title : Attacking JavaScript Engines: A ...
- 微软原版SQL Helper
代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-- ...
随机推荐
- tcp三次握手和四次挥手(2)
背景描述 通过上一篇中网络模型中的IP层的介绍,我们知道网络层,可以实现两个主机之间的通信.但是这并不具体,因为,真正进行通信的实体是在主机中的进程,是一个主机中的一个进程与另外一个主机中的一个进 ...
- SQL Server ->> Enable Instant File Initialization(开启文件及时初始化)
我们在安装SQL Server的时候会在指定SQL Server各个服务的运行启动账户的账户的时候看到底下有一个选项写着“Grant Perform Volume Maintenance Task p ...
- C++ 构造转换函数和强制转换函数
http://blog.csdn.net/chenyiming_1990/article/details/8862497 1.对于系统的预定义基本类型数据,C++提供了两种类型转换方式:隐式类型转换和 ...
- Linux Mint 18.2安装后需要进行的设置
自己的笔记本电脑升级到win10后各种不好用,运行速度慢,开关机时间很长,系统也是经常性的更新,外加发热严重.更改设置和更换驱动都没能解决问题.另外感觉在Linux下能够更加专注,所以索性将主系统更换 ...
- 安装python File "/usr/bin/pip", line 11, in <module> sys.exit(main()) File "/usr/lib/python3.4/site-packages/pip/__init__.py", line 215, in main locale.setlocale(locale.LC_ALL, '') File "/u
$ uname -a Linux debian 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u6 (2015-11-09) x86_64 GNU ...
- SIMATIC 1500 PLC 同步轴,状态字StatusWord信号描述
轴名. StatusWord.X21 (Synchronizing) 正在建立同步 轴名. StatusWord.X22 (Synchronous) 已经建立同步
- postgraSql支持View可以修改的两种方法。
http://www.postgresqltutorial.com/postgresql-views/ Creating PostgreSQL updatable views – gives you ...
- QuantLib金融库的简易安装
最近在弄毕设,研究关于固定收益债券定价方面的知识,需要使用到QuantLib这个Python金融库,但是这是一个C++编译的库,官网也只给出了源代码,安装起来十分繁琐,所以在网上找了一个简易的安装方法 ...
- Android(java)学习笔记208:Android下的属性动画高级用法(Property Animation)
1. 大家好,在上一篇文章当中,我们学习了Android属性动画的基本用法,当然也是最常用的一些用法,这些用法足以覆盖我们平时大多情况下的动画需求了.但是,正如上篇文章当中所说到的,属性动画对补间动画 ...
- PyCharm Django项目开发的调试方法
下面介绍两种PyCharm Django项目开发的调试方法: 方法一: 1. 使用PyCharm 自带的django项目Debug工具, 当然前提条件是django项目环境已经搭建好了. 2. 在代码 ...