using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query; /// <summary>
/// 销售合同
/// </summary>
public class ContractHelper
{
public static readonly string entityName = "contract";
public Guid contractId = Guid.Empty;
public IOrganizationService service; /// <summary>
/// 创建销售合同
/// </summary>
public void Create()
{
Entity en = new Entity() { LogicalName = entityName };
en["title"] = "销售合同测试";
contractId = service.Create(en);
} /// <summary>
/// 将销售合同分派给其他用户或团队
/// </summary>
/// <param name="assignee">用户或团队引用</param>
public void Assign(EntityReference assignee)
{
AssignRequest request = new AssignRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = contractId };
request.Assignee = assignee;
AssignResponse response = (AssignResponse)service.Execute(request);
} /// <summary>
/// 取消合同
/// </summary>
/// <param name="status">取消的状态</param>
public void CancelContract(int status)
{
CancelContractRequest request = new CancelContractRequest();
request.ContractId = contractId;
request.CancelDate = DateTime.Now;
request.Status = new OptionSetValue(status);
CancelContractResponse response = (CancelContractResponse)service.Execute(request);
} /// <summary>
/// 复制合同
/// </summary>
public void CloneContract()
{
CloneContractRequest request = new CloneContractRequest();
request.ContractId = contractId;
request.IncludeCanceledLines = true;
CloneContractResponse response = (CloneContractResponse)service.Execute(request);
//销售合同
Entity contractEn = response.Entity;
} /// <summary>
/// 续订合同
/// </summary>
public void RenewContract()
{
RenewContractRequest request = new RenewContractRequest();
request.ContractId = contractId;
request.IncludeCanceledLines = true;
//合同的状态
request.Status = ;
RenewContractResponse response = (RenewContractResponse)service.Execute(request);
//销售合同
Entity contractEn = response.Entity;
} /// <summary>
/// 与其他安全主体(用户或团队)共享销售合同
/// </summary>
/// <param name="accessMask">访问权限</param>
/// <param name="principal">用户或团队引用</param>
public void GrantAccessRequest(AccessRights accessMask, EntityReference principal)
{
GrantAccessRequest request = new GrantAccessRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = contractId };
request.PrincipalAccess = new PrincipalAccess() { AccessMask = accessMask, Principal = principal };
GrantAccessResponse response = (GrantAccessResponse)service.Execute(request);
} /// <summary>
/// 删除指定安全主体(用户或团队)对销售合同的所有访问权限
/// </summary>
/// <param name="revokee">用户或团队引用</param>
public void RevokeAccess(EntityReference revokee)
{
RevokeAccessRequest request = new RevokeAccessRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = contractId };
request.Revokee = revokee;
RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);
} /// <summary> ///
/// 删除销售合同 ///
/// </summary>
public void Delete() { service.Delete(entityName, contractId); }
}

Contract Helper的更多相关文章

  1. [C#] 简单的 Helper 封装 -- RegularExpressionHelper

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  2. handlebars自定义helper的写法

    handlebars相对来讲算一个轻量级.高性能的模板引擎,因其简单.直观.不污染HTML的特性,我个人特别喜欢.另一方面,handlebars作为一个logicless的模板,不支持特别复杂的表达式 ...

  3. WCF学习之旅—基于Fault Contract 的异常处理(十八)

       WCF学习之旅—WCF中传统的异常处理(十六) WCF学习之旅—基于ServiceDebug的异常处理(十七) 三.基于Fault Contract 的异常处理 第二个示例是通过定制Servic ...

  4. Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value '"*, Microsoft.AspNet.Mvc.TagHelpers"'

    project.json 配置: { "version": "1.0.0-*", "compilationOptions": { " ...

  5. VS2015突然报错————Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with value 'Microsoft.AspNet.Mvc.Razor.TagHelpers.UrlResolutionTagHelper

    Encountered an unexpected error when attempting to resolve tag helper directive '@addTagHelper' with ...

  6. JavaScript模板引擎artTemplate.js——template.helper()方法

    上一篇文章我们已经讲到了helper()方法,但是上面的例子只是一个参数的写法,如果是多个参数,写法就另有区别了. <div id="user_info"></d ...

  7. [ASP.NET MVC 小牛之路]13 - Helper Method

    我们平时编程写一些辅助类的时候习惯用“XxxHelper”来命名.同样,在 MVC 中用于生成 Html 元素的辅助类是 System.Web.Mvc 命名空间下的 HtmlHelper,习惯上我们把 ...

  8. asp.net MVC helper 和自定义函数@functions小结

    asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...

  9. 重新想象 Windows 8.1 Store Apps (81) - 控件增强: WebView 之加载本地 html, 智能替换 html 中的 url 引用, 通过 Share Contract 分享 WebView 中的内容, 为 WebView 截图

    [源码下载] 重新想象 Windows 8.1 Store Apps (81) - 控件增强: WebView 之加载本地 html, 智能替换 html 中的 url 引用, 通过 Share Co ...

随机推荐

  1. 加域(Netdom)

    客户端运行: netdom.exe join %computername% /domain:testw.com /userd:testw\adadmin /passwordd:boc.123 /reb ...

  2. ELK系统分析Nginx日志并对数据进行可视化展示

    结合之前写的一篇文章:ELK日志分析平台搭建全过程,上篇文章主要讲了部署方法.而这篇文章介绍的是单独监控nginx 日志分析再进行可视化图形展示. 本文环境与上一篇环境一样,前提 elasticsea ...

  3. centos7 docker 使用pipework 做虚拟机

    网卡配置文件 及 bridge的静态配置 centos7 Bridge配置 [root@mon-1 ~]# cd  /etc/sysconfig/network-scripts/ [root@mon- ...

  4. 内置模块之sys

    一.模块sys sys模块主要对解释器相关的操作 1.常用方法和属性 sys.argv    命令行参数List,第一个元素是程序本身路径 sys.exit(n)  退出程序,正常退出时exit(0) ...

  5. Thinkphp 漏洞小试

    首先确定这个网站使用thinkphp的框架 国内很多php开源项目的代码都是使用thinkphp框架编写的,但是thinkphp框架有很多版本,如何才能知道我们使用的框架是哪个版本的呢? 在URL后面 ...

  6. [TJOI2013]攻击装置

    题目 癌我竟然会做 发现我们要求的是一个最大独立集问题 发现一个格子和能攻击到的格子的奇偶性和它都不同,于是我们就可以按照\(i+j\)的奇偶性把整张图分成两个部分 两个部分之间没有连边 于是二分图最 ...

  7. 【LeetCode每天一题】Remove Duplicates from Sorted Array II(移除有序数组中重复的两次以上的数字)

    Given a sorted array nums, remove the duplicates in-place such that duplicates appeared at most twic ...

  8. 跨路径读取cookie

    同域下,即使设置了cookie的路径还是能将不同路径cookie读出来. 1.在/ctf/day3/ 目录设置一个cookie 2.其他目录下是不能访问这个cookie的 3.通过iframe可以实现 ...

  9. [Python 多线程] 详解daemon属性值None,False,True的区别 (五)

    本文以多个例子介绍Python多线程中daemon属性值的区别. 回顾: 前面的文章简单介绍了在现代操作系统中,每一个进程都认为自己独占所有的计算机资源. 或者说线程就是独立的王国,进程间是相对独立的 ...

  10. html字段验证

    (1)连接去掉下划线:style="text-decoration:none" <a href="/example/html/lastpage.html" ...