using System;
using Microsoft.Xrm.Sdk;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Query; /// <summary>
/// 约会
/// </summary>
public class AppointmentHelper
{
public static readonly string entityName = "appointment";
public Guid appointmentId = Guid.Empty;
public IOrganizationService service; /// <summary>
/// 创建约会
/// </summary>
public void Create()
{
WhoAmIRequest userRequest = new WhoAmIRequest();
WhoAmIResponse userResponse = (WhoAmIResponse)service.Execute(userRequest);
Entity activitypartyEn = new Entity() { LogicalName = "activityparty" };
activitypartyEn["partyId"] = new EntityReference() { LogicalName = "systemuser", Id = userResponse.UserId }; Entity en = new Entity() { LogicalName = entityName };
en["subject"] = "约会测试";
en["scheduledstart"] = DateTime.Now.AddHours();
en["scheduledend"] = DateTime.Now.AddHours();
en["location"] = "办公室";
en["requiredattendees"] = new Entity[] { activitypartyEn };
en["organizer"] = new Entity[] { activitypartyEn };
appointmentId = service.Create(en);
} /// <summary>
/// 向现有约会中添加定期信息,以使其成为定期主约会
/// </summary>
/// <param name="target">目标信息</param>
public void AddRecurrence(Entity target)
{
AddRecurrenceRequest request = new AddRecurrenceRequest();
request.AppointmentId = appointmentId;
request.Target = target;
AddRecurrenceResponse response = (AddRecurrenceResponse)service.Execute(request);
Guid id = response.id;
} /// <summary>
/// 将约会分派给其他用户或团队
/// </summary>
/// <param name="assignee">用户或团队引用</param>
public void Assign(EntityReference assignee)
{
AssignRequest request = new AssignRequest();
request.Target = new EntityReference() { LogicalName = entityName, Id = appointmentId };
request.Assignee = assignee;
AssignResponse response = (AssignResponse)service.Execute(request);
} /// <summary>
/// 安排或预定约会
/// </summary>
public void Book()
{
BookRequest request = new BookRequest();
request.Target = new Entity() { LogicalName = entityName, Id = appointmentId };
BookResponse response = (BookResponse)service.Execute(request);
ValidationResult validationResult = response.ValidationResult;
} /// <summary>
/// 重新安排约会
/// </summary>
public void Reschedule()
{
RescheduleRequest request = new RescheduleRequest();
request.Target = new Entity() { LogicalName = entityName, Id = appointmentId };
RescheduleResponse response = (RescheduleResponse)service.Execute(request);
ValidationResult validationResult = response.ValidationResult;
} /// <summary> ///
/// 删除约会 ///
/// </summary>
public void Delete() { service.Delete(entityName, appointmentId); }
}

Appointment 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. 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": { " ...

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

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

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

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

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

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

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

  8. C# random helper class

      项目中经常需要模拟些假数据,来做测试.这个随机生成数据的helper类就应用而生: using System; using System.Text; using System.Windows.Me ...

  9. @helper函数使用方法

    这个函数方法,我也是通过别人博客看到的,感觉不错和大家一起学习分享一下. 1.自定义函数方法,只在同一个view视图文件里调用 Controller public ActionResult Index ...

随机推荐

  1. androidUI异步消息

    private Handler handler = new Handler(){ public void handleMessage(android.os.Message msg) { switch ...

  2. SQL Server ->> 斐波那契数列(Fibonacci sequence)

    斐波那契数列(Fibonacci sequence)的T-SQL实现 ;WITH T AS ( AS BIGINT) AS curr, CAST(NULL AS BIGINT) AS prv UNIO ...

  3. C# 使用 Invoke 实现函数的白盒 UT 测试

    公有方法可以直接调用,但是一些非公开的方法,在覆盖率测试的时候也需要覆盖,可以使用 Invoke 来调用. 调用方法如下,其中 this 可以改为被调用的方法所属的类名,通过 BindingFlags ...

  4. 教你如何封装异步网络连接NSURLConnection实现带有百分比的下载

    教你如何封装异步网络连接NSURLConnection实现带有百分比的下载 注:本教程需要你对block有着较为深刻的理解,且对如何封装对象有着一些经验. 也许你已经用惯了AFNetworking2. ...

  5. Elasticsearch学习总结--原理篇

    一.概念 1.1 官方文档 以下总结自ElasticSearch的官方文档以及自己的一些实践,有兴趣的可以直接阅读官方文档: https://www.elastic.co/guide/en/elast ...

  6. Redis 缓存穿透

    Redis 缓存穿透 https://www.cnblogs.com/jiekzou/p/9212114.html 场景描述:我们在项目中使用缓存通常都是先检查缓存中是否存在,如果存在直接返回缓存内容 ...

  7. angular中ngOnChanges与组件变化检测的关系

    1.ngOnChanges只有在输入值改变的时候才会触发,如果输入值(@Input)是一个对象,改变对象内的属性的话是不会触发ngOnChanges的. 2.组件的变化检测: 2a.changeDet ...

  8. 关于Struts2中的ognl-2.6.11.jar和ognl-2.7.3.jar解决思路

    关于Struts2中的ognl-2.6.11.jar和ognl-2.7.3.jar建了一个简单的工程:导入的jar包有六个,包括commons-fileupload-1.2.1.jarcommons- ...

  9. ListView实现下拉刷新(二)隐藏头布局

    一.问题分析 在上一篇中,我们将头布局加到了ListView上.但是没有隐藏他.你可能会想,隐藏还不简单,直接给它设置为GONE属性不就可以了吗,在需要的时候再设定为可见.没错,这正是ListView ...

  10. 洛谷 P4593 【[TJOI2018]教科书般的亵渎】

    题目分析 一眼看上去就像是一个模拟题目,但是\(n\)的范围过大. 冷静分析一下发现难点在于如何快速求出幂和. 考虑使用伯努利数. \(B_0=1\) \(B_n=-\frac{1}{n+1}\sum ...