private async Task <CrmEntityCollection> GetEntities(ContentListRequest contentListRequest) { var crmRequestHelper = new CrmRequestHelper(); XDocument fetchXdoc = null; string entityName = string.Empty; switch (contentListRequest.Type) { case ContentType.Activity: fetchXdoc = await _contentmanagementRepository.GetActivityListFetchXml(contentListRequest); entityName = "mcs_activitycontents"; break; case ContentType.Front: fetchXdoc = await _contentmanagementRepository.GetFrontListFetchXml(contentListRequest); entityName = "mcs_frontcontent"; break; case ContentType.News: fetchXdoc = await _contentmanagementRepository.GetNewsListFetchXml(contentListRequest); entityName = "mcs_newscontents"; break; } return(await crmRequestHelper.ExecuteAsync(_crmService, entityName, fetchXdoc)); }
public async Task <ContentListResponse> GetList(ContentListRequest contentListRequest) { try { var response = new ContentListResponse() { }; var entities = await GetEntities(contentListRequest); response.ContentList = entities.Results; response.ALLTotalCount = entities.Count; response.PageSize = contentListRequest.PageSize; response.CurrentPage = contentListRequest.PageIndex; response.PicPathPre = await GetConfig(); return(response); } catch (Exception ex) { return(new ContentListResponse() { ErrorMessage = ex.Message + ";" + ex.InnerException?.Message }); } }
public async Task <XDocument> GetFrontListFetchXml(ContentListRequest contentListRequest) { return(await Task <XDocument> .Run(() => { var fetchXml = $@"<fetch version='1.0' count='{contentListRequest.PageSize}' page='{contentListRequest.PageIndex}' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='mcs_frontcontent'> <attribute name='mcs_frontcontentid' /> <attribute name='mcs_name' /> <attribute name='mcs_thumbnail' /> <attribute name='mcs_description' /> <attribute name='mcs_contentstatus' /> <order attribute='mcs_name' descending='false' /> </entity> </fetch>"; return XDocument.Parse(fetchXml); })); }
public async Task <XDocument> GetNewsListFetchXml(ContentListRequest contentListRequest) { //加入新条件,仅显示已上架的新闻 return(await Task <XDocument> .Run(() => { var fetchXml = $@"<fetch version='1.0' count='{contentListRequest.PageSize}' page='{contentListRequest.PageIndex}' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='mcs_newscontents'> <attribute name='mcs_newscontentsid' /> <attribute name='mcs_name' /> <attribute name='mcs_thumbnail' /> <attribute name='mcs_description' /> <attribute name='mcs_contentstatus' /> <order attribute='mcs_name' descending='false' /> <filter type='and'> <condition attribute='statecode' operator='eq' value='0' /> <condition attribute='mcs_contentstatus' operator='eq' value='1' /> </filter> </entity> </fetch>"; return XDocument.Parse(fetchXml); })); }
public async Task <ContentListResponse> GetList(ContentListRequest contentListRequest) { return(await _contentmanagementService.GetList(contentListRequest)); }
public async Task <NewtonsoftJsonActionResult <ContentListResponse> > GetContentList(ContentListRequest contentListRequest) { return(await _appContentManagement.GetList(contentListRequest)); }