123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Net;
- using System.Text;
- using System.Xml;
- using System.IO;
- namespace Com.Jpsoft.Hospital.Web.Module.FllowUp.MedicalQuality
- {
- //public partial class SendMsg : System.Web.UI.Page
- public partial class SendMsg : Com.Jpsoft.Hospital.Web.Common.BasePage
- {
- protected override void OnInit(EventArgs e)
- {
- if (!IsPostBack)
- {
- base.AutoCheckRight = false;
- base.CheckRightParam = Com.Jpsoft.Hospital.Web.Common.PageFuntionType.Insert;
- }
- base.OnInit(e);
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- SetPageData();
- }
- private void SetPageData()
- {
- string ids = string.Empty;
- string con = string.Empty;
- string next = string.Empty;
- string ct = string.Empty;
- string mobiles = string.Empty;
- string id = string.Empty;
- if (Request.QueryString["ct"] != null)
- {
- ct = Request.QueryString["ct"].ToString();
- }
- if (Request.QueryString["id"] != null)
- {
- id = Request.QueryString["id"].ToString();
- }
- if (Request.QueryString["ids"] != null)
- {
- ids = Request.QueryString["ids"].ToString();
- }
- if (Request.QueryString["con"] != null)
- {
- con = Request.QueryString["con"].ToString();
- }
- if (Request.QueryString["next"] != null)
- {
- next = Request.QueryString["next"].ToString();
- }
- //住院病人
- if (ct == "1" || ct == "3")
- {
- Com.Jpsoft.Hospital.BLL.Ex.ZY_BRSYKEx bll = new BLL.Ex.ZY_BRSYKEx();
- DataTable dt = bll.GetList(" blh in(" + ids + ") and brzt!='9'");
- foreach (DataRow dr in dt.Rows)
- mobiles += "," + dr["lxrdh"].ToString();
- if (mobiles.Length > 0)
- mobiles = mobiles.Substring(1);
- txtMobiles.InnerText = mobiles;
- if (ct == "1")
- txtType.Text = "住院随访";
- else
- txtType.Text = "科研随访";
- }
- //门诊病人
- else if (ct == "2")
- {
- Com.Jpsoft.Hospital.BLL.Ex.SF_BRXXKEx bll = new BLL.Ex.SF_BRXXKEx();
- DataTable dt = bll.GetPhone(" patid in(" + ids + ")");
- foreach (DataRow dr in dt.Rows)
- mobiles += "," + dr["phone"].ToString();
- if (mobiles.Length > 0)
- mobiles = mobiles.Substring(1);
- txtMobiles.InnerText = mobiles;
- txtType.Text = "门诊随访";
- }
- //潜在客户
- else if (ct == "4")
- {
- //Com.Jpsoft.Hospital.BLL.Ex.SF_BRXXKEx bll = new BLL.Ex.SF_BRXXKEx();
- //DataTable dt = bll.GetList(" patid in(" + ids + ")");
- //foreach (DataRow dr in dt.Rows)
- // mobiles += "," + dr["lxdh "].ToString();
- //if (mobiles.Length > 0)
- // mobiles = mobiles.Substring(1);
- ids = ids.Replace("'", "");
- txtMobiles.InnerText = ids;
- txtType.Text = "潜在客户随访";
- }
- //体检客户
- else if (ct == "6")
- {
- //Com.Jpsoft.Hospital.BLL.Ex.SF_BRXXKEx bll = new BLL.Ex.SF_BRXXKEx();
- //DataTable dt = bll.GetList(" patid in(" + ids + ")");
- //foreach (DataRow dr in dt.Rows)
- // mobiles += "," + dr["lxdh "].ToString();
- //if (mobiles.Length > 0)
- // mobiles = mobiles.Substring(1);
- ids = ids.Replace("'", "");
- txtMobiles.InnerText = ids;
- txtType.Text = "体检客户随访";
- }
- else if (ct == "5")
- {
- string nums = string.Empty;
- Com.Jpsoft.Hospital.BLL.jp_employee_group_detailEx bll = new BLL.jp_employee_group_detailEx();
- DataTable dt = bll.GetListEx(" egd_group_id=" + id +" and lxdh!='' ").Tables[0];
- foreach (DataRow dr in dt.Rows)
- {
- nums += "," + dr["lxdh"].ToString();
- }
- if (nums.Length > 0)
- nums = nums.Substring(1);
- txtMobiles.InnerText = nums;
- txtType.Text = "员工短信群发";
- }
- txtTypeVal.Text = ct;
- txtMessage.InnerText = con;
- txtNextFollowUpDate.Text = next;
- txtUrlPass.Text = Com.Jpsoft.Hospital.Web.Common.MD5Encoding.GetMD5_Str("08526" + "yi19890211" + mobiles).ToUpper();
- }
- protected void btnSend_Click(object sender, EventArgs e)
- {
- //错误信息
- string errorMsg = string.Empty;
- //成功发送短信数
- string successNoteCountMsg = string.Empty;
- //成功发送电话数
- string successMobileCountMsg = string.Empty;
- //发送失败电话数
- string errorMobileCountMsg = string.Empty;
- System.Text.StringBuilder script = new System.Text.StringBuilder();
- script.Append("<script>");
- if (Com.Jpsoft.Hospital.Web.Common.MSG_WS.SendMsg(txtMessage.InnerText, txtMobiles.InnerText, out errorMsg, out successNoteCountMsg, out successMobileCountMsg, out errorMobileCountMsg, txtTypeVal.Text))
- {
- script.Append("alert('发送成功!成功发送短信数:" + successNoteCountMsg + ",成功发送电话数:" + successMobileCountMsg + ",发送失败电话数:" + errorMobileCountMsg + "');");
- }
- else
- {
- script.Append("alert('发送失败!原因:" + errorMsg + "');");
- }
- script.Append("history.go(-1);");
- script.Append("</script>");
- Response.Write(script.ToString());
- //WebClient wc = new WebClient();
- //wc.Encoding = Encoding.UTF8;
- //wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
- //string para = "Message=" + txtMessage.InnerText + "&Mobiles=" + txtMobiles.InnerText + "&TeacherID=08526烃&UrlPass=" + txtUrlPass.Text;
- //string submit = wc.UploadString("http://ejz.welsend.net/Teacher/SendMobileMSXML.asp", "POST", "Message=" + con + " Mobiles=" + mobiles + " TeacherID=08526 UrlPass=" + txtUrlPass.Text);
- //string result = wc.UploadString("http://localhost:1514/Module/FllowUp/MedicalQuality/SendWindow.aspx", "POST", para);
- //string filename = DateTime.Now.ToString("yyyyMMddhhmmss") + "短信发送回执信息.xml";
- //Write(filename, result);
- //XmlDocument xdoc = new XmlDocument();
- //xdoc.LoadXml(result);
- //XmlNode xnode = xdoc.SelectSingleNode("result/code");
- //string code = xnode.InnerText;
- //xnode = xdoc.SelectSingleNode("result/error");
- //string error = xnode.InnerText;
- //xnode = xdoc.SelectSingleNode("result/sendResultList");
- //string successNoteCount = xnode.Attributes.Item(0).InnerText;
- //string successMobileCount = xnode.Attributes.Item(1).InnerText;
- //string errorMobileCount = xnode.Attributes.Item(2).InnerText;
- //XmlNodeList xnodes = xdoc.ChildNodes;
- //System.Text.StringBuilder script = new System.Text.StringBuilder();
- //script.Append("<script>");
- //if (result.IndexOf("<code>1</code>") > 0)
- //{
- // script.Append("alert('短信发送成功!')");
- //}
- //else
- //{
- // script.Append("alert('短信发送失败!原因:" + result.Substring(result.IndexOf("<error>") + 7, result.IndexOf("</error>") - result.IndexOf("<error>") - 7) + "');");
- //}
- //script.Append("</script>");
- //Response.Write(script);
- }
- public void Write(string filename, string text)
- {
- FileStream fs = new FileStream(Server.MapPath("~/Module/Report/Msg/") + filename, FileMode.Create);
- StreamWriter sw = new StreamWriter(fs, Encoding.UTF8);
- sw.WriteLine(text);
- sw.Close();
- fs.Close();
- }
- }
- }
|