/// <summary> /// 使用微信模板发送固定消息 /// </summary> /// <param name="request">请求参数</param> /// <returns>结果</returns> public JResult SendMessage(SendMessageRequest request) { var result = new JResult(); try { var strToken = GetAccessToken(request.WeiXinAppId, request.WeiXinAppSecret); if (!strToken.Status) { throw new Exception(strToken.Message); } var wResult = WeiXinHelper.SendTemplateMessage(strToken.Data, request.OpenId, request.TemplateId, request.Data, request.Url); if (wResult.IsErr) { throw new Exception(wResult.ErrMsg); } result.Status = true; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
/// <summary> /// 插入 /// </summary> /// <param name="model">数据模型</param> /// <returns>影响行数</returns> public JResult <int> Insert(FeVideo model) { var result = new JResult <int>() { Status = false }; try { var sysNo = Using <IVideo>().Insert(model); if (sysNo <= 0) { throw new Exception("添加数据失败"); } //LogApp.Instance.Info(new LogRequest() { Source = LogSource.后台, Message = "新增视频" }); result.Data = sysNo; result.Status = true; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
/// <summary> /// 修改状态 /// </summary> /// <param name="sysNo">编码</param> /// <param name="status">状态</param> /// <returns>影响行数</returns> public JResult UpdateStatus(int sysNo, int status) { var result = new JResult(); try { if (!EnumUtil.IsEnumExist <StatusEnum>(status)) { throw new Exception("数据不合法"); } if (Using <IBsUser>().UpdateStatus(sysNo, status) <= 0) { throw new Exception("修改数据失败"); } result.Status = true; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
/// <summary> /// 接管系统异常,自定义处理程序 /// </summary> /// <param name="exceptionContext">异常内容</param> protected override void OnException(ExceptionContext exceptionContext) { exceptionContext.ExceptionHandled = true; var result = new JResult() { Status = false }; var ex = exceptionContext.Exception; //记录日志 try { LogApp.Instance.Error(new LogRequest() { Source = LogEnum.Source.前台, Message = "系统日志", Exception = ex }); } catch (Exception e) { Log4Helper.WriteErrLog("BaseController->OnException日志记录失败", e); } }
/// <summary> /// 删除视频地址 /// </summary> /// <param name="videoSysNo">视频编号</param> /// <returns>影响行数</returns> public JResult Delete(int videoSysNo) { var result = new JResult() { Status = false }; try { if (Using <IVideoItem>().Delete(videoSysNo) <= 0) { throw new Exception("删除数据失败"); } //LogApp.Instance.Info(new LogRequest() { Source = LogSource.后台, Message = "修改视频" }); result.Message = "操作成功!"; result.Status = true; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
/// <summary> /// 修改 /// </summary> /// <param name="model">数据模型</param> /// <returns>影响行数</returns> public JResult Update(FeVideoItem model) { var result = new JResult() { Status = false }; try { if (Using <IVideoItem>().Update(model) <= 0) { throw new Exception("修改数据失败"); } //LogApp.Instance.Info(new LogRequest() { Source = LogSource.后台, Message = "修改视频" }); result.Message = "操作成功!"; result.Status = true; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
/// <summary> /// 插入 /// </summary> /// <param name="model">数据模型</param> /// <returns>影响行数</returns> public JResult Insert(FeVideoCategory model) { var result = new JResult() { Status = false }; try { if (Using <IVideoCategory>().Insert(model) <= 0) { throw new Exception("添加数据失败"); } //LogApp.Instance.Info(new LogRequest() { Source = LogSource.后台, Message = "新增视频" }); result.Status = true; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
/// <summary> /// 新增数据 /// </summary> /// <param name="model">实体</param> /// <returns>系统编号</returns> public JResult <int> Insert(BsUser model) { var result = new JResult <int>(); try { model.PassWord = EncryptionUtil.EncryptWithMd5AndSalt(model.PassWord); model.CreatedDate = DateTime.Now; var row = Using <IBsUser>().Insert(model); if (row <= 0) { throw new Exception("添加数据失败"); } result.Status = true; result.Data = row; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
public JsonResult GetExcelBase64() { var path = $@"{AppDomain.CurrentDomain.BaseDirectory}Content\print.xls"; //这里可以根据业务生成excel模板 var excelBase64 = ExcelHelper.GetBase64ByPath(path); return(Json(JResult.Success("成功", "0", excelBase64))); }
public IActionResult Post([FromForm] SignInModel model) { var flag = false; var msg = string.Empty; if (ModelState.IsValid) { if (WebContext.PlatformSettings.VerifyCodeEnabled && !_verifyProvider.IsValid(model.VerifyCode)) { flag = false; msg = "验证码不正确"; ModelState.AddModelError("verifycode", msg); } else { var orgInfo = WebContext.Org; var u = _systemUserService.GetUserByLoginName(model.LoginName); if (u == null) { flag = false; msg = "帐号不存在"; ModelState.AddModelError("loginname", msg); } else if (u.StateCode == RecordState.Disabled) { flag = false; msg = "帐号已禁用"; ModelState.AddModelError("loginname", msg); } else { if (_systemUserService.IsValidePassword(model.Password, u.Salt, u.Password)) { //登录状态记录 _authenticationService.SignIn(u, true); //获取用户个性化信息 //更新最后登录时间 _systemUserService.Update(n => n.Set(f => f.LastLoginTime, DateTime.Now)//.Set(f => f.IsLogin, true) .Where(f => f.SystemUserId == u.SystemUserId)); msg = "登录成功"; flag = true; } else { flag = false; msg = "密码有误"; ModelState.AddModelError("password", msg); } } } if (flag) { return(JResult.Ok(msg)); } } return(JResult.Error(GetModelErrors())); }
public JsonResult Password(PasswordRequest request) { var response = new JResult() { Status = false }; var result = VHelper.ValidatorRule( new Rule_NotAllowNull(request.OldPassword, "请输入旧密码!"), new Rule_StringLenth(request.Password, min: 6, max: 20, message: "新密码长度在6-20位之间"), new Rule_StringLenth(request.ConfirmPassword, min: 6, max: 20, message: "新确认密码长度在6-20位之间") ); if (!result.IsPass) { response.Status = false; response.Message = result.Message; return(Json(response, JsonRequestBehavior.AllowGet)); } //新密码与确认密码验证 if (!request.Password.Equals(request.ConfirmPassword)) { response.Message = "两次输入密码不一致!"; return(Json(response, JsonRequestBehavior.AllowGet)); } //当前上下文 var customer = CustomerContext.Context; //旧密码验证 if (!EncryptionUtil.VerifyCiphetrextWithMd5AndSalt(request.OldPassword, customer.Password)) { response.Status = false; response.Message = "原登录密码错误!"; return(Json(response, JsonRequestBehavior.AllowGet)); } try { customer.Password = EncryptionUtil.EncryptWithMd5AndSalt(request.Password); if (CustomerApp.Instance.UpdatePassword(customer.SysNo, customer.Password).Status) { response.Status = true; response.Message = "修改密码成功﹗"; } else { response.Message = "修改密码失败﹗"; } } catch (Exception ex) { response.Message = ex.Message; } return(Json(response, JsonRequestBehavior.AllowGet)); }
/// <summary> /// 注册验证码 /// </summary> /// <param name="phoneNumber">手机号</param> public JResult SMSVerify(string phoneNumber) { var response = new JResult() { Status = false }; var rand = WebUtil.Number(6, true); var content = string.Format("【XX】尊敬的用户,您的验证码为{0},热线:888-88888888", rand); var smsCacheKey = CacheKeys.Items.SMS_ + phoneNumber; var smsCountCacheKey = CacheKeys.Items.SMSCount_ + phoneNumber; var sendSMSResponse = this.SendSMS(new SendSMSRequest() { PhoneNumber = phoneNumber, Content = content, Rand = rand, SMSCacheKey = smsCacheKey, SMSCountCacheKey = smsCountCacheKey, catchTime = 120 }); if (sendSMSResponse != null) { var span = DateTime.Now.Subtract(sendSMSResponse.SendTime); //秒数 var seconds = (span.Minutes * 60) + span.Seconds; if (seconds > 120) { var cacheProvider = ClientProxy.GetInstance <IRedisProvider>(); //TODO 验证发送数量 //移除缓存 cacheProvider.Remove(smsCacheKey); //重新发送验证码 this.SendSMS(new SendSMSRequest() { PhoneNumber = phoneNumber, Content = content, Rand = rand, SMSCacheKey = smsCacheKey, SMSCountCacheKey = smsCountCacheKey, catchTime = 120 }); response.StatusCode = "120"; response.Status = true; } else { response.StatusCode = (120 - seconds).ToString(); response.Status = true; } } else { response.Message = "手机号验证码发送失败!"; } return(response); }
/// <summary> /// 根据请求类型返回view或json /// </summary> /// <param name="model"></param> /// <param name="viewName"></param> /// <returns></returns> protected IActionResult DynamicResult(object model, string viewName = "") { if (IsRequestJson) { return(JResult.J(model)); } viewName = viewName.IfEmpty(WebContext.ActionName); return(View(viewName, model)); }
public Result(JResult jResult) { if (jResult == null) { return; } FavoritesCount = jResult.Favorites_Count; CommentsCount = jResult.Comments_Count; }
public JsonResult Fail(string message) { JResult jp = new JResult() { IsSuccess = false, Message = message }; return(Json(jp)); }
public JsonResult Success(string message) { JResult jp = new JResult() { IsSuccess = true, Message = message }; return(Json(jp)); }
/// <summary> /// 取消挂售股权 /// </summary> /// <param name="stockRecordSysNo">股权记录编号</param> /// <param name="customerSysNo">会员编号</param> /// <returns>JResult</returns> public JResult CancelSaleStock(int stockRecordSysNo, int customerSysNo) { var result = new JResult(); try { var record = Using <IFnStockRecord>().Get(stockRecordSysNo); if (record == null) { throw new Exception("数据不存在"); } if (record.OperatorSysNo != customerSysNo) { throw new Exception("该用户不合法"); } using (var tran = new TransactionScope()) { try { var surplusStockNum = record.StockNum - record.TradedStockNum; if (Using <IFnStockAccount>().UpdateCancelSaleStock(customerSysNo, surplusStockNum) <= 0) { throw new Exception("更新股权账户失败"); } if (Using <IFnStockRecord>().UpdateCancelSaleStock(new FnStockRecord() { SysNo = record.SysNo, StockNum = surplusStockNum, Status = StockRecordEnum.StatusEnum.已处理.GetHashCode(), Remarks = string.Format("撤销股权{0};", surplusStockNum) }) <= 0) { throw new Exception("新增股权记录失败"); } result.Status = true; tran.Complete(); } catch (Exception ex) { tran.Dispose(); throw ex; } } } catch (Exception exx) { result.Message = exx.Message; } return(result); }
public override void OnException(ExceptionContext context) { if (!_hostingEnvironment.IsDevelopment()) { return; } context.HttpContext.Response.ContentType = "application/json"; var result = JResult.Error(JsonResultObject.Failure(context.Exception.GetBaseException().Message, 400)); context.Result = result; }
/// <summary> /// 提示记录不存在 /// </summary> /// <returns></returns> protected new IActionResult NotFound() { if (IsRequestJson) { return(JResult.NotFound(T)); } else { return(PromptView(T["notfound_record"])); } }
/// <summary> /// 提示没有权限 /// </summary> /// <returns></returns> protected new IActionResult Unauthorized() { if (IsRequestJson) { return(JResult.Unauthorized(T)); } else { return(PromptView(string.Format(T["security_unauthorized"], HttpContext.GetRouteString("org") + WebContext.LoginUrl))); } }
/// <summary> /// 插入 /// </summary> /// <param name="request">菜单</param> public JResult Save(SaveVideoCategoryRequest request) { var response = new JResult() { Status = false, Message = "添加失败!" }; using (var tran = new TransactionProvider()) { try { var forum = new FeVideoCategory() { SysNo = request.SysNo, Subject = request.Subject, ImageUrl = request.ImageUrl, ParentSysNo = request.ParentSysNo, DisplayOrder = request.DisplayOrder, Status = request.Status }; if (request.SysNo > 0) { var row = Using <IVideoCategory>().Update(forum); if (row <= 0) { throw new Exception("添加失败!"); } tran.Commit(); response.Status = true; response.Message = "更新成功!"; } else { var menuSysNo = Using <IVideoCategory>().Insert(forum); if (menuSysNo <= 0) { throw new Exception("添加版块失败!"); } tran.Commit(); response.Status = true; response.Message = "添加成功!"; } } catch (Exception ex) { tran.Rollback(); response.Message = ex.Message; } } return(response); }
private void LogError(NetSSLException ex) { if (Response == null) { return; } Server.ClearError(); Response.StatusCode = 200; Response.TrySkipIisCustomErrors = true; string exMsg = JsonHelper.Serialize(JResult.Error(ex.Message, ex.ExceptionCode)); Response.Write(exMsg); }
public JsonResult Upgrade(UpgradeRequest request) { var response = new JResult() { Status = false }; //当前上下文 var context = CustomerContext.Context; if (context == null) { response.Message = "用户已超时、请重新登录﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } var customer = CustomerApp.Instance.Get(context.SysNo); if (customer == null) { response.Message = "扩展会员不存在﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } var upgradeGrade = customer.Grade + Step.步长.GetHashCode(); var code = CodeApp.Instance.GetByType(EC.Entity.Enum.CodeEnum.CodeTypeEnum.会员等级信息.GetHashCode()); if (code != null) { var grades = code.Value.ToObject <List <Grade> >(); var grade = grades.FirstOrDefault(p => p.Type == upgradeGrade); if (grade != null) { //验证升级基金 if (customer.UpgradeFundAmount < grade.Amount) { response.StatusCode = ErrorEnum.余额不足.GetHashCode().ToString(); response.Message = "升级基金不足!"; return(Json(response, JsonRequestBehavior.AllowGet)); } } } response = NewCustomerApp.Instance.NewUpgrade(new EC.Entity.Parameter.Request.NewCRM.NewUpgradeRequest() { CustomerSysNo = customer.SysNo }); return(Json(response, JsonRequestBehavior.AllowGet)); }
public JsonResult CashoutCalculate(CalculateRequest request) { var response = new JResult() { Status = false }; //当前上下文 var context = CustomerContext.Context; if (context == null) { response.Message = "用户已超时、请重新登录﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } //会员扩展 var customerExt = CustomerApp.Instance.Get(context.SysNo); if (customerExt == null) { response.Message = "扩展会员不存在﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } if (request.Amount > customerExt.WalletAmount) { response.Message = "当前余额不足﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } if (request.Amount < 10) { response.Message = "提现金额必须为10元﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } //if (customerExt.Grade.Equals(CustomerEnum.Grade.股东.GetHashCode())) //{ // response.Status = true; // response.StatusCode = request.Amount.ToString("F"); //} //else //{ // response.Status = true; // response.StatusCode = (request.Amount / 2).ToString("F"); //} return(Json(response, JsonRequestBehavior.AllowGet)); }
public static IActionResult ShowMessage(this IActionResult result, Status status, string title, string message) { var htpContext = _httpContextAccessor.HttpContext; var tempData = _tempDataDictionaryFactory.GetTempData(htpContext); var messageObj = new JResult { Message = message, Status = status, Title = title }; tempData["Message"] = JsonConvert.SerializeObject(messageObj); return(result); }
/// <summary> /// 发送短信 /// </summary> /// <param name="request">请求参数</param> /// <returns>JResult</returns> /// <remarks>2017-03-31 苟治国 创建</remarks> public JResult SendVerifyCode(SendVerifyCodeRequest request) { var response = new JResult() { Status = false }; var rand = new Random().Next(100000, 999999).ToString(); string content = ""; var verifyCodeCacheKey = request.Key + request.PhoneNo; var smsRequest = SendSms(new SmsRequest() { Mobile = request.PhoneNo, Content = content, Rand = rand, VerifyCodeCacheKey = verifyCodeCacheKey, catchTime = 10 }); if (smsRequest != null) { var span = DateTime.Now.Subtract(smsRequest.SendTime); //秒数 var seconds = (span.Minutes * 60) + span.Seconds; if (seconds > 60) { var _redisProvider = ClientProxy.GetInstance<IRedisProvider>(); //删除缓存 _redisProvider.Remove(verifyCodeCacheKey); //重新发送验证码 SendSms(new SmsRequest() { Mobile = request.PhoneNo, Content = content, Rand = rand, VerifyCodeCacheKey = verifyCodeCacheKey, catchTime = 10 }); response.StatusCode = "60"; response.Status = true; } else { response.StatusCode = (60 - seconds).ToString(); response.Status = true; } } else { response.StatusCode = "手机号验证码发送失败!"; return response; } return response; }
public JsonResult Profile(ProfileRequest request) { var response = new JResult() { Status = false }; var result = VHelper.ValidatorRule( new Rule_NotAllowNull(request.BankNumber, "输入银行卡!") ); if (!result.IsPass) { response.Status = false; response.Message = result.Message; return(Json(response, JsonRequestBehavior.AllowGet)); } //当前上下文 var context = CustomerContext.Context; if (context == null) { response.Message = "用户已超时、请重新登录﹗"; return(Json(response, JsonRequestBehavior.AllowGet)); } var model = new CrCustomer() { SysNo = context.SysNo, Bank = request.Bank, BankNumber = request.BankNumber, }; int row = CustomerApp.Instance.UpdateBankInfo(model); if (row > 0) { response.Status = true; response.Message = "更新用户资料成功﹗"; } else { response.Message = "更新用户资料失败﹗"; } return(Json(response, JsonRequestBehavior.AllowGet)); }
public override void OnActionExecuting(ActionExecutingContext context) { if (context.ModelState.IsValid) { return; } var validationErrors = context.ModelState .Keys .SelectMany(k => context.ModelState[k].Errors) .Select(e => e.ErrorMessage) .ToArray(); context.HttpContext.Response.ContentType = "application/json"; var result = JResult.Error(JsonResultObject.Failure("", data: validationErrors, statusCode: 400)); context.Result = result; }
/// <summary> /// 修改数据 /// </summary> /// <param name="model">实体</param> /// <returns>影响行数</returns> public JResult Update(BsNotice model) { var result = new JResult(); try { var row = Using <IBsNotice>().Update(model); if (row <= 0) { throw new Exception("修改数据失败"); } result.Status = true; } catch (Exception ex) { result.Message = ex.Message; } return(result); }
public JsonResult sendSMS(string phoneNumber) { var response = new JResult() { Status = false }; var result = VHelper.ValidatorRule( new Rule_NotAllowNull(phoneNumber, "账号不能为空!"), new Rule_Mobile(phoneNumber, "输入手机号!") ); if (!result.IsPass) { response.Status = result.IsPass; response.Message = result.Message; return(Json(result, JsonRequestBehavior.AllowGet)); } var customer = CustomerApp.Instance.GetByAccount(phoneNumber); if (customer != null) { response.Status = false; response.Message = "该手机号已注册!"; return(Json(response, JsonRequestBehavior.AllowGet)); } var list = SmsApp.Instance.GetSendingTimes(new SMSQueryRequeest() { PhoneNumber = phoneNumber, StartTime = DateTime.Now.ToString("yyyy-MM-dd 00:00:00"), EndTime = DateTime.Now.ToString("yyyy-MM-dd 23:59:59") }); if (list.Count > 20) { response.Status = false; response.Message = "您今天发20条短信明天在来吧!"; return(Json(response, JsonRequestBehavior.AllowGet)); } return(Json(SmsApp.Instance.SMSVerify(phoneNumber), JsonRequestBehavior.AllowGet)); }
protected override void AssertServiceParameters(ServiceSettings s, JResult r, ExecutionElement ee) { }
protected abstract void AssertServiceParameters(ServiceSettings s, JResult r, ExecutionElement ee);