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. 深入解读TPC-C指标

    深入解读TPC-C指标 TPC(Transactionprocessing Performance Council,事务处理性能委员会)是由数十家会员公司创建的非盈利组织,总部设在美国.TPC的成员主 ...

  2. cocos2d在CCScrollView中嵌套CCMenu列表

    在cocos2d中,CCMenuItem经常被当做按钮使用.在有许多条目需要逐行显示,并且点击每个条目都触发对应的事件的需求下,最容易想到的是用CCScrollView嵌套CCMenu. 但默认情况下 ...

  3. stream操作 z

    常见并常用的stream一共有 文件流(FileStream), 内存流(MemoryStream), 压缩流(GZipStream), 加密流(CrypToStream), 网络流(NetworkS ...

  4. php集群和分布式理解

    首先架构层次来说: php的集群是指很多台服务器处理同样的工作,指的是硬件上的一般,比如slb负载均衡主要作用是有多台服务器处理同样的工作, php分布式是指多台服务器处理不同的工作,指的是业务上的一 ...

  5. error C2027: use of undefined type 'COleDispatchImpl'的解决方法

    解决办法:在资源管理视图中删除CMDTARG.CPP文件,然后重新编译 设置断点后,F5调试运行,调试运行后,然后关编辑器提示保存对CMDTARG.CPP的修改,点了保存,出现error C2027: ...

  6. TFS--解决新创建的windows用户无法访问TFS的问题

    今天入职新同事,帮忙配置TFS的账号碰到一个问题,TFS账号是映射取administrators组得 所以新建用户之后,无法马上引入TFS.查询原因是 Builtin组中没有该账号,以前也总是碰到新加 ...

  7. Intellij IDEA 代码中类非全路径显示

  8. [USACO11DEC]Umbrellas for Cows

    嘟嘟嘟 我dp真是太弱了,这么简单dp都不会. 令dp[i]表示前 i 头牛头被遮住了的最低成本.则dp[i] = min{dp[i], dp[j - 1] + c[a[i] - a[j] + 1]} ...

  9. 字符串匹配KMP算法(转自阮一峰)

    转自 http://www.ruanyifeng.com/blog/2013/05/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm.html 字符串匹配是计算 ...

  10. ssm分页

    pom.xml配置文件中增加相关的插件. <dependency> <groupId>com.github.pagehelper</groupId> <art ...