123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace LYFZ.WinicSmsInterface
- {
- public partial class frmAccountInformation : LYFZ.ComponentLibrary.BaseContentsFormMain
- { // 000/lyfz/9340.8260/0.0460/70//0.2000/0.3000/0.3000/winic
- //000/用户名/余额/单价/短信字符数/签名/语音短信单价/传真短信单价/彩信单价/所属经营商
- public frmAccountInformation()
- {
- InitializeComponent();
- this.Shown += frmAccountInformation_Shown;
- this.chkOpen.Click += chkOpen_Click;
- }
- void chkOpen_Click(object sender, EventArgs e)
- {
- if (this.rdobtnSingleShot.Checked)
- {
- this.CurrentSMSAccountInformation.IsSingleOpen = this.chkOpen.Checked;
- }
- else
- {
- this.CurrentSMSAccountInformation.IsBulkOpen = this.chkOpen.Checked;
- }
- }
- /* string _Account = "";
- /// <summary>
- /// 帐号
- /// </summary>
- public string Account
- {
- get { return _Account; }
- set { _Account = value; }
- }
- string _Password = "";
- /// <summary>
- /// 密码
- /// </summary>
- public string Password
- {
- get { return _Password; }
- set { _Password = value; }
- }*/
- /// <summary>
- /// 帐号
- /// </summary>
- string Account = "";
- /// <summary>
- /// 密码
- /// </summary>
- string Password = "";
- /// <summary>
- /// 旧的帐号信息
- /// </summary>
- string oldAccountInfo = "";
- public frmAccountInformation(LYFZ.Model.Model_SMSAccountInformation sMSAccountInformation)
- :this()
- {
- this.currentSMSAccountInformation = sMSAccountInformation;
- this.skinTextBoxAccount.Text = sMSAccountInformation.SingleUid;
- this.skinTextBoxPassword.Text =sMSAccountInformation.SinglePwd;
- this.skinTextBox1.Text = sMSAccountInformation.SingleRechargeRemindbalance.ToString();
- this.skinTextBox2.Text = sMSAccountInformation.SingleRechargeRemindPhone;
- this.chkOpen.Checked = sMSAccountInformation.IsSingleOpen;
- this.nudCount.Value = sMSAccountInformation.SwitchingCondition;
- this.Account = this.skinTextBoxAccount.Text;
- this.Password = this.skinTextBoxPassword.Text;
- this.oldAccountInfo = sMSAccountInformation.SingleUid
- + sMSAccountInformation.SinglePwd
- + sMSAccountInformation.SwitchingCondition
- + sMSAccountInformation.SingleServiceNumber
- + sMSAccountInformation.SingleRechargeRemindbalance.ToString()
- + sMSAccountInformation.SingleRechargeRemindPhone
- + sMSAccountInformation.BulkUid
- + sMSAccountInformation.BulkPwd
- + sMSAccountInformation.BulkServiceNumber
- + sMSAccountInformation.BulkRechargeRemindbalance.ToString()
- + this.currentSMSAccountInformation.IsSingleOpen.ToString()
- + this.currentSMSAccountInformation.IsBulkOpen.ToString()
- + sMSAccountInformation.BulkRechargeRemindPhone;
- }
- /// <summary>
- /// 是否有更新帐号
- /// </summary>
- public bool GetIsUpdateAccount()
- {
- if (this.oldAccountInfo != (this.currentSMSAccountInformation.SingleUid
- + this.currentSMSAccountInformation.SinglePwd
- + this.currentSMSAccountInformation.SwitchingCondition
- + this.currentSMSAccountInformation.SingleServiceNumber
- + this.currentSMSAccountInformation.SingleRechargeRemindbalance.ToString()
- + this.currentSMSAccountInformation.SingleRechargeRemindPhone
- + this.currentSMSAccountInformation.BulkUid
- + this.currentSMSAccountInformation.BulkPwd
- + this.currentSMSAccountInformation.BulkServiceNumber
- + this.currentSMSAccountInformation.BulkRechargeRemindbalance.ToString()
- + this.currentSMSAccountInformation.IsSingleOpen.ToString()
- + this.currentSMSAccountInformation.IsBulkOpen.ToString()
- + this.currentSMSAccountInformation.BulkRechargeRemindPhone))
- {
- return true;
- }
- else {
- return false;
- }
- }
- LYFZ.Model.Model_SMSAccountInformation currentSMSAccountInformation = new Model.Model_SMSAccountInformation();
- /// <summary>
- /// 短信接口帐号信息
- /// </summary>
- public LYFZ.Model.Model_SMSAccountInformation CurrentSMSAccountInformation
- {
- get { return currentSMSAccountInformation; }
- set { currentSMSAccountInformation = value; }
- }
- //创建一个委托,是为访问控件服务的。
- public delegate void UpdateControls();
- void frmAccountInformation_Shown(object sender, EventArgs e)
- {
-
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- try
- {
- SmsUserInfo userinfo = WebServiceSmsInterface.GetSmsUserInfo(this.Account, this.Password);
- this.Invoke(new UpdateControls(delegate()
- {
- lab查询结果.Text = userinfo.ReturnStatus.Replace("发送", "查询");
- lb用户名.Text = userinfo.Username;
- lb余额.Text = userinfo.Balance.ToString();
- lb单价.Text = userinfo.Price.ToString();
- lb短信字符数.Text = userinfo.SMSCharacterCount.ToString();
- lb短信签名.Text = userinfo.Signatures;
- lb语音单价.Text = userinfo.VoiceMessagingPrice.ToString();
- lb彩信单价.Text = userinfo.MMSPrice.ToString();
- lb传真单价.Text = userinfo.FaxMessagingPrice.ToString();
- }));
- }
- catch (Exception ex)
- {
- this.Invoke(new UpdateControls(delegate()
- {
- lab查询结果.Text = "帐号祥情查询失败,以下为余额查询";
- lb用户名.Text = this.Account;
- lb余额.Text = HTTPSmsInterface.GetBalances(this.Account, this.Password);
- }));
- MessageBoxCustom.Show("查询帐号祥情失败," + ex.Message, backgroundWorker: backgroundWorker);
- }
- });
-
- }
- private void skinButtomQuery_Click(object sender, EventArgs e)
- {
- this.Account = this.skinTextBoxAccount.Text;
- this.Password = this.skinTextBoxPassword.Text;
- this.CurrentSMSAccountInformation.SwitchingCondition = Convert.ToInt32(this.nudCount.Value);
- if (this.rdobtnSingleShot.Checked)
- {
- this.CurrentSMSAccountInformation.SingleUid = this.skinTextBoxAccount.Text.Trim();
- this.CurrentSMSAccountInformation.SinglePwd = this.skinTextBoxPassword.Text.Trim();
- //this.CurrentSMSAccountInformation.SingleRechargeRemindbalance = Convert.ToInt32(this.skinTextBox1.Text.Trim());
- //this.CurrentSMSAccountInformation.SingleRechargeRemindPhone = this.skinTextBox2.Text.Trim();
- }
- else {
- this.CurrentSMSAccountInformation.BulkUid = this.skinTextBoxAccount.Text.Trim();
- this.CurrentSMSAccountInformation.BulkPwd = this.skinTextBoxPassword.Text.Trim();
- //this.CurrentSMSAccountInformation.BulkRechargeRemindbalance = Convert.ToInt32(this.skinTextBox1.Text.Trim());
- //this.CurrentSMSAccountInformation.BulkRechargeRemindPhone = this.skinTextBox2.Text.Trim();
- }
- frmAccountInformation_Shown(null, null);
- }
- private void skinButtomSendSms_Click(object sender, EventArgs e)
- {
- this.Account = this.skinTextBoxAccount.Text.Trim();
- this.Password = this.skinTextBoxPassword.Text.Trim();
- string RecipientPhone = this.skinTextBoxPhoneNumber.Text.Trim();
- string SMSContent = this.skinTextBoxSmsInfo.Text.Trim();
- string ErrorPhone = LYFZ.WinAPI.CustomPublicMethod.ValidationPhones(RecipientPhone,ref RecipientPhone);
- if (ErrorPhone.Length > 0)
- {
- MessageBoxCustom.Show("请求发送手机号格式不正确,以下为错误手机号:\r\n" + ErrorPhone);
- return;
- }
- string[] phones = RecipientPhone.Split(',');
- if (phones.Length > 100)
- {
- MessageBoxCustom.Show("请求发送手机号过多,一次只能同时发送给100个手机号,当前请求手机号个数:" + phones.Length);
- return;
- }
- if (SMSContent.Length > 300)
- {
- MessageBoxCustom.Show("请求发送短信长度为:" + SMSContent.Length + "个字符,测试发送短信内容超长,不能发送。");
- return;
- }
- if (SMSContent.Length <= 0)
- {
- MessageBoxCustom.Show("短信内容不能为空。");
- return;
- }
- LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
- {
- try
- {
- HTTPSmsSendReturnInfo sendInfo = HTTPSmsInterface.SendSmsMessages(this.Account, this.Password, RecipientPhone, SMSContent);//new HTTPSmsSendReturnInfo("000/Send:1/Consumption:.046/Tmoney:7982.446/sid:1029101707233851");
- try
- {
- if (sendInfo.ReturnStatus.Contains("成功"))
- {
- LYFZ.DAL.tb_SMSSendRecords smsDal = new DAL.tb_SMSSendRecords();
- LYFZ.Model.tb_SMSSendRecords smsModel = new Model.tb_SMSSendRecords();
- smsModel.SMSAccount = this.Account;
- smsModel.CustomerID = smsDal.GetSendRecordID(this.Account);
- smsModel.RecipientPhone = RecipientPhone;
- smsModel.SMSContent = SMSContent;
- smsModel.Status = SendSmsResults.SendStatus.发送成功.ToString();
- smsModel.SMSCustomerDateTime = DateTime.Now;
- smsModel.RecipientDateTime = DateTime.Now;
- smsModel.SendDateTime = DateTime.Now;
- smsModel.AgentChargeback = sendInfo.SendCount;
- smsModel.OperatorChargeback = sendInfo.SendCount;
- smsModel.AgentPrice = sendInfo.Price;
- smsModel.OperatorPrice = smsModel.AgentPrice;
- smsModel.SendLogs = sendInfo.SourceString;
- smsModel.SendFailureNumber = 0;
- smsModel.PartialFailurePhone = "";
- smsModel.WaitingToSend = "";
- smsModel.SMSInterface = "深圳吉信通";
- smsModel.CustomerQueries = "1";
- string md5Key = LYFZ.WinAPI.SDKSecurity.MD5Encrypt(smsModel.RecipientPhone + smsModel.SMSContent + smsModel.SMSCustomerDateTime);
- smsModel.MD5KEY = md5Key;
- smsDal.Add(smsModel);
- }
- }
- catch { sendInfo.ReturnStatus = "发送成功,但记录插入错误"; }
- this.Invoke(new UpdateControls(delegate()
- {
- this.labelEx发送结果.Text = sendInfo.ReturnStatus + "\r\n" + sendInfo.SourceString;
- }));
- }
- catch (Exception ex)
- {
- MessageBoxCustom.Show("发送错误," + ex.Message, backgroundWorker: backgroundWorker);
- }
- });
- }
- /* int rechargeRemindbalance = 1000;
- /// <summary>
- /// 充值提醒余额 (条)
- /// </summary>
- public int RechargeRemindbalance
- {
- get { return rechargeRemindbalance; }
- set { rechargeRemindbalance = value; }
- }
- string rechargeRemindPhone = "";
- /// <summary>
- /// 充值提醒短信接收手机号
- /// </summary>
- public string RechargeRemindPhone
- {
- get { return rechargeRemindPhone; }
- set { rechargeRemindPhone = value; }
- }*/
- private void skinButtom1_Click(object sender, EventArgs e)
- {
-
- try
- {
- //this.CurrentSMSAccountInformation.SingleRechargeRemindbalance =Convert.ToInt32(this.skinTextBox1.Text.Trim());
- // this.CurrentSMSAccountInformation.SingleRechargeRemindPhone = this.skinTextBox2.Text.Trim();
- this.CurrentSMSAccountInformation.SwitchingCondition = Convert.ToInt32(this.nudCount.Value);
- if (this.rdobtnSingleShot.Checked)
- {
- this.CurrentSMSAccountInformation.SingleRechargeRemindbalance = Convert.ToInt32(this.skinTextBox1.Text.Trim());
- this.CurrentSMSAccountInformation.SingleRechargeRemindPhone = this.skinTextBox2.Text.Trim();
- }
- else
- {
- this.CurrentSMSAccountInformation.BulkRechargeRemindbalance = Convert.ToInt32(this.skinTextBox1.Text.Trim());
- this.CurrentSMSAccountInformation.BulkRechargeRemindPhone = this.skinTextBox2.Text.Trim();
- }
- MessageBoxCustom.Show("保存成功");
- }
- catch {
- MessageBoxCustom.Show("输入信息不正确");
- }
- }
- /// <summary>
- /// 单发通道
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void rdobtnSingleShot_Click(object sender, EventArgs e)
- {
- this.skinTextBoxAccount.Text = this.CurrentSMSAccountInformation.SingleUid;
- this.skinTextBoxPassword.Text = this.CurrentSMSAccountInformation.SinglePwd;
- this.skinTextBox1.Text = this.CurrentSMSAccountInformation.SingleRechargeRemindbalance.ToString();
- this.skinTextBox2.Text = this.CurrentSMSAccountInformation.SingleRechargeRemindPhone;
- this.chkOpen.Checked = this.CurrentSMSAccountInformation.IsSingleOpen;
- skinButtomQuery_Click(sender, e);
- }
- /// <summary>
- /// 群发通单
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void rdobtnBulk_Click(object sender, EventArgs e)
- {
- this.skinTextBoxAccount.Text = this.CurrentSMSAccountInformation.BulkUid;
- this.skinTextBoxPassword.Text = this.CurrentSMSAccountInformation.BulkPwd;
- this.skinTextBox1.Text = this.CurrentSMSAccountInformation.BulkRechargeRemindbalance.ToString();
- this.skinTextBox2.Text = this.CurrentSMSAccountInformation.BulkRechargeRemindPhone;
- this.chkOpen.Checked = this.CurrentSMSAccountInformation.IsSingleOpen;
- skinButtomQuery_Click(sender, e);
- }
- }
- }
|