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的更多相关文章

  1. Delphi -- Compiler helper for initializing/finalizing variable

    it CompilerhelperForInitializingFinalizingVariable; interface { Compiler helper for initializing/fin ...

  2. IEHelper - Internet Explorer Helper Class

    http://www.codeproject.com/Articles/4411/IEHelper-Internet-Explorer-Helper-Class Discussions (81) IE ...

  3. NPOI使用教程附Helper

    1 NPOI简介 1.1 NPOI是什么 NPOI是POI的.NET版本,POI是一套用Java写成的库,我们在开发中经常用到导入导出表格.文档的情况,NPOI能够帮助我们在没有安装微软Office的 ...

  4. 高盛昂赛 算法题先写corner case

    [方法] 字写大点,先注释框架 链表:指针走就行了,最多是两个同时一起走. 两个链表求交点 //corner case if (headA == null || headB == null) { re ...

  5. 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 ...

  6. 784. Letter Case Permutation 字符串中字母的大小写组合

    [抄题]: Given a string S, we can transform every letter individually to be lowercase or uppercase to c ...

  7. handlebars Helper用法

    handlebars  Helper用法:  http://www.cnblogs.com/iyangyuan/archive/2013/12/12/3471357.html 逻辑运算符在handle ...

  8. 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 ...

  9. 微软原版SQL Helper

    代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-- ...

随机推荐

  1. SpringMVC学习(六)——@InitBinder注解

    有些类型的数据是无法自动转换的,比如请求参数中包含时间类型的数据,无法自动映射到Controller里的Date参数.需要使用@initBinder注解为binder提供一个数据的转换器,这个转换器可 ...

  2. Java接口与多态

    接口 可以理解为一种特殊的类,里面全部是由全局常量(static final)和公共的抽象方法所组成 接口的定义格式 接口的数据成员,只允许被public, static, final修饰. 接口的方 ...

  3. JavaScript返回上一页

    目前来说有两种方法: window.history.back(); // 返回上一页不刷新 window.location.href = document.referrer; // 返回上一页并刷新

  4. MyEcplise的注册代码

    代码分析 package test; import java.io.BufferedReader; import java.io.IOException; import java.io.InputSt ...

  5. IEEP部署企业级网络工程-OSPF邻居关系故障排除

    OSPF邻居关系故障-现象与排除 一.OSPF邻居关系故障-现象与排除 1.OSPF建立邻居关系时,将检验hello报文中的Area ID .Autype.Authentication.network ...

  6. eclipse通过maven进行打包并且对hdfs上的文件进行wordcount

    在eclipse中配置自己的maven仓库 1.安装maven(用于管理仓库,jar包的管理) -1.解压maven安装包 -2.把maven添加到环境变量/etc/profile -3.添加mave ...

  7. 网络分析 ANP

    在许多实际问题中,各层次内部元素往往是依赖的. 低层元素对高层元素亦有支配作用,即存在反馈. 此时系统的结构更类似于网络结构.网络分析法正是适应这种需要,由AHP延伸发展得到的系统决策方法.   AN ...

  8. System IPC 与Posix IPC(msg消息对列)

    系统消息队列: 一.消息队列基本概念 系统V消息队列是随内核持续的,只有在内核重起或者显示删除一个消息队列时,该消息队列才会真正被删除.因此系统中记录消息队列的数据结构(struct ipc_ids ...

  9. html5 css3新特性了解一下

    html5: 用于绘画的 canvas 元素 以及SVG 用于媒介回放的 video 和 audio 元素 拖拽(Drag 和 drop) 地理定位(Geolocation) 对本地离线存储的更好的支 ...

  10. 阿里云maven仓库镜像mirror,速度超快

    <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http:/ ...