Quote Helper
using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query; /// <summary>
/// 报价单
/// </summary>
public class QuoteHelper
{
public static readonly string entityName = "quote";
public Guid quoteId = Guid.Empty;
public IOrganizationService service; /// <summary>
/// 创建报价单
/// </summary>
public void Create(Guid accountId)
{
Entity en = new Entity() { LogicalName = entityName };
en["name"] = "报价单测试";
en["accountid"] = new EntityReference() { LogicalName = "account",Id = accountId };
quoteId = service.Create(en);
} /// <summary>
/// 创建报价单及其相关报价单详细信息
/// </summary>
/// <param name="childEn">报价单详细信息</param>
public void CompoundCreate(EntityCollection childEn)
{
CompoundCreateRequest request = new CompoundCreateRequest();
request.Entity = new Entity() { LogicalName = entityName };
request.ChildEntities = childEn;
CompoundCreateResponse response = (CompoundCreateResponse)service.Execute(request);
quoteId = response.Id;
} /// <summary>
/// 将报价单分派给其他用户或团队
/// </summary>
/// <param name="assignee">用户或团队引用</param>
public void Assign(EntityReference assignee)
{
AssignRequest request = new AssignRequest();
request.Target = new EntityReference() { LogicalName = entityName,Id = quoteId };
request.Assignee = assignee;
AssignResponse response = (AssignResponse)service.Execute(request);
} /// <summary>
/// 指定结束报价单
/// </summary>
/// <param name="status">结束的状态值</param>
public void CloseQuote(int status)
{
CloseQuoteRequest request = new CloseQuoteRequest();
request.QuoteClose = new Entity() { LogicalName = entityName,Id = quoteId };
request.Status = new OptionSetValue(status);
CloseQuoteResponse response = (CloseQuoteResponse)service.Execute(request);
} /// <summary>
/// 将报价单转换为销售订单
/// </summary>
public Entity ConvertQuoteToSalesOrder()
{
ConvertQuoteToSalesOrderRequest request = new ConvertQuoteToSalesOrderRequest();
request.QuoteId = quoteId;
request.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("name","accountid");
ConvertQuoteToSalesOrderResponse response = (ConvertQuoteToSalesOrderResponse)service.Execute(request);
//销售订单
Entity solrorderEn = response.Entity;
return solrorderEn;
} /// <summary>
/// 为目标值中指定的实体获取产品的数量小数值
/// </summary>
/// <param name="productId">产品id</param>
/// <param name="uoMId">单位id</param>
public int GetQuantityDecimal(Guid productId, Guid uoMId)
{
GetQuantityDecimalRequest request = new GetQuantityDecimalRequest();
request.Target = new EntityReference() { LogicalName = entityName,Id = quoteId };
request.ProductId = productId;
request.UoMId = uoMId;
GetQuantityDecimalResponse response = (GetQuantityDecimalResponse)service.Execute(request);
return response.Quantity;
} /// <summary>
/// 从商机中检索产品并将其复制到报价单
/// </summary>
/// <param name="opportunityId">商机id</param>
public void GetQuoteProductsFromOpportunity(Guid opportunityId)
{
GetQuoteProductsFromOpportunityRequest request = new GetQuoteProductsFromOpportunityRequest();
request.OpportunityId = opportunityId;
request.QuoteId = quoteId;
GetQuoteProductsFromOpportunityResponse response =
(GetQuoteProductsFromOpportunityResponse)service.Execute(request);
} /// <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 = quoteId };
request.PrincipalAccess = new PrincipalAccess() { AccessMask = accessMask,Principal = principal };
GrantAccessResponse response = (GrantAccessResponse)service.Execute(request);
} /// <summary>
/// 将报价单的状态设置为“草稿”
/// </summary>
public void ReviseQuote()
{
ReviseQuoteRequest request = new ReviseQuoteRequest();
request.QuoteId = quoteId;
request.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("name","accountid");
ReviseQuoteResponse response = (ReviseQuoteResponse)service.Execute(request);
//草稿状态的报价单
Entity quoteEn = response.Entity;
} /// <summary>
/// 汇总或检索与指定的记录(客户或联系人)相关的所有报价单
/// </summary>
/// <param name="target">客户或联系人引用</param>
/// <param name="query">查询条件</param>
/// <param name="rollupType">关联类型</param>
public void Rollup(EntityReference target, QueryBase query, RollupType rollupType)
{
RollupRequest request = new RollupRequest();
request.Target = target;
request.Query = query;
request.RollupType = rollupType;
RollupResponse response = (RollupResponse)service.Execute(request);
EntityCollection entityCollection = response.EntityCollection;
} /// <summary>
/// 删除报价单
/// </summary>
public void Delete()
{
service.Delete(entityName, quoteId);
}
}
Quote Helper的更多相关文章
- [C#] 简单的 Helper 封装 -- RegularExpressionHelper
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- handlebars自定义helper的写法
handlebars相对来讲算一个轻量级.高性能的模板引擎,因其简单.直观.不污染HTML的特性,我个人特别喜欢.另一方面,handlebars作为一个logicless的模板,不支持特别复杂的表达式 ...
- 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": { " ...
- 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 ...
- JavaScript模板引擎artTemplate.js——template.helper()方法
上一篇文章我们已经讲到了helper()方法,但是上面的例子只是一个参数的写法,如果是多个参数,写法就另有区别了. <div id="user_info"></d ...
- [ASP.NET MVC 小牛之路]13 - Helper Method
我们平时编程写一些辅助类的时候习惯用“XxxHelper”来命名.同样,在 MVC 中用于生成 Html 元素的辅助类是 System.Web.Mvc 命名空间下的 HtmlHelper,习惯上我们把 ...
- asp.net MVC helper 和自定义函数@functions小结
asp.net Razor 视图具有.cshtml后缀,可以轻松的实现c#代码和html标签的切换,大大提升了我们的开发效率.但是Razor语法还是有一些棉花糖值得我们了解一下,可以更加强劲的提升我们 ...
- C# random helper class
项目中经常需要模拟些假数据,来做测试.这个随机生成数据的helper类就应用而生: using System; using System.Text; using System.Windows.Me ...
- Qt在pro文件中加入带空格的路径(使用$$quote关键字)
LIBS += -L$$quote(C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib) INCLUDEPATH += $$quote(C: ...
随机推荐
- NS Simulation Basic
这个网站上的一系列讲解NS2的内容真的是深入浅出,看完立刻豁然开朗.所以就接连转了几篇. Scheduling Events那篇里的例子特别好,看完就懂了. http://www.mathcs.emo ...
- QT的键值对应关系 看完开发节省时间 哈哈
http://blog.csdn.net/wangjieest/article/details/8283656
- linux下清空文件的几种方式以及对比
: > filename> filenamecat /dev/null > filename上面这3种方式,能将文件清空,而且文件大小为0而下面两种方式,会让文件中存在空格,导致大小 ...
- Mysql学习---SQL测试题之表结构
创建表结果和数据准备[直接执行即可] /* Navicat MySQL Data Transfer Source Server : ftl1012 Source Server Version : 50 ...
- NFS-heartbeat-drbd模拟NFS高可用
NFS介绍: NFS(Network File System)即网络文件系统,是FreeBSD支持的文件系统中的一种,它允许网络中的计算机之间通过TCP/IP网络共享资源.在NFS的应用中,本地NFS ...
- awrsqrpt.sql简介
ORACLE_HOME/RDBMS/admin/awrsqrpt.sql 这个脚本可以很方便地取出某个sql在某两个快照间隔内,消耗cpu时间,执行次数,逻辑读,物理读,sql的执行计划以及sql的 ...
- February 14 2017 Week 7 Tuesday
Love lives in cottages as well as in courts. 爱情无贵贱,贫富皆有之. Many people, especially boys, complain tha ...
- 打印出类所在的jar包
ackage time; /** * Created by sheting on 10/20/2017 */ public class Test { public static void main(S ...
- android 智能提示
<AutoCompleteTextView android:id="@+id/autoCompleteTextView" android:completionThreshol ...
- Codeforces Round #540 (Div. 3) F1. Tree Cutting (Easy Version) 【DFS】
任意门:http://codeforces.com/contest/1118/problem/F1 F1. Tree Cutting (Easy Version) time limit per tes ...