using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace LYFZ.Software.MainBusiness.SMSManagement.SmsSend { public class frmSendMicroTemplateSMS:LYFZ.Software.UI.SMSManagement.SmsSend.frmSendMicroTemplateSMS { public frmSendMicroTemplateSMS() { this.cbxTList.SelectedIndexChanged += cbxTList_SelectedIndexChanged; this.txtTitle.EventTextBoxEx_TextChanged += txtTitle_EventTextBoxEx_TextChanged; this.txtItemName.EventTextBoxEx_TextChanged += txtTitle_EventTextBoxEx_TextChanged; this.txttiem.EventTextBoxEx_TextChanged += txtTitle_EventTextBoxEx_TextChanged; this.txtAddress.EventTextBoxEx_TextChanged += txtTitle_EventTextBoxEx_TextChanged; this.txttext.EventTextBoxEx_TextChanged += txtTitle_EventTextBoxEx_TextChanged; this.linkTitle.Click += linkTitle_Click; this.linkItemName.Click += linkItemName_Click; this.linkAddress.Click += linkAddress_Click; this.linkText.Click += linkText_Click; this.linkUrl.Click += linkUrl_Click; this.txttiem.Text = SDateTime.Now.ToString("yyyy-MM-dd HH:mm"); this.Shown += frmSendMicroTemplateSMS_Shown; this.btnclose.Click += btnclose_Click; this.btnSave.Click += btnSave_Click; BindTemplateNo(); } bool isEmployee = false; /// /// 是否为员工消息 /// public bool IsEmployee { get { return isEmployee; } set { isEmployee = value; } } LYFZ.BLL.BLL_SMSTemplates mybllsmsT = new BLL.BLL_SMSTemplates(); void btnSave_Click(object sender, EventArgs e) { if (this.lbNo.Text.Trim().Length <= 1) { MessageBoxCustom.Show("选择的消息模板还没有配置,请先配置模板后重试。"); return; } if (this.txtTitle.Text.Trim().Length <= 0) { MessageBoxCustom.Show("消息标题不能为空"); return; } if (this.txtOPENID.Text.Trim().Length <= 0) { MessageBoxCustom.Show("消息接收人OPENID不能为空"); return; } string tUrl = this.txtUrl.Text.Trim(); if (tUrl.Trim().Length>0&&!tUrl.Trim().ToLower().StartsWith("https://") && !tUrl.Trim().ToLower().StartsWith("http://")) { MessageBoxCustom.Show("消息链接URL格式不正确"); return; } string TMessageTitle = this.txtTitle.Text.Trim(); string[] OPENIDs=this.txtOPENID.Text.Trim().Trim(',').Split(','); string User_Name=LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.LoginUserModel.User_Name; dynamic tMParameters = null; switch (this.TemplateNo) { case EnumPublic.MicroTemplate.待办事项通知: if (this.txtItemName.Text.Trim().Length <= 0) { MessageBoxCustom.Show("事项名称不能为空"); return; } if (this.txttiem.Text.Trim().Length <= 0) { MessageBoxCustom.Show("时间不能为空"); return; } if (this.txttext.Text.Trim().Length <= 0) { MessageBoxCustom.Show("事项内容不能为空"); return; } tMParameters = new System.Dynamic.ExpandoObject(); tMParameters.MessageTitle = TMessageTitle; tMParameters.ItemName = this.txtItemName.Text.Trim(); tMParameters.Time = this.txttiem.Text.Trim(); tMParameters.Remark = this.txttext.Text.Trim(); break; case EnumPublic.MicroTemplate.拍摄服务提醒: if (this.txtItemName.Text.Trim().Length <= 0) { MessageBoxCustom.Show("拍摄事项不能为空"); return; } if (this.txttiem.Text.Trim().Length <= 0) { MessageBoxCustom.Show("服务时间不能为空"); return; } if (this.txtAddress.Text.Trim().Length <= 0) { MessageBoxCustom.Show("服务地点不能为空"); return; } if (this.txttext.Text.Trim().Length <= 0) { MessageBoxCustom.Show("服务内容不能为空"); return; } tMParameters = new System.Dynamic.ExpandoObject(); tMParameters.MessageTitle = TMessageTitle; tMParameters.ItemName = this.txtItemName.Text.Trim(); tMParameters.Time = this.txttiem.Text.Trim(); tMParameters.Address = this.txtAddress.Text.Trim(); tMParameters.Remark = this.txttext.Text.Trim(); break; case EnumPublic.MicroTemplate.影楼服务通知: if (this.txtItemName.Text.Trim().Length <= 0) { MessageBoxCustom.Show("服务状态不能为空"); return; } if (this.txttiem.Text.Trim().Length <= 0) { MessageBoxCustom.Show("服务时间不能为空"); return; } if (this.txtAddress.Text.Trim().Length <= 0) { MessageBoxCustom.Show("备注不能为空"); return; } tMParameters = new System.Dynamic.ExpandoObject(); tMParameters.MessageTitle = TMessageTitle; tMParameters.ServiceStatus = this.txtItemName.Text.Trim(); tMParameters.Time = this.txttiem.Text.Trim(); tMParameters.Remark = this.txtAddress.Text.Trim(); break; } tMParameters.TMessageUrl = tUrl; if (mybllsmsT.GenerateEventTemplateMessage(this.TemplateNo, OPENIDs, tMParameters, User_Name, LYFZ.Software.MainBusiness.CommonLogical.SuccessfulLogin.GetCompanyInfoID(), this.lbNo.Text.Trim(), isEmployee)) { MessageBoxCustom.Show("模板消息发送成功"); this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxCustom.Show("模板消息发送失败,请关闭后重试!"); } } void btnclose_Click(object sender, EventArgs e) { this.Close(); } void frmSendMicroTemplateSMS_Shown(object sender, EventArgs e) { this.txtOPENID.Text = receiveOPNIDs; for(int i=0;i /// 接收人的OPENID /// public string ReceiveOPNIDs { get { return receiveOPNIDs; } set { receiveOPNIDs = value; } } void linkUrl_Click(object sender, EventArgs e) { SetTxtValue(this.txtUrl); } void linkText_Click(object sender, EventArgs e) { SetTxtValue(this.txttext); } void linkAddress_Click(object sender, EventArgs e) { SetTxtValue(this.txtAddress); } void linkItemName_Click(object sender, EventArgs e) { SetTxtValue(this.txtItemName); } void linkTitle_Click(object sender, EventArgs e) { SetTxtValue(this.txtTitle); } void SetTxtValue(ComponentLibrary.TextBoxEx tbox) { frmSelectSmsInfo selectInfo = new frmSelectSmsInfo(); if (selectInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { if (selectInfo.SmsModel.ID > 0) { tbox.Text = selectInfo.SmsModel.ST_SMSContent; } } } void txtTitle_EventTextBoxEx_TextChanged(object sender, EventArgs e) { int sumCount = this.txtTitle.Text.Trim().Length + this.txtItemName.Text.Trim().Length + this.txttiem.Text.Trim().Length + this.txtAddress.Text.Trim().Length + this.txttext.Text.Trim().Length; this.lbtxtCount.Text = "已输入消息内容长度 " + sumCount.ToString() + " 个字"; } LYFZ.DAL.DAL_SMSTemplates smsDal = new DAL.DAL_SMSTemplates(); void cbxTList_SelectedIndexChanged(object sender, EventArgs e) { if (this.cbxTList.SelectedItem != null) { this.TemplateNo = (EnumPublic.MicroTemplate)Enum.Parse(typeof(EnumPublic.MicroTemplate), this.cbxTList.SelectedItem.ToString()); // this.lbtitle.Text = this.TemplateNo.ToString(); this.lbContentExamples.Text = LYFZ.BLL.BLL_SMSTemplates.GetMicroTemplateExample(this.TemplateNo); this.TemplateIDModel = (LYFZ.Model.Model_SMSTemplates)smsDal.GetModelObject("ST_Category=" + (int)this.TemplateNo + " and ST_DividedShop='" + LYFZ.BLL.BLL_ErpCompanyInfo.CurrentCompanyInfoID + "'"); this.lbNo.Text = this.TemplateIDModel.ST_Remark.Trim(); if (this.lbNo.Text.Trim().Length <= 1) { this.lbNo.Text = "没有找到相关模板"; this.lbNo.ForeColor = System.Drawing.Color.Red; } else { this.lbNo.ForeColor = this.lbtitle.ForeColor; } switch (this.TemplateNo) { case EnumPublic.MicroTemplate.待办事项通知: this.plTitle.Visible = true; this.plItemName.Visible = true; this.pltime.Visible = true; this.plAddress.Visible = false; this.plText.Visible = true; this.lbItemName.Text = "事项名称"; this.lbtime.Text = "时间"; this.lbtext.Text = "事项内容"; /* this.txtTitle.Visible = ""; this.txtItemName.Visible = true; this.txttiem.Visible = true; this.txtAddress.Visible = true; this.txttext.Visible = true;*/ break; case EnumPublic.MicroTemplate.拍摄服务提醒: this.plTitle.Visible = true; this.plItemName.Visible = true; this.pltime.Visible = true; this.plAddress.Visible = true; this.plText.Visible = true; this.lbItemName.Text = "拍摄事项"; this.lbtime.Text = "服务时间"; this.lbAddress.Text = "服务地点"; this.lbtext.Text = "服务内容"; break; case EnumPublic.MicroTemplate.影楼服务通知: this.plTitle.Visible = true; this.plItemName.Visible = true; this.pltime.Visible = true; this.plAddress.Visible = true; this.plText.Visible =false; this.lbItemName.Text = "服务状态"; this.lbtime.Text = "时间"; this.lbAddress.Text = "备注"; break; } } } LYFZ.Model.Model_SMSTemplates _TemplateIDModel = new Model.Model_SMSTemplates(); /// /// 当前模板ID对象 /// public LYFZ.Model.Model_SMSTemplates TemplateIDModel { get { return _TemplateIDModel; } set { _TemplateIDModel = value; } } /// /// 当前消息模板 /// EnumPublic.MicroTemplate _TemplateNo = EnumPublic.MicroTemplate.拍摄服务提醒; /// /// 当前消息模板 /// public EnumPublic.MicroTemplate TemplateNo { get { return _TemplateNo; } set { _TemplateNo = value; } } /// /// 默认消息模板 /// EnumPublic.MicroTemplate _DfTemplateNo = EnumPublic.MicroTemplate.拍摄服务提醒; /// /// 默认消息模板 /// public EnumPublic.MicroTemplate DfTemplateNo { get { return _DfTemplateNo; } set { _DfTemplateNo = value; } } /// /// 邦定消息模板 /// void BindTemplateNo() { this.cbxTList.Items.Clear(); this.cbxTList.DataSource = GetTemplateNoList(); } List GetTemplateNoList() { List elist = new List(); Array tValues = Enum.GetValues(typeof(LYFZ.EnumPublic.MicroTemplate)); foreach (int tValue in tValues) { if (tValue > 3000 && tValue != 3003) { LYFZ.EnumPublic.MicroTemplate mT = (LYFZ.EnumPublic.MicroTemplate)tValue; elist.Add(mT.ToString()); } } return elist; } } }