コード例 #1
0
        public IActionResult SendSms(PersonInfoReq person)
        {
            if (string.IsNullOrEmpty(person.Name))
            {
                return(Content("url-name参数错误"));
            }
            var temp = friendInfos.SingleOrDefault(u => u.urlName == person.Name);

            if (temp == null)
            {
                return(Content("无此人的信息"));
            }
            if (string.IsNullOrEmpty(temp.PhoneNo))
            {
                return(Content("此人电话号码为空"));
            }
            var result = SmsHelper.SendSms(temp.PhoneNo, temp.NameInfos[0]);

            LogHelper.Info($"短信发送结果:{result} 发给{temp.NameInfos[0]} 目标号码:{temp.PhoneNo}");
            if (result)
            {
                return(Content("success"));
            }
            return(Content("短信发送失败"));
        }
コード例 #2
0
 private void btnSendSecurityCode_Click(object sender, EventArgs e)
 {
     if ((!string.IsNullOrEmpty(txtEmailId.Text.Trim())) &&
         (!string.IsNullOrEmpty(txtMobileNo.Text.Trim())))
     {
         string statusMsg = "";
         bool   isSuccess;
         string mobileNo = txtMobileNo.Text.Trim();
         string emailId  = txtEmailId.Text.Trim();
         string code     = GenerateSecurityCode(emailId);
         txtCode.Text = code;
         try
         {
             EmailHelper.SendSecurityCode(emailId, code, out isSuccess);
             SmsHelper.SendSms("Your security code for initial setup: " + Environment.NewLine + code, mobileNo, out statusMsg);
             if (isSuccess)
             {
                 _codes.Clear();
                 _codes.AddRange(OprateSecurityCodes(emailId, code, "ADD"));
                 BindCodeData();
             }
         }
         catch (Exception ex)
         {
             Logger.LogError(ex);
         }
     }
     else
     {
         MessageBox.Show("Please enter a email");
     }
 }
