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

crm操作知识库文章实体

时间:2014-07-20 10:28:18      阅读:229      评论: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 KbArticleHelper
    {
        public static readonly string entityName = "kbarticle";
        public Guid kbArticleId = Guid.Empty;
        public IOrganizationService service;

        /// <summary>
        /// 创建知识库文章
        /// </summary>
        public void Create()
        {
            Entity en = new Entity() { LogicalName = entityName };
            en["title"] = "知识库文章测试";
            kbArticleId = service.Create(en);
        }

        /// <summary>
        /// 检索指定的产品的前十篇知识库文章
        /// </summary>
        /// <param name="productId">产品id</param>
        public void RetrieveByTopIncidentProductKbArticle(Guid productId)
        {
            RetrieveByTopIncidentProductKbArticleRequest request = new RetrieveByTopIncidentProductKbArticleRequest();
            request.ProductId = productId;
            RetrieveByTopIncidentProductKbArticleResponse response =
                                (RetrieveByTopIncidentProductKbArticleResponse)service.Execute(request);
            EntityCollection entityCollection = response.EntityCollection;
        }

        /// <summary>
        /// 检索指定的主题的前十篇知识库文章
        /// </summary>
        /// <param name="subjectId">主题id</param>
        public void RetrieveByTopIncidentSubjectKbArticle(Guid subjectId)
        {
            RetrieveByTopIncidentSubjectKbArticleRequest request = new RetrieveByTopIncidentSubjectKbArticleRequest();
            request.SubjectId = subjectId;
            RetrieveByTopIncidentSubjectKbArticleResponse response =
                (RetrieveByTopIncidentSubjectKbArticleResponse)service.Execute(request);
            EntityCollection entityCollection = response.EntityCollection;
        }

        /// <summary>
        /// 查找正文中包含指定文本的所有文档索引
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <param name="text">指定文本</param>
        /// <param name="subjectId">主题id</param>
        public void SearchByBodyKbArticle(QueryBase query,string text,Guid subjectId)
        {
            SearchByBodyKbArticleRequest request = new SearchByBodyKbArticleRequest();
            request.QueryExpression = query;
            request.UseInflection = true;
            request.SearchText = text;
            request.SubjectId = subjectId;
            SearchByBodyKbArticleResponse response = (SearchByBodyKbArticleResponse)service.Execute(request);
            EntityCollection entityCollection = response.EntityCollection;
        }

        /// <summary>
        /// 查找包含指定关键字的所有文档索引
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <param name="text">指定文本</param>
        /// <param name="subjectId">主题id</param>
        public void SearchByKeywordsKbArticle(QueryBase query, string text, Guid subjectId)
        {
            SearchByKeywordsKbArticleRequest request = new SearchByKeywordsKbArticleRequest();
            request.QueryExpression = query;
            request.UseInflection = true;
            request.SearchText = text;
            request.SubjectId = subjectId;
            SearchByKeywordsKbArticleResponse response = (SearchByKeywordsKbArticleResponse)service.Execute(request);
            EntityCollection entityCollection = response.EntityCollection;
        }

        /// <summary>
        /// 查找标题中包含指定文本的所有文档索引
        /// </summary>
        /// <param name="query">查询条件</param>
        /// <param name="text">指定文本</param>
        /// <param name="subjectId">主题id</param>
        public void SearchByTitleKbArticle(QueryBase query, string text, Guid subjectId)
        {
            SearchByTitleKbArticleRequest request = new SearchByTitleKbArticleRequest();
            request.QueryExpression = query;
            request.UseInflection = true;
            request.SearchText = text;
            request.SubjectId = subjectId;
            SearchByTitleKbArticleResponse response = (SearchByTitleKbArticleResponse)service.Execute(request);
            EntityCollection entityCollection = response.EntityCollection;
        }

        /// <summary>
        /// 删除知识库文章
        /// </summary>
        public void Delete()
        {
            service.Delete(entityName, kbArticleId);
        }
    }

crm操作知识库文章实体

标签:crm创建知识库文章   crm检索指定的产品的前十篇知识库文章   crm检索指定的主题的前十篇知识库文章   crm删除知识库文章   crm自定义开发   

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

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