码迷,mamicode.com
首页 > 其他好文 > 详细

crm操作传真实体

时间:2014-07-21 11:15:55      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:crm创建传真   crm将传真分派给其他用户或团队   crm发送传真   crm自定义开发   crm   

using System;
    using Microsoft.Xrm.Sdk;
    using Microsoft.Crm.Sdk.Messages;
    using Microsoft.Xrm.Sdk.Query;
   
    /// <summary>
    /// 传真
    /// </summary>
    public class FaxHelper
    {
        public static readonly string entityName = "fax";
        public Guid faxId = Guid.Empty;
        public IOrganizationService service;

        /// <summary>
        /// 创建传真
        /// </summary>
        public void Create()
        {
            WhoAmIRequest userRequest = new WhoAmIRequest();
            WhoAmIResponse userResponse = (WhoAmIResponse)service.Execute(userRequest);
            Guid _userId = userResponse.UserId;

            Entity activityEn = new Entity() { LogicalName = "activityparty" };
            activityEn["partyId"] = new EntityReference() { LogicalName = "systemuser",Id = _userId };

            Entity en = new Entity() { LogicalName = entityName };
            en["subject"] = "传值测试";
            en["from"] = new Entity[]{ activityEn };
            en["to"] = new Entity[] { activityEn };
            faxId = 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 = faxId };
            request.Assignee = assignee;
            AssignResponse response = (AssignResponse)service.Execute(request);
        }

        /// <summary>
        /// 发送传真
        /// </summary>
        public void SendFax()
        {
            SendFaxRequest request = new SendFaxRequest();
            request.FaxId = faxId;
            request.IssueSend = true;
            SendFaxResponse response = (SendFaxResponse)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 = faxId };
            request.Revokee = revokee;
            RevokeAccessResponse response = (RevokeAccessResponse)service.Execute(request);
        }

        /// <summary>
        /// 删除传真
        /// </summary>
        public void Delete()
        {
            service.Delete(entityName, faxId);
        }
    }

crm操作传真实体

标签:crm创建传真   crm将传真分派给其他用户或团队   crm发送传真   crm自定义开发   crm   

原文地址:http://blog.csdn.net/y_f123/article/details/38009967

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!