public ActionResult Add(Msg_EmailSetting model) { Result <int> result = new Result <int>(); ResultView <int> view = new ResultView <int>(); if (Request.Form["IsEnable"] == EnumState.Enable.ToString()) { model.IsEnable = true; } else { model.IsEnable = false; } if (Request.Form["IsConfirm"] == EnumState.Confirmed.ToString()) { model.IsConfirm = true; } else { model.IsConfirm = false; } using (MessageClientProxy proxy = new MessageClientProxy(ProxyEx(Request))) { result = proxy.AddEmailSetting(model); view = result.ToResultView(); } return(Json(view)); }
/// <summary> /// 获取邮件设置 /// </summary> /// <returns></returns> public Msg_EmailSetting GetEmailSetting() { MsgDataContext db = new MsgDataContext(); Msg_EmailSetting model = null; model = db.Msg_EmailSetting.FirstOrDefault(i => i.IsConfirm && i.IsEnable); return(model); }
///<summary> ///修改:邮件接口设置 ///</summary> public Result <int> UpdateEmailSetting(Msg_EmailSetting model) { Result <int> result = new Result <int>(); try { var rows = DataOperateMsg <Msg_EmailSetting> .Get().Update(model); result.Data = rows; result.Flag = EResultFlag.Success; WriteLog(AdminModule.EmailSetting.GetText(), SystemRight.Add.GetText(), "修改邮件接口设置: " + model.Id); } catch (Exception ex) { result.Data = -1; result.Flag = EResultFlag.Failure; result.Exception = new ExceptionEx(ex, "UpdateEmailSetting"); } return(result); }
/// <summary> /// 发送邮件 /// </summary> /// <param name="model"></param> /// <param name="setting"></param> /// <param name="strategy"></param> /// <param name="displayName"></param> public static async void SendEmailAsync(Msg_Email model, Msg_EmailSetting setting, Msg_MessageStrategy strategy, string displayName = "") { await Task.Run(() => { Result <bool> result = null; result = EmailHelper.SendEmail(model.Title, model.EmailCon, model.ReceiveEmaile, setting.MailProtocol, setting.UserName, setting.PassWord, displayName); //以下为回调 //更新状态 model.SendCount += 1; model.State = result.Data; //超出重发次数 if (model.SendCount > strategy.ResendStra) { model.State = true; } model.SenderTime = DateTime.Now; //执行更新 MsgDataContext db = new MsgDataContext(); var entry = db.Entry(model); db.Entry <Msg_Email>(model).State = EntityState.Modified; db.SaveChanges(); }); }
///<summary> ///修改:邮件接口设置 ///</summary> public Result <int> UpdateEmailSetting(Msg_EmailSetting model) { return(base.Channel.UpdateEmailSetting(model)); }
///<summary> ///添加:邮件接口设置 ///</summary> public Result <int> AddEmailSetting(Msg_EmailSetting model) { return(base.Channel.AddEmailSetting(model)); }