public string GetUserNotices(UserNoticeRequest request) { var filter = string.Empty; if (!string.IsNullOrWhiteSpace(request.Search)) { filter += $"<filter type='or'>"; filter += $"<condition attribute='mcs_name' operator='like' value='%{request.Search}%' />"; filter += $"<condition attribute='mcs_content' operator='like' value='%{request.Search}%' />"; filter += $"</filter>"; } //if (!string.IsNullOrWhiteSpace(request.UserId)) //{ // filter += $"<filter type='and'>"; // filter += $"<condition attribute='mcs_user' operator='eq' value='{request.UserId}' />"; // filter += $"</filter>"; //} var fetchString = $@"<fetch version='1.0' count='{request.PageSize}' page='{request.PageIndex}' output-format='xml-platform' mapping='logical' distinct='false'> <entity name='mcs_user_msg'> <attribute name='mcs_name' /> <attribute name='createdon' /> <attribute name='mcs_content' /> <attribute name='mcs_readstatus' /> <attribute name='mcs_readdate' /> <attribute name='mcs_deletestatus' /> <attribute name='mcs_deletedate' /> <attribute name='mcs_url' /> <attribute name='mcs_head_imageurl' /> <attribute name='mcs_user' /> <attribute name='mcs_type' /> <order attribute='createdon' descending='true' /> <filter type='and'> <condition attribute='statecode' operator='eq' value='0' /> <condition attribute='mcs_deletestatus' operator='eq' value='false' /> <condition attribute='mcs_user' operator='eq' value='{request.UserId}' /> {filter} </filter> </entity> </fetch>"; return(fetchString); }
public async Task <QueryResult <CrmEntity> > GetUserNotices(UserNoticeRequest request) { try { var fetchString = _repository.GetUserNotices(request); var fetchXdoc = XDocument.Parse(fetchString); var fetchRequest = new CrmRetrieveMultipleFetchRequestMessage() { EntityName = "mcs_user_msg", FetchXml = fetchXdoc, }; fetchRequest.Headers.Add(dicHeadKey, dicHead[dicHeadKey]); var fetchResponse = await _crmService.Execute(fetchRequest); var fetchResponseResult = fetchResponse as CrmRetrieveMultipleFetchResponseMessage; var queryResult = new QueryResult <CrmEntity>(); queryResult.Results = fetchResponseResult.Value.Results; queryResult.CurrentPage = request.PageIndex; queryResult.TotalCount = 0; //更新消息为已读 //if (queryResult.Results!=null && queryResult.Results.Count>0) //{ // foreach (var item in queryResult.Results) // { // if (int.Parse(item.Attributes["mcs_readstatus"].ToString()) ==0) // { // await UpdateUserNoticeReadStatus(new UserNoticeRequest() { // Id= item.Id.ToString(), // mcs_readstatus=1 // });; // } // } //} return(queryResult); } catch (Exception ex) { throw ex; } }
public async Task <bool> UpdateUserNoticeReadStatus(UserNoticeRequest request) { bool result = false; try { Guid guid = Guid.Empty; if (!string.IsNullOrEmpty(request.Id)) { guid = Guid.Parse(request.Id); } CrmExecuteEntity updateEntity = new CrmExecuteEntity("mcs_user_msg", guid); updateEntity.Attributes.Add("mcs_readstatus", request.mcs_readstatus); await _crmService.Update(updateEntity); result = true; } catch (Exception ex) { result = false; } return(result); }
public async Task <bool> UpdateUserNoticeReadStatus(UserNoticeRequest request) { return(await _userNoticeService.UpdateUserNoticeReadStatus(request)); }
public async Task <QueryResult <CrmEntity> > QueryUserNotices(UserNoticeRequest request) { return(await _userNoticeService.GetUserNotices(request)); }
public async Task<bool> ToRead(UserNoticeRequest request) { return await _appUser.UpdateUserNoticeReadStatus(request); }
public async Task<NewtonsoftJsonActionResult<QueryResult<CrmEntity>>> GetUserNotices(UserNoticeRequest request) { return await _appUser.QueryUserNotices(request); }