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. python shopping incomplete code

    #shopping code#shopping.py#导入登录模块import login# shop car beginningsalary = input("请输入工资:\t" ...

  2. 'weblogic.kernel.Default (self-tuning) 问题weblogic层面解决办法

    声明:出现这个问题有程序方面.网络方面.weblogic设置方面等等原因,此文章主要讲述由于weblogic设置而导致的解决办法. 因为: 1.程序问题,需要项目自己去解决,weblogic在做优化处 ...

  3. vscode环境配置

    "go.goroot": "/home/ken/go", "go.gopath": "/home/ken/gopath" ...

  4. 【Leetcode】【Medium】Two Sum

    Given an array of integers, find two numbers such that they add up to a specific target number. The ...

  5. mongodb 启动

    >mongod.exe --dbpath  C:\Environ\mongodb-3.0.6\data\db >mongod.exe --logpath "C:\Environ\ ...

  6. mysql中replicate_wild_do_table和replicate_do_db区别

    使用replicate_do_db和replicate_ignore_db时有一个隐患,跨库更新时会出错. 如在Master(主)服务器上设置 replicate_do_db=test(my.conf ...

  7. 解决Unity3D操作界面字体模糊的问题

    新装的电脑安装了UNITY后,操作界面的字体异常模糊,搜了半天看看有没有换字体的功能,也没找到 后来快放弃的时候,偶然看到这篇文章http://eyehere.net/2014/unity3d-int ...

  8. Apache PredictionIO在Docker上的搭建及使用

    1.Apache PredictionIO介绍 Apache PredictionIO 是一个孵化中的机器学习服务器,它可以为为开发人员和数据科学家创建任何机器学习任务的预测引擎.官方原文: Apac ...

  9. linux自动备份oracle数据库

    #此脚本只备份数据表,而且为了方便恢复数据是做的单表逐个备份#在写脚本过程中遇到的报错均加入了解决方案的链接(虽然错误代码没有贴出来)#最终将在脚本所在目录生成年月日-时分的目录,目录下为表名.dmp ...

  10. java中的泛型1

    1.泛型概述 泛型,即“参数化类型”.一提到参数,最熟悉的就是定义方法时有形参,然后调用此方法时传递实参.那么参数化类型怎么理解呢?顾名思义,就是将类型由原来的具体的类型参数化,类似于方法中的变量参数 ...