コード例 #3
0
ファイル: Program.cs プロジェクト: seb999/CoinsAlert
        private static void CheckNewBinanceCoin()
        {
            using (MySqlConnection connection = new MySqlConnection(Properties.Settings.Default.DefaultConnection))
            {
                try
                {
                    AppDbContext myContext = new AppDbContext(connection, false);
                    Database.SetInitializer <AppDbContext>(null);

                    //List new currency that are not older than 10 minutes
                    DateTime       currentDay  = DateTime.Now.AddMinutes(-5);
                    List <binance> newCoinList = myContext.Binance.Where(p => DateTime.Compare(p.DateAdded, currentDay) > 0).Select(p => p).ToList();

                    if (newCoinList.Count() > 0)
                    {
                        Console.WriteLine("New coins available on Binance Exchange");

                        string mailTemplate = "";
                        string smsTemplate  = "";
                        foreach (var coin in newCoinList)
                        {
                            mailTemplate = mailTemplate + "Symbol :" + coin.binanceSymbol + "<br />Quote Asset : " + coin.binanceQuoteAsset + "<br />Base Asset : " + coin.binanceBaseAsset + "<br /><br />";
                            smsTemplate  = smsTemplate + " " + coin.binanceSymbol;
                        }
                        MailHelper.SendEmail("New coins available on Binance Exchange", mailTemplate);
                        SmsHelper.SendSms("New coins available on Binance Exchange " + smsTemplate);
                    }
                }
                catch (System.Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
コード例 #4
0
        public ActionResult GetSMS(string category, string phone, string vcode)
        {
            if (string.IsNullOrEmpty(category))
            {
                category = "Common";
            }
            if (string.Compare(vcode, (string)TempData[CaptchaImageText], StringComparison.InvariantCultureIgnoreCase) != 0)
            {
                return(Json(new { result = false, msg = "请确认验证码" }));
            }
            string code = StringHelper.GenerateRandomCode(6, true);
            string msg  = @"尊敬的用户:您本次的验证码为 {0},如非本人操作,请勿转告他人。";

            msg = string.Format(msg, code);
            SmsHelper.SendSms(phone, msg);
            Sms sms = new Sms
            {
                Phone      = phone,
                Code       = code,
                Message    = msg,
                Sender     = (CurrentUser != null) ? CurrentUser.Id : 0,
                Category   = category,
                CreateTime = DateTime.Now
            };

            sr.Create(sms);
            return(Json(new { result = true, msg = string.Empty }));
        }
コード例 #5
0
        protected void Retrimitere(object sender, EventArgs e)
        {
            var    grdrow = (GridViewRow)((LinkButton)sender).NamingContainer;
            string id     = grdrow.Cells[0].Text;

            var smsArchiveManager = new SmsArchiveManager(ConfigurationManager.ConnectionStrings["fccl_v2"].ConnectionString);
            var sms = smsArchiveManager.GetSmsById(id);

            SmsHelper.SendSms(sms);
            BindData();
        }
コード例 #6
0
        public void RunProcess(string[] args)
        {
            Logger.Info("SendSmsWorker | Sms Worker started");

            var smsArchiveManager = new SmsArchiveManager(ConfigurationManager.ConnectionStrings["fccl_v2"].ConnectionString);

            Sms sms = null;

            while ((sms = smsArchiveManager.Dequeue()) != null)
            {
                Logger.Info(string.Format("SendSmsWorker | Sending sms with Id: {0}", sms.Id));
                SmsHelper.SendSms(sms);
            }
        }
コード例 #7
0
        public void GenerateAuth(string username)
        {
            Entities.User user = Business.User.Get(username);

            if (user != null)
            {
                string random = RandomHelper.GenerateSecureRandom();

                long.TryParse(user.Properties["Mobile"].Substring(1), out long mobile);

                Guid resetToken = Business.User.SetResetToken(user.Email);

                SmsHelper.SendSms($"Your resetToken: {resetToken}", mobile);
            }
        }
コード例 #8
0
 public override void Execute(SendSmsArgs args)
 {
     SmsHelper.SendSms(args.Mobile, args.Content, args.Xh);
 }
コード例 #9
0
ファイル: UserController.cs プロジェクト: yyliuliang/farm
        public ActionResult Reg(string phone, string password, string passwordc, string vcode, string mcode, int?refCode)
        {
            if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(password))
            {
                ModelState.AddModelError("reg", "请填写手机和密码");
                return(View());
            }

            if (password != passwordc)
            {
                ModelState.AddModelError("reg", "请确认密码");
                return(View());
            }

            //string code = (string)TempData[CommonController.CaptchaImageText];
            //if (string.Compare(vcode, code, StringComparison.InvariantCultureIgnoreCase) != 0)
            //{
            //    ModelState.AddModelError("reg", "验证码错误");
            //    return View();
            //}

            if (!sr.CheckSms(phone, mcode, "Reg"))
            {
                ModelState.AddModelError("reg", "短信验证码错误");
                return(View());
            }

            if (ur.UserExists(phone))
            {
                ModelState.AddModelError("reg", "此号码系统中已存在");
                return(View());
            }

            var    user    = new User();
            User   refUser = null;
            string refPath = string.Empty;

            user.UserGuid      = Guid.NewGuid();
            user.Phone         = phone;
            user.UserName      = user.Phone;
            user.Password      = password.MD5Hash();
            user.LastLoginIP   = Request.UserIP();
            user.LastLoginTime = DateTime.Now;
            user.CreateTime    = DateTime.Now;
            if (refCode.HasValue)
            {
                refUser = ur.Get(refCode.Value);
                if (refUser != null)
                {
                    user.RefUserId = refCode.Value;
                    refPath        = refUser.RefUserPath;
                }
            }

            int uid = ur.Create(user);

            if (refUser != null)
            {
                user.RefUserPath = refPath + ";" + uid;
            }
            //else
            //{
            //    user.RefUserId = uid;
            //    user.RefUserPath = uid + ";";
            //}
            ur.Update(user);
            _Login(user, false);

            string sms = "恭喜您注册成功农场物语账号,祝您开心玩游戏,天天赚大钱。";

            SmsHelper.SendSms(user.Phone, sms);
            return(RedirectToAction("Index"));
        }
コード例 #10
0
ファイル: UnitTest1.cs プロジェクト: beyondbbk/xinquanyou
 public void TestSms()
 {
     SmsHelper.SendSms("13320911211", "Ñ");
 }