/// <summary> /// 发送短信-前台界面+后台处理 /// </summary> public ActionResult SendSMS() { if (Request.HttpMethod == "GET") { SMSViewData viewData = new SMSViewData(); viewData.OrgList = from o in CQGJ.Org select o; return View("SendSMS", viewData); } else { // 短信内容 string content = GetString("SMS_Content"); // Request.Form["orgs_admin_phone"]为页面传递到后台的电话字符串 if (Request.Form["orgs_admin_phone"] != null && !Request.Form["orgs_admin_phone"].Equals("")) { // 对电话字符串进行分割 string strCellPhone = Request.Form["orgs_admin_phone"].ToString(); // 用分号代替网页传递过来号码字符串的逗号, // 并将重新生成的电话号吗串保存在新的字符串对象中 string newCellPhone = strCellPhone.Replace(',', ';'); // 将短信保存到数据库中,由短信猫自行发送 T_SendTask task = new T_SendTask(); task.DestNumber = newCellPhone; task.Content = content; task.SendFlag = 0; task.SendTime = DateTime.Now; task.SplitCount = 0; task.MsgType = 0; CQGJ.AddToT_SendTask(task); CQGJ.SaveChanges(); //string[] cellPhone = strCellPhone.Split(','); // 将短信保存到数据库中,由短信猫自行发送 /* for (int i = 0; i < cellPhone.Length; i++) { T_SendTask task = new T_SendTask(); task.DestNumber = cellPhone[i]; task.Content = content; task.SendFlag = 0; task.SendTime = DateTime.Now; task.SplitCount = 0; task.MsgType = 0; CQGJ.AddToT_SendTask(task); CQGJ.SaveChanges(); } */ } // 跳转至已发送短信页面 return RedirectToAction("SentList/1"); } }
/// <summary> /// 列出已接收短信的机构 /// </summary> /// <param name="id"></param> public void ListSentDetail(int id) { // 定义短信详细信息对象 SMSViewData SMSVD = new SMSViewData(); // 获取短信内容 T_SendTask sentTask = new T_SendTask(); try { // 获取该条已发送短信信息 sentTask = (from s in CQGJ.T_SendTask where s.TaskID == id select s).First(); } catch { } // 获取接收人 SMSVD.Receiver = new SMSToOrgsListViewData(); SMSVD.Receiver.SendDestList = new List<SMSInfo>(); SMSVD.Receiver.SendDestList = GetSentOrgsAndAdminList(id); // 获取短信内容 SMSVD.SendContent = sentTask.Content; // 获取发送时间 SMSVD.SendTime = (DateTime)sentTask.SendTime; RenderView("SMSSent", SMSVD); }