public SendSMSModel GetRequireSendSMS() { using (var db = new QMSSystemEntities()) { var report = new SendSMSModel(); report.Phones.AddRange(db.Q_RecieverSMS.Where(x => x.IsActive).Select(x => x.PhoneNumber)); //report.AddRange(db.Q_UserEvaluate.Where(x => !x.IsDeleted && x.SendSMS && !x.Q_User.IsDeleted).Select(x => new SMSModel() { UserName = x.Q_User.Name, ServiceName = x.Q_DailyRequire_Detail.Q_DailyRequire.Q_Service.Name, MajorName = x.Q_DailyRequire_Detail.Q_Major.Name, sms = x.Score })); report.SMS.AddRange(db.Q_UserEvaluate.Where(x => !x.IsDeleted && x.SendSMS && !x.Q_User.IsDeleted).Select(x => new SMSModel() { UserName = x.Q_User.Name, sms = x.Score, MajorName = x.Q_DailyRequire_Detail.Q_Major.Name })); if (report.SMS.Count > 0) { var ThangDGs = db.Q_EvaluateDetail.Where(x => !x.IsDeleted && !x.Q_Evaluate.IsDeleted).ToList(); Q_EvaluateDetail found; int[] arr; for (int i = 0; i < report.SMS.Count; i++) { arr = report.SMS[i].sms.Split('_').Select(x => Convert.ToInt32(x)).ToArray(); if (arr.Length > 1) { found = ThangDGs.FirstOrDefault(x => x.Id == arr[1]); report.SMS[i].sms = (found != null ? found.SmsContent : ""); } } db.Database.ExecuteSqlCommand("update q_userevaluate set sendsms = 0"); db.SaveChanges(); } return(report); } }
public IActionResult func_sendSMS(SendSMSModel model) { if (model.pname.IsNullOrEmpty()) { return(this.FuncResult(new APIReturn(10000, $"参数错误(pname)"))); } if (model.message.IsNullOrEmpty()) { return(this.FuncResult(new APIReturn(10000, $"参数错误(message)"))); } if (model.type == 0) { return(this.FuncResult(new APIReturn(10000, $"参数错误(type)"))); } if ((model.type == 1 || model.type == 4) && model.validcode.IsNullOrEmpty()) { return(this.FuncResult(new APIReturn(10000, $"参数错误(validcode)"))); } /* * string apm_enc = string.Format("act={0}&pname={1}&message={2}&telnumbers={3}&type={4}&validcode={5}&displaynum={6}&server={7}&userid_from={8}&userid_to={9}", "sendsms", model.pname, model.message, model.telnumbers, model.type, model.validcode, model.displaynum, model.server, model.userid_from, model.userid_to); * string result = string.Empty; * result = this.SendToICC(apm_enc); */ SmsType smsType = (SmsType)model.type; CallResult callResult = ESClient.SendSms("if2017", model.pname, model.telnumbers, model.message, smsType, model.validcode); if (callResult.Code == 0) { //JToken jobject = JToken.Parse(callResult.Message); JToken jobject = JToken.Parse(callResult.Source.ToString()); int code = jobject.Value <int>("Code"); //1验证码 2国际短信 3语音短信 4单向互动短信 5双向互动短信 6游戏内招募短信 7通知短信 8内部报警短信 11礼包短信 if (code == 0 && (model.type == 1 || model.type == 4)) { string key = Guid.NewGuid().ToString("N"); RedisHelper.Set(key, model.validcode, 5 * 60); Hashtable table = new Hashtable(); table["smskey"] = key; return(this.FuncResult(new APIReturn(0, "发送成功", table))); } else { return(this.FuncResult(new APIReturn(10130, $"发送失败({code},{ jobject.Value<string>("Message")})"))); } } else { throw new Exception($"调用发送短信中控接口失败({callResult.Message})"); } }
public IActionResult func_sendSMSCode(SendSMSCodeModel model) { SendSMSModel smsModel = new SendSMSModel(); smsModel.pname = model.pname ?? string.Empty; smsModel.telnumbers = model.telnumbers ?? string.Empty; smsModel.type = model.type; Random r = new Random(); string code = r.Next(111111, 999999).ToString(); smsModel.message = code; smsModel.validcode = code; return(func_sendSMS(smsModel)); }
public IActionResult SendWeekSMS(int id, [FromBody] SendSMSModel sendModel) { UserCanAccessOrganization(id); WeekScheduleReportViewModel model = CalculateWeekModel(id, sendModel.ScheduleDate.ToString("MM/dd/yyyy")); foreach (EmployeeScheduleReportViewModel employee in model.Employees) { if (employee.TotalHours == 0) { continue; } string message = null; foreach (var day in employee.Days) { if (day.Shifts.Count == 0) { continue; } message += "---------------\n"; message += day.Day + " " + day.DayDate.ToString("MM/dd/yyyy"); message += "\n"; foreach (var shift in day.Shifts) { message += shift.Name + " - "; message += shift.StartTime.ConvertFromUTC(false).ToString("t") + "-" + shift.EndTime.ConvertFromUTC(false).ToString("t"); message += "\n"; } } // send for employee if (!string.IsNullOrEmpty(employee.SendPhoneNumber) && employee.SendPhoneNumber.Length == 10) { _smsSender.SendSmsAsync(employee.SendPhoneNumber, message); System.Diagnostics.Debug.Write(message); } } return(new ObjectResult(true)); }