public static bool SendSMSForSO(int soSysNo, SMSType smsType) { SOInfo soInfo = SOService.GetSOInfo(soSysNo); CustomerBasicInfo customerInfo = CustomerService.GetCustomerInfo(soInfo.CustomerSysNo); string customerLanguageCode = customerInfo.LanguageCode; var sms = CommonDA.GetShipTypeSMSInfo(soInfo.ShipType.ShipTypeSysNo, smsType, null); var smsContent = sms.SMSContent; if (string.IsNullOrEmpty(smsContent)) { return(false); } string mobilePhone = string.Empty; if (!string.IsNullOrEmpty(soInfo.ReceiveCellPhone)) { mobilePhone = soInfo.ReceiveCellPhone; } else { mobilePhone = soInfo.ReceivePhone; } if (smsContent.IndexOf("SO#") != -1) { smsContent = smsContent.Replace("SO#", soInfo.SOSysNo.ToString()); } else { return(false); } return(SendSMS(mobilePhone, smsContent, SMSPriority.Normal)); }
public virtual ShipTypeSMS Load(int shipTypeSysNo, SMSType smsType, string WebChannelID) { ShipTypeSMS entity = null; DataCommand cmd = DataCommandManager.GetDataCommand("QueryShipTypeSMS"); cmd.SetParameterValue("@SMSType", smsType); cmd.SetParameterValue("@ShipTypeSysNo", shipTypeSysNo); entity = cmd.ExecuteEntity <ShipTypeSMS>(); return(entity); }
public void SendSMS(String RecipientNum, String Text, String SenderNum, bool TestOnlyDebug = false, bool Status = false, SMSType SMSType = SMSType.basicplus) { UriBuilder URL = new UriBuilder(pSMS77Gateway); var kvp = HttpUtility.ParseQueryString(string.Empty); kvp["u"] = pUsername; kvp["p"] = pPassword; kvp["to"] = RecipientNum; kvp["text"] = Text; kvp["type"] = SMSType.ToString("G"); if (TestOnlyDebug) kvp["debug"]="1"; if (Status) kvp["status"]="1"; URL.Query = kvp.ToString(); //Console.WriteLine(URL.ToString ()); bool success = false; Int32 tryCounter = 0; Int32 MaxTries = 10; while (!success) { tryCounter++; WebRequest wrGETURL; wrGETURL = WebRequest.Create(URL.ToString()); Stream objStream; objStream = wrGETURL.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(objStream); string sLine = ""; int i = 0; while (sLine != null) { i++; sLine = objReader.ReadLine(); if (sLine != null) { if (sLine.Contains("100")) success = true; } } if (tryCounter == MaxTries) { return; } } }
public RPCResult <List <EnterpriseUser> > ISMPGetEnterpriseBySMSType(SMSType smstype) { try { List <SMS.Model.EnterpriseUser> list = AccountServer.Instance.GetAccounts().Where(eu => eu.SMSType == smstype).ToList(); return(new SMS.Model.RPCResult <List <SMS.Model.EnterpriseUser> >(true, list, "")); } catch { return(new SMS.Model.RPCResult <List <SMS.Model.EnterpriseUser> >(false, null, "获取企业失败")); } }
/// <summary> /// 添加发送短信记录 /// </summary> /// <param name="appSign"></param> /// <param name="mobile"></param> /// <param name="content"></param> /// <param name="smsType"></param> /// <returns></returns> private long CreateSmsRecord(string appSign, string mobile, string content, SMSType smsType) { // 写入数据 McpSysSmsInfo sms = new McpSysSmsInfo(); sms.AppSign = appSign; sms.ReceiverNo = mobile; sms.Content = content; sms.SmsType = (int)smsType; sms.CreatedBy = "1"; sms.CreatedOn = CommonUtil.GetDBDateTime(); sms.StatusCode = (int)StatusCodeType.Valid; return(this.GetRepository <McpSysSmsInfo>().Create(sms)); }
private string GetMessage(SMSType smsType, CandidateDetail candidate) { switch (smsType) { case SMSType.SelectType: return string.Empty; case SMSType.SMS_1: return string.Format("Dear Candidate this is sms 1"); case SMSType.SMS_2: return string.Format("Dear Candidate this is sms 2"); case SMSType.SMS_3: return string.Format("Dear Candidate this is sms 3"); case SMSType.SMS_4: return string.Format("Dear {0} this is sms 4", candidate.Name); default: MessageBox.Show("Selected message type is not correct"); return string.Empty; } }
public int Send(string phone, string Content, SMSType type) { #if !FB return(0); #endif SmsSingleSenderResult result = null; try { resultMsg = ""; SmsSingleSender ssender = new SmsSingleSender(appid, appkey); result = ssender.sendWithParam("86", phone, 289735, new[] { Content }, "单身狗APP", "", ""); // 签名参数未提供或者为空时,会使用默认签名发送短信 Console.WriteLine(result); resultMsg = Newtonsoft.Json.JsonConvert.SerializeObject(result); } catch (JSONException e) { resultMsg = e.Message; Console.WriteLine(e); return(1); } catch (HTTPException e) { resultMsg = e.Message; Console.WriteLine(e); return(1); } catch (Exception e) { resultMsg = e.Message; Console.WriteLine(e); return(1); } if (result.result != 0) { resultMsg = result.errMsg; return(1); } return(0); }
public void SendSMS(String RecipientNum, String Text, String SenderNum, bool TestOnlyDebug = false, bool Status = false, SMSType SMSType = SMSType.basicplus) { UriBuilder URL = new UriBuilder(pSMS77Gateway); var kvp = HttpUtility.ParseQueryString(string.Empty); kvp["u"] = pUsername; kvp["p"] = pPassword; kvp["to"] = RecipientNum; kvp["text"] = Text; kvp["type"] = SMSType.ToString("G"); if (TestOnlyDebug) kvp["debug"]="1"; if (Status) kvp["status"]="1"; URL.Query = kvp.ToString(); Console.WriteLine(URL.ToString ()); WebRequest wrGETURL; wrGETURL = WebRequest.Create(URL.ToString()); Stream objStream; objStream = wrGETURL.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(objStream); string sLine = ""; int i = 0; while (sLine!=null) { i++; sLine = objReader.ReadLine(); if (sLine!=null) Console.WriteLine("{0}:{1}",i,sLine); } }
public virtual string GetSMSContent(string webChannelID, string languageCode, int shipTypeSysNo, SMSType Type) { ShipTypeSMS entity = ObjectFactory <ShipTypeSMSProcessor> .Instance.Load(shipTypeSysNo, Type, webChannelID); if (entity == null || entity.SMSContent == null || string.IsNullOrEmpty(entity.SMSContent.Content)) { throw new BizException(ResouceManager.GetMessageString("CUSTOMER.ShipTypeSMS", "ContentIsNull")); } return(entity.SMSContent.Content); }
public virtual ShipTypeSMS Load(int shipTypeSysNo, SMSType smsType, string WebChannelID) { return(ObjectFactory <IShipTypeSMSDA> .Instance.Load(shipTypeSysNo, smsType, WebChannelID));; }
private static void DataReceivedHandler( object sender, SerialDataReceivedEventArgs e) { SerialPort sp = (SerialPort)sender; string indata = sp.ReadExisting(); int f; //Console.Write(indata); if (indata.IndexOf("OK") > 0) { lastAT = DateTime.Now; } if (indata.IndexOf("CMGL:") > 0) { string[] delimiter = new string[] { "CMGL:" }; String[] substrings = indata.Split(delimiter, StringSplitOptions.None); foreach (string substr in substrings) { if ((substr.IndexOf(",,") != -1)) { //Console.WriteLine(substr); try { f = Convert.ToInt32(substr.IndexOf(",")); } catch { continue; } string nummes = substr.Substring(1, f - 1); int n = substr.IndexOf('\n'); string str = ""; if (n != -1) { str = substr.Substring(n + 1, substr.Length - n - 2); } else { str = substr; } n = str.IndexOf('\r'); if (n != -1) { str = str.Substring(0, n); } SMSType smsType = SMSBase.GetSMSType(str); switch (smsType) { case SMSType.SMS: SMS sms = new SMS(); SMS.Fetch(sms, ref str); Console.WriteLine(sms.Message); Console.WriteLine(sms.PhoneNumber); //string databaseName = @"C:\Users\Rootkit\Desktop\WindowsService-master\ServiceSMS\bin\Debug\readsms.db"; SQLiteConnection db = new SQLiteConnection(string.Format("Data Source={0}; Version=3;", databaseName)); SQLiteCommand Command = db.CreateCommand(); Command.CommandText = "insert into smshistory (date,tel,message,UID) values (@Date,@tel,@message,@UID)"; string customFmt = "yyyy-MM-dd HH:mm:ss"; //2016-07-01 00:00:00 Command.Parameters.AddWithValue("@Date", sms.ServiceCenterTimeStamp.ToString(customFmt)); Command.Parameters.AddWithValue("@tel", sms.PhoneNumber); Command.Parameters.AddWithValue("@message", sms.Message); Command.Parameters.AddWithValue("@UID", Convert.ToString(Guid.NewGuid())); if (sms.Message != null) { db.Open(); Command.ExecuteNonQuery(); db.Close(); } port.Write("AT+CMGD=" + nummes + "\r\n"); //Console.WriteLine(sms._phoneNumber); break; } //string nummessage = substring.Substring(1, 3); //Console.WriteLine(nummessage); } } } }
/// <summary>发送短信和邮件 /// </summary> internal void SyncSendMessage(GoodsOrderInfo goodsOrderInfo, MailType mailType, SMSType smsType, RefundmentMode refundmentMode) { }
public void LoadSMSMessages(SMSType type) { if (SMSMessages.Count > 0) { SMSMessages.Clear(); } try { string messageURI = null; switch (type) { case SMSType.Inbox: messageURI = URI_INBOX; break; case SMSType.Sent: messageURI = URI_SENT; break; case SMSType.Draft: messageURI = URI_DRAFT; break; } Android.Net.Uri inboxURI = Android.Net.Uri.Parse(messageURI); // list of required columns string[] requeridColumns = new string[] { ID, ADDRESS, BODY, PERSON, DATE }; var icursor = Application.Context.ContentResolver.Query( Android.Net.Uri.Parse(messageURI), requeridColumns, null, null, null); if (icursor == null || icursor.Count == 0) { return; } for (icursor.MoveToFirst(); !icursor.IsAfterLast; icursor.MoveToNext()) { var item = new SMSMessage(); { item.Body = icursor.GetString(icursor.GetColumnIndex(BODY)); if (item.Body == string.Empty) { item.Body = "Empty Message"; } item.contact.PhoneNumber = icursor.GetString(icursor.GetColumnIndex(ADDRESS)); if (ContactManager.GetContactByNumber(item.contact.PhoneNumber) != null) { item.contact.Name = ContactManager.GetContactByNumber(item.contact.PhoneNumber).Name; } item.SMSID = icursor.GetInt(icursor.GetColumnIndex(ID)); item.Date = icursor.GetString(icursor.GetColumnIndex(DATE)); } SMSMessages.Add(item); } icursor.Close(); } catch { } }
/// <summary> /// 发送短信 /// </summary> /// <param name="appSign"></param> /// <param name="mobile"></param> /// <param name="content"></param> /// <param name="smsType"></param> /// <returns></returns> public void SendSmsMessage(string appSign, string mobile, Dictionary <string, object> parms, string content, SMSType smsType, SmsFuncType tempType) { // 参数检查 if (string.IsNullOrWhiteSpace(appSign)) { throw new MessageException("应用标识不能为空!"); } if (string.IsNullOrWhiteSpace(mobile)) { throw new MessageException("手机号码不能为空!"); } if (parms.Count <= 0) { throw new MessageException("短信内容参数不能为空!"); } if (string.IsNullOrWhiteSpace(content)) { throw new MessageException("短信内容不能为空!"); } if (!RegexUtil.IsMobile(mobile)) { throw new MessageException(string.Format("手机号码:{0},格式不正确。" + mobile)); } var smsId = CreateSmsRecord(appSign, mobile, content, smsType); switch (smsType) { case SMSType.Bind: case SMSType.UnBind: case SMSType.GetPwd: case SMSType.ValidateCode: SmsUtil.SendValidCode(mobile, parms["code"].ToString(), TryConvertUtil.ToDecimal(parms["code_expire"], 2), tempType); break; default: break; } }
public void SendMessage(NatrajComponent natrajComponent, SMSType sMSType, string mobileNumber, string message) { throw new NotImplementedException(); }
/// <summary> /// 获取验证码 /// </summary> /// <param name="email">邮箱地址</param> /// <param name="mobile">手机号码</param> /// <returns>已有的验证码</returns> public void GetVerifyCode(string appSign, VerifyCodeType verifyCodeType, SmsFuncType tempType, string terminalSign, string email, string mobile) { // 1.校验请求参数 CheckGetUserVerifyCode(appSign, verifyCodeType, terminalSign, email, mobile); // 2.获取新验证码 string verifyCode = SingleInstance <VerifyCodeService> .Instance.BuildVerifyCode(appSign, terminalSign, email, mobile); // 3.调用发送邮件接口,发送验证码 string title = string.Empty; string content = string.Empty; EmailType emlType = EmailType.UnKnown; SMSType smsType = SMSType.UnKnown; decimal validateCodeExpire = ConfigUtil.ValidatecodeExpire / 60; switch (verifyCodeType) { case VerifyCodeType.BindEmail: { emlType = EmailType.Bind; title = "yingmei.me邮箱验证"; content = string.Format(TemplateConfigUtil.EmlDic["BindEmail"], verifyCode, validateCodeExpire); break; } case VerifyCodeType.BindMobile: { smsType = SMSType.Bind; content = string.Format(TemplateConfigUtil.EmlDic["SmsValidCode"], verifyCode, validateCodeExpire); break; } case VerifyCodeType.ModifyPwdByMobile: { smsType = SMSType.Bind; content = string.Format(TemplateConfigUtil.EmlDic["SmsValidCode"], verifyCode, validateCodeExpire); break; } case VerifyCodeType.GetPwdByMobile: { smsType = SMSType.Bind; content = string.Format(TemplateConfigUtil.EmlDic["SmsValidCode"], verifyCode, validateCodeExpire); break; } case VerifyCodeType.UpdateBindMobile: { smsType = SMSType.Bind; content = string.Format(TemplateConfigUtil.EmlDic["SmsValidCode"], verifyCode, validateCodeExpire); break; } default: { throw new MessageException("未知的验证码类型!"); } } if (!string.IsNullOrWhiteSpace(content)) { int codeType = (int)verifyCodeType; if (codeType == (int)VerifyCodeType.BindEmail) { //发送邮件(暂时没有邮件发送) //SingleInstance<EmailService>.Instance.SubmitEmail(email, title, content.ToString(), emlType); } //发送短信 if (verifyCodeType == VerifyCodeType.BindMobile || verifyCodeType == VerifyCodeType.ModifyPwdByMobile || verifyCodeType == VerifyCodeType.GetPwdByMobile || verifyCodeType == VerifyCodeType.UpdateBindMobile ) { Dictionary <string, object> parms = new Dictionary <string, object>(); parms.Add("code", verifyCode); parms.Add("code_expire", validateCodeExpire); SingleInstance <SysService> .Instance.SendSmsMessage(appSign, mobile, parms, content, smsType, tempType); } } }
/// <summary> /// 发送ISV手机验证码(只有发送验证码可用,发送其他短信不要用此接口) /// </summary> public bool SendISVMobileValCode(int tenantId, string isv, string channelId, string content, string toPhone, SMSType type, string templateMessageText) { if (string.IsNullOrEmpty(channelId)) { AppConnectLogHelper.Error(new SMSSendException("短信通道未配置")); return(false); } var smsInvokeProvider = PlatformServiceFactory <ISMSMailProvider> .Instance(); if (smsInvokeProvider == null) { AppConnectLogHelper.Error(new ESBServiceNotFoundException("SMS ESB Service Is null")); return(false); } var smsBatch = new SMSBatch(); var shortMessages = new List <ShortMessage>() { new ShortMessage() { PhoneNumber = toPhone, MessageText = content, TemplateMessageText = templateMessageText } }; var messageCollection = new MessageCollection(shortMessages.ToArray()); smsBatch.SystemId = channelId; if (tenantId == 0) { tenantId = 2; } smsBatch.TenantId = tenantId; smsBatch.TenantName = "ISV业务短信"; smsBatch.ShortMessages = messageCollection; smsBatch.UserId = 0; ArgumentHelper.IsValid(smsBatch, true); var sendInfo = smsInvokeProvider.SMS_SendSMSByTime(smsBatch); bool isSuccess = CheckResult(sendInfo); if (isSuccess) { return(true); } AppConnectLogHelper.Error("短信发送失败:" + sendInfo); return(false); }
/// <summary> /// 取得短信内容 /// </summary> /// <param name="webChannelID">渠道ID</param> /// <param name="languageCode">语言Code</param> /// <param name="shipTypeSysNo">运输方式系统编号</param> /// <param name="Type">短信类型</param> /// <returns></returns> public virtual string GetSMSContent(string webChannelID, string languageCode, int shipTypeSysNo, SMSType Type) { return(ObjectFactory <ShipTypeSMSProcessor> .Instance.GetSMSContent(webChannelID, languageCode, shipTypeSysNo, Type)); }
private static bool SendSMS(string recNum, SMSType smsType, string extendMsg, JObject param, string currentIP, out string msg) { if (string.IsNullOrWhiteSpace(recNum)) { throw new ArgumentException("手机号码不能为空"); } if (param == null) { throw new ArgumentException("参数不能为空"); } //check first bool checkSMS_Limited = _checkSMS_Business_Limit(recNum, currentIP, MessageHistorySMSType.FindPassword, out msg); if (!checkSMS_Limited) { return(false); } //测试模式 if (Global.TEST_MODEL) { return(true); } //禁用注册 if (Global.DISABLE_REGISTRATION_SMS && smsType == SMSType.Registration) { return(true); } ITopClient client = new DefaultTopClient(Global.SMS_SURL, Global.SMS_APPKEY, Global.SMS_SECRET); AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest(); req.Extend = extendMsg; req.SmsType = "normal"; req.SmsFreeSignName = "企赋HR"; req.SmsParam = param.ToString(); //req.SmsParam = "{\"code\":\"1234\",\"product\":\"alidayu\"}"; req.RecNum = recNum; if (smsType == SMSType.Registration) { req.SmsTemplateCode = "SMS_12490895"; } else if (smsType == SMSType.UserCreation) { req.SmsTemplateCode = "SMS_12615251"; } else if (smsType == SMSType.ResetPassword) { req.SmsTemplateCode = "SMS_12760018"; } else if (smsType == SMSType.FindPassword) { req.SmsTemplateCode = "SMS_12715068"; } AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req); if (rsp.IsError) { //Log msg = rsp.ErrMsg; return(false); } msg = ""; return(true); }
public int Send(string phone, SMSType type) { throw new NotImplementedException(); }
public void SendSMS(String RecipientNum, String Text, String SenderNum, bool TestOnlyDebug = false, bool Status = false, SMSType SMSType = SMSType.basicplus) { UriBuilder URL = new UriBuilder(pSMS77Gateway); var kvp = HttpUtility.ParseQueryString(string.Empty); kvp["u"] = pUsername; kvp["p"] = pPassword; kvp["to"] = RecipientNum; kvp["text"] = Text; kvp["type"] = SMSType.ToString("G"); if (TestOnlyDebug) { kvp["debug"] = "1"; } if (Status) { kvp["status"] = "1"; } URL.Query = kvp.ToString(); //Console.WriteLine(URL.ToString ()); bool success = false; Int32 tryCounter = 0; Int32 MaxTries = 10; while (!success) { tryCounter++; WebRequest wrGETURL; wrGETURL = WebRequest.Create(URL.ToString()); Stream objStream; objStream = wrGETURL.GetResponse().GetResponseStream(); StreamReader objReader = new StreamReader(objStream); string sLine = ""; int i = 0; while (sLine != null) { i++; sLine = objReader.ReadLine(); if (sLine != null) { if (sLine.Contains("100")) { success = true; } } } if (tryCounter == MaxTries) { return; } } }
public static void ConvertToSMSMessage(ref NatrajSMSLog natrajSMSLog, NatrajComponent natrajComponent, SMSType sMSType, string mobileNumber, string message) { natrajSMSLog.ComponentId = (int)natrajComponent; natrajSMSLog.Receiver = mobileNumber; natrajSMSLog.SMSMessage = message; natrajSMSLog.SMSSentTime = DateTimeHelper.GetISTDateTime(); natrajSMSLog.SMSTypeId = (int)sMSType; natrajSMSLog.SMSStatus = (int)SMSStatusId.Queue; natrajSMSLog.Sender = "9566812835"; }