/* * 获取回复 */ public void testReply(SmsClient smsClient) { //3. 设置请求参数 ReplyRequest request = new ReplyRequest(); request.RegionId = "cn-north-1"; // 设置应用ID 应用管理-文本短信-概览 页面可以查看应用ID request.AppId = "{{AppId}}"; // 设置查询日期 时间格式:2019-09-01 request.DataDate = "{{DataDate}}"; // 设置要查询的手机号列表 非必传 List <string> phoneList = new List <string>() { "13800013800" // , // "phone number" }; request.PhoneList = phoneList; //4. 执行请求 var response = smsClient.Reply(request).Result; Console.WriteLine(JsonConvert.SerializeObject(response)); Console.ReadLine(); }
public async Task <IActionResult> EditReply([FromRoute] int postId, [FromRoute] int id, [FromBody] ReplyRequest request) { if (postId != request.PostId) { return(BadRequest("Post id in route doesn't match request post id.")); } if (!await _postManager.PostExists(postId)) { return(NotFound("Post does not exist.")); } var replyInDb = await _replyManager.GetReply(id); if (replyInDb == null) { return(NotFound("Reply does not exist.")); } var user = await _userManager.GetUserAsync(HttpContext.User); if (replyInDb.AuthorId != user.Id && !await _userManager.IsInRoleAsync(user, Roles.Admin)) { return(BadRequest("You are not author of reply.")); } _mapper.Map(request, replyInDb); _replyManager.UpdateReply(replyInDb); var response = _mapper.Map <ReplyResponse>(replyInDb); return(Ok(response)); }
public OperationResult Update(ReplyRequest model) { var checkListValueList = new List <string>(); var fieldValueList = new List <string>(); var core = _coreHelper.GetCore(); try { model.ElementList.ForEach(element => { checkListValueList.AddRange(CaseUpdateHelper.GetCheckList(element)); fieldValueList.AddRange(CaseUpdateHelper.GetFieldList(element)); }); } catch (Exception exception) { return(new OperationResult(false, "Case could not be updated")); } try { core.CaseUpdate(model.Id, fieldValueList, checkListValueList); return(new OperationResult(true, "Case has been updated")); } catch (Exception) { return(new OperationResult(false, "Case could not be updated")); } }
public OperationResult Update(ReplyRequest model) { var checkListValueList = new List <string>(); var fieldValueList = new List <string>(); var core = _coreHelper.GetCore(); try { model.ElementList.ForEach(element => { checkListValueList.AddRange(CaseUpdateHelper.GetCheckList(element)); fieldValueList.AddRange(CaseUpdateHelper.GetFieldList(element)); }); } catch (Exception) { return(new OperationResult(false, LocaleHelper.GetString("CaseCouldNotBeUpdated"))); } try { core.CaseUpdate(model.Id, fieldValueList, checkListValueList); core.CaseUpdateFieldValues(model.Id); return(new OperationResult(true, LocaleHelper.GetString("CaseHasBeenUpdated"))); } catch (Exception) { return(new OperationResult(false, LocaleHelper.GetString("CaseCouldNotBeUpdated"))); } }
/// <summary> /// Send a reply. /// </summary> /// <param name="reply"> /// <para> /// The message that has been sent. /// </para> /// <para> /// Note: messages with empty content are neither saved to the data source, nor forwarded to /// clients. Messages with missing topic IDs are also ignored. /// </para> /// </param> public async Task SendAsync(ReplyRequest reply) { if (_disposed) { throw new Exception("Client has been disposed."); } await _hubConnection.SendAsync(nameof(IWikiTalkHub.Send), reply).ConfigureAwait(false); }
public async Task <IActionResult> Update([FromBody] ReplyRequest model, int templateId) { if (!await _permissionsService.CheckEform(templateId, AuthConsts.EformClaims.CasesClaims.CaseUpdate)) { return(Forbid()); } return(Ok(await _casesService.Update(model))); }
public async Task Reply_EmptyId() { var request = new ReplyRequest { CommentId = Guid.Empty }; var ctl = CreateCommentController(); var result = await ctl.Reply(request, null); Assert.IsInstanceOf <BadRequestObjectResult>(result); }
public async Task <OperationResult> Update(ReplyRequest model) { var checkListValueList = new List <string>(); var fieldValueList = new List <string>(); var core = await _coreHelper.GetCore(); var locale = await _userService.GetCurrentUserLocale(); var language = core.DbContextHelper.GetDbContext().Languages.Single(x => x.LanguageCode.ToLower() == locale.ToLower()); try { model.ElementList.ForEach(element => { checkListValueList.AddRange(CaseUpdateHelper.GetCheckList(element)); fieldValueList.AddRange(CaseUpdateHelper.GetFieldList(element)); }); } catch (Exception ex) { Log.LogException(ex.Message); Log.LogException(ex.StackTrace); return(new OperationResult(false, _localizationService.GetString("CaseCouldNotBeUpdated") + $" Exception: {ex.Message}")); } try { await core.CaseUpdate(model.Id, fieldValueList, checkListValueList); await core.CaseUpdateFieldValues(model.Id, language); if (CaseUpdateDelegates.CaseUpdateDelegate != null) { var invocationList = CaseUpdateDelegates.CaseUpdateDelegate .GetInvocationList(); foreach (var func in invocationList) { func.DynamicInvoke(model.Id); } } return(new OperationResult(true, _localizationService.GetString("CaseHasBeenUpdated"))); } catch (Exception ex) { Log.LogException(ex.Message); Log.LogException(ex.StackTrace); return(new OperationResult(false, _localizationService.GetString("CaseCouldNotBeUpdated") + $" Exception: {ex.Message}")); } }
public async Task Reply_CommentDisabled() { var request = new ReplyRequest { CommentId = Guid.NewGuid() }; _mockBlogConfig.Setup(p => p.ContentSettings).Returns(new ContentSettings { EnableComments = false }); var ctl = CreateCommentController(); var result = await ctl.Reply(request, null); Assert.IsInstanceOf <ForbidResult>(result); }
public ResultJson InsertReply(ReplyRequest request) { #region 检测有无临时图片 if (request.ImgList.Contains("temp")) { var array = request.ImgList.Split('|').Where(p => !string.IsNullOrEmpty(p)).ToList(); request.ImgList = ""; foreach (var item in array) { if (item.Contains("temp")) { FileHelper.Instance.Move(HttpContext.Current.Server.MapPath(item), HttpContext.Current.Server.MapPath($"/current/images/Commodity/" + item.Split('/').Last()), HttpContext.Current.Server.MapPath($"/current/images/Commodity")); request.ImgList = request.ImgList + $"/current/images/Commodity/" + item.Split('/').Last() + "|"; } else { request.ImgList = request.ImgList + item + "|"; } } } #endregion Reply reply = new Reply { Content = request.Content, EvalinfoId = request.ParentEvalId, ImageList = request.ImgList, Id = request.ReplyId }; if (EvaluateFunc.Instance.InsertReply(reply)) { return(new ResultJson { HttpCode = 200, Message = "操作成功!" }); } else { return(new ResultJson { HttpCode = 400, Message = "操作失败,请再次尝试!" }); } }
public async Task <IActionResult> AddReplyToPost([FromRoute] int postId, [FromBody] ReplyRequest request) { if (postId != request.PostId) { return(BadRequest("Post id in route doesn't match post id in request.")); } if (!await _postManager.PostExists(postId)) { return(NotFound("Post does not exist.")); } var authorId = _userManager.GetUserId(HttpContext.User); var reply = _mapper.Map <Reply>(request); reply.AuthorId = authorId; _replyManager.AddReply(reply); var response = _mapper.Map <ReplyResponse>(reply); return(CreatedAtAction(nameof(GetReply), new { postId = postId, replyId = reply.Id }, response)); }
public async Task <IActionResult> Update([FromBody] ReplyRequest model) { return(Ok(await _itemsPlanningCaseService.Update(model))); }
/// <summary> /// 短信回复接口 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <ReplyResponse> Reply(ReplyRequest request) { return(await new ReplyExecutor().Client(this).Execute <ReplyResponse, ReplyResult, ReplyRequest>(request).ConfigureAwait(false)); }
/// <summary> /// 短信回复接口 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public ReplyResponse Reply(ReplyRequest request) { return(new ReplyExecutor().Client(this).Execute <ReplyResponse, ReplyResult, ReplyRequest>(request)); }
public async Task <OperationResult> Update(ReplyRequest model) { var checkListValueList = new List <string>(); var fieldValueList = new List <string>(); var core = await _coreHelper.GetCore(); var language = await _userService.GetCurrentUserLanguage(); try { model.ElementList.ForEach(element => { checkListValueList.AddRange(CaseUpdateHelper.GetCheckList(element)); fieldValueList.AddRange(CaseUpdateHelper.GetFieldList(element)); }); } catch (Exception ex) { Log.LogException(ex.Message); Log.LogException(ex.StackTrace); return(new OperationResult(false, $"{_localizationService.GetString("CaseCouldNotBeUpdated")} Exception: {ex.Message}")); } try { await core.CaseUpdate(model.Id, fieldValueList, checkListValueList); await core.CaseUpdateFieldValues(model.Id, language); if (model.IsDoneAtEditable) { var sdkDbContext = core.DbContextHelper.GetDbContext(); var foundCase = await sdkDbContext.Cases .Where(x => x.Id == model.Id && x.WorkflowState != Constants.WorkflowStates.Removed) .FirstOrDefaultAsync(); if (foundCase != null) { if (foundCase.DoneAt != null) { var newDoneAt = new DateTime(model.DoneAt.Year, model.DoneAt.Month, model.DoneAt.Day, foundCase.DoneAt.Value.Hour, foundCase.DoneAt.Value.Minute, foundCase.DoneAt.Value.Second); foundCase.DoneAtUserModifiable = newDoneAt; } await foundCase.Update(sdkDbContext); } else { return(new OperationResult(false, _localizationService.GetString("CaseNotFound"))); } } if (CaseUpdateDelegates.CaseUpdateDelegate != null) { var invocationList = CaseUpdateDelegates.CaseUpdateDelegate .GetInvocationList(); foreach (var func in invocationList) { func.DynamicInvoke(model.Id); } } return(new OperationResult(true, _localizationService.GetString("CaseHasBeenUpdated"))); } catch (Exception ex) { Log.LogException(ex.Message); Log.LogException(ex.StackTrace); return(new OperationResult(false, _localizationService.GetString("CaseCouldNotBeUpdated") + $" Exception: {ex.Message}")); } }
public async Task <OperationResult> Update(ReplyRequest model) { var checkListValueList = new List <string>(); var fieldValueList = new List <string>(); var core = await _coreHelper.GetCore(); var language = await _userService.GetCurrentUserLanguage(); var currentUser = await _userService.GetCurrentUserAsync(); try { model.ElementList.ForEach(element => { checkListValueList.AddRange(CaseUpdateHelper.GetCheckList(element)); fieldValueList.AddRange(CaseUpdateHelper.GetFieldList(element)); }); } catch (Exception ex) { Log.LogException(ex.Message); Log.LogException(ex.StackTrace); return(new OperationResult(false, $"{_localizationService.GetString("CaseCouldNotBeUpdated")} Exception: {ex.Message}")); } try { await core.CaseUpdate(model.Id, fieldValueList, checkListValueList); await core.CaseUpdateFieldValues(model.Id, language); var sdkDbContext = core.DbContextHelper.GetDbContext(); var foundCase = await sdkDbContext.Cases .Where(x => x.Id == model.Id && x.WorkflowState != Constants.WorkflowStates.Removed) .FirstOrDefaultAsync(); if (foundCase != null) { if (foundCase.DoneAt != null) { var newDoneAt = new DateTime(model.DoneAt.Year, model.DoneAt.Month, model.DoneAt.Day, foundCase.DoneAt.Value.Hour, foundCase.DoneAt.Value.Minute, foundCase.DoneAt.Value.Second); foundCase.DoneAtUserModifiable = newDoneAt; } // foundCase.SiteId = sdkDbContext.Sites // .Where(x => x.WorkflowState != Constants.WorkflowStates.Removed) // .Single(x => x.Name == $"{currentUser.FirstName} {currentUser.LastName}").Id; foundCase.Status = 100; await foundCase.Update(sdkDbContext); var planningCase = await _dbContext.PlanningCases.SingleAsync(x => x.MicrotingSdkCaseId == model.Id); var planningCaseSite = await _dbContext.PlanningCaseSites.SingleOrDefaultAsync(x => x.MicrotingSdkCaseId == model.Id && x.PlanningCaseId == planningCase.Id); if (planningCaseSite == null) { planningCaseSite = new PlanningCaseSite() { MicrotingSdkCaseId = model.Id, PlanningCaseId = planningCase.Id, MicrotingSdkeFormId = planningCase.MicrotingSdkeFormId, PlanningId = planningCase.PlanningId, Status = 100, MicrotingSdkSiteId = (int)foundCase.SiteId }; await planningCaseSite.Create(_dbContext); } planningCaseSite.MicrotingSdkCaseDoneAt = foundCase.DoneAtUserModifiable; planningCaseSite = await SetFieldValue(planningCaseSite, foundCase.Id, language); await planningCaseSite.Update(_dbContext); planningCase.MicrotingSdkCaseDoneAt = foundCase.DoneAtUserModifiable; planningCase = await SetFieldValue(planningCase, foundCase.Id, language); await planningCase.Update(_dbContext); } else { return(new OperationResult(false, _localizationService.GetString("CaseNotFound"))); } return(new OperationResult(true, _localizationService.GetString("CaseHasBeenUpdated"))); } catch (Exception ex) { Log.LogException(ex.Message); Log.LogException(ex.StackTrace); return(new OperationResult(false, _localizationService.GetString("CaseCouldNotBeUpdated") + $" Exception: {ex.Message}")); } }