SendMsg.aspx.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Net;
  8. using System.Text;
  9. using System.Xml;
  10. using System.IO;
  11. namespace Com.Jpsoft.Hospital.Web.Module.FllowUp.MedicalQuality
  12. {
  13. //public partial class SendMsg : System.Web.UI.Page
  14. public partial class SendMsg : Com.Jpsoft.Hospital.Web.Common.BasePage
  15. {
  16. protected override void OnInit(EventArgs e)
  17. {
  18. if (!IsPostBack)
  19. {
  20. base.AutoCheckRight = false;
  21. base.CheckRightParam = Com.Jpsoft.Hospital.Web.Common.PageFuntionType.Insert;
  22. }
  23. base.OnInit(e);
  24. }
  25. protected void Page_Load(object sender, EventArgs e)
  26. {
  27. if (!IsPostBack)
  28. SetPageData();
  29. }
  30. private void SetPageData()
  31. {
  32. string ids = string.Empty;
  33. string con = string.Empty;
  34. string next = string.Empty;
  35. string ct = string.Empty;
  36. string mobiles = string.Empty;
  37. string id = string.Empty;
  38. if (Request.QueryString["ct"] != null)
  39. {
  40. ct = Request.QueryString["ct"].ToString();
  41. }
  42. if (Request.QueryString["id"] != null)
  43. {
  44. id = Request.QueryString["id"].ToString();
  45. }
  46. if (Request.QueryString["ids"] != null)
  47. {
  48. ids = Request.QueryString["ids"].ToString();
  49. }
  50. if (Request.QueryString["con"] != null)
  51. {
  52. con = Request.QueryString["con"].ToString();
  53. }
  54. if (Request.QueryString["next"] != null)
  55. {
  56. next = Request.QueryString["next"].ToString();
  57. }
  58. //住院病人
  59. if (ct == "1" || ct == "3")
  60. {
  61. Com.Jpsoft.Hospital.BLL.Ex.ZY_BRSYKEx bll = new BLL.Ex.ZY_BRSYKEx();
  62. DataTable dt = bll.GetList(" blh in(" + ids + ") and brzt!='9'");
  63. foreach (DataRow dr in dt.Rows)
  64. mobiles += "," + dr["lxrdh"].ToString();
  65. if (mobiles.Length > 0)
  66. mobiles = mobiles.Substring(1);
  67. txtMobiles.InnerText = mobiles;
  68. if (ct == "1")
  69. txtType.Text = "住院随访";
  70. else
  71. txtType.Text = "科研随访";
  72. }
  73. //门诊病人
  74. else if (ct == "2")
  75. {
  76. Com.Jpsoft.Hospital.BLL.Ex.SF_BRXXKEx bll = new BLL.Ex.SF_BRXXKEx();
  77. DataTable dt = bll.GetPhone(" patid in(" + ids + ")");
  78. foreach (DataRow dr in dt.Rows)
  79. mobiles += "," + dr["phone"].ToString();
  80. if (mobiles.Length > 0)
  81. mobiles = mobiles.Substring(1);
  82. txtMobiles.InnerText = mobiles;
  83. txtType.Text = "门诊随访";
  84. }
  85. //潜在客户
  86. else if (ct == "4")
  87. {
  88. //Com.Jpsoft.Hospital.BLL.Ex.SF_BRXXKEx bll = new BLL.Ex.SF_BRXXKEx();
  89. //DataTable dt = bll.GetList(" patid in(" + ids + ")");
  90. //foreach (DataRow dr in dt.Rows)
  91. // mobiles += "," + dr["lxdh "].ToString();
  92. //if (mobiles.Length > 0)
  93. // mobiles = mobiles.Substring(1);
  94. ids = ids.Replace("'", "");
  95. txtMobiles.InnerText = ids;
  96. txtType.Text = "潜在客户随访";
  97. }
  98. //体检客户
  99. else if (ct == "6")
  100. {
  101. //Com.Jpsoft.Hospital.BLL.Ex.SF_BRXXKEx bll = new BLL.Ex.SF_BRXXKEx();
  102. //DataTable dt = bll.GetList(" patid in(" + ids + ")");
  103. //foreach (DataRow dr in dt.Rows)
  104. // mobiles += "," + dr["lxdh "].ToString();
  105. //if (mobiles.Length > 0)
  106. // mobiles = mobiles.Substring(1);
  107. ids = ids.Replace("'", "");
  108. txtMobiles.InnerText = ids;
  109. txtType.Text = "体检客户随访";
  110. }
  111. else if (ct == "5")
  112. {
  113. string nums = string.Empty;
  114. Com.Jpsoft.Hospital.BLL.jp_employee_group_detailEx bll = new BLL.jp_employee_group_detailEx();
  115. DataTable dt = bll.GetListEx(" egd_group_id=" + id +" and lxdh!='' ").Tables[0];
  116. foreach (DataRow dr in dt.Rows)
  117. {
  118. nums += "," + dr["lxdh"].ToString();
  119. }
  120. if (nums.Length > 0)
  121. nums = nums.Substring(1);
  122. txtMobiles.InnerText = nums;
  123. txtType.Text = "员工短信群发";
  124. }
  125. txtTypeVal.Text = ct;
  126. txtMessage.InnerText = con;
  127. txtNextFollowUpDate.Text = next;
  128. txtUrlPass.Text = Com.Jpsoft.Hospital.Web.Common.MD5Encoding.GetMD5_Str("08526" + "yi19890211" + mobiles).ToUpper();
  129. }
  130. protected void btnSend_Click(object sender, EventArgs e)
  131. {
  132. //错误信息
  133. string errorMsg = string.Empty;
  134. //成功发送短信数
  135. string successNoteCountMsg = string.Empty;
  136. //成功发送电话数
  137. string successMobileCountMsg = string.Empty;
  138. //发送失败电话数
  139. string errorMobileCountMsg = string.Empty;
  140. System.Text.StringBuilder script = new System.Text.StringBuilder();
  141. script.Append("<script>");
  142. if (Com.Jpsoft.Hospital.Web.Common.MSG_WS.SendMsg(txtMessage.InnerText, txtMobiles.InnerText, out errorMsg, out successNoteCountMsg, out successMobileCountMsg, out errorMobileCountMsg, txtTypeVal.Text))
  143. {
  144. script.Append("alert('发送成功!成功发送短信数:" + successNoteCountMsg + ",成功发送电话数:" + successMobileCountMsg + ",发送失败电话数:" + errorMobileCountMsg + "');");
  145. }
  146. else
  147. {
  148. script.Append("alert('发送失败!原因:" + errorMsg + "');");
  149. }
  150. script.Append("history.go(-1);");
  151. script.Append("</script>");
  152. Response.Write(script.ToString());
  153. //WebClient wc = new WebClient();
  154. //wc.Encoding = Encoding.UTF8;
  155. //wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
  156. //string para = "Message=" + txtMessage.InnerText + "&Mobiles=" + txtMobiles.InnerText + "&TeacherID=08526烃&UrlPass=" + txtUrlPass.Text;
  157. //string submit = wc.UploadString("http://ejz.welsend.net/Teacher/SendMobileMSXML.asp", "POST", "Message=" + con + " Mobiles=" + mobiles + " TeacherID=08526 UrlPass=" + txtUrlPass.Text);
  158. //string result = wc.UploadString("http://localhost:1514/Module/FllowUp/MedicalQuality/SendWindow.aspx", "POST", para);
  159. //string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + "短信发送回执信息.xml";
  160. //Write(filename, result);
  161. //XmlDocument xdoc = new XmlDocument();
  162. //xdoc.LoadXml(result);
  163. //XmlNode xnode = xdoc.SelectSingleNode("result/code");
  164. //string code = xnode.InnerText;
  165. //xnode = xdoc.SelectSingleNode("result/error");
  166. //string error = xnode.InnerText;
  167. //xnode = xdoc.SelectSingleNode("result/sendResultList");
  168. //string successNoteCount = xnode.Attributes.Item(0).InnerText;
  169. //string successMobileCount = xnode.Attributes.Item(1).InnerText;
  170. //string errorMobileCount = xnode.Attributes.Item(2).InnerText;
  171. //XmlNodeList xnodes = xdoc.ChildNodes;
  172. //System.Text.StringBuilder script = new System.Text.StringBuilder();
  173. //script.Append("<script>");
  174. //if (result.IndexOf("<code>1</code>") > 0)
  175. //{
  176. // script.Append("alert('短信发送成功!')");
  177. //}
  178. //else
  179. //{
  180. // script.Append("alert('短信发送失败!原因:" + result.Substring(result.IndexOf("<error>") + 7, result.IndexOf("</error>") - result.IndexOf("<error>") - 7) + "');");
  181. //}
  182. //script.Append("</script>");
  183. //Response.Write(script);
  184. }
  185. public void Write(string filename, string text)
  186. {
  187. FileStream fs = new FileStream(Server.MapPath("~/Module/Report/Msg/") + filename, FileMode.Create);
  188. StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
  189. sw.WriteLine(text);
  190. sw.Close();
  191. fs.Close();
  192. }
  193. }
  194. }